问:
Select the last element of an Array in a DataFrame
I'm working on a project and I'm dealing with some nested JSON date with a complicated schema/data structure. Basically what I want to do is filter out one of the columns, in a dataframe, such that I select the last element in the array. I'm totally stuck on how to do this. I hope this make sense.

Below is an example of what I'm trying to accomplish:

```<code>val singersDF = Seq(
  ("beatles", "help,hey,jude"),
  ("romeo", "eres,mia"),
  ("elvis", "this,is,an,example")
).toDF("name", "hit_songs")

val actualDF = singersDF.withColumn(
  "hit_songs",
  split(col("hit_songs"), "\\,")
)

actualDF.show(false)
actualDF.printSchema()

+-------+-----------------------+
|name   |hit_songs              |
+-------+-----------------------+
|beatles|[help, hey, jude]      |
|romeo  |[eres, mia]            |
|elvis  |[this, is, an, example]|
+-------+-----------------------+
root
 |-- name: string (nullable = true)
 |-- hit_songs: array (nullable = true)
 |    |-- element: string (containsNull = true)
</code>```

The end goal for the output would be the following, to select the last "string" in the hit_songs array.

I'm not worried about what the schema would look like afterwards.

```<code>+-------+---------+
|name   |hit_songs|
+-------+---------+
|beatles|jude     |
|romeo  |mia      |
|elvis  |example  |
+-------+---------+
</code>```

答:
Since spark 2.4+, you can use element_at which supports negative indexing. As you can see in this documentation quote:

element_at(array, index) - Returns element of array at given (1-based) index. If index < 0, accesses elements from the last to the first. Returns NULL if the index exceeds the length of the array.

With that, here's how to get the last element:

```<code>import org.apache.spark.sql.functions.element_at
actualDF.withColumn("hit_songs", element_at($"hit_songs", -1))
</code>```

Reproducible example:

First let's prepare a sample dataframe with an array column:

```<code>val columns = Seq("col1")
val data = Seq((Array(1,2,3)))
val rdd = spark.sparkContext.parallelize(data)
val df = rdd.toDF(columns:_*)
</code>```

which looks like this:

```<code>scala> df.show()
+---------+
|     col1|
+---------+
|[1, 2, 3]|
+---------+
</code>```

Then, apply element_at to get the last element as follows:

```<code>scala> df.withColumn("last_value", element_at($"col1", -1)).show()
+---------+----------+
|     col1|last_value|
+---------+----------+
|[1, 2, 3]|         3|
+---------+----------+
</code>```

Body:
I'm working on a project and I'm dealing with some nested JSON date with a complicated schema/data structure. Basically what I want to do is filter out one of the columns, in a dataframe, such that I select the last element in the array. I'm totally stuck on how to do this. I hope this make sense.

Below is an example of what I'm trying to accomplish:

val singersDF = Seq(
  ("beatles", "help,hey,jude"),
  ("romeo", "eres,mia"),
  ("elvis", "this,is,an,example")
).toDF("name", "hit_songs")

val actualDF = singersDF.withColumn(
  "hit_songs",
  split(col("hit_songs"), "\\,")
)

actualDF.show(false)
actualDF.printSchema()

+-------+-----------------------+
|name   |hit_songs              |
+-------+-----------------------+
|beatles|[help, hey, jude]      |
|romeo  |[eres, mia]            |
|elvis  |[this, is, an, example]|
+-------+-----------------------+
root
 |-- name: string (nullable = true)
 |-- hit_songs: array (nullable = true)
 |    |-- element: string (containsNull = true)

The end goal for the output would be the following, to select the last "string" in the hit_songs array.

I'm not worried about what the schema would look like afterwards.

+-------+---------+
|name   |hit_songs|
+-------+---------+
|beatles|jude     |
|romeo  |mia      |
|elvis  |example  |
+-------+---------+

Body:
Since spark 2.4+, you can use element_at which supports negative indexing. As you can see in this documentation quote:

element_at(array, index) - Returns element of array at given (1-based) index. If index < 0, accesses elements from the last to the first. Returns NULL if the index exceeds the length of the array.

With that, here's how to get the last element:

import org.apache.spark.sql.functions.element_at
actualDF.withColumn("hit_songs", element_at($"hit_songs", -1))

Reproducible example:

First let's prepare a sample dataframe with an array column:

val columns = Seq("col1")
val data = Seq((Array(1,2,3)))
val rdd = spark.sparkContext.parallelize(data)
val df = rdd.toDF(columns:_*)

which looks like this:

scala> df.show()
+---------+
|     col1|
+---------+
|[1, 2, 3]|
+---------+

Then, apply element_at to get the last element as follows:

scala> df.withColumn("last_value", element_at($"col1", -1)).show()
+---------+----------+
|     col1|last_value|
+---------+----------+
|[1, 2, 3]|         3|
+---------+----------+


来源: stackexchange

问:
RIA Services: Enumerate Deleted Entities
My RIA service context class has an entity set TaskToOperationAssociations which contains a list of Task to Operation associations.

Is there a way to "find" an association entity which has been removed from the collection? I can see that the context has a reference to the removed Association in it's private fields (it obviously needs to keep track of it so the delete operation can be submitted).

Here's an example...

If I have Task "A" (with Id=T1) which is associated to Operation X, Y and Z (with id's O1,O2 and O3) and task B (with Id=T2) is associated with the same operations then the collection will contain 3 TaskToOperationAssociations as follows...

Association A1, TaskId = T1, OperationID = 1

Association A2, TaskId = T1, OperationID = 2

Association A3, TaskId = T1, OperationID = 3

Association A4, TaskId = T2, OperationID = 1

Association A5, TaskId = T2, OperationID = 2

Association A6, TaskId = T2, OperationID = 3

I remove association A1 and catch the property change event of the TaskToOperationAssociations. In the event handler I want to find out if any of the associations for Task T1 have changed so I can enable a save button on the UI.

Hope this makes sense.
Thanks
Ben

答:
Maybe this can help you

```<code>var deleted = Context.EntityContainer.GetChanges().RemovedEntities
    .Where(re => re is TaskToOperationAssociations && ((TaskToOperationAssociations)re.GetOriginal()).TaskId == T1.Id)
    .Select(re => (TaskToOperationAssociations)re);
</code>```

or just

```<code>var hasDeleted = Context.EntityContainer.GetChanges().RemovedEntities
    .Any(re => re is TaskToOperationAssociations && ((TaskToOperationAssociations)re.GetOriginal()).TaskId == T1.Id)
</code>```

to find out if there are any deleted associations for T1

with

```<code>foreach (var assoc in deleted)
{
   Context.TaskToOperationAssociations.Add(assoc);
   ((IRevertibleChangeTracking)assoc).RejectChanges();
   ((IRevertibleChangeTracking)T1).RejectChanges();
}
</code>```

you can completely undo the deletion (if you have not committed your changes yet)

ContentLicense: CC BY-SA 2.5

Body:
Maybe this can help you

var deleted = Context.EntityContainer.GetChanges().RemovedEntities
    .Where(re => re is TaskToOperationAssociations && ((TaskToOperationAssociations)re.GetOriginal()).TaskId == T1.Id)
    .Select(re => (TaskToOperationAssociations)re);

or just

var hasDeleted = Context.EntityContainer.GetChanges().RemovedEntities
    .Any(re => re is TaskToOperationAssociations && ((TaskToOperationAssociations)re.GetOriginal()).TaskId == T1.Id)

to find out if there are any deleted associations for T1

with

foreach (var assoc in deleted)
{
   Context.TaskToOperationAssociations.Add(assoc);
   ((IRevertibleChangeTracking)assoc).RejectChanges();
   ((IRevertibleChangeTracking)T1).RejectChanges();
}

you can completely undo the deletion (if you have not committed your changes yet)

ContentLicense: CC BY-SA 3.0


问:
How to Get first date and last date from given month in java?
We will pass month information in yyyyMM format.From that given input how i will get FirstDate and LastDate of that month?</p>

```<code>Input:-202002

OutPut Should be:-

First Date:- 2020-02-01,
Last Date:- 2020-02-29

DateFormat dateFormat = new SimpleDateFormat("yyyyMM");
Date date = new Date();
System.out.println("First Date:- "+dateFormat.format(date));
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MONTH, -1);
Date previousmonth = calendar.getTime();
System.out.println("LastDate:-"+dateFormat.format(previousmonth).toString());
</code>```

答:
As I just learned, there are now special methods for it.

You can do it like this now:

public static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyyMM");
public static final DateTimeFormatter OUT_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");

public static LocalDate[] getFirstAndLastDateOfMonthNew(String yearAndMonth) {
    final LocalDate[] result = new LocalDate[2];
    final YearMonth yearMonth = YearMonth.parse(yearAndMonth, FORMATTER);
    result[0] = yearMonth.atDay(1);
    result[1] = yearMonth.atEndOfMonth();;
    return result;
}
```

<p>The old way would have been:</p>

<p>Just add the <code>01</code> to the date and parse it. The add a month and subtract a day.</p>

<pre class="lang-java prettyprint-override"><code>public static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd");
public static final DateTimeFormatter OUT_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");

public static LocalDate[] getFirstAndLastDateOfMonth(String yearAndMonth) {
    final LocalDate[] result = new LocalDate[2];
    final LocalDate first = LocalDate.parse(yearAndMonth + "01", FORMATTER);
    final LocalDate last = first.plusMonths(1).minusDays(1);
    result[0] = first;
    result[1] = last;
    return result;
}
</code>```

ContentLicense: CC BY-SA 4.0

Body:
We will pass month information in yyyyMM format.From that given input how i will get FirstDate and LastDate of that month?

Input:-202002

OutPut Should be:-

First Date:- 2020-02-01,
Last Date:- 2020-02-29

DateFormat dateFormat = new SimpleDateFormat("yyyyMM");
Date date = new Date();
System.out.println("First Date:- "+dateFormat.format(date));
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MONTH, -1);
Date previousmonth = calendar.getTime();
System.out.println("LastDate:-"+dateFormat.format(previousmonth).toString());

