问:
If statement not working with .equals in Java and always showing the answer of else statement
I am learning Java myself and am trying to make a sign in like app. The if statement doesn't work but the else statement is always working.

Here is the code:

```<code>package Lessons;

public class Main extends Application {

    Stage window;

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

    @Override
    public void start(Stage primaryStage) {
        window = primaryStage;
        window.setTitle("Sign in");

        TextField nameInput = new TextField();

        Button button = new Button("Sign In");

        VBox layout = new VBox(10);
        layout.setPadding(new Insets(20, 20, 20,20));
        layout.getChildren().addAll(nameInput, button);

        Scene scene = new Scene(layout, 600, 600);
        window.setScene(scene);
        window.show();

        //Checks the username
        String username = "thomas";
        if (nameInput.getText().equals(username)) {
            button.setOnAction(e -> CorrectUsernameReplier.display());}
        else {
            button.setOnAction(e -> WrongUsernameReplier.display());
        }
    }
}
</code>```

I didn't show what I imported because I don't think they are necessary.

This is the code from the CorrectUsernameReplier

```<code>public static void display() {
    Stage window = new Stage();

    //Replies to correct username
    window.setTitle("Correct username");
    window.initModality(Modality.APPLICATION_MODAL);
    StackPane layout = new StackPane();
    Scene scene = new Scene(layout, 200, 200);
    Label label = new Label("Signed In");
    layout.getChildren().add(label);
    window.setScene(scene);
    window.showAndWait();
</code>```

This is the code from the WrongUsernameReplier

```<code>public static void display() {
    Stage window = new Stage();

    //Replies to incorrect username
    window.setTitle("Incorrect username");
    window.initModality(Modality.APPLICATION_MODAL);
    StackPane layout1 = new StackPane();
    Scene scene1 = new Scene(layout1, 200, 200);
    Label label = new Label("Incorrect Username. Please try again.");
    layout1.getChildren().add(label);
    window.setScene(scene1);
    window.showAndWait();
</code>```

Here are the images if what the error is:

"thomas" is in the TextField and the username string in the code above is also "thomas". But it shows the error you see.

This is the second image:

This is the screenshot which I type nothing in it. And the respond here is correct.

Can you please help me figure out what is wrong with my code?

答:
that because the condition is always false

```<code>@Override
public void start(Stage primaryStage) {
    ...
    TextField nameInput = new TextField();
    ...
    //Checks the username
    String username = "thomas";
    if (nameInput.getText().equals(username)) {
        button.setOnAction(e -> CorrectUsernameReplier.display());}
    else {
        button.setOnAction(e -> WrongUsernameReplier.display());
    }
}
</code>```

you just created new instance of TextField which has empty text, and you compare it with "thomas".

I think you want to do the compression when the button is clicked so  you do this

```<code>@Override
public void start(Stage primaryStage) {
    window = primaryStage;
    window.setTitle("Sign in");

    final TextField nameInput = new TextField();

    Button button = new Button("Sign In");

    VBox layout = new VBox(10);
    layout.setPadding(new Insets(20, 20, 20,20));
    layout.getChildren().addAll(nameInput, button);

    Scene scene = new Scene(layout, 600, 600);
    window.setScene(scene);
    window.show();

    button.setOnAction(e -> {
         String username = "thomas";
         if (nameInput.getText().equals(username)) {
               CorrectUsernameReplier.display();
         else {
               WrongUsernameReplier.display();
         }
    });

}
</code>```

Body:
I am learning Java myself and am trying to make a sign in like app. The if statement doesn't work but the else statement is always working.

Here is the code:

package Lessons;

public class Main extends Application {

    Stage window;

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

    @Override
    public void start(Stage primaryStage) {
        window = primaryStage;
        window.setTitle("Sign in");

        TextField nameInput = new TextField();

        Button button = new Button("Sign In");

        VBox layout = new VBox(10);
        layout.setPadding(new Insets(20, 20, 20,20));
        layout.getChildren().addAll(nameInput, button);

        Scene scene = new Scene(layout, 600, 600);
        window.setScene(scene);
        window.show();

        //Checks the username
        String username = "thomas";
        if (nameInput.getText().equals(username)) {
            button.setOnAction(e -> CorrectUsernameReplier.display());}
        else {
            button.setOnAction(e -> WrongUsernameReplier.display());
        }
    }
}

I didn't show what I imported because I don't think they are necessary.

This is the code from the CorrectUsernameReplier

