问:
Spring Boot + ReactiveCosmosRepository + java.lang.NoSuchMethodError: reactor.util.concurrent.Queues.empty()Ljava/util/function/Supplier
I am implementing Cosmos DB in my Spring Boot project, and am getting error while connecting to Azure Cosmos DB.

POM.xml

```<code><dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-cosmosdb-spring-boot-starter</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>spring-data-cosmosdb</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-documentdb</artifactId>
<version>2.4.6</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-spring-boot-starter</artifactId>
<version>2.2.0</version>
</dependency>
</code>```

Repository

```<code>package com.staples.ctg.repository.cosmos;

import org.springframework.stereotype.Repository;

import com.microsoft.azure.spring.data.cosmosdb.repository.ReactiveCosmosRepository;
import com.staples.ctg.service.dto.cache.GenericCacheDTO;

@Repository
public interface SpotCacheRepository extends  ReactiveCosmosRepository <GenericCacheDTO, String> {

}
</code>```

applicationProperties.yml

```<code>azure:

cosmosdb:

    uri: Cosmos URI

    key: Key

    database: DB Name that I created
</code>```

DTO

```<code>package com.staples.ctg.service.dto.cache;

@Document(collection="cosmos")
public class GenericCacheDTO {
    @Id
    private String id;
    @PartitionKey
    private String accountId;

}
</code>```

When I spin up locally, I am getting below error

```<code>2020-02-14 12:20:32.922  INFO 22777 --- [  restartedMain] c.a.d.c.internal.RxDocumentClientImpl    : Initializing DocumentClient with serviceEndpoint [<Azure Cosmos URI>], connectionPolicy [ConnectionPolicy{requestTimeoutInMillis=60000, mediaRequestTimeoutInMillis=300000, connectionMode=DIRECT, maxPoolSize=1000, idleConnectionTimeoutInMillis=60000, userAgentSuffix=';spring-data/2.2.0;8d0607104487ba8c93ae7a32c5e20645d1bb21edf269625ead71da72d4877d65;', retryOptions=RetryOptions{maxRetryAttemptsOnThrottledRequests=9, maxRetryWaitTimeInSeconds=30}, enableEndpointDiscovery=true, preferredLocations=null, usingMultipleWriteLocations=false, inetSocketProxyAddress=null}], consistencyLevel [null], directModeProtocol [Tcp]
2020-02-14 12:20:32.922 DEBUG 22777 --- [  restartedMain] reactor.util.Loggers$LoggerFactory       : Using Slf4j logging framework
2020-02-14 12:20:32.979 DEBUG 22777 --- [  restartedMain] c.a.d.c.internal.GlobalEndpointManager   : registering a refresh in [300000] ms
2020-02-14 12:20:33.034 DEBUG 22777 --- [     parallel-1] c.a.d.c.internal.GlobalEndpointManager   : startRefreshLocationTimerAsync() - Invoking refresh, I was registered on [2020-02-14T12:20:32.985]
2020-02-14 12:20:33.035  INFO 22777 --- [     parallel-1] c.a.d.c.internal.RxDocumentClientImpl    : Getting database account endpoint from https:<Azure Cosmos URI>
2020-02-14 12:20:33.123 DEBUG 22777 --- [     parallel-1] reactor.netty.tcp.TcpResources           : [http] resources will use the default LoopResources: DefaultLoopResources {prefix=reactor-http, daemon=true, selectCount=8, workerCount=8}
2020-02-14 12:20:33.123 DEBUG 22777 --- [     parallel-1] reactor.netty.tcp.TcpResources           : [http] resources will use the default ConnectionProvider: PooledConnectionProvider {name=http, poolFactory=reactor.netty.resources.ConnectionProvider$$Lambda$2068/965477132@65222f44}
2020-02-14 12:20:33.130 DEBUG 22777 --- [     parallel-1] r.netty.resources.DefaultLoopEpoll       : Default Epoll support : false
2020-02-14 12:20:33.132 DEBUG 22777 --- [     parallel-1] r.netty.resources.DefaultLoopKQueue      : Default KQueue support : false
2020-02-14 12:20:33.162 DEBUG 22777 --- [     parallel-1] r.n.resources.PooledConnectionProvider   : Creating new client pool [reactor-netty-connection-pool] for <Azure Cosmos URI>
2020-02-14 12:20:33.183 ERROR 22777 --- [     parallel-1] reactor.core.scheduler.Schedulers        : Scheduler worker in group main failed with an uncaught exception

java.lang.NoSuchMethodError: reactor.util.concurrent.Queues.empty()Ljava/util/function/Supplier;
    at reactor.netty.internal.shaded.reactor.pool.SimpleFifoPool.<clinit>(SimpleFifoPool.java:35)
    at reactor.netty.internal.shaded.reactor.pool.PoolBuilder.build(PoolBuilder.java:333)
    at reactor.netty.internal.shaded.reactor.pool.PoolBuilder.fifo(PoolBuilder.java:321)
    at reactor.netty.resources.ConnectionProvider.lambda$fixed$3(ConnectionProvider.java:197)
    at reactor.netty.resources.PooledConnectionProvider$PooledConnectionAllocator.<init>(PooledConnectionProvider.java:237)
    at reactor.netty.resources.PooledConnectionProvider.lambda$acquire$2(PooledConnectionProvider.java:154)
    at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)
    at reactor.netty.resources.PooledConnectionProvider.lambda$acquire$3(PooledConnectionProvider.java:148)
    at reactor.core.publisher.MonoCreate.subscribe(MonoCreate.java:54)
    at reactor.netty.http.client.HttpClientConnect$MonoHttpConnect.lambda$subscribe$0(HttpClientConnect.java:319)
    at reactor.core.publisher.MonoCreate.subscribe(MonoCreate.java:54)
    at reactor.core.publisher.Mono.subscribe(Mono.java:3088)
    at reactor.core.publisher.FluxRetryPredicate$RetryPredicateSubscriber.resubscribe(FluxRetryPredicate.java:123)
    at reactor.core.publisher.MonoRetryPredicate.subscribe(MonoRetryPredicate.java:51)
    at reactor.netty.http.client.HttpClientConnect$MonoHttpConnect.subscribe(HttpClientConnect.java:322)
    at reactor.core.publisher.MonoFlatMapMany.subscribe(MonoFlatMapMany.java:49)
    at reactor.core.publisher.MonoSingle.subscribe(MonoSingle.java:58)
    at reactor.core.publisher.MonoFlatMap.subscribe(MonoFlatMap.java:60)
    at reactor.core.publisher.MonoMapFuseable.subscribe(MonoMapFuseable.java:59)
    at reactor.core.publisher.MonoOnErrorResume.subscribe(MonoOnErrorResume.java:44)
    at reactor.core.publisher.FluxSourceMono.subscribe(FluxSourceMono.java:46)
    at reactor.core.publisher.MonoSingle.subscribe(MonoSingle.java:58)
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:53)
    at reactor.core.publisher.Mono.subscribe(Mono.java:3088)
    at reactor.core.publisher.FluxRetryWhen.subscribe(FluxRetryWhen.java:82)
    at reactor.core.publisher.MonoRetryWhen.subscribe(MonoRetryWhen.java:50)
    at reactor.core.publisher.FluxSourceMono.subscribe(FluxSourceMono.java:46)
    at reactor.core.publisher.FluxOnErrorResume.subscribe(FluxOnErrorResume.java:47)
    at reactor.core.publisher.FluxMap.subscribe(FluxMap.java:62)
    at reactor.core.publisher.FluxPeek.subscribe(FluxPeek.java:83)
    at reactor.core.publisher.FluxMap.subscribe(FluxMap.java:62)
    at reactor.core.publisher.FluxPeek.subscribe(FluxPeek.java:83)
    at reactor.core.publisher.FluxDefer.subscribe(FluxDefer.java:55)
    at reactor.core.publisher.FluxPeek.subscribe(FluxPeek.java:83)
    at reactor.core.publisher.MonoSingle.subscribe(MonoSingle.java:58)
    at reactor.core.publisher.MonoOnErrorResume.subscribe(MonoOnErrorResume.java:44)
    at reactor.core.publisher.MonoFlatMap.subscribe(MonoFlatMap.java:60)
    at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:150)
    at reactor.core.publisher.MonoDelay$MonoDelayRunnable.run(MonoDelay.java:117)
    at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:50)
    at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:27)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

2020-02-14 12:20:46.801  WARN 22777 --- [scoveryClient-1] c.netflix.discovery.TimedSupervisorTask  : task supervisor timed out

java.util.concurrent.TimeoutException: null
</code>```

答:
This looks like a reactor-core incorrect version issue.

This dependency might be bringing an older version of reactor-core.

```<code><dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-cosmosdb-spring-boot-starter</artifactId>
<version>2.2.2</version>
</dependency>
</code>```

