问:
ComboBox repeat the same value in DisplayMember and ValueMember
Hi i am trying to fill a combo box but the value member is the same as the displaymember
this is my code:

```<code>private void Form1_Load(object sender, EventArgs e)
            {
                refresh();

            }

            public void refresh()
            {
                using (var context = new AppDbContext())
                {
                    var piece = context.piece.Select(d => d.quantity);
                    comboBox1.DataSource = piece.ToList();
                    comboBox1.DisplayMember = "quantity";
                    comboBox1.ValueMember = "quantity";

                }

            }
</code>```

I receive this error message: system.argumentexception 'cannot bind to the new display member. parameter name newdisplaymember'

having only the DisplayMember and the valuemember as = "" I don't get any problem, but I need to show and save the same data, what is the problem with my code?

答: Have you tried to not set ValueMember? Maybe if you don't set that, the value will be the same as the display one.</p>

Body:
Hi i am trying to fill a combo box but the value member is the same as the displaymember
this is my code:

private void Form1_Load(object sender, EventArgs e)
            {
                refresh();

            }

            public void refresh()
            {
                using (var context = new AppDbContext())
                {
                    var piece = context.piece.Select(d => d.quantity);
                    comboBox1.DataSource = piece.ToList();
                    comboBox1.DisplayMember = "quantity";
                    comboBox1.ValueMember = "quantity";

                }

            }

I receive this error message: system.argumentexception 'cannot bind to the new display member. parameter name newdisplaymember'

having only the DisplayMember and the valuemember as = "" I don't get any problem, but I need to show and save the same data, what is the problem with my code?


来源: stackexchange

问:
cs50 substitution int x = plaintext[i] - 'a';
I was trying to do substitution from cs50 pset2 on two loops but I had some issues.

I found one loop solution here: free(): invalid pointer Aborted (core dumped) cs50

But now I don't really understand this part:

```<code>int x = plaintext[i] - 'a';
</code>```

If plaintext[i] is 'm', 'm' is 109 in ASCII, and 'a' is 97, so m-a == 12, form feed in ascii. Or it's not an ASCII substraction going on?

答:
Look at the next line:

```<code>printf("%c", tolower(key[x]));
</code>```

x is used as an index into the key array.

ContentLicense: CC BY-SA 4.0

Body:
I was trying to do substitution from cs50 pset2 on two loops but I had some issues.

I found one loop solution here: free(): invalid pointer Aborted (core dumped) cs50

But now I don't really understand this part:

int x = plaintext[i] - 'a';

If plaintext[i] is 'm', 'm' is 109 in ASCII, and 'a' is 97, so m-a == 12, form feed in ascii. Or it's not an ASCII substraction going on?

Body:
Look at the next line:

printf("%c", tolower(key[x]));

x is used as an index into the key array.


问:
Unable to import python module from subdirectory
My structrue

```<code>/api/__init__.py
/api/api.py
/database_access/__init__.py
/database_access/databaseaccess.py
/database_access/models/__init__.py
/database_access/models/manufacturer.py
</code>```

manufacturer.py

```<code>class Manufacturer:
    # methods here
</code>```

And databaseaccess.py

```<code>import pymongo
from models import manufacturer # <-- unable to import 'models'

myclient = pymongo.MongoClient("mongodb://localhost:27017/")

computer_parts_database = myclient["computer_parts"]
part_types = computer_parts_database["manufacturers"]
parts = computer_parts_database["parts"]

class DatabaseAccess:
    manufacturers = computer_parts_database["manufacturers"]

da = DatabaseAccess()
#mf = Manufacturer.init2(1, "Advanced Micro Devices", "AMD")
#da.manufacturers.insert_one(mf.toObject())
</code>```

I'm unable to get the manufacturer module to load. The same happens with import models and import models.manufacturer

I get the same problem in api.py, if I want to access the databaseaccess module I'm not sure how

答:
If you aren't using PyCharm (or something like that), but instead of them the simple python 32-bit or 64-bit:
Go to Command prompt and write "pip install _____". _____ stands for the name of the module you are trying to install.
If you are using PyCharm:
Go to "File" (up, left) and click on it. Then press on settings. After that a new window will appear with some buttons on the left side. Click on the triangle of the button with the name of your project. Then there will be two buttons. Press on Project interpreter. There you will find the names of all your modules that are (in your case will) (and some others) already installed in your project. Press on the + (up, right) and then you have to write the name if the module you are needing. Click on it and then press on the install button (down, left). Wait for it to install and then you can use it. You will have to do this every time you start a new project.
If you are using something else in Python:
Good Luck, as I don't know the answer.

Without doing this it won't work (what you are trying to do).
Hope you understand everything

Body:
My structrue

/api/__init__.py
/api/api.py
/database_access/__init__.py
/database_access/databaseaccess.py
/database_access/models/__init__.py
/database_access/models/manufacturer.py

manufacturer.py

class Manufacturer:
    # methods here

And databaseaccess.py

import pymongo
from models import manufacturer # <-- unable to import 'models'

myclient = pymongo.MongoClient("mongodb://localhost:27017/")

computer_parts_database = myclient["computer_parts"]
part_types = computer_parts_database["manufacturers"]
parts = computer_parts_database["parts"]

class DatabaseAccess:
    manufacturers = computer_parts_database["manufacturers"]

da = DatabaseAccess()
#mf = Manufacturer.init2(1, "Advanced Micro Devices", "AMD")
#da.manufacturers.insert_one(mf.toObject())

I'm unable to get the manufacturer module to load. The same happens with import models and import models.manufacturer

I get the same problem in api.py, if I want to access the databaseaccess module I'm not sure how


答:
When you have more than two classes you cannot use binary crossentropy. Change your loss function to categorical crossentropy and set your output layer to have three neurons (one for each class)