public static void display() {
    Stage window = new Stage();

    //Replies to correct username
    window.setTitle("Correct username");
    window.initModality(Modality.APPLICATION_MODAL);
    StackPane layout = new StackPane();
    Scene scene = new Scene(layout, 200, 200);
    Label label = new Label("Signed In");
    layout.getChildren().add(label);
    window.setScene(scene);
    window.showAndWait();

This is the code from the WrongUsernameReplier

public static void display() {
    Stage window = new Stage();

    //Replies to incorrect username
    window.setTitle("Incorrect username");
    window.initModality(Modality.APPLICATION_MODAL);
    StackPane layout1 = new StackPane();
    Scene scene1 = new Scene(layout1, 200, 200);
    Label label = new Label("Incorrect Username. Please try again.");
    layout1.getChildren().add(label);
    window.setScene(scene1);
    window.showAndWait();

Here are the images if what the error is:

"thomas" is in the TextField and the username string in the code above is also "thomas". But it shows the error you see.

This is the second image:

This is the screenshot which I type nothing in it. And the respond here is correct.

Can you please help me figure out what is wrong with my code?

Body:
that because the condition is always false

@Override
public void start(Stage primaryStage) {
    ...
    TextField nameInput = new TextField();
    ...
    //Checks the username
    String username = "thomas";
    if (nameInput.getText().equals(username)) {
        button.setOnAction(e -> CorrectUsernameReplier.display());}
    else {
        button.setOnAction(e -> WrongUsernameReplier.display());
    }
}

you just created new instance of TextField which has empty text, and you compare it with "thomas".

I think you want to do the compression when the button is clicked so  you do this

@Override
public void start(Stage primaryStage) {
    window = primaryStage;
    window.setTitle("Sign in");

    final TextField nameInput = new TextField();

    Button button = new Button("Sign In");

    VBox layout = new VBox(10);
    layout.setPadding(new Insets(20, 20, 20,20));
    layout.getChildren().addAll(nameInput, button);

    Scene scene = new Scene(layout, 600, 600);
    window.setScene(scene);
    window.show();

    button.setOnAction(e -> {
         String username = "thomas";
         if (nameInput.getText().equals(username)) {
               CorrectUsernameReplier.display();
         else {
               WrongUsernameReplier.display();
         }
    });

}


来源: stackexchange

问:
SOAP: looks like we got no XML document
I'm trying to create a web service but before I do I'm trying to get a simple example that I found on the internet to work first but I keep getting the following error:

```<code>Fatal error: Uncaught SoapFault exception: [Client] looks like we got no XML document in C:\Documents and Settings\geoff\My Documents\Websites\jquery\index.php:20 Stack trace: #0 [internal function]: SoapClient->__call('getStockQuote', Array) #1 C:\Documents and Settings\geoff\My Documents\Websites\jquery\index.php(20): SoapClient->getStockQuote(Array) #2 {main} thrown in C:\Documents and Settings\geoff\My Documents\Websites\jquery\index.php on line 20
</code>```

I am using nusoap v1.94

My web service code looks like this:

```<code>function getStockQuote($symbol) {
$price = '1.23';
return $price;
}

require('nusoap.php');

$server = new soap_server();

$server->configureWSDL('stockserver', 'urn:stockquote');

$server->register("getStockQuote",
            array('symbol' => 'xsd:string'),
            array('return' => 'xsd:decimal'),
            'urn:stockquote',
            'urn:stockquote#getStockQuote');

$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA)
                  ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
</code>```

I know one cause is to have whitespace before or after your php tags in your server script but thats not the case. It has been driving me mad for hours! Any help would be much appreciated.

答:
The post is old, but I think it's always helpful, because I became crazy to not understand why this error appeared.

The solution for me was here: PHP SOAP client that understands multi-part messages?.

I had to extend the SoapClient to manage the MTOM encoding to obtain a clean XML as response.

I hope it can help someone.

ContentLicense: CC BY-SA 2.5

Title: SOAP: looks like we got no XML document

Body:
I'm trying to create a web service but before I do I'm trying to get a simple example that I found on the internet to work first but I keep getting the following error:

Fatal error: Uncaught SoapFault exception: [Client] looks like we got no XML document in C:\Documents and Settings\geoff\My Documents\Websites\jquery\index.php:20 Stack trace: #0 [internal function]: SoapClient->__call('getStockQuote', Array) #1 C:\Documents and Settings\geoff\My Documents\Websites\jquery\index.php(20): SoapClient->getStockQuote(Array) #2 {main} thrown in C:\Documents and Settings\geoff\My Documents\Websites\jquery\index.php on line 20

I am using nusoap v1.94

My web service code looks like this:

function getStockQuote($symbol) {
$price = '1.23';
return $price;
}

require('nusoap.php');

$server = new soap_server();

$server->configureWSDL('stockserver', 'urn:stockquote');

$server->register("getStockQuote",
            array('symbol' => 'xsd:string'),
            array('return' => 'xsd:decimal'),
            'urn:stockquote',
            'urn:stockquote#getStockQuote');

$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA)
                  ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);

I know one cause is to have whitespace before or after your php tags in your server script but thats not the case. It has been driving me mad for hours! Any help would be much appreciated.

ContentLicense: CC BY-SA 4.0


问:
Detect click outside react parent component
How to know that user has clicked outside our react app which is pointed to

(I'm having extra space to click outside root div)

I've tried the below code

```<code>import ReactDOM from 'react-dom';
// ... ✂

componentDidMount() {
    document.addEventListener('click', this.handleClickOutside, true);
}

componentWillUnmount() {
    document.removeEventListener('click', this.handleClickOutside, true);
}

handleClickOutside = event => {
    const domNode = ReactDOM.findDOMNode(this);

    if (!domNode || !domNode.contains(event.target)) {
        this.setState({
            visible: false
        });
    console.log("clicked outside")
    }
}
</code>```

But then, even if I clicked inside some child popup component under parent, it is showing as "clicked outside"

If I click anywhere inside the app (including children component), it should not say, "clicked outside"

So is there any way to know that the user clicked outside the complete app itself?

答:
The easiest way is to set a listener to the application container (the outmost element in the tree), instead of finding the id="root" element.

So, with given index.html:

```<code><div id="root"></div>
<div>Div which outside of app</div>
</code>```

Possible implementation can be (check the logs):

```<code>function useOnClickOutside(ref, handler) {
  useEffect(() => {
    const listener = event => {
      if (!ref.current || ref.current.contains(event.target)) {
        return;
      }

      handler(event);
    };

    document.addEventListener("mousedown", listener);
    document.addEventListener("touchstart", listener);

    return () => {
      document.removeEventListener("mousedown", listener);
      document.removeEventListener("touchstart", listener);
    };
  }, [ref, handler]);
}

const App = () => {
  const divRef = useRef();
  const handler = useCallback(() => console.log(`Click Outside`), []);
  useOnClickOutside(divRef, handler);

  return (
    <div
      ref={divRef}
      style={{
        margin: `0.5rem`,
        padding: `1rem`,
        border: `2px solid black`,
        cursor: `pointer`
      }}
    >
      Application
    </div>
  );
};

ReactDOM.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
  document.getElementById("root")
);
</code>```

Body:
How to know that user has clicked outside our react app which is pointed to

(I'm having extra space to click outside root div)

I've tried the below code

import ReactDOM from 'react-dom';
// ... ✂

componentDidMount() {
    document.addEventListener('click', this.handleClickOutside, true);
}

componentWillUnmount() {
    document.removeEventListener('click', this.handleClickOutside, true);
}

handleClickOutside = event => {
    const domNode = ReactDOM.findDOMNode(this);

    if (!domNode || !domNode.contains(event.target)) {
        this.setState({
            visible: false
        });
    console.log("clicked outside")
    }
}

But then, even if I clicked inside some child popup component under parent, it is showing as "clicked outside"

If I click anywhere inside the app (including children component), it should not say, "clicked outside"

So is there any way to know that the user clicked outside the complete app itself?

Body:
The easiest way is to set a listener to the application container (the outmost element in the tree), instead of finding the id="root" element.

So, with given index.html:

<div id="root"></div>
<div>Div which outside of app</div>

Possible implementation can be (check the logs):

function useOnClickOutside(ref, handler) {
  useEffect(() => {
    const listener = event => {
      if (!ref.current || ref.current.contains(event.target)) {
        return;
      }

      handler(event);
    };

    document.addEventListener("mousedown", listener);
    document.addEventListener("touchstart", listener);

    return () => {
      document.removeEventListener("mousedown", listener);
      document.removeEventListener("touchstart", listener);
    };
  }, [ref, handler]);
}

const App = () => {
  const divRef = useRef();
  const handler = useCallback(() => console.log(`Click Outside`), []);
  useOnClickOutside(divRef, handler);

  return (
    <div
      ref={divRef}
      style={{
        margin: `0.5rem`,
        padding: `1rem`,
        border: `2px solid black`,
        cursor: `pointer`
      }}
    >
      Application
    </div>
  );
};

ReactDOM.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
  document.getElementById("root")
);


问:
Using Apple Enterprise Program with external developers
We are currently using in our company the "Apple Enterprise Program", but my company is planning to outsource the developer department. So we won't do in-house development anymore. So my question: Is it possible to add external companies to our developer team? If not, is there any other way, to work together with external companies for developing in-house software, without publishing it in the App Store.</p>

答:
In principle, Apple doesn't know who does the work. Where you have to be very, very careful is with signing certificates. Anyone with signing certificates for your enterprise account could start publishing apps under that account outside your company, and if Apple finds out, your account will be blocked. That happened to Google and I think to Facebook, so don't think "they won't do that to a big company like ours". </p>

<p>I'd suggest creating another plain developer account and using that, letting people do all the work with that plain developer account, and then publishing it with your enterprise account. Or you need developers that are 100% trustworthy. </p>

Body:
In principle, Apple doesn't know who does the work. Where you have to be very, very careful is with signing certificates. Anyone with signing certificates for your enterprise account could start publishing apps under that account outside your company, and if Apple finds out, your account will be blocked. That happened to Google and I think to Facebook, so don't think "they won't do that to a big company like ours".

I'd suggest creating another plain developer account and using that, letting people do all the work with that plain developer account, and then publishing it with your enterprise account. Or you need developers that are 100% trustworthy.


问:
Unable to use Contains in LINQ to Entity VS 2017 my query attached
my query is,

Here i am trying to get region id where the region name matches,

```<code>var Rid = db.Regions.Where(p => SqlFunctions.PatIndex("%" + Search + "%", p.RegionName) > 0).Select(p => p.RegionId).ToList();
</code>```

Change Id's comma separated in string,

```<code>string joined = string.Join(",", Rid);
</code>```

Trying to get all records related to Id's comma separated in string joined

```<code>var employ = db.Employees.Include(f => f.City).Include(f => f.Region).Where(p=>p.RegionId);
</code>```

Issue is that we dont have contain when i tried use in where clause ??

Hopes for your suggestions

答:
In Linq we have Any:

```<code>var employ = db.Employees.Include(f => f.City)
                         .Include(f => f.Region)
                         .Where(p=> Rid.Any(rid => rid == p.RegionId));
</code>```

or :

```<code>var employ = db.Employees.Include(f => f.City)
                         .Include(f => f.Region)
                         .Where(p=> Rid.Contains(p.RegionId));
</code>```

Now it will select those employees have the region id in the Rid list.

Body:
my query is,

Here i am trying to get region id where the region name matches,

var Rid = db.Regions.Where(p => SqlFunctions.PatIndex("%" + Search + "%", p.RegionName) > 0).Select(p => p.RegionId).ToList();

Change Id's comma separated in string,

string joined = string.Join(",", Rid);

Trying to get all records related to Id's comma separated in string joined

var employ = db.Employees.Include(f => f.City).Include(f => f.Region).Where(p=>p.RegionId);

Issue is that we dont have contain when i tried use in where clause ??

Hopes for your suggestions

Body:
In Linq we have Any:

var employ = db.Employees.Include(f => f.City)
                         .Include(f => f.Region)
                         .Where(p=> Rid.Any(rid => rid == p.RegionId));

or :

var employ = db.Employees.Include(f => f.City)
                         .Include(f => f.Region)
                         .Where(p=> Rid.Contains(p.RegionId));

Now it will select those employees have the region id in the Rid list.


问:
How to handle CSV files in this Python script
Using the CSV file of flowers again, fill in the gaps of the contents_of_file function to process the data, without turning it into a dictionary. How do I skip over the header record with the field names?

import os
import csv

# Create a file with data in it
def create_file(filename):
    with open(filename, "w") as file:
        file.write("name,color,type\n")
        file.write("carnation,pink,annual\n")
        file.write("daffodil,yellow,perennial\n")
        file.write("iris,blue,perennial\n")
        file.write("poinsettia,red,perennial\n")
        file.write("sunflower,yellow,annual\n")

# Read the file contents and format the information about each row
def contents_of_file(filename):
    return_string = ""
    # Call the function to create the file
    create_file(filename)

    # Open the file
    with open(filename) as file:
        # Read the rows of the file
        rows = csv.reader(file)
        rows = list(rows)
        # Process each row
        for row in rows:
            name, color, ty = row
            # Format the return string for data rows only
            if row != rows[0]:
                return_string += "a {} {} is {}\n".format(name, color, ty)
    return return_string

#Call the function
print(contents_of_file("flowers.csv"))
```

<p>After submitting my answer, the following message is shown:</p>

```Not quite, contents_of_file returned:
a carnation pink is
annual
a daffodil yellow is perennial
a iris blue is
perennial
a poinsettia red is perennial
a sunflower yellow
is annual

The output should be:
a pink carnation is annual
a yellow daffodil is perennial
a blue iris is perennial
a
red poinsettia is perennial
a yellow sunflower is annual
```

How can I correct this problem?

答:
Change </p>

```<code>return_string += "a {} {} is {}\n".format(name, color, ty)
</code>```

<p>To </p>

```<code>return_string += "a {} {} is {}\n".format(color, name, ty)
</code>```

Body:
Using the CSV file of flowers again, fill in the gaps of the contents_of_file function to process the data, without turning it into a dictionary. How do I skip over the header record with the field names?

import os
import csv

# Create a file with data in it
def create_file(filename):
    with open(filename, "w") as file:
        file.write("name,color,type\n")
        file.write("carnation,pink,annual\n")
        file.write("daffodil,yellow,perennial\n")
        file.write("iris,blue,perennial\n")
        file.write("poinsettia,red,perennial\n")
        file.write("sunflower,yellow,annual\n")

# Read the file contents and format the information about each row
def contents_of_file(filename):
    return_string = ""
    # Call the function to create the file
    create_file(filename)

    # Open the file
    with open(filename) as file:
        # Read the rows of the file
        rows = csv.reader(file)
        rows = list(rows)
        # Process each row
        for row in rows:
            name, color, ty = row
            # Format the return string for data rows only
            if row != rows[0]:
                return_string += "a {} {} is {}\n".format(name, color, ty)
    return return_string

#Call the function
print(contents_of_file("flowers.csv"))

After submitting my answer, the following message is shown:

Not quite, contents_of_file returned:
a carnation pink is
annual
a daffodil yellow is perennial
a iris blue is
perennial
a poinsettia red is perennial
a sunflower yellow
is annual

The output should be:
a pink carnation is annual
a yellow daffodil is perennial
a blue iris is perennial
a
red poinsettia is perennial
a yellow sunflower is annual

How can I correct this problem?

Body:
Change

return_string += "a {} {} is {}\n".format(name, color, ty)

To

return_string += "a {} {} is {}\n".format(color, name, ty)


问:
How to test for which emoji a user has reacted to a message?
I am trying to make a system where a user can react to a message and it will reply with some text. The text will be different depending on which emoji they reacted with. I have researched reaction collectors, but I am still struggling to find an example of what I want to do.

This is the base code I am working with, which I got from Discord's guide to collections here.

message.react('');

const filter = (reaction, user) => {
  return reaction.emoji.name === '';
};

const collector = message.createReactionCollector(filter, { max: 100 });

collector.on('collect', (reaction, user) => {
  message.channel.send('Collecting...')
});

collector.on('end', collected => {
  message.channel.send('Done');
});
```

This code works, however it will execute the code in collector.on('collect'... no matter which emoji is reacted with. I want to be able to execute different code, for example sending a different embed when a user reacts with different emojis. Thanks!

答:
Your collector filter will allow only  emojis to be collected, so you should remove that in order to make the bot behave differently when other reactions are added. You can use the reaction and user arguments to determine which action to do:

// This will make it collect every reaction, without checking the emoji
const collector = message.createReactionCollector(() => true, { max: 100 })

collector.on('collect', (reaction, user) => {
  if (reaction.emoji.name == '') {
    // The user has reacted with the  emoji
  } else {
    // The user has reacted with a different emoji
  }
})

collector.on('end', collected => {
  // The bot has finished collecting reaction, because either the max number
  // has been reached or the time has finished
})
```

Inside those if/else statements you can add whatever you want (send messages, embeds, ...)

Body:
I am trying to make a system where a user can react to a message and it will reply with some text. The text will be different depending on which emoji they reacted with. I have researched reaction collectors, but I am still struggling to find an example of what I want to do.

This is the base code I am working with, which I got from Discord's guide to collections here.

message.react('');

const filter = (reaction, user) => {
  return reaction.emoji.name === '';
};

const collector = message.createReactionCollector(filter, { max: 100 });

collector.on('collect', (reaction, user) => {
  message.channel.send('Collecting...')
});

collector.on('end', collected => {
  message.channel.send('Done');
});

This code works, however it will execute the code in collector.on('collect'... no matter which emoji is reacted with. I want to be able to execute different code, for example sending a different embed when a user reacts with different emojis. Thanks!

Body:
Your collector filter will allow only  emojis to be collected, so you should remove that in order to make the bot behave differently when other reactions are added. You can use the reaction and user arguments to determine which action to do:

// This will make it collect every reaction, without checking the emoji
const collector = message.createReactionCollector(() => true, { max: 100 })

collector.on('collect', (reaction, user) => {
  if (reaction.emoji.name == '') {
    // The user has reacted with the  emoji
  } else {
    // The user has reacted with a different emoji
  }
})

collector.on('end', collected => {
  // The bot has finished collecting reaction, because either the max number
  // has been reached or the time has finished
})

Inside those if/else statements you can add whatever you want (send messages, embeds, ...)


问:
Running SQLJ procedure on third party tool
How can we execute call sqlj.install_jar('jarpath','jarname','0'); procedure on third party java tools?

I am trying to run this procedure on DBeaver to install the jar file.

But error I am getting:

No authorized routine named "SQLJ.INSTALL_JAR" of type "PROCEDURE" having compatible arguments was found.. SQLCODE=-440, SQLSTATE=42884

Is it possible to execute the sqlj commands on third party tool?

I used to install it by logging into Db2 server and execute the command.

答:
There is no such a routine with 3 parameters indeed.
Refer to the following link:

JAR file administration on the database server.

```<code>CALL sqlj.install_jar('file:/home/bob/bobsjar.jar', 'MYJAR')
</code>```

Jar file must be accessible from the database server by the full path provided with the 1-st parameter.

Body:
There is no such a routine with 3 parameters indeed.
Refer to the following link:

JAR file administration on the database server.

CALL sqlj.install_jar('file:/home/bob/bobsjar.jar', 'MYJAR')

Jar file must be accessible from the database server by the full path provided with the 1-st parameter.


问:
In Google Apps Script do breakpoints work differently when using the new V8 runtime?
Using the old runtime I could set a breakpoint anywhere in my code. With the new v8 runtime breakpoints apparently have to be in the function I run from the debugger?

Is this intended behavior? Am I doing something wrong in the debugger, or in my code? Is it not structured correctly, perhaps?

MINIMAL EXAMPLE:

```<code>var test1 = 1;
var test2 = 2;
var test3 = 3;

function myFunction() {
  var test4 = 4;
  var test5 = 5;
}
</code>```

V8 RUNTIME:

I can set a breakpoint on var test4 = 4 and then use the debugger and select myFunction, and the code breaks on that line.

But if I set the breakpoint on var test2 = 2 and then use the debugger, selecting myFunction, it doesn't break (It would with the old runtime).

答:
It is a new behavior related to V8 runtime

On one hand side

From the documentation:

When run in debug mode a script pauses when it hits a breakpoint,
  which is a line you've highlighted in your script

If your breakpoint is located outside of the function  - in a line that is never been called - your breakpoint will never be hit.

On the other hand side

Other people also noticed that this behavior is different from before and filed it on Google's Public Issue Tracker

While Google investigates either the previous or the current behavior is the intended one, as a workaround:

If you want your debugger to stop on the line var test2 = 2; which is outside of myFunction(), you need to structure your code differently, e.g.:

Body:
Using the old runtime I could set a breakpoint anywhere in my code. With the new v8 runtime breakpoints apparently have to be in the function I run from the debugger?

Is this intended behavior? Am I doing something wrong in the debugger, or in my code? Is it not structured correctly, perhaps?

MINIMAL EXAMPLE:

var test1 = 1;
var test2 = 2;
var test3 = 3;

function myFunction() {
  var test4 = 4;
  var test5 = 5;
}

V8 RUNTIME:

I can set a breakpoint on var test4 = 4 and then use the debugger and select myFunction, and the code breaks on that line.

But if I set the breakpoint on var test2 = 2 and then use the debugger, selecting myFunction, it doesn't break (It would with the old runtime).


问:
Junit test 5 (Exception)
I am doing a Junit test and in one of the tests I have problems but I don't understand why.

You do not have to allow more objects to be added to the list at any given time, that the size of the list is greater than 5, in short, if I add the sixth object to the list, the exception must be skipped, but I do not understand the reason why It does not work, I leave the code of what I am doing.

Code:

```<code> @Test
 void testAddTank() throws KeeperException, TankException {
  List<Tank> NumTanques = new ArrayList<Tank>();

  Tank tank1 = new Tank("TANQUE1","pedro1","hola",3.0,2.0,1.0,"/image",17.0,7);
  Tank tank2 = new Tank("TANQUE2","pedro2","hola",3.0,2.0,1.0,"/image",17.0,7);
  Tank tank3 = new Tank("TANQUE3","pedro3","hola",3.0,2.0,1.0,"/image",17.0,7);
  Tank tank4 = new Tank("TANQUE4","pedro4","hola",3.0,2.0,1.0,"/image",17.0,7);
  Tank tank5 = new Tank("TANQUE5","pedro5","hola",3.0,2.0,1.0,"/image",17.0,7);
  Tank tank6 = new Tank("TANQUE6","pedro6","hola",3.0,2.0,1.0,"/image",17.0,7);
  Tank tank7 = new Tank("TANQUE7","pedro6","hola",3.0,2.0,1.0,"/image",17.0,7);

  NumTanques.add(tank1);
  NumTanques.add(tank2);
  NumTanques.add(tank3);
  NumTanques.add(tank4);
  NumTanques.add(tank5);

  assertEquals(5, NumTanques.size());

  KeeperException excepcionTanques = assertThrows(KeeperException.class,()->NumTanques.add(tank6));
  assertEquals("[ERROR] A keeper cannot care of more than 5
  thanks!!",excepcionTanques.MSG_ERR_MAX_TANKS);

}
</code>```

As you can see, I create the list of type tank and create some tank objects, which I add to the list. Then with the assert what I tell you is that 5 has to be the size of the list so that it returns true ...

Then in the exception that I create I add a new tank to the list and the exception should jump, but it does not, it exits and gives an error on the line:

```<code> KeeperException excepcionTanques = assertThrows(KeeperException.class,()->NumTanques.add(tank6));
</code>```

I do not see clearly what is happening.

答:
list.add only throws exceptions as mentioned here https://docs.oracle.com/javase/7/docs/api/java/util/List.html#add(E).

So it is expected that line mentioned in question will give you compilation error.

If you still want to assert on list.add, then use any of exceptions mentioned in java doc.

may be something like this  --

```<code>UnsupportedOperationException e= assertThrows(UnsupportedOperationException.class,()->NumTanques.add(tank6));
</code>```

Title: Junit test 5 (Exception)

Body:
I am doing a Junit test and in one of the tests I have problems but I don't understand why.

You do not have to allow more objects to be added to the list at any given time, that the size of the list is greater than 5, in short, if I add the sixth object to the list, the exception must be skipped, but I do not understand the reason why It does not work, I leave the code of what I am doing.

Code:

 @Test
 void testAddTank() throws KeeperException, TankException {
  List<Tank> NumTanques = new ArrayList<Tank>();

  Tank tank1 = new Tank("TANQUE1","pedro1","hola",3.0,2.0,1.0,"/image",17.0,7);
  Tank tank2 = new Tank("TANQUE2","pedro2","hola",3.0,2.0,1.0,"/image",17.0,7);
  Tank tank3 = new Tank("TANQUE3","pedro3","hola",3.0,2.0,1.0,"/image",17.0,7);
  Tank tank4 = new Tank("TANQUE4","pedro4","hola",3.0,2.0,1.0,"/image",17.0,7);
  Tank tank5 = new Tank("TANQUE5","pedro5","hola",3.0,2.0,1.0,"/image",17.0,7);
  Tank tank6 = new Tank("TANQUE6","pedro6","hola",3.0,2.0,1.0,"/image",17.0,7);
  Tank tank7 = new Tank("TANQUE7","pedro6","hola",3.0,2.0,1.0,"/image",17.0,7);

  NumTanques.add(tank1);
  NumTanques.add(tank2);
  NumTanques.add(tank3);
  NumTanques.add(tank4);
  NumTanques.add(tank5);

  assertEquals(5, NumTanques.size());

  KeeperException excepcionTanques = assertThrows(KeeperException.class,()->NumTanques.add(tank6));
  assertEquals("[ERROR] A keeper cannot care of more than 5
  thanks!!",excepcionTanques.MSG_ERR_MAX_TANKS);

}

As you can see, I create the list of type tank and create some tank objects, which I add to the list. Then with the assert what I tell you is that 5 has to be the size of the list so that it returns true ...

Then in the exception that I create I add a new tank to the list and the exception should jump, but it does not, it exits and gives an error on the line:

 KeeperException excepcionTanques = assertThrows(KeeperException.class,()->NumTanques.add(tank6));

I do not see clearly what is happening.

Body:
list.add only throws exceptions as mentioned here https://docs.oracle.com/javase/7/docs/api/java/util/List.html#add(E).

So it is expected that line mentioned in question will give you compilation error.

If you still want to assert on list.add, then use any of exceptions mentioned in java doc.

may be something like this  --

UnsupportedOperationException e= assertThrows(UnsupportedOperationException.class,()->NumTanques.add(tank6));


问:
How can I set all text color in react components?
I have multiple components in react project and What I'm trying to do is set all the text on the page to white .

This is the index.css file :

```<code>:root {
    color: white !important;
}
</code>```

But it's not working so How can I set every text rendered on the page to white ?

答:
```<code>*{
    color: white !important;
}
</code>```

Try this one.

Body:
I have multiple components in react project and What I'm trying to do is set all the text on the page to white .

This is the index.css file :

:root {
    color: white !important;
}

But it's not working so How can I set every text rendered on the page to white ?

Body:
*{
    color: white !important;
}

Try this one.


问:
How can I create an NSMutableArray of structs?
I created a structure like this

```<code>typedef struct Node {
    NSString* Description;
    NSString* AE;
    NSString* IP;
    NSString*  Port;
} Node;
</code>```

I need to create NSMutableArray of this Node structure I need to know how create object of node path it to the NSMutableArray retrieve it and read for example the port.

答:
You can only store Objective-C objects in an NSMutableArray.

One route you can take is to use a standard C array:

```<code>unsigned int array_length = ...;
Node** nodes = malloc(sizeof(Node *) * array_length);
</code>```

Another route is to wrap the structure in an Objective-C object:

```<code>@interface NodeWrapper : NSObject {
   @public

   Node *node;
}
- (id) initWithNode:(Node *) n;
@end

@implementation NodeWrapper

- (id) initWithNode:(Node *) n {
  self = [super init];
  if(self) {
     node = n;
  }
  return self;
}

- (void) dealloc {
  free(node);
  [super dealloc];
}

@end
</code>```

Then, you'd add NodeWrapper objects to your NSMutableArray  like this:

```<code>Node *n = (Node *) malloc(sizeof(Node));
n->AE = @"blah";
NodeWrapper *nw = [[NodeWrapper alloc] initWithNode:n];
[myArray addObject:nw];
[nw release];
</code>```

To retrieve the Node from the NodeWrapper, you'd simply do this:

```<code>Node *n = nw->node;
</code>```

or

```<code>Node n = *(nw->node);
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I created a structure like this

typedef struct Node {
    NSString* Description;
    NSString* AE;
    NSString* IP;
    NSString*  Port;
} Node;

I need to create NSMutableArray of this Node structure I need to know how create object of node path it to the NSMutableArray retrieve it and read for example the port.

Body:
You can only store Objective-C objects in an NSMutableArray.

One route you can take is to use a standard C array:

unsigned int array_length = ...;
Node** nodes = malloc(sizeof(Node *) * array_length);

Another route is to wrap the structure in an Objective-C object:

@interface NodeWrapper : NSObject {
   @public

   Node *node;
}
- (id) initWithNode:(Node *) n;
@end

@implementation NodeWrapper

- (id) initWithNode:(Node *) n {
  self = [super init];
  if(self) {
     node = n;
  }
  return self;
}

- (void) dealloc {
  free(node);
  [super dealloc];
}

@end

Then, you'd add NodeWrapper objects to your NSMutableArray  like this:

Node *n = (Node *) malloc(sizeof(Node));
n->AE = @"blah";
NodeWrapper *nw = [[NodeWrapper alloc] initWithNode:n];
[myArray addObject:nw];
[nw release];

To retrieve the Node from the NodeWrapper, you'd simply do this:

Node *n = nw->node;

or

Node n = *(nw->node);


问:
How to run a service in init (Android 8.1)
I want to run the service through Init. (Android 8.1, sepolicy=permissive)

The service executes the script file, and the script file is as follows.

```<code>tcc898x:/ # cat /system/bin/tcc_dxb_service
#!/system/bin/sh
echo ----------------
echo RICHGOLD.
echo ----------------
</code>```

Service execution in init proceeds as follows.

```<code>tcc898x:/ # cat init.tcc898x.rc
(...)
on boot
    (...)
    start tcc_dxb_service
(...)
service tcc_dxb_service /system/bin/tcc_dxb_service
    class main
    user root
    u:object_r:tcc_dxb_service_exec:s0
</code>```

And to add domain, sepolicy file is added as below.

```<code># cat (Android 8.1 SDK)/device/(vendor)/(product)/sepolicy/tcc_dxb_service.te
type tcc_dxb_service, domain;
type tcc_dxb_service_exec, exec_type, system_file_type, file_type;
init_daemon_domain(tcc_dxb_service)
</code>```

When the tcc_dxb_service service is executed, the following output is displayed.

```<code>tcc898x:/ # start tcc_dxb_service
init: could not get context while starting 'tcc_dxb_service'
</code>```

Please tell me how to register the domain in Sepolicy to run the service.

Thanks.

答:
thanks your answer.

I referenced the Android reference site to add services to the project under development.

Added a service,
(init.{device}.rc)

```<code>service foo /system/bin/foo
    class core
</code>```

Added label.
((android SDK)/device/(vendor)/(device)/sepolicy/file_contexts)

```<code>/system/bin/foo u:object_r:foo_exec:s0
</code>```

Create a new domain.
((android SDK)/device/(vendor)/(device)/sepolicy/foo.te)

```<code># foo sercie
# Integrated foo process
type foo, domain;
type foo_exec, exec,type, file_type;

# started by init
init_daemon_domain(foo)
</code>```

(/system/bin/foo)

```<code>echo "-----"
echo "RICHGOLD"
echo "-----"

</code>```

I set it like this.
When building, the following error occurs.

```<code>FAILED: out/target/product/tcc898x/obj/ETC/sepolicy_intermediates/sepolicy
/bin/bash -c "(out/host/linux-x86/bin/secilc -M true -G -c 30 out/target/product/tcc898x/obj/ETC/plat_sepolicy.cil_intermediates/plat_sepolicy.cil out/target/product/tcc898x/obj/ETC/27.0.cil_intermediates/27.0.cil out/target/product/tcc898x/obj/ETC/nonplat_sepolicy.cil_intermediates/nonplat_sepolicy.cil -o out/target/product/tcc898x/obj/ETC/sepolicy_intermediates/sepolicy.tmp -f /dev/null ) && (out/host/linux-x86/bin/sepolicy-analyze out/target/product/tcc898x/obj/ETC/sepolicy_intermediates/sepolicy.tmp permissive > out/target/product/tcc898x/obj/ETC/sepolicy_intermediates/sepolicy.permissivedomains ) && (if [ \"eng\" = \"user\" -a -s out/target/product/tcc898x/obj/ETC/sepolicy_intermediates/sepolicy.permissivedomains ]; then         echo \"==========\" 1>&2;       echo \"ERROR: permissive domains not allowed in user builds\" 1>&2;         echo \"List of invalid domains:\" 1>&2;         cat out/target/product/tcc898x/obj/ETC/sepolicy_intermediates/sepolicy.permissivedomains 1>&2;      exit 1;         fi ) && (mv out/target/product/tcc898x/obj/ETC/sepolicy_intermediates/sepolicy.tmp out/target/product/tcc898x/obj/ETC/sepolicy_intermediates/sepolicy )"
neverallow check failed at out/target/product/tcc898x/obj/ETC/nonplat_sepolicy.cil_intermediates/nonplat_sepolicy.cil:2715
  (neverallow base_typeattr_56_27_0 base_typeattr_57_27_0 (file (execute execute_no_trans entrypoint)))
    <root>
    allow at out/target/product/tcc898x/obj/ETC/nonplat_sepolicy.cil_intermediates/nonplat_sepolicy.cil:6207
      (allow foo foo_exec (file (read getattr map execute entrypoint open)))

neverallow check failed at out/target/product/tcc898x/obj/ETC/plat_sepolicy.cil_intermediates/plat_sepolicy.cil:4641 from system/sepolicy/public/domain.te:668
  (neverallow base_typeattr_56 base_typeattr_57 (file (execute execute_no_trans entrypoint)))
    <root>
    allow at out/target/product/tcc898x/obj/ETC/nonplat_sepolicy.cil_intermediates/nonplat_sepolicy.cil:6207
      (allow foo foo_exec (file (read getattr map execute entrypoint open)))

Failed to generate binary
Failed to build policydb
[  2% 110/5135] build out/target/product/tcc898x/obj/ETC/precompiled_sepolicy_intermediates/precompiled_sepolicy
FAILED: out/target/product/tcc898x/obj/ETC/precompiled_sepolicy_intermediates/precompiled_sepolicy
/bin/bash -c "out/host/linux-x86/bin/secilc -M true -G -c 30        out/target/product/tcc898x/obj/ETC/plat_sepolicy.cil_intermediates/plat_sepolicy.cil out/target/product/tcc898x/obj/ETC/27.0.cil_intermediates/27.0.cil out/target/product/tcc898x/obj/ETC/nonplat_sepolicy.cil_intermediates/nonplat_sepolicy.cil -o out/target/product/tcc898x/obj/ETC/precompiled_sepolicy_intermediates/precompiled_sepolicy -f /dev/null"
neverallow check failed at out/target/product/tcc898x/obj/ETC/nonplat_sepolicy.cil_intermediates/nonplat_sepolicy.cil:2715
  (neverallow base_typeattr_56_27_0 base_typeattr_57_27_0 (file (execute execute_no_trans entrypoint)))
    <root>
    allow at out/target/product/tcc898x/obj/ETC/nonplat_sepolicy.cil_intermediates/nonplat_sepolicy.cil:6207
      (allow foo foo_exec (file (read getattr map execute entrypoint open)))

neverallow check failed at out/target/product/tcc898x/obj/ETC/plat_sepolicy.cil_intermediates/plat_sepolicy.cil:4641 from system/sepolicy/public/domain.te:668
  (neverallow base_typeattr_56 base_typeattr_57 (file (execute execute_no_trans entrypoint)))
    <root>
    allow at out/target/product/tcc898x/obj/ETC/nonplat_sepolicy.cil_intermediates/nonplat_sepolicy.cil:6207
      (allow foo foo_exec (file (read getattr map execute entrypoint open)))

Failed to generate binary
Failed to build policydb
ninja: build stopped: subcommand failed.
17:24:01 ninja failed with: exit status 1

#### failed to build some targets (43 seconds) ####

</code>```

If init_daemon_domain (foo) is removed when a domain is created,
((android SDK)/device/(vendor)/(device)/sepolicy/foo.te)

```<code># foo sercie
# Integrated foo process
type foo, domain;
type foo_exec, exec,type, file_type;

# started by init
# init_daemon_domain(foo)
</code>```

the log below is displayed after a normal build.
When the service is executed,

```<code># start foo
init: service foo does not have a SELinux domain defined
</code>```

How do I add a domain?
Please give me tips on neverallow.

Thanks.

Body:
I want to run the service through Init. (Android 8.1, sepolicy=permissive)

The service executes the script file, and the script file is as follows.

tcc898x:/ # cat /system/bin/tcc_dxb_service
#!/system/bin/sh
echo ----------------
echo RICHGOLD.
echo ----------------

Service execution in init proceeds as follows.

tcc898x:/ # cat init.tcc898x.rc
(...)
on boot
    (...)
    start tcc_dxb_service
(...)
service tcc_dxb_service /system/bin/tcc_dxb_service
    class main
    user root
    u:object_r:tcc_dxb_service_exec:s0

And to add domain, sepolicy file is added as below.

# cat (Android 8.1 SDK)/device/(vendor)/(product)/sepolicy/tcc_dxb_service.te
type tcc_dxb_service, domain;
type tcc_dxb_service_exec, exec_type, system_file_type, file_type;
init_daemon_domain(tcc_dxb_service)

When the tcc_dxb_service service is executed, the following output is displayed.

tcc898x:/ # start tcc_dxb_service
init: could not get context while starting 'tcc_dxb_service'

Please tell me how to register the domain in Sepolicy to run the service.

Thanks.

Body:
thanks your answer.

I referenced the Android reference site to add services to the project under development.

Added a service,
(init.{device}.rc)

service foo /system/bin/foo
    class core

Added label.
((android SDK)/device/(vendor)/(device)/sepolicy/file_contexts)

/system/bin/foo u:object_r:foo_exec:s0

Create a new domain.
((android SDK)/device/(vendor)/(device)/sepolicy/foo.te)

# foo sercie
# Integrated foo process
type foo, domain;
type foo_exec, exec,type, file_type;

# started by init
init_daemon_domain(foo)

(/system/bin/foo)

echo "-----"
echo "RICHGOLD"
echo "-----"

I set it like this.
When building, the following error occurs.

FAILED: out/target/product/tcc898x/obj/ETC/sepolicy_intermediates/sepolicy
/bin/bash -c "(out/host/linux-x86/bin/secilc -M true -G -c 30 out/target/product/tcc898x/obj/ETC/plat_sepolicy.cil_intermediates/plat_sepolicy.cil out/target/product/tcc898x/obj/ETC/27.0.cil_intermediates/27.0.cil out/target/product/tcc898x/obj/ETC/nonplat_sepolicy.cil_intermediates/nonplat_sepolicy.cil -o out/target/product/tcc898x/obj/ETC/sepolicy_intermediates/sepolicy.tmp -f /dev/null ) && (out/host/linux-x86/bin/sepolicy-analyze out/target/product/tcc898x/obj/ETC/sepolicy_intermediates/sepolicy.tmp permissive > out/target/product/tcc898x/obj/ETC/sepolicy_intermediates/sepolicy.permissivedomains ) && (if [ \"eng\" = \"user\" -a -s out/target/product/tcc898x/obj/ETC/sepolicy_intermediates/sepolicy.permissivedomains ]; then         echo \"==========\" 1>&2;       echo \"ERROR: permissive domains not allowed in user builds\" 1>&2;         echo \"List of invalid domains:\" 1>&2;         cat out/target/product/tcc898x/obj/ETC/sepolicy_intermediates/sepolicy.permissivedomains 1>&2;      exit 1;         fi ) && (mv out/target/product/tcc898x/obj/ETC/sepolicy_intermediates/sepolicy.tmp out/target/product/tcc898x/obj/ETC/sepolicy_intermediates/sepolicy )"
neverallow check failed at out/target/product/tcc898x/obj/ETC/nonplat_sepolicy.cil_intermediates/nonplat_sepolicy.cil:2715
  (neverallow base_typeattr_56_27_0 base_typeattr_57_27_0 (file (execute execute_no_trans entrypoint)))
    <root>
    allow at out/target/product/tcc898x/obj/ETC/nonplat_sepolicy.cil_intermediates/nonplat_sepolicy.cil:6207
      (allow foo foo_exec (file (read getattr map execute entrypoint open)))

neverallow check failed at out/target/product/tcc898x/obj/ETC/plat_sepolicy.cil_intermediates/plat_sepolicy.cil:4641 from system/sepolicy/public/domain.te:668
  (neverallow base_typeattr_56 base_typeattr_57 (file (execute execute_no_trans entrypoint)))
    <root>
    allow at out/target/product/tcc898x/obj/ETC/nonplat_sepolicy.cil_intermediates/nonplat_sepolicy.cil:6207
      (allow foo foo_exec (file (read getattr map execute entrypoint open)))

Failed to generate binary
Failed to build policydb
[  2% 110/5135] build out/target/product/tcc898x/obj/ETC/precompiled_sepolicy_intermediates/precompiled_sepolicy
FAILED: out/target/product/tcc898x/obj/ETC/precompiled_sepolicy_intermediates/precompiled_sepolicy
/bin/bash -c "out/host/linux-x86/bin/secilc -M true -G -c 30        out/target/product/tcc898x/obj/ETC/plat_sepolicy.cil_intermediates/plat_sepolicy.cil out/target/product/tcc898x/obj/ETC/27.0.cil_intermediates/27.0.cil out/target/product/tcc898x/obj/ETC/nonplat_sepolicy.cil_intermediates/nonplat_sepolicy.cil -o out/target/product/tcc898x/obj/ETC/precompiled_sepolicy_intermediates/precompiled_sepolicy -f /dev/null"
neverallow check failed at out/target/product/tcc898x/obj/ETC/nonplat_sepolicy.cil_intermediates/nonplat_sepolicy.cil:2715
  (neverallow base_typeattr_56_27_0 base_typeattr_57_27_0 (file (execute execute_no_trans entrypoint)))
    <root>
    allow at out/target/product/tcc898x/obj/ETC/nonplat_sepolicy.cil_intermediates/nonplat_sepolicy.cil:6207
      (allow foo foo_exec (file (read getattr map execute entrypoint open)))

neverallow check failed at out/target/product/tcc898x/obj/ETC/plat_sepolicy.cil_intermediates/plat_sepolicy.cil:4641 from system/sepolicy/public/domain.te:668
  (neverallow base_typeattr_56 base_typeattr_57 (file (execute execute_no_trans entrypoint)))
    <root>
    allow at out/target/product/tcc898x/obj/ETC/nonplat_sepolicy.cil_intermediates/nonplat_sepolicy.cil:6207
      (allow foo foo_exec (file (read getattr map execute entrypoint open)))

Failed to generate binary
Failed to build policydb
ninja: build stopped: subcommand failed.
17:24:01 ninja failed with: exit status 1

#### failed to build some targets (43 seconds) ####

If init_daemon_domain (foo) is removed when a domain is created,
((android SDK)/device/(vendor)/(device)/sepolicy/foo.te)

# foo sercie
# Integrated foo process
type foo, domain;
type foo_exec, exec,type, file_type;

# started by init
# init_daemon_domain(foo)

the log below is displayed after a normal build.
When the service is executed,

# start foo
init: service foo does not have a SELinux domain defined

How do I add a domain?
Please give me tips on neverallow.

Thanks.


问:
angular 7 style attribute value from an array dynamically
I am creating a progress bar using code below.

```<code><td class="pBar">
  <label>{{kpiCriteriaLevel[i]['High_Impact']}}%</label>
  <br/>
  <div class="progress">
    <div class="progress-bar progress-bar-yellow" role="progressbar" aria-valuenow="5" aria-valuemin="0" aria-valuemax="100" [ngStyle]="{'width.px': kpiCriteriaLevel[i]['Low_Impact'] }">
    </div>
  </div>
</td>
</code>```

This part of string interpolation {{kpiCriteriaLevel[i]['High_Impact']}} is coming from component file. But the same value is unable to read in style tag of HTML.

In the inspect element of browser I see - ng-reflect-ng-style="[object Object]" style="width: 0px;"

Please help, how to dynamically add value to width dynamically.

答: You don't need to worry. Angular will update the value automatically as soon as you update the value in the component file as it uses rxjs under the hood.

Body:
I am creating a progress bar using code below.

  {{kpiCriteriaLevel[i]['High_Impact']}}%

This part of string interpolation {{kpiCriteriaLevel[i]['High_Impact']}} is coming from component file. But the same value is unable to read in style tag of HTML.

In the inspect element of browser I see - ng-reflect-ng-style="[object Object]" style="width: 0px;"

Please help, how to dynamically add value to width dynamically.


问:
Is it possible to upgrade pip via text file?
Assume the machine has an older pip version - example pip 10.0.0

To update pip I use: python -m pip install pip==20.1.1

Is it possible to create a text file with freezed pip version - example - pip == 20.1.1 and install it using pip install -r file.txt. Will all the packages in the file.txt then use the 20.1.1 pip? or will they still use the original pip 10.0.0?

答:
Will all the packages in the file.txt then use the 20.1.1 pip?

No, they will use the original pip 10.0.0. The command pip install -r requirements.txt runs once under one pip. After the command starts the same Python and the same pip are running until the entire requirements.txt is processed.

So if you want to upgrade pip and immediately use it you need 2 (two) separate commands:

```<code>python -m pip install -U pip==20.1.1
pip install -r requirements.txt
</code>```

Body:
Will all the packages in the file.txt then use the 20.1.1 pip?

No, they will use the original pip 10.0.0. The command pip install -r requirements.txt runs once under one pip. After the command starts the same Python and the same pip are running until the entire requirements.txt is processed.

So if you want to upgrade pip and immediately use it you need 2 (two) separate commands:

python -m pip install -U pip==20.1.1
pip install -r requirements.txt


问:
Incorrect milliseconds in long value retrieved from MySQL in Java
First of I was trying to insert timestamp in millisecond precision in my mysql database, which I got success by this code:

```<code>Instant instant = Instant.now().truncatedTo(ChronoUnit.MILLIS);

try (Connection conn = DbConnection.getCon();
        PreparedStatement ps = conn.prepareStatement("INSERT INTO test_table (timestamp) VALUES (FROM_UNIXTIME(?*0.001))");) {
    ps.setObject(1, instant.toEpochMilli());
    ps.executeUpdate();
    LOG.info("Instant: {} and long: {}", instant, instant.toEpochMilli());
} catch (SQLException ex) {
    LOG.error(ex.getMessage());
}
</code>```

For this my table in database is:

```<code>CREATE TABLE `test_table` (
`id` INT NOT NULL AUTO_INCREMENT,
`timestamp` TIMESTAMP(3) NOT NULL,
PRIMARY KEY (`id`));
</code>```

This is my milliseconds from instant.toEpochMilli() from my java code and timestamp in from my database:

milliseconds: 1564566174331 and timestamp: 2019-07-31 15:27:54.331

Now I wanted to retrieve this timestamp in my java code hence my code is:

```<code>    try (Connection conn = DbConnection.getCon();
            PreparedStatement ps = conn.prepareStatement("SELECT timestamp FROM test_table WHERE id=?")) {
        ps.setString(1, "14");
        ResultSet rs = ps.executeQuery();
        if (rs.next()) {
            LOG.info("milliseconds: {}", rs.getTimestamp("timestamp").toInstant().toEpochMilli());
        } else {
            LOG.info("No data");
        }
    } catch (SQLException ex) {
        LOG.error(ex.getMessage());
    }
</code>```

But what I got for total timestamp in milliseconds for this is:

milliseconds: 1564566174000

Somehow that 331 value in millisecond place is gone.

How to RETRIEVE complete timestamp value in millisecond precision. Now I am getting more confused. What am I missing?

What I tried:

A) I tried getTime() of ResultSet for timestamp to retrieve total time in milliseconds as:

```<code>LOG.info("milliseconds: {}", rs.getTimestamp("timestamp").getTime());
</code>```

Still not retrieving that milliseconds place value. Same result as above.

B) I tried getObject() as well and TO MY ASTONISHMENT the milliseconds place value is somehow placed at NANOSECONDS place.

```<code>LOG.info("object: {}", rs.getObject("timestamp").toString());
</code>```

What I got:

object: 2019-07-31 15:27:54.000000331

答: I was also facing same Issue , i changed Database column to long/int .and inserted Directly milliseconds.it reduced lots of code and complexity for me .</p>

Body:
First of I was trying to insert timestamp in millisecond precision in my mysql database, which I got success by this code:

Instant instant = Instant.now().truncatedTo(ChronoUnit.MILLIS);

try (Connection conn = DbConnection.getCon();
        PreparedStatement ps = conn.prepareStatement("INSERT INTO test_table (timestamp) VALUES (FROM_UNIXTIME(?*0.001))");) {
    ps.setObject(1, instant.toEpochMilli());
    ps.executeUpdate();
    LOG.info("Instant: {} and long: {}", instant, instant.toEpochMilli());
} catch (SQLException ex) {
    LOG.error(ex.getMessage());
}

For this my table in database is:

CREATE TABLE `test_table` (
`id` INT NOT NULL AUTO_INCREMENT,
`timestamp` TIMESTAMP(3) NOT NULL,
PRIMARY KEY (`id`));

This is my milliseconds from instant.toEpochMilli() from my java code and timestamp in from my database:

milliseconds: 1564566174331 and timestamp: 2019-07-31 15:27:54.331

Now I wanted to retrieve this timestamp in my java code hence my code is:

    try (Connection conn = DbConnection.getCon();
            PreparedStatement ps = conn.prepareStatement("SELECT timestamp FROM test_table WHERE id=?")) {
        ps.setString(1, "14");
        ResultSet rs = ps.executeQuery();
        if (rs.next()) {
            LOG.info("milliseconds: {}", rs.getTimestamp("timestamp").toInstant().toEpochMilli());
        } else {
            LOG.info("No data");
        }
    } catch (SQLException ex) {
        LOG.error(ex.getMessage());
    }

But what I got for total timestamp in milliseconds for this is:

milliseconds: 1564566174000

Somehow that 331 value in millisecond place is gone.

How to RETRIEVE complete timestamp value in millisecond precision. Now I am getting more confused. What am I missing?

What I tried:

A) I tried getTime() of ResultSet for timestamp to retrieve total time in milliseconds as:

LOG.info("milliseconds: {}", rs.getTimestamp("timestamp").getTime());

Still not retrieving that milliseconds place value. Same result as above.

B) I tried getObject() as well and TO MY ASTONISHMENT the milliseconds place value is somehow placed at NANOSECONDS place.