Body:
As I just learned, there are now special methods for it.

You can do it like this now:

public static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyyMM");
public static final DateTimeFormatter OUT_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");

public static LocalDate[] getFirstAndLastDateOfMonthNew(String yearAndMonth) {
    final LocalDate[] result = new LocalDate[2];
    final YearMonth yearMonth = YearMonth.parse(yearAndMonth, FORMATTER);
    result[0] = yearMonth.atDay(1);
    result[1] = yearMonth.atEndOfMonth();;
    return result;
}

The old way would have been:

Just add the 01 to the date and parse it. The add a month and subtract a day.

public static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd");
public static final DateTimeFormatter OUT_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");

public static LocalDate[] getFirstAndLastDateOfMonth(String yearAndMonth) {
    final LocalDate[] result = new LocalDate[2];
    final LocalDate first = LocalDate.parse(yearAndMonth + "01", FORMATTER);
    final LocalDate last = first.plusMonths(1).minusDays(1);
    result[0] = first;
    result[1] = last;
    return result;
}


问:
Flutter - change color on another button tap
I have 5x5 grid of 5xTableRow -> 5xFittedBox. With the tap on the top right button, I want it to shuffle colors that are described in an array (see image).

I tried with the "OnChanged" and "onPressed", but the problem is I don't know how to access each element individually

I read that I should use "setState" function to force flutter to redraw certain elements, but the problem is where do I put said function?

Also is there an easy way to give widgets and children some kind of identifier (for example class = "something" or id = "something")
The point of that is that I want to use for loop to recolor all 25 boxes, and after that I want to store those 25 boxes in an array to use for later condition checking.

```<code>var colorArr = [0xffd61745, 0xff3569bc, 0xffffffff, 0xfff4862a, 0xffeaed19, 0xff329f64,
0xff000000];
//playArr is used to store values from 0-5 which corresponds each color => colorArr[playArr[n]]
var playArr = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
void shuffleBox() {
  for (var i = 0; i<playArr.length;i++) {
    playArr[i] = new Random().nextInt(6);
    print(playArr[i]);
  }
}

@override
Widget build(BuildContext context) {
  return Scaffold(
    appBar: AppBar(
      centerTitle: true,
      title: Container(
        child: Text(
          'Table Widget',
          style: TextStyle(
            fontSize: 20.0,
            fontWeight: FontWeight.bold,
          ),
        ),
      ),
      actions: <Widget>[
        IconButton(
          icon: Icon(Icons.shuffle),
          onPressed: shuffleBox,
        ),
      ],
    ),
    body: SingleChildScrollView(
      padding: EdgeInsets.only(top: 12),
      child: Table(
        border: null,
        defaultVerticalAlignment: TableCellVerticalAlignment.top,
        children: <TableRow>[
          TableRow(children: <Widget>[
            //this is what i want recolored and/or redrawn
            FittedBox(
              fit: BoxFit.contain,
              child: Container(
                margin: EdgeInsets.all(2),
                color: Color(a),
                width: 48.0,
                height: 48.0,
              ),
            ),
            FittedBox -> repeated 5x, then TableRow again
</code>```

答:
You can call setState() function from anywhere in your Stateful Widget (class).

Code should be looks like;

```<code>void shuffleBox() {
   // 1- you can execute your code here
   setState((){
     // 2- or here, inside the setState
   });
   // at this point your code executes after refresh
   print("Refresh ends.");
}
</code>```

Also you can use shuffle() method for shuffling the list in Dart:
https://api.dart.dev/stable/2.7.1/dart-core/List/shuffle.html

Body:
I have 5x5 grid of 5xTableRow -> 5xFittedBox. With the tap on the top right button, I want it to shuffle colors that are described in an array (see image).

I tried with the "OnChanged" and "onPressed", but the problem is I don't know how to access each element individually

I read that I should use "setState" function to force flutter to redraw certain elements, but the problem is where do I put said function?

Also is there an easy way to give widgets and children some kind of identifier (for example class = "something" or id = "something")
The point of that is that I want to use for loop to recolor all 25 boxes, and after that I want to store those 25 boxes in an array to use for later condition checking.

var colorArr = [0xffd61745, 0xff3569bc, 0xffffffff, 0xfff4862a, 0xffeaed19, 0xff329f64,
0xff000000];
//playArr is used to store values from 0-5 which corresponds each color => colorArr[playArr[n]]
var playArr = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
void shuffleBox() {
  for (var i = 0; i<playArr.length;i++) {
    playArr[i] = new Random().nextInt(6);
    print(playArr[i]);
  }
}