```<code>model = Sequential()
model.add(Embedding(max_words, 30, input_length=max_len))
model.add(BatchNormalization())
model.add(Activation('tanh'))
model.add(Dropout(0.3))
model.add(Bidirectional(LSTM(32)))
model.add(BatchNormalization())
model.add(Activation('tanh'))
model.add(Dropout(0.5))
model.add(Dense(3, activation='softmax'))

model.compile(optimizer='adam',
              loss='sparse_categorical_crossentropy',
              metrics=['accuracy'])
</code>```

Anyway, from your training curves, I can see that the network is overfitting. It may be because of your data or because of your network. Check this post to know more about overfitting in deep learning models.

This is the plot of the learning curve of your model. It shows a classical overfitting behaviour.

Title: Validation loss having a sinusoidal wave form

Body:
I am training an LSTM model on the SemEval 2017 task 4A dataset (classification problem with 3 classes). I observe that first validation loss decreases but then suddenly increases by a significant amount and again decreases. It is showing a sinusoidal nature which can be observed from the below training epochs.

Here is the code of my model

model = Sequential()
model.add(Embedding(max_words, 30, input_length=max_len))
model.add(Activation('tanh'))
model.add(Dropout(0.3))
model.add(Bidirectional(LSTM(32)))
model.add(Activation('tanh'))
model.add(Dropout(0.5))
model.add(Dense(3, activation='sigmoid'))
model.summary()

And here is the model summary

