问:
Changing UISlider Images with Swift
I'm trying to change the default images for UISliders with Swift. I'm editing didFinishLaunchingWithOptions in AppDelegate.

In Objective C you would do this:

```<code>UIImage *maxImage = [UIImage imageNamed:@"slider-track.png"];
[[UISlider appearance] setMaximumTrackImage:maxImage forState:UIControlStateNormal];
</code>```

I've tried converting to Swift but have not been successful:

```<code>var maxImage:UIImage = UIImage (named:"slider-track.png")
UISlider.setMaximumTrackImage(image: maxImage, forState: UIControlStateNormal)
</code>```

The first line is fine, but the second gives an error.

What is the correct syntax for the second line?

Thanks

答:
Changing images fast using slider in swift4

```<code>class ViewController: UIViewController {
    //var slider1 = UISlider()

    var immgar = [UIImage(named: "bgspices.jpg"),UIImage(named: "index1.jpg"),  UIImage(named: "index2.jpg"),UIImage(named: "index3.jpg"),UIImage(named: "index4.jpg"), UIImage(named: "woods.jpg")]

                  override func viewDidLoad() {
        super.viewDidLoad()

    }

    @IBOutlet weak var imageview: UIImageView!

    @IBOutlet weak var slider: UISlider!

    @IBAction func slider1(_ sender: Any) {

        print("changeImage method being called!!!!");

        let slider1 = Int(slider.value)
        imageview.image = immgar[slider1]
</code>```

Title: Changing UISlider Images with Swift

Body:
I'm trying to change the default images for UISliders with Swift. I'm editing didFinishLaunchingWithOptions in AppDelegate.

In Objective C you would do this:

UIImage *maxImage = [UIImage imageNamed:@"slider-track.png"];
[[UISlider appearance] setMaximumTrackImage:maxImage forState:UIControlStateNormal];

I've tried converting to Swift but have not been successful:

var maxImage:UIImage = UIImage (named:"slider-track.png")
UISlider.setMaximumTrackImage(image: maxImage, forState: UIControlStateNormal)

The first line is fine, but the second gives an error.

What is the correct syntax for the second line?

Thanks

Body:
Changing images fast using slider in swift4

class ViewController: UIViewController {
    //var slider1 = UISlider()

    var immgar = [UIImage(named: "bgspices.jpg"),UIImage(named: "index1.jpg"),  UIImage(named: "index2.jpg"),UIImage(named: "index3.jpg"),UIImage(named: "index4.jpg"), UIImage(named: "woods.jpg")]

                  override func viewDidLoad() {
        super.viewDidLoad()

    }

    @IBOutlet weak var imageview: UIImageView!

    @IBOutlet weak var slider: UISlider!