@override
Widget build(BuildContext context) {
  return Scaffold(
    appBar: AppBar(
      centerTitle: true,
      title: Container(
        child: Text(
          'Table Widget',
          style: TextStyle(
            fontSize: 20.0,
            fontWeight: FontWeight.bold,
          ),
        ),
      ),
      actions: <Widget>[
        IconButton(
          icon: Icon(Icons.shuffle),
          onPressed: shuffleBox,
        ),
      ],
    ),
    body: SingleChildScrollView(
      padding: EdgeInsets.only(top: 12),
      child: Table(
        border: null,
        defaultVerticalAlignment: TableCellVerticalAlignment.top,
        children: <TableRow>[
          TableRow(children: <Widget>[
            //this is what i want recolored and/or redrawn
            FittedBox(
              fit: BoxFit.contain,
              child: Container(
                margin: EdgeInsets.all(2),
                color: Color(a),
                width: 48.0,
                height: 48.0,
              ),
            ),
            FittedBox -> repeated 5x, then TableRow again

Body:
You can call setState() function from anywhere in your Stateful Widget (class).

Code should be looks like;

void shuffleBox() {
   // 1- you can execute your code here
   setState((){
     // 2- or here, inside the setState
   });
   // at this point your code executes after refresh
   print("Refresh ends.");
}

Also you can use shuffle() method for shuffling the list in Dart:
https://api.dart.dev/stable/2.7.1/dart-core/List/shuffle.html


问:
In Http Methods, what is purpose of having differet method names
In Http Methods, what is purpose of having differet method name like(putmapping/postmapping/deletemapping/getmapping), when i can handle from backend logic</p>

答:
It's all about the semantics of the request.

See the following quote from the RFC 7231, the document that currently defines the semantics and content of the HTTP/1.1 protocol:

The request method token is the primary source of request semantics;
it indicates the purpose for which the client has made this request
and what is expected by the client as a successful result. [...]

Here's a brief description of some HTTP methods defined in the RFC 7231 (click the links to check the full method definition):

GET: Transfer a current representation of the target resource.

HEAD: Same as GET, but only transfer the status line and header section.

POST: Perform resource-specific processing on the request payload.

PUT: Replace all current representations of the target resource with the request payload.

DELETE: Remove all current representations of the target resource.


问:
Getting crash when converting Error to NSEroor (_swift_stdlib_bridgeErrorToNSError) in swift
```<code>Crashed: com.apple.main-thread
0  libswiftCore.dylib             0x19db65dd4 _swift_stdlib_bridgeErrorToNSError + 36
1                                 0x101005410 closure #2 in closure #1 in MCRegistrationViewController.requestForVerificationCode() + 229 (MCRegistrationViewController.swift:229)
2                                 0x10105e2d0 thunk for @escaping @callee_guaranteed (@guaranteed NSURLSessionDataTask, @guaranteed Error) -> () + 4339360464 (<compiler-generated>:4339360464)
3                                 0x100f956f8 __68-[BoomAPIClient callSuccessBlock:failureBlock:forTask:withResponse:]_block_invoke + 522 (BoomAPIClient.m:522)
4  libdispatch.dylib              0x19042d610 _dispatch_call_block_and_release + 24
5  libdispatch.dylib              0x19042e184 _dispatch_client_callout + 16
6  libdispatch.dylib              0x1903e01d0 _dispatch_main_queue_callback_4CF$VARIANT$mp + 1044
7  CoreFoundation                 0x1906de3c4 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
8  CoreFoundation                 0x1906d93b8 __CFRunLoopRun + 2004
9  CoreFoundation                 0x1906d88bc CFRunLoopRunSpecific + 464
10 GraphicsServices               0x19a543328 GSEventRunModal + 104
11 UIKitCore                      0x19476d6d4 UIApplicationMain + 1936
12                                0x100fba224 main + 5 (main.m:5)
13 libdyld.dylib                  0x190563460 start + 4
</code>```

I tried to convert the swift Error to Objective C NSError to but getting a crash while doing.

```<code>if let convertedError = error as NSError? {

}
</code>```

Thanks
Nicky

答:
From Error to NSError it is trying to access the errorCode and errorDomain.</p>

```<code>extension CustomError: LocalizedError {
public var errorDescription: String? {
    return "Some localized description"
}
}

extension CustomError: CustomNSError {
    public static var errorDomain: String {
        return "Some Domain Name"
    }
    public var errorCode: Int {
        return 204 //Should be your custom error code.
    }
}
</code>```

Body:
Crashed: com.apple.main-thread
0  libswiftCore.dylib             0x19db65dd4 _swift_stdlib_bridgeErrorToNSError + 36
1                                 0x101005410 closure #2 in closure #1 in MCRegistrationViewController.requestForVerificationCode() + 229 (MCRegistrationViewController.swift:229)
2                                 0x10105e2d0 thunk for @escaping @callee_guaranteed (@guaranteed NSURLSessionDataTask, @guaranteed Error) -> () + 4339360464 (<compiler-generated>:4339360464)
3                                 0x100f956f8 __68-[BoomAPIClient callSuccessBlock:failureBlock:forTask:withResponse:]_block_invoke + 522 (BoomAPIClient.m:522)
4  libdispatch.dylib              0x19042d610 _dispatch_call_block_and_release + 24
5  libdispatch.dylib              0x19042e184 _dispatch_client_callout + 16
6  libdispatch.dylib              0x1903e01d0 _dispatch_main_queue_callback_4CF$VARIANT$mp + 1044
7  CoreFoundation                 0x1906de3c4 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
8  CoreFoundation                 0x1906d93b8 __CFRunLoopRun + 2004
9  CoreFoundation                 0x1906d88bc CFRunLoopRunSpecific + 464
10 GraphicsServices               0x19a543328 GSEventRunModal + 104
11 UIKitCore                      0x19476d6d4 UIApplicationMain + 1936
12                                0x100fba224 main + 5 (main.m:5)
13 libdyld.dylib                  0x190563460 start + 4

I tried to convert the swift Error to Objective C NSError to but getting a crash while doing.

if let convertedError = error as NSError? {

}

Thanks
Nicky

Body:
From Error to NSError it is trying to access the errorCode and errorDomain.

extension CustomError: LocalizedError {
public var errorDescription: String? {
    return "Some localized description"
}
}

extension CustomError: CustomNSError {
    public static var errorDomain: String {
        return "Some Domain Name"
    }
    public var errorCode: Int {
        return 204 //Should be your custom error code.
    }
}


问:
Is it possible to have a non-friend function which can only be found by ADL?
C++ has a feature, that in-class-defined friend functions can only be found by ADL (argument dependent lookup):

```<code>struct Foo {
    friend void fn(Foo) { } // fn can only be called by ADL, it won't be found by other lookup methods
};
</code>```

Is it possible to achieve the same for non-friend functions? I ask this, because sometimes, I'd like to have this "only found by ADL" feature, but I don't actually need friend access to the class internals.

(And a somewhat opinionated question: if this is not possible, what is the reason for this? Is this "only found by ADL" rule intentionally designed into the language?)

答:
The argument dependent lookup is introduced for unqualified name lookup of all functions not only of friend functions of classes.

Here is a demonstrative program

```<code>#include <iostream>

namespace N1
{

struct A
{
    int a = 10;
    friend void f( A &a ) { std::cout << "friend f( A & ) : A::a = " <<  a.a << '\n'; }
};

void f( const A &a ) { std::cout << "f( const A & ) : A::a = " <<  a.a << '\n'; }

}

int main()
{
    N1::A a1;
    f( a1 );

    const N1::A a2;
    f( a2 );

    N1::f( a1 );
}
</code>```

The program output is

```<code>friend f( A & ) : A::a = 10
f( const A & ) : A::a = 10
f( const A & ) : A::a = 10
</code>```

In this program when the qualified name lookup is used for a function with the name f and non-constant object a1 as its argument there is called the non-friend function f because the name of the friend function f is invisible in the namespace where its declaration is introduced.

Friend functions are included in the ADL because if a friend function is declared (and correspondingly defined) only in a class its name is invisible in the namespace where the declaration is introduced opposite to functions that declared in the namespace. So non-friend functions for example can be called using qualified names while friend functions that are only declared in classes can not be called using qualified names because they are invisible.

To achieve the same action with non-friend functions you have to make them at first invisible in the namespace where their declarations are introduced and the qualified name lookup shall not find them. It is impossible without introducing in the C++ Standard some new notions.

Body:
C++ has a feature, that in-class-defined friend functions can only be found by ADL (argument dependent lookup):

struct Foo {
    friend void fn(Foo) { } // fn can only be called by ADL, it won't be found by other lookup methods
};

Is it possible to achieve the same for non-friend functions? I ask this, because sometimes, I'd like to have this "only found by ADL" feature, but I don't actually need friend access to the class internals.

(And a somewhat opinionated question: if this is not possible, what is the reason for this? Is this "only found by ADL" rule intentionally designed into the language?)

Body:
The argument dependent lookup is introduced for unqualified name lookup of all functions not only of friend functions of classes.

Here is a demonstrative program

#include <iostream>

namespace N1
{

struct A
{
    int a = 10;
    friend void f( A &a ) { std::cout << "friend f( A & ) : A::a = " <<  a.a << '\n'; }
};

void f( const A &a ) { std::cout << "f( const A & ) : A::a = " <<  a.a << '\n'; }

}

int main()
{
    N1::A a1;
    f( a1 );

    const N1::A a2;
    f( a2 );

    N1::f( a1 );
}

The program output is

friend f( A & ) : A::a = 10
f( const A & ) : A::a = 10
f( const A & ) : A::a = 10

In this program when the qualified name lookup is used for a function with the name f and non-constant object a1 as its argument there is called the non-friend function f because the name of the friend function f is invisible in the namespace where its declaration is introduced.

Friend functions are included in the ADL because if a friend function is declared (and correspondingly defined) only in a class its name is invisible in the namespace where the declaration is introduced opposite to functions that declared in the namespace. So non-friend functions for example can be called using qualified names while friend functions that are only declared in classes can not be called using qualified names because they are invisible.

To achieve the same action with non-friend functions you have to make them at first invisible in the namespace where their declarations are introduced and the qualified name lookup shall not find them. It is impossible without introducing in the C++ Standard some new notions.


问:
403 Error while creating storage account in Azure
I was trying to access the CLI in azure. I wanted to execute the script in Power shell CLI. But I'm not able to create a storage account for PowerShell in azure.

答:
The error clearly indicates that you don’t have “read” permission on “cloud-shell-storage-westeurope” resource group.

Please ask your administrator to grant you proper permission on this resource group.


问:
New to Xamarin, I don't understand the project structure
I have a project where i'm asked to develop in xamarin. The problem is that I don't really understand the structure. There're Project, Project.Android and Project.IOS folders. If i code in Project, then what are the 2 other folders for ?

I think it's to code specific parts that can't be in Project, but how do you include them ? If there's a good youtube tutorial for that i would be thankful.

答:
it is never late to start with any technology let me answer your question as you said there are 3 folders

YourProject

YourProject.Android

YourProject.IOS

when you work on xamarin your 70-80% of your code is reused but some things are always platform specific

when we talk about YourProject.Android or YourProject.IOS they are platform specific implementations

in this folders you can add code for hardware based implementation, using platform specific features, Designing controls differently for platforms(Custom Renderer) and much more

in case of any such doubts i would suggest you to go through the official documentation of xamarin

Link to Document Official Xamarin Documentation


问:
Same QueryParams In All JAX-RS Endpoints
I have a requirement that a few QueryParams should be present in absolutely all JAX-RS endpoints of my application.

Is there a way to specify somewhere, only once, these parameters? Or do I have to repeat myself in all method endpoints?

Thank you!

答:
I would implement a ContainerRequestFilter and handle the parameters there. You can add the result to the ContainerRequestContext:

```<code>@Provider
public class MyFilter implements ContainerRequestFilter {

  @Override
  public void filter(ContainerRequestContext requestContext) throws IOException {
    Object result = // handle the parameter
    requestContext.setProperty("myParam", result);
  }

}
</code>```

Your implementation will of course depend on your needs.

You can inject the context into your resource classes like:

```<code>@Context
private ContainerRequestContext containerRequestContext;
</code>```

See also:

Jersey 2 filter uses Container Request Context in Client Request Filter

Body:
I would implement a ContainerRequestFilter and handle the parameters there. You can add the result to the ContainerRequestContext:

@Provider
public class MyFilter implements ContainerRequestFilter {

  @Override
  public void filter(ContainerRequestContext requestContext) throws IOException {
    Object result = // handle the parameter
    requestContext.setProperty("myParam", result);
  }

}

Your implementation will of course depend on your needs.

You can inject the context into your resource classes like:

@Context
private ContainerRequestContext containerRequestContext;

See also:

Jersey 2 filter uses Container Request Context in Client Request Filter


问:
htaccess problem cleaun up request uri
I am using following htaccess code

```<code>Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.digilink\.co$ [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{REQUEST_URI} ^($|/.*$)

RewriteRule ^category/([a-z]+)-([a-z]+) /search.php?cat=$1-$2 [NC]
RewriteRule ^category/([a-z]+) /search.php?cat=$1 [NC]

#non www to www

RewriteCond %{HTTP_HOST} !^www\.digilink\.co$
RewriteRule (.*) http://www.digilink.co/$1 [R=301,L]

# custom error documents
ErrorDocument 404 http://www.digilink.co/404.php
</code>```

As the URI is converted as www.digilink.co/category/automotive no CSS and images are loaded. As the directory is added. Please help me with the query.

答:
I can suggest you to add who more conditions to check if the requested link is not directory or file and then rewrite it </p>

```<code>RequestCond %{REQUEST_FILENAME} !-f
RequestCond %{REQUEST_FILENAME} !-d
</code>```

Title: htaccess problem cleaun up request uri

Body:
I am using following htaccess code

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.digilink\.co$ [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{REQUEST_URI} ^($|/.*$)

RewriteRule ^category/([a-z]+)-([a-z]+) /search.php?cat=$1-$2 [NC]
RewriteRule ^category/([a-z]+) /search.php?cat=$1 [NC]

#non www to www

RewriteCond %{HTTP_HOST} !^www\.digilink\.co$
RewriteRule (.*) http://www.digilink.co/$1 [R=301,L]

# custom error documents
ErrorDocument 404 http://www.digilink.co/404.php

As the URI is converted as www.digilink.co/category/automotive no CSS and images are loaded. As the directory is added. Please help me with the query.

Body:
I can suggest you to add who more conditions to check if the requested link is not directory or file and then rewrite it

RequestCond %{REQUEST_FILENAME} !-f
RequestCond %{REQUEST_FILENAME} !-d


问:
How to extract the heatmap of from a set of gene interest from main heatmap?
I have made a heatmap based on following script.

```<code>#load the library
library(pheatmap)

#set label font
par(cex.lab=1.5) # is for y-axis
par(cex.axis=1.5) # is for x-axis

#Set the working directory
setwd("F:\\User\\OneDrive\\data\\final\\Rcode")

#hedge
#read the expression matrix
hedge <- read.table("hedge.txt",sep="\t",header = TRUE)

#Group the data in the frame
group_df = data.frame(Groups=rep(c("AP","CP","BP"),c(6,42,28)))

#Assign the col name to the matrix
rownames(group_df) = colnames(hedge)[2:ncol(hedge)]

#Assign the rownames
rownames(hedge) = hedge[,1]

#plot the heatmap with specific split
pheatmap(hedge[,-1],cluster_cols=FALSE,
         annotation_col=group_df, gaps_col = cumsum(c(6,42,28)))
</code>```

I got following heatmap from the code:

Now I want to extract and replot a subplot from the main heatmap using gene set of my interest (CD34, CD117, CD38, SHH, GLI1, GLI2, GLI3, BCL2, PTCH1, PTCH2, SMO). How can I do this?

答:
This should work:

```<code>pheatmap(hedge[which(hedge[,1]==c("CD34" , "CD117" , "CD38" , "SHH" ,
"GLI1" , "GLI2" , "GLI3" , "BCL2" , "PTCH1" , "PTCH2" , "SMO")),-1],
cluster_cols=FALSE, annotation_col=group_df, gaps_col =cumsum(c(6,42,28)))
</code>```

Here, you take the rows having those gene names in their first column and plot it.

EDIT: Removed first column.

Body:
I have made a heatmap based on following script.

#load the library
library(pheatmap)

#set label font
par(cex.lab=1.5) # is for y-axis
par(cex.axis=1.5) # is for x-axis

#Set the working directory
setwd("F:\\User\\OneDrive\\data\\final\\Rcode")

#hedge
#read the expression matrix
hedge <- read.table("hedge.txt",sep="\t",header = TRUE)

#Group the data in the frame
group_df = data.frame(Groups=rep(c("AP","CP","BP"),c(6,42,28)))

#Assign the col name to the matrix
rownames(group_df) = colnames(hedge)[2:ncol(hedge)]

#Assign the rownames
rownames(hedge) = hedge[,1]

#plot the heatmap with specific split
pheatmap(hedge[,-1],cluster_cols=FALSE,
         annotation_col=group_df, gaps_col = cumsum(c(6,42,28)))

I got following heatmap from the code:

Now I want to extract and replot a subplot from the main heatmap using gene set of my interest (CD34, CD117, CD38, SHH, GLI1, GLI2, GLI3, BCL2, PTCH1, PTCH2, SMO). How can I do this?

Body:
This should work:

pheatmap(hedge[which(hedge[,1]==c("CD34" , "CD117" , "CD38" , "SHH" ,
"GLI1" , "GLI2" , "GLI3" , "BCL2" , "PTCH1" , "PTCH2" , "SMO")),-1],
cluster_cols=FALSE, annotation_col=group_df, gaps_col =cumsum(c(6,42,28)))

Here, you take the rows having those gene names in their first column and plot it.

EDIT: Removed first column.


问:
Bigtable Backups and Redundancy
Google Cloud Bigtable looks fantastic, however I have some questions about backups and redundancy.

Are there any options for backing up data to protect against human errors?

Clusters currently run in a single zone - are there any ways to mitigate against a zone being unavailable?

答: You may consider Egnyte's https://github.com/egnyte/bigtable-backup-and-restore. These are Python wrappers for the java-bigtable-hbase shaded jar which export/import Bigtable data to/from a GCS bucket as a series of Hadoop sequence files.</p>

Title: Bigtable Backups and Redundancy


问:
How to match a class property from application.yml to the java class with a different class name?
I am using Spring Framework and need to match a class property from application.yml to the java class with a different class name?

I have the following application.yml file:

```<code>service:
  cms:
    webClient:
      basePath: http://www.example.com
      connectionTimeoutSeconds: 3
      readTimeoutSeconds: 3
    url:
      path: /some/path/
      parameters:
        tree: basic
    credential:
      username: misha
      password: 123
</code>```

and my java class for service.cms properties:

```<code>// block A: It already works

@Getter
@Setter
@ConfigurationProperties(prefix = "service.cms")
public class CmsProperties {
  private WebClientProperties webClient; // I want rename it to webClientProperties
  private UrlProperties url;
  private CredentialProperties credential;
}

</code>```

where WebClientProperties is

```<code>@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class WebClientProperties {
  private String basePath;
  private int connectionTimeoutSeconds;
  private int readTimeoutSeconds;
}
</code>```

I would like to rename java field name CmsProperties#webClient into CmsProperties#WebClientProperties, but I must keep the original name webClient in the application.yml.
Just using @Value over CmsProperties#webClient does not work:

```<code>//Block B: `webClient` name is changed to `WebClientProperties`.
// This what I want - but it did not work!

@Getter
@Setter
@ConfigurationProperties(prefix = "service.cms")
public class CmsProperties {
  @Value("${webClient}")
  private WebClientProperties webClientProperties; // Name changed to `webClientProperties`
  ...
}
</code>```

I have errors:

```<code>Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'webClient' in value "${webClient}"
</code>```

Is it possible to do it?

答:
Yes, below code will work

Parent Property class

```<code>@Configuration
@ConfigurationProperties(prefix = "service.cms")
public class PropertyReader {

    public WebClient webClient;
}
</code>```

Child Property Class

```<code>//GETTER SETTER removed
public class WebClient {

@Value("${basePath}")
private String basePath;
@Value("${connectionTimeoutSeconds}")
private String connectionTimeoutSeconds;
@Value("${readTimeoutSeconds}")
private String readTimeoutSeconds;
}
</code>```

application.yml

```<code>service:
  cms:
    webClient:
      basePath: http://www.example.com
      connectionTimeoutSeconds: 3
      readTimeoutSeconds: 3
</code>```

Body:
I am using Spring Framework and need to match a class property from application.yml to the java class with a different class name?

I have the following application.yml file:

service:
  cms:
    webClient:
      basePath: http://www.example.com
      connectionTimeoutSeconds: 3
      readTimeoutSeconds: 3
    url:
      path: /some/path/
      parameters:
        tree: basic
    credential:
      username: misha
      password: 123

and my java class for service.cms properties:

// block A: It already works

@Getter
@Setter
@ConfigurationProperties(prefix = "service.cms")
public class CmsProperties {
  private WebClientProperties webClient; // I want rename it to webClientProperties
  private UrlProperties url;
  private CredentialProperties credential;
}

where WebClientProperties is

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class WebClientProperties {
  private String basePath;
  private int connectionTimeoutSeconds;
  private int readTimeoutSeconds;
}

I would like to rename java field name CmsProperties#webClient into CmsProperties#WebClientProperties, but I must keep the original name webClient in the application.yml.
Just using @Value over CmsProperties#webClient does not work:

//Block B: `webClient` name is changed to `WebClientProperties`.
// This what I want - but it did not work!

@Getter
@Setter
@ConfigurationProperties(prefix = "service.cms")
public class CmsProperties {
  @Value("${webClient}")
  private WebClientProperties webClientProperties; // Name changed to `webClientProperties`
  ...
}

I have errors:

Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'webClient' in value "${webClient}"

Is it possible to do it?

Body:
Yes, below code will work

Parent Property class

@Configuration
@ConfigurationProperties(prefix = "service.cms")
public class PropertyReader {

    public WebClient webClient;
}

Child Property Class

//GETTER SETTER removed
public class WebClient {

@Value("${basePath}")
private String basePath;
@Value("${connectionTimeoutSeconds}")
private String connectionTimeoutSeconds;
@Value("${readTimeoutSeconds}")
private String readTimeoutSeconds;
}

application.yml

service:
  cms:
    webClient:
      basePath: http://www.example.com
      connectionTimeoutSeconds: 3
      readTimeoutSeconds: 3


问:
java.io.IOException: Cannot run program CreateProcess error=2, The system cannot find the file specified on android studio
I dont quite know why this happen, my other project works fine, and this project was also fine before I added coroutines (and after my internet connection got cut off while my project was in building progress if this could possibly affect this too)

This was showed up on the exception:

```<code>e: java.io.IOException: Cannot run program "D:\Android Studio\jre\jre\bin\java" (in directory "C:\Users\User\AppData\Local\kotlin\daemon"): CreateProcess error=2, The system cannot find the file specified
</code>```

Log Error:

```<code>    org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:compileDebugKotlin'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.accept(ExecuteActionsTaskExecuter.java:151)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.accept(ExecuteActionsTaskExecuter.java:148)
    at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:191)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:141)
    at org.gradle.api.internal.tasks.execution.ResolveBeforeExecutionStateTaskExecuter.execute(ResolveBeforeExecutionStateTaskExecuter.java:75)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:62)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:108)
    at org.gradle.api.internal.tasks.execution.ResolveBeforeExecutionOutputsTaskExecuter.execute(ResolveBeforeExecutionOutputsTaskExecuter.java:67)
    at org.gradle.api.internal.tasks.execution.ResolveAfterPreviousExecutionStateTaskExecuter.execute(ResolveAfterPreviousExecutionStateTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:94)
    at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:95)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:73)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:49)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
    at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:49)
    at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:43)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:355)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:343)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:336)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:322)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:134)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:129)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:202)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:193)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:129)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
    at java.lang.Thread.run(Thread.java:748)
Caused by: org.gradle.api.UncheckedIOException: java.io.IOException: Cannot run program "D:\Android Studio\jre\jre\bin\java": CreateProcess error=2, The system cannot find the file specified
    at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:61)
    at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:41)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:106)
    at org.gradle.api.internal.project.taskfactory.IncrementalTaskInputsTaskAction.doExecute(IncrementalTaskInputsTaskAction.java:46)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:41)
    at org.gradle.api.internal.project.taskfactory.AbstractIncrementalTaskAction.execute(AbstractIncrementalTaskAction.java:25)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:28)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$5.run(ExecuteActionsTaskExecuter.java:404)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:402)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:394)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:92)
    at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:393)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:376)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.access$200(ExecuteActionsTaskExecuter.java:80)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.execute(ExecuteActionsTaskExecuter.java:213)
    at org.gradle.internal.execution.steps.ExecuteStep.lambda$execute$0(ExecuteStep.java:32)
    at java.util.Optional.map(Optional.java:215)
    at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:32)
    at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:26)
    at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:58)
    at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:35)
    at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:48)
    at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:33)
    at org.gradle.internal.execution.steps.CancelExecutionStep.execute(CancelExecutionStep.java:39)
    at org.gradle.internal.execution.steps.TimeoutStep.executeWithoutTimeout(TimeoutStep.java:73)
    at org.gradle.internal.execution.steps.TimeoutStep.execute(TimeoutStep.java:54)
    at org.gradle.internal.execution.steps.CatchExceptionStep.execute(CatchExceptionStep.java:35)
    at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:51)
    at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:45)
    at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:31)
    at org.gradle.internal.execution.steps.CacheStep.executeWithoutCache(CacheStep.java:201)
    at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:70)
    at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:45)
    at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:49)
    at org.gradle.internal.execution.steps.StoreSnapshotsStep.execute(StoreSnapshotsStep.java:43)
    at org.gradle.internal.execution.steps.StoreSnapshotsStep.execute(StoreSnapshotsStep.java:32)
    at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:38)
    at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:24)
    at org.gradle.internal.execution.steps.SkipUpToDateStep.executeBecause(SkipUpToDateStep.java:96)
    at org.gradle.internal.execution.steps.SkipUpToDateStep.lambda$execute$0(SkipUpToDateStep.java:89)
    at java.util.Optional.map(Optional.java:215)
    at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:54)
    at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:38)
    at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:77)
    at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:37)
    at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:36)
    at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:26)
    at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:90)
    at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:48)
    at org.gradle.internal.execution.impl.DefaultWorkExecutor.execute(DefaultWorkExecutor.java:33)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:120)
    ... 38 more
Caused by: java.io.IOException: Cannot run program "D:\Android Studio\jre\jre\bin\java": CreateProcess error=2, The system cannot find the file specified
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
    at org.jetbrains.kotlin.daemon.client.NativePlatformUtilKt.launchProcessWithFallback(NativePlatformUtil.kt:58)
    at org.jetbrains.kotlin.daemon.client.NativePlatformUtilKt.launchProcessWithFallback$default(NativePlatformUtil.kt:37)
    at org.jetbrains.kotlin.compilerRunner.ReportUtilsKt.runToolInSeparateProcess(reportUtils.kt:81)
    at org.jetbrains.kotlin.compilerRunner.GradleKotlinCompilerWork.compileOutOfProcess(GradleKotlinCompilerWork.kt:300)
    at org.jetbrains.kotlin.compilerRunner.GradleKotlinCompilerWork.compileWithDaemonOrFallbackImpl(GradleKotlinCompilerWork.kt:147)
    at org.jetbrains.kotlin.compilerRunner.GradleKotlinCompilerWork.run(GradleKotlinCompilerWork.kt:117)
    at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.runCompilerAsync(GradleKotlinCompilerRunner.kt:146)
    at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.runCompilerAsync(GradleKotlinCompilerRunner.kt:141)
    at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.runJvmCompilerAsync(GradleKotlinCompilerRunner.kt:81)
    at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompilerAsync$kotlin_gradle_plugin(Tasks.kt:449)
    at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompilerAsync$kotlin_gradle_plugin(Tasks.kt:359)
    at org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile.executeImpl(Tasks.kt:316)
    at org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile.execute(Tasks.kt:288)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:103)
    ... 90 more
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
    at java.lang.ProcessImpl.create(Native Method)
    at java.lang.ProcessImpl.<init>(ProcessImpl.java:386)
    at java.lang.ProcessImpl.start(ProcessImpl.java:137)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
    ... 108 more
</code>```

build.gradle (module:app)

```<code>    apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.furis.sid.wazap"
        minSdkVersion 18
        targetSdkVersion 28
        multiDexEnabled true
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.core:core-ktx:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'com.google.firebase:firebase-auth:16.0.5'
    implementation 'com.google.firebase:firebase-storage:16.0.4'
    implementation 'com.google.firebase:firebase-firestore:17.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    implementation 'androidx.navigation:navigation-fragment-ktx:2.1.0'
    implementation 'androidx.navigation:navigation-ui-ktx:2.1.0'
    implementation 'de.hdodenhof:circleimageview:2.1.0'
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.2.1"
    implementation 'androidx.multidex:multidex:2.0.1'

}
</code>```

build.gradle (project)

```<code>buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.3'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.2.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
</code>```

I appreciate any help, thank you

答:
Follow the steps as below:

Check where Java files are saved globally. Check if that is JDK or JRE. Always use jdk.
example, C:/ProgramFiles/Java/java_version/bin/java.exe

Next open gradlew.bat in your Android Project and edit the JAVA_HOME variable manually to the path obtained in 1st step.

Rebuild your android project.

Thus Java will be referenced explicitly.

Body:
I dont quite know why this happen, my other project works fine, and this project was also fine before I added coroutines (and after my internet connection got cut off while my project was in building progress if this could possibly affect this too)

This was showed up on the exception:

e: java.io.IOException: Cannot run program "D:\Android Studio\jre\jre\bin\java" (in directory "C:\Users\User\AppData\Local\kotlin\daemon"): CreateProcess error=2, The system cannot find the file specified

Log Error:

    org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:compileDebugKotlin'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.accept(ExecuteActionsTaskExecuter.java:151)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.accept(ExecuteActionsTaskExecuter.java:148)
    at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:191)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:141)
    at org.gradle.api.internal.tasks.execution.ResolveBeforeExecutionStateTaskExecuter.execute(ResolveBeforeExecutionStateTaskExecuter.java:75)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:62)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:108)
    at org.gradle.api.internal.tasks.execution.ResolveBeforeExecutionOutputsTaskExecuter.execute(ResolveBeforeExecutionOutputsTaskExecuter.java:67)
    at org.gradle.api.internal.tasks.execution.ResolveAfterPreviousExecutionStateTaskExecuter.execute(ResolveAfterPreviousExecutionStateTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:94)
    at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:95)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:73)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:49)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
    at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:49)
    at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:43)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:355)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:343)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:336)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:322)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:134)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:129)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:202)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:193)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:129)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
    at java.lang.Thread.run(Thread.java:748)
