问:
How to get similar records using SQL
I need to write sql query for get similar records from table.It has 100 of records with difference of values. But some records have similar name.Similar names start with capital or simple.   </p>

<p>ex- I want to get all the similar records who has similar names. </p>

```<code>Student_no | student_Name | Subject   |class
  1        | Abc          | Java      | 1
  2        | Abc          | Java      | 1
  3        | xyz          | AngularJS | 2
  4        | xyz          | AngularJS | 2
  5        | Abc Def      | SpringBoot| 3
</code>```

答:
Use EXISTS and the LIKE operator:

```<code>select t.*
from tablename t
where exists (
  select 1 from tablename
  where
    Student_no <> t.Student_no
    and (
      student_Name like concat(t.student_Name, '%')
      or
      t.student_Name like concat(student_Name, '%')
    )
)
</code>```

See the demo.

Results:

```<code>| Student_no | student_Name | Subject    | class |
| ---------- | ------------ | ---------- | ----- |
| 1          | Abc          | Java       | 1     |
| 2          | Abc          | Java       | 1     |
| 3          | xyz          | AngularJS  | 2     |
| 4          | xyz          | AngularJS  | 2     |
| 5          | Abc Def      | SpringBoot | 3     |
</code>```

Title: How to get similar records using SQL

Body:
I need to write sql query for get similar records from table.It has 100 of records with difference of values. But some records have similar name.Similar names start with capital or simple.

ex- I want to get all the similar records who has similar names.

Student_no | student_Name | Subject   |class
  1        | Abc          | Java      | 1
  2        | Abc          | Java      | 1
  3        | xyz          | AngularJS | 2
  4        | xyz          | AngularJS | 2
  5        | Abc Def      | SpringBoot| 3

Body:
Use EXISTS and the LIKE operator:

select t.*
from tablename t
where exists (
  select 1 from tablename
  where
    Student_no <> t.Student_no
    and (
      student_Name like concat(t.student_Name, '%')
      or
      t.student_Name like concat(student_Name, '%')
    )
)

See the demo.

Results:

| Student_no | student_Name | Subject    | class |
| ---------- | ------------ | ---------- | ----- |
| 1          | Abc          | Java       | 1     |
| 2          | Abc          | Java       | 1     |
| 3          | xyz          | AngularJS  | 2     |
| 4          | xyz          | AngularJS  | 2     |
| 5          | Abc Def      | SpringBoot | 3     |


来源: stackexchange

问:
Android keystore password change
I would like to change the password I use in my keystore for an android app that is already available in google play and I would like to know some things before I do it:

1) If I change the keystore password, could I continue using the same keystore for my uploaded app without any issue (I need to do this, this is why I ask)

2) Does changing my alias password has the same consequences?

3) How should I use keytool?

答:
We don't want to include the password as part of the command to avoid storing it in the shell history.</p>
```<code># Change the key password
keytool -keypasswd -alias "your_key_alias" -keystore "key_filename.key"
# Change the keystore password
keytool -storepasswd -keystore "key_filename.key"
</code>```

ContentLicense: CC BY-SA 3.0

Title: Android keystore password change

Body:
We don't want to include the password as part of the command to avoid storing it in the shell history.

# Change the key password
keytool -keypasswd -alias "your_key_alias" -keystore "key_filename.key"
# Change the keystore password
keytool -storepasswd -keystore "key_filename.key"

ContentLicense: CC BY-SA 4.0


问:
Run some actions at the same time in a makefile
I have the following makefile.

I would like step0 to run then I would like all of the b*.R scripts to run at the same time in step1. When step1 is complete I would like final to run.

When I run make or make -j 8 it seems like all of the b*.R files still run sequentially. Is this makefile set up correctly to run all of the b*.R files at the same time? If not what do I need to change.

```<code>final : step1
    Rscript c.R

step1 : step0
    Rscript b1.R
    Rscript b2.R
    Rscript b3.R
    Rscript b4.R
    Rscript b5.R
    Rscript b6.R

step0 :
    Rscript a.R
</code>```

答:
If you want make to handle the parallelism for you, you need to restructure the makefile to have different targets.  For example:

```<code>step1: b1 b2 b3 b4 b5 b6
b1: step0
    Rscript b1.R
b2: step0
    Rscript b2.R
...

step0 :
    Rscript a.R
</code>```

Or, you could let the shell do the parallelism and write:

```<code>step1: step0
    Rscript b1.R & Rscript b2.R & \
    Rscript b3.R & ... & wait
</code>```

I would recommend the former.

Body:
I have the following makefile.

I would like step0 to run then I would like all of the b*.R scripts to run at the same time in step1. When step1 is complete I would like final to run.

When I run make or make -j 8 it seems like all of the b*.R files still run sequentially. Is this makefile set up correctly to run all of the b*.R files at the same time? If not what do I need to change.

final : step1
    Rscript c.R

step1 : step0
    Rscript b1.R
    Rscript b2.R
    Rscript b3.R
    Rscript b4.R
    Rscript b5.R
    Rscript b6.R

step0 :
    Rscript a.R

Body:
If you want make to handle the parallelism for you, you need to restructure the makefile to have different targets.  For example:

step1: b1 b2 b3 b4 b5 b6
b1: step0
    Rscript b1.R
b2: step0
    Rscript b2.R
...

step0 :
    Rscript a.R

Or, you could let the shell do the parallelism and write:

step1: step0
    Rscript b1.R & Rscript b2.R & \
    Rscript b3.R & ... & wait

I would recommend the former.


问:
How use reduce() to concat an array and delete the items duplicated
I have a problem using the reduce function in JavaScript. My goal is to take an array of arrays and, using reduce, then concat all the values and delete the duplicates:

I have an array like this:
firstArray = [[1, 2],[2, 3, 4],[4, 5, 6]]

I need an array like this after apply reduce():
resultArray = [1, 2, 3, 4, 5, 6]

```<code>const arrayElements = [[1,2],[2,3,4],[5,6]];
const newArray = arrayElements.reduce((total, value) => {
    return total.concat(value);
}, []);
</code>```

This is the fragment that I have, this only concat all the values, this is to say, [1, 2, 2, 3, 4, 5, 6]

答:
You can do this using Set:

```<code>const newArray = arrayElements.reduce((accum, arr) => [...accum, ..arr], [])
const arrNoDupes = [...new Set(newArray)]
</code>```

or using filter:

```<code>const newArray = arrayElements.reduce((accum, arr) => [
  ...accum
  ...arr.filter(value => !accum.includes(value))
], [])
</code>```

These are just two ways you can do what you want to achieve.

Body:
I have a problem using the reduce function in JavaScript. My goal is to take an array of arrays and, using reduce, then concat all the values and delete the duplicates:

I have an array like this:
firstArray = [[1, 2],[2, 3, 4],[4, 5, 6]]

I need an array like this after apply reduce():
resultArray = [1, 2, 3, 4, 5, 6]

const arrayElements = [[1,2],[2,3,4],[5,6]];
const newArray = arrayElements.reduce((total, value) => {
    return total.concat(value);
}, []);

This is the fragment that I have, this only concat all the values, this is to say, [1, 2, 2, 3, 4, 5, 6]

Body:
You can do this using Set:

const newArray = arrayElements.reduce((accum, arr) => [...accum, ..arr], [])
const arrNoDupes = [...new Set(newArray)]

or using filter:

const newArray = arrayElements.reduce((accum, arr) => [
  ...accum
  ...arr.filter(value => !accum.includes(value))
], [])

These are just two ways you can do what you want to achieve.


问:
Python error while finding greatest number
I am trying techgig problem of finding greatest of 3 numbers. problem as follows

You just need to take three number as input from stdin and you need to
  find greatest of them.

Input Format

You will be taking three numbers as an input from stdin one on each line respectively.

Constraints

-100000 <= N <= 100000

Output Format

You need to print the greatest of the three numbers to the stdout.

Sample TestCase 1

Input

```<code>902
100
666
</code>```

I done this

```<code>''' Read input from STDIN. Print your output to STDOUT '''
#Use input() to read input from STDIN and use print to write your output to STDOUT
import sys
def main():

    s=sys.stdin.read()
    s=s.split("\n")
    a=int(s[0])
    b=int(s[1])
    c=int(s[2])
    temp=0
    e=[a,b,c]
    for i in e:
        if i > temp:
            temp=i
    print(temp)

    '''if (a>b) and (a>c):
        temp = a
    elif (b>a) and (b>c):
        temp = b
    else:
        temp = c
    print(temp)'''

main()
</code>```

It has predefined input 902, 100, 666. My code shows 902 output and expected also shows 902, but its showing failed, Why? In above code commented or non commented thing both showing failed.

答:
I might be wrong but the output says to print using the stdout: You need to print the greatest of the three numbers to the stdout. The print in python is the same as sys.stdout.write(str(99) + '\n'). Try using stdout to print the result.</p>

```<code>sys.stdout.write(str(temp))
</code>```

Body:
I am trying techgig problem of finding greatest of 3 numbers. problem as follows

You just need to take three number as input from stdin and you need to
  find greatest of them.

Input Format

You will be taking three numbers as an input from stdin one on each line respectively.

Constraints

-100000 <= N <= 100000

Output Format

You need to print the greatest of the three numbers to the stdout.

Sample TestCase 1

Input

902
100
666

I done this

''' Read input from STDIN. Print your output to STDOUT '''
#Use input() to read input from STDIN and use print to write your output to STDOUT
import sys
def main():

    s=sys.stdin.read()
    s=s.split("\n")
    a=int(s[0])
    b=int(s[1])
    c=int(s[2])
    temp=0
    e=[a,b,c]
    for i in e:
        if i > temp:
            temp=i
    print(temp)

    '''if (a>b) and (a>c):
        temp = a
    elif (b>a) and (b>c):
        temp = b
    else:
        temp = c
    print(temp)'''

main()

It has predefined input 902, 100, 666. My code shows 902 output and expected also shows 902, but its showing failed, Why? In above code commented or non commented thing both showing failed.

Body:
I might be wrong but the output says to print using the stdout: You need to print the greatest of the three numbers to the stdout. The print in python is the same as sys.stdout.write(str(99) + '\n'). Try using stdout to print the result.

sys.stdout.write(str(temp))


问:
Why do we use numpy.argmax() to return an index from a numpy array of predictions?
Let me preface this by saying, I am very new to neural networks, and this is my first time using numpy, tensorflow, or keras.

I wrote a neural network to recognize handwritten digits, using the MNIST data set. I followed this tutorial by Sentdex and noticed he was using print(np.argmax(predictions[0])) to print the first index from the numpy array of predictions.

I tried running the program with that line replaced by print(predictions[i]), (i was set to 0) but the output was not a number, it was:
[2.1975785e-08 1.8658861e-08 2.8842608e-06 5.7113186e-05 1.2067199e-10
 7.2511304e-09 1.6282028e-12 9.9993789e-01 1.3356166e-08 2.0409643e-06].

My code than I'm confused about is:

```<code>predictions = model.predict(x_test)
for i in range(10):
   plt.imshow(x_test[i])
   plt.show()
   print("PREDICTION: ", predictions[i])
</code>```

I read the numpy documentation for the argmax() function, and from what I understand, it takes in a x-dimensional array, converts it to a one-dimensional array, then returns the index of the largest value. The Keras documentation for model.predict() indicated that the function returns a numpy array of the networks predictions. So I don't understand why we have to use argmax() to properly print the prediction, because as I understand, it has a completely unrelated purpose.

