问:
Last Item in recyclerview is cut off
I am using recyclerview to display a list of items and constraint layout is the parent view. The layout is displayed  below:

```<code>  <?xml version="1.0" encoding="utf-8"?>
    <android.support.constraint.ConstraintLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:orientation="vertical"
        android:layout_height="match_parent">

        <!-- Load the toolbar here -->
        <android.support.v7.widget.Toolbar
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:id="@+id/toolbar"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:fitsSystemWindows="true"
            android:minHeight="?android:attr/actionBarSize"
            app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            android:background="@color/colorPrimary"/>

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recyclerView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            android:visibility="visible"
            app:layout_constraintTop_toBottomOf="@+id/toolbar" />

        <ImageView
            android:id="@+id/imageViewContent"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintTop_toBottomOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintBottom_toTopOf="parent"
            android:visibility="gone"
            android:src="@drawable/empty_category"/>

        <TextView
            android:id="@+id/textViewContent"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="16dp"
            android:gravity="center"
            android:text="Empty Category"
            android:textStyle="bold"
            android:textColor="@color/colorPrimary"
            android:textAppearance="@style/TextAppearance.AppCompat.Large"
            android:visibility="gone"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/imageViewContent" />

    </android.support.constraint.ConstraintLayout>

The adapter layout for each row is presented below:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <FrameLayout
        android:id="@+id/framelayoutImage"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@id/buttonCart"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp">

        <ImageView
            android:id="@+id/imageViewCoverArt"
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:scaleType="center" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:background="#59000000"
            android:orientation="vertical">

            <TextView
                android:id="@+id/textViewPrice"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom|left"
                android:layout_marginLeft="10dp"
                android:clickable="false"
                android:text="$220"
                android:textAppearance="@style/TextAppearance.AppCompat.Medium"
                android:textColor="@android:color/white"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/textViewDetails"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom|left"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="8dp"
                android:ellipsize="end"
                android:maxLength="17"
                android:maxLines="1"
                android:text="Lorem ipsum dolor sit amet, consecte"
                android:textAppearance="@style/TextAppearance.AppCompat.Medium"
                android:textColor="@android:color/white" />

        </LinearLayout>

    </FrameLayout>

    <Button
        android:id="@+id/buttonCart"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="8dp"
        android:background="@drawable/buttonshape"
        android:text="Add to Cart"
        android:textAppearance="@style/TextAppearance.AppCompat.Small"
        android:textColor="@android:color/white"
        android:textStyle="bold"
     />
</LinearLayout>
</code>```

After running my application the layouts are presented in the image below:

I tried adding a bottom margin to the recycle view, but this has not resolved the issue. I used the following links as references: RecyclerView is cutting off the last item, RecyclerView cutting off last item and tried making those changes with no luck

答:
I tried all the available option from most of possible site but I didn't get the solution.
Then, I think can I use bottom padding? And Yes, It's work for me.

I am sharing the code to you.
Nothing more attribute required other than height, width & padding.

```<code><android.support.v7.widget.RecyclerView
    android:id="@+id/your id name"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingBottom="?attr/actionBarSize"
    app:layout_constraintTop_toBottomOf="@+id/your field" />
</code>```

Title: Last Item in recyclerview is cut off

Body:
I am using recyclerview to display a list of items and constraint layout is the parent view. The layout is displayed  below:

  <?xml version="1.0" encoding="utf-8"?>
    <android.support.constraint.ConstraintLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:orientation="vertical"
        android:layout_height="match_parent">

        <android.support.v7.widget.Toolbar
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:id="@+id/toolbar"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:fitsSystemWindows="true"
            android:minHeight="?android:attr/actionBarSize"
            app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            android:background="@color/colorPrimary"/>

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recyclerView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            android:visibility="visible"
            app:layout_constraintTop_toBottomOf="@+id/toolbar" />

        <ImageView
            android:id="@+id/imageViewContent"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintTop_toBottomOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintBottom_toTopOf="parent"
            android:visibility="gone"
            android:src="@drawable/empty_category"/>

        <TextView
            android:id="@+id/textViewContent"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="16dp"
            android:gravity="center"
            android:text="Empty Category"
            android:textStyle="bold"
            android:textColor="@color/colorPrimary"
            android:textAppearance="@style/TextAppearance.AppCompat.Large"
            android:visibility="gone"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/imageViewContent" />

    </android.support.constraint.ConstraintLayout>

The adapter layout for each row is presented below:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <FrameLayout
        android:id="@+id/framelayoutImage"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@id/buttonCart"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp">

        <ImageView
            android:id="@+id/imageViewCoverArt"
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:scaleType="center" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:background="#59000000"
            android:orientation="vertical">

            <TextView
                android:id="@+id/textViewPrice"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom|left"
                android:layout_marginLeft="10dp"
                android:clickable="false"
                android:text="$220"
                android:textAppearance="@style/TextAppearance.AppCompat.Medium"
                android:textColor="@android:color/white"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/textViewDetails"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom|left"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="8dp"
                android:ellipsize="end"
                android:maxLength="17"
                android:maxLines="1"
                android:text="Lorem ipsum dolor sit amet, consecte"
                android:textAppearance="@style/TextAppearance.AppCompat.Medium"
                android:textColor="@android:color/white" />

        </LinearLayout>

    </FrameLayout>

    <Button
        android:id="@+id/buttonCart"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="8dp"
        android:background="@drawable/buttonshape"
        android:text="Add to Cart"
        android:textAppearance="@style/TextAppearance.AppCompat.Small"
        android:textColor="@android:color/white"
        android:textStyle="bold"
     />
</LinearLayout>

After running my application the layouts are presented in the image below:

I tried adding a bottom margin to the recycle view, but this has not resolved the issue. I used the following links as references: RecyclerView is cutting off the last item, RecyclerView cutting off last item and tried making those changes with no luck

Body:
I tried all the available option from most of possible site but I didn't get the solution.
Then, I think can I use bottom padding? And Yes, It's work for me.

I am sharing the code to you.
Nothing more attribute required other than height, width & padding.

<android.support.v7.widget.RecyclerView
    android:id="@+id/your id name"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingBottom="?attr/actionBarSize"
    app:layout_constraintTop_toBottomOf="@+id/your field" />


来源: stackexchange

问:
powerapps Radio button control
I have a gallery and a radio button.
In the gallery where the user has to answer questions.

Each question can be a radio button with multiple choice answers, for example  one could be a yes no response another could be a yes no unknown choice.

These choices are determined from the list field called answerchoice .

In the answerchoice field it might be populated with

```<code>yes\no or yes\no\unknown or 1\2\3\4.
</code>```

Therefore in the items of the radio button I need to pass the values of the answerchoice field

Thank you

答:
If the separator for the options is the \ character, then you can use the Split function to convert that into a collection that you can set to the Items property of the radio button control:

```<code>Split(ThisItem.Value, "\")
</code>```

ContentLicense: CC BY-SA 4.0

Title: powerapps Radio button control

Body:
I have a gallery and a radio button.
In the gallery where the user has to answer questions.

Each question can be a radio button with multiple choice answers, for example  one could be a yes no response another could be a yes no unknown choice.

These choices are determined from the list field called answerchoice .

In the answerchoice field it might be populated with

yes\no or yes\no\unknown or 1\2\3\4.

Therefore in the items of the radio button I need to pass the values of the answerchoice field

Thank you

Body:
If the separator for the options is the \ character, then you can use the Split function to convert that into a collection that you can set to the Items property of the radio button control:

Split(ThisItem.Value, "\")


问:
elasticsearch aggregate on list of objects with condition
Say we have following documents in elasticsearch:

```<code>[{
  "person": {
    'name': 'asqar'
  },
  "bill": [
    {
      code:2,
      value: 210
    },
    {
      code:3,
      value: 330
    },
    {
      code:8,
      value: 220
    },
  ]
},
{
  "person": {
    'name': 'asqar'
  },
  "bill": [
    {
      code:2,
      value: 340
    },
    {
      code:4,
      value: 340
    },
    {
      code:1,
      value: 200
    },
  ]
},
{
  "person": {
    'name': 'asqar'
  },
  "bill": [
    {
      code:2,
      value: 810
    },
    {
      code:4,
      value: 630
    },
    {
      code:8,
      value: 220
    },
  ]
}]
</code>```

I want to apply aggregate function on specific object in the bill array iwth some condition, for example I want calculate avg of value which its code is 2.

答:
Field bill needs to be created as nested object to filter on it.

You can then use filter aggregation

Mapping:

```<code>PUT testindex/_mapping
{
  "properties": {
    "person": {
      "properties": {
        "name": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        }
      }
    },
    "bill": {
      "type": "nested",
      "properties": {
        "code": {
          "type": "integer"
        },
        "value":{
          "type": "double"
        }
      }
    }
  }
}
</code>```

Data:

```<code>    "hits" : [
      {
        "_index" : "testindex",
        "_type" : "_doc",
        "_id" : "422tAWsBd-1D6Ztt1_Tb",
        "_score" : 1.0,
        "_source" : {
          "person" : {
            "name" : "asqar"
          },
          "bill" : [
            {
              "code" : 2,
              "value" : 210
            },
            {
              "code" : 3,
              "value" : 330
            },
            {
              "code" : 8,
              "value" : 220
            }
          ]
        }
      },
      {
        "_index" : "testindex",
        "_type" : "_doc",
        "_id" : "5G2uAWsBd-1D6ZttpfR9",
        "_score" : 1.0,
        "_source" : {
          "person" : {
            "name" : "asqar"
          },
          "bill" : [
            {
              "code" : 2,
              "value" : 340
            },
            {
              "code" : 4,
              "value" : 340
            },
            {
              "code" : 1,
              "value" : 200
            }
          ]
        }
      },
      {
        "_index" : "testindex",
        "_type" : "_doc",
        "_id" : "5W2vAWsBd-1D6ZttQfQ_",
        "_score" : 1.0,
        "_source" : {
          "person" : {
            "name" : "asqar"
          },
          "bill" : [
            {
              "code" : 2,
              "value" : 810
            },
            {
              "code" : 4,
              "value" : 630
            },
            {
              "code" : 8,
              "value" : 220
            }
          ]
        }
      }
    ]
</code>```

Query:

```<code>GET testindex/_search
{
  "size": 0,
  "aggs": {
    "terms_agg": {
      "terms": {
        "field": "person.name.keyword"
      },
      "aggs": {
        "bill": {
          "nested": {
            "path": "bill"
          },
          "aggs": {
            "bill_code": {
              "filter": {
                "term": {
                  "bill.code": 2
                }
              },
              "aggs": {
                "average": {
                  "avg": {
                    "field": "bill.value"
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

</code>```

Output:

```<code> "hits" : {
    "total" : {
      "value" : 3,
      "relation" : "eq"
    },
    "max_score" : null,
    "hits" : [ ]
  },
  "aggregations" : {
    "terms_agg" : {
      "doc_count_error_upper_bound" : 0,
      "sum_other_doc_count" : 0,
      "buckets" : [
        {
          "key" : "asqar",
          "doc_count" : 3,
          "bill" : {
            "doc_count" : 9,
            "bill_code" : {
              "doc_count" : 3,
              "average" : {
                "value" : 453.3333333333333
              }
            }
          }
        }
      ]
    }
  }
</code>```

Body:
Say we have following documents in elasticsearch:

[{
  "person": {
    'name': 'asqar'
  },
  "bill": [
    {
      code:2,
      value: 210
    },
    {
      code:3,
      value: 330
    },
    {
      code:8,
      value: 220
    },
  ]
},
{
  "person": {
    'name': 'asqar'
  },
  "bill": [
    {
      code:2,
      value: 340
    },
    {
      code:4,
      value: 340
    },
    {
      code:1,
      value: 200
    },
  ]
},
{
  "person": {
    'name': 'asqar'
  },
  "bill": [
    {
      code:2,
      value: 810
    },
    {
      code:4,
      value: 630
    },
    {
      code:8,
      value: 220
    },
  ]
}]

I want to apply aggregate function on specific object in the bill array iwth some condition, for example I want calculate avg of value which its code is 2.

Body:
Field bill needs to be created as nested object to filter on it.

You can then use filter aggregation

Mapping:

PUT testindex/_mapping
{
  "properties": {
    "person": {
      "properties": {
        "name": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        }
      }
    },
    "bill": {
      "type": "nested",
      "properties": {
        "code": {
          "type": "integer"
        },
        "value":{
          "type": "double"
        }
      }
    }
  }
}

Data:

    "hits" : [
      {
        "_index" : "testindex",
        "_type" : "_doc",
        "_id" : "422tAWsBd-1D6Ztt1_Tb",
        "_score" : 1.0,
        "_source" : {
          "person" : {
            "name" : "asqar"
          },
          "bill" : [
            {
              "code" : 2,
              "value" : 210
            },
            {
              "code" : 3,
              "value" : 330
            },
            {
              "code" : 8,
              "value" : 220
            }
          ]
        }
      },
      {
        "_index" : "testindex",
        "_type" : "_doc",
        "_id" : "5G2uAWsBd-1D6ZttpfR9",
        "_score" : 1.0,
        "_source" : {
          "person" : {
            "name" : "asqar"
          },
          "bill" : [
            {
              "code" : 2,
              "value" : 340
            },
            {
              "code" : 4,
              "value" : 340
            },
            {
              "code" : 1,
              "value" : 200
            }
          ]
        }
      },
      {
        "_index" : "testindex",
        "_type" : "_doc",
        "_id" : "5W2vAWsBd-1D6ZttQfQ_",
        "_score" : 1.0,
        "_source" : {
          "person" : {
            "name" : "asqar"
          },
          "bill" : [
            {
              "code" : 2,
              "value" : 810
            },
            {
              "code" : 4,
              "value" : 630
            },
            {
              "code" : 8,
              "value" : 220
            }
          ]
        }
      }
    ]

Query:

GET testindex/_search
{
  "size": 0,
  "aggs": {
    "terms_agg": {
      "terms": {
        "field": "person.name.keyword"
      },
      "aggs": {
        "bill": {
          "nested": {
            "path": "bill"
          },
          "aggs": {
            "bill_code": {
              "filter": {
                "term": {
                  "bill.code": 2
                }
              },
              "aggs": {
                "average": {
                  "avg": {
                    "field": "bill.value"
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

Output:

 "hits" : {
    "total" : {
      "value" : 3,
      "relation" : "eq"
    },
    "max_score" : null,
    "hits" : [ ]
  },
  "aggregations" : {
    "terms_agg" : {
      "doc_count_error_upper_bound" : 0,
      "sum_other_doc_count" : 0,
      "buckets" : [
        {
          "key" : "asqar",
          "doc_count" : 3,
          "bill" : {
            "doc_count" : 9,
            "bill_code" : {
              "doc_count" : 3,
              "average" : {
                "value" : 453.3333333333333
              }
            }
          }
        }
      ]
    }
  }


问:
Maintenance for the Amazon RDS API in the AP-NORTHEAST-1 Region
My 3 RDS instances are running in AP-NORTHEAST-1 Region. Among these, one is multi-AZ enabled and remaining two are not multi-AZ.

During the upcoming maintenance, my two non multiAZ RDS instance will have downtime for sure as it will be in one availability zone only. As per the multiAZ concept, one stand by copy of DB will be in another availability zone. I assume, region wise maintenance will be AZ by AZ, so it will not have downtime. Is it correct?

答:
From Maintaining a DB Instance - Amazon Relational Database Service:

Running a DB instance as a Multi-AZ deployment can further reduce the impact of a maintenance event, because Amazon RDS applies operating system updates by following these steps:

Perform maintenance on the standby.

Promote the standby to primary.

Perform maintenance on the old primary, which becomes the new standby.

Therefore, there is little or no impact to availability.


问:
Javascript My Array Push is only getting the last value
I have this for loop that I want to increment the year on every cycle, but I'm only getting the last year all repeating multiple times.

```<code>for (let i = 0; i < 2; i++) {
  this.data.year = new Date().getFullYear() + i;
  this.data.noSolar = averageBill * increaseRate;
  this.data.withSolar = (contractAmount * .004) + customerCharge;
  this.data.saving = (contractAmount * .004 + customerCharge) * 12 - (averageBill * 12);
  this.data.check = SREC;
  this.data.total = (contractAmount * .004 + customerCharge) * 12 - (averageBill * 12) + SREC;

  this.dataSource.push(this.data);
}
</code>```

The Year in this case 2020 is showing twice. I want something like 2019 and 2020. Its like the variable is being reference multiple times.

答:
Reference of object is pushed in array. Instead clone or create copy and then push</p>

```<code>    const temp = {};
    for (let i = 0; i < 2; i++) {
      this.data.year = new Date().getFullYear() + i;
      this.data.noSolar = averageBill * increaseRate;
      this.data.withSolar = (contractAmount * .004) + customerCharge;
      this.data.saving = (contractAmount * .004 + customerCharge) * 12 - (averageBill * 12);
      this.data.check = SREC;
      this.data.total = (contractAmount * .004 + customerCharge) * 12 - (averageBill * 12) + SREC;
      // this.dataSource.push(...this.data)
      Object.assign(temp, this.data);
      this.dataSource.push(temp);
    };
</code>```

Body:
I have this for loop that I want to increment the year on every cycle, but I'm only getting the last year all repeating multiple times.

for (let i = 0; i < 2; i++) {
  this.data.year = new Date().getFullYear() + i;
  this.data.noSolar = averageBill * increaseRate;
  this.data.withSolar = (contractAmount * .004) + customerCharge;
  this.data.saving = (contractAmount * .004 + customerCharge) * 12 - (averageBill * 12);
  this.data.check = SREC;
  this.data.total = (contractAmount * .004 + customerCharge) * 12 - (averageBill * 12) + SREC;

  this.dataSource.push(this.data);
}

The Year in this case 2020 is showing twice. I want something like 2019 and 2020. Its like the variable is being reference multiple times.

Body:
Reference of object is pushed in array. Instead clone or create copy and then push

    const temp = {};
    for (let i = 0; i < 2; i++) {
      this.data.year = new Date().getFullYear() + i;
      this.data.noSolar = averageBill * increaseRate;
      this.data.withSolar = (contractAmount * .004) + customerCharge;
      this.data.saving = (contractAmount * .004 + customerCharge) * 12 - (averageBill * 12);
      this.data.check = SREC;
      this.data.total = (contractAmount * .004 + customerCharge) * 12 - (averageBill * 12) + SREC;
      // this.dataSource.push(...this.data)
      Object.assign(temp, this.data);
      this.dataSource.push(temp);
    };


问:
why is my page reloading even when i am not calling reload()?
I am having a collapse component which is dynamic list of arrays. However, this collapse component has 3 features as "compare", "edit" and "delete".

Edit routes to a new screen which is working, however compare is a modal (Popup) but the problem is when i click on the icon, flag sets to true but at the same time refresh the screen which makes flag go back to its default value of false, hence popup does not Open. Can someone help me where is the issue? TIA

I tried to invoke shouldComponentUpdate method, but it doesnt help. I am checking boolean state value of visibleModal in which case if its true i return false else i will return true. Although, i am condition becomes true, but i see page getting refreshed.

```<code>      recipes = data.map((recipe, i) => {
        return  this.state.dataReceived === true ? ( <div>
          <Col span={24}>
            <Collapse accordion>
              <Panel header={recipe.BASELINE_NAME} >
                {recipe.RUN_BASELINE.map((runs) => (
                <div>
                    <div style={{ marginLeft: "1em", padding: "0.8em", backgroundColor: "#a09f9f", height: "54px", borderRadius: "5px" }}>
                      <Col span={18}>
                        <Icon type="star" style={{ fontSize: "18px" }} /><a href={hrefdata} id={runs} name={recipe.BASELINE_NAME} style={{ marginTop: "-1em", marginLeft: "1em", color: "#fff", fontSize: "18px",fontFamily: "OpenSans" }} onClick={this.run}><strong>{runs}</strong></a>
                      </Col>
                    <Col span={6}>
                      <div style={{ display: "inline-block", marginLeft: "60%" }}>
                        <a href="" onClick={this.showModalNow} name="swap"><Icon type="swap" style={{ color: "#000", fontSize: "18px" }}></Icon></a>
                        <a href={hrefdata1} onClick={this.showCreate} name="edit" id={runs} name={recipe.BASELINE_NAME}><Icon type="edit" style={{ color: "#000", fontSize: "18px", marginLeft: "1em" }}></Icon></a>
                        <a href="" onClick={this.delete} id={runs} name="dash" ><Icon type="delete" style={{ color: "#000", fontSize: "18px", marginLeft: "1em" }}></Icon></a>
                      </div>
                    </Col>
                  </div><br></br>
                </div>
                ))}
                <div style={{ borderStyle: "dotted", marginLeft: "1em", padding: "0.5em", height: "54px", borderRadius: "5px" }}>
                  <a href={hrefdata2} onClick={this.create} id={recipe.BASELINE_NAME} title="Create New Scenario"><strong style={{ fontSize: "18px", marginLeft: "1.5em", fontFamily:"OpenSans",color:"#c7c7c7" }}>CREATE NEW SCENARIO</strong></a>
                </div>

              </Panel>
            </Collapse><br></br>
          </Col>
          <Modal
                  visible={this.state.visibleModal}
                  title="Compare Scenario"
                  style={{ top: 20 }}
                  onCancel={this.handleCancelNow}
                  footer={[
                    <Button key="back" onClick={this.handleCancelNow}>Cancel</Button>,
                    <Button key="submit" type="primary"  onClick={this.handleOk} disabled={this.state.flag}>
                      Compare
                    </Button>,
                  ]}
                >
                  <div style={{ marginTop: "6em" }}>
                  </div>
                </Modal>
        </div>) : (<LoadingSpinner message={"Please wait while we load the data.."}/>)
      }
</code>```

答:
Remove key="submit" it treats the modal as a form.
But if you really want to use it in , The function this.handleOk should be on onSubmit prop of form.
<form onSubmit={e => this.handleOk(e)}>
then on your handleOk function, you should add e.preventDefault(); to prevent the page from reloading.
See the sample below:

```<code>handleOk = e => {
 //Prevent page reload
 e.preventDefault();
...so on
</code>```

Body:
I am having a collapse component which is dynamic list of arrays. However, this collapse component has 3 features as "compare", "edit" and "delete".

Edit routes to a new screen which is working, however compare is a modal (Popup) but the problem is when i click on the icon, flag sets to true but at the same time refresh the screen which makes flag go back to its default value of false, hence popup does not Open. Can someone help me where is the issue? TIA

I tried to invoke shouldComponentUpdate method, but it doesnt help. I am checking boolean state value of visibleModal in which case if its true i return false else i will return true. Although, i am condition becomes true, but i see page getting refreshed.

      recipes = data.map((recipe, i) => {
        return  this.state.dataReceived === true ? (

          <Col span={24}>
            <Collapse accordion>
              <Panel header={recipe.BASELINE_NAME} >
                {recipe.RUN_BASELINE.map((runs) => (

                      <Col span={18}>
                        <Icon type="star" style={{ fontSize: "18px" }} />{runs}
                      </Col>
                    <Col span={6}>

                        <Icon type="swap" style={{ color: "#000", fontSize: "18px" }}></Icon>
                        <Icon type="edit" style={{ color: "#000", fontSize: "18px", marginLeft: "1em" }}></Icon>
                        <Icon type="delete" style={{ color: "#000", fontSize: "18px", marginLeft: "1em" }}></Icon>

                    </Col>

                ))}

                  CREATE NEW SCENARIO

              </Panel>
            </Collapse>

          </Col>
          <Modal
                  visible={this.state.visibleModal}
                  title="Compare Scenario"
                  style={{ top: 20 }}
                  onCancel={this.handleCancelNow}
                  footer={[
                    <Button key="back" onClick={this.handleCancelNow}>Cancel</Button>,
                    <Button key="submit" type="primary"  onClick={this.handleOk} disabled={this.state.flag}>
                      Compare
                    </Button>,
                  ]}
                >

                </Modal>

) : (<LoadingSpinner message={"Please wait while we load the data.."}/>)
      }

Body:
Remove key="submit" it treats the modal as a form.
But if you really want to use it in , The function this.handleOk should be on onSubmit prop of form.
<form onSubmit={e => this.handleOk(e)}>
then on your handleOk function, you should add e.preventDefault(); to prevent the page from reloading.
See the sample below:

handleOk = e => {
 //Prevent page reload
 e.preventDefault();
...so on


问:
Telerik RadTabStrip doesn't render correctly when loaded via AJAX
I'm loading a user control dynamically and displaying it using a RadAjaxPanel. The problem is that my RadTabStrip doesn't render correctly. The skin hasn't been applied and I only see part of the text. If I do a complete refresh of the page then it displays perfectly fine and from that point on it will render correctly even if I load it with AJAX again (until I open up a new browser window and start again).

This symptom is also evident with the RadDatePicker (skin not rendering correctly on initial AJAX load).

Any help will be much appreciated!

Dave.

P.S. I should point out that I'm using this line of code to force the RadAjaxPanel to refresh and it's only then that the problem is experienced:

```<code>pnlAjax.ResponseScripts.Add(String.Format("$find('{0}').ajaxRequest();", pnlAjax.ClientID));
</code>```

答: Haven´t used the RadAjax-stuff but using jquery ($.ajax) I got it working just by setting RegisterWithScriptManager="false". Maybe helps someone...</p>

ContentLicense: CC BY-SA 2.5

Body:
I'm loading a user control dynamically and displaying it using a RadAjaxPanel. The problem is that my RadTabStrip doesn't render correctly. The skin hasn't been applied and I only see part of the text. If I do a complete refresh of the page then it displays perfectly fine and from that point on it will render correctly even if I load it with AJAX again (until I open up a new browser window and start again).

This symptom is also evident with the RadDatePicker (skin not rendering correctly on initial AJAX load).

Any help will be much appreciated!

Dave.

P.S. I should point out that I'm using this line of code to force the RadAjaxPanel to refresh and it's only then that the problem is experienced:

pnlAjax.ResponseScripts.Add(String.Format("$find('{0}').ajaxRequest();", pnlAjax.ClientID));

ContentLicense: CC BY-SA 3.0


问:
Formatting csv file with python
I have a csv file with the following structure:

```<code>"txNomeParlamentar";"ideCadastro";"nuCarteiraParlamentar";"nuLegislatura";"sgUF"
"AVANTE;1;1;2015;PP"
</code>```

I need him to stay like this:

```<code>"txNomeParlamentar";"ideCadastro";"nuCarteiraParlamentar";"nuLegislatura";"sgUF"
"AVANTE";"1";"1";"2015";"PP"
</code>```

I received this .csv file from someone else, so I do not know how the conversion was done. I am trying unsuccessfully with the code below:

```<code>input_fd = open("/home/gustavo/Downloads/Redes/Despesas/csvfile.csv", 'r')
output_fd = open('dados_2018_1.csv', 'w')
for line in input_fd.readlines():
    line.replace("\"","")
    output_fd.write(line)
    input_fd.close()
output_fd.close()
</code>```

Is it possible to make this change or will I have to do the conversion from an xml file to a csv, and make this change during the conversion?

答:
Using csv module.

Ex:

```<code>import csv

with open(filename) as csvfile:
    reader = csv.reader(csvfile, delimiter=";")
    headers = next(reader)    #Read Headers
    data = [row.strip('"').split(";") for row in csvfile]    #Format data

with open(filename, "w") as csvfile_out:
    writer = csv.writer(csvfile_out, delimiter=";")
    writer.writerow(headers)   #Write Headers
    writer.writerows(data)     #Write data
</code>```

Title: Formatting csv file with python

Body:
I have a csv file with the following structure:

"txNomeParlamentar";"ideCadastro";"nuCarteiraParlamentar";"nuLegislatura";"sgUF"
"AVANTE;1;1;2015;PP"

I need him to stay like this:

"txNomeParlamentar";"ideCadastro";"nuCarteiraParlamentar";"nuLegislatura";"sgUF"
"AVANTE";"1";"1";"2015";"PP"

I received this .csv file from someone else, so I do not know how the conversion was done. I am trying unsuccessfully with the code below:

input_fd = open("/home/gustavo/Downloads/Redes/Despesas/csvfile.csv", 'r')
output_fd = open('dados_2018_1.csv', 'w')
for line in input_fd.readlines():
    line.replace("\"","")
    output_fd.write(line)
    input_fd.close()
output_fd.close()

Is it possible to make this change or will I have to do the conversion from an xml file to a csv, and make this change during the conversion?

Body:
Using csv module.

Ex:

import csv

with open(filename) as csvfile:
    reader = csv.reader(csvfile, delimiter=";")
    headers = next(reader)    #Read Headers
    data = [row.strip('"').split(";") for row in csvfile]    #Format data

with open(filename, "w") as csvfile_out:
    writer = csv.writer(csvfile_out, delimiter=";")
    writer.writerow(headers)   #Write Headers
    writer.writerows(data)     #Write data


答:
A new object should be created on each iteration. You are referring to the same object every time.

You can do like this,

```<code>for (let i = 0; i < 2; i++) {
  this.dataSource.push({
     year : new Date().getFullYear() + i,
     noSolar : averageBill * increaseRate,
     withSolar : (contractAmount * .004) + customerCharge,
     saving : (contractAmount * .004 + customerCharge) * 12 - (averageBill * 12),
     check : SREC,
     total : (contractAmount * .004 + customerCharge) * 12 - (averageBill * 12) + SREC,
  });
}
</code>```

or do like,

```<code>for (let i = 0; i < 2; i++) {
      this.data=new DataSourceObject();
      this.data.year = new Date().getFullYear() + i;
      this.data.noSolar = averageBill * increaseRate;
      this.data.withSolar = (contractAmount * .004) + customerCharge;
      this.data.saving = (contractAmount * .004 + customerCharge) * 12 - (averageBill * 12);
      this.data.check = SREC;
      this.data.total = (contractAmount * .004 + customerCharge) * 12 - (averageBill * 12) + SREC;

      this.dataSource.push(this.data);
    }
</code>```

Title: Javascript My Array Push is only getting the last value

Body:
A new object should be created on each iteration. You are referring to the same object every time.

You can do like this,

for (let i = 0; i < 2; i++) {
  this.dataSource.push({
     year : new Date().getFullYear() + i,
     noSolar : averageBill * increaseRate,
     withSolar : (contractAmount * .004) + customerCharge,
     saving : (contractAmount * .004 + customerCharge) * 12 - (averageBill * 12),
     check : SREC,
     total : (contractAmount * .004 + customerCharge) * 12 - (averageBill * 12) + SREC,
  });
}

or do like,

for (let i = 0; i < 2; i++) {
      this.data=new DataSourceObject();
      this.data.year = new Date().getFullYear() + i;
      this.data.noSolar = averageBill * increaseRate;
      this.data.withSolar = (contractAmount * .004) + customerCharge;
      this.data.saving = (contractAmount * .004 + customerCharge) * 12 - (averageBill * 12);
      this.data.check = SREC;
      this.data.total = (contractAmount * .004 + customerCharge) * 12 - (averageBill * 12) + SREC;

      this.dataSource.push(this.data);
    }


问:
How to Prevent the Beautify Extension from Formatting Inline Javascript?
I want the ESLint extension to be the only formatter inside inline Javascript. Beautify just screws it up and I have to correct it manually.

I have added these lines to my .jsbeautifyrc file:

```<code>    "format.contentUnformatted": "script",
    "format.unformatted": "script",
</code>```

But it has no effect: Beautify still formats every line in the html file. What am I overlooking?

答:
According to documentation it should be something like:

```<code>{
  "unformatted": ["script"]
}
</code>```

If that does not work, then maybe with the language setting this might work.

You can control which file types, extensions, or specific file names should be beautified with the beautify.language setting.

  ```<code>{
 "beautify.language": {
   "js": {
     "type": ["javascript", "json"],
     "filename": [".jshintrc", ".jsbeautifyrc"]
     // "ext": ["js", "json"]
     // ^^ to set extensions to be beautified using the javascript beautifier
   },
   "css": ["css", "scss"],
   "html": ["htm", "html"]
   // ^^ providing just an array sets the VS Code file type
 }
}
</code>```

Above configuration should enable formatting only on specified .js files.

Good luck.

Body:
I want the ESLint extension to be the only formatter inside inline Javascript. Beautify just screws it up and I have to correct it manually.

I have added these lines to my .jsbeautifyrc file:

    "format.contentUnformatted": "script",
    "format.unformatted": "script",

But it has no effect: Beautify still formats every line in the html file. What am I overlooking?

Body:
According to documentation it should be something like:

{
  "unformatted": ["script"]
}

If that does not work, then maybe with the language setting this might work.

You can control which file types, extensions, or specific file names should be beautified with the beautify.language setting.

{
 "beautify.language": {
   "js": {
     "type": ["javascript", "json"],
     "filename": [".jshintrc", ".jsbeautifyrc"]
     // "ext": ["js", "json"]
     // ^^ to set extensions to be beautified using the javascript beautifier
   },
   "css": ["css", "scss"],
   "html": ["htm", "html"]
   // ^^ providing just an array sets the VS Code file type
 }
}

Above configuration should enable formatting only on specified .js files.

Good luck.


答:
You can try below -</p>

```<code>select rank, name, max(case when rank=1 then value end) as valA,
max(case when rank=2 then value end) as valB
from
(
select * from tablename
where rank in (1,2)
group by id, value, name, rank
having count(distinct rank)=2
)X group by rank, name
</code>```

Title: Pivot over rank'ed table

Body:
Trying to effectively convert an existing table with a rank over partition column, into a columnar only when there is a rank of 1 and more.  Here's my data:

   -------------------------------------
   | Id | Value  | Name          | rank|
   -------------------------------------
   | 1  | 1234   | John          |1    |
   | 2  | 3456   | John          |2    |
   | 3  | 9999   | Chris         |1    |
   | 4  | 9801   | Joe           |1    |
   | 5  | 1287   | Joe           |2    |
   _____________________________________

What I'm trying to arrive at:

   -------------------------------------
   |       ValA  | ValB     | Name     |
   -------------------------------------
   | 1  | 1234   | 3456    | John      |
   | 2  | 9801   | 1287    | Joe       |
   -------------------------------------

Tried a few versions of pivot but I feel like I'm missing something.  The key is dropping any rows where rank is only 1, and if I have a 1 & 2, to convert those.

Body:
You can try below -

select rank, name, max(case when rank=1 then value end) as valA,
max(case when rank=2 then value end) as valB
from
(
select * from tablename
where rank in (1,2)
group by id, value, name, rank
having count(distinct rank)=2
)X group by rank, name


问:
RecyclerView cutting off last item

We can see here last item is partially visible. How can i fix this?
layout.xml

```<code><?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    android:id="@+id/coordinator_layout"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fitsSystemWindows="true">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <include
                layout="@layout/header"
                android:fitsSystemWindows="true"
                app:layout_collapseMode="parallax"/>

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
        </android.support.design.widget.CollapsingToolbarLayout>
    </android.support.design.widget.AppBarLayout>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycler_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

</android.support.design.widget.CoordinatorLayout>
</code>```

list_item.xml

```<code><?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@color/grey_background">

    <ImageView
        android:id="@+id/image"
        android:layout_width="@dimen/thumbnail_width"
        android:layout_height="@dimen/thumbnail_height"
        android:layout_gravity="center"
        android:adjustViewBounds="true"
        android:scaleType="fitCenter"/>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_toRightOf="@id/image"
        android:orientation="vertical"
        android:padding="@dimen/participant_left_padding">

        <TextView
            android:id="@+id/participants_name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="name"
            android:textColor="@android:color/white"/>

        <TextView
            android:id="@+id/total_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="view"
            android:textColor="@android:color/white"/>

        <TextView
            android:id="@+id/ranking"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="ranking"
            android:textColor="@android:color/white"/>
    </LinearLayout>

    <ImageView
        android:id="@+id/overflow"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:src="@drawable/ic_action_overflow"/>
</RelativeLayout>
</code>```

答:
I tried all the available option from most of possible site but I didn't get the solution.
Then, I think can I use bottom padding? And Yes, It's work for me.

I am sharing the code to you.
Nothing more attribute required other than height, width & padding.

android:paddingBottom="?attr/actionBarSize"

```<code> <android.support.v7.widget.RecyclerView
    android:id="@+id/your id name"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingBottom="?attr/actionBarSize"
    app:layout_constraintTop_toBottomOf="@+id/your field" />
</code>```

Title: RecyclerView cutting off last item

Body:
We can see here last item is partially visible. How can i fix this?
layout.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    android:id="@+id/coordinator_layout"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fitsSystemWindows="true">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <include
                layout="@layout/header"
                android:fitsSystemWindows="true"
                app:layout_collapseMode="parallax"/>

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
        </android.support.design.widget.CollapsingToolbarLayout>
    </android.support.design.widget.AppBarLayout>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycler_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

</android.support.design.widget.CoordinatorLayout>

list_item.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@color/grey_background">

    <ImageView
        android:id="@+id/image"
        android:layout_width="@dimen/thumbnail_width"
        android:layout_height="@dimen/thumbnail_height"
        android:layout_gravity="center"
        android:adjustViewBounds="true"
        android:scaleType="fitCenter"/>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_toRightOf="@id/image"
        android:orientation="vertical"
        android:padding="@dimen/participant_left_padding">

        <TextView
            android:id="@+id/participants_name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="name"
            android:textColor="@android:color/white"/>

        <TextView
            android:id="@+id/total_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="view"
            android:textColor="@android:color/white"/>

        <TextView
            android:id="@+id/ranking"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="ranking"
            android:textColor="@android:color/white"/>
    </LinearLayout>

    <ImageView
        android:id="@+id/overflow"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:src="@drawable/ic_action_overflow"/>
</RelativeLayout>

Body:
I tried all the available option from most of possible site but I didn't get the solution.
Then, I think can I use bottom padding? And Yes, It's work for me.

I am sharing the code to you.
Nothing more attribute required other than height, width & padding.

android:paddingBottom="?attr/actionBarSize"

 <android.support.v7.widget.RecyclerView
    android:id="@+id/your id name"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingBottom="?attr/actionBarSize"
    app:layout_constraintTop_toBottomOf="@+id/your field" />


问:
How to disable/enable submit button based on Datepicker selected date?
I have a simple form that contains one submit button and 2 input text, that call "date1" and "date2" and both are using DatePicker Gijgo plugin (https://gijgo.com/datepicker) to select date.

I would like to disable submit button if i select date from "date2" that is less than today and enable submit button if i select date from "data2" that is greater/equal than today.

Before i post here, i researched the topics below, but i didn't find the correct way to solve this:

JQuery Datepicker OnSelect and TextChanged problem

Activate button when two datepickers fields have values

jQuery disable or enable submit button based on dates

Below is the code that i'm working:

1. CDN Scripts

```<code><!-- BOOTSTRAP CSS CDN -->

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" />

<!-- BOOTSTRAP SCRIPT CDN -->

<script src="https://code.jquery.com/jquery-3.4.0.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>

<!-- DATEPICKER SCRIPT CDN -->

<script src="https://unpkg.com/gijgo@1.9.13/js/gijgo.min.js" type="text/javascript"></script>
<link href="https://unpkg.com/gijgo@1.9.13/css/gijgo.min.css" rel="stylesheet" type="text/css" />

</code>```

2. HTML form code

```<code><div class="container" style="max-width:507px;">
<br>
<form method="post" id="date_form" enctype="multipart/form-data">

<div class="form-row">

<div class="col-md-6 mb-3">
<label align="left"><b>Date 1</b></label>
<input type="text" name="date1" id="date1" class="form-control"/>

</div>

<div class="col-md-6 mb-3">
<label align="left"><b>Date 2</b></label>
<input type="text" name="date2" id="date2" class="form-control"/>

</div>

</div>

</form>

<div class="form-footer">
<input type="submit" id="btnSubmit" name="btnSubmit" class="btn btn-success" value="SUBMIT" disabled/>
</div>
</div>
</code>```

DatePicker script that disable old date from "date2" before the date that was selected at "date1":

```<code>
<!-- DATEPICKER SCRIPT -->

<script>

var today = new Date();
        $('#date1').datepicker({
            format: 'dd/mm/yyyy',
            uiLibrary: 'bootstrap4',
            iconsLibrary: 'fontawesome',
            maxDate: function () {
                return $('#date2').val();
            }
        });
        $('#date2').datepicker({
            format: 'dd/mm/yyyy',
            uiLibrary: 'bootstrap4',
            iconsLibrary: 'fontawesome',
            minDate: function () {
                return $('#date1').val();
            }
        });

</script>

</code>```

4. And finaly, the code that i'm trying to apply to disable submit button when i selected a date from "date2" that is less (<) than today, but unfortunately it doesn't works:

```<code><!-- SCRIPT TO DISABLE SUBMIT BUTTON IF ***date2*** IS LESS THAN TODAY -->

<script>

$('#date2').datepicker({
    dateFormat: 'dd/mm/yyyy',
    onSelect: function(dateText){
        var date2 = $('#date2').val();
            var curDate = new Date();
            if(date2 < curDate){
$("#btnSubmit").attr("disabled", true);
            }else{
$("#btnSubmit").attr("disabled", false);
            }
        }
});
</script>
</code>```

In this case, how can i modify this script above to disable submit button when i select each time a date from "date2" that is less than today and enable submit button when i select a date from "date2" that is greater/equal than today?

答:
You cant directly compare the dates. The date need to be formatted/parsed exactly into mm, dd, yyyy and then you need to check the conditions for the date and year specifically.

Also you dont need to use the datepicker two times on the same selector.

Please find the below script. I have tested this in the plunker and the date 2 is being formatted and validated exactly and also the submit button is working as expected. also you need use "change" not "onSelect"

```<code><script>

        $('#date1').datepicker({
            format: 'dd/mm/yyyy',
            uiLibrary: 'bootstrap4',
            iconsLibrary: 'fontawesome',
            maxDate: function () {
                return $('#date2').val();
            }
        });

        $('#date2').datepicker({
          dateFormat: 'dd/mm/yyyy',
          format: 'dd/mm/yyyy',
                  uiLibrary: 'bootstrap4',
                  iconsLibrary: 'fontawesome',
                  minDate: function () {
                      return $('#date1').val();
                  },
          change: function(dateText){

              var date2 = $('#date2').val();
              var curDate = new Date();

              var cur_dd = curDate.getDate();
              var cur_mm = curDate.getMonth() + 1; //January is 0!

              var cur_yyyy = parseInt(curDate.getFullYear());
              if (cur_dd < 10) {
                cur_dd = parseInt('0' + cur_dd);
              }
              if (cur_mm < 10) {
                cur_mm = parseInt('0' + cur_mm);
              }
              curDate = cur_dd + '/' + cur_mm + '/' + cur_yyyy;

              var date2Arr = date2.split('/');
              var date2_dd = date2Arr[0];
              var date2_mm = date2Arr[1];
              var date2_yyyy = parseInt(date2Arr[2]);

              if (date2_dd < 10) {
                date2_dd = parseInt('0' + date2_dd);
              }
              if (date2_mm < 10) {
                date2_mm = parseInt('0' + date2_mm);
              }
              date2 = date2_dd + '/' + date2_mm + '/' + date2_yyyy;

              if(date2_yyyy < cur_yyyy){
                $("#btnSubmit").attr("disabled", true);
              } else if(date2_yyyy === cur_yyyy && date2_mm <= cur_mm && date2_dd < cur_dd ) {
                $("#btnSubmit").prop("disabled", true);
              } else{
                $("#btnSubmit").prop("disabled", false);
              }
          }

        });
</script>
</code>```

Plunker URL:
https://plnkr.co/edit/brCcHutewGoZe2a1cdjl?p=preview

Body:
I have a simple form that contains one submit button and 2 input text, that call "date1" and "date2" and both are using DatePicker Gijgo plugin (https://gijgo.com/datepicker) to select date.

I would like to disable submit button if i select date from "date2" that is less than today and enable submit button if i select date from "data2" that is greater/equal than today.

Before i post here, i researched the topics below, but i didn't find the correct way to solve this:

JQuery Datepicker OnSelect and TextChanged problem

Activate button when two datepickers fields have values

jQuery disable or enable submit button based on dates

Below is the code that i'm working:

1. CDN Scripts

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" />

<link href="https://unpkg.com/gijgo@1.9.13/css/gijgo.min.css" rel="stylesheet" type="text/css" />

2. HTML form code

<form method="post" id="date_form" enctype="multipart/form-data">

Date 1
<input type="text" name="date1" id="date1" class="form-control"/>

Date 2
<input type="text" name="date2" id="date2" class="form-control"/>

</form>

<input type="submit" id="btnSubmit" name="btnSubmit" class="btn btn-success" value="SUBMIT" disabled/>

DatePicker script that disable old date from "date2" before the date that was selected at "date1":

4. And finaly, the code that i'm trying to apply to disable submit button when i selected a date from "date2" that is less (<) than today, but unfortunately it doesn't works:

In this case, how can i modify this script above to disable submit button when i select each time a date from "date2" that is less than today and enable submit button when i select a date from "date2" that is greater/equal than today?

Body:
You cant directly compare the dates. The date need to be formatted/parsed exactly into mm, dd, yyyy and then you need to check the conditions for the date and year specifically.

Also you dont need to use the datepicker two times on the same selector.

Please find the below script. I have tested this in the plunker and the date 2 is being formatted and validated exactly and also the submit button is working as expected. also you need use "change" not "onSelect"

<script>

        $('#date1').datepicker({
            format: 'dd/mm/yyyy',
            uiLibrary: 'bootstrap4',
            iconsLibrary: 'fontawesome',
            maxDate: function () {
                return $('#date2').val();
            }
        });

        $('#date2').datepicker({
          dateFormat: 'dd/mm/yyyy',
          format: 'dd/mm/yyyy',
                  uiLibrary: 'bootstrap4',
                  iconsLibrary: 'fontawesome',
                  minDate: function () {
                      return $('#date1').val();
                  },
          change: function(dateText){

              var date2 = $('#date2').val();
              var curDate = new Date();

              var cur_dd = curDate.getDate();
              var cur_mm = curDate.getMonth() + 1; //January is 0!

              var cur_yyyy = parseInt(curDate.getFullYear());
              if (cur_dd < 10) {
                cur_dd = parseInt('0' + cur_dd);
              }
              if (cur_mm < 10) {
                cur_mm = parseInt('0' + cur_mm);
              }
              curDate = cur_dd + '/' + cur_mm + '/' + cur_yyyy;

              var date2Arr = date2.split('/');
              var date2_dd = date2Arr[0];
              var date2_mm = date2Arr[1];
              var date2_yyyy = parseInt(date2Arr[2]);

              if (date2_dd < 10) {
                date2_dd = parseInt('0' + date2_dd);
              }
              if (date2_mm < 10) {
                date2_mm = parseInt('0' + date2_mm);
              }
              date2 = date2_dd + '/' + date2_mm + '/' + date2_yyyy;

              if(date2_yyyy < cur_yyyy){
                $("#btnSubmit").attr("disabled", true);
              } else if(date2_yyyy === cur_yyyy && date2_mm <= cur_mm && date2_dd < cur_dd ) {
                $("#btnSubmit").prop("disabled", true);
              } else{
                $("#btnSubmit").prop("disabled", false);
              }
          }

        });
</script>

Plunker URL:
https://plnkr.co/edit/brCcHutewGoZe2a1cdjl?p=preview


问:
Azure Application Gateway/WAF has never been reported to Azure Security Center
The Application Gateway has automatically detected by Azure Security center but not showing the health status. Below is the message I got from the portal:

Partner solution name: Application Gateway

Type: Saas-based Web Application Firewall

Integration mode: Semi-automatically provisioned

Status: Not reported

Status has never been reported to Azure Security Center. Usually, this means that this security solution isn't configured yet. It is recommended you login to the security solution management console to finalize the initial configuration

NSG has configured as per the MS documentation.

答:
Azure Security Center's Security Solution doesn't support WAFv2. Currently WAF (V1 SKU) is supported and you will be able to connect from there. </p>

<p>It is a known issue and public documentation will be updated soon to reflect this information. </p>

Body:
Azure Security Center's Security Solution doesn't support WAFv2. Currently WAF (V1 SKU) is supported and you will be able to connect from there.

It is a known issue and public documentation will be updated soon to reflect this information.


问:
How to convert interger to time while the interger is actually time data but no separation
I have data that contains time data but in integer type and have no separation between the integer.
my data like = [91310, 101012, ...]  in fact it's suppose to be ["9:13:10", "10:10:12"]

how to convert that into time format

答:
You can use simple math operations to get the hours, minutes and seconds from your integer values. Then you can format them however you please (either into a string with appropriate colons, or into something like a datetime.time object).

```<code>import datetime

results = []
dt_results = []
for n in data:
    hours = n // 10000
    minutes = n // 100 % 100
    seconds = n % 100
    results.append(f'{hours:02}:{minutes:02}:{seconds:02}')
    dt_results.append(datetime.time(hour=hours, minute=minutes, second=seconds))
</code>```

If you don't want a leading zero on hours in the string results, remove the first :02 from the format string. If you only want one of the results, you could pretty easily put the computations for the hours minutes and seconds inline into the format string or datetime.time call, and so turn the whole loop into a list comprehension:

```<code>results = [f'{n // 10000:02}:{n // 100 % 100:02}:{n % 100:02}' for n in data]
</code>```

Body:
You can use simple math operations to get the hours, minutes and seconds from your integer values. Then you can format them however you please (either into a string with appropriate colons, or into something like a datetime.time object).

import datetime

results = []
dt_results = []
for n in data:
    hours = n // 10000
    minutes = n // 100 % 100
    seconds = n % 100
    results.append(f'{hours:02}:{minutes:02}:{seconds:02}')
    dt_results.append(datetime.time(hour=hours, minute=minutes, second=seconds))

If you don't want a leading zero on hours in the string results, remove the first :02 from the format string. If you only want one of the results, you could pretty easily put the computations for the hours minutes and seconds inline into the format string or datetime.time call, and so turn the whole loop into a list comprehension:

results = [f'{n // 10000:02}:{n // 100 % 100:02}:{n % 100:02}' for n in data]


问:
Button next to my entry always shows below the entry
I have a blog I am building with entries. I have a form with hidden variables to submit the entryID and other data to "delete" the post.  The button always shows below the entry, instead of beside it.

I have tried using CSS Clear, and putting everything in a single
 line to see if that helps. I feel like the issue is that there is a form with hidden variables, but I'm not sure how to fix this.

```<code> <div id="subformposts">
    <?php echo $subentry['Body']; ?>
    <?php echo $subentry['CreateDate']; ?> - <?php echo $subentry['UserName']; ?><br />

<!-- Determine whether to show the delete button -->
<form action="Delete_entry.php" method="post" id="Deletesub<?php echo $subentry['EntryID'];?>" onsubmit="return confirmdelete('Deletesub<?php echo $subentry['EntryID'];?>')">
        <input type="hidden" readonly="true" name="EntryID" value="<?php echo $subentry['EntryID']; ?>" />
        <input type="hidden" readonly="true" name="UserID" value="<?php echo $subentry['UserID']; ?>" />
        <?php if ($userid == 1 || $userid == $res['UserID']) { ?>
        <input type="image" src="redx.png" alt="Delete Post" id="btnDelete" value="Delete Post" />
    <?php } ?>
</form>
</div>
</code>```

I want to see the button floating to the right of my entry, (or to the left at this point.) If I could have it tucked into the div that would be great.

答:
You can use display: inline-flex on subformposts.

Like this one :

```<code><div id="subformposts" style="display: inline-flex;">
<?php echo $subentry['Body']; ?>
<?php echo $subentry['CreateDate']; ?> - <?php echo $subentry['UserName']; ?><br />

<!-- Determine whether to show the delete button -->
<form action="Delete_entry.php" method="post" id="Deletesub<?php echo
$subentry['EntryID'];?>" onsubmit="return confirmdelete('Deletesub<?php echo $subentry['EntryID'];?>')">
    <input type="hidden" readonly="true" name="EntryID" value="<?php echo $subentry['EntryID']; ?>" />
    <input type="hidden" readonly="true" name="UserID" value="<?php echo $subentry['UserID']; ?>" />
    <?php if ($userid == 1 || $userid == $res['UserID']) { ?>
    <input type="image" src="redx.png" alt="Delete Post" id="btnDelete" value="Delete Post" />
<?php } ?>
</form>
</div>
</code>```

Or you can keep both in two different div and put display:inline-block on both of those div. Like this .

```<code> <div id="subformposts" style="display: inline-block;">
 <?php echo $subentry['Body']; ?>
 <?php echo $subentry['CreateDate']; ?> - <?php echo $subentry['UserName']; ?><br />
</div>
<div style="display: inline-block;">
<!-- Determine whether to show the delete button -->
 <form action="Delete_entry.php" method="post" id="Deletesub<?php echo
 $subentry['EntryID'];?>" onsubmit="return confirmdelete('Deletesub<?php echo $subentry['EntryID'];?>')">
<input type="hidden" readonly="true" name="EntryID" value="<?php echo
$subentry['EntryID']; ?>" />
<input type="hidden" readonly="true" name="UserID" value="<?php echo
$subentry['UserID']; ?>" />
<?php if ($userid == 1 || $userid == $res['UserID']) { ?>
<input type="image" src="redx.png" alt="Delete Post" id="btnDelete" value="Delete Post" />
<?php } ?>
</form>
</div>
</code>```

Body:
I have a blog I am building with entries. I have a form with hidden variables to submit the entryID and other data to "delete" the post.  The button always shows below the entry, instead of beside it.

I have tried using CSS Clear, and putting everything in a single
 line to see if that helps. I feel like the issue is that there is a form with hidden variables, but I'm not sure how to fix this.

    <?php echo $subentry['Body']; ?>
    <?php echo $subentry['CreateDate']; ?> - <?php echo $subentry['UserName']; ?>

<form action="Delete_entry.php" method="post" id="Deletesub<?php echo $subentry['EntryID'];?>" onsubmit="return confirmdelete('Deletesub<?php echo $subentry['EntryID'];?>')">
        <input type="hidden" readonly="true" name="EntryID" value="<?php echo $subentry['EntryID']; ?>" />
        <input type="hidden" readonly="true" name="UserID" value="<?php echo $subentry['UserID']; ?>" />
        <?php if ($userid == 1 || $userid == $res['UserID']) { ?>
        <input type="image" src="redx.png" alt="Delete Post" id="btnDelete" value="Delete Post" />
    <?php } ?>
</form>

I want to see the button floating to the right of my entry, (or to the left at this point.) If I could have it tucked into the div that would be great.

Body:
You can use display: inline-flex on subformposts.

Like this one :

<div id="subformposts" style="display: inline-flex;">
<?php echo $subentry['Body']; ?>
<?php echo $subentry['CreateDate']; ?> - <?php echo $subentry['UserName']; ?><br />

<!-- Determine whether to show the delete button -->
<form action="Delete_entry.php" method="post" id="Deletesub<?php echo
$subentry['EntryID'];?>" onsubmit="return confirmdelete('Deletesub<?php echo $subentry['EntryID'];?>')">
    <input type="hidden" readonly="true" name="EntryID" value="<?php echo $subentry['EntryID']; ?>" />
    <input type="hidden" readonly="true" name="UserID" value="<?php echo $subentry['UserID']; ?>" />
    <?php if ($userid == 1 || $userid == $res['UserID']) { ?>
    <input type="image" src="redx.png" alt="Delete Post" id="btnDelete" value="Delete Post" />
<?php } ?>
</form>
</div>

Or you can keep both in two different div and put display:inline-block on both of those div. Like this .

 <div id="subformposts" style="display: inline-block;">
 <?php echo $subentry['Body']; ?>
 <?php echo $subentry['CreateDate']; ?> - <?php echo $subentry['UserName']; ?><br />
</div>
<div style="display: inline-block;">
<!-- Determine whether to show the delete button -->
 <form action="Delete_entry.php" method="post" id="Deletesub<?php echo
 $subentry['EntryID'];?>" onsubmit="return confirmdelete('Deletesub<?php echo $subentry['EntryID'];?>')">
<input type="hidden" readonly="true" name="EntryID" value="<?php echo
$subentry['EntryID']; ?>" />
<input type="hidden" readonly="true" name="UserID" value="<?php echo
$subentry['UserID']; ?>" />
<?php if ($userid == 1 || $userid == $res['UserID']) { ?>
<input type="image" src="redx.png" alt="Delete Post" id="btnDelete" value="Delete Post" />
<?php } ?>
</form>
</div>


问:
RecyclerView is cutting off the last item
I have a fragment with a toolbar and a recyclerView inside it.

I am populating the recyclerView with dummy data and then try to show them. For some reason, the last element of the recyclerView is getting cut-off.

This is the XML of the fragment:

```<code><?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/background_1"
    android:fitsSystemWindows="true">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar_layout"
        android:layout_width="match_parent"
        android:layout_height="@dimen/height_of_app_bar"
        android:fitsSystemWindows="true"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:contentScrim="@color/primary"
            app:expandedTitleMarginEnd="64dp"
            app:expandedTitleMarginStart="48dp"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <ImageView
                android:id="@+id/backdrop"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fitsSystemWindows="true"
                android:scaleType="centerCrop"
                android:src="@drawable/placeholder_rect_header"
                app:layout_collapseMode="parallax"/>

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>

        </android.support.design.widget.CollapsingToolbarLayout>

    </android.support.design.widget.AppBarLayout>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/simpleList"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

</android.support.design.widget.CoordinatorLayout>
</code>```

The items at the list are really simple ones:

```<code><?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="200dp"
    android:background="@color/background_1"
    android:orientation="horizontal"
    android:padding="@dimen/space_for_a_bit_of_air">

    <ImageView
        android:id="@+id/album_cover"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_gravity="center_vertical"
        android:scaleType="fitXY"
        android:src="@drawable/placeholder_album_cover"/>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:layout_marginLeft="@dimen/space_for_distinguishing_stuff"
        android:orientation="vertical">

        <TextView
            android:id="@+id/album_title"
            style="@style/titleText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/sample_text_c"/>

        <TextView
            android:id="@+id/album_year"
            style="@style/subtitleText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/sample_text_a"/>

    </LinearLayout>

</LinearLayout>
</code>```

I am now at the end of the list, but the last element still looks cut-off.

I am using the latest version as of 2015-09-23 of google libraries, 23.0.1, (i.e. com.android.support:recyclerview-v7:23.0.1), and the following configuration at the build.gradle:

```<code>compileSdkVersion 23
buildToolsVersion "23.0.1"

defaultConfig {
   minSdkVersion 14
   targetSdkVersion 23
   versionCode 1
   versionName "1.0"

   multiDexEnabled true// Enabling multidex support
 }
</code>```

Any help would be greatly appreciated since I am going nuts with this problem :(

SOLUTION

Ok, after cleaning the code to the bare essentials and removing complexity, I found the problem: it was a combination of wrong flags and missing or extra attributes. The following works fine for both Android 4.x and 5.x:

```<code><?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/background_1"
    android:fitsSystemWindows="true">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar_layout"
        android:layout_width="match_parent"
        android:layout_height="@dimen/height_of_app_bar"
        android:fitsSystemWindows="true">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:collapsedTitleTextAppearance="@style/Title.collapsed"
            app:contentScrim="@color/primary"
            app:expandedTitleMarginStart="48dp"
            app:expandedTitleTextAppearance="@style/Title.Expanded"
            app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed">

            <ImageView
                android:id="@+id/backdrop"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fitsSystemWindows="true"
                android:scaleType="centerCrop"
                android:src="@drawable/artistic_4"
                app:layout_collapseMode="parallax"/>

            <View
                android:layout_width="match_parent"
                android:layout_height="@dimen/height_of_app_bar"
                android:background="@drawable/gradient"/>

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin"/>

        </android.support.design.widget.CollapsingToolbarLayout>

    </android.support.design.widget.AppBarLayout>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/simpleList"
        style="@style/genericRecyclerView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        tools:listitem="@layout/item_discography_album"/>

</android.support.design.widget.CoordinatorLayout>
</code>```

In a nutshell, android:fitsSystemWindows="true" should only be at the coordinatorLayout, AppBarLayout and theCollapsingToolbarLayout (which are the ones that we want to be adjusted based on the screen on Android 5.x), the app:layout_scrollFlags should be set to "scroll|enterAlways|enterAlwaysCollapsed" and the toolbar should have as height, the height of the actionBar. Finally, it's better to keep the RecyclerView as clean as possible so you can control the layout spacing at each line item.

Body:
I have a fragment with a toolbar and a recyclerView inside it.

I am populating the recyclerView with dummy data and then try to show them. For some reason, the last element of the recyclerView is getting cut-off.

This is the XML of the fragment:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/background_1"
    android:fitsSystemWindows="true">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar_layout"
        android:layout_width="match_parent"
        android:layout_height="@dimen/height_of_app_bar"
        android:fitsSystemWindows="true"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:contentScrim="@color/primary"
            app:expandedTitleMarginEnd="64dp"
            app:expandedTitleMarginStart="48dp"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <ImageView
                android:id="@+id/backdrop"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fitsSystemWindows="true"
                android:scaleType="centerCrop"
                android:src="@drawable/placeholder_rect_header"
                app:layout_collapseMode="parallax"/>

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>

        </android.support.design.widget.CollapsingToolbarLayout>

    </android.support.design.widget.AppBarLayout>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/simpleList"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

</android.support.design.widget.CoordinatorLayout>

The items at the list are really simple ones:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="200dp"
    android:background="@color/background_1"
    android:orientation="horizontal"
    android:padding="@dimen/space_for_a_bit_of_air">

    <ImageView
        android:id="@+id/album_cover"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_gravity="center_vertical"
        android:scaleType="fitXY"
        android:src="@drawable/placeholder_album_cover"/>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:layout_marginLeft="@dimen/space_for_distinguishing_stuff"
        android:orientation="vertical">

        <TextView
            android:id="@+id/album_title"
            style="@style/titleText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/sample_text_c"/>

        <TextView
            android:id="@+id/album_year"
            style="@style/subtitleText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/sample_text_a"/>

    </LinearLayout>

</LinearLayout>

I am now at the end of the list, but the last element still looks cut-off.

I am using the latest version as of 2015-09-23 of google libraries, 23.0.1, (i.e. com.android.support:recyclerview-v7:23.0.1), and the following configuration at the build.gradle:

compileSdkVersion 23
buildToolsVersion "23.0.1"

defaultConfig {
   minSdkVersion 14
   targetSdkVersion 23
   versionCode 1
   versionName "1.0"

   multiDexEnabled true// Enabling multidex support
 }

Any help would be greatly appreciated since I am going nuts with this problem :(

SOLUTION

Ok, after cleaning the code to the bare essentials and removing complexity, I found the problem: it was a combination of wrong flags and missing or extra attributes. The following works fine for both Android 4.x and 5.x:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/background_1"
    android:fitsSystemWindows="true">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar_layout"
        android:layout_width="match_parent"
        android:layout_height="@dimen/height_of_app_bar"
        android:fitsSystemWindows="true">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:collapsedTitleTextAppearance="@style/Title.collapsed"
            app:contentScrim="@color/primary"
            app:expandedTitleMarginStart="48dp"
            app:expandedTitleTextAppearance="@style/Title.Expanded"
            app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed">

            <ImageView
                android:id="@+id/backdrop"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fitsSystemWindows="true"
                android:scaleType="centerCrop"
                android:src="@drawable/artistic_4"
                app:layout_collapseMode="parallax"/>

            <View
                android:layout_width="match_parent"
                android:layout_height="@dimen/height_of_app_bar"
                android:background="@drawable/gradient"/>

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin"/>

        </android.support.design.widget.CollapsingToolbarLayout>

    </android.support.design.widget.AppBarLayout>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/simpleList"
        style="@style/genericRecyclerView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        tools:listitem="@layout/item_discography_album"/>

</android.support.design.widget.CoordinatorLayout>

In a nutshell, android:fitsSystemWindows="true" should only be at the coordinatorLayout, AppBarLayout and theCollapsingToolbarLayout (which are the ones that we want to be adjusted based on the screen on Android 5.x), the app:layout_scrollFlags should be set to "scroll|enterAlways|enterAlwaysCollapsed" and the toolbar should have as height, the height of the actionBar. Finally, it's better to keep the RecyclerView as clean as possible so you can control the layout spacing at each line item.


问:
Can I set a data breakpoint in runtime in System C (or in Plain Vanilla C++)?
I have a class in system-C with some data members as such:

```<code>long double x[8];
</code>```

I'm initializing it in the construction like this:

```<code>for (i = 0; i < 8; ++i) {
    x[i] = 0;
}
</code>```

But the first time I use it in my code I have garbage there.

Because of the way the system is built I can't connect a debugger easily.  Are there any methods to set a data breakpoint in the code so that it tells me where in the code the variables were actually changed, but without hooking up a debugger?

Edit:
@Prakash:
Actually, this is a typo in the question, but not in my code...  Thanks!

答:
Just use printk/syslog.

It's old-fashioned, but super duper easy.

OwnerDisplayName: Nathan Fellman

Body:
I have a class in system-C with some data members as such:

long double x[8];

I'm initializing it in the construction like this:

for (i = 0; i < 8; ++i) {
    x[i] = 0;
}

But the first time I use it in my code I have garbage there.

Because of the way the system is built I can't connect a debugger easily.  Are there any methods to set a data breakpoint in the code so that it tells me where in the code the variables were actually changed, but without hooking up a debugger?

Edit:
@Prakash:
Actually, this is a typo in the question, but not in my code...  Thanks!

LastEditorDisplayName: Nathan Fellman

OwnerDisplayName: Frank Krueger


问:
Scrapy can't manage to request text with neither CSS or xPath
I've been trying to extract some text for a while now, and while everything works fine, there is something I can't manage to get.

Take this website : https://duproprio.com/fr/montreal/pierrefonds-roxboro/condo-a-vendre/hab-305-5221-rue-riviera-854000

I want to get the texts from the class=listing-main-characteristics__number nodes (below the picture, the box with "2 chambres 1 salle de bain Aire habitable (s-sol exclu) 1,030 pi2 (95,69m2)", there are 3 elements with that class in the page ( "2", "1" and "1,030 pi² (95,69 m²)"). I've tried a bunch of options in XPath and CSS, but none has worked, some gave back strange answers.

For example, with :

```<code>response.xpath('//span[@class="listing-main-characteristics__number"]').getall()
</code>```

I get :

```<code>['<span class="listing-main-characteristics\_\_number">\n 2\n </span>', '<span class="listing-main-characteristics\_\_number">\n 1\n </span>']
</code>```

For example, something else that works just fine on the same webpage :

```<code>response.xpath('//div[@property="description"]/p/text()').getall()
</code>```

If I get all the spans with this query :

```<code>response.css('span::text').getall()
</code>```

I can find my texts mentioned in the beginning in the. But from this :

```<code>response.css('span[class=listing-main-characteristics__number]::text').getall()
</code>```

I only get this

```<code>['\n                        2\n                    ', '\n                        1\n                    ']
</code>```

Could someone clue me in with what kind of selection I would need? Thank you so much!

答:
Here is the xpath that you have to use.

```<code>//div[@data-label='#description']//div[@class='listing-main-characteristics__label']|//div[@data-label='#description']//div[@class='listing-main-characteristics__item-dimensions']/span[2]
</code>```

you might have to use the above xpath. (Add /text() is you want the associated text.)

```<code>response.xpath("//div[@data-label='#description']//div[@class='listing-main-characteristics__label']|//div[@data-label='#description']//div[@class='listing-main-characteristics__item-dimensions']/span[2]").getall()
</code>```

Below is the python sample code

```<code>url = "https://duproprio.com/fr/montreal/pierrefonds-roxboro/condo-a-vendre/hab-305-5221-rue-riviera-854000#description"
driver.get(url)
# get the output elements then we will get the text from them
outputs = driver.find_elements_by_xpath("//div[@data-label='#description']//div[@class='listing-main-characteristics__label']|//div[@data-label='#description']//div[@class='listing-main-characteristics__item-dimensions']/span[2]")
for output in outputs:
    # replace the new line character with space and trim the text
    print(output.text.replace("\n", ' ').strip())
</code>```

Output:

2 chambres

1 salle de bain

1,030 pi² (95,69 m²)

Screenshot:

Body:
I've been trying to extract some text for a while now, and while everything works fine, there is something I can't manage to get.

Take this website : https://duproprio.com/fr/montreal/pierrefonds-roxboro/condo-a-vendre/hab-305-5221-rue-riviera-854000

I want to get the texts from the class=listing-main-characteristics__number nodes (below the picture, the box with "2 chambres 1 salle de bain Aire habitable (s-sol exclu) 1,030 pi2 (95,69m2)", there are 3 elements with that class in the page ( "2", "1" and "1,030 pi² (95,69 m²)"). I've tried a bunch of options in XPath and CSS, but none has worked, some gave back strange answers.

For example, with :

response.xpath('//span[@class="listing-main-characteristics__number"]').getall()

I get :

['\n 2\n ', '\n 1\n ']

For example, something else that works just fine on the same webpage :

response.xpath('//div[@property="description"]/p/text()').getall()

If I get all the spans with this query :

response.css('span::text').getall()

I can find my texts mentioned in the beginning in the. But from this :

response.css('span[class=listing-main-characteristics__number]::text').getall()

I only get this

['\n                        2\n                    ', '\n                        1\n                    ']

Could someone clue me in with what kind of selection I would need? Thank you so much!

Body:
Here is the xpath that you have to use.

//div[@data-label='#description']//div[@class='listing-main-characteristics__label']|//div[@data-label='#description']//div[@class='listing-main-characteristics__item-dimensions']/span[2]

you might have to use the above xpath. (Add /text() is you want the associated text.)

response.xpath("//div[@data-label='#description']//div[@class='listing-main-characteristics__label']|//div[@data-label='#description']//div[@class='listing-main-characteristics__item-dimensions']/span[2]").getall()

Below is the python sample code

url = "https://duproprio.com/fr/montreal/pierrefonds-roxboro/condo-a-vendre/hab-305-5221-rue-riviera-854000#description"
driver.get(url)
# get the output elements then we will get the text from them
outputs = driver.find_elements_by_xpath("//div[@data-label='#description']//div[@class='listing-main-characteristics__label']|//div[@data-label='#description']//div[@class='listing-main-characteristics__item-dimensions']/span[2]")
for output in outputs:
    # replace the new line character with space and trim the text
    print(output.text.replace("\n", ' ').strip())

Output:

2 chambres

1 salle de bain

1,030 pi² (95,69 m²)

Screenshot:


问:
How could a Docker container get host process quit message?
We have two processes in our project, and they run in the physical machine as two Systemd services with a 'BindsTo' config. If process A is restarted, process B would restart too. They worked well until we have to containerize process B for some reasons. Now, process A runs in the host machine, while process B is inside a Docker container，and the Systemd mechanism doesn't work anymore.

Is there any way to for process B to get notified as soon as the process A restarts, just like what Systemd 'BindsTo' do?

答:
Just put your container in a systemd Unit, and you can control your container like a systemd service. For example:

```<code>[Unit]
Description=B in Docker
After=docker.service
Requires=docker.service

[Service]
ExecStartpre=-/usr/bin/docker stop container_b
ExecStartpre=-/usr/bin/docker rm container_b
ExecStart=/usr/bin/docker run --rm --name container_b image:tag
ExecStop=-/usr/bin/docker stop container_b
ExecStop=-/usr/bin/docker rm container_b
Restart=always
</code>```

Body:
Just put your container in a systemd Unit, and you can control your container like a systemd service. For example:

[Unit]
Description=B in Docker
After=docker.service
Requires=docker.service

[Service]
ExecStartpre=-/usr/bin/docker stop container_b
ExecStartpre=-/usr/bin/docker rm container_b
ExecStart=/usr/bin/docker run --rm --name container_b image:tag
ExecStop=-/usr/bin/docker stop container_b
ExecStop=-/usr/bin/docker rm container_b
Restart=always