Caused by: org.gradle.api.UncheckedIOException: java.io.IOException: Cannot run program "D:\Android Studio\jre\jre\bin\java": CreateProcess error=2, The system cannot find the file specified
    at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:61)
    at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:41)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:106)
    at org.gradle.api.internal.project.taskfactory.IncrementalTaskInputsTaskAction.doExecute(IncrementalTaskInputsTaskAction.java:46)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:41)
    at org.gradle.api.internal.project.taskfactory.AbstractIncrementalTaskAction.execute(AbstractIncrementalTaskAction.java:25)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:28)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$5.run(ExecuteActionsTaskExecuter.java:404)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:402)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:394)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:92)
    at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:393)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:376)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.access$200(ExecuteActionsTaskExecuter.java:80)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.execute(ExecuteActionsTaskExecuter.java:213)
    at org.gradle.internal.execution.steps.ExecuteStep.lambda$execute$0(ExecuteStep.java:32)
    at java.util.Optional.map(Optional.java:215)
    at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:32)
    at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:26)
    at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:58)
    at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:35)
    at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:48)
    at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:33)
    at org.gradle.internal.execution.steps.CancelExecutionStep.execute(CancelExecutionStep.java:39)
    at org.gradle.internal.execution.steps.TimeoutStep.executeWithoutTimeout(TimeoutStep.java:73)
    at org.gradle.internal.execution.steps.TimeoutStep.execute(TimeoutStep.java:54)
    at org.gradle.internal.execution.steps.CatchExceptionStep.execute(CatchExceptionStep.java:35)
    at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:51)
    at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:45)
    at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:31)
    at org.gradle.internal.execution.steps.CacheStep.executeWithoutCache(CacheStep.java:201)
    at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:70)
    at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:45)
    at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:49)
    at org.gradle.internal.execution.steps.StoreSnapshotsStep.execute(StoreSnapshotsStep.java:43)
    at org.gradle.internal.execution.steps.StoreSnapshotsStep.execute(StoreSnapshotsStep.java:32)
    at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:38)
    at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:24)
    at org.gradle.internal.execution.steps.SkipUpToDateStep.executeBecause(SkipUpToDateStep.java:96)
    at org.gradle.internal.execution.steps.SkipUpToDateStep.lambda$execute$0(SkipUpToDateStep.java:89)
    at java.util.Optional.map(Optional.java:215)
    at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:54)
    at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:38)
    at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:77)
    at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:37)
    at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:36)
    at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:26)
    at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:90)
    at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:48)
    at org.gradle.internal.execution.impl.DefaultWorkExecutor.execute(DefaultWorkExecutor.java:33)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:120)
    ... 38 more
