问:
Docker Error: Cannot create container for service, no such file or dir
I'm trying to install CKAN via docker-compose:
http://docs.ckan.org/en/2.8/maintaining/installing/install-from-docker-compose.html

If I try to build with:

```<code>docker-compose up -d --build
</code>```

I keep getting:

```<code>ERROR: for db  Cannot create container for service db: no such file or directory
ERROR: compose.cli.main.main: Encountered errors while bringing up the project.
</code>```

With the verbose flag I get:

```<code>compose.cli.verbose_proxy.proxy_callable: docker inspect_image <- (u'docker_db')
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.25/images/docker_db/json HTTP/1.1" 200 None
compose.cli.verbose_proxy.proxy_callable: docker inspect_image -> {u'Architecture': u'amd64',
 u'Author': u'Open Knowledge',
 u'Comment': u'',
 u'Config': {u'ArgsEscaped': True,
             u'AttachStderr': False,
             u'AttachStdin': False,
             u'AttachStdout': False,
             u'Cmd': [u'postgres'],
             u'Domainname': u'',
             u'Entrypoint': [u'docker-entrypoint.sh'],
...
compose.service.build_container_labels: Added config hash: dfb16feda9d1de6f3a84b0a6e1ecee1a8d041d06d5676351f8f723b05c4f6f03
compose.cli.verbose_proxy.proxy_callable: docker create_host_config <- (device_read_iops=None, mem_swappiness=None, links=[], oom_score_adj=None, blkio_weight=None, cpu_count=None, cpuset_cpus=None, dns_search=None, pid_mode=None, init_path=None, log_config={'Type': u'', 'Config': {}}, cpu_quota=None, read_only=None, cpu_percent=None, device_read_bps=None, storage_opt=None, init=None, dns=None, volumes_from=[], ipc_mode=None, mem_reservation=None, security_opt=None, shm_size=None, device_write_iops=None, dns_opt=None, cgroup_parent=None, group_add=None, network_mode=u'docker_default', volume_driver=None, oom_kill_disable=None, userns_mode=None, tmpfs=[], nano_cpus=None, port_bindings={}, isolation=None, memswap_limit=None, restart_policy=None, blkio_weight_device=None, devices=None, extra_hosts=None, binds=[u'docker_pg_data:/var/lib/postgresql/data:rw'], sysctls=None, pids_limit=None, device_write_bps=None, cap_add=None, mounts=None, mem_limit=None, runtime=None, cap_drop=None, privileged=False, ulimits=None, cpu_shares=None)
compose.cli.verbose_proxy.proxy_callable: docker create_host_config -> {'Binds': [u'docker_pg_data:/var/lib/postgresql/data:rw'],
 'Links': [],
 'LogConfig': {'Config': {}, 'Type': u''},
 'NetworkMode': u'docker_default',
 'PortBindings': {},
 'VolumesFrom': []}
compose.cli.verbose_proxy.proxy_callable: docker create_container <- (name='db', image=u'docker_db', labels={u'com.docker.compose.service': u'db', u'com.docker.compose.project': u'docker', u'com.docker.compose.config-hash': 'dfb16feda9d1de6f3a84b0a6e1ecee1a8d041d06d5676351f8f723b05c4f6f03', u'com.docker.compose.version': u'1.19.0', u'com.docker.compose.oneoff': u'False', u'com.docker.compose.container-number': '1'}, host_config={'NetworkMode': u'docker_default', 'Links': [], 'PortBindings': {}, 'Binds': [u'docker_pg_data:/var/lib/postgresql/data:rw'], 'LogConfig': {'Type': u'', 'Config': {}}, 'VolumesFrom': []}, environment=[u'POSTGRES_PASSWORD=uuimwc', u'DS_RO_PASS=uuimwc'], volumes={u'/var/lib/postgresql/data': {}}, detach=True, networking_config={u'EndpointsConfig': {u'docker_default': {u'IPAMConfig': {}, u'Aliases': ['db']}}})
compose.parallel.feed_queue: Pending: set([<Service: ckan>])
compose.parallel.feed_queue: Pending: set([])
Creating db ... error
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
urllib3.connectionpool._make_request: http://localhost:None "POST /v1.25/containers/create?name=db HTTP/1.1" 500 40
compose.parallel.parallel_execute_iter: Failed: ServiceName(project=u'docker', service='db', number=1)
compose.parallel.feed_queue: Pending: set([])

ERROR: for db  Cannot create container for service db: no such file or directory
compose.parallel.parallel_execute_iter: Failed: <Service: db>
compose.parallel.feed_queue: Pending: set([<Service: ckan>])
compose.parallel.feed_queue: <Service: ckan> has upstream errors - not processing
compose.parallel.parallel_execute_iter: Failed: <Service: ckan>
</code>```

Can anyone tell me how to find out what causes this?
The errors are not really meaningful it seems, how can I find out what file or directory it is missing?

答:
1.cd （your run project content)
2.then run : docker-compose down (close the server关闭服务)
3.now,you can delete it。</p>

Body:
I'm trying to install CKAN via docker-compose:
http://docs.ckan.org/en/2.8/maintaining/installing/install-from-docker-compose.html

If I try to build with:

docker-compose up -d --build

I keep getting:

ERROR: for db  Cannot create container for service db: no such file or directory
ERROR: compose.cli.main.main: Encountered errors while bringing up the project.

With the verbose flag I get:

compose.cli.verbose_proxy.proxy_callable: docker inspect_image <- (u'docker_db')
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.25/images/docker_db/json HTTP/1.1" 200 None
compose.cli.verbose_proxy.proxy_callable: docker inspect_image -> {u'Architecture': u'amd64',
 u'Author': u'Open Knowledge',
 u'Comment': u'',
 u'Config': {u'ArgsEscaped': True,
             u'AttachStderr': False,
             u'AttachStdin': False,
             u'AttachStdout': False,
             u'Cmd': [u'postgres'],
             u'Domainname': u'',
             u'Entrypoint': [u'docker-entrypoint.sh'],
...
compose.service.build_container_labels: Added config hash: dfb16feda9d1de6f3a84b0a6e1ecee1a8d041d06d5676351f8f723b05c4f6f03
compose.cli.verbose_proxy.proxy_callable: docker create_host_config <- (device_read_iops=None, mem_swappiness=None, links=[], oom_score_adj=None, blkio_weight=None, cpu_count=None, cpuset_cpus=None, dns_search=None, pid_mode=None, init_path=None, log_config={'Type': u'', 'Config': {}}, cpu_quota=None, read_only=None, cpu_percent=None, device_read_bps=None, storage_opt=None, init=None, dns=None, volumes_from=[], ipc_mode=None, mem_reservation=None, security_opt=None, shm_size=None, device_write_iops=None, dns_opt=None, cgroup_parent=None, group_add=None, network_mode=u'docker_default', volume_driver=None, oom_kill_disable=None, userns_mode=None, tmpfs=[], nano_cpus=None, port_bindings={}, isolation=None, memswap_limit=None, restart_policy=None, blkio_weight_device=None, devices=None, extra_hosts=None, binds=[u'docker_pg_data:/var/lib/postgresql/data:rw'], sysctls=None, pids_limit=None, device_write_bps=None, cap_add=None, mounts=None, mem_limit=None, runtime=None, cap_drop=None, privileged=False, ulimits=None, cpu_shares=None)
compose.cli.verbose_proxy.proxy_callable: docker create_host_config -> {'Binds': [u'docker_pg_data:/var/lib/postgresql/data:rw'],
 'Links': [],
 'LogConfig': {'Config': {}, 'Type': u''},
 'NetworkMode': u'docker_default',
 'PortBindings': {},
 'VolumesFrom': []}
compose.cli.verbose_proxy.proxy_callable: docker create_container <- (name='db', image=u'docker_db', labels={u'com.docker.compose.service': u'db', u'com.docker.compose.project': u'docker', u'com.docker.compose.config-hash': 'dfb16feda9d1de6f3a84b0a6e1ecee1a8d041d06d5676351f8f723b05c4f6f03', u'com.docker.compose.version': u'1.19.0', u'com.docker.compose.oneoff': u'False', u'com.docker.compose.container-number': '1'}, host_config={'NetworkMode': u'docker_default', 'Links': [], 'PortBindings': {}, 'Binds': [u'docker_pg_data:/var/lib/postgresql/data:rw'], 'LogConfig': {'Type': u'', 'Config': {}}, 'VolumesFrom': []}, environment=[u'POSTGRES_PASSWORD=uuimwc', u'DS_RO_PASS=uuimwc'], volumes={u'/var/lib/postgresql/data': {}}, detach=True, networking_config={u'EndpointsConfig': {u'docker_default': {u'IPAMConfig': {}, u'Aliases': ['db']}}})
compose.parallel.feed_queue: Pending: set([<Service: ckan>])
compose.parallel.feed_queue: Pending: set([])
Creating db ... error
compose.parallel.feed_queue: Pending: set([])
compose.parallel.feed_queue: Pending: set([])
urllib3.connectionpool._make_request: http://localhost:None "POST /v1.25/containers/create?name=db HTTP/1.1" 500 40
compose.parallel.parallel_execute_iter: Failed: ServiceName(project=u'docker', service='db', number=1)
compose.parallel.feed_queue: Pending: set([])

ERROR: for db  Cannot create container for service db: no such file or directory
compose.parallel.parallel_execute_iter: Failed: <Service: db>
compose.parallel.feed_queue: Pending: set([<Service: ckan>])
compose.parallel.feed_queue: <Service: ckan> has upstream errors - not processing
compose.parallel.parallel_execute_iter: Failed: <Service: ckan>

Can anyone tell me how to find out what causes this?
The errors are not really meaningful it seems, how can I find out what file or directory it is missing?


来源: stackexchange

问:
Get last datetime from from weekday() index in Python
I would like to get the most recent datetime of a weekday() index in Python. How could I do this?

Example:
Let's say today is Wednesday 02/09 (weekday index 2). Input 0 would give me datetime of last Tuesday, which is 02/07. 3 would give me datetime of last Thursday, which would be 02/03.

答:
I broke it down to small steps, of course you can combine them to fewer expressions:</p>
```<code>from datetime import date

def most_recent_date(most_recent_index):
    today = date.today()
    today_index = today.weekday()
    today_ordinal = today.toordinal()
    most_recent_ordinal = today_ordinal - (today_index - most_recent_index) % 7
    most_recent = date.fromordinal(most_recent_ordinal)
    return most_recent

print(most_recent_date(1))
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I broke it down to small steps, of course you can combine them to fewer expressions:

from datetime import date

def most_recent_date(most_recent_index):
    today = date.today()
    today_index = today.weekday()
    today_ordinal = today.toordinal()
    most_recent_ordinal = today_ordinal - (today_index - most_recent_index) % 7
    most_recent = date.fromordinal(most_recent_ordinal)
    return most_recent

print(most_recent_date(1))


问:
elasticSearch count multiple
I have two profiles, "A" and "B" both have events in the elastic

this is the elastic data for ex:

```<code> {hits: [
   {tag:"A"},
   {tag:"B"},
   {tag:B}
 ]}
</code>```

I want to count how much events tag "a" have and and how much "B" in one request

Ive tried this but it counts them total as 3 and I want A:1 and B:2

```<code>GET forensics/_count
{
"query": {
 "terms": {
   "waas_tag": ["A","B"]
 }
}
}

</code>```

答:
at the end I found a solution not using count but msearch</p>
```<code>GET forensics/_msearch
{} // this means {index:"forensics"}
{"query":{"term":{"waas_tag":"A"}}}
{} // this means {index:"forensics"}
{"query":
 {
 "bool":{
 "must":[{"term":{"waas_tag":"B"}
 },
 {
 "range":{"@timestamp":{"gte":"now-20d","lt":"now/s"}}}]}
 }
}
</code>```

Title: elasticSearch count multiple

Body:
I have two profiles, "A" and "B" both have events in the elastic

this is the elastic data for ex:

 {hits: [
   {tag:"A"},
   {tag:"B"},
   {tag:B}
 ]}

I want to count how much events tag "a" have and and how much "B" in one request

Ive tried this but it counts them total as 3 and I want A:1 and B:2

GET forensics/_count
{
"query": {
 "terms": {
   "waas_tag": ["A","B"]
 }
}
}

Body:
at the end I found a solution not using count but msearch

GET forensics/_msearch
{} // this means {index:"forensics"}
{"query":{"term":{"waas_tag":"A"}}}
{} // this means {index:"forensics"}
{"query":
 {
 "bool":{
 "must":[{"term":{"waas_tag":"B"}
 },
 {
 "range":{"@timestamp":{"gte":"now-20d","lt":"now/s"}}}]}
 }
}


问:
What is the problem with this script?
This is the fourth time I'm asking this query.

I have a contact form, that I got from the Internet, with file attachment. It's showing no error but when I tried to send mail with a file attached it didn't work.  Can you tell me what is the problem or can you suggest a good simple contact form with file attachment?  I already tried most contact forms with file attachment on the Internet but the file attachment part in most does not work.

Below is a small part of the HTML code that is part of my script.  My site is online and because of this I'm facing problems.

```<code> <form action="" method="post" name="form1" enctype="multipart/form-data">
 <input name="txtTo" type="text" id="txtTo">
 <input name="txtSubject" type="text" id="txtSubject">
 <textarea name="txtDescription" cols="30" rows="4" id="txtDescription">
 <input name="txtFormName" type="text">
  <input name="txtFormEmail" type="text">
  <input name="fileAttach" type="file">
  <input type="submit" name="Submit" value="Send">
  </form>
</code>```

php script

```<code> <?php
 if(isset($_POST["submit"])){
 $strTo = $_POST["txtTo"];
 $strSubject = $_POST["txtSubject"];
 $strMessage = nl2br($_POST["txtDescription"]);

 //*** Uniqid Session ***//
 $strSid = md5(uniqid(time()));

 $strHeader = "";
 $strHeader .= "From: ".$_POST["txtFormName"]."<".$_POST["txtFormEmail"].">\nReply-To:   ".$_POST["txtFormEmail"]."";

 $strHeader .= "MIME-Version: 1.0\n";
 $strHeader .= "Content-Type: multipart/mixed; boundary=\"".$strSid."\"\n\n";
 $strHeader .= "This is a multi-part message in MIME format.\n";

 $strHeader .= "--".$strSid."\n";
 $strHeader .= "Content-type: text/html; charset=utf-8\n";
  $strHeader .= "Content-Transfer-Encoding: 7bit\n\n";
   $strHeader .= $strMessage."\n\n";

 //*** Attachment ***//
  if($_FILES["fileAttach"]["name"] != "")
  {
  $strFilesName = $_FILES["fileAttach"]["name"];
  $strContent = chunk_split(base64_encode(file_get_contents($_FILES["fileAttach"]  ["tmp_name"])));
  $strHeader .= "--".$strSid."\n";
  $strHeader .= "Content-Type: application/octet-stream; name=\"".$strFilesName."\"\n";
  $strHeader .= "Content-Transfer-Encoding: base64\n";
  $strHeader .= "Content-Disposition: attachment; filename=\"".$strFilesName."\"\n\n";
   $strHeader .= $strContent."\n\n";
 }

 $flgSend = @mail($strTo,$strSubject,null,$strHeader);  // @ = No Show Error //

 if($flgSend)
 {
  echo "Mail send completed.";
 }
  else
 {
 echo "Cannot send mail.";
 }
 }
?>
</code>```

答:
This is my humble answer. I formatted your code a little and created a stand-alone version of it (with some simple styling^^).

Live demo: http://kopli.pri.ee/stackoverflow/6935517.php

(Please don't abuse my little mail-sending service)

In a nutshell it seems, that the $_POST["submit"] was the main issue. However, it is possible, that I fixed some other critical aspect and forgot to note it out.

NOTE: Maybe your script worked in some ways, but your e-mails providers anti-spam systems marked it as spam?! Also, if your page was not correctly encoded, then there might have been conflicts with the UTF-8 format of the email...

I would wish to give some pointers to you:

There was a critical problem with $_POST["submit"], no such input in the form.. meaning its not a valid trigger

Your <textarea> was not closed and was causing problems.

I'm using xhtml in my example, so <input>'s need to be ended with /

In <input> for PHP, you don't need have id="txtSubject" (id's are useful when dealing with JS)

There is no point of having name="" in <form>

There were some weird spaces in your PHP code. Example: $_FILES["fileAttach"]  ["tmp_name"]. That's not very correct code!

Adding . "" at the end of a string is very much pointless

Full standalone code:

```<code><?php

if (isset($_POST["submit_trigger"])) {
    $strTo = $_POST["txtTo"];
    $strSubject = $_POST["txtSubject"];
    $strMessage = nl2br($_POST["txtDescription"]);

    //*** Uniqid Session ***//
    $strSid = md5(uniqid(time()));

    $strHeader = "";
    $strHeader .= "From: " . $_POST["txtFormName"] . "<" . $_POST["txtFormEmail"] . ">\nReply-To: " . $_POST["txtFormEmail"];

    $strHeader .= "MIME-Version: 1.0\n";
    $strHeader .= "Content-Type: multipart/mixed; boundary=\"" . $strSid . "\"\n\n";
    $strHeader .= "This is a multi-part message in MIME format.\n";

    $strHeader .= "--" . $strSid . "\n";
    $strHeader .= "Content-type: text/html; charset=utf-8\n";
    $strHeader .= "Content-Transfer-Encoding: 7bit\n\n";
    $strHeader .= $strMessage . "\n\n";

    //*** Attachment ***//
    if ($_FILES["fileAttach"]["name"] != "") {
        $strFilesName = $_FILES["fileAttach"]["name"];
        $strContent = chunk_split(base64_encode(file_get_contents($_FILES["fileAttach"]["tmp_name"])));
        $strHeader .= "--" . $strSid . "\n";
        $strHeader .= "Content-Type: application/octet-stream; name=\"" . $strFilesName . "\"\n";
        $strHeader .= "Content-Transfer-Encoding: base64\n";
        $strHeader .= "Content-Disposition: attachment; filename=\"" . $strFilesName . "\"\n\n";
        $strHeader .= $strContent."\n\n";
    }

    // @ = No Show Error //
    $flgSend = @mail($strTo, $strSubject, null, $strHeader);

    if ($flgSend) {
        $posting_message = '<div class="success_message">Mail send completed :)</div>';
    } else {
        $posting_message = '<div class="error_message">Cannot send mail :(</div>';
    }
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <title>Can you tell me what is the problem with this script - Kalle H. Väravas</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <style>
        html, body {margin: 0px; padding: 0px; background: #B3D9FF;}
        label {font-weight: bold; width: 140px; display: inline-block; padding: 10px;}
        .success_message,
        .error_message {display: inline-block; padding: 2px 5px; font-weight: bold; margin-bottom: 5px;}
        .success_message {background: #A9F5AB;}
        .error_message {background: #FF8080;}
        #main_container {width: 500px; -moz-border-radius: 5px; background: #FFFFFF; margin: 20px auto; padding: 20px;}
    </style>
</head>
<body>
    <div id="main_container">
        <?php echo $posting_message; ?>
        <form action="" method="post" enctype="multipart/form-data">
            <input name="submit_trigger" value="1" type="hidden" />
            <label>To:</label><input name="txtTo" type="text" /><br />
            <label>Subject:</label><input name="txtSubject" type="text" /><br />
            <label>Message:</label><textarea name="txtDescription" cols="30" rows="4"></textarea><br />
            <label>From name:</label><input name="txtFormName" type="text" /><br />
            <label>From email</label><input name="txtFormEmail" type="text" /><br />
            <label>Attachment:</label><input name="fileAttach" type="file" /><br />
            <input type="submit" name="Submit" value="Send" /><br />
        </form>
    </div>
</body>
</html>
</code>```

ContentLicense: CC BY-SA 3.0

Title: What is the problem with this script?

Body:
This is the fourth time I'm asking this query.

I have a contact form, that I got from the Internet, with file attachment. It's showing no error but when I tried to send mail with a file attached it didn't work.  Can you tell me what is the problem or can you suggest a good simple contact form with file attachment?  I already tried most contact forms with file attachment on the Internet but the file attachment part in most does not work.

Below is a small part of the HTML code that is part of my script.  My site is online and because of this I'm facing problems.

 <form action="" method="post" name="form1" enctype="multipart/form-data">
 <input name="txtTo" type="text" id="txtTo">
 <input name="txtSubject" type="text" id="txtSubject">
 <textarea name="txtDescription" cols="30" rows="4" id="txtDescription">
 <input name="txtFormName" type="text">
  <input name="txtFormEmail" type="text">
  <input name="fileAttach" type="file">
  <input type="submit" name="Submit" value="Send">
  </form>

php script

 <?php
 if(isset($_POST["submit"])){
 $strTo = $_POST["txtTo"];
 $strSubject = $_POST["txtSubject"];
 $strMessage = nl2br($_POST["txtDescription"]);

 //*** Uniqid Session ***//
 $strSid = md5(uniqid(time()));

 $strHeader = "";
 $strHeader .= "From: ".$_POST["txtFormName"]."<".$_POST["txtFormEmail"].">\nReply-To:   ".$_POST["txtFormEmail"]."";

 $strHeader .= "MIME-Version: 1.0\n";
 $strHeader .= "Content-Type: multipart/mixed; boundary=\"".$strSid."\"\n\n";
 $strHeader .= "This is a multi-part message in MIME format.\n";

 $strHeader .= "--".$strSid."\n";
 $strHeader .= "Content-type: text/html; charset=utf-8\n";
  $strHeader .= "Content-Transfer-Encoding: 7bit\n\n";
   $strHeader .= $strMessage."\n\n";

 //*** Attachment ***//
  if($_FILES["fileAttach"]["name"] != "")
  {
  $strFilesName = $_FILES["fileAttach"]["name"];
  $strContent = chunk_split(base64_encode(file_get_contents($_FILES["fileAttach"]  ["tmp_name"])));
  $strHeader .= "--".$strSid."\n";
  $strHeader .= "Content-Type: application/octet-stream; name=\"".$strFilesName."\"\n";
  $strHeader .= "Content-Transfer-Encoding: base64\n";
  $strHeader .= "Content-Disposition: attachment; filename=\"".$strFilesName."\"\n\n";
   $strHeader .= $strContent."\n\n";
 }

 $flgSend = @mail($strTo,$strSubject,null,$strHeader);  // @ = No Show Error //

 if($flgSend)
 {
  echo "Mail send completed.";
 }
  else
 {
 echo "Cannot send mail.";
 }
 }
?>

Body:
This is my humble answer. I formatted your code a little and created a stand-alone version of it (with some simple styling^^).

Live demo: http://kopli.pri.ee/stackoverflow/6935517.php

(Please don't abuse my little mail-sending service)

In a nutshell it seems, that the $_POST["submit"] was the main issue. However, it is possible, that I fixed some other critical aspect and forgot to note it out.

NOTE: Maybe your script worked in some ways, but your e-mails providers anti-spam systems marked it as spam?! Also, if your page was not correctly encoded, then there might have been conflicts with the UTF-8 format of the email...

I would wish to give some pointers to you:

There was a critical problem with $_POST["submit"], no such input in the form.. meaning its not a valid trigger

Your <textarea> was not closed and was causing problems.

I'm using xhtml in my example, so <input>'s need to be ended with /

In <input> for PHP, you don't need have id="txtSubject" (id's are useful when dealing with JS)

There is no point of having name="" in <form>

There were some weird spaces in your PHP code. Example: $_FILES["fileAttach"]  ["tmp_name"]. That's not very correct code!

Adding . "" at the end of a string is very much pointless

Full standalone code:

<?php

if (isset($_POST["submit_trigger"])) {
    $strTo = $_POST["txtTo"];
    $strSubject = $_POST["txtSubject"];
    $strMessage = nl2br($_POST["txtDescription"]);

    //*** Uniqid Session ***//
    $strSid = md5(uniqid(time()));

    $strHeader = "";
    $strHeader .= "From: " . $_POST["txtFormName"] . "<" . $_POST["txtFormEmail"] . ">\nReply-To: " . $_POST["txtFormEmail"];

    $strHeader .= "MIME-Version: 1.0\n";
    $strHeader .= "Content-Type: multipart/mixed; boundary=\"" . $strSid . "\"\n\n";
    $strHeader .= "This is a multi-part message in MIME format.\n";

    $strHeader .= "--" . $strSid . "\n";
    $strHeader .= "Content-type: text/html; charset=utf-8\n";
    $strHeader .= "Content-Transfer-Encoding: 7bit\n\n";
    $strHeader .= $strMessage . "\n\n";

    //*** Attachment ***//
    if ($_FILES["fileAttach"]["name"] != "") {
        $strFilesName = $_FILES["fileAttach"]["name"];
        $strContent = chunk_split(base64_encode(file_get_contents($_FILES["fileAttach"]["tmp_name"])));
        $strHeader .= "--" . $strSid . "\n";
        $strHeader .= "Content-Type: application/octet-stream; name=\"" . $strFilesName . "\"\n";
        $strHeader .= "Content-Transfer-Encoding: base64\n";
        $strHeader .= "Content-Disposition: attachment; filename=\"" . $strFilesName . "\"\n\n";
        $strHeader .= $strContent."\n\n";
    }

    // @ = No Show Error //
    $flgSend = @mail($strTo, $strSubject, null, $strHeader);

    if ($flgSend) {
        $posting_message = '<div class="success_message">Mail send completed :)</div>';
    } else {
        $posting_message = '<div class="error_message">Cannot send mail :(</div>';
    }
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <title>Can you tell me what is the problem with this script - Kalle H. Väravas</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <style>
        html, body {margin: 0px; padding: 0px; background: #B3D9FF;}
        label {font-weight: bold; width: 140px; display: inline-block; padding: 10px;}
        .success_message,
        .error_message {display: inline-block; padding: 2px 5px; font-weight: bold; margin-bottom: 5px;}
        .success_message {background: #A9F5AB;}
        .error_message {background: #FF8080;}
        #main_container {width: 500px; -moz-border-radius: 5px; background: #FFFFFF; margin: 20px auto; padding: 20px;}
    </style>
</head>
<body>
    <div id="main_container">
        <?php echo $posting_message; ?>
        <form action="" method="post" enctype="multipart/form-data">
            <input name="submit_trigger" value="1" type="hidden" />
            <label>To:</label><input name="txtTo" type="text" /><br />
            <label>Subject:</label><input name="txtSubject" type="text" /><br />
            <label>Message:</label><textarea name="txtDescription" cols="30" rows="4"></textarea><br />
            <label>From name:</label><input name="txtFormName" type="text" /><br />
            <label>From email</label><input name="txtFormEmail" type="text" /><br />
            <label>Attachment:</label><input name="fileAttach" type="file" /><br />
            <input type="submit" name="Submit" value="Send" /><br />
        </form>
    </div>
</body>
</html>


问:
copy value from one column to another if condition is met in pandas
I have a dataframe:

df =

col1
Aciton1

1
A

2
B

3
C

1
C

I want to edit df, such that when the value of col1 is bigger than 1 , take the value from Action1.

So I will get:

col1
Aciton1
Previous_Aciton

1
A
Initial Action

2
B
A

3
C
B

1
C
Initial Action

答:
Use:

```<code>df = pd.DataFrame({'col1': [1,2,3], 'act1': ['A', 'B', 'C'], 'Previsou_Aciton':['G', 'H', 'I']})
temp = df[df['col1']>1].index
df['Previsou_Aciton'].loc[temp]=df.loc[[x-1 for x in temp]]['act1'].values
</code>```

input df:

the result:

Body:
Use:

df = pd.DataFrame({'col1': [1,2,3], 'act1': ['A', 'B', 'C'], 'Previsou_Aciton':['G', 'H', 'I']})
temp = df[df['col1']>1].index
df['Previsou_Aciton'].loc[temp]=df.loc[[x-1 for x in temp]]['act1'].values

input df:

the result:


问:
test element in object is empty with jest
I have this code, and the npm run test give me a problem with the coverage.
I see the coverage html and i see that my deconstruction, url='' appear in yellow.

I see the problem and i can see this:

```<code>function Team(props) {
  const { team } = props;
  const {
    url = '', //this element appear in yellow, so is not being testing.
  } = team;
  const context = useAppContext();
  const { sportEvent, protocol } = getProperties(context);
  const { arcSite, outputType } = context;
  const basePath = getBasePath(context);
  const infoTeamPicture = translateMessage({ arcSite, id: 'infoCard.infoTeamPicture', defaultMessage: 'Escudo/Bandera equipo' });
  const initPath = getInitPath(team, protocol, basePath);
  return (
    outputType === 'amp' ?
      <TeamAmp infoTeamPicture={infoTeamPicture} team={team} initPath={initPath}/>
      :
      <figure className="ext ext-ic ext-ic--team">
        <div className="ext-ic__wr" {...getDTMRegion(ACTIVITY_MAP_NAME)}>
          <a href={`${initPath}${url}`} className="ext-ic__img">
            <img
              src={`${sportEvent.host}${team.image60}`}
              alt={infoTeamPicture}
              width="80"
              height="80"
            />
          </a>
            <div className="ext-ic__inf">
                <a href={`${initPath}${url}`} title={team.shortName} className="ext-ic__tl"><span>{team.shortName}</span></a>
                <InfoList team={team} />
            </div>
            <InfoButtons protocol={protocol} info={team} initPath={initPath}/>
        </div>
        {team.competition && <Competition competition={team.competition} />}
      </figure>
  );
}
</code>```

I try to create a new test like:

```<code>it('no render url', () => {
    const specificTeams = {
      shortName: 'Real Madrid',
      country: 'España',
      url: '',
      urlTag: 'as.com/m/tag/real_madrid/a?omnil=src-app',
      image60: '/img/comunes/fotos/fichas/equipos/small/2x/1.png',
      image100: '/img/comunes/fotos/fichas/equipos/large/1.png',
      elementType: 'team',
      competition: {
        name: 'LaLiga Santander 2020/2021',
        normalized: 'primera',
        standing: [],
        nextGames: {},
      },
    };
    const instance = shallow(<Team team={specificTeams}/>);
    expect(specificTeams.url).toEqual('')
  });
</code>```

but i can not achieve that the coverage arrive to 100%.
Someone can help me to understand how to test this kind of things?
Thanks

答:
i did find a solutions that works.
In my case, i need to pass an empty object in my test, to check the empty object that is in the real code.

Just like that:

```<code>it('no render url', () => {
    const specificTeams = {
      url: '',
      },
    };
    const instance = shallow(<Team team={specificTeams}/>);
     expect(instance).toBeDefined();
  });
</code>```

The other way to do this, would be just pass the object totally empty, but sometimes the test could send you an error. An undefined message about the object.

Body:
I have this code, and the npm run test give me a problem with the coverage.
I see the coverage html and i see that my deconstruction, url='' appear in yellow.

I see the problem and i can see this:

function Team(props) {
  const { team } = props;
  const {
    url = '', //this element appear in yellow, so is not being testing.
  } = team;
  const context = useAppContext();
  const { sportEvent, protocol } = getProperties(context);
  const { arcSite, outputType } = context;
  const basePath = getBasePath(context);
  const infoTeamPicture = translateMessage({ arcSite, id: 'infoCard.infoTeamPicture', defaultMessage: 'Escudo/Bandera equipo' });
  const initPath = getInitPath(team, protocol, basePath);
  return (
    outputType === 'amp' ?
      <TeamAmp infoTeamPicture={infoTeamPicture} team={team} initPath={initPath}/>
      :

          <a href={`${initPath}${url}`} className="ext-ic__img">
            <img
              src={`${sportEvent.host}${team.image60}`}
              alt={infoTeamPicture}
              width="80"
              height="80"
            />

                <a href={`${initPath}${url}`} title={team.shortName} className="ext-ic__tl">{team.shortName}
                <InfoList team={team} />

            <InfoButtons protocol={protocol} info={team} initPath={initPath}/>

        {team.competition && <Competition competition={team.competition} />}

  );
}

I try to create a new test like:

it('no render url', () => {
    const specificTeams = {
      shortName: 'Real Madrid',
      country: 'España',
      url: '',
      urlTag: 'as.com/m/tag/real_madrid/a?omnil=src-app',
      image60: '/img/comunes/fotos/fichas/equipos/small/2x/1.png',
      image100: '/img/comunes/fotos/fichas/equipos/large/1.png',
      elementType: 'team',
      competition: {
        name: 'LaLiga Santander 2020/2021',
        normalized: 'primera',
        standing: [],
        nextGames: {},
      },
    };
    const instance = shallow(<Team team={specificTeams}/>);
    expect(specificTeams.url).toEqual('')
  });

but i can not achieve that the coverage arrive to 100%.
Someone can help me to understand how to test this kind of things?
Thanks

Body:
i did find a solutions that works.
In my case, i need to pass an empty object in my test, to check the empty object that is in the real code.

Just like that:

it('no render url', () => {
    const specificTeams = {
      url: '',
      },
    };
    const instance = shallow(<Team team={specificTeams}/>);
     expect(instance).toBeDefined();
  });

The other way to do this, would be just pass the object totally empty, but sometimes the test could send you an error. An undefined message about the object.


问:
How do you remove a model from mongoose?
I don't mean remove a document or documents. I mean remove the model entirely so that mongoose is no longer aware of it. After declaring a model I can't figure out how to make mongoose forget that model so that it could be recreated.

```<code>mongoose.model('Book', bookSchema);
mongoose.model('Book', bookSchema);
</code>```

Currently the above throws an exception.

OverwriteModelError: Cannot overwrite 'Book' model once compiled.

I'd like to be able do something like this...

```<code>mongoose.model('Book', bookSchema);
mongoose.removeModel('Book');
mongoose.model('Book', bookSchema);
</code>```

...and not get any errors. Any ideas?

答:
You can use the deleteModel method

mongoose.deleteModel(modelName);

Body:
I don't mean remove a document or documents. I mean remove the model entirely so that mongoose is no longer aware of it. After declaring a model I can't figure out how to make mongoose forget that model so that it could be recreated.

mongoose.model('Book', bookSchema);
mongoose.model('Book', bookSchema);

Currently the above throws an exception.

OverwriteModelError: Cannot overwrite 'Book' model once compiled.

I'd like to be able do something like this...

mongoose.model('Book', bookSchema);
mongoose.removeModel('Book');
mongoose.model('Book', bookSchema);

...and not get any errors. Any ideas?


问:
Import css from a file in shared module or node module in next js
My setup:
I have a mono repo with multiple NextJS app sharing component from a shared module. The apps and shared module are individual workspaces managed by npm workspace. I m using css modules and post css for my NextJS apps.

Problem:
I want to import a css file from a shared module to css files in the NextJS apps. For example, I want to do something like @import @shared/shared.css in my css file for one of my component in the NextJS app.

Solutions tried:

postcss-import - works but its weird to import css files within the shared module components from shared modules using full package name. I hear relative path root can be specified using from but not really good doc.

tried something like @import ~@shared/shared.css. My IDE actually recognizes the path and is happy but the application fails to resolve the import and errors out like this: error - ../node_modules/next/dist/compiled/css-loader/cjs.js??ruleSet[1].rules[2].oneOf[2].use[1]!../node_modules/next/dist/compiled/postcss-loader/cjs.js??ruleSet[1].rules[2].oneOf[2].use[2]!./components/common/ToastAlert/ToastAlert.module.css TypeError: Cannot destructure property 'file' of 'undefined' as it is undefined.

Thank you in advance

答:
You can use next-transpile-modules package. The way you use it

```<code>// next.config.js
const withTM = require("next-transpile-modules");
const nextConfig = {...}

module.exports = withTM(["@shared"])(nextConfig);
</code>```

Worked for me with no issues. I used rush.

Body:
You can use next-transpile-modules package. The way you use it

// next.config.js
const withTM = require("next-transpile-modules");
const nextConfig = {...}

module.exports = withTM(["@shared"])(nextConfig);

Worked for me with no issues. I used rush.


问:
How to upload multiple folders containing images on the host in Android App Studio
On the server there will be folders of the same name as Folder in the App, I send all the images in the folder under the app to the folder in the server. For example in the App with Foler A There are 10 images on the server also have a Folder A when clicking the button, it automatically sends all images under the App to the server.</p>

答:
You should get all files, and add multiple files,
Refer retrofit: retrofit</p>


问:
An exception occurred while executing a query: SQLSTATE[42883]: Undefined function: 7 ERROR: operator does not exist: json
I'm using PostgreSQL with Symfony.

I have a user table which is as below:

```<code>id | email         | roles
---------------------------------------
1  | abc@gmail.com | ["ROLE_IVM_USER"]
</code>```

The roles column is JSON type as shown above.

I want to get user list which has role of ROLE_IVM_USER using code below:

```<code>$queryBuilder
            ->andWhere(sprintf('%s.roles IN (:roles)', $rootAlias))
            ->setParameter('roles', [User::ROLE_IVM_USER]);
</code>```

which results in the below error:

```<code>An exception occurred while executing a query: SQLSTATE[42883]: Undefined function: 7 ERROR: operator does not exist: json = unknown\nLINE 1: ... u0_ WHERE u0_.organization_id = $1 AND u0_.roles IN ($2) OR...\n ^\nHINT: No operator matches the given name and argument types. You might need to add explicit type casts."
</code>```

I'm new to PostgreSQL let me know how to get users with the role of ROLE_IVM_USER

答:
Here is how I achived the desired result without using any third party lib:

```<code>$rsm = $this->createResultSetMappingBuilder('u');

        $rawQuery = sprintf(
            'SELECT %s
                    FROM public.user u
                    WHERE u.roles::jsonb ?? :role',
            $rsm->generateSelectClause()
        );

        $query = $this->getEntityManager()->createNativeQuery($rawQuery, $rsm);
        $query->setParameter('role', $role);
        return $query->getResult();
</code>```

Hope this will help someone and will save hours of investigation

Body:
I'm using PostgreSQL with Symfony.

I have a user table which is as below:

id | email         | roles
---------------------------------------
1  | abc@gmail.com | ["ROLE_IVM_USER"]

The roles column is JSON type as shown above.

I want to get user list which has role of ROLE_IVM_USER using code below:

$queryBuilder
            ->andWhere(sprintf('%s.roles IN (:roles)', $rootAlias))
            ->setParameter('roles', [User::ROLE_IVM_USER]);

which results in the below error:

An exception occurred while executing a query: SQLSTATE[42883]: Undefined function: 7 ERROR: operator does not exist: json = unknown\nLINE 1: ... u0_ WHERE u0_.organization_id = $1 AND u0_.roles IN ($2) OR...\n ^\nHINT: No operator matches the given name and argument types. You might need to add explicit type casts."

I'm new to PostgreSQL let me know how to get users with the role of ROLE_IVM_USER

Body:
Here is how I achived the desired result without using any third party lib:

$rsm = $this->createResultSetMappingBuilder('u');

        $rawQuery = sprintf(
            'SELECT %s
                    FROM public.user u
                    WHERE u.roles::jsonb ?? :role',
            $rsm->generateSelectClause()
        );

        $query = $this->getEntityManager()->createNativeQuery($rawQuery, $rsm);
        $query->setParameter('role', $role);
        return $query->getResult();

Hope this will help someone and will save hours of investigation


问:
Simple hover sub-menu disappears after reaching 3rd item
I am currently working on making a simple hover action menu (relatively straightforward and done in previous applications).

When I hover to make the menu appear, all goes well, and I can even select the first couple of elements. However, once I reach the 3rd element (located at the edge of the larger div containing the action panel) the remaining elements are behind the later elements on the page. I have tried adjusting z-value, positioning for the hover menu is absolute, the submenu is nested within an
 element, and rewritten multiple times with different html structures.

Example of HTML

```<code><div>
        <menu aria-label='action menu'>
          <li><p>{'Sort by '}<span>{sortType}</span></p>
            <menu>
              <li><a href='/'>{'Sort'}</a></li>
              <li><a href='/'>{'Sort again'}</a></li>
              <li><a href='/'>{'Sorting'}</a></li>
              <li><a href='/'>{'Sorted'}</a></li>
            </menu>
          </li>
        </menu>
      </div>
</code>```

Example of CSS:

```<code>> div {
    margin-right: 16px;
    display: flex;
    position: relative;
    flex-direction: column;
    justify-content: center;
    height: 100%;

    > menu {
      display: block;
      list-style: none;

      > li {
        width: 100%;
        position: relative;

        > menu {
          list-style: none;
          display: list-item;
          position: absolute;
          right: 0;

          > a {
            display: block;
            width: 100%;
          }
        }
      &:hover {
          > menu {
            display: list-item;
            position: absolute;
            right: 0;

            > li {
              display: block;

              > a {
                display: block;
                width: 100%;
              }
            }
          }
        }
      }
    }
  }
}
</code>```

答:
Simply use ol li OR ul li if you are trying to make navigation or navbar. Also, you should only use z-index, if nothing works. That too is complicated, and it doesn't matter what z-index you give to child, the comparison is always between the 2 html-elements that are at same level.

If your menu is contained in a div, with z-index: 1 and it has a sibling div which has z-index: 2. It will never matter what z-index: you give to children of 1st-div, whether 9999 or Whatever, till the parent itself has higher z-index, compared to its sibling or other html-elements at same level as it is. So, I won't suggest go with that approach.

Just use ol li or ul li and complete your task.

div {
  background:yellow;
  border:2px solid #000;
  margin-right:10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

ol li {list-style-type:none;}

.list-items {display:none;}

.my-list li:hover .list-items {
  display:block;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div>
  <ol class="my-list">
    <li>{'Sort by '}{sortType}
      <ol class="list-items">
        <li>{'Sort'}</li>
        <li>{'Sort again'}</li>
        <li>{'Sorting'}</li>
        <li>{'Sorted'}</li>
      </ol>
    </li>
  </ol>
</div></code>```

Body:
I am currently working on making a simple hover action menu (relatively straightforward and done in previous applications).

When I hover to make the menu appear, all goes well, and I can even select the first couple of elements. However, once I reach the 3rd element (located at the edge of the larger div containing the action panel) the remaining elements are behind the later elements on the page. I have tried adjusting z-value, positioning for the hover menu is absolute, the submenu is nested within an
 element, and rewritten multiple times with different html structures.

Example of HTML

        <menu aria-label='action menu'>

{'Sort by '}{sortType}

            <menu>

{'Sort'}

{'Sort again'}

{'Sorting'}

{'Sorted'}

            </menu>

        </menu>

Example of CSS:

> div {
    margin-right: 16px;
    display: flex;
    position: relative;
    flex-direction: column;
    justify-content: center;
    height: 100%;

    > menu {
      display: block;
      list-style: none;

      > li {
        width: 100%;
        position: relative;

        > menu {
          list-style: none;
          display: list-item;
          position: absolute;
          right: 0;

          > a {
            display: block;
            width: 100%;
          }
        }
      &:hover {
          > menu {
            display: list-item;
            position: absolute;
            right: 0;

            > li {
              display: block;

              > a {
                display: block;
                width: 100%;
              }
            }
          }
        }
      }
    }
  }
}

Body:
Simply use ol li OR ul li if you are trying to make navigation or navbar. Also, you should only use z-index, if nothing works. That too is complicated, and it doesn't matter what z-index you give to child, the comparison is always between the 2 html-elements that are at same level.

If your menu is contained in a div, with z-index: 1 and it has a sibling div which has z-index: 2. It will never matter what z-index: you give to children of 1st-div, whether 9999 or Whatever, till the parent itself has higher z-index, compared to its sibling or other html-elements at same level as it is. So, I won't suggest go with that approach.

Just use ol li or ul li and complete your task.

div {
  background:yellow;
  border:2px solid #000;
  margin-right:10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

ol li {list-style-type:none;}

.list-items {display:none;}

.my-list li:hover .list-items {
  display:block;
}

<div>
  <ol class="my-list">
    <li>{'Sort by '}{sortType}
      <ol class="list-items">
        <li><a href='/'>{'Sort'}</a></li>
        <li><a href='/'>{'Sort again'}</a></li>
        <li><a href='/'>{'Sorting'}</a></li>
        <li><a href='/'>{'Sorted'}</a></li>
      </ol>
    </li>
  </ol>
</div>


问:
How to add support for larger android screens (21:9)?
I found an open source app that doesn't scale up on my big screen of aspect ratio (21:9) and it just stays (16:9) size. So my question is how do I can support bigger screens?

I've really tried to find an answer on Google but I'm a beginner and I couldn't really find a workable solution.

答:
The right approach to this is using consrait layout and using match constraints easily.

However, for a simpler solution, you can use this library

```<code>dependencies {
  implementation 'com.intuit.sdp:sdp-android:1.0.6'
 implementation 'com.intuit.ssp:ssp-android:1.0.6'
}
</code>```

This library uses scalable dp for the design once and adjust to the screensize automatically

Sdp library

Body:
The right approach to this is using consrait layout and using match constraints easily.

However, for a simpler solution, you can use this library

dependencies {
  implementation 'com.intuit.sdp:sdp-android:1.0.6'
 implementation 'com.intuit.ssp:ssp-android:1.0.6'
}

This library uses scalable dp for the design once and adjust to the screensize automatically

Sdp library


问:
Couchbase with Azure Linux VM
I installed ubuntu server VM on Azure there I installed couchbase community edition on  now i need to access the couchbase using dotnet SDK  but code gives me bucket not found or unreachable error.
even i try configuring a public dns and gave it as ip during cluster creation but still its giving the same.
even i added public dns to the host file like below
127.0.0.1 public dns
The SDK log includes below 2 statements
Attempted bootstrapping on endpoint "name.eastus.cloudapp.azure.com" has failed. (e80489ed)
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

SDK Doctor Log:

```<code>09:51:20.331 INFO ▶ Parsing connection string `couchbases://hsotname.eastus.cloudapp.azure.com/travel-sample`
09:51:20.334 INFO ▶ Connection string was parsed as a potential DNS SRV record
09:51:31.316 INFO ▶ Connection string specifies to use secured connections
09:51:31.316 INFO ▶ Connection string identifies the following CCCP endpoints:
09:51:31.316 INFO ▶   1. hsotname.eastus.cloudapp.azure.com:11207
09:51:31.316 INFO ▶ Connection string identifies the following HTTP endpoints:
09:51:31.316 INFO ▶   1. hsotname.eastus.cloudapp.azure.com:18091
09:51:31.316 INFO ▶ Connection string specifies bucket `travel-sample`
09:51:31.316 WARN ▶ No certificate authority file specified (--tls-ca), skipping server certificate verification for this run.
09:51:42.453 WARN ▶ Your connection string specifies only a single host.  You should consider adding additional static nodes from your cluster to this list to improve your applications fault-tolerance
09:51:42.462 INFO ▶ Performing DNS lookup for host `hsotname.eastus.cloudapp.azure.com`
09:51:42.462 INFO ▶ Bootstrap host `hsotname.eastus.cloudapp.azure.com` refers to a server with the address `13.82.80.55`
09:51:42.462 INFO ▶ Attempting to connect to cluster via CCCP
09:51:42.463 INFO ▶ Attempting to fetch config via cccp from `hsotname.eastus.cloudapp.azure.com:11207`
09:51:44.474 ERRO ▶ Failed to fetch configuration via cccp from `hsotname.eastus.cloudapp.azure.com:11207` (error: dial tcp 13.82.80.55:11207: i/o timeout)
09:51:44.474 INFO ▶ Attempting to connect to cluster via HTTP (Terse)
09:51:44.474 INFO ▶ Attempting to fetch terse config via http from `hsotname.eastus.cloudapp.azure.com:18091`
09:51:46.480 ERRO ▶ Failed to fetch terse configuration via http from `hsotname.eastus.cloudapp.azure.com:18091` (error: Get "http://hsotname.eastus.cloudapp.azure.com:18091/pools/default/b/travel-sample": context deadline exceeded (Client.Timeout exceeded while awaiting headers))
09:51:46.480 INFO ▶ Attempting to connect to cluster via HTTP (Full)
09:51:46.480 INFO ▶ Failed to connect via HTTP (Full), as it is not yet supported by the doctor
09:51:46.481 INFO ▶ Selected the following network type:
09:51:46.481 ERRO ▶ All endpoints specified by your connection string were unreachable, further cluster diagnostics are not possible
09:51:46.481 INFO ▶ Diagnostics completed

Summary:
←[33m[WARN]←[0m No certificate authority file specified (--tls-ca), skipping server certificate verification for this run.
←[33m[WARN]←[0m Your connection string specifies only a single host.  You should consider adding additional static nodes from your cluster to this list to improve your applications fault-tolerance
←[31m[ERRO]←[0m Failed to fetch configuration via cccp from `hsotname.eastus.cloudapp.azure.com:11207` (error: dial tcp 13.82.80.55:11207: i/o timeout)
←[31m[ERRO]←[0m Failed to fetch terse configuration via http from `hsotname.eastus.cloudapp.azure.com:18091` (error: Get "http://hsotname.eastus.cloudapp.azure.com:18091/pools/default/b/travel-sample": context deadline exceeded (Client.Timeout exceeded while awaiting headers))
←[31m[ERRO]←[0m All endpoints specified by your connection string were unreachable, further cluster diagnostics are not possible

Found multiple issues, see listing above.
</code>```

Both 18091 and 11207 port i added as inbound rule.
my ufw status is inactive
The above mentioned 2 ports are not listening

couchbaseadm@couchbasedbserver:~$ sudo lsof -i -P -n | grep LISTEN

```<code>systemd-r   926 systemd-resolve   13u  IPv4   18715      0t0  TCP 127.0.0.53:53 (LISTEN)
sshd       1103            root    3u  IPv4   21086      0t0  TCP *:22 (LISTEN)
sshd       1103            root    4u  IPv6   21088      0t0  TCP *:22 (LISTEN)
beam.smp   6323       couchbase   17u  IPv4 3937812      0t0  TCP 127.0.0.1:21200 (LISTEN)
epmd       6354       couchbase    3u  IPv4 3937267      0t0  TCP *:4369 (LISTEN)
epmd       6354       couchbase    4u  IPv6 3937268      0t0  TCP *:4369 (LISTEN)
beam.smp   6465       couchbase   34u  IPv4 3943391      0t0  TCP *:21100 (LISTEN)
beam.smp   6465       couchbase   48u  IPv4 3938657      0t0  TCP *:8091 (LISTEN)
beam.smp   6514       couchbase   17u  IPv4 3938608      0t0  TCP 127.0.0.1:21300 (LISTEN)
beam.smp   6514       couchbase   27u  IPv4 3938628      0t0  TCP *:8092 (LISTEN)
prometheu  6563       couchbase    9u  IPv4 3938650      0t0  TCP 127.0.0.1:9123 (LISTEN)
goxdcr     6583       couchbase   11u  IPv4 3938705      0t0  TCP 127.0.0.1:9998 (LISTEN)
memcached  6592       couchbase    5u  IPv4 3938689      0t0  TCP 127.0.0.1:11280 (LISTEN)
memcached  6592       couchbase   12u  IPv4 3937931      0t0  TCP *:11210 (LISTEN)
memcached  6592       couchbase   13u  IPv4 3937932      0t0  TCP *:11209 (LISTEN)
memcached  6592       couchbase   14u  IPv6 3937933      0t0  TCP *:11210 (LISTEN)
memcached  6592       couchbase   15u  IPv6 3937934      0t0  TCP *:11209 (LISTEN)
indexer    6741       couchbase   16u  IPv4 3944492      0t0  TCP *:9101 (LISTEN)
indexer    6741       couchbase   19u  IPv4 3944066      0t0  TCP *:9100 (LISTEN)
indexer    6741       couchbase   20u  IPv4 3944500      0t0  TCP *:9102 (LISTEN)
indexer    6741       couchbase   69u  IPv4 3946013      0t0  TCP *:9105 (LISTEN)
projector  6762       couchbase    9u  IPv4 3944075      0t0  TCP *:9999 (LISTEN)
cbq-engin  6782       couchbase    7u  IPv6 3944534      0t0  TCP *:8093 (LISTEN)
cbq-engin  6782       couchbase    8u  IPv4 3944535      0t0  TCP *:8093 (LISTEN)
cbft       6799       couchbase    8u  IPv4 3944112      0t0  TCP *:9130 (LISTEN)
cbft       6799       couchbase    9u  IPv4 3944149      0t0  TCP *:8094 (LISTEN)
sync_gate 11950    sync_gateway    8u  IPv4 4119414      0t0  TCP 127.0.0.1:4985 (LISTEN)
sync_gate 11950    sync_gateway    9u  IPv6 4119422      0t0  TCP *:4984 (LISTEN)
</code>```

Here is the stacktrace:

```<code>StackTrace " at Couchbase.Core.ClusterContext.d__58.MoveNext()\r\n
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n
at System.Threading.Tasks.ValueTask1.get_Result()\r\n at System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable1.ConfiguredValueTaskAwaiter.GetResult()\r\n
at Couchbase.Cluster.<>c__DisplayClass30_0.<b__0>d.MoveNext()\r\n
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n
at System.Threading.Tasks.ValueTask1.get_Result()\r\n at System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable1.ConfiguredValueTaskAwaiter.GetResult()\r\n
</code>```

Dotnet SDK Log

```<code>2022-02-09T17:28:46.3409884+05:30  [DBG] Waiting for 00:00:02.5000000 before polling. (c8639b24)
2022-02-09T17:28:48.8643285+05:30  [DBG] Done waiting, polling... (93018145)
2022-02-09T17:28:48.8649060+05:30  [DBG] Waiting for 00:00:02.5000000 before polling. (c8639b24)
2022-02-09T17:28:51.3664735+05:30  [DBG] Done waiting, polling... (93018145)
2022-02-09T17:28:51.3667541+05:30  [DBG] Waiting for 00:00:02.5000000 before polling. (c8639b24)
2022-02-09T17:28:53.8811651+05:30  [DBG] Done waiting, polling... (93018145)
2022-02-09T17:28:53.8814100+05:30  [DBG] Waiting for 00:00:02.5000000 before polling. (c8639b24)
2022-02-09T17:28:56.3823825+05:30  [DBG] Done waiting, polling... (93018145)
2022-02-09T17:28:56.3826183+05:30  [DBG] Waiting for 00:00:02.5000000 before polling. (c8639b24)
2022-02-09T17:28:58.8964320+05:30  [DBG] Done waiting, polling... (93018145)
2022-02-09T17:28:58.8967224+05:30  [DBG] Waiting for 00:00:02.5000000 before polling. (c8639b24)
2022-02-09T17:29:01.4007664+05:30  [DBG] Done waiting, polling... (93018145)
2022-02-09T17:29:01.4010274+05:30  [DBG] Waiting for 00:00:02.5000000 before polling. (c8639b24)
2022-02-09T17:29:01.7019750+05:30  [INF] Error trying to retrieve DNS SRV entries. (addddf06)
DnsClient.DnsResponseException: Query 12389 => _couchbases._tcp.hsotname.eastus.cloudapp.azure.com IN SRV on 192.168.8.1:53 timed out or is a transient error.
 ---> System.OperationCanceledException: The operation was canceled.
   at System.Threading.Tasks.TaskExtensions.WithCancellation[T](Task`1 task, CancellationToken cancellationToken, Action onCancel)
   at DnsClient.LookupClient.ResolveQueryAsync(IReadOnlyList`1 servers, DnsQuerySettings settings, DnsMessageHandler handler, DnsRequestMessage request, LookupClientAudit audit, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at DnsClient.LookupClient.ResolveQueryAsync(IReadOnlyList`1 servers, DnsQuerySettings settings, DnsMessageHandler handler, DnsRequestMessage request, LookupClientAudit audit, CancellationToken cancellationToken)
   at DnsClient.LookupClient.QueryInternalAsync(DnsQuestion question, DnsQuerySettings queryOptions, IReadOnlyCollection`1 servers, CancellationToken cancellationToken)
   at Couchbase.DnsClientDnsResolver.GetDnsSrvEntriesAsync(Uri bootstrapUri, CancellationToken cancellationToken)
   at Couchbase.Core.ClusterContext.BootstrapGlobalAsync()
2022-02-09T17:29:01.7034867+05:30  [DBG] Bootstrapping with node "hsotname.eastus.cloudapp.azure.com" (98ca0e33)
2022-02-09T17:29:03.9124149+05:30  [DBG] Done waiting, polling... (93018145)
2022-02-09T17:29:03.9127285+05:30  [DBG] Waiting for 00:00:02.5000000 before polling. (c8639b24)
2022-02-09T17:29:06.4201295+05:30  [DBG] Done waiting, polling... (93018145)
2022-02-09T17:29:06.4205385+05:30  [DBG] Waiting for 00:00:02.5000000 before polling. (c8639b24)
2022-02-09T17:29:08.9317820+05:30  [DBG] Done waiting, polling... (93018145)
2022-02-09T17:29:08.9320832+05:30  [DBG] Waiting for 00:00:02.5000000 before polling. (c8639b24)
2022-02-09T17:29:11.4459313+05:30  [DBG] Done waiting, polling... (93018145)
2022-02-09T17:29:11.4463142+05:30  [DBG] Waiting for 00:00:02.5000000 before polling. (c8639b24)
2022-02-09T17:29:12.1488979+05:30  [DBG] Attempted bootstrapping on endpoint "hsotname.eastus.cloudapp.azure.com" has failed. (e80489ed)
System.Net.Sockets.SocketException (10060): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
   at Couchbase.Core.IO.Connections.ConnectionFactory.CreateAndConnectAsync(HostEndpointWithPort hostEndpoint, CancellationToken cancellationToken)
   at Couchbase.Core.IO.Connections.ConnectionPoolBase.CreateConnectionAsync(CancellationToken cancellationToken)
   at Couchbase.Core.IO.Connections.DataFlow.DataFlowConnectionPool.<>c__DisplayClass30_0.<<AddConnectionsAsync>g__StartConnection|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Couchbase.Core.IO.Connections.DataFlow.DataFlowConnectionPool.AddConnectionsAsync(Int32 count, CancellationToken cancellationToken)
   at Couchbase.Core.IO.Connections.DataFlow.DataFlowConnectionPool.InitializeAsync(CancellationToken cancellationToken)
   at Couchbase.Core.ClusterNode.InitializeAsync()
   at Couchbase.Core.DI.ClusterNodeFactory.CreateAndConnectAsync(HostEndpointWithPort endPoint, BucketType bucketType, NodeAdapter nodeAdapter, CancellationToken cancellationToken)
   at Couchbase.Core.ClusterContext.BootstrapGlobalAsync()
2022-02-09T17:29:33.3259787+05:30  [DBG] Done waiting, polling... (93018145)
2022-02-09T17:29:33.3262710+05:30  [DBG] Waiting for 00:00:02.5000000 before polling. (c8639b24)
2022-02-09T17:29:35.8341848+05:30  [DBG] Done waiting, polling... (93018145)
2022-02-09T17:29:35.8343993+05:30  [DBG] Waiting for 00:00:02.5000000 before polling. (c8639b24)
2022-02-09T17:29:36.9552318+05:30  [DBG] Setting TCP Keep-Alives using SocketOptions - enable keep-alives True, time 00:01:00, interval 00:00:01. (d66a37aa)
2022-02-09T17:29:36.9596725+05:30  [DBG] Setting TCP Keep-Alives using SocketOptions - enable keep-alives True, time 00:01:00, interval 00:00:01. (d66a37aa)
2022-02-09T17:29:37.0170984+05:30  [INF] Cannot bootstrap bucket "travel-sample" as Couchbase. (1ecb21a9)
System.IO.IOException: The operation is not allowed on non-connected sockets.
   at System.Net.Sockets.NetworkStream..ctor(Socket socket, FileAccess access, Boolean ownsSocket)
   at Couchbase.Core.IO.Connections.ConnectionFactory.CreateAndConnectAsync(HostEndpointWithPort hostEndpoint, CancellationToken cancellationToken)
   at Couchbase.Core.IO.Connections.ConnectionPoolBase.CreateConnectionAsync(CancellationToken cancellationToken)
   at Couchbase.Core.IO.Connections.DataFlow.DataFlowConnectionPool.<>c__DisplayClass30_0.<<AddConnectionsAsync>g__StartConnection|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Couchbase.Core.IO.Connections.DataFlow.DataFlowConnectionPool.AddConnectionsAsync(Int32 count, CancellationToken cancellationToken)
   at Couchbase.Core.IO.Connections.DataFlow.DataFlowConnectionPool.InitializeAsync(CancellationToken cancellationToken)
   at Couchbase.Core.ClusterNode.InitializeAsync()
   at Couchbase.Core.DI.ClusterNodeFactory.CreateAndConnectAsync(HostEndpointWithPort endPoint, BucketType bucketType, NodeAdapter nodeAdapter, CancellationToken cancellationToken)
   at Couchbase.Core.ClusterContext.CreateAndBootStrapBucketAsync(String name, HostEndpointWithPort endpoint, BucketType type)
   at Couchbase.Core.ClusterContext.GetOrCreateBucketAsync(String name)
2022-02-09T17:29:38.3360012+05:30  [DBG] Done waiting, polling... (93018145)
2022-02-09T17:29:38.3361875+05:30  [DBG] Waiting for 00:00:02.5000000 before polling. (c8639b24)
2022-02-09T17:29:40.3244490+05:30  [DBG] Setting TCP Keep-Alives using SocketOptions - enable keep-alives True, time 00:01:00, interval 00:00:01. (d66a37aa)
2022-02-09T17:29:40.3507801+05:30  [DBG] Setting TCP Keep-Alives using SocketOptions - enable keep-alives True, time 00:01:00, interval 00:00:01. (d66a37aa)
2022-02-09T17:29:40.3525230+05:30  [INF] Cannot bootstrap bucket "travel-sample" as Memcached. (1ecb21a9)
System.IO.IOException: The operation is not allowed on non-connected sockets.
   at System.Net.Sockets.NetworkStream..ctor(Socket socket, FileAccess access, Boolean ownsSocket)
   at Couchbase.Core.IO.Connections.ConnectionFactory.CreateAndConnectAsync(HostEndpointWithPort hostEndpoint, CancellationToken cancellationToken)
   at Couchbase.Core.IO.Connections.ConnectionPoolBase.CreateConnectionAsync(CancellationToken cancellationToken)
   at Couchbase.Core.IO.Connections.DataFlow.DataFlowConnectionPool.<>c__DisplayClass30_0.<<AddConnectionsAsync>g__StartConnection|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Couchbase.Core.IO.Connections.DataFlow.DataFlowConnectionPool.AddConnectionsAsync(Int32 count, CancellationToken cancellationToken)
   at Couchbase.Core.IO.Connections.DataFlow.DataFlowConnectionPool.InitializeAsync(CancellationToken cancellationToken)
   at Couchbase.Core.ClusterNode.InitializeAsync()
   at Couchbase.Core.DI.ClusterNodeFactory.CreateAndConnectAsync(HostEndpointWithPort endPoint, BucketType bucketType, NodeAdapter nodeAdapter, CancellationToken cancellationToken)
   at Couchbase.Core.ClusterContext.CreateAndBootStrapBucketAsync(String name, HostEndpointWithPort endpoint, BucketType type)
   at Couchbase.Core.ClusterContext.GetOrCreateBucketAsync(String name)
2022-02-09T17:29:40.8385667+05:30  [DBG] Done waiting, polling... (93018145)
2022-02-09T17:29:40.8387609+05:30  [DBG] Waiting for 00:00:02.5000000 before polling. (c8639b24)
2022-02-09T17:29:43.3380840+05:30  [DBG] Done waiting, polling... (93018145)
2022-02-09T17:29:43.3382393+05:30  [DBG] Waiting for 00:00:02.5000000 before polling. (c8639b24)
2022-02-09T17:29:43.6633010+05:30  [DBG] Setting TCP Keep-Alives using SocketOptions - enable keep-alives True, time 00:01:00, interval 00:00:01. (d66a37aa)
2022-02-09T17:29:43.6842924+05:30  [DBG] Setting TCP Keep-Alives using SocketOptions - enable keep-alives True, time 00:01:00, interval 00:00:01. (d66a37aa)
2022-02-09T17:29:43.6862758+05:30  [INF] Cannot bootstrap bucket "travel-sample" as Ephemeral. (1ecb21a9)
System.IO.IOException: The operation is not allowed on non-connected sockets.
   at System.Net.Sockets.NetworkStream..ctor(Socket socket, FileAccess access, Boolean ownsSocket)
   at Couchbase.Core.IO.Connections.ConnectionFactory.CreateAndConnectAsync(HostEndpointWithPort hostEndpoint, CancellationToken cancellationToken)
   at Couchbase.Core.IO.Connections.ConnectionPoolBase.CreateConnectionAsync(CancellationToken cancellationToken)
   at Couchbase.Core.IO.Connections.DataFlow.DataFlowConnectionPool.<>c__DisplayClass30_0.<<AddConnectionsAsync>g__StartConnection|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Couchbase.Core.IO.Connections.DataFlow.DataFlowConnectionPool.AddConnectionsAsync(Int32 count, CancellationToken cancellationToken)
   at Couchbase.Core.IO.Connections.DataFlow.DataFlowConnectionPool.InitializeAsync(CancellationToken cancellationToken)
   at Couchbase.Core.ClusterNode.InitializeAsync()
   at Couchbase.Core.DI.ClusterNodeFactory.CreateAndConnectAsync(HostEndpointWithPort endPoint, BucketType bucketType, NodeAdapter nodeAdapter, CancellationToken cancellationToken)
   at Couchbase.Core.ClusterContext.CreateAndBootStrapBucketAsync(String name, HostEndpointWithPort endpoint, BucketType type)
   at Couchbase.Core.ClusterContext.GetOrCreateBucketAsync(String name)
</code>```

Thanks!!

答:
I resolve the issue by changing the connection string for couchbase

from

```<code>couchbase://
</code>```

to

```<code>http://
</code>```

Title: Couchbase with Azure Linux VM

Body:
I installed ubuntu server VM on Azure there I installed couchbase community edition on  now i need to access the couchbase using dotnet SDK  but code gives me bucket not found or unreachable error.
even i try configuring a public dns and gave it as ip during cluster creation but still its giving the same.
even i added public dns to the host file like below
127.0.0.1 public dns
The SDK log includes below 2 statements
Attempted bootstrapping on endpoint "name.eastus.cloudapp.azure.com" has failed. (e80489ed)
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

SDK Doctor Log:

09:51:20.331 INFO ▶ Parsing connection string `couchbases://hsotname.eastus.cloudapp.azure.com/travel-sample`
09:51:20.334 INFO ▶ Connection string was parsed as a potential DNS SRV record
09:51:31.316 INFO ▶ Connection string specifies to use secured connections
09:51:31.316 INFO ▶ Connection string identifies the following CCCP endpoints:
09:51:31.316 INFO ▶   1. hsotname.eastus.cloudapp.azure.com:11207
09:51:31.316 INFO ▶ Connection string identifies the following HTTP endpoints:
09:51:31.316 INFO ▶   1. hsotname.eastus.cloudapp.azure.com:18091
09:51:31.316 INFO ▶ Connection string specifies bucket `travel-sample`
09:51:31.316 WARN ▶ No certificate authority file specified (--tls-ca), skipping server certificate verification for this run.
09:51:42.453 WARN ▶ Your connection string specifies only a single host.  You should consider adding additional static nodes from your cluster to this list to improve your applications fault-tolerance
09:51:42.462 INFO ▶ Performing DNS lookup for host `hsotname.eastus.cloudapp.azure.com`
09:51:42.462 INFO ▶ Bootstrap host `hsotname.eastus.cloudapp.azure.com` refers to a server with the address `13.82.80.55`
09:51:42.462 INFO ▶ Attempting to connect to cluster via CCCP
09:51:42.463 INFO ▶ Attempting to fetch config via cccp from `hsotname.eastus.cloudapp.azure.com:11207`
09:51:44.474 ERRO ▶ Failed to fetch configuration via cccp from `hsotname.eastus.cloudapp.azure.com:11207` (error: dial tcp 13.82.80.55:11207: i/o timeout)
09:51:44.474 INFO ▶ Attempting to connect to cluster via HTTP (Terse)
09:51:44.474 INFO ▶ Attempting to fetch terse config via http from `hsotname.eastus.cloudapp.azure.com:18091`
09:51:46.480 ERRO ▶ Failed to fetch terse configuration via http from `hsotname.eastus.cloudapp.azure.com:18091` (error: Get "http://hsotname.eastus.cloudapp.azure.com:18091/pools/default/b/travel-sample": context deadline exceeded (Client.Timeout exceeded while awaiting headers))
09:51:46.480 INFO ▶ Attempting to connect to cluster via HTTP (Full)
09:51:46.480 INFO ▶ Failed to connect via HTTP (Full), as it is not yet supported by the doctor
09:51:46.481 INFO ▶ Selected the following network type:
09:51:46.481 ERRO ▶ All endpoints specified by your connection string were unreachable, further cluster diagnostics are not possible
09:51:46.481 INFO ▶ Diagnostics completed

Summary:
←[33m[WARN]←[0m No certificate authority file specified (--tls-ca), skipping server certificate verification for this run.
←[33m[WARN]←[0m Your connection string specifies only a single host.  You should consider adding additional static nodes from your cluster to this list to improve your applications fault-tolerance
←[31m[ERRO]←[0m Failed to fetch configuration via cccp from `hsotname.eastus.cloudapp.azure.com:11207` (error: dial tcp 13.82.80.55:11207: i/o timeout)
←[31m[ERRO]←[0m Failed to fetch terse configuration via http from `hsotname.eastus.cloudapp.azure.com:18091` (error: Get "http://hsotname.eastus.cloudapp.azure.com:18091/pools/default/b/travel-sample": context deadline exceeded (Client.Timeout exceeded while awaiting headers))
←[31m[ERRO]←[0m All endpoints specified by your connection string were unreachable, further cluster diagnostics are not possible

Found multiple issues, see listing above.

Both 18091 and 11207 port i added as inbound rule.
my ufw status is inactive
The above mentioned 2 ports are not listening

couchbaseadm@couchbasedbserver:~$ sudo lsof -i -P -n | grep LISTEN

systemd-r   926 systemd-resolve   13u  IPv4   18715      0t0  TCP 127.0.0.53:53 (LISTEN)
sshd       1103            root    3u  IPv4   21086      0t0  TCP *:22 (LISTEN)
sshd       1103            root    4u  IPv6   21088      0t0  TCP *:22 (LISTEN)
beam.smp   6323       couchbase   17u  IPv4 3937812      0t0  TCP 127.0.0.1:21200 (LISTEN)
epmd       6354       couchbase    3u  IPv4 3937267      0t0  TCP *:4369 (LISTEN)
epmd       6354       couchbase    4u  IPv6 3937268      0t0  TCP *:4369 (LISTEN)
beam.smp   6465       couchbase   34u  IPv4 3943391      0t0  TCP *:21100 (LISTEN)
beam.smp   6465       couchbase   48u  IPv4 3938657      0t0  TCP *:8091 (LISTEN)
beam.smp   6514       couchbase   17u  IPv4 3938608      0t0  TCP 127.0.0.1:21300 (LISTEN)
beam.smp   6514       couchbase   27u  IPv4 3938628      0t0  TCP *:8092 (LISTEN)
prometheu  6563       couchbase    9u  IPv4 3938650      0t0  TCP 127.0.0.1:9123 (LISTEN)
goxdcr     6583       couchbase   11u  IPv4 3938705      0t0  TCP 127.0.0.1:9998 (LISTEN)
memcached  6592       couchbase    5u  IPv4 3938689      0t0  TCP 127.0.0.1:11280 (LISTEN)
memcached  6592       couchbase   12u  IPv4 3937931      0t0  TCP *:11210 (LISTEN)
memcached  6592       couchbase   13u  IPv4 3937932      0t0  TCP *:11209 (LISTEN)
memcached  6592       couchbase   14u  IPv6 3937933      0t0  TCP *:11210 (LISTEN)
memcached  6592       couchbase   15u  IPv6 3937934      0t0  TCP *:11209 (LISTEN)
indexer    6741       couchbase   16u  IPv4 3944492      0t0  TCP *:9101 (LISTEN)
indexer    6741       couchbase   19u  IPv4 3944066      0t0  TCP *:9100 (LISTEN)
indexer    6741       couchbase   20u  IPv4 3944500      0t0  TCP *:9102 (LISTEN)
indexer    6741       couchbase   69u  IPv4 3946013      0t0  TCP *:9105 (LISTEN)
projector  6762       couchbase    9u  IPv4 3944075      0t0  TCP *:9999 (LISTEN)
cbq-engin  6782       couchbase    7u  IPv6 3944534      0t0  TCP *:8093 (LISTEN)
cbq-engin  6782       couchbase    8u  IPv4 3944535      0t0  TCP *:8093 (LISTEN)
cbft       6799       couchbase    8u  IPv4 3944112      0t0  TCP *:9130 (LISTEN)
cbft       6799       couchbase    9u  IPv4 3944149      0t0  TCP *:8094 (LISTEN)
sync_gate 11950    sync_gateway    8u  IPv4 4119414      0t0  TCP 127.0.0.1:4985 (LISTEN)
sync_gate 11950    sync_gateway    9u  IPv6 4119422      0t0  TCP *:4984 (LISTEN)

Here is the stacktrace:

StackTrace " at Couchbase.Core.ClusterContext.d__58.MoveNext()\r\n
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n
at System.Threading.Tasks.ValueTask1.get_Result()\r\n at System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable1.ConfiguredValueTaskAwaiter.GetResult()\r\n
at Couchbase.Cluster.<>c__DisplayClass30_0.<b__0>d.MoveNext()\r\n
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n
at System.Threading.Tasks.ValueTask1.get_Result()\r\n at System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable1.ConfiguredValueTaskAwaiter.GetResult()\r\n

Dotnet SDK Log

2022-02-09T17:28:46.3409884+05:30  [DBG] Waiting for 00:00:02.5000000 before polling. (c8639b24)
2022-02-09T17:28:48.8643285+05:30  [DBG] Done waiting, polling... (93018145)
2022-02-09T17:28:48.8649060+05:30  [DBG] Waiting for 00:00:02.5000000 before polling. (c8639b24)
2022-02-09T17:28:51.3664735+05:30  [DBG] Done waiting, polling... (93018145)
2022-02-09T17:28:51.3667541+05:30  [DBG] Waiting for 00:00:02.5000000 before polling. (c8639b24)
2022-02-09T17:28:53.8811651+05:30  [DBG] Done waiting, polling... (93018145)
2022-02-09T17:28:53.8814100+05:30  [DBG] Waiting for 00:00:02.5000000 before polling. (c8639b24)
2022-02-09T17:28:56.3823825+05:30  [DBG] Done waiting, polling... (93018145)
2022-02-09T17:28:56.3826183+05:30  [DBG] Waiting for 00:00:02.5000000 before polling. (c8639b24)
2022-02-09T17:28:58.8964320+05:30  [DBG] Done waiting, polling... (93018145)
2022-02-09T17:28:58.8967224+05:30  [DBG] Waiting for 00:00:02.5000000 before polling. (c8639b24)
2022-02-09T17:29:01.4007664+05:30  [DBG] Done waiting, polling... (93018145)
2022-02-09T17:29:01.4010274+05:30  [DBG] Waiting for 00:00:02.5000000 before polling. (c8639b24)
2022-02-09T17:29:01.7019750+05:30  [INF] Error trying to retrieve DNS SRV entries. (addddf06)
DnsClient.DnsResponseException: Query 12389 => _couchbases._tcp.hsotname.eastus.cloudapp.azure.com IN SRV on 192.168.8.1:53 timed out or is a transient error.
 ---> System.OperationCanceledException: The operation was canceled.
   at System.Threading.Tasks.TaskExtensions.WithCancellation[T](Task`1 task, CancellationToken cancellationToken, Action onCancel)
   at DnsClient.LookupClient.ResolveQueryAsync(IReadOnlyList`1 servers, DnsQuerySettings settings, DnsMessageHandler handler, DnsRequestMessage request, LookupClientAudit audit, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at DnsClient.LookupClient.ResolveQueryAsync(IReadOnlyList`1 servers, DnsQuerySettings settings, DnsMessageHandler handler, DnsRequestMessage request, LookupClientAudit audit, CancellationToken cancellationToken)
   at DnsClient.LookupClient.QueryInternalAsync(DnsQuestion question, DnsQuerySettings queryOptions, IReadOnlyCollection`1 servers, CancellationToken cancellationToken)
   at Couchbase.DnsClientDnsResolver.GetDnsSrvEntriesAsync(Uri bootstrapUri, CancellationToken cancellationToken)
   at Couchbase.Core.ClusterContext.BootstrapGlobalAsync()
2022-02-09T17:29:01.7034867+05:30  [DBG] Bootstrapping with node "hsotname.eastus.cloudapp.azure.com" (98ca0e33)
2022-02-09T17:29:03.9124149+05:30  [DBG] Done waiting, polling... (93018145)
2022-02-09T17:29:03.9127285+05:30  [DBG] Waiting for 00:00:02.5000000 before polling. (c8639b24)
2022-02-09T17:29:06.4201295+05:30  [DBG] Done waiting, polling... (93018145)
2022-02-09T17:29:06.4205385+05:30  [DBG] Waiting for 00:00:02.5000000 before polling. (c8639b24)
2022-02-09T17:29:08.9317820+05:30  [DBG] Done waiting, polling... (93018145)
2022-02-09T17:29:08.9320832+05:30  [DBG] Waiting for 00:00:02.5000000 before polling. (c8639b24)
2022-02-09T17:29:11.4459313+05:30  [DBG] Done waiting, polling... (93018145)
2022-02-09T17:29:11.4463142+05:30  [DBG] Waiting for 00:00:02.5000000 before polling. (c8639b24)
2022-02-09T17:29:12.1488979+05:30  [DBG] Attempted bootstrapping on endpoint "hsotname.eastus.cloudapp.azure.com" has failed. (e80489ed)
System.Net.Sockets.SocketException (10060): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
   at Couchbase.Core.IO.Connections.ConnectionFactory.CreateAndConnectAsync(HostEndpointWithPort hostEndpoint, CancellationToken cancellationToken)
   at Couchbase.Core.IO.Connections.ConnectionPoolBase.CreateConnectionAsync(CancellationToken cancellationToken)
   at Couchbase.Core.IO.Connections.DataFlow.DataFlowConnectionPool.<>c__DisplayClass30_0.<<AddConnectionsAsync>g__StartConnection|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Couchbase.Core.IO.Connections.DataFlow.DataFlowConnectionPool.AddConnectionsAsync(Int32 count, CancellationToken cancellationToken)
   at Couchbase.Core.IO.Connections.DataFlow.DataFlowConnectionPool.InitializeAsync(CancellationToken cancellationToken)
   at Couchbase.Core.ClusterNode.InitializeAsync()
   at Couchbase.Core.DI.ClusterNodeFactory.CreateAndConnectAsync(HostEndpointWithPort endPoint, BucketType bucketType, NodeAdapter nodeAdapter, CancellationToken cancellationToken)
   at Couchbase.Core.ClusterContext.BootstrapGlobalAsync()
2022-02-09T17:29:33.3259787+05:30  [DBG] Done waiting, polling... (93018145)
2022-02-09T17:29:33.3262710+05:30  [DBG] Waiting for 00:00:02.5000000 before polling. (c8639b24)
2022-02-09T17:29:35.8341848+05:30  [DBG] Done waiting, polling... (93018145)
2022-02-09T17:29:35.8343993+05:30  [DBG] Waiting for 00:00:02.5000000 before polling. (c8639b24)
2022-02-09T17:29:36.9552318+05:30  [DBG] Setting TCP Keep-Alives using SocketOptions - enable keep-alives True, time 00:01:00, interval 00:00:01. (d66a37aa)
2022-02-09T17:29:36.9596725+05:30  [DBG] Setting TCP Keep-Alives using SocketOptions - enable keep-alives True, time 00:01:00, interval 00:00:01. (d66a37aa)
2022-02-09T17:29:37.0170984+05:30  [INF] Cannot bootstrap bucket "travel-sample" as Couchbase. (1ecb21a9)
System.IO.IOException: The operation is not allowed on non-connected sockets.
   at System.Net.Sockets.NetworkStream..ctor(Socket socket, FileAccess access, Boolean ownsSocket)
   at Couchbase.Core.IO.Connections.ConnectionFactory.CreateAndConnectAsync(HostEndpointWithPort hostEndpoint, CancellationToken cancellationToken)
   at Couchbase.Core.IO.Connections.ConnectionPoolBase.CreateConnectionAsync(CancellationToken cancellationToken)
   at Couchbase.Core.IO.Connections.DataFlow.DataFlowConnectionPool.<>c__DisplayClass30_0.<<AddConnectionsAsync>g__StartConnection|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Couchbase.Core.IO.Connections.DataFlow.DataFlowConnectionPool.AddConnectionsAsync(Int32 count, CancellationToken cancellationToken)
   at Couchbase.Core.IO.Connections.DataFlow.DataFlowConnectionPool.InitializeAsync(CancellationToken cancellationToken)
   at Couchbase.Core.ClusterNode.InitializeAsync()
   at Couchbase.Core.DI.ClusterNodeFactory.CreateAndConnectAsync(HostEndpointWithPort endPoint, BucketType bucketType, NodeAdapter nodeAdapter, CancellationToken cancellationToken)
   at Couchbase.Core.ClusterContext.CreateAndBootStrapBucketAsync(String name, HostEndpointWithPort endpoint, BucketType type)
   at Couchbase.Core.ClusterContext.GetOrCreateBucketAsync(String name)
2022-02-09T17:29:38.3360012+05:30  [DBG] Done waiting, polling... (93018145)
2022-02-09T17:29:38.3361875+05:30  [DBG] Waiting for 00:00:02.5000000 before polling. (c8639b24)
2022-02-09T17:29:40.3244490+05:30  [DBG] Setting TCP Keep-Alives using SocketOptions - enable keep-alives True, time 00:01:00, interval 00:00:01. (d66a37aa)
2022-02-09T17:29:40.3507801+05:30  [DBG] Setting TCP Keep-Alives using SocketOptions - enable keep-alives True, time 00:01:00, interval 00:00:01. (d66a37aa)
2022-02-09T17:29:40.3525230+05:30  [INF] Cannot bootstrap bucket "travel-sample" as Memcached. (1ecb21a9)
System.IO.IOException: The operation is not allowed on non-connected sockets.
   at System.Net.Sockets.NetworkStream..ctor(Socket socket, FileAccess access, Boolean ownsSocket)
   at Couchbase.Core.IO.Connections.ConnectionFactory.CreateAndConnectAsync(HostEndpointWithPort hostEndpoint, CancellationToken cancellationToken)
   at Couchbase.Core.IO.Connections.ConnectionPoolBase.CreateConnectionAsync(CancellationToken cancellationToken)
   at Couchbase.Core.IO.Connections.DataFlow.DataFlowConnectionPool.<>c__DisplayClass30_0.<<AddConnectionsAsync>g__StartConnection|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Couchbase.Core.IO.Connections.DataFlow.DataFlowConnectionPool.AddConnectionsAsync(Int32 count, CancellationToken cancellationToken)
   at Couchbase.Core.IO.Connections.DataFlow.DataFlowConnectionPool.InitializeAsync(CancellationToken cancellationToken)
   at Couchbase.Core.ClusterNode.InitializeAsync()
   at Couchbase.Core.DI.ClusterNodeFactory.CreateAndConnectAsync(HostEndpointWithPort endPoint, BucketType bucketType, NodeAdapter nodeAdapter, CancellationToken cancellationToken)
   at Couchbase.Core.ClusterContext.CreateAndBootStrapBucketAsync(String name, HostEndpointWithPort endpoint, BucketType type)
   at Couchbase.Core.ClusterContext.GetOrCreateBucketAsync(String name)
2022-02-09T17:29:40.8385667+05:30  [DBG] Done waiting, polling... (93018145)
2022-02-09T17:29:40.8387609+05:30  [DBG] Waiting for 00:00:02.5000000 before polling. (c8639b24)
2022-02-09T17:29:43.3380840+05:30  [DBG] Done waiting, polling... (93018145)
2022-02-09T17:29:43.3382393+05:30  [DBG] Waiting for 00:00:02.5000000 before polling. (c8639b24)
2022-02-09T17:29:43.6633010+05:30  [DBG] Setting TCP Keep-Alives using SocketOptions - enable keep-alives True, time 00:01:00, interval 00:00:01. (d66a37aa)
2022-02-09T17:29:43.6842924+05:30  [DBG] Setting TCP Keep-Alives using SocketOptions - enable keep-alives True, time 00:01:00, interval 00:00:01. (d66a37aa)
2022-02-09T17:29:43.6862758+05:30  [INF] Cannot bootstrap bucket "travel-sample" as Ephemeral. (1ecb21a9)
System.IO.IOException: The operation is not allowed on non-connected sockets.
   at System.Net.Sockets.NetworkStream..ctor(Socket socket, FileAccess access, Boolean ownsSocket)
   at Couchbase.Core.IO.Connections.ConnectionFactory.CreateAndConnectAsync(HostEndpointWithPort hostEndpoint, CancellationToken cancellationToken)
   at Couchbase.Core.IO.Connections.ConnectionPoolBase.CreateConnectionAsync(CancellationToken cancellationToken)
   at Couchbase.Core.IO.Connections.DataFlow.DataFlowConnectionPool.<>c__DisplayClass30_0.<<AddConnectionsAsync>g__StartConnection|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Couchbase.Core.IO.Connections.DataFlow.DataFlowConnectionPool.AddConnectionsAsync(Int32 count, CancellationToken cancellationToken)
   at Couchbase.Core.IO.Connections.DataFlow.DataFlowConnectionPool.InitializeAsync(CancellationToken cancellationToken)
   at Couchbase.Core.ClusterNode.InitializeAsync()
   at Couchbase.Core.DI.ClusterNodeFactory.CreateAndConnectAsync(HostEndpointWithPort endPoint, BucketType bucketType, NodeAdapter nodeAdapter, CancellationToken cancellationToken)
   at Couchbase.Core.ClusterContext.CreateAndBootStrapBucketAsync(String name, HostEndpointWithPort endpoint, BucketType type)
   at Couchbase.Core.ClusterContext.GetOrCreateBucketAsync(String name)

Thanks!!

Body:
I resolve the issue by changing the connection string for couchbase

from

couchbase://

to

http://


问:
Is there any other option for authenticate using auth0 in third party cookie disabled browsers (safari or brave browser )?
I,m trying to login safari and brave browser in my react web application using auth0, but it does not allow the redirect uri to third party requests.I also tried using custom domain in auth0, but it does not work.

答:
Have a look at this as auth0 uses third-party cookies for login can be bypassed using this approach.
Invalid token, state does not match - Auth0 Error Safari only</p>


问:
Overwrite Local Notifications
I have a method that activates a local notification.

```<code>UILocalNotification *localNotif = [[UILocalNotification alloc] init];
if (localNotif == nil)
    return;
localNotif.fireDate = itemDate;
localNotif.timeZone = [NSTimeZone defaultTimeZone];

// Notification details
localNotif.alertBody = [mainTitle text];
// Set the action button
localNotif.alertAction = @"View";

localNotif.soundName = UILocalNotificationDefaultSoundName;

[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
[localNotif release];
</code>```

The problem is that if you call several times the method, do not overwrite the localNotif, but it adds another. How do I delete the old every time?

Thanks!

答: Make localNotif a property or instance variable of the class that contains this method.

Title: Overwrite Local Notifications

Body:
I have a method that activates a local notification.

UILocalNotification *localNotif = [[UILocalNotification alloc] init];
if (localNotif == nil)
    return;
localNotif.fireDate = itemDate;
localNotif.timeZone = [NSTimeZone defaultTimeZone];

// Notification details
localNotif.alertBody = [mainTitle text];
// Set the action button
localNotif.alertAction = @"View";

localNotif.soundName = UILocalNotificationDefaultSoundName;

[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
[localNotif release];

The problem is that if you call several times the method, do not overwrite the localNotif, but it adds another. How do I delete the old every time?

Thanks!


问:
How to specify the weights in a MixtureModel in Julia Distributions.jl?
In Distributions.jl we can specify the priors of a mixture model. But we cannot specify the weights. For example, if I want to make a mixture like this:

```<code>pdf(Normal(2, 3), x)*w1.+pdf(Normal(5, 10), x)*w2
</code>```

I cannot really specify the weights. And the priors are required to add up to 1 for obv reasons.
So, is there a way to specify the weights in MixtureModel?
Something like:

```<code>MixtureModel(Normal[
        Normal(2, 3),
        Normal(5, 10)
        ], **weights=[w1, w2]**)
</code>```

Thanks

答:
This is covered in the Distributions.jl documentation on mixture model constructors — you want the prior argument. See

https://juliastats.org/Distributions.jl/v0.14/mixture.html#Constructors-1

Here's a quick plot of their first example.  The [0.2, 0.5, 0.3] are the weights:

```<code>julia> using Distributions, Plots

julia> d = MixtureModel(Normal[
          Normal(-2.0, 1.2),
          Normal(0.0, 1.0),
          Normal(3.0, 2.5)], [0.2, 0.5, 0.3])
MixtureModel{Normal}(K = 3)
components[1] (prior = 0.2000): Normal{Float64}(μ=-2.0, σ=1.2)
components[2] (prior = 0.5000): Normal{Float64}(μ=0.0, σ=1.0)
components[3] (prior = 0.3000): Normal{Float64}(μ=3.0, σ=2.5)

julia> x = -10:0.1:10
-10.0:0.1:10.0

julia> plot(x, pdf.(d, x), legend=nothing, xlabel="x", ylabel="pdf")
</code>```

Which produces

Body:
In Distributions.jl we can specify the priors of a mixture model. But we cannot specify the weights. For example, if I want to make a mixture like this:

pdf(Normal(2, 3), x)*w1.+pdf(Normal(5, 10), x)*w2

I cannot really specify the weights. And the priors are required to add up to 1 for obv reasons.
So, is there a way to specify the weights in MixtureModel?
Something like:

MixtureModel(Normal[
        Normal(2, 3),
        Normal(5, 10)
        ], **weights=[w1, w2]**)

Thanks

Body:
This is covered in the Distributions.jl documentation on mixture model constructors — you want the prior argument. See

https://juliastats.org/Distributions.jl/v0.14/mixture.html#Constructors-1

Here's a quick plot of their first example.  The [0.2, 0.5, 0.3] are the weights:

julia> using Distributions, Plots

julia> d = MixtureModel(Normal[
          Normal(-2.0, 1.2),
          Normal(0.0, 1.0),
          Normal(3.0, 2.5)], [0.2, 0.5, 0.3])
MixtureModel{Normal}(K = 3)
components[1] (prior = 0.2000): Normal{Float64}(μ=-2.0, σ=1.2)
components[2] (prior = 0.5000): Normal{Float64}(μ=0.0, σ=1.0)
components[3] (prior = 0.3000): Normal{Float64}(μ=3.0, σ=2.5)

julia> x = -10:0.1:10
-10.0:0.1:10.0

julia> plot(x, pdf.(d, x), legend=nothing, xlabel="x", ylabel="pdf")

Which produces


问:
How can we access the pylint messages in lint.run object?
Similar to how we access the pylint score using lint.run in the following way:

```<code>pylint_obj = lint.Run(args,reporter=reporter, do_exit=False)
pylint_obj. linter.stats['global_note'] <- This is the score
</code>```

Is there any variable which stores pylint messages like these:

```<code>status.py:348:4: W0612: Unused variable 'foo' (unused-variable)
status.py:373:4: W0612: Unused variable 'step_source_address' (unused-variable)
status.py:429:4: W0612: Unused variable 'range_status_destin' (unused-variable)
status.py:18:0: R0915: Too many statements (103/80) (too-many-statements)
status.py:524:0: R0913: Too many arguments (10/8) (too-many-arguments)
status.py:524:0: R0914: Too many local variables (34/15) (too-many-locals)
</code>```

I need to access the string messages and perform further operations

答:
There's a CollectingReporter class in pylint itself:

```<code>from pylint import lint
from pylint.reporters import CollectingReporter

reporter = CollectingReporter()
pylint_obj = lint.Run([__file__], reporter=reporter, do_exit=False)
print(reporter.messages)
</code>```

prints out

```<code>[Message(msg_id='C0114', symbol='missing-module-docstring', msg='Missing module docstring', C='C', category='convention', confidence=Confidence(name='HIGH', description='No false positive possible.'), abspath='/Users/akx/build/so-misc/aa.py', path='aa.py', module='aa', obj='', line=1, column=0, end_line=None, end_column=None)]
</code>```

(and nothing else since CollectingReporter doesn't print out things itself).

Body:
Similar to how we access the pylint score using lint.run in the following way:

pylint_obj = lint.Run(args,reporter=reporter, do_exit=False)
pylint_obj. linter.stats['global_note'] <- This is the score

Is there any variable which stores pylint messages like these:

status.py:348:4: W0612: Unused variable 'foo' (unused-variable)
status.py:373:4: W0612: Unused variable 'step_source_address' (unused-variable)
status.py:429:4: W0612: Unused variable 'range_status_destin' (unused-variable)
status.py:18:0: R0915: Too many statements (103/80) (too-many-statements)
status.py:524:0: R0913: Too many arguments (10/8) (too-many-arguments)
status.py:524:0: R0914: Too many local variables (34/15) (too-many-locals)

I need to access the string messages and perform further operations

Body:
There's a CollectingReporter class in pylint itself:

from pylint import lint
from pylint.reporters import CollectingReporter

reporter = CollectingReporter()
pylint_obj = lint.Run([__file__], reporter=reporter, do_exit=False)
print(reporter.messages)

prints out

[Message(msg_id='C0114', symbol='missing-module-docstring', msg='Missing module docstring', C='C', category='convention', confidence=Confidence(name='HIGH', description='No false positive possible.'), abspath='/Users/akx/build/so-misc/aa.py', path='aa.py', module='aa', obj='', line=1, column=0, end_line=None, end_column=None)]

(and nothing else since CollectingReporter doesn't print out things itself).


问:
Fast writing bytearray to file
I use _FileStream.Write(_ByteArray, 0, _ByteArray.Length); to write a bytearray to a file. I noticed that's very slow.
I read a line from a text file, convert it to a bytearray and then need to write it to a new (large > 500 Mb) file. Please some advice to speed up the write process.

答:
FileStream.Write is basically what there is. It's possible that using a BufferedStream would help, but unlikely.

If you're really reading a single line of text which, when encoded, is 500MB then I wouldn't be surprised to find that most of the time is being spent performing encoding. You should be able to test that by doing the encoding and then throwing away the result.

Assuming the "encoding" you're performing is just Encoding.GetBytes(string), you might want to try using a StreamWriter to wrap the FileStream - it may work better by tricks like repeatedly encoding into the same array before writing to the file.

If you're actually reading a line at a time and appending that to the file, then:

Obviously it's best if you keep both the input stream and output stream open throughout the operation. Don't repeatedly read and then write.

You may get better performance using multiple threads or possibly asynchronous IO. This will partly depend on whether you're reading from and writing to the same drive.

Using a StreamWriter is probably still a good idea.

Additionally when creating the file, you may want to look at using a constructor which accepts a FileOptions. Experiment with the available options, but I suspect you'll want SequentialScan and possibly WriteThrough.

Title: Fast writing bytearray to file


问:
Unknown module(s) in QT: webenginewidgets

Hi. I want to connect QtWebEngineWidgets. To do this, you need to write(https://doc.qt.io/qt-5/qtwebenginewidgets-module.html) in .cpp file

```<code>#include <QtWebEngineWidgets>
</code>```

and

```<code>QT += webenginewidgets
</code>```

inside .pro file.

The problem is that when writing to a .pro file, I get the error - Unknown module(s) in QT: webenginewidgets

Everywhere I read, it is only written that you need to connect the module in the .pro file, but it doesn’t work for me. Am I doing everything right?

• Qt Creator version - 5.0.0 Community

• Qt version - 6.1.3

• C++ compiler version - MSVC2019 64bit 17.032112.339(amd64)

UPD:
I want to add that this module is not in the installer.

Installer exaple1, Installer example2

答: It turned out that it was necessary to install a newer version of Qt. For example, since version 6.2.3.0 and newer, the installer contains the "WebView" item. I'm installing it now and I'll see if it helps. Thank you.

Body:
Hi. I want to connect QtWebEngineWidgets. To do this, you need to write(https://doc.qt.io/qt-5/qtwebenginewidgets-module.html) in .cpp file

#include <QtWebEngineWidgets>

and

QT += webenginewidgets

inside .pro file.

The problem is that when writing to a .pro file, I get the error - Unknown module(s) in QT: webenginewidgets

Everywhere I read, it is only written that you need to connect the module in the .pro file, but it doesn’t work for me. Am I doing everything right?

• Qt Creator version - 5.0.0 Community

• Qt version - 6.1.3

• C++ compiler version - MSVC2019 64bit 17.032112.339(amd64)

UPD:
I want to add that this module is not in the installer.

Installer exaple1, Installer example2


问:
Assigning type of a dynamically generate variable to a list in a loop
I have a set of technical indicators in a list - indicator_list = [ema10,ema20,...]
I am trying to generate a indicator series list which will hold the series value for each stock for each indicator as below -

```<code>indicator_ser_dict = {}
for indicator in indicator_list:
   indicator_ser_list = indicator + '_ser_list'
   indicator_ser_dict[indicator] = indicator_ser_list
</code>```

How do I set the type of each indicator_ser_list to a list. That is each of the value in the indicator_ser_dict needs to be a list.
Please note that indicator_ser_list needs to be treated as a variable and not a string.

答:
Using the following method:

```<code>indicator_ser_dict = {}
for indicator in indicator_list:
    indicator_ser_list = indicator + '_ser_list'
    indicator_ser_dict[indicator] = indicator_ser_list
    indicator_ser_dict[indicator_ser_list] = []
</code>```

With input list: [ema10, ema20] The output dictionary will look like:

```<code>indicator_ser_dict = {
    ema10: 'ema10_ser_list',
    ema10_ser_list = [],
    ema20: 'ema20_ser_list',
    ema20_ser_list = []
}
</code>```

Alternatively, you could declare the list variable directly into the name of the indicator:

```<code>indicator_ser_dict = {}
for indicator in indicator_list:
    indicator_ser_dict[indicator] = []
</code>```

For output dictionary:

```<code>indicator_ser_dict = {
    ema10: [],
    ema20: [],
}
</code>```

Body:
I have a set of technical indicators in a list - indicator_list = [ema10,ema20,...]
I am trying to generate a indicator series list which will hold the series value for each stock for each indicator as below -

indicator_ser_dict = {}
for indicator in indicator_list:
   indicator_ser_list = indicator + '_ser_list'
   indicator_ser_dict[indicator] = indicator_ser_list

How do I set the type of each indicator_ser_list to a list. That is each of the value in the indicator_ser_dict needs to be a list.
Please note that indicator_ser_list needs to be treated as a variable and not a string.

Body:
Using the following method:

indicator_ser_dict = {}
for indicator in indicator_list:
    indicator_ser_list = indicator + '_ser_list'
    indicator_ser_dict[indicator] = indicator_ser_list
    indicator_ser_dict[indicator_ser_list] = []

With input list: [ema10, ema20] The output dictionary will look like:

indicator_ser_dict = {
    ema10: 'ema10_ser_list',
    ema10_ser_list = [],
    ema20: 'ema20_ser_list',
    ema20_ser_list = []
}

Alternatively, you could declare the list variable directly into the name of the indicator:

indicator_ser_dict = {}
for indicator in indicator_list:
    indicator_ser_dict[indicator] = []

For output dictionary:

indicator_ser_dict = {
    ema10: [],
    ema20: [],
}