Sorry for the bad code formatting, I couldn't figure out how to properly insert multi line chunks of code into my post

答:
If i understand well your question, the answer is pretty simple :

You want to predict which number is in the image, for that you are using a softmax activation layer in order to predict a probability for each class

So your predictions is an array of NUMBER_OF_CLASS shape, but what we want is not the class probability, only which digit is in the image

So we take the indice of the maximum probability in this array of prediction

This indice will correspond to digit predicted by the network

I hope i'm clear ahah

Body:
Let me preface this by saying, I am very new to neural networks, and this is my first time using numpy, tensorflow, or keras.

I wrote a neural network to recognize handwritten digits, using the MNIST data set. I followed this tutorial by Sentdex and noticed he was using print(np.argmax(predictions[0])) to print the first index from the numpy array of predictions.

I tried running the program with that line replaced by print(predictions[i]), (i was set to 0) but the output was not a number, it was:
[2.1975785e-08 1.8658861e-08 2.8842608e-06 5.7113186e-05 1.2067199e-10
 7.2511304e-09 1.6282028e-12 9.9993789e-01 1.3356166e-08 2.0409643e-06].

My code than I'm confused about is:

predictions = model.predict(x_test)
for i in range(10):
   plt.imshow(x_test[i])
   plt.show()
   print("PREDICTION: ", predictions[i])

I read the numpy documentation for the argmax() function, and from what I understand, it takes in a x-dimensional array, converts it to a one-dimensional array, then returns the index of the largest value. The Keras documentation for model.predict() indicated that the function returns a numpy array of the networks predictions. So I don't understand why we have to use argmax() to properly print the prediction, because as I understand, it has a completely unrelated purpose.

Sorry for the bad code formatting, I couldn't figure out how to properly insert multi line chunks of code into my post


问:
Rails: Starting Sidekiq on Heroku
I'm having a problem getting Sidekiq up and running on my Heroku deployed Rails app. I have my app working fine in development (and on Heroku without Sidekiq).

I created a Procfile with:

```<code>worker: bundle exec sidekiq
</code>```

If I run heroku ps, the only process I see is web.1.

Should I see one for
Sidekiq?

I do get an error:

Redis::CannotConnectError (Error connecting to Redis on localhost:6379) in my Heroku logs.

UPDATE: Found I probably needed heroku addons:add redistogo. Still not working.  I feel I'm missing some basic configuration.

Is there something I need to do to get Redis up and running for my Heroku app?

I've been using Redis/Sidekiq for about a day, so this is new to me.

Thanks!

Greg

答:
Complementing gdurelle answer:

You do need some config with Heroku for Sidekiq:

1) Have the Sidekiq and Redis gems installed (in gemfile and bundled), in my case:

Gemfile

```<code>gem 'redis', '~> 3.1'
gem 'sidekiq', '~> 2.7', '>= 2.7.1'
</code>```

2) Add a worker, if you don't have any workers created locally I suggest you create at least one, just in case, use this:

```<code>rails g sidekiq:worker Hard # will create app/workers/hard_worker.rb
</code>```

should create this:

app/workers/hard_worker.rb

```<code>class HardWorker
  include Sidekiq::Worker
  def perform(name, count)
    # do something
  end
end
</code>```

3) Add the Redis add-on (in my case Heroku Redis):

```<code>heroku addons:create heroku-redis:hobby-dev
</code>```

4) Add your redis.rb file, in my case:

config/initializers/redis.rb

```<code>$redis = Redis.new(url: ENV["REDIS_URL"])
</code>```

5) Add Procfile or config/sidekiq.yml or both, here are mine:

Procfile

```<code>worker: bundle exec sidekiq -c 1 -q default -q mailers
</code>```

which you can create easier by pasting this in your terminal

```<code>echo "worker: bundle exec sidekiq -c 1 -q default -q mailers" > Procfile
</code>```

config/sidekiq.yml

```<code>:concurrency: 1
:queues:
  - [mailers, 7]
  - [default, 5]
</code>```

6) Most important part go here:

and turn on the switch for your worker, click on the pencil and then turn on the missing switch. Things should be working fine now, have a great day!

Title: Rails: Starting Sidekiq on Heroku

Body:
I'm having a problem getting Sidekiq up and running on my Heroku deployed Rails app. I have my app working fine in development (and on Heroku without Sidekiq).

I created a Procfile with:

worker: bundle exec sidekiq

If I run heroku ps, the only process I see is web.1.

Should I see one for
Sidekiq?

I do get an error:

Redis::CannotConnectError (Error connecting to Redis on localhost:6379) in my Heroku logs.

UPDATE: Found I probably needed heroku addons:add redistogo. Still not working.  I feel I'm missing some basic configuration.

Is there something I need to do to get Redis up and running for my Heroku app?

I've been using Redis/Sidekiq for about a day, so this is new to me.

Thanks!

Greg

Body:
Complementing gdurelle answer:

You do need some config with Heroku for Sidekiq:

1) Have the Sidekiq and Redis gems installed (in gemfile and bundled), in my case:

Gemfile

gem 'redis', '~> 3.1'
gem 'sidekiq', '~> 2.7', '>= 2.7.1'

2) Add a worker, if you don't have any workers created locally I suggest you create at least one, just in case, use this:

rails g sidekiq:worker Hard # will create app/workers/hard_worker.rb

should create this:

app/workers/hard_worker.rb

class HardWorker
  include Sidekiq::Worker
  def perform(name, count)
    # do something
  end
end

3) Add the Redis add-on (in my case Heroku Redis):

heroku addons:create heroku-redis:hobby-dev

4) Add your redis.rb file, in my case:

config/initializers/redis.rb

$redis = Redis.new(url: ENV["REDIS_URL"])

5) Add Procfile or config/sidekiq.yml or both, here are mine:

Procfile

worker: bundle exec sidekiq -c 1 -q default -q mailers

which you can create easier by pasting this in your terminal

echo "worker: bundle exec sidekiq -c 1 -q default -q mailers" > Procfile

config/sidekiq.yml

:concurrency: 1
:queues:
  - [mailers, 7]
  - [default, 5]

6) Most important part go here:

and turn on the switch for your worker, click on the pencil and then turn on the missing switch. Things should be working fine now, have a great day!


问:
system cannot find the path specified in spark-shell
I am trying to install Spark in Win7 and am getting an error.

These are my environment settings:

SPARK_HOME : C:\spark (this is where I have unzipped the spark files)

JAVA_HOME : C:\Program Files\Java\jdk1.7.0_71;

```<code>SCALA_HOME: C:\Program Files (x86)\scala
</code>```

PATH : C:\Program Files\Java\jdk1.7.0_71\bin;C:\app\Sampad\product\11.2.0\dbhome_1\bin;C:\Python27;C:\Program Files\Python27\;C:\Program Files\Python27\Scripts;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Java\jdk1.6.0_45\bin;C:\Program Files\nodejs\;C:\Program Files\Python27;C:\Anaconda;C:\Anaconda\Scripts;C:\HashiCorp\Vagrant\bin;C:\Program Files (x86)\scala\bin;C:\spark\bin;

```<code>HADOOP_HOME : C:\winutils; (set this after reading this blog
</code>```

Please let me know what mistake I have made. Thanks in advance.

答:
you need to setup JAVA_HOME and path
the first thing is you have to go

```<code>edit system Environment variable -> Environment variable -> under the User varibales for <user>
</code>```

add New

```<code>1. JAVA_HOME = C:\Program Files\Java\jdk1.8.0_191
In path
add %JAVA_HOME%\bin

2. SPARK_HOME = C:\spark   //*spark is my folder where i have installed spark*
In path
add %SPARK_HOME%\bin
</code>```

This will fix your problem

Body:
I am trying to install Spark in Win7 and am getting an error.

These are my environment settings:

SPARK_HOME : C:\spark (this is where I have unzipped the spark files)

JAVA_HOME : C:\Program Files\Java\jdk1.7.0_71;

SCALA_HOME: C:\Program Files (x86)\scala

PATH : C:\Program Files\Java\jdk1.7.0_71\bin;C:\app\Sampad\product\11.2.0\dbhome_1\bin;C:\Python27;C:\Program Files\Python27\;C:\Program Files\Python27\Scripts;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Java\jdk1.6.0_45\bin;C:\Program Files\nodejs\;C:\Program Files\Python27;C:\Anaconda;C:\Anaconda\Scripts;C:\HashiCorp\Vagrant\bin;C:\Program Files (x86)\scala\bin;C:\spark\bin;

HADOOP_HOME : C:\winutils; (set this after reading this blog

Please let me know what mistake I have made. Thanks in advance.

Body:
you need to setup JAVA_HOME and path
the first thing is you have to go

edit system Environment variable -> Environment variable -> under the User varibales for <user>

add New

1. JAVA_HOME = C:\Program Files\Java\jdk1.8.0_191
In path
add %JAVA_HOME%\bin

2. SPARK_HOME = C:\spark   //*spark is my folder where i have installed spark*
In path
add %SPARK_HOME%\bin

This will fix your problem


问:
How to get number of lines of TextView?
I want to get the number of lines of a text view

```<code>textView.setText("Test line 1 Test line 2 Test line 3 Test line 4 Test line 5.............")
</code>```

textView.getLineCount(); always returns zero

Then I have also tried:

```<code>ViewTreeObserver vto = this.textView.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {

    @Override
    public void onGlobalLayout() {
        ViewTreeObserver obs = textView.getViewTreeObserver();
        obs.removeGlobalOnLayoutListener(this);
        System.out.println(": " + textView.getLineCount());

    }
});
</code>```

It returns the exact output.

But this works only for a static layout.

When I am inflating the layout dynamically this doesn't work anymore.

How could I find the number of line in a TextView?

答:
You can also calculate the amount of lines through this function:

```<code>private fun countLines(textView: TextView): Int {
        return Math.ceil(textView.paint.measureText(textView.text.toString()) /
                textView.measuredWidth.toDouble()).toInt()
    }
</code>```

Keep in mind that It may not work very well on a RecyclerView though.

Title: How to get number of lines of TextView?

Body:
I want to get the number of lines of a text view

textView.setText("Test line 1 Test line 2 Test line 3 Test line 4 Test line 5.............")

textView.getLineCount(); always returns zero

Then I have also tried:

ViewTreeObserver vto = this.textView.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {

    @Override
    public void onGlobalLayout() {
        ViewTreeObserver obs = textView.getViewTreeObserver();
        obs.removeGlobalOnLayoutListener(this);
        System.out.println(": " + textView.getLineCount());

    }
});

It returns the exact output.

But this works only for a static layout.

When I am inflating the layout dynamically this doesn't work anymore.

How could I find the number of line in a TextView?

Body:
You can also calculate the amount of lines through this function:

private fun countLines(textView: TextView): Int {
        return Math.ceil(textView.paint.measureText(textView.text.toString()) /
                textView.measuredWidth.toDouble()).toInt()
    }

Keep in mind that It may not work very well on a RecyclerView though.


问:
How to SET CELL VALUE without written any formula in it
I have values in

A2 = "2"

B2 = "1"

C2 = "3"

and formula in D2

Is it possible to set a value of Cell A3 equals to C2 without putting any formula in A3 and depending upon results of D2 and not using app script?
Like if:

D2 = if(A2>B2,than value A3= C2 eles keep blank

答:
For (almost?) all practical purposes "can't be done" but as a curiosity, and perhaps with some liberal interpretation of the requirements (and because tagged google-query-language), it might be considered technically feasible (if largely useless). Assuming the 'trigger' is for the formula in D2 to return 9, in A2 with A3 blank:

```<code>=query(C2:D2,"select C where D=9 label C '2'")
</code>```

Body:
For (almost?) all practical purposes "can't be done" but as a curiosity, and perhaps with some liberal interpretation of the requirements (and because tagged google-query-language), it might be considered technically feasible (if largely useless). Assuming the 'trigger' is for the formula in D2 to return 9, in A2 with A3 blank:

=query(C2:D2,"select C where D=9 label C '2'")


问:
Unable to resolve dependency as a result of conversion to using Gradle Kotlin DSL
Having converted my original Kotlin Gradle scripts from using groovy to using Kotlin DSL using the following articles as references:
A Better way to Manage Gradle Build Script
and Migrating Gradle Build Scripts to Kotlin DSL. After compiling my code I get the following build errors.

```<code>ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could
not resolve project :app.
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for
':app@debugAndroidTest/compileClasspath': Could not resolve project :app.
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for
':app@debugUnitTest/compileClasspath': Could not resolve project :app.
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for ':app@release/compileClasspath':
Could not resolve project :app.
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for
':app@releaseUnitTest/compileClasspath': Could not resolve project :app.
Show Details
Affected Modules: app
</code>```

Past questions asked on this platform have suggested,

Invalidating the cache and restarting android studio, which I have
tried and that does not seem to work.

Making sure that the gradle global setting is not selected as offline work,
that has also been checked that is offline and the problem still persists.

I have tried to resolve the issue using the suggested solutions.
My build.gradle for the app module is as follows:

```<code>plugins {
    id(Plugins.androidApplication)
    kotlin(Plugins.kotlinAndroid)
    kotlin(Plugins.kotlinExtensions)
    kotlin(Plugins.kapt)
}
android {

    compileSdkVersion(Configs.compileVersion)
    defaultConfig {
        applicationId = Configs.applicationId
        minSdkVersion(Configs.minSdkVersion)
        targetSdkVersion(Configs.targetSdkVersion)
        testInstrumentationRunner = Configs.testInstrumentationRunner
        var value = Integer.parseInt(project.property("build_version_code") as String?)
        versionCode = value
        versionName = project.property("build_version") as String?
    }

    signingConfigs {
        getByName("debug") {

        }

        create("release") {

        }
    }
        buildTypes {
        getByName("debug") {
            buildConfigField("boolean", "MOCK_HARDWARE", "false")
            signingConfig = signingConfigs.findByName("debug")
            applicationIdSuffix = ".debug"
            matchingFallbacks = listOf("debug")
        }
        getByName("release") {
            isMinifyEnabled = false
            buildConfigField("boolean", "MOCK_HARDWARE", "false")
            proguardFiles(getDefaultProguardFile(ProGuards.proguardTxt), ProGuards.androidDefault)
            signingConfig = signingConfigs.findByName("release")
            matchingFallbacks = listOf("release")
        }

    dataBinding {
        isEnabled = true
    }

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
}
repositories {
    flatDir {
        dirs("libs")
    }
}
dependencies {

    implementation(fileTree(mapOf("dir" to "libs", "include" to
    listOf("*.jar", "*.arr"))))
    implementation(Libs.stdLib)
    implementation(Libs.sunmiui)
    implementation(Libs.slf4j)
    implementation(Libs.appCompact)
    implementation(Libs.otpView)
    implementation(Libs.vectordrawableAnimated)
    implementation(Libs.materialComponents)
    implementation(Libs.recyclerView)
    implementation(Libs.constraintLayout)
    implementation(Libs.junit)
    implementation(Libs.testRunner)
    implementation(Libs.expressoCore)
    implementation(Libs.lifecyleExtensions)
    kapt(Libs.lifecyleCompiler)
    implementation(Libs.roomRuntime)
    implementation(Libs.databindingCompiler)
    implementation(Libs.rxjava)
    implementation(Libs.rxjavaAndroid)
    implementation(Libs.glide)
    implementation(Libs.glideCompiler)
    implementation(Libs.gson)
    implementation(Libs.joda)
    implementation(Libs.countrycodePicker)
    implementation(Libs.timber)
    implementation(Libs.daggerandroidSupport)
    implementation(Libs.daggerandroidProcessor)
}
</code>```

My Dependecies.kts is as follows:

```<code>    object Versions
    {
        // kotlin
        const val kotlin = "1.3.31"
        const val buildToolsVersion = "28.0.3"

        const val lifecycleExtensionVersion = "2.0.0"
        const val lifecyleCompilerVersion = "2.0.0"

        const val stdLibVersion = "1.3.21"
        const val otpViewVersion = "2.0.3"

        const val appCompactVersion = "1.1.0-alpha05"
        const val constraintLayoutVersion = "2.0.0-beta1"
        const val materialComponentsVersion = "1.1.0-alpha06"
        const val recyclerViewVersion = "1.0.0"

        const val junitVersion = "4.12"
        const val testRunnerVersion = "1.1.1"
        const val expressoCoreVersion = "3.1.1"

        const val roomRuntimeVersion = "2.1.0-alpha04"

        const val databindingCompilerVersion = "3.5.0-alpha06"

        const val rxjavaVersion = "2.2.7"
        const val rxjavaAndroidVersion = "2.1.1"

        const val glideVersion = "4.8.0"
        const val glideCompilerVersion = "4.8.0"

        const val gsonVersion = "2.8.5"

        const val jodaVersion = "2.7.2"

        const val countrycodePickerVersion = "2.3.0"

        const val timberVersion = "4.7.1"

        const val daggerandroidSupportVersion = "2.19"
        const val daggerandroidProcessorVersion = "2.19"

        const val slf4jVersion = "1.7.21"

        const val vectordrawableAnimatedVersion = "1.1.0-beta01"

        const val sunmiuiVersion = "1.1.27"
    }

    object Libs
    {
        const val lifecyleExtensions = "androidx.lifecycle:lifecycle-extensions:${Versions.lifecycleExtensionVersion}"
        const val lifecyleCompiler = "androidx.lifecycle:lifecycle-compiler:${Versions.lifecyleCompilerVersion}"

        const val stdLib = "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${Versions.kotlin}"

        const val otpView = "com.github.mukeshsolanki:android-otpview-pinview:${Versions.otpViewVersion}"

        const val appCompact = "androidx.appcompat:appcompat:${Versions.appCompactVersion}"
        const val constraintLayout = "androidx.constraintlayout:constraintlayout:${Versions.constraintLayoutVersion}"
        const val materialComponents = "com.google.android.material:material:${Versions.materialComponentsVersion}"
        const val recyclerView = "androidx.recyclerview:recyclerview:${Versions.recyclerViewVersion}"

        const val junit = "junit:junit:${Versions.junitVersion}"
        const val testRunner = "androidx.test:runner:${Versions.testRunnerVersion}"
        const val expressoCore = "androidx.test.espresso:espresso-core:${Versions.expressoCoreVersion}"

        const val roomRuntime = "androidx.room:room-runtime:${Versions.roomRuntimeVersion}"

        const val databindingCompiler = "androidx.databinding:databinding-compiler:${Versions.databindingCompilerVersion}"

        const val rxjava = "io.reactivex.rxjava2:rxjava:${Versions.rxjavaVersion}"
        const val rxjavaAndroid = "io.reactivex.rxjava2:rxandroid:${Versions.rxjavaAndroidVersion}"

        const val glide = "com.github.bumptech.glide:glide:${Versions.glideVersion}"
        const val glideCompiler = "com.github.bumptech.glide:compiler:${Versions.glideCompilerVersion}"

        const val gson = "com.google.code.gson:gson:${Versions.gsonVersion}"

        const val joda = "net.danlew:android.joda:${Versions.jodaVersion}"

        const val countrycodePicker = "com.github.joielechong:countrycodepicker:${Versions.countrycodePickerVersion}"

        const val timber = "com.jakewharton.timber:timber:${Versions.timberVersion}"

        const val daggerandroidSupport = "com.google.dagger:dagger-android-support:${Versions.daggerandroidSupportVersion}"
        const val daggerandroidProcessor = "com.google.dagger:dagger-android-processor:${Versions.daggerandroidProcessorVersion}"

        const val slf4j = "org.slf4j:slf4j-api:${Versions.slf4jVersion}"

        const val vectordrawableAnimated = "androidx.vectordrawable:vectordrawable-animated:${Versions.vectordrawableAnimatedVersion}"

        const val sunmiui = "com.sunmi:sunmiui:${Versions.sunmiuiVersion}"
    }

    object Plugins
    {
        const val androidApplication = "com.android.application"
        const val kotlinAndroid = "android"
        const val kotlinExtensions = "android.extensions"
        const val kapt = "kapt"
    }

    object ProGuards
    {
        val androidDefault = "proguard-rules.pro"
        val proguardTxt = "proguard-android.txt"
    }

    object ClassPaths
    {
        const val gradlePlugin = "com.android.tools.build:gradle:3.4.1"
        const val kotlinPlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.31"
    }

    object Configs
    {
        const val applicationId = "eteetetet"
        const val compileVersion = 28
        const val minSdkVersion = 24
        const val targetSdkVersion = 28
        const val testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
    }
</code>```

My build.gradle for the Project Module is as follows:

```<code>    buildscript {
        repositories {
            google()
            jcenter()
            mavenCentral()
        }

        dependencies {
            classpath(ClassPaths.gradlePlugin)
            classpath(ClassPaths.kotlinPlugin)

            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }

    allprojects {
        repositories {
            jcenter()
            google()
            mavenCentral()
            maven {
                url = uri("https://plugins.gradle.org/m2/")
            }
            maven {
                url = uri("https://maven.google.com")
            }
            maven { url = uri("https://jitpack.io") }
        }
    }

    tasks.register("clean", Delete::class) {
        delete(rootProject.buildDir)
    }
</code>```

My settings.gradle.kts file is as follows:

```<code>include(":app",
        ":asterixclient",
        ":asterixtest",
        ":data",
        ":hardware",
        ":registrations",
        ":rewards",
        ":rules",
        ":rulescontracts",
        ":sdfclient",
        ":sdfservice",
        ":sunmiclient",
        ":sync",
        ":till",
        ":tsdevice",
        ":ui",
        ":webapi")

project(":asterixclient").projectDir =
File("../modules/sdfservice/asterixclient")
project(":asterixtest").projectDir =
File("../modules/sdfservice/asterixtest")
project(":data").projectDir = File("../modules/data/data")
project(":hardware").projectDir = File("../modules/hardware/hardware")
project(":registrations").projectDir = File("../modules/registrations/app")
project(":rewards").projectDir = File("../modules/rewards/rewards")
project(":rules").projectDir = File("../modules/rules/rules")
project(":rulescontracts").projectDir =
File("../modules/rules/rulescontracts")
project(":sdfclient").projectDir = File("../modules/sdfservice/sdfclient")
project(":sdfservice").projectDir = File("../modules/sdfservice/sdfservice")
project(":sunmiclient").projectDir =
File("../modules/sdfservice/sunmiclient")
project(":sync").projectDir = File("../modules/sync/sync")
project(":till").projectDir = File("../modules/till/till")
project(":tsdevice").projectDir = File("../modules/sdfservice/tsdevice")
project(":ui").projectDir = File("../modules/ui/ui")
project(":webapi").projectDir = File("../modules/webapi/webapi")
</code>```

答:
I finally resolved the issue this is how I changed the

Firstly I updated to the latest version of the Gradle distribution

```<code>#Tue May 14 11:11:48 CAT 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
</code>```

Then I changed the gradle.buid.kts for the app module to look as follows

```<code>plugins {
    id(Plugins.androidApplication)
    kotlin(Plugins.kotlinAndroid)
    kotlin(Plugins.kotlinExtensions)
    kotlin(Plugins.kapt)
}

android {
    compileSdkVersion(Configs.compileVersion)
    buildToolsVersion(Versions.buildToolsVersion)

    defaultConfig {
        multiDexEnabled = true
        applicationId = Configs.applicationId
        minSdkVersion(Configs.minSdkVersion)
        targetSdkVersion(Configs.targetSdkVersion)
        val version_code = Integer.parseInt(project.property("build_version_code") as String)
        versionCode = version_code
        versionName = project.property("build_version") as String
        testInstrumentationRunner = Configs.testInstrumentationRunner
        proguardFiles(getDefaultProguardFile(ProGuard.proguardTxt), ProGuard.androidDefault)
    }

    signingConfigs {
        named("debug").configure {
            storeFile = file(project.property("keyStore") as String)
            storePassword = project.property("keystorePassword") as String
            keyPassword = project.property("keystorePassword") as String
            keyAlias = project.property("keyName") as String
        }

        register("release") {
            storeFile = file(project.property("keyStore") as String)
            storePassword = project.property("keystorePassword") as String
            keyPassword = project.property("keystorePassword") as String
            keyAlias = project.property("keyName") as String
        }
    }

    buildTypes {
        named("release").configure {
            buildConfigField("boolean", "MOCK_HARDWARE", "false")
            proguardFiles(getDefaultProguardFile(ProGuard.proguardTxt), ProGuard.androidDefault)
            signingConfig = (signingConfigs.getByName("release"))
            matchingFallbacks = listOf("release")
        }
        named("debug").configure {
            buildConfigField("boolean", "MOCK_HARDWARE", "false")
            applicationIdSuffix = ".debug"
            signingConfig = signingConfigs.getByName("debug")
            matchingFallbacks = listOf("debug")
        }
    }

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }

    repositories {
        flatDir {
            dirs("libs")
        }
    }
}

dependencies {
    implementation(fileTree(mapOf("include" to listOf("*.jar", "*.arr"), "dir" to "libs")))
    implementation(Libs.stdLib)
    implementation(Libs.sunmiui)
    implementation(Libs.slf4j)
    implementation(Libs.appCompact)
    implementation(Libs.otpView)
    implementation(Libs.vectordrawableAnimated)
    implementation(Libs.materialComponents)
    implementation(Libs.recyclerView)
    implementation(Libs.constraintLayout)
    implementation(Libs.junit)
    implementation(Libs.testRunner)
    implementation(Libs.expressoCore)
    implementation(Libs.lifecyleExtensions)
    annotationProcessor(Libs.lifecyleCompiler)
    implementation(Libs.roomRuntime)
    annotationProcessor(Libs.databindingCompiler)
    implementation(Libs.rxjava)
    implementation(Libs.rxjavaAndroid)
    implementation(Libs.glide)
    annotationProcessor(Libs.glideCompiler)
    implementation(Libs.gson)
    implementation(Libs.joda)
    implementation(Libs.countrycodePicker)
    implementation(Libs.timber)
    implementation(Libs.daggerandroidSupport)
    annotationProcessor(Libs.daggerandroidProcessor)
    implementation(project(":data"))
    implementation (project( ":ui"))
    implementation (project( ":webapi"))
    implementation (project(":hardware"))
    implementation (project(":sdfclient"))

}
</code>```

I also updated the project references in the settings.gradle.kts file as follows:

```<code>include(":app",
        ":data")
project(":data").projectDir = file("../modules/data/data"))
</code>```

The major changes being the signingConfigs, buildTypes and the referencing of the other modules in the project.
For example

```<code>implementation(project(":data"))
</code>```

instead of

```<code>implementation(project(path, ":data"))
</code>```

Body:
Having converted my original Kotlin Gradle scripts from using groovy to using Kotlin DSL using the following articles as references:
A Better way to Manage Gradle Build Script
and Migrating Gradle Build Scripts to Kotlin DSL. After compiling my code I get the following build errors.

ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could
not resolve project :app.
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for
':app@debugAndroidTest/compileClasspath': Could not resolve project :app.
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for
':app@debugUnitTest/compileClasspath': Could not resolve project :app.
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for ':app@release/compileClasspath':
Could not resolve project :app.
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for
':app@releaseUnitTest/compileClasspath': Could not resolve project :app.
Show Details
Affected Modules: app

Past questions asked on this platform have suggested,

Invalidating the cache and restarting android studio, which I have
tried and that does not seem to work.

Making sure that the gradle global setting is not selected as offline work,
that has also been checked that is offline and the problem still persists.

I have tried to resolve the issue using the suggested solutions.
My build.gradle for the app module is as follows:

plugins {
    id(Plugins.androidApplication)
    kotlin(Plugins.kotlinAndroid)
    kotlin(Plugins.kotlinExtensions)
    kotlin(Plugins.kapt)
}
android {

    compileSdkVersion(Configs.compileVersion)
    defaultConfig {
        applicationId = Configs.applicationId
        minSdkVersion(Configs.minSdkVersion)
        targetSdkVersion(Configs.targetSdkVersion)
        testInstrumentationRunner = Configs.testInstrumentationRunner
        var value = Integer.parseInt(project.property("build_version_code") as String?)
        versionCode = value
        versionName = project.property("build_version") as String?
    }

    signingConfigs {
        getByName("debug") {

        }

        create("release") {

        }
    }
        buildTypes {
        getByName("debug") {
            buildConfigField("boolean", "MOCK_HARDWARE", "false")
            signingConfig = signingConfigs.findByName("debug")
            applicationIdSuffix = ".debug"
            matchingFallbacks = listOf("debug")
        }
        getByName("release") {
            isMinifyEnabled = false
            buildConfigField("boolean", "MOCK_HARDWARE", "false")
            proguardFiles(getDefaultProguardFile(ProGuards.proguardTxt), ProGuards.androidDefault)
            signingConfig = signingConfigs.findByName("release")
            matchingFallbacks = listOf("release")
        }

    dataBinding {
        isEnabled = true
    }

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
}
repositories {
    flatDir {
        dirs("libs")
    }
}
dependencies {

    implementation(fileTree(mapOf("dir" to "libs", "include" to
    listOf("*.jar", "*.arr"))))
    implementation(Libs.stdLib)
    implementation(Libs.sunmiui)
    implementation(Libs.slf4j)
    implementation(Libs.appCompact)
    implementation(Libs.otpView)
    implementation(Libs.vectordrawableAnimated)
    implementation(Libs.materialComponents)
    implementation(Libs.recyclerView)
    implementation(Libs.constraintLayout)
    implementation(Libs.junit)
    implementation(Libs.testRunner)
    implementation(Libs.expressoCore)
    implementation(Libs.lifecyleExtensions)
    kapt(Libs.lifecyleCompiler)
    implementation(Libs.roomRuntime)
    implementation(Libs.databindingCompiler)
    implementation(Libs.rxjava)
    implementation(Libs.rxjavaAndroid)
    implementation(Libs.glide)
    implementation(Libs.glideCompiler)
    implementation(Libs.gson)
    implementation(Libs.joda)
    implementation(Libs.countrycodePicker)
    implementation(Libs.timber)
    implementation(Libs.daggerandroidSupport)
    implementation(Libs.daggerandroidProcessor)
}

My Dependecies.kts is as follows:

    object Versions
    {
        // kotlin
        const val kotlin = "1.3.31"
        const val buildToolsVersion = "28.0.3"

        const val lifecycleExtensionVersion = "2.0.0"
        const val lifecyleCompilerVersion = "2.0.0"

        const val stdLibVersion = "1.3.21"
        const val otpViewVersion = "2.0.3"

        const val appCompactVersion = "1.1.0-alpha05"
        const val constraintLayoutVersion = "2.0.0-beta1"
        const val materialComponentsVersion = "1.1.0-alpha06"
        const val recyclerViewVersion = "1.0.0"

        const val junitVersion = "4.12"
        const val testRunnerVersion = "1.1.1"
        const val expressoCoreVersion = "3.1.1"

        const val roomRuntimeVersion = "2.1.0-alpha04"

        const val databindingCompilerVersion = "3.5.0-alpha06"

        const val rxjavaVersion = "2.2.7"
        const val rxjavaAndroidVersion = "2.1.1"

        const val glideVersion = "4.8.0"
        const val glideCompilerVersion = "4.8.0"

        const val gsonVersion = "2.8.5"

        const val jodaVersion = "2.7.2"

        const val countrycodePickerVersion = "2.3.0"

        const val timberVersion = "4.7.1"

        const val daggerandroidSupportVersion = "2.19"
        const val daggerandroidProcessorVersion = "2.19"

        const val slf4jVersion = "1.7.21"

        const val vectordrawableAnimatedVersion = "1.1.0-beta01"

        const val sunmiuiVersion = "1.1.27"
    }

    object Libs
    {
        const val lifecyleExtensions = "androidx.lifecycle:lifecycle-extensions:${Versions.lifecycleExtensionVersion}"
        const val lifecyleCompiler = "androidx.lifecycle:lifecycle-compiler:${Versions.lifecyleCompilerVersion}"

        const val stdLib = "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${Versions.kotlin}"

        const val otpView = "com.github.mukeshsolanki:android-otpview-pinview:${Versions.otpViewVersion}"

        const val appCompact = "androidx.appcompat:appcompat:${Versions.appCompactVersion}"
        const val constraintLayout = "androidx.constraintlayout:constraintlayout:${Versions.constraintLayoutVersion}"
        const val materialComponents = "com.google.android.material:material:${Versions.materialComponentsVersion}"
        const val recyclerView = "androidx.recyclerview:recyclerview:${Versions.recyclerViewVersion}"

        const val junit = "junit:junit:${Versions.junitVersion}"
        const val testRunner = "androidx.test:runner:${Versions.testRunnerVersion}"
        const val expressoCore = "androidx.test.espresso:espresso-core:${Versions.expressoCoreVersion}"

        const val roomRuntime = "androidx.room:room-runtime:${Versions.roomRuntimeVersion}"

        const val databindingCompiler = "androidx.databinding:databinding-compiler:${Versions.databindingCompilerVersion}"

        const val rxjava = "io.reactivex.rxjava2:rxjava:${Versions.rxjavaVersion}"
        const val rxjavaAndroid = "io.reactivex.rxjava2:rxandroid:${Versions.rxjavaAndroidVersion}"

        const val glide = "com.github.bumptech.glide:glide:${Versions.glideVersion}"
        const val glideCompiler = "com.github.bumptech.glide:compiler:${Versions.glideCompilerVersion}"

        const val gson = "com.google.code.gson:gson:${Versions.gsonVersion}"

        const val joda = "net.danlew:android.joda:${Versions.jodaVersion}"

        const val countrycodePicker = "com.github.joielechong:countrycodepicker:${Versions.countrycodePickerVersion}"

        const val timber = "com.jakewharton.timber:timber:${Versions.timberVersion}"

        const val daggerandroidSupport = "com.google.dagger:dagger-android-support:${Versions.daggerandroidSupportVersion}"
        const val daggerandroidProcessor = "com.google.dagger:dagger-android-processor:${Versions.daggerandroidProcessorVersion}"

        const val slf4j = "org.slf4j:slf4j-api:${Versions.slf4jVersion}"

        const val vectordrawableAnimated = "androidx.vectordrawable:vectordrawable-animated:${Versions.vectordrawableAnimatedVersion}"

        const val sunmiui = "com.sunmi:sunmiui:${Versions.sunmiuiVersion}"
    }

    object Plugins
    {
        const val androidApplication = "com.android.application"
        const val kotlinAndroid = "android"
        const val kotlinExtensions = "android.extensions"
        const val kapt = "kapt"
    }

    object ProGuards
    {
        val androidDefault = "proguard-rules.pro"
        val proguardTxt = "proguard-android.txt"
    }

    object ClassPaths
    {
        const val gradlePlugin = "com.android.tools.build:gradle:3.4.1"
        const val kotlinPlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.31"
    }

    object Configs
    {
        const val applicationId = "eteetetet"
        const val compileVersion = 28
        const val minSdkVersion = 24
        const val targetSdkVersion = 28
        const val testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
    }

My build.gradle for the Project Module is as follows:

    buildscript {
        repositories {
            google()
            jcenter()
            mavenCentral()
        }

        dependencies {
            classpath(ClassPaths.gradlePlugin)
            classpath(ClassPaths.kotlinPlugin)

            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }

    allprojects {
        repositories {
            jcenter()
            google()
            mavenCentral()
            maven {
                url = uri("https://plugins.gradle.org/m2/")
            }
            maven {
                url = uri("https://maven.google.com")
            }
            maven { url = uri("https://jitpack.io") }
        }
    }

    tasks.register("clean", Delete::class) {
        delete(rootProject.buildDir)
    }

My settings.gradle.kts file is as follows:

include(":app",
        ":asterixclient",
        ":asterixtest",
        ":data",
        ":hardware",
        ":registrations",
        ":rewards",
        ":rules",
        ":rulescontracts",
        ":sdfclient",
        ":sdfservice",
        ":sunmiclient",
        ":sync",
        ":till",
        ":tsdevice",
        ":ui",
        ":webapi")

project(":asterixclient").projectDir =
File("../modules/sdfservice/asterixclient")
project(":asterixtest").projectDir =
File("../modules/sdfservice/asterixtest")
project(":data").projectDir = File("../modules/data/data")
project(":hardware").projectDir = File("../modules/hardware/hardware")
project(":registrations").projectDir = File("../modules/registrations/app")
project(":rewards").projectDir = File("../modules/rewards/rewards")
project(":rules").projectDir = File("../modules/rules/rules")
project(":rulescontracts").projectDir =
File("../modules/rules/rulescontracts")
project(":sdfclient").projectDir = File("../modules/sdfservice/sdfclient")
project(":sdfservice").projectDir = File("../modules/sdfservice/sdfservice")
project(":sunmiclient").projectDir =
File("../modules/sdfservice/sunmiclient")
project(":sync").projectDir = File("../modules/sync/sync")
project(":till").projectDir = File("../modules/till/till")
project(":tsdevice").projectDir = File("../modules/sdfservice/tsdevice")
project(":ui").projectDir = File("../modules/ui/ui")
project(":webapi").projectDir = File("../modules/webapi/webapi")

Body:
I finally resolved the issue this is how I changed the

Firstly I updated to the latest version of the Gradle distribution

#Tue May 14 11:11:48 CAT 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

Then I changed the gradle.buid.kts for the app module to look as follows

plugins {
    id(Plugins.androidApplication)
    kotlin(Plugins.kotlinAndroid)
    kotlin(Plugins.kotlinExtensions)
    kotlin(Plugins.kapt)
}

android {
    compileSdkVersion(Configs.compileVersion)
    buildToolsVersion(Versions.buildToolsVersion)

    defaultConfig {
        multiDexEnabled = true
        applicationId = Configs.applicationId
        minSdkVersion(Configs.minSdkVersion)
        targetSdkVersion(Configs.targetSdkVersion)
        val version_code = Integer.parseInt(project.property("build_version_code") as String)
        versionCode = version_code
        versionName = project.property("build_version") as String
        testInstrumentationRunner = Configs.testInstrumentationRunner
        proguardFiles(getDefaultProguardFile(ProGuard.proguardTxt), ProGuard.androidDefault)
    }

    signingConfigs {
        named("debug").configure {
            storeFile = file(project.property("keyStore") as String)
            storePassword = project.property("keystorePassword") as String
            keyPassword = project.property("keystorePassword") as String
            keyAlias = project.property("keyName") as String
        }

        register("release") {
            storeFile = file(project.property("keyStore") as String)
            storePassword = project.property("keystorePassword") as String
            keyPassword = project.property("keystorePassword") as String
            keyAlias = project.property("keyName") as String
        }
    }

    buildTypes {
        named("release").configure {
            buildConfigField("boolean", "MOCK_HARDWARE", "false")
            proguardFiles(getDefaultProguardFile(ProGuard.proguardTxt), ProGuard.androidDefault)
            signingConfig = (signingConfigs.getByName("release"))
            matchingFallbacks = listOf("release")
        }
        named("debug").configure {
            buildConfigField("boolean", "MOCK_HARDWARE", "false")
            applicationIdSuffix = ".debug"
            signingConfig = signingConfigs.getByName("debug")
            matchingFallbacks = listOf("debug")
        }
    }

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }

    repositories {
        flatDir {
            dirs("libs")
        }
    }
}

dependencies {
    implementation(fileTree(mapOf("include" to listOf("*.jar", "*.arr"), "dir" to "libs")))
    implementation(Libs.stdLib)
    implementation(Libs.sunmiui)
    implementation(Libs.slf4j)
    implementation(Libs.appCompact)
    implementation(Libs.otpView)
    implementation(Libs.vectordrawableAnimated)
    implementation(Libs.materialComponents)
    implementation(Libs.recyclerView)
    implementation(Libs.constraintLayout)
    implementation(Libs.junit)
    implementation(Libs.testRunner)
    implementation(Libs.expressoCore)
    implementation(Libs.lifecyleExtensions)
    annotationProcessor(Libs.lifecyleCompiler)
    implementation(Libs.roomRuntime)
    annotationProcessor(Libs.databindingCompiler)
    implementation(Libs.rxjava)
    implementation(Libs.rxjavaAndroid)
    implementation(Libs.glide)
    annotationProcessor(Libs.glideCompiler)
    implementation(Libs.gson)
    implementation(Libs.joda)
    implementation(Libs.countrycodePicker)
    implementation(Libs.timber)
    implementation(Libs.daggerandroidSupport)
    annotationProcessor(Libs.daggerandroidProcessor)
    implementation(project(":data"))
    implementation (project( ":ui"))
    implementation (project( ":webapi"))
    implementation (project(":hardware"))
    implementation (project(":sdfclient"))

}

I also updated the project references in the settings.gradle.kts file as follows:

include(":app",
        ":data")
project(":data").projectDir = file("../modules/data/data"))

The major changes being the signingConfigs, buildTypes and the referencing of the other modules in the project.
For example

implementation(project(":data"))

instead of

implementation(project(path, ":data"))


问:
How can a hierarchical menu be made dynamically in PyroCMS?
I am using PyroCMS Version 1.1.0. It has the navigation module that is used to show up menus in front end. But I couldn't find the way out to generate hierarchical menus like I am working on category module. And in this, I have to generate a menu Category under which I have to show up multi-level menus for categories and subcategories.

Please help me with this.

答:
Each link can have a "parent". Just go to the Navigation page and do it.

This does not support Page Children and the interface is not as awesome as it could be, but those changes are coming in 1.2.

ContentLicense: CC BY-SA 2.5


问:
send email when PutSQL failed
I want to send email when PutSQL failed, PutSQL's Rollback on Failure=true, as the source code does not support send email when PutSQL failed, so I add REL_ALERT relationship. I add three lines code to send email when PutSQL failed, but none of them works.

答:
You can route a flowfile to multiple relationships (see the Apache NiFi Developer Guide -- Route Based on Content (One to Many) for details). I am not sure if you're saying you want rollback on failure to be true, or if you didn't realize you can change it to false.

If you need the rollback on failure to be true AND to receive an email alert, you have a couple options:

Modify the PutSQL source code to clone the flowfile and send it to an alert relationship as above. You'll need to use code similar to RouteOnContent (see below).

Register an email log appender in $NIFI_HOME/conf/logback.xml which gets WARN or ERROR level log events from org.apache.nifi.processors.standard.PutSQL

Sample code for routing flowfile to multiple relationships

```<code>final Relationship firstRelationship = destinations.iterator().next();
destinations.remove(firstRelationship);

for (final Relationship relationship : destinations) {
    FlowFile clone = session.clone(flowFile);
    clone = session.putAttribute(clone, ROUTE_ATTRIBUTE_KEY, relationship.getName());
    session.getProvenanceReporter().route(clone, relationship);
    session.transfer(clone, relationship);
    logger.info("Cloning {} to {} and routing clone to {}", new Object[]{flowFile, clone, relationship});
}

flowFile = session.putAttribute(flowFile, ROUTE_ATTRIBUTE_KEY, firstRelationship.getName());
session.getProvenanceReporter().route(flowFile, firstRelationship);
session.transfer(flowFile, firstRelationship);
logger.info("Routing {} to {}", new Object[]{flowFile, firstRelationship});
</code>```

Title: send email when PutSQL failed

Body:
You can route a flowfile to multiple relationships (see the Apache NiFi Developer Guide -- Route Based on Content (One to Many) for details). I am not sure if you're saying you want rollback on failure to be true, or if you didn't realize you can change it to false.

If you need the rollback on failure to be true AND to receive an email alert, you have a couple options:

Modify the PutSQL source code to clone the flowfile and send it to an alert relationship as above. You'll need to use code similar to RouteOnContent (see below).

Register an email log appender in $NIFI_HOME/conf/logback.xml which gets WARN or ERROR level log events from org.apache.nifi.processors.standard.PutSQL

Sample code for routing flowfile to multiple relationships

final Relationship firstRelationship = destinations.iterator().next();
destinations.remove(firstRelationship);

for (final Relationship relationship : destinations) {
    FlowFile clone = session.clone(flowFile);
    clone = session.putAttribute(clone, ROUTE_ATTRIBUTE_KEY, relationship.getName());
    session.getProvenanceReporter().route(clone, relationship);
    session.transfer(clone, relationship);
    logger.info("Cloning {} to {} and routing clone to {}", new Object[]{flowFile, clone, relationship});
}

flowFile = session.putAttribute(flowFile, ROUTE_ATTRIBUTE_KEY, firstRelationship.getName());
session.getProvenanceReporter().route(flowFile, firstRelationship);
session.transfer(flowFile, firstRelationship);
logger.info("Routing {} to {}", new Object[]{flowFile, firstRelationship});


问:
how to merge data across data.frame rows based on identical column values, for data.frames with multiple column formats
I have raw data in the format of df below that I'm needing to condense into a fewer row data.frame. The data represent eventual GIS point data (columns for coordinates are left off here) so I'm hoping to avoid plotting any duplicate points.  Each row represents one point for which either or both of agency1 and agency2 publish data. A simpler case with fewer column formats is answered here.

For cases where there are rows with identical agency3_id, I'd like to condense those two rows into one row. AS an example, I want rows 3 and 4 in the original data.frame (which both have agency3_id abcde) to become a single row in the desired data.frame below (its row 3). I'm open to any R method.  I'm sure there's a better title question - any help appreciated.

```<code>library(tidyverse)
library(lubridate)

agency1_id   <- as.double(c("1500", NA, "2007", NA, "4501", NA))
agency2_id   <- c(NA, "zxc", NA, "xcv", NA, "bnm")
agency3_id   <- c("qwert", "ertyu", "abcde", "abcde", NA, NA)
agency1_val  <- c(0.21, 1.5, 0.23, NA, 4.3, NA)
agency2_val  <- c(0.05, 4.4, NA, 6.3, NA, 2.0)
agency1_desc <- c("st", NA, "ko", NA, "ui", NA)
agency2_desc <- c(NA, "lo", NA, "vf", NA, "kl")
agency1_dtm  <- ymd_hm(c("2019-05-30 04:30", NA, "2019-05-30 04:35",
                          NA, "2019-05-30 04:33", NA))
agency2_dtm  <- ymd_hm(c(NA, "2019-05-30 04:20", NA, "2019-05-30
                          04:29", NA, "2019-05-30 04:31"))

df <- data.frame(agency1_id, agency2_id, agency3_id, agency1_val,
                 agency2_val, agency1_desc, agency2_desc, agency1_dtm,
                 agency2_dtm)
as_tibble(df)

# agency1_id agency2_id agency3_id agency1_val agency2_val agency1_desc agency2_desc agency1_dtm         agency2_dtm
# <dbl>      <fct>      <fct>       <dbl>       <dbl>        <fct>        <fct>        <dttm>              <dttm>
# 1 1500       NA         qwert      0.21        0.05        st           NA           2019-05-30 04:30:00 NA
# 2 NA         zxc        ertyu      1.5         4.4         NA           lo           NA                  2019-05-30 04:20:00
# 3 2007       NA         abcde      0.23         NA         ko           NA           2019-05-30 04:35:00 NA
# 4 NA         xcv        abcde       NA         6.3         NA           vf           NA                  2019-05-30 04:29:00
# 5 4501       NA         NA         4.3          NA         ui           NA           2019-05-30 04:33:00 NA
# 6 NA         bnm        NA          NA         2           NA           kl           NA                  2019-05-30 04:31:00
</code>```

desired df:

```<code># agency1_id agency2_id agency3_id agency1_val agency2_val agency1_desc agency2_desc agency1_dtm         agency2_dtm
# <dbl>      <fct>      <fct>       <dbl>       <dbl>        <fct>        <fct>        <dttm>              <dttm>
# 1 1500       NA         qwert      0.21        0.05        st           NA           2019-05-30 04:30:00 NA
# 2 NA         zxc        ertyu      1.5         4.4         NA           lo           NA                  2019-05-30 04:20:00
# 3 2007       xcv        abcde      0.23        6.3         ko           vf           2019-05-30 04:35:00 2019-05-30 04:29:00
# 4 4501       NA         NA         4.3          NA         ui           NA           2019-05-30 04:33:00 NA
# 5 NA         bnm        NA          NA         2           NA           kl           NA                  2019-05-30 04:31:00
</code>```

答:
You can make use of this. Might not be the most concise solution.

# Data with NA values in column - agency3_id
df_na <- df[is.na(df$agency3_id), ]

# Logic
df <- df[!is.na(df$agency3_id), ] %>%
  group_by(agency3_id) %>%
  summarise_all(list(~ if(all(is.na(.))) NA else .[!is.na(.)][1]))

# Merge dataframes
rbind(df, df_na)
```

<pre class="lang-r prettyprint-override"><code># Result
# A tibble: 5 x 9
  agency3_id agency1_id agency2_id agency1_val agency2_val agency1_desc agency2_desc agency1_dtm
* <fct>           <dbl> <fct>            <dbl>       <dbl> <fct>        <fct>        <dttm>
1 abcde            2007 xcv               0.23        6.3  ko           vf           2019-05-30 04:35:00
2 ertyu              NA zxc               1.5         4.4  NA           lo           NA
3 qwert            1500 NA                0.21        0.05 st           NA           2019-05-30 04:30:00
4 NA               4501 NA                4.3        NA    ui           NA           2019-05-30 04:33:00
5 NA                 NA bnm              NA           2    NA           kl           NA
# … with 1 more variable: agency2_dtm <dttm>
</code>```

Body:
I have raw data in the format of df below that I'm needing to condense into a fewer row data.frame. The data represent eventual GIS point data (columns for coordinates are left off here) so I'm hoping to avoid plotting any duplicate points.  Each row represents one point for which either or both of agency1 and agency2 publish data. A simpler case with fewer column formats is answered here.

For cases where there are rows with identical agency3_id, I'd like to condense those two rows into one row. AS an example, I want rows 3 and 4 in the original data.frame (which both have agency3_id abcde) to become a single row in the desired data.frame below (its row 3). I'm open to any R method.  I'm sure there's a better title question - any help appreciated.

library(tidyverse)
library(lubridate)

agency1_id   <- as.double(c("1500", NA, "2007", NA, "4501", NA))
agency2_id   <- c(NA, "zxc", NA, "xcv", NA, "bnm")
agency3_id   <- c("qwert", "ertyu", "abcde", "abcde", NA, NA)
agency1_val  <- c(0.21, 1.5, 0.23, NA, 4.3, NA)
agency2_val  <- c(0.05, 4.4, NA, 6.3, NA, 2.0)
agency1_desc <- c("st", NA, "ko", NA, "ui", NA)
agency2_desc <- c(NA, "lo", NA, "vf", NA, "kl")
agency1_dtm  <- ymd_hm(c("2019-05-30 04:30", NA, "2019-05-30 04:35",
                          NA, "2019-05-30 04:33", NA))
agency2_dtm  <- ymd_hm(c(NA, "2019-05-30 04:20", NA, "2019-05-30
                          04:29", NA, "2019-05-30 04:31"))

df <- data.frame(agency1_id, agency2_id, agency3_id, agency1_val,
                 agency2_val, agency1_desc, agency2_desc, agency1_dtm,
                 agency2_dtm)
as_tibble(df)

# agency1_id agency2_id agency3_id agency1_val agency2_val agency1_desc agency2_desc agency1_dtm         agency2_dtm
# <dbl>      <fct>      <fct>       <dbl>       <dbl>        <fct>        <fct>        <dttm>              <dttm>
# 1 1500       NA         qwert      0.21        0.05        st           NA           2019-05-30 04:30:00 NA
# 2 NA         zxc        ertyu      1.5         4.4         NA           lo           NA                  2019-05-30 04:20:00
# 3 2007       NA         abcde      0.23         NA         ko           NA           2019-05-30 04:35:00 NA
# 4 NA         xcv        abcde       NA         6.3         NA           vf           NA                  2019-05-30 04:29:00
# 5 4501       NA         NA         4.3          NA         ui           NA           2019-05-30 04:33:00 NA
# 6 NA         bnm        NA          NA         2           NA           kl           NA                  2019-05-30 04:31:00

desired df:

# agency1_id agency2_id agency3_id agency1_val agency2_val agency1_desc agency2_desc agency1_dtm         agency2_dtm
# <dbl>      <fct>      <fct>       <dbl>       <dbl>        <fct>        <fct>        <dttm>              <dttm>
# 1 1500       NA         qwert      0.21        0.05        st           NA           2019-05-30 04:30:00 NA
# 2 NA         zxc        ertyu      1.5         4.4         NA           lo           NA                  2019-05-30 04:20:00
# 3 2007       xcv        abcde      0.23        6.3         ko           vf           2019-05-30 04:35:00 2019-05-30 04:29:00
# 4 4501       NA         NA         4.3          NA         ui           NA           2019-05-30 04:33:00 NA
# 5 NA         bnm        NA          NA         2           NA           kl           NA                  2019-05-30 04:31:00

Body:
You can make use of this. Might not be the most concise solution.

# Data with NA values in column - agency3_id
df_na <- df[is.na(df$agency3_id), ]

# Logic
df <- df[!is.na(df$agency3_id), ] %>%
  group_by(agency3_id) %>%
  summarise_all(list(~ if(all(is.na(.))) NA else .[!is.na(.)][1]))

# Merge dataframes
rbind(df, df_na)

# Result
# A tibble: 5 x 9
  agency3_id agency1_id agency2_id agency1_val agency2_val agency1_desc agency2_desc agency1_dtm
* <fct>           <dbl> <fct>            <dbl>       <dbl> <fct>        <fct>        <dttm>
1 abcde            2007 xcv               0.23        6.3  ko           vf           2019-05-30 04:35:00
2 ertyu              NA zxc               1.5         4.4  NA           lo           NA
3 qwert            1500 NA                0.21        0.05 st           NA           2019-05-30 04:30:00
4 NA               4501 NA                4.3        NA    ui           NA           2019-05-30 04:33:00
5 NA                 NA bnm              NA           2    NA           kl           NA
# … with 1 more variable: agency2_dtm <dttm>


问:
Center different size images in the same block size
I have different images encapsulated in square style blocks that I would like to always center in but I'm having a heck of a time trying to get them to do so.

I made an example of what's happening to me in similar design. Notice the product (the grill) is not actually centered in the imgblock container.

This starts to become very apparent with other product images that are much wider than narrow.

.imgBlock {
  width:100px;
  height:100px;
  border:2px solid black;
  margin:1px;
  padding:4px;
}

.imgBlock img{
  max-height:100%;
  max-width:100%;
  margin:auto;
  display:block;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="container">
  <div class="imgBlock">
    <img src="https://cdn.shopify.com/s/files/1/1150/2512/t/41/assets/WG-logo-short-black.png?43066">
  </div>
  <div class="imgBlock">
    <img src="https://cdn.shopify.com/s/files/1/1150/2512/t/41/assets/M1-Grill-FAQ.jpg?43066">
  </div>
</div></code>```

答:
You can add display: flex to imgBlock, then center horizontally with justify-content and vertically with align-items.

.imgBlock {
  display: flex;
  align-items: center;
  justify-content: center;

  width:100px;
  height:100px;
  border:2px solid black;
  margin:1px;
  padding:4px;
}

.imgBlock img{
  max-height:100%;
  max-width:100%;
  margin:auto;
  display:block;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="container">
  <div class="imgBlock">
    <img src="https://cdn.shopify.com/s/files/1/1150/2512/t/41/assets/WG-logo-short-black.png?43066">
  </div>
  <div class="imgBlock">
    <img src="https://cdn.shopify.com/s/files/1/1150/2512/t/41/assets/M1-Grill-FAQ.jpg?43066">
  </div>
</div></code>```

Body:
You can add display: flex to imgBlock, then center horizontally with justify-content and vertically with align-items.

.imgBlock {
  display: flex;
  align-items: center;
  justify-content: center;

  width:100px;
  height:100px;
  border:2px solid black;
  margin:1px;
  padding:4px;
}

.imgBlock img{
  max-height:100%;
  max-width:100%;
  margin:auto;
  display:block;
}

<div class="container">
  <div class="imgBlock">
    <img src="https://cdn.shopify.com/s/files/1/1150/2512/t/41/assets/WG-logo-short-black.png?43066">
  </div>
  <div class="imgBlock">
    <img src="https://cdn.shopify.com/s/files/1/1150/2512/t/41/assets/M1-Grill-FAQ.jpg?43066">
  </div>
</div>


问:
AJAX - OnSubmit Problem
I am fairly new to AJAX so please forgive me.

I have to forms - the fist one works but the second does not and I don't know why. The fist html form does not have submit button but the second does. They both use the same javascript function.

```<code><script type="text/javascript">
function showUser(str)
{
if (str=="")
 {
 document.getElementById("txtHint").innerHTML="";
 return;
 }
if (window.XMLHttpRequest)
 {// code for IE7+, Firefox, Chrome, Opera, Safari
 xmlhttp=new XMLHttpRequest();
 }
else
 {// code for IE6, IE5
 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
 }
xmlhttp.onreadystatechange=function()
 {
 if (xmlhttp.readyState==4 && xmlhttp.status==200)
   {
   document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
   }
 }
xmlhttp.open("GET","server_script.php?q="+str,true);
xmlhttp.send();
}
</script>
</code>```

From 1:

```<code><form>
<select name="users" onchange="showUser(this.value)">
<option value="0001">0001</option>
</code>```

0002

   Person info will be listed here.

From 2:

```<code><form onsubmit="showUser(this.foo.value)">
<input type="foo" >
<input type="submit" >
</form>
<br />
<div id="txtHint"><b>Person info will be listed here.</b></div>
</code>```

答:
On the first one your ajax is firing onchange, as such there is no default behaviour that is going to interfere with that.

On the second form you are using the onsubmit event, which has the default behaviour of posting back the form to the server. So you have to return false or preventdefault on that event to allow your ajax code to complete. The easiest fix would be to simply add a return false:

```<code><form onsubmit="showUser(this.foo.value); return false;">
</code>```

Title: AJAX - OnSubmit Problem

Body:
I am fairly new to AJAX so please forgive me.

I have to forms - the fist one works but the second does not and I don't know why. The fist html form does not have submit button but the second does. They both use the same javascript function.

From 1:

<form>
<select name="users" onchange="showUser(this.value)">
<option value="0001">0001</option>

0002

   Person info will be listed here.

From 2:

<form onsubmit="showUser(this.foo.value)">
<input type="foo" >
<input type="submit" >
</form>

Person info will be listed here.

Body:
On the first one your ajax is firing onchange, as such there is no default behaviour that is going to interfere with that.

On the second form you are using the onsubmit event, which has the default behaviour of posting back the form to the server. So you have to return false or preventdefault on that event to allow your ajax code to complete. The easiest fix would be to simply add a return false:

<form onsubmit="showUser(this.foo.value); return false;">


问:
How do I change the default path of IIS Express?
Simply, how do I change the default path which IIS Express uses to write files too, etc.
It's currently set to C:\Program Files (x86)\IIS Express.

Note: I'm using Visual Studio 2019.

Code snippet:

```<code>System.IO.File.WriteAllText(@"file1.txt", "Test!");
</code>```

答:
Please try https://learn.microsoft.com/en-us/dotnet/api/system.io.directory.setcurrentdirectory?view=netcore-2.2</p>

```<code> public static void Main()
    {
    // Create string for a directory. This value should be an existing directory
    // or the sample will throw a DirectoryNotFoundException.
      string dir = @"C:\test";
      try
      {
          //Set the current directory.
          Directory.SetCurrentDirectory(dir);
      }
      catch (DirectoryNotFoundException e)
      {
          Console.WriteLine("The specified directory does not exist. {0}", e);
      }
    // Print to console the results.
      Console.WriteLine("Root directory: {0}", Directory.GetDirectoryRoot(dir));
      Console.WriteLine("Current directory: {0}", Directory.GetCurrentDirectory());
}
</code>```

Body:
Simply, how do I change the default path which IIS Express uses to write files too, etc.
It's currently set to C:\Program Files (x86)\IIS Express.

Note: I'm using Visual Studio 2019.

Code snippet:

System.IO.File.WriteAllText(@"file1.txt", "Test!");

Body:
Please try https://learn.microsoft.com/en-us/dotnet/api/system.io.directory.setcurrentdirectory?view=netcore-2.2

 public static void Main()
    {
    // Create string for a directory. This value should be an existing directory
    // or the sample will throw a DirectoryNotFoundException.
      string dir = @"C:\test";
      try
      {
          //Set the current directory.
          Directory.SetCurrentDirectory(dir);
      }
      catch (DirectoryNotFoundException e)
      {
          Console.WriteLine("The specified directory does not exist. {0}", e);
      }
    // Print to console the results.
      Console.WriteLine("Root directory: {0}", Directory.GetDirectoryRoot(dir));
      Console.WriteLine("Current directory: {0}", Directory.GetCurrentDirectory());
}


问:
No provider for AngularFireAuth
I am using Ionic4 and @angular/fire to code an chat application, but I'm getting a white page and error message(F12) when I run my application.
Can someone help me ?

thank you.

app.module.ts

import { firebaseConfig } from '../environments/environment';

import { AngularFireModule } from '@angular/fire';
import { AngularFireAuthModule, AngularFireAuth } from '@Angular/fire/auth';
import { AngularFireDatabaseModule } from '@angular/fire/database';
// import { AngularFirestore } from '@angular/fire/firestore';
import { HttpClient } from '@angular/common/http';

@NgModule({
  declarations: [AppComponent],
  entryComponents: [],
  imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule,
    AngularFireModule.initializeApp(firebaseConfig),
    AngularFireAuthModule,
    AngularFireDatabaseModule, ],
  providers: [
    StatusBar,
    AngularFireModule,
    AngularFireAuthModule,
    AngularFireAuth

ERROR (F12) with Chrome

```

When I go to the home page it works, it is only when i go to my login page

thanks alot to those who will help me

答: The error I made was in the thrid line, it is not @Angular but @angular. after changing that, everything work fine</p>

Title: No provider for AngularFireAuth

Body:
I am using Ionic4 and @angular/fire to code an chat application, but I'm getting a white page and error message(F12) when I run my application.
Can someone help me ?

thank you.

app.module.ts

import { firebaseConfig } from '../environments/environment';

import { AngularFireModule } from '@angular/fire';
import { AngularFireAuthModule, AngularFireAuth } from '@Angular/fire/auth';
import { AngularFireDatabaseModule } from '@angular/fire/database';
// import { AngularFirestore } from '@angular/fire/firestore';
import { HttpClient } from '@angular/common/http';

@NgModule({
  declarations: [AppComponent],
  entryComponents: [],
  imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule,
    AngularFireModule.initializeApp(firebaseConfig),
    AngularFireAuthModule,
    AngularFireDatabaseModule, ],
  providers: [
    StatusBar,
    AngularFireModule,
    AngularFireAuthModule,
    AngularFireAuth

ERROR (F12) with Chrome

When I go to the home page it works, it is only when i go to my login page

thanks alot to those who will help me


问:
Getting Last Modified by Name of xlsx file
I have an excel file that gets modified by a group of people and we need to keep track of when the file was last modified and by whom

I was able to retrieve the file properties through .properties but trying to figure out how to isolate the lastModifiedby and insert its value in to a column

```<code>from openpyxl import load_workbook
wb = load_workbook('Rec1.xlsx')
wb.properties.lastModifiedBy
</code>```

It gets me the information I need but I am stumped on how to create a new column "lastmodifiedby" with the information provided in properties

答:
is this what you are looking for??</p>

```<code>Dim lastModifiedBy
lastModifiedBy = ThisWorkbook.BuiltinDocumentProperties("Last Author")
</code>```

Body:
I have an excel file that gets modified by a group of people and we need to keep track of when the file was last modified and by whom

I was able to retrieve the file properties through .properties but trying to figure out how to isolate the lastModifiedby and insert its value in to a column

from openpyxl import load_workbook
wb = load_workbook('Rec1.xlsx')
wb.properties.lastModifiedBy

It gets me the information I need but I am stumped on how to create a new column "lastmodifiedby" with the information provided in properties

Body:
is this what you are looking for??

Dim lastModifiedBy
lastModifiedBy = ThisWorkbook.BuiltinDocumentProperties("Last Author")


问:
How do I display Django ManyToMany on a template? Simple code needed
I am trying to display ManyToMany field on the template in reversed order.

Here is what I mean:

I managed to display ManyToMany field on template when ManyToMany field was a field in model used so for example:

```<code><br/>{% for tag in post.tag.all %}{{ tag }}<br/>{% endfor %}
</code>```

will display all of the tags(meaning categories) that the post belongs to based on this model:

```<code>class Post(models.Model):
tag = models.ManyToManyField(Tag,blank=True,null=True,related_name='tag')
</code>```

Now I want something opposite - display authors of the post when ManyToMany field is in the Author model (Post model above stays the same):

```<code>class Person(models.Model):
post=models.ManyToManyField(Post,blank=True,null=True,related_name='post')

</code>```

I am quite sure it has something to do with Related Object Reference ( https://docs.djangoproject.com/en/2.2/ref/models/relations/)

Just can not make it work.

I have tried the following on the template.

```<code>{% for post in posts %}
{% for author in post.person_set.all %}{{author}}<br/>{% endfor %}
{% endfor %}

</code>```

Also, shall I do this kind of searches on the template like above or is it a better practice put this kind of searches in views...resourcewise.

Thanks for help.

答:
You have a misunderstanding on what the related_name= parameter [Django-doc] does. Like the documentation says:

The name to use for the relation from the related object back to this one. (...)

So it is the name of the relation in reverse. In order to make your models "sound", you thus should name it like:

```<code>class Person(models.Model):
    <b>posts</b> = models.ManyToManyField(Post, blank=True, null=True, <b>related_name='authors'</b>)</code>```

It also makes sense here to use the plural, so posts instead of post.

In that case, you thus can render this with:

```<code>{% for post in posts %}
    {% for author in post.<b>authors</b>.all %}{{author}}<br/>{% endfor %}
{% endfor %}</code>```

Note that if you want to render all the values for ManyToManyFields, you better use .prefetch_related(..) in the queryset to prefetch the Person,s otherwise rendering the template will result in a lot of extra queries.

Body:
I am trying to display ManyToMany field on the template in reversed order.

Here is what I mean:

I managed to display ManyToMany field on template when ManyToMany field was a field in model used so for example:

{% for tag in post.tag.all %}{{ tag }}
{% endfor %}

will display all of the tags(meaning categories) that the post belongs to based on this model:

class Post(models.Model):
tag = models.ManyToManyField(Tag,blank=True,null=True,related_name='tag')

Now I want something opposite - display authors of the post when ManyToMany field is in the Author model (Post model above stays the same):

class Person(models.Model):
post=models.ManyToManyField(Post,blank=True,null=True,related_name='post')

I am quite sure it has something to do with Related Object Reference ( https://docs.djangoproject.com/en/2.2/ref/models/relations/)

Just can not make it work.

I have tried the following on the template.

{% for post in posts %}
{% for author in post.person_set.all %}{{author}}
{% endfor %}
{% endfor %}

Also, shall I do this kind of searches on the template like above or is it a better practice put this kind of searches in views...resourcewise.

Thanks for help.

Body:
You have a misunderstanding on what the related_name= parameter [Django-doc] does. Like the documentation says:

The name to use for the relation from the related object back to this one. (...)

So it is the name of the relation in reverse. In order to make your models "sound", you thus should name it like:

class Person(models.Model):
    posts = models.ManyToManyField(Post, blank=True, null=True, related_name='authors')

It also makes sense here to use the plural, so posts instead of post.

In that case, you thus can render this with:

{% for post in posts %}
    {% for author in post.authors.all %}{{author}}<br/>{% endfor %}
{% endfor %}

Note that if you want to render all the values for ManyToManyFields, you better use .prefetch_related(..) in the queryset to prefetch the Person,s otherwise rendering the template will result in a lot of extra queries.


问:
Angular Service for particular NgModule
I'm following the Angular Documentation and trying to provide a service (OrderService) to a particular module (OrdersModule). After importing the service to a component (OrderListComponent), I'm getting an error. Could somebody tell me, what I'm doing wrong here?

Here is a link to my stackblitz code.

order.service.ts

```<code>import { Injectable } from '@angular/core';
import { OrdersModule } from './orders.module';

@Injectable({
  providedIn: OrdersModule
})
export class OrderService {
  constructor() {
  }

  ...
}
</code>```

order-list.component.ts

```<code>import { Component, OnInit } from '@angular/core';
import { OrderService } from '../order.service';

@Component({
  selector: 'order-list',
  templateUrl: './order-list.component.html',
  styleUrls: [ './order-list.component.css' ]
})
export class OrderListComponent implements OnInit {
  ...

  constructor(private orderService: OrderService) {
    ...
  }

  ...
}
</code>```

I'm getting following error:

```<code>Error: Uncaught (in promise):
Error: StaticInjectorError(AppModule)[OrderListComponent -> OrderService]:
StaticInjectorError(Platform: core)[OrderListComponent -> OrderService]:
NullInjectorError: No provider for OrderService!
</code>```

答:
You should add OrderService into the providers array of OrdersModule.
Here is a guide how to use providedIn and service.
https://angular.io/guide/providers#providedin-and-ngmodules

Title: Angular Service for particular NgModule

Body:
I'm following the Angular Documentation and trying to provide a service (OrderService) to a particular module (OrdersModule). After importing the service to a component (OrderListComponent), I'm getting an error. Could somebody tell me, what I'm doing wrong here?

Here is a link to my stackblitz code.

order.service.ts

import { Injectable } from '@angular/core';
import { OrdersModule } from './orders.module';

@Injectable({
  providedIn: OrdersModule
})
export class OrderService {
  constructor() {
  }

  ...
}

order-list.component.ts

import { Component, OnInit } from '@angular/core';
import { OrderService } from '../order.service';

@Component({
  selector: 'order-list',
  templateUrl: './order-list.component.html',
  styleUrls: [ './order-list.component.css' ]
})
export class OrderListComponent implements OnInit {
  ...

  constructor(private orderService: OrderService) {
    ...
  }

  ...
}

I'm getting following error:

Error: Uncaught (in promise):
Error: StaticInjectorError(AppModule)[OrderListComponent -> OrderService]:
StaticInjectorError(Platform: core)[OrderListComponent -> OrderService]:
NullInjectorError: No provider for OrderService!


问:
How to display multiple widgets on the same page using MVC
I'm a bit confused about how MVC works and I can't find anything but basic examples.

I want to make a kind of widget-based design; you can choose various widgets to go on your page.  Each widget should be responsible for itself - it should have a controller and a view.   But what about the main page?  Suddenly I've got a page with lots of controllers on it!

The obvious thing to do is to embed the controllers in the view somehow... This is my widget {SomeWidget} but I've read that "breaks the MVC paradigm".

Some widgets will need to POST to different urls (like a search box goes to the result page) and some will need to POST back to the same URL (like adding a comment to an article brings you back to the article).

To top things off, the user should be able to edit the HTML around the widget - for example if they want a search box on the right, they can type
{SearchController}
 (in my paradigm-breaking world)

答:
I think JarrettV's and jcoby's answers are closest.

I've come to know subcontrollers as Hierarchical MCV (HMVC). The idea is that you "pull" content (a view populated by a subcontroller) from the parent view template instead of "pushing" data to the template from the controller. So instead of needing to edit both the controller and view to add a widget, you just call the widget from the view. There are libraries to accomplish this in the php frameworks CodeIgniter (Modular Extensions) and Kohana (Dispatch, and Component).

OwnerDisplayName: RoBorg

OwnerDisplayName: rick


问:
LINQ to DataSet - Joins and GridView Issues
I've got three DataTables that I need to join together, and use the joined data as the DataSource for a GridView.  The first (localSQLTable) is populated via a query against an MS-SQL database.  The second two (serviceResponse.Tables(0) and serviceResponse.Tables(1) ) are built using DataSet.ReadXML from the results of a web service.

I've gotten this far:

```<code>Dim joinedData = From f In localSQLTable _
                 Join s1 As DataRow In serviceResponse.Tables(0) _
                 On f.Item("KNum") Equals s1.Item("Number") _
                 Join s2 As DataRow In serviceResponse.Tables(1) _
                 On s1.Item("KNumber_Id") Equals s2.Item("KNumber_Id") _
                 Select Guid = f.Item("Guid"), Num = f.Item("Num"), Desc = f.Item("Desc"), KNum = f.Item("KNum"), KDesc = s2.Item("KDescription_Text"), Type = s2.Item("Type") _
                 Where (Type.ToString.ToUpper = "LONG_HTML")

myGridView.DataSource = joinedData
myGridView.DataBind()
</code>```

However, it seemed joinedData is just an IEnumerable (of anonymous type).  I've tried a few things, including the following:

Attempting to build joinedData as an IEnumerable(Of DataRow) using a lambda function (of which I am not familiar at all) to build the new DataRow

Calling .ToList() or .AsEnumerable() (after toying with types) on the result set

The main issue is that no matter what I seem to try, there's something wrong with using the results as the DataSource for my GridView - I got one of the two exceptions:

The data source for GridView with id  did not have any properties or attributes from which to generate columns. Ensure that your data source has content.

The data source does not support server-side data paging.

I also know I probably shouldn't be using .Item ("Field") instead of the strongly-typed .Field (Of T)("Field") in my Linq query - I was waiting on that change until I've got the data actually usable.

I'm not married to Linq; if DataSet.Merge is more appropriate (or some other methodology), I'll entertain it.  There's also a distinct possibility that I'll actually have to join what I have to another two DataTables later.  If that's the case, I'll likely merge the serviceResponse tables into one, so I'll still only be joining three tables.

So what can I do to join this data together and use the result as my GridView's DataSource?  And is anything I'm doing going to be any faster than just tacking on two extra columns in my original DataTable (localSQLTable) and filling them row-by-row using the XML response data?

答:
The end result of all of this is the following:

```<code>Dim joinedData As Generic.IEnumerable(Of DataRow) = (From f In localSQLTable.AsEnumerable() _
                                                     Join h In serviceResponse.Tables(0).AsEnumerable() _
                                                     On h.Item("serviceknum") Equals f.Item("knum") _
                                                     Select GetFinalDataRow(finalTable, f, h))

gvGridOne.DataSource = joinedData.CopyToDataTable()
gvGridOne.DataBind()
</code>```

I explicitly defined the DataTable and schema (by adding DataColumns) of the ending DataTable I need, then passed that DataTable and the two DataRows in my join to GetFinalDataRow(), defined as:

```<code>Public Function GetFinalDataRow(ByRef FinalTable As DataTable, ByVal Row1 As DataRow, ByVal Row2 As DataRow) As DataRow
    Dim newRow As DataRow = FinalTable.NewRow()
    For Each col As DataColumn In FinalTable.Columns
        If Row1.Table.Columns.Contains(col.ColumnName) Then
            newRow(col.ColumnName) = Row1.Item(col.ColumnName)
        ElseIf Row2.Table.Columns.Contains(col.ColumnName) Then
            newRow(col.ColumnName) = Row2.Item(col.ColumnName)
        Else
            newRow(col.ColumnName) = ""
        End If
    Next

    Return newRow
End Function
</code>```

My joinedData object is now an IEnumerable of DataRows, and I can copy that to a DataTable for my GridView's datasource, and it will auto generate columns and allow paging.

Body:
I've got three DataTables that I need to join together, and use the joined data as the DataSource for a GridView.  The first (localSQLTable) is populated via a query against an MS-SQL database.  The second two (serviceResponse.Tables(0) and serviceResponse.Tables(1) ) are built using DataSet.ReadXML from the results of a web service.

I've gotten this far:

Dim joinedData = From f In localSQLTable _
                 Join s1 As DataRow In serviceResponse.Tables(0) _
                 On f.Item("KNum") Equals s1.Item("Number") _
                 Join s2 As DataRow In serviceResponse.Tables(1) _
                 On s1.Item("KNumber_Id") Equals s2.Item("KNumber_Id") _
                 Select Guid = f.Item("Guid"), Num = f.Item("Num"), Desc = f.Item("Desc"), KNum = f.Item("KNum"), KDesc = s2.Item("KDescription_Text"), Type = s2.Item("Type") _
                 Where (Type.ToString.ToUpper = "LONG_HTML")

myGridView.DataSource = joinedData
myGridView.DataBind()

However, it seemed joinedData is just an IEnumerable (of anonymous type).  I've tried a few things, including the following:

Attempting to build joinedData as an IEnumerable(Of DataRow) using a lambda function (of which I am not familiar at all) to build the new DataRow

Calling .ToList() or .AsEnumerable() (after toying with types) on the result set

The main issue is that no matter what I seem to try, there's something wrong with using the results as the DataSource for my GridView - I got one of the two exceptions:

The data source for GridView with id  did not have any properties or attributes from which to generate columns. Ensure that your data source has content.

The data source does not support server-side data paging.

I also know I probably shouldn't be using .Item ("Field") instead of the strongly-typed .Field (Of T)("Field") in my Linq query - I was waiting on that change until I've got the data actually usable.

I'm not married to Linq; if DataSet.Merge is more appropriate (or some other methodology), I'll entertain it.  There's also a distinct possibility that I'll actually have to join what I have to another two DataTables later.  If that's the case, I'll likely merge the serviceResponse tables into one, so I'll still only be joining three tables.

So what can I do to join this data together and use the result as my GridView's DataSource?  And is anything I'm doing going to be any faster than just tacking on two extra columns in my original DataTable (localSQLTable) and filling them row-by-row using the XML response data?

Body:
The end result of all of this is the following:

Dim joinedData As Generic.IEnumerable(Of DataRow) = (From f In localSQLTable.AsEnumerable() _
                                                     Join h In serviceResponse.Tables(0).AsEnumerable() _
                                                     On h.Item("serviceknum") Equals f.Item("knum") _
                                                     Select GetFinalDataRow(finalTable, f, h))

gvGridOne.DataSource = joinedData.CopyToDataTable()
gvGridOne.DataBind()

I explicitly defined the DataTable and schema (by adding DataColumns) of the ending DataTable I need, then passed that DataTable and the two DataRows in my join to GetFinalDataRow(), defined as:

Public Function GetFinalDataRow(ByRef FinalTable As DataTable, ByVal Row1 As DataRow, ByVal Row2 As DataRow) As DataRow
    Dim newRow As DataRow = FinalTable.NewRow()
    For Each col As DataColumn In FinalTable.Columns
        If Row1.Table.Columns.Contains(col.ColumnName) Then
            newRow(col.ColumnName) = Row1.Item(col.ColumnName)
        ElseIf Row2.Table.Columns.Contains(col.ColumnName) Then
            newRow(col.ColumnName) = Row2.Item(col.ColumnName)
        Else
            newRow(col.ColumnName) = ""
        End If
    Next

    Return newRow
End Function

My joinedData object is now an IEnumerable of DataRows, and I can copy that to a DataTable for my GridView's datasource, and it will auto generate columns and allow paging.