Caused by: java.io.IOException: Cannot run program "D:\Android Studio\jre\jre\bin\java": CreateProcess error=2, The system cannot find the file specified
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
    at org.jetbrains.kotlin.daemon.client.NativePlatformUtilKt.launchProcessWithFallback(NativePlatformUtil.kt:58)
    at org.jetbrains.kotlin.daemon.client.NativePlatformUtilKt.launchProcessWithFallback$default(NativePlatformUtil.kt:37)
    at org.jetbrains.kotlin.compilerRunner.ReportUtilsKt.runToolInSeparateProcess(reportUtils.kt:81)
    at org.jetbrains.kotlin.compilerRunner.GradleKotlinCompilerWork.compileOutOfProcess(GradleKotlinCompilerWork.kt:300)
    at org.jetbrains.kotlin.compilerRunner.GradleKotlinCompilerWork.compileWithDaemonOrFallbackImpl(GradleKotlinCompilerWork.kt:147)
    at org.jetbrains.kotlin.compilerRunner.GradleKotlinCompilerWork.run(GradleKotlinCompilerWork.kt:117)
    at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.runCompilerAsync(GradleKotlinCompilerRunner.kt:146)
    at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.runCompilerAsync(GradleKotlinCompilerRunner.kt:141)
    at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.runJvmCompilerAsync(GradleKotlinCompilerRunner.kt:81)
    at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompilerAsync$kotlin_gradle_plugin(Tasks.kt:449)
    at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompilerAsync$kotlin_gradle_plugin(Tasks.kt:359)
    at org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile.executeImpl(Tasks.kt:316)
    at org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile.execute(Tasks.kt:288)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:103)
    ... 90 more
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
    at java.lang.ProcessImpl.create(Native Method)
    at java.lang.ProcessImpl.<init>(ProcessImpl.java:386)
    at java.lang.ProcessImpl.start(ProcessImpl.java:137)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
    ... 108 more