LOG.info("object: {}", rs.getObject("timestamp").toString());

What I got:

object: 2019-07-31 15:27:54.000000331


问:
What does the Workperformer class id in Filenet represents(F_WPclassID)
I need to clarify what is the use of the Work performer class id in VWdb (process engine db) . I could find some numbers assigned to the F_WPClassid to it. I dont know what those number represents.
Is it some kind of identifier. Does anyone know the use of this ID.</p>

答:
There is a list in the documentation explaining all the PE system fields. For this particular field it states:

Internal identifier of the work performer class of the queue that contains the work item.

This still does not answer your question. But if you use de process engine application "vwtool" you can get more information. Details how to start vwtool can be found here. The best way to analyse this is to dump you region configuration to a file. So the first command you give in vwtool is:

```<code>hardcopy
</code>```

This will prompt you for a location where you want to store the output. The next command is:

```<code>configdetails
</code>```

This will print the configuration of your isolated region to the output file. It will work the fastest if you turn paging of. Next you have to give the hardcopy command again to stop hard copying.

If you do a search in this file for "F_WPClassid" you will see that this field is coupled to all the event log tables in your system. Finally, if you search for "Repository class ID" you will see the different values of F_WPClassid. These values correspond to the queue that processed the work item.

Body:
There is a list in the documentation explaining all the PE system fields. For this particular field it states:

Internal identifier of the work performer class of the queue that contains the work item.

This still does not answer your question. But if you use de process engine application "vwtool" you can get more information. Details how to start vwtool can be found here. The best way to analyse this is to dump you region configuration to a file. So the first command you give in vwtool is:

hardcopy

This will prompt you for a location where you want to store the output. The next command is:

configdetails

This will print the configuration of your isolated region to the output file. It will work the fastest if you turn paging of. Next you have to give the hardcopy command again to stop hard copying.

If you do a search in this file for "F_WPClassid" you will see that this field is coupled to all the event log tables in your system. Finally, if you search for "Repository class ID" you will see the different values of F_WPClassid. These values correspond to the queue that processed the work item.


问:
How to disable Crashlytics during development
Is there any simple way to turn Crashlytics Android SDK off while developing ?

I don't want it to send a crash every time I do something stupid

On the other hand I don't want to comment out Crashlytics.start() and possibly risk forgetting to uncomment it and commit

答:
There are two options in order to disable Firebase Crashlytics for the following version com.google.firebase:firebase-crashlytics:17.0.0:

Add meta-tag to app's Manifest

<meta-data android:name="firebase_crashlytics_collection_enabled" android:value="false" />

OR

Configure directly in the app (keep in mind when set to false, the new value does not apply until the next run of the app)

FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(true)


问:
How to insert a specific text at the end of exisitng data in a specific column?
I am using SQL Server 2014. Assume I have a table called T1 with 2 columns, IdNumber and Notes. Table T1 contains around 300,000 records.

The Notes column is a free text column, meaning users have entered therein free text. Some records have this column empty (no text entered).

I now have a list of IdNumbers where I need to add this specific text "(TOC)" in the Notes column of T1, ideally at the end of any text already present therein. I have created a table called tempID which contains the list of all these IdNumbers.

Here is how table T1 looks (extract):

```<code>IdNumber        Notes
--------------------------------------------------------------------
   101          Guest does not like beer
   154          wedding anniversary - to prepare a cake - 03052020
   160
</code>```

IdNumber = 160 has a blank/empty Notes column.

Here is what I want to achieve (assuming "(TOC)" need to be added to these 3 IdNumbers):

```<code>IdNumber        Notes
------------------------------------------------------------------------
  101           Guest does not like beer (TOC)
  154           wedding anniversary - to prepare a cake - 03052020 (TOC)
  160           (TOC)
</code>```

How can I do this (I have a list of around 1500 IdNumbers)?

This is where I am stuck with my SQL query:

```<code>UPDATE T1
INSERT INTO [Notes]
VALUE ('(TOC)') ----stuck here!
WHERE [IdNumber] in (Select [IdNumber] from [tempID]
</code>```