Two ways to solve this issue:

Try excluding reactor-core from this dependency.

Try adding reactor-core dependency - 3.3.0 or higher.

Body:
I am implementing Cosmos DB in my Spring Boot project, and am getting error while connecting to Azure Cosmos DB.

POM.xml

<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-cosmosdb-spring-boot-starter</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>spring-data-cosmosdb</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-documentdb</artifactId>
<version>2.4.6</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-spring-boot-starter</artifactId>
<version>2.2.0</version>
</dependency>

Repository

package com.staples.ctg.repository.cosmos;

import org.springframework.stereotype.Repository;

import com.microsoft.azure.spring.data.cosmosdb.repository.ReactiveCosmosRepository;
import com.staples.ctg.service.dto.cache.GenericCacheDTO;

@Repository
public interface SpotCacheRepository extends  ReactiveCosmosRepository <GenericCacheDTO, String> {

}

applicationProperties.yml

azure:

cosmosdb:

    uri: Cosmos URI

    key: Key

    database: DB Name that I created

DTO

package com.staples.ctg.service.dto.cache;

@Document(collection="cosmos")
public class GenericCacheDTO {
    @Id
    private String id;
    @PartitionKey
    private String accountId;

}

When I spin up locally, I am getting below error

2020-02-14 12:20:32.922  INFO 22777 --- [  restartedMain] c.a.d.c.internal.RxDocumentClientImpl    : Initializing DocumentClient with serviceEndpoint [<Azure Cosmos URI>], connectionPolicy [ConnectionPolicy{requestTimeoutInMillis=60000, mediaRequestTimeoutInMillis=300000, connectionMode=DIRECT, maxPoolSize=1000, idleConnectionTimeoutInMillis=60000, userAgentSuffix=';spring-data/2.2.0;8d0607104487ba8c93ae7a32c5e20645d1bb21edf269625ead71da72d4877d65;', retryOptions=RetryOptions{maxRetryAttemptsOnThrottledRequests=9, maxRetryWaitTimeInSeconds=30}, enableEndpointDiscovery=true, preferredLocations=null, usingMultipleWriteLocations=false, inetSocketProxyAddress=null}], consistencyLevel [null], directModeProtocol [Tcp]
2020-02-14 12:20:32.922 DEBUG 22777 --- [  restartedMain] reactor.util.Loggers$LoggerFactory       : Using Slf4j logging framework
2020-02-14 12:20:32.979 DEBUG 22777 --- [  restartedMain] c.a.d.c.internal.GlobalEndpointManager   : registering a refresh in [300000] ms
2020-02-14 12:20:33.034 DEBUG 22777 --- [     parallel-1] c.a.d.c.internal.GlobalEndpointManager   : startRefreshLocationTimerAsync() - Invoking refresh, I was registered on [2020-02-14T12:20:32.985]
2020-02-14 12:20:33.035  INFO 22777 --- [     parallel-1] c.a.d.c.internal.RxDocumentClientImpl    : Getting database account endpoint from https:<Azure Cosmos URI>
2020-02-14 12:20:33.123 DEBUG 22777 --- [     parallel-1] reactor.netty.tcp.TcpResources           : [http] resources will use the default LoopResources: DefaultLoopResources {prefix=reactor-http, daemon=true, selectCount=8, workerCount=8}
2020-02-14 12:20:33.123 DEBUG 22777 --- [     parallel-1] reactor.netty.tcp.TcpResources           : [http] resources will use the default ConnectionProvider: PooledConnectionProvider {name=http, poolFactory=reactor.netty.resources.ConnectionProvider$$Lambda$2068/965477132@65222f44}
2020-02-14 12:20:33.130 DEBUG 22777 --- [     parallel-1] r.netty.resources.DefaultLoopEpoll       : Default Epoll support : false
2020-02-14 12:20:33.132 DEBUG 22777 --- [     parallel-1] r.netty.resources.DefaultLoopKQueue      : Default KQueue support : false
2020-02-14 12:20:33.162 DEBUG 22777 --- [     parallel-1] r.n.resources.PooledConnectionProvider   : Creating new client pool [reactor-netty-connection-pool] for <Azure Cosmos URI>
2020-02-14 12:20:33.183 ERROR 22777 --- [     parallel-1] reactor.core.scheduler.Schedulers        : Scheduler worker in group main failed with an uncaught exception

java.lang.NoSuchMethodError: reactor.util.concurrent.Queues.empty()Ljava/util/function/Supplier;
    at reactor.netty.internal.shaded.reactor.pool.SimpleFifoPool.<clinit>(SimpleFifoPool.java:35)
    at reactor.netty.internal.shaded.reactor.pool.PoolBuilder.build(PoolBuilder.java:333)
    at reactor.netty.internal.shaded.reactor.pool.PoolBuilder.fifo(PoolBuilder.java:321)
    at reactor.netty.resources.ConnectionProvider.lambda$fixed$3(ConnectionProvider.java:197)
    at reactor.netty.resources.PooledConnectionProvider$PooledConnectionAllocator.<init>(PooledConnectionProvider.java:237)
    at reactor.netty.resources.PooledConnectionProvider.lambda$acquire$2(PooledConnectionProvider.java:154)
    at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)
    at reactor.netty.resources.PooledConnectionProvider.lambda$acquire$3(PooledConnectionProvider.java:148)
    at reactor.core.publisher.MonoCreate.subscribe(MonoCreate.java:54)
    at reactor.netty.http.client.HttpClientConnect$MonoHttpConnect.lambda$subscribe$0(HttpClientConnect.java:319)
    at reactor.core.publisher.MonoCreate.subscribe(MonoCreate.java:54)
    at reactor.core.publisher.Mono.subscribe(Mono.java:3088)
    at reactor.core.publisher.FluxRetryPredicate$RetryPredicateSubscriber.resubscribe(FluxRetryPredicate.java:123)
    at reactor.core.publisher.MonoRetryPredicate.subscribe(MonoRetryPredicate.java:51)
    at reactor.netty.http.client.HttpClientConnect$MonoHttpConnect.subscribe(HttpClientConnect.java:322)
    at reactor.core.publisher.MonoFlatMapMany.subscribe(MonoFlatMapMany.java:49)
    at reactor.core.publisher.MonoSingle.subscribe(MonoSingle.java:58)
    at reactor.core.publisher.MonoFlatMap.subscribe(MonoFlatMap.java:60)
    at reactor.core.publisher.MonoMapFuseable.subscribe(MonoMapFuseable.java:59)
    at reactor.core.publisher.MonoOnErrorResume.subscribe(MonoOnErrorResume.java:44)
    at reactor.core.publisher.FluxSourceMono.subscribe(FluxSourceMono.java:46)
    at reactor.core.publisher.MonoSingle.subscribe(MonoSingle.java:58)
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:53)
    at reactor.core.publisher.Mono.subscribe(Mono.java:3088)
    at reactor.core.publisher.FluxRetryWhen.subscribe(FluxRetryWhen.java:82)
    at reactor.core.publisher.MonoRetryWhen.subscribe(MonoRetryWhen.java:50)
    at reactor.core.publisher.FluxSourceMono.subscribe(FluxSourceMono.java:46)
    at reactor.core.publisher.FluxOnErrorResume.subscribe(FluxOnErrorResume.java:47)
    at reactor.core.publisher.FluxMap.subscribe(FluxMap.java:62)
    at reactor.core.publisher.FluxPeek.subscribe(FluxPeek.java:83)
    at reactor.core.publisher.FluxMap.subscribe(FluxMap.java:62)
    at reactor.core.publisher.FluxPeek.subscribe(FluxPeek.java:83)
    at reactor.core.publisher.FluxDefer.subscribe(FluxDefer.java:55)
    at reactor.core.publisher.FluxPeek.subscribe(FluxPeek.java:83)
    at reactor.core.publisher.MonoSingle.subscribe(MonoSingle.java:58)
    at reactor.core.publisher.MonoOnErrorResume.subscribe(MonoOnErrorResume.java:44)
    at reactor.core.publisher.MonoFlatMap.subscribe(MonoFlatMap.java:60)
    at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:150)
    at reactor.core.publisher.MonoDelay$MonoDelayRunnable.run(MonoDelay.java:117)
    at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:50)
    at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:27)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

2020-02-14 12:20:46.801  WARN 22777 --- [scoveryClient-1] c.netflix.discovery.TimedSupervisorTask  : task supervisor timed out

java.util.concurrent.TimeoutException: null

Body:
This looks like a reactor-core incorrect version issue.

This dependency might be bringing an older version of reactor-core.

<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-cosmosdb-spring-boot-starter</artifactId>
<version>2.2.2</version>
</dependency>

Two ways to solve this issue:

Try excluding reactor-core from this dependency.

Try adding reactor-core dependency - 3.3.0 or higher.


来源: stackexchange