build.gradle (module:app)

    apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.furis.sid.wazap"
        minSdkVersion 18
        targetSdkVersion 28
        multiDexEnabled true
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.core:core-ktx:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'com.google.firebase:firebase-auth:16.0.5'
    implementation 'com.google.firebase:firebase-storage:16.0.4'
    implementation 'com.google.firebase:firebase-firestore:17.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    implementation 'androidx.navigation:navigation-fragment-ktx:2.1.0'
    implementation 'androidx.navigation:navigation-ui-ktx:2.1.0'
    implementation 'de.hdodenhof:circleimageview:2.1.0'
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.2.1"
    implementation 'androidx.multidex:multidex:2.0.1'

}

build.gradle (project)

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.3'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.2.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

I appreciate any help, thank you


问:
Android: Clear old activity instance from history stack
I have the following simple scenario:

One Activity called ListCarsActivity.kt where list of cars are displayed. When the user click on the FloatingActionButton, it opens another activity called AddCarActivity.kt

When the user click on the Add Car button, I start a new intent to go to the initial activity ListCarsActivity.kt where the added car is now displayed.

Problem: From now, when I click on the Back button, the ListCarsActivity is displayed a second time.

How to clear the old entry of ListCarsActivity from the History stack?

答:
Call your AddCarActivity.kt Activity like below inside your ListCarsActivity.kt

```<code>val intent = Intent(mContext, AddCarActivity.class);
startActivityForResult(intent, 1); //Use any request code
</code>```

Now for the above code what startActivityForResult do is that it is an intent to receive data back from some other activity or source(like camera, contacts, etc)

Now when all the work is done in your AddCarActivity.kt you can all the below intent to get the result back

```<code>                Intent intent = getIntent();
                intent.putExtra("key", data); // if you wanted to get data
                setResult(RESULT_OK, intent);
                finish();
</code>```

And inside your ListCarsActivity.kt you need to add onActivityResult which will get the data from AddCarActivity.kt

```<code> @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    try {
        super.onActivityResult(requestCode, resultCode, data);

        if (resultCode == RESULT_OK) {
            if (requestCode == 1) { //Your request code here
                Object obj = data.getParcelableExtra("key");
                 //Do as per your needs

            }
        }

    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
</code>```

With this, if you wanted to return the newly added data back in the first activity it can be fetched without the usage of any third-party libs.

Try it and do let me know if it worked for you.

Body:
Call your AddCarActivity.kt Activity like below inside your ListCarsActivity.kt

val intent = Intent(mContext, AddCarActivity.class);
startActivityForResult(intent, 1); //Use any request code

Now for the above code what startActivityForResult do is that it is an intent to receive data back from some other activity or source(like camera, contacts, etc)

Now when all the work is done in your AddCarActivity.kt you can all the below intent to get the result back

                Intent intent = getIntent();
                intent.putExtra("key", data); // if you wanted to get data
                setResult(RESULT_OK, intent);
                finish();