    @IBAction func slider1(_ sender: Any) {

        print("changeImage method being called!!!!");

        let slider1 = Int(slider.value)
        imageview.image = immgar[slider1]


来源: stackexchange

问:
Get ZXing to work
I followed every instructions, wiki, getting started, guides, help,
etc. I could find about ZXing project.
After many many debugging, I finally manged to compile using ant
core.jar, javame.jar, and javese.jar.
I would like to integrate ZXing into my code, i.e., I wish to scan
\read a barcode and handle its data.

I've imported as external jar each of the files mentioned above. Then
I turned to https://code.google.com/p/zxing/wiki/DeveloperNotes to use
the MultiFormatReader().
The BufferedImage class cannot be resolved. I tried whatever I know
and I even tried android's Bitmap for a workaround, but it didn't help
me either.

I know I can use an intent to read\scan the barcode, but I wish to
handle it myself and not to install a "3rd party" application.

Can anyone please help me understand how can I do so?
Few lines of code will be appreciated.

And again, I only want to scan\read a barcode and analyze its data.

答:
Here is what I did for my experimental app:

Downloaded Android version of ZXing Barcode Scanner (here)

Converted this project into Android Library

Removed all the functionality I didn't need

Modified CaptureActivity the way I wanted, so its better integrated with my app.

I found this way was easier, because Android has some problems with uniform Camera support across different devices, and guys from ZXing already took care of it.

ContentLicense: CC BY-SA 3.0

Title: Get ZXing to work


问:
SSIS/SSDT Warnings Don't Appear in Error List
Essentially, I encounter the same problem as the question below, except that the accepted answer does not resolve it. I have neither warnings nor errors in the Error List:

See complete tooltip error message for Data Flow SSIS element in Visual Studio

Similar to the question noted above I can see a truncated warning message on the Data Flow design surface.

However, no corresponding warning is visible in Visual Studio's Error List view.

How can I view the entire warning?

答:
This text truncation issue/bug is not just tooltips.
It's in SSIS Toolbox (description box at bottom) - no way to see the entire text describing the task/component (if not too big you can increase the width of the pane but that is not really acceptable).

(VS/SSDT 2019)

ContentLicense: CC BY-SA 4.0


问:
How Do i get the heights ranked Decade of a movie?
I'm new to my SQL I came across a question which I couldn't solve i will list down the tables and what I attempt to do so please help!

The question is: Which decade has the highest average ranked movies?

答:
Consider:

```<code>SELECT floor(m.year / 10) * 10 decade
FROM  movies m
INNER JOIN rate r on m.movieid = r.movieid
GROUP BY m.movieid, decade
ORDER BY avg(r.rank) desc
LIMIT 1
</code>```

This gives you the decade that has the highest averaged ranked movie.

Side note: your original queries had issues - namely, column movieid is ambiguous since it exists in both tables and is not prefixed with a table name.

Body:
Consider:

SELECT floor(m.year / 10) * 10 decade
FROM  movies m
INNER JOIN rate r on m.movieid = r.movieid
GROUP BY m.movieid, decade
ORDER BY avg(r.rank) desc
LIMIT 1

This gives you the decade that has the highest averaged ranked movie.

Side note: your original queries had issues - namely, column movieid is ambiguous since it exists in both tables and is not prefixed with a table name.


问:
React, unable to display the data received by an api, after doing a GET in componentDidMount()
I have done a function in my react call which calls an api, and sets a state based on the data received by that api

```<code>getUserList() {
    API.get('/userlist')
        .then(response => {
            this.setState({
                userList: response.data
            }, () => {
                console.log(this.state.userList) //I can see this
            });
        })
}
</code>```

This is how my constructor looks

```<code>constructor(props) {
    super(props)
    this.state = {
        retracted: false,
        userList: []

    }
    this.getUserList = this.getUserList.bind(this);
}
</code>```

I call it in componentDidMount()

```<code>componentDidMount() {
    this.getUserList();
}
</code>```

But then my render crashes, because both console.log return undefined

```<code>render() {
    var users = this.state.userList;
    var user = users[0].email //cannot read email of undefined

    console.log(this.state.userList)
    console.log(users)
    return (
        <div class="maincontainer">
            <div className="content-landing">
                 <p>{user}</p>
            </div>

        </div>
    )
}
</code>```

答:
componentDidMount is not async, and cannot be. You should deal with transition state like loading during the async call.

Consider do a check since the result is not fetched yet :

    render() {
      var users = this.state.userList;

      if (users.length === 0) {
        return
loading

      }

      return
{users[0].email}

    }
```

This could be not fully fonctionnal depending your usage, especially for error response. You still do a check for error case / state where users.length === 0 but not loading.

Body:
I have done a function in my react call which calls an api, and sets a state based on the data received by that api

getUserList() {
    API.get('/userlist')
        .then(response => {
            this.setState({
                userList: response.data
            }, () => {
                console.log(this.state.userList) //I can see this
            });
        })
}

This is how my constructor looks

constructor(props) {
    super(props)
    this.state = {
        retracted: false,
        userList: []

    }
    this.getUserList = this.getUserList.bind(this);
}

I call it in componentDidMount()

componentDidMount() {
    this.getUserList();
}

But then my render crashes, because both console.log return undefined

render() {
    var users = this.state.userList;
    var user = users[0].email //cannot read email of undefined

    console.log(this.state.userList)
    console.log(users)
    return (

{user}

    )
}

Body:
componentDidMount is not async, and cannot be. You should deal with transition state like loading during the async call.

Consider do a check since the result is not fetched yet :

    render() {
      var users = this.state.userList;

      if (users.length === 0) {
        return <p>loading</p>
      }

      return <p>{users[0].email}</p>
    }

This could be not fully fonctionnal depending your usage, especially for error response. You still do a check for error case / state where users.length === 0 but not loading.


问:
Update web.config to add rewrite rules for specific environments in Azure DevOps release pipeline for an Azure App Service
What is a good way to update web.config for a Azure Application Service webapp in AZDO to add rewrite rules? We use Azure DevOps to deploy a webapp that uses a web.config and we want to set URL Rewrite rules based on the environment it is. We have some default values in a web.config to be used across all environments, but just need to add some lines for the rewrite rules. </p>

答:
Update web.config to add rewrite rules for specific environments in Azure DevOps release pipeline for an Azure App Service

To rewrite or replace rules for specific environments in the web.config, we could use xdt:Transform="Insert" to add some lines for the rewrite rule based on different environments.

For the Web.Release.config:

```<code><?xml version="1.0"?>

.....
  <system.webServer>
    <rewrite xdt:Transform="Insert">
      <rules>
        ......
      </rules>
    </rewrite>
  </system.webServer>
</configuration>
</code>```

For the Azure App Service Deploy task, there is an option XML transformation under File Transforms & Variable Substitution Options:

The XML transformation supports transforming the configuration files (*.config files) by following Web.config Transformation Syntax and is based on the environment to which the web package will be deployed.

Check this document XML Transformation for some more details.

Hope this helps.

Body:
Update web.config to add rewrite rules for specific environments in Azure DevOps release pipeline for an Azure App Service

To rewrite or replace rules for specific environments in the web.config, we could use xdt:Transform="Insert" to add some lines for the rewrite rule based on different environments.

For the Web.Release.config:

<?xml version="1.0"?>

.....
  <system.webServer>
    <rewrite xdt:Transform="Insert">
      <rules>
        ......
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

For the Azure App Service Deploy task, there is an option XML transformation under File Transforms & Variable Substitution Options:

The XML transformation supports transforming the configuration files (*.config files) by following Web.config Transformation Syntax and is based on the environment to which the web package will be deployed.

Check this document XML Transformation for some more details.

Hope this helps.


问:
Terraform: Error creating App Engine application: googleapi: Error 403: The caller does not have permission, forbidden
I am trying to create a simple appengine application with terraform.

Firstly I have created all the basic resources with the gcloud cli. Here I list the commands I have executed:

```<code>export PROJECT=ProjectName
export TF_VAR_billing_account=xxxxxx-xxxxxx-xxxxxx
export TF_VAR_project=${PROJECT}-terraform
export TF_CREDS=./${PROJECT}-terraform.json

gcloud projects create ${TF_VAR_project} \
  --set-as-default

gcloud beta billing projects link ${TF_VAR_project} \
  --billing-account ${TF_VAR_billing_account}

######################################################################################
##### Create the Terraform service account
######################################################################################

gcloud iam service-accounts create terraform \
  --display-name "Terraform admin account"

gcloud iam service-accounts keys create ${TF_CREDS} \
  --iam-account terraform@${TF_VAR_project}.iam.gserviceaccount.com

gcloud projects add-iam-policy-binding ${TF_VAR_project} \
  --member serviceAccount:terraform@${TF_VAR_project}.iam.gserviceaccount.com \
  --role roles/editor

gcloud projects add-iam-policy-binding ${TF_VAR_project} \
  --member serviceAccount:terraform@${TF_VAR_project}.iam.gserviceaccount.com \
  --role roles/storage.admin

gcloud projects add-iam-policy-binding ${TF_VAR_project} \
  --member serviceAccount:terraform@${TF_VAR_project}.iam.gserviceaccount.com \
  --role roles/appengine.appAdmin

gcloud services enable cloudresourcemanager.googleapis.com
gcloud services enable cloudbilling.googleapis.com
gcloud services enable iam.googleapis.com
gcloud services enable serviceusage.googleapis.com

######################################################################################
##### Set up remote state in Cloud Storage
######################################################################################

gsutil mb -p ${TF_VAR_project} gs://${TF_VAR_project}

cat > backend.tf << EOF
terraform {
 backend "gcs" {
   bucket  = "${TF_VAR_project}"
   prefix  = "terraform/state"
 }
}
EOF

gsutil versioning set on gs://${TF_VAR_project}

export GOOGLE_APPLICATION_CREDENTIALS=${TF_CREDS}
export GOOGLE_PROJECT=${TF_VAR_project}
</code>```

Those commands are executed correctly. At this point  I have the following terraform file:

```<code>variable "project" {}
variable "region" {}

provider "google" {
    project = var.project
    region = var.region
}

data "google_project" "project" {}

resource "google_project_service" "service" {
  for_each = toset([
    "appengine.googleapis.com",
    "appengineflex.googleapis.com",
    "firestore.googleapis.com"
  ])

  service = each.key

  disable_on_destroy = false
}

resource "google_app_engine_application" "app" {
    project     = data.google_project.project.project_id
    location_id = var.region
}
</code>```

When I run the terraform plan and apply the resources 'service' are created correcly but the app engine application cannot be created and I get the follwoing error:

```<code>google_app_engine_application.app: Creating...

Error: Error creating App Engine application: googleapi: Error 403: The caller does not have permission, forbidden

  on project.tf line 24, in resource "google_app_engine_application" "app":
  24: resource "google_app_engine_application" "app" {
</code>```

It seems that the service key that I have created is missing some permission but I cannot figure out what is the issue.

答: As another member of the community has pointed out, you need to have Owner permissions on the project in order to properly create applications if you are using the primitive roles. This is mentioned in the permissions documentation for App engine.</p>

Body:
I am trying to create a simple appengine application with terraform.

Firstly I have created all the basic resources with the gcloud cli. Here I list the commands I have executed:

export PROJECT=ProjectName
export TF_VAR_billing_account=xxxxxx-xxxxxx-xxxxxx
export TF_VAR_project=${PROJECT}-terraform
export TF_CREDS=./${PROJECT}-terraform.json

gcloud projects create ${TF_VAR_project} \
  --set-as-default

gcloud beta billing projects link ${TF_VAR_project} \
  --billing-account ${TF_VAR_billing_account}

######################################################################################
##### Create the Terraform service account
######################################################################################

gcloud iam service-accounts create terraform \
  --display-name "Terraform admin account"

gcloud iam service-accounts keys create ${TF_CREDS} \
  --iam-account terraform@${TF_VAR_project}.iam.gserviceaccount.com

gcloud projects add-iam-policy-binding ${TF_VAR_project} \
  --member serviceAccount:terraform@${TF_VAR_project}.iam.gserviceaccount.com \
  --role roles/editor

gcloud projects add-iam-policy-binding ${TF_VAR_project} \
  --member serviceAccount:terraform@${TF_VAR_project}.iam.gserviceaccount.com \
  --role roles/storage.admin

gcloud projects add-iam-policy-binding ${TF_VAR_project} \
  --member serviceAccount:terraform@${TF_VAR_project}.iam.gserviceaccount.com \
  --role roles/appengine.appAdmin

gcloud services enable cloudresourcemanager.googleapis.com
gcloud services enable cloudbilling.googleapis.com
gcloud services enable iam.googleapis.com
gcloud services enable serviceusage.googleapis.com

######################################################################################
##### Set up remote state in Cloud Storage
######################################################################################

gsutil mb -p ${TF_VAR_project} gs://${TF_VAR_project}

cat > backend.tf << EOF
terraform {
 backend "gcs" {
   bucket  = "${TF_VAR_project}"
   prefix  = "terraform/state"
 }
}
EOF

gsutil versioning set on gs://${TF_VAR_project}

export GOOGLE_APPLICATION_CREDENTIALS=${TF_CREDS}
export GOOGLE_PROJECT=${TF_VAR_project}

Those commands are executed correctly. At this point  I have the following terraform file:

variable "project" {}
variable "region" {}

provider "google" {
    project = var.project
    region = var.region
}

data "google_project" "project" {}

resource "google_project_service" "service" {
  for_each = toset([
    "appengine.googleapis.com",
    "appengineflex.googleapis.com",
    "firestore.googleapis.com"
  ])

  service = each.key

  disable_on_destroy = false
}

resource "google_app_engine_application" "app" {
    project     = data.google_project.project.project_id
    location_id = var.region
}

When I run the terraform plan and apply the resources 'service' are created correcly but the app engine application cannot be created and I get the follwoing error:

google_app_engine_application.app: Creating...

Error: Error creating App Engine application: googleapi: Error 403: The caller does not have permission, forbidden

  on project.tf line 24, in resource "google_app_engine_application" "app":
  24: resource "google_app_engine_application" "app" {

It seems that the service key that I have created is missing some permission but I cannot figure out what is the issue.


问:
Creating threads with parameters in Swift?
I am trying to create a thread in swift and send two parameters. I create thread and this work:

let thread = NSThread(target:self, selector:"getData", object:nil)
thread.start()
```

<p>But how to send parameters to my func getData? How to create object with parameters like this:</p>

```let params =...
let thread = NSThread(target:self, selector:"getData", object:params)
thread.start()

...

getData(username: String, password: String) {
    ...
}
```

答:
Updated with Swift 5 </p>

```<code>Thread.detachNewThreadSelector(#selector(getData), toTarget: self, with: params)
func getData(params: Params) {
    // ...
}
</code>```

Body:
I am trying to create a thread in swift and send two parameters. I create thread and this work:

let thread = NSThread(target:self, selector:"getData", object:nil)
thread.start()

But how to send parameters to my func getData? How to create object with parameters like this:

let params =...
let thread = NSThread(target:self, selector:"getData", object:params)
thread.start()

...

getData(username: String, password: String) {
    ...
}

Body:
Updated with Swift 5

Thread.detachNewThreadSelector(#selector(getData), toTarget: self, with: params)
func getData(params: Params) {
    // ...
}


问:
HTTP request JWT
I am a little bit confused about how HTTP works.
My question is that when the server assigns a JWT token to a client after providing credentials, the server assigns token in HTTP header['Authorization']. Now the user is logged in and can make a request.
So please tell me if when the user makes an API call again, will the HTTP header['Authorization'] remain same or be changed?</p>

答:
The header['Authorization'] remains the same.

The server basically generates a token and sends it to the client-side.
On the client-side, the token will be saved in the request header of subsequent requests sent to the server.

Please check this resource

Title: HTTP request JWT


问:
How to have a wsdl conform to the soap input
We are changing our soap webservices from jetty to jaxws. The goal is to keep the same input message. I have used the original WSDL to create the service with netbeans. The WSDL is the following:

```<code><?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://www.mycompany.nl/DcxExpeditieService/v1"
        xmlns:tns="http://www.mycompany.nl/DcxExpeditieService/v1"
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
        xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
    <wsdl:types>
        <xs:schema targetNamespace="http://www.mycompany.nl/DcxExpeditieService/v1"
                xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
            <xs:element name="DcxExpeditie" type="tns:DcxExpeditie"/>
            <xs:complexType name="DcxExpeditie">
                <xs:sequence>
                    <xs:element name="Expeditie" type="tns:Expeditie"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="Expeditie">
                <xs:sequence>
                    <xs:element name="tag1" type="xs:string"/>
                    <xs:element name="tag2" type="xs:string"/>
                </xs:sequence>
            </xs:complexType>
        </xs:schema>
    </wsdl:types>
    <wsdl:message name="DcxExpeditieRequest">
        <wsdl:part name="DcxExpeditie" type="tns:DcxExpeditie"/>
    </wsdl:message>
    <wsdl:message name="DcxExpeditieResponse">
        <wsdl:part name="DcxExpeditieResponse" type="xs:string"/>
    </wsdl:message>
    <wsdl:portType name="DcxExpeditieServicePortType">
        <wsdl:operation name="DcxExpeditieOperation">
            <wsdl:input message="tns:DcxExpeditieRequest"/>
            <wsdl:output message="tns:DcxExpeditieResponse"/>
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="DcxExpeditieServiceSOAP" type="tns:DcxExpeditieServicePortType">
        <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
        <wsdl:operation name="DcxExpeditieOperation">
            <soap:operation soapAction="http://www.mycompany.nl/DcxExpeditieService/v1/DcxExpeditie"/>
            <wsdl:input>
                <soap:body use="literal" namespace="http://www.mycompany.nl/DcxExpeditieService/v1"/>
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal" namespace="http://www.mycompany.nl/DcxExpeditieService/v1"/>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="DcxExpeditieService">
        <wsdl:port name="DcxExpeditieServiceSOAP" binding="tns:DcxExpeditieServiceSOAP">
            <soap:address location="https://someserver.mycompany.nl/vbs/dcxexpeditie"/>
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>
</code>```

When using this WSDL in soapui it results in the following input example:

```<code><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://www.mycompany.nl/DcxExpeditieService/v1">
   <soapenv:Header/>
   <soapenv:Body>
      <v1:DcxExpeditieOperation>
         <DcxExpeditie>
            <v1:Expeditie>
               <v1:tag1>?</v1:tag1>
               <v1:tag2>?</v1:tag2>
            </v1:Expeditie>
         </DcxExpeditie>
      </v1:DcxExpeditieOperation>
   </soapenv:Body>
</soapenv:Envelope>
</code>```

However, the original input format was:

```<code><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://www.mycompany.nl/DcxExpeditieService/v1">
       <soapenv:Header/>
       <soapenv:Body>
          <v1:DcxExpeditie>
                <v1:Expeditie>
                   <v1:tag1>?</v1:tag1>
                   <v1:tag2>?</v1:tag2>
                </v1:Expeditie>
          </v1:DcxExpeditie>
       </soapenv:Body>
    </soapenv:Envelope>
</code>```

so with no DcxExpeditieOperation tag and with the v1 namespace in front of DcxExpeditie

Is this possible and if so, how can I accomplish this?

答:
Try to change SOAP binding from rpc to document to remove DcxExpeditieOperation tag:

```<code><soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
</code>```

To fix the namespace issue refer DcxExpeditie element insted of type:

```<code><wsdl:part name="DcxExpeditie" element="tns:DcxExpeditie"/>
</code>```

Updated WSDL file:

```<code><?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://www.mycompany.nl/DcxExpeditieService/v1"
                  xmlns:tns="http://www.mycompany.nl/DcxExpeditieService/v1"
                  xmlns:xs="http://www.w3.org/2001/XMLSchema"
                  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
                  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
    <wsdl:types>
        <xs:schema targetNamespace="http://www.mycompany.nl/DcxExpeditieService/v1"
                           xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
            <xs:element name="DcxExpeditie" type="tns:DcxExpeditie"/>
            <xs:element name="DcxExpeditieResponse" type="xs:string"/>
            <xs:complexType name="DcxExpeditie">
                <xs:sequence>
                    <xs:element name="Expeditie" type="tns:Expeditie"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="Expeditie">
                <xs:sequence>
                    <xs:element name="tag1" type="xs:string"/>
                    <xs:element name="tag2" type="xs:string"/>
                </xs:sequence>
            </xs:complexType>
        </xs:schema>
    </wsdl:types>
    <wsdl:message name="DcxExpeditieRequest">
        <wsdl:part name="DcxExpeditie" element="tns:DcxExpeditie"/>
    </wsdl:message>
    <wsdl:message name="DcxExpeditieResponse">
        <wsdl:part name="DcxExpeditieResponse" element="tns:DcxExpeditieResponse" />
    </wsdl:message>
    <wsdl:portType name="DcxExpeditieServicePortType">
        <wsdl:operation name="DcxExpeditieOperation">
            <wsdl:input message="tns:DcxExpeditieRequest"/>
            <wsdl:output message="tns:DcxExpeditieResponse"/>
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="DcxExpeditieServiceSOAP" type="tns:DcxExpeditieServicePortType">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <wsdl:operation name="DcxExpeditieOperation">
            <soap:operation soapAction="http://www.mycompany.nl/DcxExpeditieService/v1/DcxExpeditie"/>
            <wsdl:input>
                <soap:body use="literal" />
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal" />
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="DcxExpeditieService">
        <wsdl:port name="DcxExpeditieServiceSOAP" binding="tns:DcxExpeditieServiceSOAP">
            <soap:address location="https://someserver.mycompany.nl/vbs/dcxexpeditie"/>
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>
</code>```

Body:
We are changing our soap webservices from jetty to jaxws. The goal is to keep the same input message. I have used the original WSDL to create the service with netbeans. The WSDL is the following:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://www.mycompany.nl/DcxExpeditieService/v1"
        xmlns:tns="http://www.mycompany.nl/DcxExpeditieService/v1"
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
        xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
    <wsdl:types>
        <xs:schema targetNamespace="http://www.mycompany.nl/DcxExpeditieService/v1"
                xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
            <xs:element name="DcxExpeditie" type="tns:DcxExpeditie"/>
            <xs:complexType name="DcxExpeditie">
                <xs:sequence>
                    <xs:element name="Expeditie" type="tns:Expeditie"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="Expeditie">
                <xs:sequence>
                    <xs:element name="tag1" type="xs:string"/>
                    <xs:element name="tag2" type="xs:string"/>
                </xs:sequence>
            </xs:complexType>
        </xs:schema>
    </wsdl:types>
    <wsdl:message name="DcxExpeditieRequest">
        <wsdl:part name="DcxExpeditie" type="tns:DcxExpeditie"/>
    </wsdl:message>
    <wsdl:message name="DcxExpeditieResponse">
        <wsdl:part name="DcxExpeditieResponse" type="xs:string"/>
    </wsdl:message>
    <wsdl:portType name="DcxExpeditieServicePortType">
        <wsdl:operation name="DcxExpeditieOperation">
            <wsdl:input message="tns:DcxExpeditieRequest"/>
            <wsdl:output message="tns:DcxExpeditieResponse"/>
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="DcxExpeditieServiceSOAP" type="tns:DcxExpeditieServicePortType">
        <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
        <wsdl:operation name="DcxExpeditieOperation">
            <soap:operation soapAction="http://www.mycompany.nl/DcxExpeditieService/v1/DcxExpeditie"/>
            <wsdl:input>
                <soap:body use="literal" namespace="http://www.mycompany.nl/DcxExpeditieService/v1"/>
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal" namespace="http://www.mycompany.nl/DcxExpeditieService/v1"/>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="DcxExpeditieService">
        <wsdl:port name="DcxExpeditieServiceSOAP" binding="tns:DcxExpeditieServiceSOAP">
            <soap:address location="https://someserver.mycompany.nl/vbs/dcxexpeditie"/>
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

When using this WSDL in soapui it results in the following input example:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://www.mycompany.nl/DcxExpeditieService/v1">
   <soapenv:Header/>
   <soapenv:Body>
      <v1:DcxExpeditieOperation>
         <DcxExpeditie>
            <v1:Expeditie>
               <v1:tag1>?</v1:tag1>
               <v1:tag2>?</v1:tag2>
            </v1:Expeditie>
         </DcxExpeditie>
      </v1:DcxExpeditieOperation>
   </soapenv:Body>
</soapenv:Envelope>

However, the original input format was:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://www.mycompany.nl/DcxExpeditieService/v1">
       <soapenv:Header/>
       <soapenv:Body>
          <v1:DcxExpeditie>
                <v1:Expeditie>
                   <v1:tag1>?</v1:tag1>
                   <v1:tag2>?</v1:tag2>
                </v1:Expeditie>
          </v1:DcxExpeditie>
       </soapenv:Body>
    </soapenv:Envelope>

so with no DcxExpeditieOperation tag and with the v1 namespace in front of DcxExpeditie

Is this possible and if so, how can I accomplish this?

Body:
Try to change SOAP binding from rpc to document to remove DcxExpeditieOperation tag:

<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>

To fix the namespace issue refer DcxExpeditie element insted of type:

<wsdl:part name="DcxExpeditie" element="tns:DcxExpeditie"/>

Updated WSDL file:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://www.mycompany.nl/DcxExpeditieService/v1"
                  xmlns:tns="http://www.mycompany.nl/DcxExpeditieService/v1"
                  xmlns:xs="http://www.w3.org/2001/XMLSchema"
                  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
                  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
    <wsdl:types>
        <xs:schema targetNamespace="http://www.mycompany.nl/DcxExpeditieService/v1"
                           xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
            <xs:element name="DcxExpeditie" type="tns:DcxExpeditie"/>
            <xs:element name="DcxExpeditieResponse" type="xs:string"/>
            <xs:complexType name="DcxExpeditie">
                <xs:sequence>
                    <xs:element name="Expeditie" type="tns:Expeditie"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="Expeditie">
                <xs:sequence>
                    <xs:element name="tag1" type="xs:string"/>
                    <xs:element name="tag2" type="xs:string"/>
                </xs:sequence>
            </xs:complexType>
        </xs:schema>
    </wsdl:types>
    <wsdl:message name="DcxExpeditieRequest">
        <wsdl:part name="DcxExpeditie" element="tns:DcxExpeditie"/>
    </wsdl:message>
    <wsdl:message name="DcxExpeditieResponse">
        <wsdl:part name="DcxExpeditieResponse" element="tns:DcxExpeditieResponse" />
    </wsdl:message>
    <wsdl:portType name="DcxExpeditieServicePortType">
        <wsdl:operation name="DcxExpeditieOperation">
            <wsdl:input message="tns:DcxExpeditieRequest"/>
            <wsdl:output message="tns:DcxExpeditieResponse"/>
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="DcxExpeditieServiceSOAP" type="tns:DcxExpeditieServicePortType">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <wsdl:operation name="DcxExpeditieOperation">
            <soap:operation soapAction="http://www.mycompany.nl/DcxExpeditieService/v1/DcxExpeditie"/>
            <wsdl:input>
                <soap:body use="literal" />
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal" />
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="DcxExpeditieService">
        <wsdl:port name="DcxExpeditieServiceSOAP" binding="tns:DcxExpeditieServiceSOAP">
            <soap:address location="https://someserver.mycompany.nl/vbs/dcxexpeditie"/>
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>


问:
angular 9, @ContentChildren does not initialize correctly
I have a directive named "VerticalTabsDirective" with propery-

```<code>@ContentChildren(MatTabLink) contentChildren: QueryList<MatTabLink>;
@Input() exlVerticalTabs
</code>```

I am using it in a my component with recursive ng-template in this way-

```<code> <nav mat-tab-nav-bar
             [exlVerticalTabs]="selectedIndex">
            <ng-template #recursiveNavList let-tabs="tabs" let-level="level">
                <ng-container *ngFor="let tab of tabs; let i = index">
                    <a mat-tab-link
                       [active]="rla.isActive"
                       [routerLink]="[tab.link]"
                       #rla="routerLinkActive"
                       routerLinkActive>
                            <span>
                               {{tab}}
                            </span>
                    </a>

                    <div>
                        <ng-container *ngTemplateOutlet="recursiveNavList; context: { tabs: tab.subCategories, level: level + 1}"></ng-container>
                    </div>

                </ng-container>
            </ng-template>

            <ng-container *ngTemplateOutlet="recursiveNavList; context: { tabs: profileOutputService.facets, level:0}"></ng-container>

        </nav>
</code>```

But when I debug my directive I can see that "contentChildren" property does not initialize correctly, the "_results" object inside is empty, and does not contain "MatTabLink" fields as expected.
In other components I use "VerticalTabsDirective" and "contentChildren" is initialized correctly, but I do not use recursive ng-template is those components.

Any idea how to make it work?

答:
I found an answer that can help people- need to add "{descendants: true}".</p>

```<code> @ContentChildren(ChildComponent, { descendants: true}) children: QueryList<
    ChildComponent>
</code>```

Body:
I have a directive named "VerticalTabsDirective" with propery-

@ContentChildren(MatTabLink) contentChildren: QueryList<MatTabLink>;
@Input() exlVerticalTabs

I am using it in a my component with recursive ng-template in this way-

            <ng-template #recursiveNavList let-tabs="tabs" let-level="level">
                <ng-container *ngFor="let tab of tabs; let i = index">

                               {{tab}}

                        <ng-container *ngTemplateOutlet="recursiveNavList; context: { tabs: tab.subCategories, level: level + 1}"></ng-container>

                </ng-container>
            </ng-template>

            <ng-container *ngTemplateOutlet="recursiveNavList; context: { tabs: profileOutputService.facets, level:0}"></ng-container>

But when I debug my directive I can see that "contentChildren" property does not initialize correctly, the "_results" object inside is empty, and does not contain "MatTabLink" fields as expected.
In other components I use "VerticalTabsDirective" and "contentChildren" is initialized correctly, but I do not use recursive ng-template is those components.

Any idea how to make it work?

Body:
I found an answer that can help people- need to add "{descendants: true}".

 @ContentChildren(ChildComponent, { descendants: true}) children: QueryList<
    ChildComponent>


问:
How to display my background-image in my html/css?
I've seen another topic about my issue, but it doesn't resolve it, I try to put a background image for my portfolio but it doesn't work. I don't understand why, do you have an idea ?

my code:

html:

          Project
          Skills
          Contact

```

```css:

.main{
background-image: url(../img/dev-dots.png);
background-position: center;
background-repeat: no-repeat;
background-size: cover;

}

.navbar{
    height: 10vh;
    background-color: purple;
    position: fixed;
}
```

PS: Sorry for my english, it's not my first language.

答:
Your div element with class 'main' doesn't have any height. The background image will not show because of this.

You can do one of these options:

Give it a fixed height (not recommended)

```<code>.main {
  height: 100px
}
</code>```

Add block elements to your navbar so main gets it height automaticaly

```<code> .navbar {
display: block
}
</code>```

Don't use position fixed in this case as well.

Last but not least, lose the backgroundcolor of navbar, this wil lay on top of de backgroundimage of main.

I hope this helps!

Body:
I've seen another topic about my issue, but it doesn't resolve it, I try to put a background image for my portfolio but it doesn't work. I don't understand why, do you have an idea ?

my code:

html:

          Project
          Skills
          Contact

css:

.main{
background-image: url(../img/dev-dots.png);
background-position: center;
background-repeat: no-repeat;
background-size: cover;

}

.navbar{
    height: 10vh;
    background-color: purple;
    position: fixed;
}

PS: Sorry for my english, it's not my first language.

Body:
Your div element with class 'main' doesn't have any height. The background image will not show because of this.

You can do one of these options:

Give it a fixed height (not recommended)

.main {
  height: 100px
}

Add block elements to your navbar so main gets it height automaticaly

 .navbar {
display: block
}

Don't use position fixed in this case as well.

Last but not least, lose the backgroundcolor of navbar, this wil lay on top of de backgroundimage of main.

I hope this helps!


问:
git diff how many files of specific file extension (.js and not .test.js)
I want to know how many files of the extension .js are in my git diff.

So far I know I can do: git diff -- '*.js', but this doesn't work because it also shows files that finish with .test.js, and I just want the ones which extension is .js

答:
Use a tool like grep to filter out the names you do not want :

```<code>git diff --name-only -- '*.js' | grep -v 'test\.js$'
</code>```

Body:
Use a tool like grep to filter out the names you do not want :

git diff --name-only -- '*.js' | grep -v 'test\.js$'


问:
Android 2.3 doesn't pass cookie information for html5 audio tag Get request
I am trying to play a media file using html5 audio tag in android 2.3 from a secure site but I notice that on the Get request, android 2.3 isnt passing the cookie information from the browser to the server causing a
'HTTP/1.1 302 Moved Temporarily'
response from the server back to the login page for reauthentication. I tried the same request on IOS mobile browser, chrome, safari, IE and the cookie information is sent on each request. Whats more puzzling is also that on img tag request, the cookie information is sent on the android browser.

My question is, is anyone aware if this is just an implementation bug on android 2.3 audio tag or am I missing an parameter to allow the cookie information to be passed?

thanks for any help

答:
I am experiencing the same problem.
In my case I see a specific User-Agent:

```<code>User-Agent: HTC Streaming Player htc_wwe / 1.0 / htc_ace / 2.3.3
</code>```

So, maybe, playing is performed by device player, that does not send browser cookies.

ContentLicense: CC BY-SA 2.5

Body:
I am experiencing the same problem.
In my case I see a specific User-Agent:

User-Agent: HTC Streaming Player htc_wwe / 1.0 / htc_ace / 2.3.3

So, maybe, playing is performed by device player, that does not send browser cookies.


问:
Deriving the list of JSON Paths from a JSON Schema model
I am looking for a Javascript library to list the possible Json Paths based on a Json Schema.

For a json schema like below, I want to list the possible json paths.

```<code>{
  "$id": "https://example.com/person.schema.json",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Customer",
  "type": "object",
  "properties": {
    "firstName": {
      "type": "string",
      "description": "The person's first name."
    },
    "lastName": {
      "type": "string",
      "description": "The person's last name."
    },
    "age": {
      "description": "Age in years which must be equal to or greater than zero.",
      "type": "integer",
      "minimum": 0
    },
    "address": {
        "type": "object",
        "city": {
            "type": "string",
        },
        "country": {
            "type": "string",
        }
    }
  }
}
</code>```

Possible Json Paths: firstName, lastName, age, address.city, and address.country

答:
Based on @customcommander's answer

Add support for $ref (prevent recursion)

Add hierarchy parents paths too (i.e. a.b.c -> a + a.b + a.b.c)

Add support for array items (using [] as a generic indexer)

const _derivePathsFromSchema = (schema, properties, defined) => {
  let paths = [];
  if (!properties) return paths;
  return Object.keys(properties).reduce((paths, childKey) => {
    let child = properties[childKey];
    const { $ref, ...childProperties } = child;
    if ($ref?.startsWith('#/definitions/')) {
      const definition = $ref.substr($ref.lastIndexOf('/') + 1);
      if (!defined.includes(definition)) // prevent recursion of definitions
      {
        defined.push(definition);
        child = {
          ...schema.definitions[definition], // load $ref properties
          ...childProperties, // child properties override those of the $ref
        };
      }
    }
    if (child.type === 'object') {
      return paths.concat(childKey, _derivePathsFromSchema(schema, child.properties, defined.slice()).map(p => `${childKey}.${p}`));
    }
    if (child.type === 'array' && child.items?.properties) {
      return paths.concat(childKey, `${childKey}[]`, _derivePathsFromSchema(schema, child.items.properties, defined.slice()).map(p => `${childKey}[].${p}`));
    }

    return paths.concat(childKey);
  }, paths);
};
const derivePathsFromSchema = schema => _derivePathsFromSchema(schema, schema.properties, []);

console.log(derivePathsFromSchema({
  "$schema": "http://json-schema.org/draft-07/schema#",
  "definitions": {
    "BType": {
      "type": "object",
      "properties": {
        "a": {
          "$ref": "#/definitions/AType"
        }
      }
    },
    "AType": {
      "type": "object",
      "properties": {
        "b": {
          "$ref": "#/definitions/BType"
        }
      }
    }
  },
  "type": "object",
  "properties": {
    "a": {
      "$ref": "#/definitions/AType"
    },
    "b": {
      "$ref": "#/definitions/BType"
    },
    "id": {
      "type": "string"
    },
    "array": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "item": { "type": "string" }
        }
      }
    },
    "obj": {
      "type": "object",
      "properties": {
        "nested": { "type": "string" }
      }
    }
  }
}));```

Body:
I am looking for a Javascript library to list the possible Json Paths based on a Json Schema.

For a json schema like below, I want to list the possible json paths.

{
  "$id": "https://example.com/person.schema.json",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Customer",
  "type": "object",
  "properties": {
    "firstName": {
      "type": "string",
      "description": "The person's first name."
    },
    "lastName": {
      "type": "string",
      "description": "The person's last name."
    },
    "age": {
      "description": "Age in years which must be equal to or greater than zero.",
      "type": "integer",
      "minimum": 0
    },
    "address": {
        "type": "object",
        "city": {
            "type": "string",
        },
        "country": {
            "type": "string",
        }
    }
  }
}

Possible Json Paths: firstName, lastName, age, address.city, and address.country


问:
Navbar item highlight
I have a question regarding navbars. I want to highlight a navbar item when I clicked an item but I don't know if I need to use angular or css for that. Can you guide me a little bit, please? </p>

```<code>   <div class="collapse navbar-collapse" id="navbarNav">
      <ul class="navbar-nav">
        <li class="nav-item">
          <a routerLink="/tasks" class="nav-link" href="#">Tasks</a>
        </li>
        <li class="nav-item">
          <a routerLink="/newTask" class="nav-link" href="#">New task</a>
        </li>
        <li class="nav-item">
          <a routerLink="/users" class="nav-link" href="#">Users</a>
        </li>
        <li class="nav-item">
          <a routerLink="/newProject" class="nav-link" href="#">New Project</a>
        </li>
      </ul>
    </div>
</code>```

答:
You can use routerLinkActive which will add a css class that you can use for styling. So in the following code if the current route is /newProject the list item will be styled according to your active css class:

```<code><li routerLinkActive="active">
  <a routerLink="/newProject" class="nav-link" href="#">New Project</a>
</li>
</code>```

More information on routerLinkActive here.

Title: Navbar item highlight

Body:
I have a question regarding navbars. I want to highlight a navbar item when I clicked an item but I don't know if I need to use angular or css for that. Can you guide me a little bit, please?

          Tasks

          New task

          Users

          New Project

Body:
You can use routerLinkActive which will add a css class that you can use for styling. So in the following code if the current route is /newProject the list item will be styled according to your active css class:

<li routerLinkActive="active">
  <a routerLink="/newProject" class="nav-link" href="#">New Project</a>
</li>

More information on routerLinkActive here.


问:
R: Window Function "Start" after "End"
I am having a problem with the window function in R.

```<code>newdata1 <-window(mergedall,start=c(as.Date(as.character("2014-06-16"))),end=c(as.Date(as.character("2015-01-31"))))
</code>```

I got this error. I am trying to understand how I can fix this issue. Thank you!

```<code>Error in window.default(mergedall, start = c(as.Date(as.character("2014-06-16"))),  :
  'start' cannot be after 'end'
In addition: Warning message:
In window.default(mergedall, start = c(as.Date(as.character("2014-06-16"))),  :
  'end' value not changed`
</code>```

答:
Again it's an old post. But since I stumbled upon it by searching the same error. I want to still provide something useful for future Googlers.

I could not replicate your issue because you did not provide your own mergedall dataset. So I am starting with a toy example to show a few places where the problem might be. It's really not that difficult at all.

Potential problem #1:

You did not create a ts object to begin with. Window function operates on a ts object, and it cannot just be a vector took directly from a df. Use ts function to make a vector a ts object first. And then assign it with proper start, end, frequency.

```<code>all <-seq(1:8) #eight observations in sequence
</code>```

Assign these eight values as monthly observations, starting from 201406 to 201501. Frequency 12 means monthly.

```<code>all.ts <- ts(all, start = c(2014,6), end = c(2015,1), frequency = 12)
</code>```

Potential problem #2:

You perhaps already assigned your mergedall series as a ts object, but with different start/end/frequency. My example above was based on monthly observations. So even though they are correct examples, they will not match with your daily-based window function. Window function and the ts object needs to be consistent.

Following my example, the window function would look like:

```<code>newdata1 <-window(all.ts,start=c(2014,6),end=c(2015,1) )
</code>```

Title: R: Window Function "Start" after "End"

Body:
I am having a problem with the window function in R.

newdata1 <-window(mergedall,start=c(as.Date(as.character("2014-06-16"))),end=c(as.Date(as.character("2015-01-31"))))

I got this error. I am trying to understand how I can fix this issue. Thank you!

Error in window.default(mergedall, start = c(as.Date(as.character("2014-06-16"))),  :
  'start' cannot be after 'end'
In addition: Warning message:
In window.default(mergedall, start = c(as.Date(as.character("2014-06-16"))),  :
  'end' value not changed`

Body:
Again it's an old post. But since I stumbled upon it by searching the same error. I want to still provide something useful for future Googlers.

I could not replicate your issue because you did not provide your own mergedall dataset. So I am starting with a toy example to show a few places where the problem might be. It's really not that difficult at all.

Potential problem #1:

You did not create a ts object to begin with. Window function operates on a ts object, and it cannot just be a vector took directly from a df. Use ts function to make a vector a ts object first. And then assign it with proper start, end, frequency.

all <-seq(1:8) #eight observations in sequence

Assign these eight values as monthly observations, starting from 201406 to 201501. Frequency 12 means monthly.

all.ts <- ts(all, start = c(2014,6), end = c(2015,1), frequency = 12)

Potential problem #2:

You perhaps already assigned your mergedall series as a ts object, but with different start/end/frequency. My example above was based on monthly observations. So even though they are correct examples, they will not match with your daily-based window function. Window function and the ts object needs to be consistent.

Following my example, the window function would look like:

newdata1 <-window(all.ts,start=c(2014,6),end=c(2015,1) )


问:
JavaScript positional property access in Objects
I have the following JavaScript object:

```<code>{
  "_embedded": {
    "dealerListItemDToes": [
      {
        ...
      },
      {
        ...
      }
    ]
  }
}
</code>```

Property called 'dealerListItemDToes' will always be at the given position in the object but its name can vary depending on the HTTP requests.

How can I access the property 'dealerListItemDToes' and retrieve its content without referencing its name?

答:
You can try like this

let data = {
  "_embedded": {
    "dealerListItemDToes": [{
      "h": 1
    }]
  }
}

console.log(data._embedded[Object.keys(data._embedded)[0]])```

Body:
I have the following JavaScript object:

{
  "_embedded": {
    "dealerListItemDToes": [
      {
        ...
      },
      {
        ...
      }
    ]
  }
}

Property called 'dealerListItemDToes' will always be at the given position in the object but its name can vary depending on the HTTP requests.

How can I access the property 'dealerListItemDToes' and retrieve its content without referencing its name?


问:
Does creating a CTE in this case helps?
I have a query written very poorly in SQL Server 2008

```<code>UPDATE  PatientChartImages
SET     PatientChartImages.IsLockDown = @IsLockdown
WHERE   PatientChartImages.IsLockDown = @IsNotLockdown
    AND PatientChartId IN (
    SELECT  PatientCharts.PatientChartId
    FROM    PatientCharts
    WHERE   ( PatientCharts.ChartStatusID = @ChartCompletedStatusID
              OR PatientCharts.ChartStatusID = @ChartOnBaseStatusID
            )
            AND PatientCharts.IsLockDown = @IsNotLockdown
            AND PatientCharts.CompletedOn IS NOT NULL
            AND DATEDIFF(MINUTE, PatientCharts.CompletedOn, GETUTCDATE()) >= ( SELECT
                                                          tf.LockUpInterval
                                                          FROM
                                                          @tblFacCOnf tf
                                                          WHERE
                                                          tf.facilityId = PatientCharts.FacilityId
                                                          ) )
</code>```

This query locks the main table and results in TimeOut. IF i create a CTE first of all the updateable records and then update the main table by joining to the CTE. Will it help ??

答:
I think you should create an SQL script (or stored procedure, if you will use it from a higher level) where you store the results of your selection into a cursor (you'll only have to find the PatientCartId's of the rows to be updated) and then you should use it in your update, so, the answer is yes.

It's easy to test this, you should put these commands into a transaction, rollback the transaction and before the rollback you should perform a selection to test your results. Good luck.

Title: Does creating a CTE in this case helps?

Body:
I have a query written very poorly in SQL Server 2008

UPDATE  PatientChartImages
SET     PatientChartImages.IsLockDown = @IsLockdown
WHERE   PatientChartImages.IsLockDown = @IsNotLockdown
    AND PatientChartId IN (
    SELECT  PatientCharts.PatientChartId
    FROM    PatientCharts
    WHERE   ( PatientCharts.ChartStatusID = @ChartCompletedStatusID
              OR PatientCharts.ChartStatusID = @ChartOnBaseStatusID
            )
            AND PatientCharts.IsLockDown = @IsNotLockdown
            AND PatientCharts.CompletedOn IS NOT NULL
            AND DATEDIFF(MINUTE, PatientCharts.CompletedOn, GETUTCDATE()) >= ( SELECT
                                                          tf.LockUpInterval
                                                          FROM
                                                          @tblFacCOnf tf
                                                          WHERE
                                                          tf.facilityId = PatientCharts.FacilityId
                                                          ) )

This query locks the main table and results in TimeOut. IF i create a CTE first of all the updateable records and then update the main table by joining to the CTE. Will it help ??


问:
Proper way to create Custom Bindable WPF Control
I want to ask about the right way if I want to create Bindable user control consisting of two controls. I am not sure about what I am doing - whether I do it correctly  , because I run into some problems.

Here is what I am trying to do:

Lets call this control ucFlagControl . Create new , custom user control ...
Its purpose is to show Color interpretation of logic ( True/ False ) value in variable , type of Bool.

What I used to do before was that I use Rectangle, and Bind FillProperty to boolean value using Converter

What I did to make it works was , that I made a usercontrol , and put rectangle and label inside
than I added this code:

```<code> public partial class ucStatusFlag : UserControl
{
    public ucStatusFlag()
    {
        InitializeComponent();

    }

    public string LabelContent
    {
        get { return (string)GetValue(LabelContentProperty); }
        set
        {
            SetValue(LabelContentProperty, value);
            OnPropertyChanged("LabelContent");
        }
    }

    ///in case that I use integer or array
    public int BitIndex
    {
        get { return (int)GetValue(BitIndexProperty); }
        set
        {
            SetValue(BitIndexProperty, value);
            OnPropertyChanged("BitIndex");
        }
    }

    public string BindingSource
    {
        get { return (string)GetValue(BindingSourceProperty); }
        set
        {
            SetValue(BindingSourceProperty, value);
            OnPropertyChanged("BindingSource");
        }
    }

    public event PropertyChangedEventHandler PropertyChanged;

    protected void OnPropertyChanged(string name)
    {
        if (PropertyChanged != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs(name));
        }
    }

    /// <summary>
    /// Identified the Label dependency property
    /// </summary>
    public static readonly DependencyProperty LabelContentProperty =
        DependencyProperty.Register("LabelContent", typeof(string), typeof(ucStatusFlag), new PropertyMetadata("LabelContent"));

    public static readonly DependencyProperty BitIndexProperty =
        DependencyProperty.Register("BitIndex", typeof(int), typeof(ucStatusFlag), new PropertyMetadata(0));

    public static readonly DependencyProperty BindingSourceProperty =
        DependencyProperty.Register("(BindingSource", typeof(string), typeof(ucStatusFlag), new PropertyMetadata(""));

    private void StatusFlag_Loaded(object sender, RoutedEventArgs e)
    {
        if (BindingSource.Length > 0)
        {
            Binding bind = new Binding();
            string s = LabelContent;
            int i = BitIndex;

             bind.Converter = new StatusToColor();

            bind.Path = new PropertyPath(BindingSource);
            bind.ConverterParameter = BitIndex.ToString();
            bind.Mode = BindingMode.OneWay;
            bind.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            recStatusBit.SetBinding(Rectangle.FillProperty, bind);
        }
    }

    private class StatusToColor : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {

            byte bDataWordIdx;
            byte bDataBitIdx;

            Byte.TryParse((string)parameter, out bDataBitIdx);

            if (Object.ReferenceEquals(typeof(UInt16[]), value.GetType()))
            {
                UInt16[] uiaData = (UInt16[])value;
                bDataWordIdx = (byte)uiaData[0];

                if ((uiaData[bDataBitIdx / 16] >> (bDataBitIdx % 16) & 0x1) == 1)
                {
                    return Brushes.Green;
                }
                else
                {
                    return Brushes.Red;
                }
            }
            else if (Object.ReferenceEquals(typeof(UInt16), value.GetType()))
            {
                UInt16 uiaData = (UInt16)value;

                if (((uiaData >> bDataBitIdx) & 0x1) == 1)
                {
                    return Brushes.Green;
                }
                else
                {
                    return Brushes.Red;
                }
            }
            return 0;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return 0;
        }
    }

}
</code>```

}
    Than I realized that I can easily bind content and I do not have to create public static readonly DependencyProperty LabelContentProperty

but just property

```<code> public new string Content
    {
        get { return (string)label.Content; }
        set
        {
            SetValue(label.Content, value);
            OnPropertyChanged("Content");
        }
    }
</code>```

this overrides the original content so I am able to Bind and/or  assign the text of the label in upper level - in e.g. MainWindow.xaml where this user control is put

First question is if this is in this case OK or if there is some background I am not aware of and I should even such small controls do in different way - I would like to make dll. from it an load it to toolbox  - I tested it works. And than use it in for example stack panel .

Second question is that I have problem with a rectangle "Fill" property . I am not able to bind that property like I bind content .
I know that the rectangle is derived from Shape class so I am not sure if it has something to do with this.

If I am able to do the inner binding or connection same as in

```<code>Content
</code>```

I can remove the converters than and just bind it in e.g. MainWindow.xaml file (using the converter and converter parameter )

But FillProperty does not work for me so I am not sure about my point of view .

Thank you for suggestions

EDIT:

well I am sorry but I did not catch all you want to say in a comment below. Could you please explain closer ?
I know that the code above is not the right way to do it ... ?
Or can you post any article about it ?
my actual code is like this:
In a user control ... I removed all the code from code behind ...

```<code>'  <Label x:Name="lStatusBit"  Grid.Column="1" Padding="0" VerticalContentAlignment="Center" Margin="2,1,17,2"  />
        <Rectangle x:Name="recStatusBit"  Margin="0,3,1,7" />'
</code>```

Content property works, I cant see Rectangle , and rectangle fill property ...
Other problem is if I fill in Content property in XAML where my uc is placed ,  Rectangle disappears .

答:
Finally I found this working :

XAML

```<code><UserControl x:Class="ucStatusFlag"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         mc:Ignorable="d"
         d:DesignHeight="17" d:DesignWidth="100"
         x:Name="StatusFlag">
<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="auto"/>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    <Rectangle x:Name="recStatusBit" Grid.Column="0" Stroke="Black" Width="11"  Fill="{Binding ElementName=StatusFlag, Path=RectangleColor}" Margin="0,2,0.2,3.8"  />
    <Label  Height="17" x:Name="lStatusBit" Foreground="Black" Grid.Column="1" Padding="0" VerticalContentAlignment="Center" Margin="5,0,0,1" Content="{Binding ElementName=StatusFlag, Path=LabelContent}" />
</Grid>
</code>```

C#

```<code> public partial class ucStatusFlag : UserControl
{
    public ucStatusFlag()
    {
        InitializeComponent();

    }

    public string LabelContent
    {
        get { return (string)GetValue(LabelContentProperty); }
        set
        {
            SetValue(LabelContentProperty, value);

        }
    }

    public SolidColorBrush RectangleColor
    {
        get { return (SolidColorBrush)GetValue(RectangleColorProperty); }
        set
        {
            SetValue(RectangleColorProperty, value);

        }
    }

    public static readonly DependencyProperty RectangleColorProperty =
        DependencyProperty.Register("RectangleColor", typeof(SolidColorBrush), typeof(ucStatusFlag), new PropertyMetadata(Brushes.Gold));

    public static readonly DependencyProperty LabelContentProperty =
         DependencyProperty.Register("LabelContent", typeof(string), typeof(ucStatusFlag), new PropertyMetadata("LabelContent"));

}
</code>```

Binding in Another Project :

```<code>   <ucStatusFlag HorizontalAlignment="Left" Height="18" Margin="154,224,0,0" VerticalAlignment="Top" Width="100" LabelContent="ABC" RectangleColor="{Binding RectangleColorPropertyInProject}"/>
</code>```

Where RectangleColorPropertyInProject is Property In certain project view model

Body:
I want to ask about the right way if I want to create Bindable user control consisting of two controls. I am not sure about what I am doing - whether I do it correctly  , because I run into some problems.

Here is what I am trying to do:

Lets call this control ucFlagControl . Create new , custom user control ...
Its purpose is to show Color interpretation of logic ( True/ False ) value in variable , type of Bool.

What I used to do before was that I use Rectangle, and Bind FillProperty to boolean value using Converter

What I did to make it works was , that I made a usercontrol , and put rectangle and label inside
than I added this code:

 public partial class ucStatusFlag : UserControl
{
    public ucStatusFlag()
    {
        InitializeComponent();

    }

    public string LabelContent
    {
        get { return (string)GetValue(LabelContentProperty); }
        set
        {
            SetValue(LabelContentProperty, value);
            OnPropertyChanged("LabelContent");
        }
    }

    ///in case that I use integer or array
    public int BitIndex
    {
        get { return (int)GetValue(BitIndexProperty); }
        set
        {
            SetValue(BitIndexProperty, value);
            OnPropertyChanged("BitIndex");
        }
    }

    public string BindingSource
    {
        get { return (string)GetValue(BindingSourceProperty); }
        set
        {
            SetValue(BindingSourceProperty, value);
            OnPropertyChanged("BindingSource");
        }
    }

    public event PropertyChangedEventHandler PropertyChanged;

    protected void OnPropertyChanged(string name)
    {
        if (PropertyChanged != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs(name));
        }
    }

    ///
    /// Identified the Label dependency property
    ///
    public static readonly DependencyProperty LabelContentProperty =
        DependencyProperty.Register("LabelContent", typeof(string), typeof(ucStatusFlag), new PropertyMetadata("LabelContent"));

    public static readonly DependencyProperty BitIndexProperty =
        DependencyProperty.Register("BitIndex", typeof(int), typeof(ucStatusFlag), new PropertyMetadata(0));

    public static readonly DependencyProperty BindingSourceProperty =
        DependencyProperty.Register("(BindingSource", typeof(string), typeof(ucStatusFlag), new PropertyMetadata(""));

    private void StatusFlag_Loaded(object sender, RoutedEventArgs e)
    {
        if (BindingSource.Length > 0)
        {
            Binding bind = new Binding();
            string s = LabelContent;
            int i = BitIndex;

             bind.Converter = new StatusToColor();

            bind.Path = new PropertyPath(BindingSource);
            bind.ConverterParameter = BitIndex.ToString();
            bind.Mode = BindingMode.OneWay;
            bind.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            recStatusBit.SetBinding(Rectangle.FillProperty, bind);
        }
    }

    private class StatusToColor : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {

            byte bDataWordIdx;
            byte bDataBitIdx;

            Byte.TryParse((string)parameter, out bDataBitIdx);

            if (Object.ReferenceEquals(typeof(UInt16[]), value.GetType()))
            {
                UInt16[] uiaData = (UInt16[])value;
                bDataWordIdx = (byte)uiaData[0];

                if ((uiaData[bDataBitIdx / 16] >> (bDataBitIdx % 16) & 0x1) == 1)
                {
                    return Brushes.Green;
                }
                else
                {
                    return Brushes.Red;
                }
            }
            else if (Object.ReferenceEquals(typeof(UInt16), value.GetType()))
            {
                UInt16 uiaData = (UInt16)value;

                if (((uiaData >> bDataBitIdx) & 0x1) == 1)
                {
                    return Brushes.Green;
                }
                else
                {
                    return Brushes.Red;
                }
            }
            return 0;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return 0;
        }
    }

}

}
    Than I realized that I can easily bind content and I do not have to create public static readonly DependencyProperty LabelContentProperty

but just property

 public new string Content
    {
        get { return (string)label.Content; }
        set
        {
            SetValue(label.Content, value);
            OnPropertyChanged("Content");
        }
    }

this overrides the original content so I am able to Bind and/or  assign the text of the label in upper level - in e.g. MainWindow.xaml where this user control is put

First question is if this is in this case OK or if there is some background I am not aware of and I should even such small controls do in different way - I would like to make dll. from it an load it to toolbox  - I tested it works. And than use it in for example stack panel .

Second question is that I have problem with a rectangle "Fill" property . I am not able to bind that property like I bind content .
I know that the rectangle is derived from Shape class so I am not sure if it has something to do with this.

If I am able to do the inner binding or connection same as in

Content

I can remove the converters than and just bind it in e.g. MainWindow.xaml file (using the converter and converter parameter )

But FillProperty does not work for me so I am not sure about my point of view .

Thank you for suggestions

EDIT:

well I am sorry but I did not catch all you want to say in a comment below. Could you please explain closer ?
I know that the code above is not the right way to do it ... ?
Or can you post any article about it ?
my actual code is like this:
In a user control ... I removed all the code from code behind ...

'
        <Rectangle x:Name="recStatusBit"  Margin="0,3,1,7" />'

Content property works, I cant see Rectangle , and rectangle fill property ...
Other problem is if I fill in Content property in XAML where my uc is placed ,  Rectangle disappears .

Body:
Finally I found this working :

XAML

<UserControl x:Class="ucStatusFlag"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         mc:Ignorable="d"
         d:DesignHeight="17" d:DesignWidth="100"
         x:Name="StatusFlag">
<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="auto"/>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    <Rectangle x:Name="recStatusBit" Grid.Column="0" Stroke="Black" Width="11"  Fill="{Binding ElementName=StatusFlag, Path=RectangleColor}" Margin="0,2,0.2,3.8"  />
    <Label  Height="17" x:Name="lStatusBit" Foreground="Black" Grid.Column="1" Padding="0" VerticalContentAlignment="Center" Margin="5,0,0,1" Content="{Binding ElementName=StatusFlag, Path=LabelContent}" />
</Grid>

C#

 public partial class ucStatusFlag : UserControl
{
    public ucStatusFlag()
    {
        InitializeComponent();

    }

    public string LabelContent
    {
        get { return (string)GetValue(LabelContentProperty); }
        set
        {
            SetValue(LabelContentProperty, value);

        }
    }

    public SolidColorBrush RectangleColor
    {
        get { return (SolidColorBrush)GetValue(RectangleColorProperty); }
        set
        {
            SetValue(RectangleColorProperty, value);

        }
    }

    public static readonly DependencyProperty RectangleColorProperty =
        DependencyProperty.Register("RectangleColor", typeof(SolidColorBrush), typeof(ucStatusFlag), new PropertyMetadata(Brushes.Gold));

    public static readonly DependencyProperty LabelContentProperty =
         DependencyProperty.Register("LabelContent", typeof(string), typeof(ucStatusFlag), new PropertyMetadata("LabelContent"));

}

Binding in Another Project :

   <ucStatusFlag HorizontalAlignment="Left" Height="18" Margin="154,224,0,0" VerticalAlignment="Top" Width="100" LabelContent="ABC" RectangleColor="{Binding RectangleColorPropertyInProject}"/>

Where RectangleColorPropertyInProject is Property In certain project view model


问:
JSDoc how to add member to type without creating new typedef
Supposedly I have a type called A and B

```<code>/**
 * @typedef A
 * @type {object}
 * @property {String} id this is id A
 * @property {String} name this is name A
 * @property {String} child_id this is id B
 */

/**
 * @typedef B
 * @type {object}
 * @property {String} id this is id A
 * @property {Number} qty this is qty B
 */
</code>```

Is there anyway I can have something like

```<code>{
   id:"a",
   name:"a",
   B:{
     id: "b",
     qty:0
   }
}
</code>```

without rewriting typedef?

I have a function returning Sequelize Object thats why

答:
From my reading of your question it sounds like you can solve it by amending the typedef for A like so, given the expected output object you provided.

```<code>/**
 * @typedef A
 * @type {object}
 * @property {String} id this is id A
 * @property {String} name this is name A
 * @property {B} type B
 */

/**
 * @typedef B
 * @type {object}
 * @property {String} id
 * @property {Number} qty
 */
</code>```

Unless you need a field that specific references the id of the child B object? And you don't want to explicitly define the child B relationship for some reason. In that case you could do this and specify B as optional.

```<code>/**
 * @typedef A
 * @type {object}
 * @property {String} id this is id A
 * @property {String} name this is name A
 * @property {String} idOfB - A string that holds the id from B
 * @property {B} [B] - Notice the square brackets, this makes it an optional property.
 */
</code>```

Here is what the resulting JSDoc looks like when VSCode provides type assistance

Body:
Supposedly I have a type called A and B

/**
 * @typedef A
 * @type {object}
 * @property {String} id this is id A
 * @property {String} name this is name A
 * @property {String} child_id this is id B
 */

/**
 * @typedef B
 * @type {object}
 * @property {String} id this is id A
 * @property {Number} qty this is qty B
 */

Is there anyway I can have something like

{
   id:"a",
   name:"a",
   B:{
     id: "b",
     qty:0
   }
}

without rewriting typedef?

I have a function returning Sequelize Object thats why

Body:
From my reading of your question it sounds like you can solve it by amending the typedef for A like so, given the expected output object you provided.

/**
 * @typedef A
 * @type {object}
 * @property {String} id this is id A
 * @property {String} name this is name A
 * @property {B} type B
 */

/**
 * @typedef B
 * @type {object}
 * @property {String} id
 * @property {Number} qty
 */

Unless you need a field that specific references the id of the child B object? And you don't want to explicitly define the child B relationship for some reason. In that case you could do this and specify B as optional.

/**
 * @typedef A
 * @type {object}
 * @property {String} id this is id A
 * @property {String} name this is name A
 * @property {String} idOfB - A string that holds the id from B
 * @property {B} [B] - Notice the square brackets, this makes it an optional property.
 */

Here is what the resulting JSDoc looks like when VSCode provides type assistance


问:
Getting "unable to resolve method using strict-mode: org.drools.core.spi.KnowledgeHelper.throw()" when throwing an exception on DRL file
I am trying drools integration with Spring Boot and would like to throw an exception if a property of a model is not satisfied.

For this case, I have a Client model and would like to check if its lastName field is NULL - if so then throw an exception.

However, I am getting an "unable to resolve method using strict-mode: org.drools.core.spi.KnowledgeHelper.throw()" during compile time. What is the correct way to try this?

I have tried to use global to update a field and it is working however, for convenience, I would just like to throw an exception with a message.

Below is my config file:

```<code>@Configuration
public class CreateClientRuleEngineConfig {

    public static final String bhfCreateClientRule = "CreateClientRule.drl";

    @Bean
    public KieContainer kieContainer() {
        KieServices kieServices = KieServices.Factory.get();

        KieFileSystem kieFileSystem = kieServices.newKieFileSystem();
        kieFileSystem.write(ResourceFactory.newClassPathResource(bhfCreateClientRule));
        KieBuilder kieBuilder = kieServices.newKieBuilder(kieFileSystem);
        kieBuilder.buildAll();
        KieModule kieModule = kieBuilder.getKieModule();

        return kieServices.newKieContainer(kieModule.getReleaseId());

    }

}
</code>```

=========================================
Below is my DRL file:

```<code>import com.test.rulengine.entity.Client;
import com.test.rulengine.exception.CreateClientException;

dialect  "mvel"

rule "Required fields"
    when
        clientInstance: Client( lastName == null);
    then
        throw new CreateClientException("LastName is required");
end
</code>```

=========================================

Below is my Maven Dependency (note: I did not include other dependencies not related Drools/Kie):

```<code>    <properties>
        <java.version>1.8</java.version>
        <drools-version>7.0.0.Final</drools-version>
        <kie-version>7.0.0.Final</kie-version>
    </properties>

    <dependencies>

        <!-- Drools/Kie dependencies -->
        <dependency>
            <groupId>org.drools</groupId>
            <artifactId>drools-core</artifactId>
            <version>${drools-version}</version>
        </dependency>
        <dependency>
            <groupId>org.kie</groupId>
            <artifactId>kie-spring</artifactId>
            <version>${kie-version}</version>
        </dependency>
</code>```

=========================================

Here is the error during compile:

Unable to Analyse Expression throw new CreateClientException("LastName is required");:
  [Error: unable to resolve method using strict-mode: org.drools.core.spi.KnowledgeHelper.throw()]
  [Near : {... throw new CreateClientExceptio ....}]
               ^
  [Line: 6, Column: 0] : [Rule name='Required fields']

I have checked this link regarding this and I really cant figure out what I am missing. Thank you in advance

答: You have to remove "dialect  "mvel"" keyword in your drl file.</p>

Body:
I am trying drools integration with Spring Boot and would like to throw an exception if a property of a model is not satisfied.

For this case, I have a Client model and would like to check if its lastName field is NULL - if so then throw an exception.

However, I am getting an "unable to resolve method using strict-mode: org.drools.core.spi.KnowledgeHelper.throw()" during compile time. What is the correct way to try this?

I have tried to use global to update a field and it is working however, for convenience, I would just like to throw an exception with a message.

Below is my config file:

@Configuration
public class CreateClientRuleEngineConfig {

    public static final String bhfCreateClientRule = "CreateClientRule.drl";

    @Bean
    public KieContainer kieContainer() {
        KieServices kieServices = KieServices.Factory.get();

        KieFileSystem kieFileSystem = kieServices.newKieFileSystem();
        kieFileSystem.write(ResourceFactory.newClassPathResource(bhfCreateClientRule));
        KieBuilder kieBuilder = kieServices.newKieBuilder(kieFileSystem);
        kieBuilder.buildAll();
        KieModule kieModule = kieBuilder.getKieModule();

        return kieServices.newKieContainer(kieModule.getReleaseId());

    }

}

=========================================
Below is my DRL file:

import com.test.rulengine.entity.Client;
import com.test.rulengine.exception.CreateClientException;

dialect  "mvel"

rule "Required fields"
    when
        clientInstance: Client( lastName == null);
    then
        throw new CreateClientException("LastName is required");
end

=========================================

Below is my Maven Dependency (note: I did not include other dependencies not related Drools/Kie):

    <properties>
        <java.version>1.8</java.version>
        <drools-version>7.0.0.Final</drools-version>
        <kie-version>7.0.0.Final</kie-version>
    </properties>

    <dependencies>

        <dependency>
            <groupId>org.drools</groupId>
            <artifactId>drools-core</artifactId>
            <version>${drools-version}</version>
        </dependency>
        <dependency>
            <groupId>org.kie</groupId>
            <artifactId>kie-spring</artifactId>
            <version>${kie-version}</version>
        </dependency>

=========================================

Here is the error during compile:

Unable to Analyse Expression throw new CreateClientException("LastName is required");:
  [Error: unable to resolve method using strict-mode: org.drools.core.spi.KnowledgeHelper.throw()]
  [Near : {... throw new CreateClientExceptio ....}]
               ^
  [Line: 6, Column: 0] : [Rule name='Required fields']

I have checked this link regarding this and I really cant figure out what I am missing. Thank you in advance


问:
How can I get npm to create a .min.css file from scss?
I'm automatically compiling css from scss using a json script, but it's removing ".min" from the suffix. This is the terminal output which shows the script that I'm running and the file that is rendering:

```<code>PS C:\Projects\myproject> npm run globalscss

> myproject@1.0.0 globalscss C:\Projects\myproject
> node-sass -w scss/usn-global.scss -o css css/usn-global.min.css --output-style compressed

=> changed: C:\Projects\myproject\scss\usn-global.scss
Rendering Complete, saving .css file...
Wrote CSS to C:\Projects\myproject\css\usn-global.css
</code>```

I'm expecting to see the script write to C:\Projects\myproject\css\usn-global.min.css

But the script is writing to C:\Projects\myproject\css\usn-global.css

Is there a problem with having a double suffix?

答:
As long as you are using the -o, --output flag, node-sass will always compile the input file to the given output directory with the same filename.

If you omit the output flag and pipe the output to the folder instead, it's possible to target the suffixed filename you want.

Example:

```<code>node-sass --output-style compressed scss/usn-global.scss > css/usn-global.min.css
</code>```

This will work as long as the css folder exists.

However it seems according to this issue that it's not possible to combine this command with the -w, --watch flag. There are options to renaming files with npm scripts though.

If you stick to your current workflow with the watcher intact, you can add another npm script to your package.json file, maybe something like this:

```<code>"scripts": {
    "rename": "node -e \"require('fs').rename('css/usn-global.css', 'css/usn-global.min.css', function(err) { if (err) console.log(err); console.log('CSS file renamed with .min suffix!') })\""
}
</code>```

...meaning that when you're done CSS-ing, you'd need to run npm run rename to get the correct filename.

Body:
I'm automatically compiling css from scss using a json script, but it's removing ".min" from the suffix. This is the terminal output which shows the script that I'm running and the file that is rendering:

PS C:\Projects\myproject> npm run globalscss

> myproject@1.0.0 globalscss C:\Projects\myproject
> node-sass -w scss/usn-global.scss -o css css/usn-global.min.css --output-style compressed

=> changed: C:\Projects\myproject\scss\usn-global.scss
Rendering Complete, saving .css file...
Wrote CSS to C:\Projects\myproject\css\usn-global.css

I'm expecting to see the script write to C:\Projects\myproject\css\usn-global.min.css

But the script is writing to C:\Projects\myproject\css\usn-global.css

Is there a problem with having a double suffix?

Body:
As long as you are using the -o, --output flag, node-sass will always compile the input file to the given output directory with the same filename.

If you omit the output flag and pipe the output to the folder instead, it's possible to target the suffixed filename you want.

Example:

node-sass --output-style compressed scss/usn-global.scss > css/usn-global.min.css

This will work as long as the css folder exists.

However it seems according to this issue that it's not possible to combine this command with the -w, --watch flag. There are options to renaming files with npm scripts though.

If you stick to your current workflow with the watcher intact, you can add another npm script to your package.json file, maybe something like this:

"scripts": {
    "rename": "node -e \"require('fs').rename('css/usn-global.css', 'css/usn-global.min.css', function(err) { if (err) console.log(err); console.log('CSS file renamed with .min suffix!') })\""
}

...meaning that when you're done CSS-ing, you'd need to run npm run rename to get the correct filename.


问:
How to convert a list to json in python
have a list with values

```<code>test = ["mark","will","john"]

</code>```

using for loop how to convert this into JSON like this

```<code>test =[{"name":"mark"},{"name":"john"},{"name":"will"}]
</code>```

Tried this

```<code>for i in test :
    print({"name":i})

</code>```

答:
functional way using map()

```<code>test = ["mark", "will", "john"]

toJson = lambda _name: {"name": _name} # this expression returns {"name": name} for every iterated "_name"

testJson = map(toJson, test)

for name in testJson:
  print(name)
</code>```

to print a list of a map object cast it to list, example list(testJson)
and you can replace toJson with your lambda expression to customize the result

Title: How to convert a list to json in python

Body:
have a list with values

test = ["mark","will","john"]

using for loop how to convert this into JSON like this

test =[{"name":"mark"},{"name":"john"},{"name":"will"}]

Tried this

for i in test :
    print({"name":i})

Body:
functional way using map()

test = ["mark", "will", "john"]

toJson = lambda _name: {"name": _name} # this expression returns {"name": name} for every iterated "_name"

testJson = map(toJson, test)

for name in testJson:
  print(name)

to print a list of a map object cast it to list, example list(testJson)
and you can replace toJson with your lambda expression to customize the result


问:
Print Date and Time In Visual Studio C++ build?
How would I print the date and time for the purposes of the build. Ie: When the console for my application starts up I want to do this:

```<code>Binary Build date: 03/03/2009 @ 10:00AM
</code>```

I think this would be a super useful function for all applications to have behind the scenes for programmers, especially in a team environment.

Is there a simple way to do this using Visual Studio 2008 in C++. Thanks.

答:
Use preprocessor's __DATE__ and __TIME__.

```<code>printf("Binary build date: %s @ %s\n", __DATE__, __TIME__);
</code>```

For making sure that cpp file that contains this code is really compiled, I use touch-utility for file as a pre-build step: touch file.cpp

Touch.bat:

```<code>@copy nul: /b +%1 tmp.$$$
@move tmp.$$$ %1
</code>```

OwnerDisplayName: Brock Woolf

Body:
How would I print the date and time for the purposes of the build. Ie: When the console for my application starts up I want to do this:

Binary Build date: 03/03/2009 @ 10:00AM

I think this would be a super useful function for all applications to have behind the scenes for programmers, especially in a team environment.

Is there a simple way to do this using Visual Studio 2008 in C++. Thanks.

LastEditorDisplayName: Iraimbilanja

Body:
Use preprocessor's __DATE__ and __TIME__.

printf("Binary build date: %s @ %s\n", __DATE__, __TIME__);

For making sure that cpp file that contains this code is really compiled, I use touch-utility for file as a pre-build step: touch file.cpp

Touch.bat:

@copy nul: /b +%1 tmp.$$$
@move tmp.$$$ %1

OwnerDisplayName: Virne

LastEditorDisplayName: Virne


问:
Binance Crypto Exchange API Error -1131 recvWindow must be less than 60000
I have a problem with my PHP script which was working before without problem. I dont know whay it have stop to work, because i dont have change anythink.

I am getting the error message:

array(2) { ["code"]=> int(-1131) ["msg"]=> string(37) "'recvWindow' must be less than 60000." }

So i did think ok easy i will just make the setting "recvWindow" smaller then "60000", but then the next error message comes also somethink with "recvWindow"

array(2) { ["code"]=> int(-1021) ["msg"]=> string(56) "Timestamp for this request is outside of the recvWindow." }

So what is wrong what must i do to make it work again? Here is the complete script which i have:

```<code>        <?php
        //--API Call
        $nonce=time();
        //--
        $url='recvWindow=10000000000000000&timestamp='.$nonce;
        //--
        $sign=hash_hmac('SHA256',$url,$apisecret);
        $url=$url.'&signature='.$sign;
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-MBX-APIKEY:'.$apikey));
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($ch, CURLOPT_URL, "https://api.binance.com/api/v3/account?".$url);
        $execResult = curl_exec($ch);
        $Balances = json_decode($execResult, true);
        var_dump($Balances);
        ?>
</code>```

答:
i did slove the problem, if you write the nonce parameter in milliseconds instead of seconds, then it works, and try to change the recwindow value also if you still get difficulties:

$nonce=round(microtime(true) * 1000); //time();

Body:
I have a problem with my PHP script which was working before without problem. I dont know whay it have stop to work, because i dont have change anythink.

I am getting the error message:

array(2) { ["code"]=> int(-1131) ["msg"]=> string(37) "'recvWindow' must be less than 60000." }

So i did think ok easy i will just make the setting "recvWindow" smaller then "60000", but then the next error message comes also somethink with "recvWindow"

array(2) { ["code"]=> int(-1021) ["msg"]=> string(56) "Timestamp for this request is outside of the recvWindow." }

So what is wrong what must i do to make it work again? Here is the complete script which i have:

        <?php
        //--API Call
        $nonce=time();
        //--
        $url='recvWindow=10000000000000000&timestamp='.$nonce;
        //--
        $sign=hash_hmac('SHA256',$url,$apisecret);
        $url=$url.'&signature='.$sign;
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-MBX-APIKEY:'.$apikey));
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($ch, CURLOPT_URL, "https://api.binance.com/api/v3/account?".$url);
        $execResult = curl_exec($ch);
        $Balances = json_decode($execResult, true);
        var_dump($Balances);
        ?>


问:
Mutilple delimiter pandas txt
I am trying to turn a long string in a .txt file into a 2D pandas table

```<code>[{"CAN":"5420060701","VAL":"0"},{"CAN":"1920010101","VAL":"1"},{"CAN":"1920020101","VAL":"1"},...]
</code>```

Into

```<code>+----CAN-----+----VAL--+
+-5420060701-+----0----+
+-1920010101-+----1----+
+-1920020101-+----1----+
</code>```

....

I thought about pd.read_fwf but my value as different width, (i.e can be 65000 sometimes).

I though about pd.read_csv(file,  delimiter=',') but it returns a long row that is hard to reshape.

I have seen from a separate thread I could use genfromtxtfrom numpy but did not get it to run.

答:
Just use pandas read_json method:</p>

```<code>df = pd.read_json('jsn.txt')
print(df.head())
</code>```

Title: Mutilple delimiter pandas txt

Body:
I am trying to turn a long string in a .txt file into a 2D pandas table

[{"CAN":"5420060701","VAL":"0"},{"CAN":"1920010101","VAL":"1"},{"CAN":"1920020101","VAL":"1"},...]

Into

+----CAN-----+----VAL--+
+-5420060701-+----0----+
+-1920010101-+----1----+
+-1920020101-+----1----+

....

I thought about pd.read_fwf but my value as different width, (i.e can be 65000 sometimes).

I though about pd.read_csv(file,  delimiter=',') but it returns a long row that is hard to reshape.

I have seen from a separate thread I could use genfromtxtfrom numpy but did not get it to run.

Body:
Just use pandas read_json method:

df = pd.read_json('jsn.txt')
print(df.head())


答:
.main{
background-image: url('https://cdn.pixabay.com/photo/2020/02/14/04/20/old-city-4847469_960_720.jpg');
background-position: center top;
background-repeat: no-repeat;
background-size: cover;

}

.navbar{
    height: 20vh;
     background-color: rgba(0,0,0,0.5);
    position: relative;
    width: 100%;
    z-index: 999;
    color: #fff;
    padding: 20px;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="main">
    <div class="navbar container-fluid d-flex justify-content-center">
        <i class="fab fa-react fa-3x firstIcon mr-4"> <span class="txtIcon"> Project</span></i>
        <i class="fas fa-check-square fa-3x mx-4"> <span class="txtIcon2"> Skills</span></i>
        <i class="fas fa-id-card fa-3x ml-4"> <span class="txtIcon3"> Contact</span></i>
    </div>
</div></code>```

Title: How to display my background-image in my html/css?

Body:
I've seen another topic about my issue, but it doesn't resolve it, I try to put a background image for my portfolio but it doesn't work. I don't understand why, do you have an idea ?

my code:

html:

          Project
          Skills
          Contact

css:

.main{
background-image: url(../img/dev-dots.png);
background-position: center;
background-repeat: no-repeat;
background-size: cover;

}

.navbar{
    height: 10vh;
    background-color: purple;
    position: fixed;
}

PS: Sorry for my english, it's not my first language.

Body:
.main{
background-image: url('https://cdn.pixabay.com/photo/2020/02/14/04/20/old-city-4847469_960_720.jpg');
background-position: center top;
background-repeat: no-repeat;
background-size: cover;

}

.navbar{
    height: 20vh;
     background-color: rgba(0,0,0,0.5);
    position: relative;
    width: 100%;
    z-index: 999;
    color: #fff;
    padding: 20px;
}

<div class="main">
    <div class="navbar container-fluid d-flex justify-content-center">
        <i class="fab fa-react fa-3x firstIcon mr-4"> <span class="txtIcon"> Project</span></i>
        <i class="fas fa-check-square fa-3x mx-4"> <span class="txtIcon2"> Skills</span></i>
        <i class="fas fa-id-card fa-3x ml-4"> <span class="txtIcon3"> Contact</span></i>
    </div>
</div>


问:
Laravel : Issue in database connection when use # keyword in env file
When use # keyword in env file like below

```<code>DB_PASSWORD=&#252525
</code>```

Database connection not happening in laravel, As in config/database.php file we just have password = & instead of full string

How can we resolve this issue

答:
Laravel consider # as a comment in environment file. So write in quotes If any text has # value in the text in environment file.</p>

```<code>DB_PASSWORD='&#252525'
</code>```

Body:
When use # keyword in env file like below

DB_PASSWORD=&#252525

Database connection not happening in laravel, As in config/database.php file we just have password = & instead of full string

How can we resolve this issue

Body:
Laravel consider # as a comment in environment file. So write in quotes If any text has # value in the text in environment file.

DB_PASSWORD='&#252525'


问:
mmap fails with ENOMEM
I use mmap() in our application as:

```<code> mmap(NULL, get_size(), PROT_NONE,  MAP_ANONYMOUS | MAP_SHARED, -1, 0);
</code>```

But my intention here is just to reserve get_size() speicified amount of memory, but I don't intend to use it. Sometimes I see this mmap() fails with ENOMEM. The question is why mmap() should fail with ENOMEM here, when we just try to reserve the address space but not trying to actually use it. Is it because of MAP_SHARED?

答:
There is a limit on virtual memory size of a process which you can see with ulimit -v. If you are hitting that limit you can try removing it with ulimit -v unlimited. You can also get and set the limit programmatically with getrlimit/setrlimit POSIX functions.

The system default and hard limits are set in /etc/security/limits.conf and files from directory /etc/security/limits.d.

Another reason mmap fails with ENOMEM is exceeding the maximum number of memory mappings for a process controlled by vm.max_map_count configuration option of sysctl.

Title: mmap fails with ENOMEM

Body:
I use mmap() in our application as:

 mmap(NULL, get_size(), PROT_NONE,  MAP_ANONYMOUS | MAP_SHARED, -1, 0);

But my intention here is just to reserve get_size() speicified amount of memory, but I don't intend to use it. Sometimes I see this mmap() fails with ENOMEM. The question is why mmap() should fail with ENOMEM here, when we just try to reserve the address space but not trying to actually use it. Is it because of MAP_SHARED?