Model: "sequential_2"
_________________________________________________________________
Layer (type)                 Output Shape              Param #
=================================================================
embedding_2 (Embedding)      (None, 300, 30)           60000
_________________________________________________________________
batch_normalization_3 (Batch (None, 300, 30)           120
_________________________________________________________________
activation_3 (Activation)    (None, 300, 30)           0
_________________________________________________________________
dropout_3 (Dropout)          (None, 300, 30)           0
_________________________________________________________________
bidirectional_2 (Bidirection (None, 64)                16128
_________________________________________________________________
batch_normalization_4 (Batch (None, 64)                256
_________________________________________________________________
activation_4 (Activation)    (None, 64)                0
_________________________________________________________________
dropout_4 (Dropout)          (None, 64)                0
_________________________________________________________________
dense_2 (Dense)              (None, 1)                 65
=================================================================
Total params: 76,569
Trainable params: 76,381
Non-trainable params: 188

I am using GloVe for word embeddings, Adam optimizer, Categorical Crossentropy loss function.

After changing the loss function and Dense layer, here is the training phase.

       Train on 16711 samples, validate on 1857 samples
Epoch 1/5
16711/16711 [==============================] - 55s 3ms/step - loss: 0.5976 - accuracy: 0.7456 - val_loss: 0.9060 - val_accuracy: 0.6182
Epoch 2/5
16711/16711 [==============================] - 54s 3ms/step - loss: 0.5872 - accuracy: 0.7521 - val_loss: 0.8919 - val_accuracy: 0.6144
Epoch 3/5
16711/16711 [==============================] - 54s 3ms/step - loss: 0.5839 - accuracy: 0.7518 - val_loss: 0.9067 - val_accuracy: 0.6187
Epoch 4/5
16711/16711 [==============================] - 54s 3ms/step - loss: 0.5766 - accuracy: 0.7554 - val_loss: 0.9437 - val_accuracy: 0.6268
Epoch 5/5
16711/16711 [==============================] - 54s 3ms/step - loss: 0.5742 - accuracy: 0.7544 - val_loss: 0.9272 - val_accuracy: 0.6166

Testing phase

 accr = model.evaluate(test_sequences_matrix, Y_test)
    2064/2064 [==============================] - 2s 1ms/step

print('Test set\n  Loss: {:0.3f}\n  Accuracy: {:0.3f}'.format(accr[0],accr[1]))
Test set
  Loss: 0.863
  Accuracy: 0.649

Confusion matrix

Confusion Matrix :
[[517 357 165]
 [379 246 108]
 [161  88  43]]
Accuracy Score : 0.3905038759689923

Classification report

              precision    recall  f1-score   support

           0       0.49      0.50      0.49      1039
           1       0.36      0.34      0.35       733
           2       0.14      0.15      0.14       292

    accuracy                           0.39      2064
   macro avg       0.33      0.33      0.33      2064
weighted avg       0.39      0.39      0.39      2064

Confusion matrix code (I have imported from sklearn.metrics import confusion_matrix, accuracy_score, classification_report)

results = confusion_matrix(doc_test.response, Y_test)

print('Confusion Matrix :')
print(results)
print('Accuracy Score :',accuracy_score(doc_test.response, Y_test))

Body:
When you have more than two classes you cannot use binary crossentropy. Change your loss function to categorical crossentropy and set your output layer to have three neurons (one for each class)

model = Sequential()
model.add(Embedding(max_words, 30, input_length=max_len))
model.add(BatchNormalization())
model.add(Activation('tanh'))
model.add(Dropout(0.3))
model.add(Bidirectional(LSTM(32)))
model.add(BatchNormalization())
model.add(Activation('tanh'))
model.add(Dropout(0.5))
model.add(Dense(3, activation='softmax'))

model.compile(optimizer='adam',
              loss='sparse_categorical_crossentropy',
              metrics=['accuracy'])

Anyway, from your training curves, I can see that the network is overfitting. It may be because of your data or because of your network. Check this post to know more about overfitting in deep learning models.

This is the plot of the learning curve of your model. It shows a classical overfitting behaviour.


问:
Difference between two lists
I Have two generic list filled with CustomsObjects.

I need to retrieve the difference between those two lists(Items who are in the first without the items in the second one)  in a third one.

I was thinking using .Except() was a good idea but I don't see how to use this..
Help!

答:
here is my solution:</p>

```<code>    List<String> list1 = new List<String>();

    List<String> list2 = new List<String>();

    List<String> exceptValue = new List<String>();

foreach(String L1 in List1)
{
    if(!List2.Contains(L1)
    {
         exceptValue.Add(L1);
    }
}
foreach(String L2 in List2)
{
    if(!List1.Contains(L2)
    {
         exceptValue.Add(L2);
    }
}
</code>```

ContentLicense: CC BY-SA 3.0

Title: Difference between two lists

Body:
here is my solution:

    List<String> list1 = new List<String>();

    List<String> list2 = new List<String>();

    List<String> exceptValue = new List<String>();

foreach(String L1 in List1)
{
    if(!List2.Contains(L1)
    {
         exceptValue.Add(L1);
    }
}
foreach(String L2 in List2)
{
    if(!List1.Contains(L2)
    {
         exceptValue.Add(L2);
    }
}


问:
jQuery - clone() is not a function
I'm trying to copy some of my elements from this block and paste them in the end:

```<code><div class="brands">
    <img src="brand1.png" alt="1" />
    <img src="brand2.png" alt="2" />
    <img src="brand3.png" alt="3" />
</div>
</code>```

That's what I'm doing:

```<code>for (var i = 0; i < 2; i++) {
    $('.brands img')[i].clone().appendTo('.brands');
}
</code>```

But then I see this in console: TypeError: $(...)[i].clone is not a function, jQuery is uncluded. What's wrong with my code?

答:
You don't need the loop. https://api.jquery.com/slice/

```<code>$('.brands img').slice(0, 2).clone().appendTo('.brands');
</code>```

The issue you were having is that once you extract the native Element by using [index] or .get(index) out of the $() function you loose jQuery Object methods chainability.

Title: jQuery - clone() is not a function

Body:
I'm trying to copy some of my elements from this block and paste them in the end:

That's what I'm doing:

for (var i = 0; i < 2; i++) {
    $('.brands img')[i].clone().appendTo('.brands');
}

But then I see this in console: TypeError: $(...)[i].clone is not a function, jQuery is uncluded. What's wrong with my code?

Body:
You don't need the loop. https://api.jquery.com/slice/

$('.brands img').slice(0, 2).clone().appendTo('.brands');

The issue you were having is that once you extract the native Element by using [index] or .get(index) out of the $() function you loose jQuery Object methods chainability.


问:
Bootstrap Carousal is not working in my code
I'm learning bootstrap these days. I am developing  a main page. But the carousal is not working. Please check the code and tell me which thing i'm missing in my code. I am just copy pasting the code of carousal from w3school. I don't know where i am missing. It'll be great if somebody can help me in this.</p>

```<code>    <!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <title>Bootstrap 101 Template</title>

    <!-- Bootstrap -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="index.css" rel="stylesheet">

  </head>
  <body>

   <!-- Image and text -->
<nav class="navbar navbar-light bg-light">
  <a class="navbar-brand" href="#">
    <img src="Solupo_h.png" width="500" height="180" class="d-inline-block align-top" id="header" alt="top header" loading="lazy" >
    </a>
</nav>

<div id="ct">
  <div class="corner "id="left_top"></div>
  <div class="corner" id="left_bottom"></div>
  <div class="corner" id="right_top"></div>
  <div class="corner" id="right_bottom"></div>
  <span>Winston Churchill</span>
  <blockquote>
    <p><i>“Success consists of going from failure to failure without loss of enthusiasm.” </i></p>
  </blockquote>
</div>

<div class="container">
  <div id="demo" class="carousel slide" data-ride="carousel">

    <!-- Indicators -->
    <ul class="carousel-indicators">
      <li data-target="#demo" data-slide-to="0" class="active"></li>
      <li data-target="#demo" data-slide-to="1"></li>
      <li data-target="#demo" data-slide-to="2"></li>
    </ul>

    <!-- The slideshow -->
    <div class="carousel-inner">
      <div class="carousel-item active">
        <img src="654-500x3002.jpg" alt="Los Angeles">
      </div>
      <div class="carousel-item">
        <img src="654-500x3002.jpg" alt="Chicago">
      </div>
      <div class="carousel-item">
        <img src="654-500x3002.jpg" alt="New York">
      </div>
    </div>

    <!-- Left and right controls -->
    <a class="carousel-control-prev" href="#demo" data-slide="prev">
      <span class="carousel-control-prev-icon"></span>
    </a>
    <a class="carousel-control-next" href="#demo" data-slide="next">
      <span class="carousel-control-next-icon"></span>
    </a>

  </div>
</div>

    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>
  </body>
</html>
</code>```

答:
You may not have downloaded the bootstrap stylesheet or javascript assets. The code is fine since you mentioned that you copy pasted the code directly from w3schools.

You need the following files downloaded and added to your folder:

css/bootstrap.min.css
js/bootstrap.min.js

OR

You can just paste the following in your  tag:

```<code><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</code>```

And you can add the following at the end of your  tag:

```<code><script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</code>```

Hope that helps!

Body:
I'm learning bootstrap these days. I am developing  a main page. But the carousal is not working. Please check the code and tell me which thing i'm missing in my code. I am just copy pasting the code of carousal from w3school. I don't know where i am missing. It'll be great if somebody can help me in this.

    <!DOCTYPE html>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Bootstrap 101 Template</title>

    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="index.css" rel="stylesheet">

  Winston Churchill

“Success consists of going from failure to failure without loss of enthusiasm.”

Body:
You may not have downloaded the bootstrap stylesheet or javascript assets. The code is fine since you mentioned that you copy pasted the code directly from w3schools.

You need the following files downloaded and added to your folder:

css/bootstrap.min.css
js/bootstrap.min.js

OR

You can just paste the following in your <head> tag:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

And you can add the following at the end of your <body> tag:

<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

Hope that helps!


问:
how can I reduce database hints in Django ORM?
I have some Models:

F ---> D ---> C <--- B ---> A

```<code>class A:
    -

class B:
    a = ForeignKey
    c = ForeignKey

class C:
    -

class D:
    c = ForeignKey

class F:
    d = ForeignKey
</code>```

and I'm using this query:

```<code>querset = B.objects.select_related('c').filter(a=a_instance)
</code>```

to show result in template:

```<code>{% for b in querset %}
    {% for d in b.c.d_set.all %}
        {% for f in d.f_set.all %}
        {% endfor %}
    {% endfor %}
{% endfor %}
</code>```

how can I reduce database hints?
is it ok to use Prefetch like this or am I wrong?

```<code>querset = B.objects.select_related(
        'c'
    ).prefetch_related(
        Prefetch('c__d_set__f_set')
    ).filter(
        a=a_instance
    )
</code>```

django = 2.2

thanks

答: One issue is that C doesn't have a field to point to D. So in your template, the line: {% for d in b.c.d_set.all %} will have performance issues with the reverse-lookup. I'd suggest something like this, which shows you how to cache the related fields from the reverse lookup, to optimize your queries.

Body:
I have some Models:

F ---> D ---> C <--- B ---> A

class A:
    -

class B:
    a = ForeignKey
    c = ForeignKey

class C:
    -

class D:
    c = ForeignKey

class F:
    d = ForeignKey

and I'm using this query:

querset = B.objects.select_related('c').filter(a=a_instance)

to show result in template:

{% for b in querset %}
    {% for d in b.c.d_set.all %}
        {% for f in d.f_set.all %}
        {% endfor %}
    {% endfor %}
{% endfor %}

how can I reduce database hints?
is it ok to use Prefetch like this or am I wrong?

querset = B.objects.select_related(
        'c'
    ).prefetch_related(
        Prefetch('c__d_set__f_set')
    ).filter(
        a=a_instance
    )

django = 2.2

thanks


问:
How to know the name of the fields of a list that is empty?
In a Sharepoint there is a SPList that I should check if a name of field exist. (If exist I add content, if not exist I do something else)

Now I'm doing that:

```<code>SPListItemCollection listItems = spList.GetItems();
SPFieldCollection spFieldCollection =listItems.Fields;
foreach (SPField field in spFieldCollection)
 {
     String name = field.Title;

     if (name == "nameField") {
         return true; // Exist
     }
 }
</code>```

that works ok, except if the list is empty. How can I check if a name of the field exist before add content to the list?

答:
Just check on the Fields property on the SPList:

```<code>SPFieldCollection fields = spList.Fields;
</code>```

Use the method ContainsField to check if a field exists:

```<code>return spList.Fields.ContainsField(fieldName);
</code>```

fieldName
  Type: System.String A string
  that contains either the display name
  or the internal name of the field.

SPFieldCollection.ContainsField Method

Body:
In a Sharepoint there is a SPList that I should check if a name of field exist. (If exist I add content, if not exist I do something else)

Now I'm doing that:

SPListItemCollection listItems = spList.GetItems();
SPFieldCollection spFieldCollection =listItems.Fields;
foreach (SPField field in spFieldCollection)
 {
     String name = field.Title;

     if (name == "nameField") {
         return true; // Exist
     }
 }

that works ok, except if the list is empty. How can I check if a name of the field exist before add content to the list?

Body:
Just check on the Fields property on the SPList:

SPFieldCollection fields = spList.Fields;

Use the method ContainsField to check if a field exists:

return spList.Fields.ContainsField(fieldName);

fieldName
  Type: System.String A string
  that contains either the display name
  or the internal name of the field.

SPFieldCollection.ContainsField Method


问:
Count values in a dict of lists and join keys and values names for the output using pandas
I need help getting some outputs from a dictionary (python3):

```<code>{'horse': ['brown', 'black'], 'duck': ['brown', 'black', 'brown', 'grey', 'brown']}
</code>```

Outputs required:

```<code>black horse: 1
brown horse: 1
grey horse: 0
black duck: 1
brown duck: 3
grey duck: 1
</code>```

Can someone offer a solution please?

答:
you can recursively tack on the string of the key to the desired result and keep a record of the unique solutions.

The pseudocode I would imagine using is the following:

```<code>def helper(dict, string_of_prior_keys = ""):
  list_of_strings = []
  for k in dict.keys():
    if type(dict[k]) is dict:
      list_of_strings += [helper(dict[k], k + string_of_prior_keys)]
    else:
      list_of_strings += [k + string_of_prior_keys]
  return list_of_strings
</code>```

Then all you need to do is count the unique strings in that returned list of strings. I hope this helps. If I'm not clear at any point, please let me know!

Body:
I need help getting some outputs from a dictionary (python3):

{'horse': ['brown', 'black'], 'duck': ['brown', 'black', 'brown', 'grey', 'brown']}

Outputs required:

black horse: 1
brown horse: 1
grey horse: 0
black duck: 1
brown duck: 3
grey duck: 1

Can someone offer a solution please?

Body:
you can recursively tack on the string of the key to the desired result and keep a record of the unique solutions.

The pseudocode I would imagine using is the following:

def helper(dict, string_of_prior_keys = ""):
  list_of_strings = []
  for k in dict.keys():
    if type(dict[k]) is dict:
      list_of_strings += [helper(dict[k], k + string_of_prior_keys)]
    else:
      list_of_strings += [k + string_of_prior_keys]
  return list_of_strings

Then all you need to do is count the unique strings in that returned list of strings. I hope this helps. If I'm not clear at any point, please let me know!


问:
change the mysql root password.How?
I am new to MySQL. I am trying to change the root credentials for Mysql. I searched for it on many sites but I didn't find anything. I tried it with the help of this site blog. I thought it will help me because my error code was the same as mentioned in this blog. Please help me with this. Thank you in advance</p>

答:
You can update your password instead of YOUR PASSWORD HERE and execute query

update user set password = PASSWORD('YOUR PASSWORD HERE') where user='root';

Title: change the mysql root password.How?


问:
Error: The truth value of a DataFrame is ambiguous when splitting strings into two columns if two conditions are met
I am trying to make split the string in column['first'] if the following two conditions are met.

column['first'] contains words 'floor' or 'floors'

column['second'] is empty

However, I received an error message.

The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

Below is my code

```<code>#boolean series for condition 1: when values in column['second'] are empty

only_first_token = pd.isna(results_threshold_50_split_ownership['second'])
print (len(only_first_token))
print (type(only_first_token))

#boolean series for condition 2: when values in column['first'] contain string floor or floors

first_token_contain_floor = results_threshold_50_split_ownership['first'].str.contains('floors|floor',case=False)
print (len(first_token_contain_floor))
print (type(only_first_token))

#if both conditions are met, the string in column['first'] will be split into column['first'] and['second']

if results_threshold_50_split_ownership[(only_first_token) & (first_token_contain_floor)]:
    results_threshold_50_split_ownership.first.str.split('Floors|Floor', expand=True)

print(results_threshold_50_split_ownership['first'])

</code>```

I have read some answers here and have already changed the code a few times. I made sure the total number of boolean are the same at 1016. And I can successfully locate the rows that can fulfil the two conditions with the same code if I remove if. So I don't understand why it is ambiguous.

Any help would be much appreciated. Many thanks.

答:
Your conditions are perfectly OK, the problem is the if statement - it reads:

```<code>if boolean_array :
  ...
</code>```

but if needs just one boolean value, not a whole array of booleans. In order to reduce a boolean array to just one value you can use e.g. any() or all() as the error message suggests -  if all(boolean_array): etc.

What you really want to do is probably:

```<code>results_threshold_50_split_ownership[(only_first_token) & (first_token_contain_floor)]['first'].str.split('Floors|Floor', expand=True)
</code>```

i.e. use the boolean array for boolean indexing.

Update as per comment below:

You can assign the result of the splitting to the orginal columns using results_threshold_50_split_ownership.loc[(only_first_token) & (first_token_contain_floor), ['first', 'second']]. In this can you need to make sure, however, that maximum 2 columns are being return by specifying n=1 in the split function (in case your fist column contains the word 'floor' multiple times).

Example:

```<code>results_threshold_50_split_ownership = pd.DataFrame({'first': ['first floor value', 'all floors values', 'x'],
                                                     'second': ['y', None, None]})
print(results_threshold_50_split_ownership)
#               first second
#0  first floor value      y
#1  all floors values   None
#2                  x   None
only_first_token = pd.isna(results_threshold_50_split_ownership['second'])
first_token_contain_floor = results_threshold_50_split_ownership['first'].str.contains('floors|floor',case=False)
results_threshold_50_split_ownership.loc[(only_first_token) & (first_token_contain_floor), ['first', 'second']] = results_threshold_50_split_ownership[(only_first_token) & (first_token_contain_floor)]['first'].str.split('floors|floor', 1, expand=True).to_numpy()
print(results_threshold_50_split_ownership)
#               first   second
#0  first floor value        y
#1               all    values
#2                  x     None
</code>```

Body:
I am trying to make split the string in column['first'] if the following two conditions are met.

column['first'] contains words 'floor' or 'floors'

column['second'] is empty

However, I received an error message.

The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

Below is my code

#boolean series for condition 1: when values in column['second'] are empty

only_first_token = pd.isna(results_threshold_50_split_ownership['second'])
print (len(only_first_token))
print (type(only_first_token))

#boolean series for condition 2: when values in column['first'] contain string floor or floors

first_token_contain_floor = results_threshold_50_split_ownership['first'].str.contains('floors|floor',case=False)
print (len(first_token_contain_floor))
print (type(only_first_token))

#if both conditions are met, the string in column['first'] will be split into column['first'] and['second']

if results_threshold_50_split_ownership[(only_first_token) & (first_token_contain_floor)]:
    results_threshold_50_split_ownership.first.str.split('Floors|Floor', expand=True)

print(results_threshold_50_split_ownership['first'])

I have read some answers here and have already changed the code a few times. I made sure the total number of boolean are the same at 1016. And I can successfully locate the rows that can fulfil the two conditions with the same code if I remove if. So I don't understand why it is ambiguous.

Any help would be much appreciated. Many thanks.

Body:
Your conditions are perfectly OK, the problem is the if statement - it reads:

if boolean_array :
  ...

but if needs just one boolean value, not a whole array of booleans. In order to reduce a boolean array to just one value you can use e.g. any() or all() as the error message suggests -  if all(boolean_array): etc.

What you really want to do is probably:

results_threshold_50_split_ownership[(only_first_token) & (first_token_contain_floor)]['first'].str.split('Floors|Floor', expand=True)

i.e. use the boolean array for boolean indexing.

Update as per comment below:

You can assign the result of the splitting to the orginal columns using results_threshold_50_split_ownership.loc[(only_first_token) & (first_token_contain_floor), ['first', 'second']]. In this can you need to make sure, however, that maximum 2 columns are being return by specifying n=1 in the split function (in case your fist column contains the word 'floor' multiple times).

Example:

results_threshold_50_split_ownership = pd.DataFrame({'first': ['first floor value', 'all floors values', 'x'],
                                                     'second': ['y', None, None]})
print(results_threshold_50_split_ownership)
#               first second
#0  first floor value      y
#1  all floors values   None
#2                  x   None
only_first_token = pd.isna(results_threshold_50_split_ownership['second'])
first_token_contain_floor = results_threshold_50_split_ownership['first'].str.contains('floors|floor',case=False)
results_threshold_50_split_ownership.loc[(only_first_token) & (first_token_contain_floor), ['first', 'second']] = results_threshold_50_split_ownership[(only_first_token) & (first_token_contain_floor)]['first'].str.split('floors|floor', 1, expand=True).to_numpy()
print(results_threshold_50_split_ownership)
#               first   second
#0  first floor value        y
#1               all    values
#2                  x     None


问:
Does HTTP allow the server to start output before consuming all input? If so, how to access such a server in Java?
Note: this question is closely related to Is it acceptable for a server to send a HTTP response before the entire request has been received? with the difference that (1) I'm not sending an error, I'm sending a 200 OK, and (2) I control both the client and server, so don't really care about browser support.

Context: I am implementing a Java HTTP client and server for managing files. In particular an "upload" query contains a file path and the file body, and the server responds with a numerical identifier for the file. However if a file with the same path has already been uploaded, the server will simply respond with the previously generated identifier.

Concretely: if I write the server as follows (sparkjava)

```<code>put(url, (req, res) -> {
  Item existing = lookForExistingItem(req);
  if (existing != null) {
     return existing.getId();
  }
  /* Otherwise, consume input, save, generate id and return that */
});
</code>```

... then the server will respond with the id and close the connection before the client finished sending data. If I write the client as follows:

```<code>final HttpURLConnection connection = (HttpURLConnection) new URL(...).openConnection();
connection.setDoOutput(true);
connection.setRequestMethod("PUT");
ByteStreams.copy(fileInput, connection.getOutputStream());
final String response = CharStreams.toString(new InputStreamReader(connection.getInputStream()));
</code>```

then an IOException is thrown during the copy operation due to the closed connection. After that point I am not able to access the connection's InputStream anymore.

My Question: how can I make this work? If I change the server to consume the whole input and throw it away, it works, but it feels like wasting resources (some of the files being uploaded may be videos weighing hundreds of megabytes). Is there any way to change the client code to deal with that scenario?

答:
You could break that call in to several requests assuming that files are big enough and making multiple requests consumes far less resources than transferring a partial file.

enum UploadStatus {
   INITIALIZED,
   STARTED,
   UPLOADED,
   ERROR
}
```

My Suggestion:

Have a static map ConcurrentMap<File name string, UploadStatus> (or DB
entry) where you can keep track of file upload statuses

Create an endpoint to check and set file status

Client first make a request to above endpoint

if file exist on the map and it's status is not UploadStatus.ERROR, set the file's status on the map to UploadStatus.INITIALIZED and let client (client A) know it can upload the file (Should do this on a synchronized block)

If file exists and UploadStatus.INITIALIZED, let that client (client B) know its being uploaded. For the sake of UX, you could make the client B poll for the file status until UploadStatus becomes ERROR or UPLOADED and then take appropriate action. i.e.

Re-upload file on UploadStatus.ERROR

Show uploaded message on UploadStatus.UPLOADED

Once the server receive the request to upload the actual file from the client A, keep the file upload status up to date so that on error other clients such as Client B can re-upload a failed file.

Doing the file status check and set on a single sync block is important to avoid race condition when setting correct file status. Also, that enum is just to explain the general high level steps. Since you already have Guava, you could use Guava Cache with time base eviction for storing the file statues.

Body:
Note: this question is closely related to Is it acceptable for a server to send a HTTP response before the entire request has been received? with the difference that (1) I'm not sending an error, I'm sending a 200 OK, and (2) I control both the client and server, so don't really care about browser support.

Context: I am implementing a Java HTTP client and server for managing files. In particular an "upload" query contains a file path and the file body, and the server responds with a numerical identifier for the file. However if a file with the same path has already been uploaded, the server will simply respond with the previously generated identifier.

Concretely: if I write the server as follows (sparkjava)

put(url, (req, res) -> {
  Item existing = lookForExistingItem(req);
  if (existing != null) {
     return existing.getId();
  }
  /* Otherwise, consume input, save, generate id and return that */
});

... then the server will respond with the id and close the connection before the client finished sending data. If I write the client as follows:

final HttpURLConnection connection = (HttpURLConnection) new URL(...).openConnection();
connection.setDoOutput(true);
connection.setRequestMethod("PUT");
ByteStreams.copy(fileInput, connection.getOutputStream());
final String response = CharStreams.toString(new InputStreamReader(connection.getInputStream()));

then an IOException is thrown during the copy operation due to the closed connection. After that point I am not able to access the connection's InputStream anymore.

My Question: how can I make this work? If I change the server to consume the whole input and throw it away, it works, but it feels like wasting resources (some of the files being uploaded may be videos weighing hundreds of megabytes). Is there any way to change the client code to deal with that scenario?

Body:
You could break that call in to several requests assuming that files are big enough and making multiple requests consumes far less resources than transferring a partial file.

enum UploadStatus {
   INITIALIZED,
   STARTED,
   UPLOADED,
   ERROR
}

My Suggestion:

Have a static map ConcurrentMap<File name string, UploadStatus> (or DB
entry) where you can keep track of file upload statuses

Create an endpoint to check and set file status

Client first make a request to above endpoint

if file exist on the map and it's status is not UploadStatus.ERROR, set the file's status on the map to UploadStatus.INITIALIZED and let client (client A) know it can upload the file (Should do this on a synchronized block)

If file exists and UploadStatus.INITIALIZED, let that client (client B) know its being uploaded. For the sake of UX, you could make the client B poll for the file status until UploadStatus becomes ERROR or UPLOADED and then take appropriate action. i.e.

Re-upload file on UploadStatus.ERROR

Show uploaded message on UploadStatus.UPLOADED

Once the server receive the request to upload the actual file from the client A, keep the file upload status up to date so that on error other clients such as Client B can re-upload a failed file.

Doing the file status check and set on a single sync block is important to avoid race condition when setting correct file status. Also, that enum is just to explain the general high level steps. Since you already have Guava, you could use Guava Cache with time base eviction for storing the file statues.


问:
Merge the community found in stage 1 Louvain algorithm and evaluate modularity gain obtaining by further merging of the super-nodes
I wrote the code below, for modularity  detection,  I also  run the stage 1 of the Louvain algorithm, but I have a question , how can i Merge the community found at the Stage 1 into the so-called super-nodes and evaluate modularity gain obtaining by further merging of the super-nodes</p>

```<code>library(igraph)
g <- graph.formula(A1:A2:A3:A4:A5--A1:A2:A3:A4,A5,A5-A6,
                   A6:A7:A8:A9:A10--A6:A7:A8:A9,A10,A10-A11,
                   A11:A12:A13:A14:A15--A11:A12:A13:A14,A15,A15-A16,
                   A16:A17:A18:A19:A20--A16:A17:A18:A19,A20,A20-A21,
                   A21:A22:A23:A24:A25--A21:A22:A23:A24,A25,A25-A26,
                   A26:A27:A28:A29:A30--A26:A27:A28:A29,A30,A30-A1)
par(mar=c(2,2,2,2)) ### set margins

plot(g, vertex.size=5,edge.color="gray80",vertex.label=NA,vertex.color="red")

#2) Compute the initial value of the modularity
V(g)$grp <- c(1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,5,5,5,5,5,6,6,6,6,6)
#op <- par(mfrow=c(1,2))
par(mar=c(2,2,2,2)) ### set margins

plot(g,vertex.color=(V(g)$grp),
     vertex.size=7,vertex.label=NA)

modularity(g,V(g)$grp)

#3) Try to PARTIALLY run the stage 1 of the Louvain algorithm
cl <- cluster_louvain(g)
modularity(cl)
plot(cl, g,
     main="Louvain algorithm",vertex.size=8 )
</code>```

答:
I think that what you need is the function contract.  The most basic solution would be:

```<code>g2 = contract(g, cl$membership)
plot(g2, vertex.color=1:6)
</code>```

However, if you want to eliminate the edges from the new vertices to themselves,
also run

g2 = simplify(g2).

If you want nicer names for the nodes, try

V(g2)$name = 1:6

Body:
I wrote the code below, for modularity  detection,  I also  run the stage 1 of the Louvain algorithm, but I have a question , how can i Merge the community found at the Stage 1 into the so-called super-nodes and evaluate modularity gain obtaining by further merging of the super-nodes

library(igraph)
g <- graph.formula(A1:A2:A3:A4:A5--A1:A2:A3:A4,A5,A5-A6,
                   A6:A7:A8:A9:A10--A6:A7:A8:A9,A10,A10-A11,
                   A11:A12:A13:A14:A15--A11:A12:A13:A14,A15,A15-A16,
                   A16:A17:A18:A19:A20--A16:A17:A18:A19,A20,A20-A21,
                   A21:A22:A23:A24:A25--A21:A22:A23:A24,A25,A25-A26,
                   A26:A27:A28:A29:A30--A26:A27:A28:A29,A30,A30-A1)
par(mar=c(2,2,2,2)) ### set margins

plot(g, vertex.size=5,edge.color="gray80",vertex.label=NA,vertex.color="red")

#2) Compute the initial value of the modularity
V(g)$grp <- c(1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,5,5,5,5,5,6,6,6,6,6)
#op <- par(mfrow=c(1,2))
par(mar=c(2,2,2,2)) ### set margins

plot(g,vertex.color=(V(g)$grp),
     vertex.size=7,vertex.label=NA)

modularity(g,V(g)$grp)

#3) Try to PARTIALLY run the stage 1 of the Louvain algorithm
cl <- cluster_louvain(g)
modularity(cl)
plot(cl, g,
     main="Louvain algorithm",vertex.size=8 )

Body:
I think that what you need is the function contract.  The most basic solution would be:

g2 = contract(g, cl$membership)
plot(g2, vertex.color=1:6)

However, if you want to eliminate the edges from the new vertices to themselves,
also run

g2 = simplify(g2).

If you want nicer names for the nodes, try

V(g2)$name = 1:6


问:
JavaFX: Remove a child from Vbox
So I am new to JavaFX, and I am trying to do an app for school and I've been reading lots of related posts, but I can't seem to figure it how to do for my own case. Here Is a picture

So the big screen is my main screen and the one with the red border are children of the Vbox. And for the child, I have a separate FXML and a controller. When I hit the "Close Deal" button I want to remove the specific child of the Vbox.

I know I should do parent.getChildren().remove(specific_child_node); The problem is I don't know how to get the specific_child_node for the child for which has been the "Closed Deal" button pressed. The close button is in the child's controller and the Vbox is in the main page controller

Has anyone any idea of how I could do it?

答:
I created a small example to show how you could do it:

MainController Class:

```<code>package sample;

import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox;

import java.io.IOException;

public class MainController {

    @FXML
    private VBox middleVBox;

    @FXML
    public void handleAddChildBtnClick() {

        FXMLLoader loader = new FXMLLoader(getClass().getResource("deal.fxml"));
        GridPane root = null;
        try {
            root = loader.load();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
        if (root == null) return;

        // Get the controller instance:
        DealController controller = loader.getController();

        // Set a reference for the parent vbox:
        controller.setParent(middleVBox);

        middleVBox.getChildren().add(1, root);
    }
}
</code>```

FXML File "main.fxml":

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?>

<GridPane alignment="center" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.MainController">
   <children>
      <VBox style="-fx-background-color: black;">
         <children>

         </children>
      </VBox>
      <VBox fx:id="middleVBox" GridPane.columnIndex="1">
         <children>

            <VBox>
               <children>

               </children>
            </VBox>
         </children>
      </VBox>
      <VBox GridPane.columnIndex="2">
         <children>
            <Button mnemonicParsing="false" onAction="#handleAddChildBtnClick" text="Add Child" />
         </children>
      </VBox>
   </children>
   <columnConstraints>
      <ColumnConstraints />
      <ColumnConstraints />
      <ColumnConstraints />
   </columnConstraints>
   <rowConstraints>
      <RowConstraints prefHeight="200.0" />
   </rowConstraints>
</GridPane>
```

<p>DealController Class:</p>

```package sample;

import javafx.fxml.FXML;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox;

public class DealController {

    @FXML
    private GridPane dealRoot;

    private VBox parent;

    @FXML
    public void handleCloseDealBtnClick() {
        parent.getChildren().remove(dealRoot);
    }

    void setParent(VBox parent) {
        this.parent = parent;
    }
}
```

<p>FXML File "deal.fxml":</p>

<pre class="lang-xml prettyprint-override"><code><?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>

<GridPane fx:id="dealRoot" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.DealController">
  <columnConstraints>
    <ColumnConstraints hgrow="SOMETIMES" />
      <ColumnConstraints hgrow="SOMETIMES" />
  </columnConstraints>
  <rowConstraints>
    <RowConstraints vgrow="SOMETIMES" />
    <RowConstraints vgrow="SOMETIMES" />
  </rowConstraints>
   <children>
      <Label text="cvbn" textFill="#008612" />
      <Button mnemonicParsing="false" onAction="#handleCloseDealBtnClick" text="Close Deal" GridPane.columnIndex="1" GridPane.rowIndex="1" />
   </children>
</GridPane>
</code>```

Main Class:

```<code>package sample;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class Main extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception {
        Parent root = FXMLLoader.load(getClass().getResource("main.fxml"));
        primaryStage.setScene(new Scene(root));
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}
</code>```

Title: JavaFX: Remove a child from Vbox

Body:
I created a small example to show how you could do it:

MainController Class:

package sample;

import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox;

import java.io.IOException;

public class MainController {

    @FXML
    private VBox middleVBox;

    @FXML
    public void handleAddChildBtnClick() {

        FXMLLoader loader = new FXMLLoader(getClass().getResource("deal.fxml"));
        GridPane root = null;
        try {
            root = loader.load();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
        if (root == null) return;

        // Get the controller instance:
        DealController controller = loader.getController();

        // Set a reference for the parent vbox:
        controller.setParent(middleVBox);

        middleVBox.getChildren().add(1, root);
    }
}

FXML File "main.fxml":

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?>

<GridPane alignment="center" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.MainController">
   <children>
      <VBox style="-fx-background-color: black;">
         <children>
            <Label text="Welcome, Client" textFill="WHITE" />
         </children>
      </VBox>
      <VBox fx:id="middleVBox" GridPane.columnIndex="1">
         <children>
            <Label text="Generate Public Auction" />
            <VBox>
               <children>
                  <Label text="dfgh" textFill="#1aab0d" />
               </children>
            </VBox>
         </children>
      </VBox>
      <VBox GridPane.columnIndex="2">
         <children>
            <Button mnemonicParsing="false" onAction="#handleAddChildBtnClick" text="Add Child" />
         </children>
      </VBox>
   </children>
   <columnConstraints>
      <ColumnConstraints />
      <ColumnConstraints />
      <ColumnConstraints />
   </columnConstraints>
   <rowConstraints>
      <RowConstraints prefHeight="200.0" />
   </rowConstraints>
</GridPane>

DealController Class:

package sample;

import javafx.fxml.FXML;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox;

public class DealController {

    @FXML
    private GridPane dealRoot;

    private VBox parent;

    @FXML
    public void handleCloseDealBtnClick() {
        parent.getChildren().remove(dealRoot);
    }

    void setParent(VBox parent) {
        this.parent = parent;
    }
}

FXML File "deal.fxml":

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>

<GridPane fx:id="dealRoot" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.DealController">
  <columnConstraints>
    <ColumnConstraints hgrow="SOMETIMES" />
      <ColumnConstraints hgrow="SOMETIMES" />
  </columnConstraints>
  <rowConstraints>
    <RowConstraints vgrow="SOMETIMES" />
    <RowConstraints vgrow="SOMETIMES" />
  </rowConstraints>
   <children>
      <Label text="cvbn" textFill="#008612" />
      <Button mnemonicParsing="false" onAction="#handleCloseDealBtnClick" text="Close Deal" GridPane.columnIndex="1" GridPane.rowIndex="1" />
   </children>
</GridPane>

Main Class:

package sample;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class Main extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception {
        Parent root = FXMLLoader.load(getClass().getResource("main.fxml"));
        primaryStage.setScene(new Scene(root));
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}


问:
C++ versions, what they mean, how to update them
Is the c++ version you use tied to the version of compiler you have or IDE?
If it isn't either of those, how do I use c++ 11 on my IDE? How do i update what C++ version i use in my programs?
How do I check what version I'm using?

I know that printing the __cplusplus variable can tell me what version I'm using, but this doesn't answer my other questions, neither does it answer my third question, because: https://stackoverflow.com/a/14131551/10938047

Found this question, with the answer containing an outdated link.
Visual Studio 2012 __cplusplus and C++ 11

答:
The C++ version you can use is obviously tied to the compiler you use. If your compiler doesn't support some newer standard then of course you cannot use it.

As for IDEs; some IDEs are tied to a specific compiler, some can use different ones.

Some compilers support multiple language versions but require you to explicitly enable anything newer than what they enable by default. For example; most older versions of GCC support C++17 just fine, but default to C++11 or C++14 unless you tell them to enable C++17 support via the -std=c++17 command line option.