And inside your ListCarsActivity.kt you need to add onActivityResult which will get the data from AddCarActivity.kt

 @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    try {
        super.onActivityResult(requestCode, resultCode, data);

        if (resultCode == RESULT_OK) {
            if (requestCode == 1) { //Your request code here
                Object obj = data.getParcelableExtra("key");
                 //Do as per your needs

            }
        }

    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

With this, if you wanted to return the newly added data back in the first activity it can be fetched without the usage of any third-party libs.

Try it and do let me know if it worked for you.


问:
how to pass link parameter when i click the export excel button?
I need help to pass the parameter on URL.

routes.php

```<code>Route::get('downloadExcel/{type}', 'ExcelController@downloadExcel');
</code>```

blade.php

```<code><a href="{{ URL::to('/downloadExcel/xls') }}" class="btn btn-warning btn-sm hidden-print"><i class="glyphicon glyphicon-export"></i> Export to Excel</a>
</code>```

controller

```<code>class ExcelController extends Controller{
    public function downloadExcel($type, Request $request)
    {
     return Excel::create('Laporan Kehadiran Harian', function($excel) use
      ($transaksi) {
            $excel->sheet('mySheet', function($sheet) use ($transaksi)
            {
                $sheet->fromArray($transaksi);
            });
        })->download($type);
    }
}
</code>```

答:
In the blade.php try to set a second parameter as an array with the type property and the value you want to pass.

If it is "xls" it would be the following:

```<code><a href="{{ URL::to('/downloadExcel', array("type" => "xls")) }}"></a>
</code>```

Body:
I need help to pass the parameter on URL.

routes.php

Route::get('downloadExcel/{type}', 'ExcelController@downloadExcel');

blade.php

 Export to Excel

controller

class ExcelController extends Controller{
    public function downloadExcel($type, Request $request)
    {
     return Excel::create('Laporan Kehadiran Harian', function($excel) use
      ($transaksi) {
            $excel->sheet('mySheet', function($sheet) use ($transaksi)
            {
                $sheet->fromArray($transaksi);
            });
        })->download($type);
    }
}

Body:
In the blade.php try to set a second parameter as an array with the type property and the value you want to pass.

If it is "xls" it would be the following:

<a href="{{ URL::to('/downloadExcel', array("type" => "xls")) }}"></a>


问:
Extract WORLDCLIM data using R for a single country
I want to extract world climate data for minimum and maximum temperature for only one country India using R and save it as a data set (to use with my own data-set that contains crop yields at the district level).
I have gone through several posts and can see that this can be done easily in R, however the posts that I have tried to follow are a bit different in terms of the commands or sequences and I am getting confused.
(https://gis.stackexchange.com/questions/259478/worldclim-data-na-for-my-coordinates, https://gis.stackexchange.com/questions/227585/using-r-to-extract-data-from-worldclim

What I have tried to use is as follows.

```<code>library(raster)
library(sp)
r<- getData('CMIP5', var='tmin', res=10, rcp=45, model='HE', year=70)
r <- r[[c(1,12)]]
values <- extract(r,points)
df <- cbind.data.frame(coordinates(points),values)
head(df)
</code>```

However, I can run only the first two lines and the line values

```<code><- extract(r,points) gives the error Error in (function (classes, fdef, mtable)  :
  unable to find an inherited method for function ‘extract’ for signature ‘"RasterStack", "function"’
</code>```

Any suggestions?

答:
Here is the solution for it</p>

```<code>library(raster)
library(sp)
library(rgeos)
library(rgdal)
library(sf)

r<- getData('CMIP5', var='tmin', res=10, rcp=45, model='HE', year=70)

#Using Zonal statistics
poly <- shapefile("Provide_your_drive_name" e.g. "F:\\Kriging in R\\India Shape files\\2011_Dist.shp")
plot(poly)

#This will take considerable time
ex <- extract(r, poly, fun='mean', na.rm=TRUE, df=TRUE, weights = TRUE)

write.csv(cbind(poly$DISTRICT,ex),"Worldclim.csv", row.names = F)

# using centroids
nc <- st_read(dsn="Provide_your_drive_name" e.g. "F:\\Kriging in R\\India Shape files", layer="2011_Dist")
# just view the attributes & first 6 attribute values of the data
head(nc)
sp_cent <- gCentroid(as(nc, "Spatial"), byid = TRUE)
values <- extract(r,sp_cent)

write.csv(cbind(as.data.frame(nc$DISTRICT),as.data.frame(values)),"Worldclim_centroids.csv", row.names = F)
</code>```

Body:
I want to extract world climate data for minimum and maximum temperature for only one country India using R and save it as a data set (to use with my own data-set that contains crop yields at the district level).
I have gone through several posts and can see that this can be done easily in R, however the posts that I have tried to follow are a bit different in terms of the commands or sequences and I am getting confused.
(https://gis.stackexchange.com/questions/259478/worldclim-data-na-for-my-coordinates, https://gis.stackexchange.com/questions/227585/using-r-to-extract-data-from-worldclim

What I have tried to use is as follows.

library(raster)
library(sp)
r<- getData('CMIP5', var='tmin', res=10, rcp=45, model='HE', year=70)
r <- r[[c(1,12)]]
values <- extract(r,points)
df <- cbind.data.frame(coordinates(points),values)
head(df)

However, I can run only the first two lines and the line values

<- extract(r,points) gives the error Error in (function (classes, fdef, mtable)  :
  unable to find an inherited method for function ‘extract’ for signature ‘"RasterStack", "function"’

Any suggestions?

Body:
Here is the solution for it

library(raster)
library(sp)
library(rgeos)
library(rgdal)
library(sf)

r<- getData('CMIP5', var='tmin', res=10, rcp=45, model='HE', year=70)

#Using Zonal statistics
poly <- shapefile("Provide_your_drive_name" e.g. "F:\\Kriging in R\\India Shape files\\2011_Dist.shp")
plot(poly)

#This will take considerable time
ex <- extract(r, poly, fun='mean', na.rm=TRUE, df=TRUE, weights = TRUE)

write.csv(cbind(poly$DISTRICT,ex),"Worldclim.csv", row.names = F)

# using centroids
nc <- st_read(dsn="Provide_your_drive_name" e.g. "F:\\Kriging in R\\India Shape files", layer="2011_Dist")
# just view the attributes & first 6 attribute values of the data
head(nc)
sp_cent <- gCentroid(as(nc, "Spatial"), byid = TRUE)
values <- extract(r,sp_cent)

write.csv(cbind(as.data.frame(nc$DISTRICT),as.data.frame(values)),"Worldclim_centroids.csv", row.names = F)


问:
Font Awesome 5 Is there a non-breakable space for "fa-layers-text" class?
I'm really stuck at this supposedly easy task: I'd like to put one single line of text containing white spaces over an FA icon. Following their instructions works only as long as the text does not contain any blanks. Blanks wrap the text into the next line. How can I prevent this so that there's only one single line of text (no matter how wide) put over an icon?

This creates three lines of text over the solid heart icon - I'd like just one.

.fa-layers {
  margin:50px;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://use.fontawesome.com/releases/v5.12.0/js/all.js"></script>
<span class="fa-layers fa-fw">
 <i class="fas fa-heart" data-fa-transform="grow-96" style="color:red"></i>
 <span class="fa-layers-text" style="font-weight:900">any text here</span>
</span></code>```

Thanks for any hints.

答:
Simply consider white-space:nowrap;

.fa-layers {
  margin:50px;
}
.fa-layers-text {
  white-space:nowrap;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://use.fontawesome.com/releases/v5.12.0/js/all.js"></script>
<span class="fa-layers fa-fw">
 <i class="fas fa-heart" data-fa-transform="grow-96" style="color:red"></i>
 <span class="fa-layers-text" style="font-weight:900">any text here</span>
</span></code>```

Body:
I'm really stuck at this supposedly easy task: I'd like to put one single line of text containing white spaces over an FA icon. Following their instructions works only as long as the text does not contain any blanks. Blanks wrap the text into the next line. How can I prevent this so that there's only one single line of text (no matter how wide) put over an icon?

This creates three lines of text over the solid heart icon - I'd like just one.

.fa-layers {
  margin:50px;
}

 any text here

Thanks for any hints.

Body:
Simply consider white-space:nowrap;

.fa-layers {
  margin:50px;
}
.fa-layers-text {
  white-space:nowrap;
}

<script src="https://use.fontawesome.com/releases/v5.12.0/js/all.js"></script>
<span class="fa-layers fa-fw">
 <i class="fas fa-heart" data-fa-transform="grow-96" style="color:red"></i>
 <span class="fa-layers-text" style="font-weight:900">any text here</span>
</span>


问:
How do I segregate internal and external loads using Istio Ingress?
On my Kubernetes cluster I would like to segregate access to internal and external apps.  In my example below I have app1 and app2 both exposed to the internet but would like only app1 exposed to the internet and app2 only available for users in the internal vnet.

My initial thought was to just make a new service (blue box) and use the "internal=true" attribute and my cloud provider creates the internal IP and I'm good. The issue is the gateway points to the deployment (pods) so it seem like to create an internal ingress I need to copy all 3 blue boxes.

Is there an easy way to tie in a new service and gateway without a new deployment (blue boxes) or maybe restrict external access via policy?

答:
Based on my knowledge you can create virtual service to do that

The reserved word mesh is used to imply all the sidecars in the mesh. When this field is omitted, the default gateway (mesh) will be used, which would apply the rule to all sidecars in the mesh. If a list of gateway names is provided, the rules will apply only to the gateways. To apply the rules to both gateways and sidecars, specify mesh as one of the gateway names.

You can check my another answer on stackoverflow, there is whole reproduction of someone problem where i made virtual service with a gateway to access(in a example just a curl) from outside, and if you want to make it only inside the mesh just delete this gateway and leave only mesh one, like in below example.

Specially the virtual service

```<code>apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: nginxvirt
spec:
  gateways:
  - mesh #inside cluster
  hosts:
  - nginx.default.svc.cluster.local #inside cluster
  http:
  - name: match-myuid
    match:
    - uri:
        prefix: /
    rewrite:
      uri: /
    route:
    - destination:
        host: nginx.default.svc.cluster.local
        port:
          number: 80
</code>```

And some external and internal tests

External

with additional gateway to allow external traffic

curl -v -H "host: nginx.com" loadbalancer_istio_ingress_gateway_ip/

HTTP/1.1 200 OK

without additional gateway to allow external traffic, just the mesh one

curl -v -H "host: nginx.com" loadbalancer_istio_ingress_gateway_ip/

HTTP/1.1 404 Not Found

Internal

```<code>Created some basic ubuntu pod for tests

kubectl exec -ti ubu1 -- /bin/bash
</code>```

With mesh gateway

curl -v nginx/

HTTP/1.1 200 OK

Without mesh gateway

curl -v nginx/

HTTP/1.1 404 Not Found

Based on that you can use gateway "mesh" which will work only inside the mesh and won't allow external requests.

I can bring you pack of yamls to test if you want, if you wanna test it.

Let me know if that answer your question or you have any more questions.

Body:
Based on my knowledge you can create virtual service to do that

The reserved word mesh is used to imply all the sidecars in the mesh. When this field is omitted, the default gateway (mesh) will be used, which would apply the rule to all sidecars in the mesh. If a list of gateway names is provided, the rules will apply only to the gateways. To apply the rules to both gateways and sidecars, specify mesh as one of the gateway names.

You can check my another answer on stackoverflow, there is whole reproduction of someone problem where i made virtual service with a gateway to access(in a example just a curl) from outside, and if you want to make it only inside the mesh just delete this gateway and leave only mesh one, like in below example.

Specially the virtual service

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: nginxvirt
spec:
  gateways:
  - mesh #inside cluster
  hosts:
  - nginx.default.svc.cluster.local #inside cluster
  http:
  - name: match-myuid
    match:
    - uri:
        prefix: /
    rewrite:
      uri: /
    route:
    - destination:
        host: nginx.default.svc.cluster.local
        port:
          number: 80

And some external and internal tests

External

with additional gateway to allow external traffic

curl -v -H "host: nginx.com" loadbalancer_istio_ingress_gateway_ip/

HTTP/1.1 200 OK

without additional gateway to allow external traffic, just the mesh one

curl -v -H "host: nginx.com" loadbalancer_istio_ingress_gateway_ip/

HTTP/1.1 404 Not Found

Internal

Created some basic ubuntu pod for tests

kubectl exec -ti ubu1 -- /bin/bash

With mesh gateway

curl -v nginx/

HTTP/1.1 200 OK

Without mesh gateway

curl -v nginx/

HTTP/1.1 404 Not Found

Based on that you can use gateway "mesh" which will work only inside the mesh and won't allow external requests.

I can bring you pack of yamls to test if you want, if you wanna test it.

Let me know if that answer your question or you have any more questions.


问:
DOM Click event never registers if an entity is updating fast
This can be clicked: https://jsfiddle.net/tgrL3vnh/1/

```<code><div id='gg'>One second</div>
<style></style>
<script>
    var click_num=1;
    setInterval(function(){
        var html="<div onclick='alert(click_num++)'>I can be clicked!</div>";
        // $('#gg').html(html);
        document.getElementById('gg').innerHTML=html;
    },2000);
    document.addEventListener('click', function (event) {
        console.log(click_num);
    }, false);
</script>
</code>```

This can't be clicked: https://jsfiddle.net/tgrL3vnh/2/

```<code><div id='gg'>One second</div>
<style></style>
<script>
    var click_num=1;
    setInterval(function(){
        var html="<div onclick='alert(click_num++)'>I can't be clicked!</div>";
        // $('#gg').html(html);
        document.getElementById('gg').innerHTML=html;
    },20);
    document.addEventListener('click', function (event) {
        console.log(click_num);
    }, false);
</script>
</code>```

I have an html including game with interfaces updating occasionally, approximately 5% of the time, clicks to these interfaces are lost, it's very annoying, I'm wondering how I can work around this

In the above example, you can observe this scenario in it's most extreme form, if an entity is updating every 20ms, you can never click it, even at 2000ms, sometimes the clicks don't register, but if you look at the console logs, the clicks can register anywhere else in the page

TL;DR: Only when you click an updating DOM entity, the click event can never be observed, I want to observe it and work around the issue

答:
One solution came from our community, onmousedown instead of onclick works in this scenario

This was the fiddle: https://jsfiddle.net/w93hLkpe/1/

In hindsight, it does make sense, the entity gets removed before mouse up, click doesn't complete, I'm just surprised there wasn't any information online about this problem/solution - I ended up integrating this fix, along with localised updates wherever possible, together they make the ux smooth as expected

Body:
This can be clicked: https://jsfiddle.net/tgrL3vnh/1/

One second

This can't be clicked: https://jsfiddle.net/tgrL3vnh/2/

One second

I have an html including game with interfaces updating occasionally, approximately 5% of the time, clicks to these interfaces are lost, it's very annoying, I'm wondering how I can work around this

In the above example, you can observe this scenario in it's most extreme form, if an entity is updating every 20ms, you can never click it, even at 2000ms, sometimes the clicks don't register, but if you look at the console logs, the clicks can register anywhere else in the page

TL;DR: Only when you click an updating DOM entity, the click event can never be observed, I want to observe it and work around the issue


问:
Reactjs Access class method outside the class but in same file
I have this code and want to access a class method outside the class in AssetsMap array.

```<code>import OrientationEnum from "../enums/orientation_enum";
import * as gameconfig from "../gameconfig";
import GA from "./analytics";
import * as Raven from "raven-js";
import {getQueryString} from "./tools";

const AssetsMap = new Map([
    [AssetsEnum.background, 'common/background.jpg']
]);

class AssetsManager {

    constructor...

    getConfigValue(key, defaultValue) { ... }

}

</code>```

if I try to access getConfigValue method inside map array somethings like this

```<code>[AssetsEnum.background, 'common/background'+this.getConfigValue()+'.jpg']

</code>```

the console throws error that getConfigValue is not defined. How should I access the method?

答: You can't access the getConfigValue() method outside the class with this keyword. Try putting your Map inside the class.

Body:
I have this code and want to access a class method outside the class in AssetsMap array.

import OrientationEnum from "../enums/orientation_enum";
import * as gameconfig from "../gameconfig";
import GA from "./analytics";
import * as Raven from "raven-js";
import {getQueryString} from "./tools";

const AssetsMap = new Map([
    [AssetsEnum.background, 'common/background.jpg']
]);

class AssetsManager {

    constructor...

    getConfigValue(key, defaultValue) { ... }

}

if I try to access getConfigValue method inside map array somethings like this

[AssetsEnum.background, 'common/background'+this.getConfigValue()+'.jpg']

the console throws error that getConfigValue is not defined. How should I access the method?


问:
Invalid result for calculating angles between triangle respective planes
I need to find the angle between two triangles' respective planes. I use triangles from an .stl file of different objects. I have followed the answer from this question. It works with some of the shapes, however, I recently encountered a problem, where the resulting cosine of the angle equals 2, thus it is not correct.

Neither of the two triangles in this case are degenerate, as their points respectively are A, B, C and B, C, D. The common edge is BC. The values:
A (50.3473, 2.03038, 50)
B (99.072, 10.6219, 50)
C (50.3473, 0.3038, 0)
D (99.072, 10.6219, 50)

When I calculate the cross products of BC X AB and BC X AD, they both have the same values. After normalizing them and finding the dot product, it results in 2.

Am I doing something wrong? What does this mean?

Any help is appreciated.

答:
Cauchy-Schwarz inequality: the dot product of two normalized vectors cannot be greater than 1.

The problem must be in the normalisation of the vectors, or in the dot product calculation.


答:
what are your css and image sources?

```<code><img src="images/image.jpg">
</code>```

or

```<code><img src="/images/image.jpg">
</code>```

In this case, you probably want the second style so that it always resolves to http://www.digilink.co/images/image.jpg

Title: htaccess problem cleaun up request uri

Body:
I am using following htaccess code

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.digilink\.co$ [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{REQUEST_URI} ^($|/.*$)

RewriteRule ^category/([a-z]+)-([a-z]+) /search.php?cat=$1-$2 [NC]
RewriteRule ^category/([a-z]+) /search.php?cat=$1 [NC]

#non www to www

RewriteCond %{HTTP_HOST} !^www\.digilink\.co$
RewriteRule (.*) http://www.digilink.co/$1 [R=301,L]

# custom error documents
ErrorDocument 404 http://www.digilink.co/404.php

As the URI is converted as www.digilink.co/category/automotive no CSS and images are loaded. As the directory is added. Please help me with the query.

Body:
what are your css and image sources?

<img src="images/image.jpg">

or

<img src="/images/image.jpg">

In this case, you probably want the second style so that it always resolves to http://www.digilink.co/images/image.jpg


问:
Execute function in other component with no parent child relationship in angular 8
Execute function in other component without parent child relationship in angular 8. Demo code is given url https://stackblitz.com/edit/angular-bex9hp</p>

答:
You have to declare the TwoComponent Reference anyway because if it is not constructed any of its functions will not be called.

change app.component.html

```<code><my-app-two #TwoComponent></my-app-two>
<button type="button" class="btn btn-primary" (click)="func1()">Proceed</button>
</code>```

And in TS file change @ViewChild

```<code>@ViewChild('TwoComponent', {static: false}) TwoComponent: TwoComponent;
</code>```

Body:
You have to declare the TwoComponent Reference anyway because if it is not constructed any of its functions will not be called.

change app.component.html

<my-app-two #TwoComponent></my-app-two>
<button type="button" class="btn btn-primary" (click)="func1()">Proceed</button>

And in TS file change @ViewChild

@ViewChild('TwoComponent', {static: false}) TwoComponent: TwoComponent;