问:
How to select inputs elements in divs which not hidden?
How can I select an array of input and select elements that are not hidden from the form below, using jQuery?

```<code>  <form class="FORM_1">
    <div class="a" style="display:inline-block><input id="A"/></div>

    <div class="a" style="display:none"><input id="B"/></div>

    <div class="a"><select id="C"/></div>
    <div class="a"style="display:none"><select id="D"/></div>

    <div class="a style="display:inline-block"><input id="F"/></div>
   </form>
</code>```

I tried with code below but it doesn't work how I need.

```<code>$('.FORM_1 input, .FORM_1 select').prop('display', 'inline-block').each(function(index){
  var input = $(this);
  console.log('Type: ' + input.attr('type'));
});
</code>```

答:
$(".FORM_1 input:visible, .FORM_1 select:visible").each(function(index) {
  var input = $(this);
  console.log("Type: " + input.prop("type"));
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.a {
  display: inline-block;
}</code>```

<form class="FORM_1">

<input id="A" type="text" />

<input id="B" type="text" />

<select id="C"></select>

<select id="D"></select>

<input id="F" type="text" />

</form>```

ContentLicense: CC BY-SA 4.0

Body:
How can I select an array of input and select elements that are not hidden from the form below, using jQuery?

  <form class="FORM_1">

<input id="A"/>

<input id="B"/>

<select id="C"/>

<select id="D"/>

<input id="F"/>

   </form>

I tried with code below but it doesn't work how I need.

$('.FORM_1 input, .FORM_1 select').prop('display', 'inline-block').each(function(index){
  var input = $(this);
  console.log('Type: ' + input.attr('type'));
});

Body:
$(".FORM_1 input:visible, .FORM_1 select:visible").each(function(index) {
  var input = $(this);
  console.log("Type: " + input.prop("type"));
});

.a {
  display: inline-block;
}

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form class="FORM_1">
  <div class="a"><input id="A" type="text" />
  </div>

  <div class="a" style="display:none"><input id="B" type="text" /></div>

  <div class="a"><select id="C"></select></div>
  <div class="a" style="display:none"><select id="D"></select></div>

  <div class="a"><input id="F" type="text" /></div>
</form>


问:
How to echo names of last upload file
I was asked that the output file should only output the name and id of the last person who uploaded a file with a specific name. confusing right? even I am confused. so let me give an example

let us say that you have 3 employees registered in your company. lets call them

Pikachu,

Raichu and

Pichu.

Pikachu has 3 files uploaded in the company, Raichu has 2 files uploaded and Pichu has also 2 files uploaded. The files must also be ordered according to employeename(ASC) and filename(DESC). Mine is already in ordered by. This is my only problem. In this case the output should look like this:

*noticed that the employee name and employee id is in the last file uploaded?? does anyone knows how to do that?please i beg you guys to help me out here T-T the task is way too hard and im just a rookie

Im thinking of using 2 tables here. table 1 for the employee id and employee name, table 2 for the file name, etc. so i guess this would also involve 2 while clause. i have the idea but i dont know how to mix them all up.

my code before I edited it like sir vincent look like this:

```<code>if ($_SESSION[$fgmembersite->GetLoginSessionVar()] == 'sa'
   OR $_SESSION[$fgmembersite->GetLoginSessionVar()] == 'admin')
{

  $sql= "select * from gmdc_employee
         where employee_name like '%$search%'
         AND employee_name like '$listname%'";
} else {
  $sql = "select b.* from gmdc_user a, gmdc_employee b
          where a.username = '".$_SESSION[$fgmembersite->GetLoginSessionVar()]."'
          AND a.company_id = b.company_id
          AND b.employee_name like '$listname%'
          AND b.employee_name like '%$search%'";
}
$query = mysql_query("$sql ORDER BY employee_name,confirmation DESC
                     ,file_id DESC,file_date DESC
                      LIMIT $offset,$limit") or die ( mysql_error () );
$result = mysql_query($sql) or die (mysql_error());
$total = mysql_num_rows($result);

if(!$result || mysql_num_rows($result) <= 0)
{
  $fgmembersite->HandleError("No file found.");
  return false;
}
while ($row = mysql_fetch_assoc($query))
{
  $file_id = $row['file_id'];
  $file_desc = $row['file_description'];
  $file_date = $row['file_date'];
  $file_name = $row['file_name'];
  $file_accs = $row['folder_access'];
  $file_employee  = $row['employee_id'];
  $file_confir = $row['confirmation'];
  $file_ename = ucwords($row['employee_name']);

  $info = pathinfo($file_name);
  $file_ext = $info['extension'];

  echo '<tr><td> </td></tr>
        <tr class="subone"><td class="sub" width="100">'.$file_employee.'<br />
         </td>';
  if($_SESSION[$fgmembersite->GetLoginSessionVar()] == 'sa')
  {
    ?>
    <td class="sub" width="100">
    <a href="" onclick = javascript:newPopup('addfile.php?emp=
    <?php echo $file_employee ?>');><?php echo$file_ename?></a>
    <br /> </td>
    <?php
  } else {
    echo '<td class="sub" width="182">'.$file_ename.'<br /> </td>';
  }
  echo'<td  class="sub" width="218">
       <a href="'.$file_accs.$file_name.'" target="_blank"
        style="text-decoration: underline;">'.$file_desc.'</a>
       <br /> </td><td  class="sub" width="100">
      '.date('M d, Y',mktime(0,0,0,substr($file_date,5,2)
       ,substr($file_date,8,2),substr($file_date,0,4))).'
       <br /> </td><td  class="sub" width="100">'.$file_confir.'
       <br /> </td>';

  if($_SESSION[$fgmembersite->GetLoginSessionVar()] == 'sa')
  {
    if($file_confir == 'Pending' OR $file_confir == 'NotApproved')
    {
      if(isset($_GET['id']))
      {
        $fgmembersite->Delete_Db($_GET['id']);
      }
      echo '<td  class="sub" width="100">
            <a href="index.php?id='.$file_id.'">Delete</a>
            <br /> </td>';
    }
  }
  else if($_SESSION[$fgmembersite->GetLoginSessionVar()] == 'admin')
  {
    if($file_confir == 'Pending')
      {
        if(isset($_GET['yes']))
        {
          $fgmembersite->UpdateYesDB($_GET['yes']);
          //echo "<script>location.reload();</script>";
        }
        else if(isset($_GET['no']))
        {
          $fgmembersite->UpdateNoDB($_GET['no']);
          //echo "<script>location.reload();</script>";
        }
        if (!isset($_GET['offset'])) {
          $prevoffset = 0;
        } else {
          $prevoffset = $_GET['offset'];
          echo'<td  class="sub" width="100">
          <a href="index.php?offset='.$prevoffset.'&searchfile='.$search.'
           &namelist='.$listname.'&yes='.$file_id.'">Approve</a>
           //there's a link here<br /><br />
           <a href="index.php?offset='.$prevoffset.'&searchfile='.$search.'
            &namelist='.$listname.'&no='.$file_id.'">NotApprove</a>
            //there's a link here
             </td> ';
      }
    }
  }?>
</code>```

Just ignore every if($_SESSION[$fgmembersite->GetLoginSessionVar()] == 'admin') and whatever, this is for different output since my file can be logged into by 3 different users. SA(programmers), admin(the approver of the file uploaded), and user(company). There are TD and TR there as well, I don't know why wont it appear here.

output looked like this:

```<code>employee_id  +   employee_name  +  file_name
3            |   pichu          |  file6
3            |   pichu          |  file1
1            |   pikachu        |  file7
1            |   pikachu        |  file4
1            |   pikachi        |  file3
2            |   raichu         |  file8
2            |   raichu         |  file5
2            |   raichu         |  file2
</code>```

and I want my output to be like this:

```<code>***OUTPUT***

**employee_id        employee_name              file_name**
    3                      pichu                        file6
                                                        file1
    1                     pikachu                       file7
                                                        file4
                                                        file3
    2                     raichu                        file5
                                                        file2
</code>```

for example that raichu uploaded another file, the output should now look like this:

OUTPUT

```<code>**employee_id        employee_name            file_name**
    3                      pichu                      file6
                                                      file1
    1                      pikachu                    file7
                                                      file4
                                                      file3
    2                      raichu                     file8
                                                      file5
                                                      file2
</code>```

答:
sounds like not that hard.

TABLE employee:

this table may have two fields(in the simplest way): employee_id, employee_name

TABLE file:

this table may have three fields: file_id, employee_id(this is a foreign key), file_name

when the file is uploaded, change its name to this format: "file" + file_id

therefor, we have:

TABLE employee:

```employee_id  |  employee_name
-----------------------------
1            |  pikachu
2            |  raichu
3            |  pichu```

TABLE file:

```file_id  |  employee_id  |  file_name
-------------------------------------
1        |  3            |  file1
2        |  2            |  file2
3        |  1            |  file3
4        |  1            |  file4
5        |  2            |  file5
6        |  3            |  file6
7        |  1            |  file7
8        |  2            |  file8```

then it is really easy to make them all up, what do you think?

ContentLicense: CC BY-SA 3.0

Title: How to echo names of last upload file

Body:
I was asked that the output file should only output the name and id of the last person who uploaded a file with a specific name. confusing right? even I am confused. so let me give an example

let us say that you have 3 employees registered in your company. lets call them

Pikachu,

Raichu and

Pichu.

Pikachu has 3 files uploaded in the company, Raichu has 2 files uploaded and Pichu has also 2 files uploaded. The files must also be ordered according to employeename(ASC) and filename(DESC). Mine is already in ordered by. This is my only problem. In this case the output should look like this:

*noticed that the employee name and employee id is in the last file uploaded?? does anyone knows how to do that?please i beg you guys to help me out here T-T the task is way too hard and im just a rookie

Im thinking of using 2 tables here. table 1 for the employee id and employee name, table 2 for the file name, etc. so i guess this would also involve 2 while clause. i have the idea but i dont know how to mix them all up.

my code before I edited it like sir vincent look like this:

if ($_SESSION[$fgmembersite->GetLoginSessionVar()] == 'sa'
   OR $_SESSION[$fgmembersite->GetLoginSessionVar()] == 'admin')
{

  $sql= "select * from gmdc_employee
         where employee_name like '%$search%'
         AND employee_name like '$listname%'";
} else {
  $sql = "select b.* from gmdc_user a, gmdc_employee b
          where a.username = '".$_SESSION[$fgmembersite->GetLoginSessionVar()]."'
          AND a.company_id = b.company_id
          AND b.employee_name like '$listname%'
          AND b.employee_name like '%$search%'";
}
$query = mysql_query("$sql ORDER BY employee_name,confirmation DESC
                     ,file_id DESC,file_date DESC
                      LIMIT $offset,$limit") or die ( mysql_error () );
$result = mysql_query($sql) or die (mysql_error());
$total = mysql_num_rows($result);

if(!$result || mysql_num_rows($result) <= 0)
{
  $fgmembersite->HandleError("No file found.");
  return false;
}
while ($row = mysql_fetch_assoc($query))
{
  $file_id = $row['file_id'];
  $file_desc = $row['file_description'];
  $file_date = $row['file_date'];
  $file_name = $row['file_name'];
  $file_accs = $row['folder_access'];
  $file_employee  = $row['employee_id'];
  $file_confir = $row['confirmation'];
  $file_ename = ucwords($row['employee_name']);

  $info = pathinfo($file_name);
  $file_ext = $info['extension'];

  echo '

'.$file_employee.'

         	';
  if($_SESSION[$fgmembersite->GetLoginSessionVar()] == 'sa')
  {
    ?>

    <a href="" onclick = javascript:newPopup('addfile.php?emp=
    <?php echo $file_employee ?>');><?php echo$file_ename?>

    <?php
  } else {
    echo ''.$file_ename.'
 	';
  }
  echo'
       '.$file_desc.'

      '.date('M d, Y',mktime(0,0,0,substr($file_date,5,2)
       ,substr($file_date,8,2),substr($file_date,0,4))).'

 	'.$file_confir.'

 	';

  if($_SESSION[$fgmembersite->GetLoginSessionVar()] == 'sa')
  {
    if($file_confir == 'Pending' OR $file_confir == 'NotApproved')
    {
      if(isset($_GET['id']))
      {
        $fgmembersite->Delete_Db($_GET['id']);
      }
      echo '
            Delete

 	';
    }
  }
  else if($_SESSION[$fgmembersite->GetLoginSessionVar()] == 'admin')
  {
    if($file_confir == 'Pending')
      {
        if(isset($_GET['yes']))
        {
          $fgmembersite->UpdateYesDB($_GET['yes']);
          //echo "";
        }
        else if(isset($_GET['no']))
        {
          $fgmembersite->UpdateNoDB($_GET['no']);
          //echo "";
        }
        if (!isset($_GET['offset'])) {
          $prevoffset = 0;
        } else {
          $prevoffset = $_GET['offset'];
          echo'
          Approve
           //there's a link here

           NotApprove
            //there's a link here
             	 ';
      }
    }
  }?>

Just ignore every if($_SESSION[$fgmembersite->GetLoginSessionVar()] == 'admin') and whatever, this is for different output since my file can be logged into by 3 different users. SA(programmers), admin(the approver of the file uploaded), and user(company). There are TD and TR there as well, I don't know why wont it appear here.

output looked like this:

employee_id  +   employee_name  +  file_name
3            |   pichu          |  file6
3            |   pichu          |  file1
1            |   pikachu        |  file7
1            |   pikachu        |  file4
1            |   pikachi        |  file3
2            |   raichu         |  file8
2            |   raichu         |  file5
2            |   raichu         |  file2

and I want my output to be like this:

***OUTPUT***

**employee_id        employee_name              file_name**
    3                      pichu                        file6
                                                        file1
    1                     pikachu                       file7
                                                        file4
                                                        file3
    2                     raichu                        file5
                                                        file2

for example that raichu uploaded another file, the output should now look like this:

OUTPUT

**employee_id        employee_name            file_name**
    3                      pichu                      file6
                                                      file1
    1                      pikachu                    file7
                                                      file4
                                                      file3
    2                      raichu                     file8
                                                      file5
                                                      file2

Body:
sounds like not that hard.

TABLE employee:

this table may have two fields(in the simplest way): employee_id, employee_name

TABLE file:

this table may have three fields: file_id, employee_id(this is a foreign key), file_name

when the file is uploaded, change its name to this format: "file" + file_id

therefor, we have:

TABLE employee:

employee_id  |  employee_name
-----------------------------
1            |  pikachu
2            |  raichu
3            |  pichu

TABLE file:

file_id  |  employee_id  |  file_name
-------------------------------------
1        |  3            |  file1
2        |  2            |  file2
3        |  1            |  file3
4        |  1            |  file4
5        |  2            |  file5
6        |  3            |  file6
7        |  1            |  file7
8        |  2            |  file8

then it is really easy to make them all up, what do you think?


问:
Google Calendar API Service Account Error 401 Invalid credential
I'm trying to create a Google Calendar Service Account.

Here are my credentials:

Here's my service account definition (Site Wide delegation for service account is enabled):

Here's my "Manage API client access" page:

And this is my code:

```<code>        string userName = "xxx@yyy.it";
        string[] Scopes = { CalendarService.Scope.Calendar, CalendarService.Scope.CalendarEvents };
        string ApplicationName = "Client per quickstart";
        ServiceAccountCredential credential = GoogleCredential.FromFile(@"path\credentialjson.json").CreateScoped(Scopes).CreateWithUser(userName).UnderlyingCredential as ServiceAccountCredential;

        // Create Google Calendar API service.
        var service = new CalendarService(new BaseClientService.Initializer()
        {
            HttpClientInitializer = credential,
            ApplicationName = ApplicationName
        });
        // THIS REQUEST FAILS!!
        var y = service.CalendarList.List().Execute();

</code>```

The service is created correctly but all requests fail with this error:

Code: 401, Message: "Invalid Credentials", Location: "Authorization", >LocationType: "header", Reason: "authError", Domain: "global"

I don't understand what I'm missing in the authorization header.

What should I set before the request that was not done when creating the service? Thanks!

答:
Your issue is due to the Scopes you are using at the same time, because you are setting CalendarService.Scope.CalendarEvents, this one will be the priority over CalendarService.Scope.Calendar, because the Google APIs always take as priority the most restricted Scope (in this case CalendarEvents).

And as you can see in the CalendarList: list endpoint scopes, the CalendarService.Scope.CalendarEvents is not a Scope you could use to  hit the endpoint you wanted to hit.

So, in your code you can delete the extra Scope and leave it like this:

```<code>string[] Scopes = { CalendarService.Scope.Calendar };
</code>```

Body:
I'm trying to create a Google Calendar Service Account.

Here are my credentials:

Here's my service account definition (Site Wide delegation for service account is enabled):

Here's my "Manage API client access" page:

And this is my code:

        string userName = "xxx@yyy.it";
        string[] Scopes = { CalendarService.Scope.Calendar, CalendarService.Scope.CalendarEvents };
        string ApplicationName = "Client per quickstart";
        ServiceAccountCredential credential = GoogleCredential.FromFile(@"path\credentialjson.json").CreateScoped(Scopes).CreateWithUser(userName).UnderlyingCredential as ServiceAccountCredential;

        // Create Google Calendar API service.
        var service = new CalendarService(new BaseClientService.Initializer()
        {
            HttpClientInitializer = credential,
            ApplicationName = ApplicationName
        });
        // THIS REQUEST FAILS!!
        var y = service.CalendarList.List().Execute();

The service is created correctly but all requests fail with this error:

Code: 401, Message: "Invalid Credentials", Location: "Authorization", >LocationType: "header", Reason: "authError", Domain: "global"

I don't understand what I'm missing in the authorization header.

What should I set before the request that was not done when creating the service? Thanks!

Body:
Your issue is due to the Scopes you are using at the same time, because you are setting CalendarService.Scope.CalendarEvents, this one will be the priority over CalendarService.Scope.Calendar, because the Google APIs always take as priority the most restricted Scope (in this case CalendarEvents).

And as you can see in the CalendarList: list endpoint scopes, the CalendarService.Scope.CalendarEvents is not a Scope you could use to  hit the endpoint you wanted to hit.

So, in your code you can delete the extra Scope and leave it like this:

string[] Scopes = { CalendarService.Scope.Calendar };


问:
Copy-paste with loop, different ranges under each other
I'm quiet new to vba.
I would like to have a code that copies up to 200 different ranges (B4:B48, C4:C48,D4:D48...GT4:GT48) to a cell (B50) and put the different ranges under each other.

So, the first ranges (B4:B48) should be put in cell B50, the second range (C4:C48) should be put in cell B95 etc.

I suppose this code will need a loop, however: not all the 200 ranges are filled, if there is an empty range then that range doesn't need to be copied.
Every range can contain a different number of items, although the maximum different number of items is always 42.

Thanks if you can help me further!

I added an example, the coulours are just making it more visual but aren't needed in vba-code.

答:
First you will need to copy each of your range one by one.

If your ranges B4:B48, C4:C48,D4:D48...GT4:GT48 follow a rule like always one column right, then you can use a loop going through all columns. B is column no 2 and GT is column no 202. So you can loop like

```<code>Dim iCol As Long
For iCol = 2 To 202
    'your code here
Next iCol
</code>```

The ranges eg B4:B48 can then be dynamically written as

```<code>ws.Range(ws.Cells(4, iCol), ws.Cells(48, iCol))
</code>```

wich means if iCol = 2 then Cells(4, iCol) is B4 and Cells(48, iCol) is B48 so it represents the range between those 2 cells. In the next iteration Next iCol will increase iCol by one so the same line represents column C now.

Note that in the code above ws represents your worksheet, you should specify that in the beginning so you can use that shortcut ws:

```<code>Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("YourSheetName")
</code>```

You will also need to find the last used cell in column B to determine the place where you need to paste your range. A good way to do this is:

```<code>Dim LastUsedRow As Long
LastUsedRow = ws.Cells(ws.Rows.Count, "B").End(xlUp).Row
</code>```

So now your next free row in column B is LastUsedRow + 1 and this is where you should paste.

Give it a try on your own, do some research if you get stuck. I gave you pretty much of what you need. The rest should be really basic stuff you can easily figure out by reading some basic tutorials or google.

Two last things that will prevent you from running into common issues:

I recommend always to activate Option Explicit: In the VBA editor go to Tools › Options › Require Variable Declaration and declare all your variables properly.

You might benefit from reading How to avoid using Select in Excel VBA. Using .Select or .Activate should be avoided at any cost. It slows down everything a lot and your code will run into issues easily soon or later.

Body:
First you will need to copy each of your range one by one.

If your ranges B4:B48, C4:C48,D4:D48...GT4:GT48 follow a rule like always one column right, then you can use a loop going through all columns. B is column no 2 and GT is column no 202. So you can loop like

Dim iCol As Long
For iCol = 2 To 202
    'your code here
Next iCol

The ranges eg B4:B48 can then be dynamically written as

ws.Range(ws.Cells(4, iCol), ws.Cells(48, iCol))

wich means if iCol = 2 then Cells(4, iCol) is B4 and Cells(48, iCol) is B48 so it represents the range between those 2 cells. In the next iteration Next iCol will increase iCol by one so the same line represents column C now.

Note that in the code above ws represents your worksheet, you should specify that in the beginning so you can use that shortcut ws:

Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("YourSheetName")

You will also need to find the last used cell in column B to determine the place where you need to paste your range. A good way to do this is:

Dim LastUsedRow As Long
LastUsedRow = ws.Cells(ws.Rows.Count, "B").End(xlUp).Row

So now your next free row in column B is LastUsedRow + 1 and this is where you should paste.

Give it a try on your own, do some research if you get stuck. I gave you pretty much of what you need. The rest should be really basic stuff you can easily figure out by reading some basic tutorials or google.

Two last things that will prevent you from running into common issues:

I recommend always to activate Option Explicit: In the VBA editor go to Tools › Options › Require Variable Declaration and declare all your variables properly.

You might benefit from reading How to avoid using Select in Excel VBA. Using .Select or .Activate should be avoided at any cost. It slows down everything a lot and your code will run into issues easily soon or later.


问:
Loop through array with objects with optional properties but always loop fully
I want to iterate through an array of objects defined like this:

```<code>export interface Incident {
  ID: string;
  userName1?: string;
  userName2?: string;
  userPhoneNumber?: string;
  crashSeverity: number;
  crashTime: number;
}
</code>```

Now I have some sample data like this:

```<code>  {
    crashID: "CO111111",
    userName1: "TEST",
    userName2: "NAME2",
    userPhoneNumber: "11111",
    crashSeverity: 2,
    crashTime: 1571566666
  },
  {
    crashID: "12345",
    userName1: "TEST",
    crashSeverity: 2,
    crashTime: 1571566666
  }
</code>```

However, I want to save the data to a csv file. For this, I need to always iterate through the whole interface, even if some properties are missing and still write a comma.
Is there a way to iterate through the whole incident interface for each object and not just all the available properties?

Here is an example output:

My current code:

```<code>
  ConvertToCSV(objArray) {
    const array =
      typeof objArray !== "object" ? JSON.parse(objArray) : objArray;
    let str = "";
    let header = "";

    for (const index in objArray[0]) {
      header += index + ";";
    }
    header = header.slice(0, -1);
    // append Label row with line break
    str += header + "\r\n";

    // loop through every entry
    for (let i = 0; i < array.length; i++) {
      let line = "";
      // loop through every row
      for (const firstIndex in array[i]) {
          line += array[i][firstIndex] + ";";
      }
      str += line + "\r\n";
    }
    return str;
  }

</code>```

答:
Interfaces only exist at compile time. They don't exist at run time, so you cannot inspect them with code.

Without that possibility, you could still do something to at least make sure the output CSV is well-formed, i.e. all values appear in their right column.

For this you would need to first inspect the whole data, and collect all used fields. When fields are often lacking, you will need some logic to derive which is the right field ordering. For instance if you have two objects, and the first has only fields "a" and "b", and the second only field "c" and "d", there is no way to know the correct field ordering. It could be "a;b;c;d", or "a;c;b;d", or "c;a;b;d", ...etc. However, if there is also a third object that has fields "b" and "c", then the order is perfectly defined: "a;b;c;d". This is about finding a topological order.

So here is code that first performs such a scan and ordering, and then proceeds to actually encode the data as CSV in a second phase:

function convertToCSV(objArray) {
    const array =
        typeof objArray === "string" ? JSON.parse(objArray) : objArray;

    // Iterate the whole array to find any fields
    //    Keep track of which fields have to precede other fields
    const predecessors = new Map;
    for (const obj of array) {
        Object.keys(obj).forEach((key, i, keys) => {
            if (!predecessors.has(key)) predecessors.set(key, new Set);
            if (i) predecessors.get(key).add(keys[i-1]);
        });
    }
    // Sort fields
    const fields = topologicalSort(predecessors);

    return [fields.join(";"), // header line
        ...array.map(obj => fields.map(field => obj[field] || "").join(";")) // data lines
    ].join("\r\n");
}

function topologicalSort(predecessors) {
    const visited = new Set;

    function visit(key) {
        if (visited.has(key)) return;
        predecessors.get(key).forEach(visit);
        visited.add(key);
    }

    for (let key of predecessors.keys()) visit(key);
    return [...visited];
}

// Sample data
const data = [{
    userName2: "NAME2",
    userPhoneNumber: "11111",
    crashSeverity: 2,
  }, {
    userName1: "TEST",
    crashSeverity: 2,
    crashTime: 1571577777
  }, {
    crashID: "12345",
    userName1: "Mr First",
    userName2: "Second name",
    crashSeverity: 3,
    crashTime: 1571588888
  }];

const csv = convertToCSV(data);
console.log(csv);```

Body:
I want to iterate through an array of objects defined like this:

export interface Incident {
  ID: string;
  userName1?: string;
  userName2?: string;
  userPhoneNumber?: string;
  crashSeverity: number;
  crashTime: number;
}

Now I have some sample data like this:

  {
    crashID: "CO111111",
    userName1: "TEST",
    userName2: "NAME2",
    userPhoneNumber: "11111",
    crashSeverity: 2,
    crashTime: 1571566666
  },
  {
    crashID: "12345",
    userName1: "TEST",
    crashSeverity: 2,
    crashTime: 1571566666
  }

However, I want to save the data to a csv file. For this, I need to always iterate through the whole interface, even if some properties are missing and still write a comma.
Is there a way to iterate through the whole incident interface for each object and not just all the available properties?

Here is an example output:

My current code:

  ConvertToCSV(objArray) {
    const array =
      typeof objArray !== "object" ? JSON.parse(objArray) : objArray;
    let str = "";
    let header = "";

    for (const index in objArray[0]) {
      header += index + ";";
    }
    header = header.slice(0, -1);
    // append Label row with line break
    str += header + "\r\n";

    // loop through every entry
    for (let i = 0; i < array.length; i++) {
      let line = "";
      // loop through every row
      for (const firstIndex in array[i]) {
          line += array[i][firstIndex] + ";";
      }
      str += line + "\r\n";
    }
    return str;
  }


问:
Send e-mail code is sending a blank file, unless the template is saved first
The code below is used in other files to send in effect a form for review and approval, but within this workbook for some reason I am getting blank files sent and the content added by the users is lost.  I know this isn't a code checking service, but I was wondering have I missed something with this - so I need to have the file 'saved' before it is attached to the e-mail?

```<code>    'Open e-mail and create a new message
Set OutlookApp = CreateObject("Outlook.Application")
Set OlObjects = OutlookApp.GetNamespace("MAPI")
Set newmsg = OutlookApp.CreateItem(olMailItem)
Dim SubmitEMail As String: SubmitEMail = ws.Range("U1").Value

' set the requirements for the new message
With newmsg
    .Recipients.Add SubmitEMail
    .CC = ws.Range("U2").Value
    .Subject = "New Concession request form submitted"
'use string defined above as the main body of the message
    .Body = "Dear " & Location & "," & vbLf & vbLf & "Please find attached: a new Concession request.  Please review and indicate Concession number, or provide details of amendments needed." & vbLf & vbLf & "Regards," & vbLf & vbLf & SenderName
    .Attachments.Add wb.FullName
    .Display
End With
End If

MsgBox "Please review the E-Mail, Adding any additional recipients as required. add your signature and send to complete the submission"
</code>```

The e-mail sending bit works perfectly, but the attachment is always blank, the data the user has added is lost (if the user saves the workbook first on their local station) the process works perfectly, but I am wanting to avoid asking them to so this - potentially creates 2 versions of a document where I only want one)

答:
You need a saved Workbook to attach. If you want to make sure there are no unneeded duplicates, you can do the following:

Save a copy of the workbook in a temp folder (with SaveCopyAs)

attach this copy to the email and display

delete the copy in the temp folder

Body:
The code below is used in other files to send in effect a form for review and approval, but within this workbook for some reason I am getting blank files sent and the content added by the users is lost.  I know this isn't a code checking service, but I was wondering have I missed something with this - so I need to have the file 'saved' before it is attached to the e-mail?

    'Open e-mail and create a new message
Set OutlookApp = CreateObject("Outlook.Application")
Set OlObjects = OutlookApp.GetNamespace("MAPI")
Set newmsg = OutlookApp.CreateItem(olMailItem)
Dim SubmitEMail As String: SubmitEMail = ws.Range("U1").Value

' set the requirements for the new message
With newmsg
    .Recipients.Add SubmitEMail
    .CC = ws.Range("U2").Value
    .Subject = "New Concession request form submitted"
'use string defined above as the main body of the message
    .Body = "Dear " & Location & "," & vbLf & vbLf & "Please find attached: a new Concession request.  Please review and indicate Concession number, or provide details of amendments needed." & vbLf & vbLf & "Regards," & vbLf & vbLf & SenderName
    .Attachments.Add wb.FullName
    .Display
End With
End If

MsgBox "Please review the E-Mail, Adding any additional recipients as required. add your signature and send to complete the submission"

The e-mail sending bit works perfectly, but the attachment is always blank, the data the user has added is lost (if the user saves the workbook first on their local station) the process works perfectly, but I am wanting to avoid asking them to so this - potentially creates 2 versions of a document where I only want one)


问:
Redirecting after form submission with user input in the URL
I need to have a form that when filled out will create a variable and then goto a url with that variable in the url.

Something like this (but that works) :)

```<code><form action="?????" method="?????">

Number: <input type="text" name="url1" value=""><br>

<input type="submit" name="submit" value="Goto URL">
</form>
</code>```

When the submit is pressed I need it to goto http://somewhere.com?url=VALUEHERE

Any ideas?

答:
Different from 1st. No form needed, add an attribute named 'id' for the textfield,then defined a javascript function to retrieve the value of textfield,then do the jump, Hope usefully.</p>

```<code><form action="?????" method="?????">

Number: <input id="url1" type="text" name="url1" value=""><br>

<input type="button" name="submit" value="gotoURL()">
</form>

<script>
function gotoURL(){
window.location='http://somewhere.com?url='+document.getElementById('url1').value;
}
</script>
</code>```

Body:
I need to have a form that when filled out will create a variable and then goto a url with that variable in the url.

Something like this (but that works) :)

<form action="?????" method="?????">

Number: <input type="text" name="url1" value="">

<input type="submit" name="submit" value="Goto URL">
</form>

When the submit is pressed I need it to goto http://somewhere.com?url=VALUEHERE

Any ideas?

Body:
Different from 1st. No form needed, add an attribute named 'id' for the textfield,then defined a javascript function to retrieve the value of textfield,then do the jump, Hope usefully.

<form action="?????" method="?????">

Number: <input id="url1" type="text" name="url1" value=""><br>

<input type="button" name="submit" value="gotoURL()">
</form>

<script>
function gotoURL(){
window.location='http://somewhere.com?url='+document.getElementById('url1').value;
}
</script>


问:
How to change nav "active" class on different pages with base.html
I have my navbar on my base.html, so I extend it on all other pages.
But I have a class "active" on the home page, so it also stays active in all other pages.

```<code><ul class="navbar-nav">
    <li class="nav-item">
        <a class="nav-link active" href="http://127.0.0.1:8000/backend/">
            <i class="ni ni-shop text-primary"></i>
            <span class="nav-link-text">Dashboard</span>
        </a>
    </li>
    <li class="nav-item">
        <a class="nav-link" href="http://127.0.0.1:8000/backend/clientes">
            <i class="ni ni-ungroup text-orange"></i>
            <span class="nav-link-text">Clients</span>
        </a>
    </li>
</ul>
</code>```

How can I change the active class to a different menu item based on the page I am?

答:
Send name as variable and value with active.

```<code>def index(request):
   # your code

    context = {

        'dashboard': 'active',
    }

    return render(request, 'index.html', context)

def clients(request):
   # your code

    context = {

        'clients': 'active',
    }

    return render(request, 'clients.html', context)
</code>```

Use variable like this:

```<code><ul class="navbar-nav">
    <li class="nav-item">
        <a class="nav-link {{ dashboard }}" href="http://127.0.0.1:8000/backend/">
            <i class="ni ni-shop text-primary"></i>
            <span class="nav-link-text">Dashboard</span>
        </a>
    </li>
    <li class="nav-item">
        <a class="nav-link {{ clients }}" href="http://127.0.0.1:8000/backend/clientes">
            <i class="ni ni-ungroup text-orange"></i>
            <span class="nav-link-text">Clients</span>
        </a>
    </li>
</ul>
</code>```

Body:
I have my navbar on my base.html, so I extend it on all other pages.
But I have a class "active" on the home page, so it also stays active in all other pages.

            Dashboard

            Clients

How can I change the active class to a different menu item based on the page I am?

Body:
Send name as variable and value with active.

def index(request):
   # your code

    context = {

        'dashboard': 'active',
    }

    return render(request, 'index.html', context)

def clients(request):
   # your code

    context = {

        'clients': 'active',
    }

    return render(request, 'clients.html', context)

Use variable like this:

<ul class="navbar-nav">
    <li class="nav-item">
        <a class="nav-link {{ dashboard }}" href="http://127.0.0.1:8000/backend/">
            <i class="ni ni-shop text-primary"></i>
            <span class="nav-link-text">Dashboard</span>
        </a>
    </li>
    <li class="nav-item">
        <a class="nav-link {{ clients }}" href="http://127.0.0.1:8000/backend/clientes">
            <i class="ni ni-ungroup text-orange"></i>
            <span class="nav-link-text">Clients</span>
        </a>
    </li>
</ul>


问:
Logging issue for akka typed 2.6.3
Logs have stopped working for me for akka typed actor(2.6.3). It was working well for classic actors.

Message is as:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".

SLF4J: Defaulting to no-operation (NOP) logger implementation

SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

SLF4J: Failed to load class "org.slf4j.impl.StaticMDCBinder".

SLF4J: Defaulting to no-operation MDCAdapter implementation.

SLF4J: See http://www.slf4j.org/codes.html#no_static_mdc_binder for further details.

答:
Need to add following dependency:

libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.2.3"

Title: Logging issue for akka typed 2.6.3


问:
Hiding span under div in CSS
Below is the code for my WP post. I'm trying to hide the span for comment. So that it doesn't appear on the blog post.

```<code><div class="blog-stats">
    <span class="clock">
        <i class="fa fa-calendar stats-item"></i>
        <span class="text-center text-light stats-item">February 15, 2020</span>
    </span>
    <span class="comment">
        <i class="fa fa-comment stats-item"></i>
        <span class="text-center text-light stats-item">no comments</span>
    </span>
    <span class="user">
        <i class="fa fa-user stats-item"></i>
        <span class="text-content text-light stats-item">Wayne John</span>
    </span>
</div>
</code>```

I tried a few below and it didn't work.

```<code>.blog-stats.comment {
    display: none;
}

span .comment {
    display: none;
}

span.comment {
    display: none;
}
</code>```

Any idea how to fix it?

答:
your CSS code is OKAY!

try putting "!important" besides your style and clear your browser cache. maybe fixed.

Title: Hiding span under div in CSS

Body:
Below is the code for my WP post. I'm trying to hide the span for comment. So that it doesn't appear on the blog post.

        February 15, 2020

        no comments

        Wayne John

I tried a few below and it didn't work.

.blog-stats.comment {
    display: none;
}

span .comment {
    display: none;
}

span.comment {
    display: none;
}

Any idea how to fix it?


问:
Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead
How to fix Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "show" problem?

my SnackbarComponent.vue:

```<code><template>
  <v-snackbar
    v-model="show"
    :top="pinY === 'top'"
    :right="pinX === 'right'"
    :bottom="pinY === 'bottom'"
    :left="pinX === 'left'"
    :color="variant"
    :timeout="timeout"
    :vertical="mode === 'vertical'"
    :multi-line="mode === 'multi-line'"
  >
    {{ message }}
    <v-btn fab @click="show = false" color="transparent" depressed>
      close
    </v-btn>
  </v-snackbar>
</template>
<script>
export default {
  props: {
    show: {
      type: Boolean,
      required: true,
      default: false
    },
  },
  data() {
    return {

    }
  }
}
</script>
</code>```

答:
You cannot mutate a prop directly instead you can emit an event from
  child component & change the data property being passed as a prop to
  the child component as per requirement.

To read more: https://vegibit.com/vuejs-parent-child-communication/

Child.vue

```<code><template>
  <v-snackbar
    v-model="show"
    :top="pinY === 'top'"
    :right="pinX === 'right'"
    :bottom="pinY === 'bottom'"
    :left="pinX === 'left'"
    :color="variant"
    :timeout="timeout"
    :vertical="mode === 'vertical'"
    :multi-line="mode === 'multi-line'"
  >
    {{ message }}
    <v-btn fab @click="handleClose" color="transparent" depressed>
      close
    </v-btn>
  </v-snackbar>
</template>

<script>
export default {
  props: {
    show: {
      type: Boolean,
      required: true,
      default: false
    },
  },
  data() {
    return {}
  },
  methods: {
   handleClose() {
    this.$emit('onClose')
   }
  }
}
</script>
</code>```

Parent.vue

```<code><template>
 <div>
  <Child
   :show="show"
   @onClose="handleClose"
  />
 </div>
</template>

<script>
 import Child from './Child.vue'
 export default {
  data () {
   return {
    show: true
   }
  },
  components: {
   Child
  },
  methods: {
   handleClose () {
    this.show = false
   }
  }
 }
</script>
</code>```

So, here child is emitting an event on the close button, on emit a handler fn in the parent is called where data property show in the parent is set to false. And, since the show is being passed as a prop to a child component, the child gets the updated value for prop show & update the component accordingly.

Body:
How to fix Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "show" problem?

my SnackbarComponent.vue:

<template>
  <v-snackbar
    v-model="show"
    :top="pinY === 'top'"
    :right="pinX === 'right'"
    :bottom="pinY === 'bottom'"
    :left="pinX === 'left'"
    :color="variant"
    :timeout="timeout"
    :vertical="mode === 'vertical'"
    :multi-line="mode === 'multi-line'"
  >
    {{ message }}
    <v-btn fab @click="show = false" color="transparent" depressed>
      close
    </v-btn>
  </v-snackbar>
</template>

Body:
You cannot mutate a prop directly instead you can emit an event from
  child component & change the data property being passed as a prop to
  the child component as per requirement.

To read more: https://vegibit.com/vuejs-parent-child-communication/

Child.vue

<template>
  <v-snackbar
    v-model="show"
    :top="pinY === 'top'"
    :right="pinX === 'right'"
    :bottom="pinY === 'bottom'"
    :left="pinX === 'left'"
    :color="variant"
    :timeout="timeout"
    :vertical="mode === 'vertical'"
    :multi-line="mode === 'multi-line'"
  >
    {{ message }}
    <v-btn fab @click="handleClose" color="transparent" depressed>
      close
    </v-btn>
  </v-snackbar>
</template>

<script>
export default {
  props: {
    show: {
      type: Boolean,
      required: true,
      default: false
    },
  },
  data() {
    return {}
  },
  methods: {
   handleClose() {
    this.$emit('onClose')
   }
  }
}
</script>

Parent.vue

<template>
 <div>
  <Child
   :show="show"
   @onClose="handleClose"
  />
 </div>
</template>

<script>
 import Child from './Child.vue'
 export default {
  data () {
   return {
    show: true
   }
  },
  components: {
   Child
  },
  methods: {
   handleClose () {
    this.show = false
   }
  }
 }
</script>

So, here child is emitting an event on the close button, on emit a handler fn in the parent is called where data property show in the parent is set to false. And, since the show is being passed as a prop to a child component, the child gets the updated value for prop show & update the component accordingly.


问:
Creating simple path edges not contained in BFS
First off...here's the problem...

Give an example of a directed graph G = (V, E), a source vertex s in V, and a set of tree edges F contained in E, such that for each vertex contained in V, the unique simple path in the graph (V, F) from s to v is a shortest path in G, yet the set of edges F cannot be produced by running BFS on G, no matter how the vertices are ordered in each adjacency list.

Now...since this IS homework, I don't want a straight-out answer, but more of ideas for things to look at/try.  But, here's what I've thought of so far...

I've basically figured that I can create a graph that has several shortest paths to a particular vertex.  Of course, one of those paths would be found in the BFS.  But, I can use one of the alternate routes to fit into F.  However, the part that is throwing me off is the "no matter how the vertices are ordered"... I'm not sure how to include that in to my process.  I've tried loops, various different directional flows, and nothing yet.

Any other ideas?

答:
```<code>    3
 s ---- x
 |     /
1|    / 1
 |   /
 |  /
 y
</code>```

In case the above picture doesn't show

Assume

E = { ((s, x) : 3), ((s, y) : 1), ((y, x) : 1) }

where the two-tuples are ordered pairs with weights attached.

The edge set F = { (s, y), (y, x) } contains all the vertices of the graph.  Further, the unique simple path it contains from s to x is the shortest path in the graph from s to x.  However, F will never be found by a BFS.

Starting from s, x and y will be discovered and marked gray.
Then, when y is explored, it will only find one other gray vertex, i.e. x, and not add it as a descendant in the resulting breadth-first tree.

ContentLicense: CC BY-SA 2.5

Body:
    3
 s ---- x
 |     /
1|    / 1
 |   /
 |  /
 y

In case the above picture doesn't show

Assume

E = { ((s, x) : 3), ((s, y) : 1), ((y, x) : 1) }

where the two-tuples are ordered pairs with weights attached.

The edge set F = { (s, y), (y, x) } contains all the vertices of the graph.  Further, the unique simple path it contains from s to x is the shortest path in the graph from s to x.  However, F will never be found by a BFS.

Starting from s, x and y will be discovered and marked gray.
Then, when y is explored, it will only find one other gray vertex, i.e. x, and not add it as a descendant in the resulting breadth-first tree.


问:
testing react-redux useSelector
I have a react application which uses react-redux, useSelector to get data from the store.
The react component has

```<code>function PersonDataView() {
  const name= useSelector(state => state.data.name)
  const dob= useSelector(state => state.data.dob)
  const dispatch = useDispatch()
  const show= () => dispatch({type: 'SHOW'})
  const remove= () => dispatch({type: 'REMOVE'})
  return (
    <div>
      <h2>Person Details</h2>
     <div>
      <button onClick={show}>Show</button>
      <span aria-label="name">{name}</span>
      <span aria-label="dob">{dob}</span>
      <button onClick={remove}>Remove</button>
     </div>
   </div>
  )
}
</code>```

I am using react-testing-library to test this component. Is there any API which makes testing these components easier for us. I know two ways of testing these:
1) I can mock the store using redux-mock-store and then wrap this component under provider component.
2) mock the useSelector method in jest

```<code>jest.mock('react-redux', () => ({
  useSelector: () => ({
  })
});
</code>```

But the problem using jest mock is in case of multiple selector, all the useSelectors will return same mocked value.
Using jest way of mocking, jest.fn().mockReturnValueOnce() doesn't look correct to me.

答:
Try this:</p>

```<code>jest.mock('react-router');
const useSelectorMock = useSelector as any;

describe('something', () {

test('name', () => {

// Use this for each useSelector call:
useSelectorMock.mockImplementationOnce(jest.fn(() => returnValue as yourType));
}

}
</code>```

Title: testing react-redux useSelector

Body:
I have a react application which uses react-redux, useSelector to get data from the store.
The react component has

function PersonDataView() {
  const name= useSelector(state => state.data.name)
  const dob= useSelector(state => state.data.dob)
  const dispatch = useDispatch()
  const show= () => dispatch({type: 'SHOW'})
  const remove= () => dispatch({type: 'REMOVE'})
  return (

Person Details

      <button onClick={show}>Show</button>
      {name}
      {dob}
      <button onClick={remove}>Remove</button>

  )
}

I am using react-testing-library to test this component. Is there any API which makes testing these components easier for us. I know two ways of testing these:
1) I can mock the store using redux-mock-store and then wrap this component under provider component.
2) mock the useSelector method in jest

jest.mock('react-redux', () => ({
  useSelector: () => ({
  })
});

But the problem using jest mock is in case of multiple selector, all the useSelectors will return same mocked value.
Using jest way of mocking, jest.fn().mockReturnValueOnce() doesn't look correct to me.

Body:
Try this:

jest.mock('react-router');
const useSelectorMock = useSelector as any;

describe('something', () {

test('name', () => {

// Use this for each useSelector call:
useSelectorMock.mockImplementationOnce(jest.fn(() => returnValue as yourType));
}

}


问:
List of multiple class to run same function name C++
I have multiple classes with same function as below

```<code>class A
{
  void display()
  {
    // display something
  }
};

class B
{
  void display()
  {
    // display something two
  }
};
</code>```

I want to store difference class at a list or a vector and loop to call the same function with same name

```<code>int main()
{
  A * a;

  B * b;

  //list or vector to store object

  std::vector < Something that can store different class > listofclass;

  listofclass.emplace_back(a);

  listofclass.emplace_back(b);

  for (int i = 0; i < listofclass.size(); i++)

  {

    listofclass[i].display();

  }
}
</code>```

Is that possible to do like this?
Because there is separate classes, having different purpose, and now i try to group them together
Or there is other alternative way to achieve something like this

答:
If you control the definition of A and B, you can write a common base class, and have them inherit it.

```<code>class can_display {
public:
  virtual void display() = 0;
  virtual ~can_display() = default;
};

class A : public can_display
{
  void display() override
  {
    // display something
  }
};

class B : public can_display
{
  void display() override
  {
    // display something two
  }
};

int main()
{
  A a;

  B b;

  std::vector<can_display *> displayables;

  displayables.push_back(&a);

  displayables.push_back(&b);

  for (can_display * displayable : displayables)
  {
    displayable->display();
  }
}
</code>```

As an alternative to changing the definition of A and B to inherit from a common base, you can have a wrapper that inherits.

```<code>template <typename T>
class can_display_impl {
  T * wrapped;
public:
  can_display_impl(T * wrapped) : wrapped(wrapped) {}
  void display() override { wrapped->display(); }
}

template <typename T>
std::unique_ptr<can_display> make_can_display(T & wrapped) {
  return std::make_unique<can_display_impl<T>>(&wrapped);
}

int main()
{
  A a;

  B b;

  std::vector<std::unique_ptr<can_display>> displayables;

  displayables.emplace_back(make_can_display(a));

  displayables.emplace_back(make_can_display(b));

  for (auto & displayable : displayables)
  {
    displayable->display();
  }
}
</code>```

Body:
I have multiple classes with same function as below

class A
{
  void display()
  {
    // display something
  }
};

class B
{
  void display()
  {
    // display something two
  }
};

I want to store difference class at a list or a vector and loop to call the same function with same name

int main()
{
  A * a;

  B * b;

  //list or vector to store object

  std::vector < Something that can store different class > listofclass;

  listofclass.emplace_back(a);

  listofclass.emplace_back(b);

  for (int i = 0; i < listofclass.size(); i++)

  {

    listofclass[i].display();

  }
}

Is that possible to do like this?
Because there is separate classes, having different purpose, and now i try to group them together
Or there is other alternative way to achieve something like this

Body:
If you control the definition of A and B, you can write a common base class, and have them inherit it.

class can_display {
public:
  virtual void display() = 0;
  virtual ~can_display() = default;
};

class A : public can_display
{
  void display() override
  {
    // display something
  }
};

class B : public can_display
{
  void display() override
  {
    // display something two
  }
};

int main()
{
  A a;

  B b;

  std::vector<can_display *> displayables;

  displayables.push_back(&a);

  displayables.push_back(&b);

  for (can_display * displayable : displayables)
  {
    displayable->display();
  }
}

As an alternative to changing the definition of A and B to inherit from a common base, you can have a wrapper that inherits.

template <typename T>
class can_display_impl {
  T * wrapped;
public:
  can_display_impl(T * wrapped) : wrapped(wrapped) {}
  void display() override { wrapped->display(); }
}

template <typename T>
std::unique_ptr<can_display> make_can_display(T & wrapped) {
  return std::make_unique<can_display_impl<T>>(&wrapped);
}

int main()
{
  A a;

  B b;

  std::vector<std::unique_ptr<can_display>> displayables;

  displayables.emplace_back(make_can_display(a));

  displayables.emplace_back(make_can_display(b));

  for (auto & displayable : displayables)
  {
    displayable->display();
  }
}


问:
jQuery add class based on parent URL
on my homepage, I currently have a jQuery that adds a class (in this case an underline) to the link element. This works great and is based on comparing the url (url/firstsubmenu) in the browser with the href of the link element.

However as soon as I go to a child of that link element (url/firstsubmenu/secondsubmenu), the class is gone. I have tried to split the url so that the jQuery always looks for the parent but I just can't solve it. Can you help me?

Could it be solved by adding another code, like maybe "if (this).children().length > 0 ?"

Here is my jQuery:

```<code>var cururl = window.location.href;
cururl = cururl.split('#')[0];
jQuery("a.rs-layer").each(function(){
    if(jQuery(this).attr('href')=== cururl){
        jQuery(this).addClass("current-slider-menu");
    }
});
</code>```

EDIT: I am new to this, and I have tried so many different codes, googled for hours. I now know that I can only write JavaScript in my CMS. That is, I cannot use jQuery operators such as, for example, $.

答:
EDITED

try   this

```<code>  var cururl = window.location.href;
    jQuery("rs-layer[id|='"+cururl.split('/')[3]+"'] , .rs-layer[href='"+cururl+"']").each(function(){
           jQuery(this).addClass("current-slider-menu");
    });
</code>```

Title: jQuery add class based on parent URL

Body:
on my homepage, I currently have a jQuery that adds a class (in this case an underline) to the link element. This works great and is based on comparing the url (url/firstsubmenu) in the browser with the href of the link element.

However as soon as I go to a child of that link element (url/firstsubmenu/secondsubmenu), the class is gone. I have tried to split the url so that the jQuery always looks for the parent but I just can't solve it. Can you help me?

Could it be solved by adding another code, like maybe "if (this).children().length > 0 ?"

Here is my jQuery:

var cururl = window.location.href;
cururl = cururl.split('#')[0];
jQuery("a.rs-layer").each(function(){
    if(jQuery(this).attr('href')=== cururl){
        jQuery(this).addClass("current-slider-menu");
    }
});

EDIT: I am new to this, and I have tried so many different codes, googled for hours. I now know that I can only write JavaScript in my CMS. That is, I cannot use jQuery operators such as, for example, $.

Body:
EDITED

try   this

  var cururl = window.location.href;
    jQuery("rs-layer[id|='"+cururl.split('/')[3]+"'] , .rs-layer[href='"+cururl+"']").each(function(){
           jQuery(this).addClass("current-slider-menu");
    });


答:
Add below CSS and try : </p>

```<code><style type="text/css">
    .blog-stats .comment span{
          display: none !important;
      }
 </style>
</code>```

Title: Hiding span under div in CSS

Body:
Add below CSS and try :

<style type="text/css">
    .blog-stats .comment span{
          display: none !important;
      }
 </style>