I think it should be done differently since my above query will simply overwrite the existing content of the Notes column with "(TOC)".

答:
You need to just simply add (TOC) to your column - and make sure to be aware that if Notes is NULL, you need to do some extra handling:

```<code>UPDATE dbo.T1
SET Notes = ISNUL(Notes, '') + ' (TOC)'
WHERE IdNumber IN (SELECT IdNumber FROM dbo.tempID);
</code>```

With the ISNULL() operator, you turn a NULL into an empty string, which can then be concatenated with the (TOC) string. If you omit this, then it wouldn't work, because concatenating NULL with anything else will still results in NULL

Body:
I am using SQL Server 2014. Assume I have a table called T1 with 2 columns, IdNumber and Notes. Table T1 contains around 300,000 records.

The Notes column is a free text column, meaning users have entered therein free text. Some records have this column empty (no text entered).

I now have a list of IdNumbers where I need to add this specific text "(TOC)" in the Notes column of T1, ideally at the end of any text already present therein. I have created a table called tempID which contains the list of all these IdNumbers.

Here is how table T1 looks (extract):

IdNumber        Notes
--------------------------------------------------------------------
   101          Guest does not like beer
   154          wedding anniversary - to prepare a cake - 03052020
   160

IdNumber = 160 has a blank/empty Notes column.

Here is what I want to achieve (assuming "(TOC)" need to be added to these 3 IdNumbers):

IdNumber        Notes
------------------------------------------------------------------------
  101           Guest does not like beer (TOC)
  154           wedding anniversary - to prepare a cake - 03052020 (TOC)
  160           (TOC)

How can I do this (I have a list of around 1500 IdNumbers)?

This is where I am stuck with my SQL query:

UPDATE T1
INSERT INTO [Notes]
VALUE ('(TOC)') ----stuck here!
WHERE [IdNumber] in (Select [IdNumber] from [tempID]

I think it should be done differently since my above query will simply overwrite the existing content of the Notes column with "(TOC)".

Body:
You need to just simply add (TOC) to your column - and make sure to be aware that if Notes is NULL, you need to do some extra handling:

UPDATE dbo.T1
SET Notes = ISNUL(Notes, '') + ' (TOC)'
WHERE IdNumber IN (SELECT IdNumber FROM dbo.tempID);

With the ISNULL() operator, you turn a NULL into an empty string, which can then be concatenated with the (TOC) string. If you omit this, then it wouldn't work, because concatenating NULL with anything else will still results in NULL