问:
Create an instance of an object with the help of function (dynamically), on event triggers
I want to create an instance of an user Object containing the name, age etc.. prop. I just given a form to be filled by user and with that details i want to create his instance of an object dynamically (with that person own name i.e; user). For that i used function like shown below, but i'm facing this error . Thanks for the help in advance

```<code>class MainUser{
  constructor(name,age){
    this.name=name;
    this.age=age;
  }
}
</code>```

```<code>function createUser(user, name, age){
  let user = new MainUser(name, age);
}
</code>```

I'm getting this error
Uncaught SyntaxError: Identifier 'user' has already been declared

答:
You have the variable user as an parameter in the function-definition of createUser, and with let user you are trying to re-declare that parameter/variable. You have three options depending on what you try to achieve.

rename the user-parameter of the function

rename the user variable for your object inside the function

remove the let to use the parameter of the function

class User {
  constructor(name, age){
    this.name=name;
    this.age=age;
  }
}

let user = null;
function createUser(name, age){
  user = new User(name, age);
}
createUser('Alice', 32);

console.log(user);```
</div>
</div>
</p>

<p>Another approach you can use:</p>

<p><div class="snippet" data-lang="js" data-hide="true" data-console="true" data-babel="false">
<div class="snippet-code snippet-currently-hidden">
<pre class="snippet-code-js lang-js prettyprint-override"><code>class User {
  constructor(name, age){
    this.name=name;
    this.age=age;
  }
}

function createUser(name, age){
  let userObject = new User(name, age);
  return userObject;
}
let user = createUser('Bob', 31);

console.log(user);</code>```

For creating a variable with a dynamic name inside the current scope you can use the following:

class User {
  constructor(name, age){
    this.name=name;
    this.age=age;
  }
}

function createUser(user, name, age){
  this[user] = new User(name, age);
  console.log(this[user]);
  console.log(test_user);
}
createUser('test_user', 'Charly', 42);```

Body:
I want to create an instance of an user Object containing the name, age etc.. prop. I just given a form to be filled by user and with that details i want to create his instance of an object dynamically (with that person own name i.e; user). For that i used function like shown below, but i'm facing this error . Thanks for the help in advance

class MainUser{
  constructor(name,age){
    this.name=name;
    this.age=age;
  }
}

function createUser(user, name, age){
  let user = new MainUser(name, age);
}

I'm getting this error
Uncaught SyntaxError: Identifier 'user' has already been declared

Body:
You have the variable user as an parameter in the function-definition of createUser, and with let user you are trying to re-declare that parameter/variable. You have three options depending on what you try to achieve.

rename the user-parameter of the function

rename the user variable for your object inside the function

remove the let to use the parameter of the function

class User {
  constructor(name, age){
    this.name=name;
    this.age=age;
  }
}

let user = null;
function createUser(name, age){
  user = new User(name, age);
}
createUser('Alice', 32);

console.log(user);

Another approach you can use:

class User {
  constructor(name, age){
    this.name=name;
    this.age=age;
  }
}

function createUser(name, age){
  let userObject = new User(name, age);
  return userObject;
}
let user = createUser('Bob', 31);

console.log(user);

For creating a variable with a dynamic name inside the current scope you can use the following:

class User {
  constructor(name, age){
    this.name=name;
    this.age=age;
  }
}

function createUser(user, name, age){
  this[user] = new User(name, age);
  console.log(this[user]);
  console.log(test_user);
}
createUser('test_user', 'Charly', 42);


来源: stackexchange

问:
C++ substring searching - JUMPING INTO C++
I'm reading "Jumping Into C++" by Alex Allain. I'm at a chapter on strings and searching strings, and I don't really understand this for-loop. Someone please explain to me how this works. Thanks. </p>

```<code>for ( i = input.find( "cat", 0 ); i != string::npos; i = input.find( "cat", i ) )
{
    cat_appearances++;
    i++; // Move past the last discovered instance to avoid
    // finding same string again
}
    cout << "The word cat appears " << cat_appearances << " in the string
    " << '"' << input << '"';
}
</code>```

答:
It has the same structure as every for loop:

```<code>for (initialise once; compare before each iteration; post iteration)
</code>```

But normally you'd see something like this

```<code>for (int i = 0; i < 5; i++)
</code>```

That is: initialise i = 0 once, then check if i < 5 before each iteration of the loop, then perform i++ after.

Yours instead initialises i to the result of find("cat", 0): that is, it finds the first occurrence of "cat" in the string input.

Before each loop, it checks that i != std::string::npos; that is, it checks to make sure we actually found an occurrence of "cat" in input, since find will return std::string::npos if no occurrence is found.

At the end of each loop, it will then i = input.find("cat", i), which will search again for an occurrence of "cat" starting from our current position.

The actual loop itself just counts occurrences.

ContentLicense: CC BY-SA 4.0

Body:
I'm reading "Jumping Into C++" by Alex Allain. I'm at a chapter on strings and searching strings, and I don't really understand this for-loop. Someone please explain to me how this works. Thanks.

for ( i = input.find( "cat", 0 ); i != string::npos; i = input.find( "cat", i ) )
{
    cat_appearances++;
    i++; // Move past the last discovered instance to avoid
    // finding same string again
}
    cout << "The word cat appears " << cat_appearances << " in the string
    " << '"' << input << '"';
}

Body:
It has the same structure as every for loop:

for (initialise once; compare before each iteration; post iteration)

But normally you'd see something like this

for (int i = 0; i < 5; i++)

That is: initialise i = 0 once, then check if i < 5 before each iteration of the loop, then perform i++ after.

Yours instead initialises i to the result of find("cat", 0): that is, it finds the first occurrence of "cat" in the string input.

Before each loop, it checks that i != std::string::npos; that is, it checks to make sure we actually found an occurrence of "cat" in input, since find will return std::string::npos if no occurrence is found.

At the end of each loop, it will then i = input.find("cat", i), which will search again for an occurrence of "cat" starting from our current position.

The actual loop itself just counts occurrences.


问:
How to change FontFamily when user choose specific item in ComboBox (WPF)

```<code><ComboBox x:Name="theComboBox">
    <ComboBox.ItemsSource>
        <CompositeCollection>
            <ComboBoxItem Content="Use Default Font"/>
            <CollectionContainer Collection="{Binding Source={x:Static onts.SystemFontFamilies}}"/>
        </CompositeCollection>
    </ComboBox.ItemsSource>
</ComboBox>

<TextBlock Text="Text in selected font" FontFamily="{Binding ElementName=theComboBox, Path=SelectedItem}" />
</code>```

I binded fontfamily of the textblock to choosed font in the combobox. It works correctly. But I want when user click "use default font", fontfamily of textblock changes to this:

```<code>FontFamily={StaticResource Great} //Great.ttf is an embedded font in my project
</code>```

答:
Assign the SelectionChanged event of the combobox to call a method, where you check, if the selected item is the one you want (yourItem), you set the textblock's FontFamily to the one you want (YourFont).

```<code><ComboBox x:Name="theComboBox" SelectionChanged="ComboBox_SelectionChanged">
    <ComboBox.ItemsSource>
        <CompositeCollection>
            <ComboBoxItem Content="Use Default Font"/>
            <CollectionContainer Collection="{Binding Source={x:Static onts.SystemFontFamilies}}"/>
        </CompositeCollection>
    </ComboBox.ItemsSource>
</ComboBox>

<TextBlock x:Name="myTextblock" Text="Text in selected font" FontFamily="{Binding ElementName=theComboBox, Path=SelectedItem}" />
</code>```

And,

```<code>private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    if (theComboBox.SelectedItem = yourItem)
    {
        myTextBlock.FontFamily = YourFont;
    }
}
</code>```

Body:
<ComboBox x:Name="theComboBox">
    <ComboBox.ItemsSource>
        <CompositeCollection>
            <ComboBoxItem Content="Use Default Font"/>
            <CollectionContainer Collection="{Binding Source={x:Static onts.SystemFontFamilies}}"/>
        </CompositeCollection>
    </ComboBox.ItemsSource>
</ComboBox>

<TextBlock Text="Text in selected font" FontFamily="{Binding ElementName=theComboBox, Path=SelectedItem}" />

I binded fontfamily of the textblock to choosed font in the combobox. It works correctly. But I want when user click "use default font", fontfamily of textblock changes to this:

FontFamily={StaticResource Great} //Great.ttf is an embedded font in my project

Body:
Assign the SelectionChanged event of the combobox to call a method, where you check, if the selected item is the one you want (yourItem), you set the textblock's FontFamily to the one you want (YourFont).

<ComboBox x:Name="theComboBox" SelectionChanged="ComboBox_SelectionChanged">
    <ComboBox.ItemsSource>
        <CompositeCollection>
            <ComboBoxItem Content="Use Default Font"/>
            <CollectionContainer Collection="{Binding Source={x:Static onts.SystemFontFamilies}}"/>
        </CompositeCollection>
    </ComboBox.ItemsSource>
</ComboBox>

<TextBlock x:Name="myTextblock" Text="Text in selected font" FontFamily="{Binding ElementName=theComboBox, Path=SelectedItem}" />

And,

private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    if (theComboBox.SelectedItem = yourItem)
    {
        myTextBlock.FontFamily = YourFont;
    }
}


问:
How can I position my progress bar at the bottom of a button?
I am facing a bit of an issue and I can't seem to figure it out.

I am trying to create a button and add a bootstrap progress bar at the bottom of it, but I cant seem to figure out how to get it to do just that.

Here's my current setup. https://jsfiddle.net/bob_mosh/7qeazm9w/3/

HTML:

```<code><button id="sample_button" type="button" class="soundButton">
<label class="buttonTitle">Bird Song</label>
<label class="buttonDescription">A nice bird song.</label>
<div class="progress volume-slider">
<div class="progress-bar" role="progressbar" style="width: 100%" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"></div>
</div>
</button>
</code>```

CSS:

```<code>.soundButton {
    display: table-cell;
    background-color: rgba(255, 255, 255, 0.650);
    margin: 4px;
    padding: 8px;
    width: 250px;
    height: 120px !important;
    border-radius: 8px;
    border: none !important;
    float: left !important;
}

.soundButton label {
    color: rgba(37, 38, 43, 1.00) !important;
}

body {
  background-color: rgba(37, 38, 43, 1.00)
}

.buttonTitle {
    font-weight: 700;
    font-size: 1.5em;
    display: block;
}

.volume-slider {
    bottom:0;
    height: 8px !important;
}
</code>```

This is the current state on the right and the way I am envisioning it on the left.

For some reason I cant get the absolute positioning to work. Every time I try to set the position of the progress bar to absolute, it completely disappears. Can anyone help me figure this out?

答:
Reviewed your code on JsFiddle. I made some changes to it, please review:

```<code><div class="progress progress-bottom">
<div class="progress-bar progress-child" role="progressbar" style="width: 50%" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100">
</div>
</code>```

CSS:

```<code>.progress-bottom {
  position: relative;
  left: -8px;
  top: 15px;
  width: 250px;
}
</code>```

This allowed me to get the progress bar at the bottom. Like this:

Body:
I am facing a bit of an issue and I can't seem to figure it out.

I am trying to create a button and add a bootstrap progress bar at the bottom of it, but I cant seem to figure out how to get it to do just that.

Here's my current setup. https://jsfiddle.net/bob_mosh/7qeazm9w/3/

HTML:

<button id="sample_button" type="button" class="soundButton">
Bird Song
A nice bird song.

</button>

CSS:

.soundButton {
    display: table-cell;
    background-color: rgba(255, 255, 255, 0.650);
    margin: 4px;
    padding: 8px;
    width: 250px;
    height: 120px !important;
    border-radius: 8px;
    border: none !important;
    float: left !important;
}

.soundButton label {
    color: rgba(37, 38, 43, 1.00) !important;
}

body {
  background-color: rgba(37, 38, 43, 1.00)
}

.buttonTitle {
    font-weight: 700;
    font-size: 1.5em;
    display: block;
}

.volume-slider {
    bottom:0;
    height: 8px !important;
}

This is the current state on the right and the way I am envisioning it on the left.

For some reason I cant get the absolute positioning to work. Every time I try to set the position of the progress bar to absolute, it completely disappears. Can anyone help me figure this out?

Body:
Reviewed your code on JsFiddle. I made some changes to it, please review:

<div class="progress progress-bottom">
<div class="progress-bar progress-child" role="progressbar" style="width: 50%" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100">
</div>

CSS:

.progress-bottom {
  position: relative;
  left: -8px;
  top: 15px;
  width: 250px;
}

This allowed me to get the progress bar at the bottom. Like this:


问:
Problem while uploading file in Spring with apache-commons-fileupload
I'm trying to upload an image in a web application built on Spring MVC using local tomcat container, but the code continue to throw a NullPointerException.

I already searched the net for tutorials but none of them worked, in particular i followed the one provided by webSystique, Baeldung and mkyong sites.
Everything goes well, including validation, until it comes to fetch the file.

So the Spring configuration and the webapp are correct, as far as I can understand, except for the upload part shown below.

This is the code in AppConfig.java to configure MultipartResolver for apache-commons:

```<code>@Bean
public CommonsMultipartResolver getResolver() throws IOException{

    CommonsMultipartResolver resolver = new CommonsMultipartResolver();
    resolver.setMaxUploadSize(5242880); //max file size set to 5MB

    return resolver;
}
</code>```

This is the model Image.java file which represent the file:

```<code>public class Image {

private MultipartFile profilePicture;

public MultipartFile getProfilePicture() {
    return profilePicture;
}

public void setProfilePicture(MultipartFile profilePicture) {
    this.profilePicture = profilePicture;
}
}
</code>```

Controller method that redirect to form:

```<code>@RequestMapping(value = "/upload-{id}", method = RequestMethod.GET)
public String uploadPage(ModelMap model){

    Image image = new Image();
    model.addAttribute("image", image); //set attribute to request map

    return "uploadForm";
}
</code>```

The form code in the uploadForm.jps page:

```<code>        <form:form method="POST" modelAttribute="image" enctype="multipart/form-data">
            <div class="row">
                <div class="form-group col-md-12">
                    <div class="col-md-7">
                        <form:input path="profilePicture" type="file" id="profilePicture"></form:input>
                        <form:errors path="profilePicture" cssClass="text-danger"></form:errors>
                    </div>
                </div>
            </div>
            <div class="row">
                <input type="submit" value="upload" class="btn btn-primary btn-sm">
            </div>
        </form:form>
</code>```

and last, the method mapped to upload the file in the new path:

```<code>@RequestMapping(value = "/upload-{id}", method = RequestMethod.POST)
public String fileUpload(@Valid Image profilePicture, BindingResult result, @PathVariable int id, ModelMap model) throws IOException {

    if(result.hasErrors()){ //in case of validation error redirect to form page
        return "uploadForm";
    }

    MultipartFile multipartFile = profilePicture.getProfilePicture();

    byte[] source = multipartFile.getBytes(); //source file bytes array
    File dest = new java.io.File(UPLOAD_LOCATION + profilePicture.getProfilePicture().getOriginalFilename()); //destination file
    //copying the file to the new position
    FileCopyUtils.copy(source, dest);

    String fileName = multipartFile.getOriginalFilename(); //original name of file got and saved in attributes map
    employeeService.updateImage(id, fileName);
    model.addAttribute("fileName", fileName);

    return "fileUploaded";
}
</code>```

The UPLOAD_LOCATION is defined inside the controller class with the line:

```<code>private static final String UPLOAD_LOCATION = "C:/EmployeeManager/";
</code>```

and the O.S. is windows.

The exception is thrown in the fileUpload method in the subsequent line:
byte[] source = multipartFile.getBytes(); //source file bytes array

This is the root cause shown by the log:

```<code>java.lang.NullPointerException
employeeManager.controller.FileController.fileUpload(FileController.java:80)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215)
org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:749)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:689)
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:938)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:863)
javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
</code>```

答:
Your problem is caused by a NullPointerException so the solution to your problem is quite simple, make sure that you are not trying to access members of a null object.

The exception is thrown at line 80 and you have already determined that yourself:

```<code>java.lang.NullPointerException
employeeManager.controller.FileController.fileUpload(FileController.java:80)
</code>```

```<code>byte[] source = multipartFile.getBytes(); //source file bytes array
</code>```

So just make sure that neither multipartFile nor profilePicture objects are null before they are accessed. According to your stacktrace the problem is one of those two variables.

Body:
I'm trying to upload an image in a web application built on Spring MVC using local tomcat container, but the code continue to throw a NullPointerException.

I already searched the net for tutorials but none of them worked, in particular i followed the one provided by webSystique, Baeldung and mkyong sites.
Everything goes well, including validation, until it comes to fetch the file.

So the Spring configuration and the webapp are correct, as far as I can understand, except for the upload part shown below.

This is the code in AppConfig.java to configure MultipartResolver for apache-commons:

@Bean
public CommonsMultipartResolver getResolver() throws IOException{

    CommonsMultipartResolver resolver = new CommonsMultipartResolver();
    resolver.setMaxUploadSize(5242880); //max file size set to 5MB

    return resolver;
}

This is the model Image.java file which represent the file:

public class Image {

private MultipartFile profilePicture;

public MultipartFile getProfilePicture() {
    return profilePicture;
}

public void setProfilePicture(MultipartFile profilePicture) {
    this.profilePicture = profilePicture;
}
}

Controller method that redirect to form:

@RequestMapping(value = "/upload-{id}", method = RequestMethod.GET)
public String uploadPage(ModelMap model){

    Image image = new Image();
    model.addAttribute("image", image); //set attribute to request map

    return "uploadForm";
}

The form code in the uploadForm.jps page:

        <form:form method="POST" modelAttribute="image" enctype="multipart/form-data">

                        <form:input path="profilePicture" type="file" id="profilePicture"></form:input>
                        <form:errors path="profilePicture" cssClass="text-danger"></form:errors>

                <input type="submit" value="upload" class="btn btn-primary btn-sm">

        </form:form>

and last, the method mapped to upload the file in the new path:

@RequestMapping(value = "/upload-{id}", method = RequestMethod.POST)
public String fileUpload(@Valid Image profilePicture, BindingResult result, @PathVariable int id, ModelMap model) throws IOException {

    if(result.hasErrors()){ //in case of validation error redirect to form page
        return "uploadForm";
    }

    MultipartFile multipartFile = profilePicture.getProfilePicture();

    byte[] source = multipartFile.getBytes(); //source file bytes array
    File dest = new java.io.File(UPLOAD_LOCATION + profilePicture.getProfilePicture().getOriginalFilename()); //destination file
    //copying the file to the new position
    FileCopyUtils.copy(source, dest);

    String fileName = multipartFile.getOriginalFilename(); //original name of file got and saved in attributes map
    employeeService.updateImage(id, fileName);
    model.addAttribute("fileName", fileName);

    return "fileUploaded";
}

The UPLOAD_LOCATION is defined inside the controller class with the line:

private static final String UPLOAD_LOCATION = "C:/EmployeeManager/";

and the O.S. is windows.

The exception is thrown in the fileUpload method in the subsequent line:
byte[] source = multipartFile.getBytes(); //source file bytes array

This is the root cause shown by the log:

java.lang.NullPointerException
employeeManager.controller.FileController.fileUpload(FileController.java:80)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215)
org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:749)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:689)
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:938)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:863)
javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

Body:
Your problem is caused by a NullPointerException so the solution to your problem is quite simple, make sure that you are not trying to access members of a null object.

The exception is thrown at line 80 and you have already determined that yourself:

java.lang.NullPointerException
employeeManager.controller.FileController.fileUpload(FileController.java:80)

byte[] source = multipartFile.getBytes(); //source file bytes array

So just make sure that neither multipartFile nor profilePicture objects are null before they are accessed. According to your stacktrace the problem is one of those two variables.


问:
API Connect Test and Monitor Desktop Client
Am I able to automate and schedule tests using the APIC Test and Monitor desktop client ???

I have successfully created a working request but cant for the life of me see where I could automate and schedule this request.

答:
Unfortunately, the auto generation feature of the IBM API Connect test and monitor is not currently available for the desktop app.

However, there are plans to integrate this feature into the desktop app in the future.

Disclaimer: I'm a member of the IBM API Connect Test and Monitor development team.


问:
array of pointers
Consider the following code:

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

int main()
{
  static int a[]={0,1,2,3,4};
  int *p[]={a,a+1,a+2,a+3};            /* clear up to this extent */
  printf(("%u\n%u\n%u",p,*p,*(*p)));   /* how does this statement work? */
  return 0;
}
</code>```

Also is it necessary to get the value of addresses through %u,or we can use %d also?

答:
My memory on C pointers is a tiny bit rusty, but let me see if I can recall.

p should be a memory location, it points to nothing else, other than p.

*p dereferences (goes to the memory location and returns the value there) p.  since p itself is a pointer to pointers (*p[] can be also written as **p) when we dereference p we get the first value in the array definition, or the address of a.

**p dereferences *p.  *p is the address of a.  If we dereference that, we'll get the value we put in the first location of a, which is 0

ContentLicense: CC BY-SA 3.0

Title: array of pointers

Body:
Consider the following code:

#include <stdio.h>

int main()
{
  static int a[]={0,1,2,3,4};
  int *p[]={a,a+1,a+2,a+3};            /* clear up to this extent */
  printf(("%u\n%u\n%u",p,*p,*(*p)));   /* how does this statement work? */
  return 0;
}

Also is it necessary to get the value of addresses through %u,or we can use %d also?


答:
You could set the FallbackValue property of the binding:

```<code><TextBlock Text="Text in selected font" FontFamily="{Binding ElementName=theComboBox,
                                 Path=SelectedItem, FallbackValue={StaticResource Great}}" />
</code>```

Title: How to change FontFamily when user choose specific item in ComboBox (WPF)

Body:
You could set the FallbackValue property of the binding:

<TextBlock Text="Text in selected font" FontFamily="{Binding ElementName=theComboBox,
                                 Path=SelectedItem, FallbackValue={StaticResource Great}}" />


问:
Autocomplete using jsp and scriplets(Not using java classes)
I want to make an autocomplete but not by using any java method. Just by using jsp, jquery, ajax and scriplets. Is it possible? Please suggest.

I tried using the code given below, but am getting error

Uncaught Error: cannot call methods on autocomplete prior to initialization; attempted to call method 'List.jsp'

The code is given below:

//(Index.jsp)

```<code><html>
<head>

<script src = "https://code.jquery.com/jquery-1.10.2.js"></script>
<script src = "https://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<script>
$(document).ready(function() {
$('#country').focusin(function() {
$("#country").autocomplete("List.jsp");
});
});
</script>
</head>
<body>
    <br><br><center>
        <font face="verdana" size="2">
        <font size="4">Java(jsp)/jQuery Autocompleter Example</font>
        <br><br><br><br>

        Select Country   :
        <input type="text" id="country" name="country"/>

        </font>
    </body>
</html>
</code>```

//(List.jsp)

```<code><%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.*"%>
<%@page import="java.util.*"%>

<%
    try {
        String s[] = null;

        Class.forName("com.mysql.jdbc.Driver");
        System.out.println("Driver found");
        String url = "jdbc:mysql://localhost:protNum/dbName";
        String user = "";
        String pass = "";
        System.out.println("Connected....");
        Connection con = (Connection) DriverManager.getConnection(url, user, pass);
        Statement st = con.createStatement();
        ResultSet rs = st.executeQuery("select * from tbctry");

        List li = new ArrayList();

        while (rs.next()) {
            li.add(rs.getString(1));
        }

        String[] str = new String[li.size()];
        Iterator it = li.iterator();

        int i = 0;
        while (it.hasNext()) {
            String p = (String) it.next();
            str[i] = p;
            i++;
        }

        //jQuery related start
        String query = (String) request.getParameter("q");

        int cnt = 1;
        for (int j = 0; j < str.length; j++) {
            if (str[j].toUpperCase().startsWith(query.toUpperCase())) {
                out.print(str[j] + "\n");
                if (cnt >= 5)// 5=How many results have to show while we are typing(auto suggestions)
                {
                    break;
                }
                cnt++;
            }
        }
 //jQuery related end

        rs.close();
        st.close();
        con.close();

    } catch (Exception e) {
        e.printStackTrace();
    }
%>
</code>```

I want the textbox to autopopulate values from database on keydown. I have done this using spring MVC, but I'm not getting any clue how to do this without using any java class but by just using jsp, jquery, ajax, and scriplets. Please help!

答:
You can do that by using jquery onkeyup event ,when user start typing in input box the typed value will passed to your jquery function and by using ajax you can call your List.jsp page and get that value using request.getParameter("") ,lastly passed that value in your query and return result back using out.print like below :

Input i.e :where value will be typed :

```<code>    Select Country   :  <input type="text" id="country" name="country"/>
  //here result will be display
    <div id="result"></div>
</code>```

Jquery & Ajax :

```<code> <script>
     $('#country').keyup(function(){
       //getting typed value
            var searchid=$(this).val();
               if(searchid!='')
                     {
                        $.ajax({
                           type:"POST",
                            url:"List.jsp",
                            //passing value
                             data:{search:searchid},
                             success:function(html){
                            //response from List.jsp page will come here
                                $('#result').html(html);
                            }
                         });
                         }
                   });
        </script>
</code>```

List.jsp page :

```<code>//getting value passed from ajax
 String search = (String) request.getParameter("search");
//db setting
      try{
        Class.forName("com.mysql.jdbc.Driver");
        System.out.println("Driver found");
        String url = "jdbc:mysql://localhost:protNum/dbName";
        String user = "";
        String pass = "";
        System.out.println("Connected....");
        Connection con = (Connection) DriverManager.getConnection(url, user, pass);
          //below columnanme is fieldname from where you need to compare your search value.
        PreparedStatement pstmt = con.prepareStatement(
         "select * from tbctry where columnname LIKE ?");
         pstmt.setString(1, search + "%");
         ResultSet rs=pstmt.executeQuery();
         while(rs.next()){
        //here you need to print values which you need to show in div
         out.print("something");
          }
        rs.close();
    pstmt.close();
    con.close();

} catch (Exception e) {
    e.printStackTrace();
}
</code>```

Hope this helps !

Body:
I want to make an autocomplete but not by using any java method. Just by using jsp, jquery, ajax and scriplets. Is it possible? Please suggest.

I tried using the code given below, but am getting error

Uncaught Error: cannot call methods on autocomplete prior to initialization; attempted to call method 'List.jsp'

The code is given below:

//(Index.jsp)

        Java(jsp)/jQuery Autocompleter Example

        Select Country   :
        <input type="text" id="country" name="country"/>

//(List.jsp)

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.*"%>
<%@page import="java.util.*"%>

<%
    try {
        String s[] = null;

        Class.forName("com.mysql.jdbc.Driver");
        System.out.println("Driver found");
        String url = "jdbc:mysql://localhost:protNum/dbName";
        String user = "";
        String pass = "";
        System.out.println("Connected....");
        Connection con = (Connection) DriverManager.getConnection(url, user, pass);
        Statement st = con.createStatement();
        ResultSet rs = st.executeQuery("select * from tbctry");

        List li = new ArrayList();

        while (rs.next()) {
            li.add(rs.getString(1));
        }

        String[] str = new String[li.size()];
        Iterator it = li.iterator();

        int i = 0;
        while (it.hasNext()) {
            String p = (String) it.next();
            str[i] = p;
            i++;
        }

        //jQuery related start
        String query = (String) request.getParameter("q");

        int cnt = 1;
        for (int j = 0; j < str.length; j++) {
            if (str[j].toUpperCase().startsWith(query.toUpperCase())) {
                out.print(str[j] + "\n");
                if (cnt >= 5)// 5=How many results have to show while we are typing(auto suggestions)
                {
                    break;
                }
                cnt++;
            }
        }
 //jQuery related end

        rs.close();
        st.close();
        con.close();

    } catch (Exception e) {
        e.printStackTrace();
    }
%>

I want the textbox to autopopulate values from database on keydown. I have done this using spring MVC, but I'm not getting any clue how to do this without using any java class but by just using jsp, jquery, ajax, and scriplets. Please help!

Body:
You can do that by using jquery onkeyup event ,when user start typing in input box the typed value will passed to your jquery function and by using ajax you can call your List.jsp page and get that value using request.getParameter("") ,lastly passed that value in your query and return result back using out.print like below :

Input i.e :where value will be typed :

    Select Country   :  <input type="text" id="country" name="country"/>
  //here result will be display
    <div id="result"></div>

Jquery & Ajax :

 <script>
     $('#country').keyup(function(){
       //getting typed value
            var searchid=$(this).val();
               if(searchid!='')
                     {
                        $.ajax({
                           type:"POST",
                            url:"List.jsp",
                            //passing value
                             data:{search:searchid},
                             success:function(html){
                            //response from List.jsp page will come here
                                $('#result').html(html);
                            }
                         });
                         }
                   });
        </script>

List.jsp page :

//getting value passed from ajax
 String search = (String) request.getParameter("search");
//db setting
      try{
        Class.forName("com.mysql.jdbc.Driver");
        System.out.println("Driver found");
        String url = "jdbc:mysql://localhost:protNum/dbName";
        String user = "";
        String pass = "";
        System.out.println("Connected....");
        Connection con = (Connection) DriverManager.getConnection(url, user, pass);
          //below columnanme is fieldname from where you need to compare your search value.
        PreparedStatement pstmt = con.prepareStatement(
         "select * from tbctry where columnname LIKE ?");
         pstmt.setString(1, search + "%");
         ResultSet rs=pstmt.executeQuery();
         while(rs.next()){
        //here you need to print values which you need to show in div
         out.print("something");
          }
        rs.close();
    pstmt.close();
    con.close();

} catch (Exception e) {
    e.printStackTrace();
}

Hope this helps !


问:
How to suppress graphviz warnings in Python 3?
I'm using the graphviz module to render a network of nodes and links.

I use small circles as node's shape, so the labels are intentionally bigger than the nodes.

As a consequence, I get the following warning:

"Warning: node 'wave', graph 'N' size too small for label"

'Wave' is just an example of a node's label.

I get lots of this warnings because of the high quantity of nodes (screencapture).

So, my question is: How can I suppress warnings like those?

The graphviz command I'm using is:

```<code>n.view()  # n is my digraph
</code>```

I have already tried the suggestions from:

How to suppress a third-party warning using warnings.filterwarnings

How to redirect python warnings to a custom stream?

But nothing so far.
Thanks in advance.

答:
Try Eli Bendersky's excellent page: Redirecting all kinds of stdout in Python

After replacing stdout with stderr, Eli's solution worked on graphviz for me.

If you happen to be using Evince, Ubuntu's builtin PDF viewer, see:

https://superuser.com/questions/980237/silence-evinces-warnings-in-ubuntu

Body:
I'm using the graphviz module to render a network of nodes and links.

I use small circles as node's shape, so the labels are intentionally bigger than the nodes.

As a consequence, I get the following warning:

"Warning: node 'wave', graph 'N' size too small for label"

'Wave' is just an example of a node's label.

I get lots of this warnings because of the high quantity of nodes (screencapture).

So, my question is: How can I suppress warnings like those?

The graphviz command I'm using is:

n.view()  # n is my digraph

I have already tried the suggestions from:

How to suppress a third-party warning using warnings.filterwarnings

How to redirect python warnings to a custom stream?

But nothing so far.
Thanks in advance.


问:
Azure Function (C#, v1): Logging does not work properly
I implemented an Azure Function that is time triggered. It shall run e.g. every 15 minutes. But when I look into the logs from Application Settings I don't see every run despite the Azure Function actually runs every 15 minutes. Why is this happening?</p>

答:
What solved the issue for me was increasing the sampling rate (or disabling it completely) that can be adjusted via host.json (in this case for v1):

```<code>{
  "applicationInsights": {
    "sampling": {
      "isEnabled": true,
      "maxTelemetryItemsPerSecond" : 5
    }
  }
}
</code>```

See also Configure sampling

Body:
What solved the issue for me was increasing the sampling rate (or disabling it completely) that can be adjusted via host.json (in this case for v1):

{
  "applicationInsights": {
    "sampling": {
      "isEnabled": true,
      "maxTelemetryItemsPerSecond" : 5
    }
  }
}

See also Configure sampling


问:
Android - problems with JNI
I have the following code (stored as .c file) in my Android project:

```<code>static void convert(unsigned int &c, const float &temp1, const float &temp2, const float &temp3) {
    if ( (temp3 * 6) < 1) c = (unsigned int) ((temp2 + (temp1 - temp2) * 6 * temp3) * 100);

    else if ((temp3 * 2) < 1) c = (unsigned int) (temp1 * 100);

    else if ((temp3 * 3) < 2) c = (unsigned int) ((temp2 + (temp1 - temp2) * (.66666 - temp3) * 6) * 100);

    else c = (unsigned int) (temp2 * 100);

    return;
}
</code>```

During the code it gets called like this:

```<code>convert(r, temp1, temp2, temp3);
</code>```

But when I compile it with the ndk-build command from the command line, then I get the following errors:

Android NDK: APP_PLATFORM not set. Defaulting to minimum supported
  version android-16.     [arm64-v8a] Compile        :
  com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor
  <=
  com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c
  jni/com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c:193:47:
  error:
        expected ')' static void convert(unsigned int &c, const float &temp1, const float ...
                                                ^ jni/com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c:193:33:
  note:
        to match this '(' static void convert(unsigned int &c, const float &temp1, const float ...
                                  ^ jni/com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c:193:47:
  error:
        parameter name omitted static void convert(unsigned int &c, const float &temp1, const float ...
                                                ^ jni/com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c:194:11:
  error:
        use of undeclared identifier 'temp3'
      if ( (temp3 * 6) < 1) c = (unsigned int) ((temp2 + (temp1 - temp2) * 6 * temp3...
            ^ jni/com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c:194:27:
  error:
        use of undeclared identifier 'c'
      if ( (temp3 * 6) < 1) c = (unsigned int) ((temp2 + (temp1 - temp2) * 6 * temp3...
                            ^ jni/com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c:194:57:
  error:
        use of undeclared identifier 'temp1'
      if ( (temp3 * 6) < 1) c = (unsigned int) ((temp2 + (temp1 - temp2) * 6 * temp3...
                                                          ^ jni/com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c:194:65:
  error:
        use of undeclared identifier 'temp2'
      if ( (temp3 * 6) < 1) c = (unsigned int) ((temp2 + (temp1 - temp2) * 6 * temp3) * ...
                                                                  ^ jni/com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c:194:48:
  error:
        use of undeclared identifier 'temp2'
      if ( (temp3 * 6) < 1) c = (unsigned int) ((temp2 + (temp1 - temp2) * 6 * temp3...
                                                 ^ jni/com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c:194:78:
  error:
        use of undeclared identifier 'temp3'   ...(temp3 * 6) < 1) c = (unsigned int) ((temp2 + (temp1 - temp2) * 6 * temp3) * 100);
                                                                           ^
  jni/com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c:196:15:
  error:
        use of undeclared identifier 'temp3'
      else if ((temp3 * 2) < 1) c = (unsigned int) (temp1 * 100);
                ^ jni/com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c:196:31:
  error:
        use of undeclared identifier 'c'
      else if ((temp3 * 2) < 1) c = (unsigned int) (temp1 * 100);
                                ^ jni/com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c:196:51:
  error:
        use of undeclared identifier 'temp1'
      else if ((temp3 * 2) < 1) c = (unsigned int) (temp1 * 100);
                                                    ^ jni/com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c:198:15:
  error:
        use of undeclared identifier 'temp3'
      else if ((temp3 * 3) < 2) c = (unsigned int) ((temp2 + (temp1 - temp2) * (.666...
                ^ jni/com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c:198:31:
  error:
        use of undeclared identifier 'c'
      else if ((temp3 * 3) < 2) c = (unsigned int) ((temp2 + (temp1 - temp2) * (.666...
                                ^ jni/com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c:198:61:
  error:
        use of undeclared identifier 'temp1'
      else if ((temp3 * 3) < 2) c = (unsigned int) ((temp2 + (temp1 - temp2) * (.666...
                                                              ^ jni/com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c:198:69:
  error:
        use of undeclared identifier 'temp2'   ...if ((temp3 * 3) < 2) c = (unsigned int) ((temp2 + (temp1 - temp2) * (.66666 - temp...
                                                                  ^ jni/com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c:198:52:
  error:
        use of undeclared identifier 'temp2'
      else if ((temp3 * 3) < 2) c = (unsigned int) ((temp2 + (temp1 - temp2) * (.666...
                                                     ^ jni/com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c:198:88:
  error:
        use of undeclared identifier 'temp3'   ...< 2) c = (unsigned int) ((temp2 + (temp1 - temp2) * (.66666 - temp3) * 6) * 100);
                                                                     ^ jni/com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c:200:10:
  error:
        use of undeclared identifier 'c'
      else c = (unsigned int) (temp2 * 100);
           ^ jni/com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c:200:30:
  error:
        use of undeclared identifier 'temp2'
      else c = (unsigned int) (temp2 * 100);

I got that code from a .cpp file. When I delete the address operator (&) in the signature, then everything is fine (no errors) but I do not know if then the algorithm would work.

Can anybody help ?

答:
You're trying to compile C++ code with a C compiler, which will not work.

The obvious solution would be to compile it with a C++ compiler instead (e.g. by giving the source file a .cpp extension).

If for some reason you must use a C compiler, then you'll have to rewrite the function in C.
For starters, you can pass all those const float parameters by value instead of by reference (by getting rid of the &). I don't know why they were references in the first place.

That first parameter (c) is used as an output-parameter to which the result is written. So you'll have to change it from a reference to a pointer (i.e. unsigned int *c). Or better yet, skip the output parameter and have the function return its result instead:

```<code>static int convert(const float temp1, const float temp2, const float temp3) {
    unsigned int c;

    if ( (temp3 * 6) < 1) c = (unsigned int) ((temp2 + (temp1 - temp2) * 6 * temp3) * 100);
    else if ((temp3 * 2) < 1) c = (unsigned int) (temp1 * 100);
    else if ((temp3 * 3) < 2) c = (unsigned int) ((temp2 + (temp1 - temp2) * (.66666 - temp3) * 6) * 100);
    else c = (unsigned int) (temp2 * 100);

    return c;
}
</code>```

Calling code:

```<code>r = convert(temp1, temp2, temp3);
</code>```

Title: Android - problems with JNI

Body:
I have the following code (stored as .c file) in my Android project:

static void convert(unsigned int &c, const float &temp1, const float &temp2, const float &temp3) {
    if ( (temp3 * 6) < 1) c = (unsigned int) ((temp2 + (temp1 - temp2) * 6 * temp3) * 100);

    else if ((temp3 * 2) < 1) c = (unsigned int) (temp1 * 100);

    else if ((temp3 * 3) < 2) c = (unsigned int) ((temp2 + (temp1 - temp2) * (.66666 - temp3) * 6) * 100);

    else c = (unsigned int) (temp2 * 100);

    return;
}

During the code it gets called like this:

convert(r, temp1, temp2, temp3);

But when I compile it with the ndk-build command from the command line, then I get the following errors:

Android NDK: APP_PLATFORM not set. Defaulting to minimum supported
  version android-16.     [arm64-v8a] Compile        :
  com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor
  <=
  com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c
  jni/com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c:193:47:
  error:
        expected ')' static void convert(unsigned int &c, const float &temp1, const float ...
                                                ^ jni/com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c:193:33:
  note:
        to match this '(' static void convert(unsigned int &c, const float &temp1, const float ...
                                  ^ jni/com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c:193:47:
  error:
        parameter name omitted static void convert(unsigned int &c, const float &temp1, const float ...
                                                ^ jni/com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c:194:11:
  error:
        use of undeclared identifier 'temp3'
      if ( (temp3 * 6) < 1) c = (unsigned int) ((temp2 + (temp1 - temp2) * 6 * temp3...
            ^ jni/com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c:194:27:
  error:
        use of undeclared identifier 'c'
      if ( (temp3 * 6) < 1) c = (unsigned int) ((temp2 + (temp1 - temp2) * 6 * temp3...
                            ^ jni/com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c:194:57:
  error:
        use of undeclared identifier 'temp1'
      if ( (temp3 * 6) < 1) c = (unsigned int) ((temp2 + (temp1 - temp2) * 6 * temp3...
                                                          ^ jni/com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c:194:65:
  error:
        use of undeclared identifier 'temp2'
      if ( (temp3 * 6) < 1) c = (unsigned int) ((temp2 + (temp1 - temp2) * 6 * temp3) * ...
                                                                  ^ jni/com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c:194:48:
  error:
        use of undeclared identifier 'temp2'
      if ( (temp3 * 6) < 1) c = (unsigned int) ((temp2 + (temp1 - temp2) * 6 * temp3...
                                                 ^ jni/com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c:194:78:
  error:
        use of undeclared identifier 'temp3'   ...(temp3 * 6) < 1) c = (unsigned int) ((temp2 + (temp1 - temp2) * 6 * temp3) * 100);
                                                                           ^
  jni/com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c:196:15:
  error:
        use of undeclared identifier 'temp3'
      else if ((temp3 * 2) < 1) c = (unsigned int) (temp1 * 100);
                ^ jni/com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c:196:31:
  error:
        use of undeclared identifier 'c'
      else if ((temp3 * 2) < 1) c = (unsigned int) (temp1 * 100);
                                ^ jni/com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c:196:51:
  error:
        use of undeclared identifier 'temp1'
      else if ((temp3 * 2) < 1) c = (unsigned int) (temp1 * 100);
                                                    ^ jni/com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c:198:15:
  error:
        use of undeclared identifier 'temp3'
      else if ((temp3 * 3) < 2) c = (unsigned int) ((temp2 + (temp1 - temp2) * (.666...
                ^ jni/com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c:198:31:
  error:
        use of undeclared identifier 'c'
      else if ((temp3 * 3) < 2) c = (unsigned int) ((temp2 + (temp1 - temp2) * (.666...
                                ^ jni/com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c:198:61:
  error:
        use of undeclared identifier 'temp1'
      else if ((temp3 * 3) < 2) c = (unsigned int) ((temp2 + (temp1 - temp2) * (.666...
                                                              ^ jni/com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c:198:69:
  error:
        use of undeclared identifier 'temp2'   ...if ((temp3 * 3) < 2) c = (unsigned int) ((temp2 + (temp1 - temp2) * (.66666 - temp...
                                                                  ^ jni/com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c:198:52:
  error:
        use of undeclared identifier 'temp2'
      else if ((temp3 * 3) < 2) c = (unsigned int) ((temp2 + (temp1 - temp2) * (.666...
                                                     ^ jni/com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c:198:88:
  error:
        use of undeclared identifier 'temp3'   ...< 2) c = (unsigned int) ((temp2 + (temp1 - temp2) * (.66666 - temp3) * 6) * 100);
                                                                     ^ jni/com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c:200:10:
  error:
        use of undeclared identifier 'c'
      else c = (unsigned int) (temp2 * 100);
           ^ jni/com_celik_abdullah_imageprocessingpart_processors_NativeImageProcessor.c:200:30:
  error:
        use of undeclared identifier 'temp2'
      else c = (unsigned int) (temp2 * 100);

I got that code from a .cpp file. When I delete the address operator (&) in the signature, then everything is fine (no errors) but I do not know if then the algorithm would work.

Can anybody help ?

Body:
You're trying to compile C++ code with a C compiler, which will not work.

The obvious solution would be to compile it with a C++ compiler instead (e.g. by giving the source file a .cpp extension).

If for some reason you must use a C compiler, then you'll have to rewrite the function in C.
For starters, you can pass all those const float parameters by value instead of by reference (by getting rid of the &). I don't know why they were references in the first place.

That first parameter (c) is used as an output-parameter to which the result is written. So you'll have to change it from a reference to a pointer (i.e. unsigned int *c). Or better yet, skip the output parameter and have the function return its result instead:

static int convert(const float temp1, const float temp2, const float temp3) {
    unsigned int c;

    if ( (temp3 * 6) < 1) c = (unsigned int) ((temp2 + (temp1 - temp2) * 6 * temp3) * 100);
    else if ((temp3 * 2) < 1) c = (unsigned int) (temp1 * 100);
    else if ((temp3 * 3) < 2) c = (unsigned int) ((temp2 + (temp1 - temp2) * (.66666 - temp3) * 6) * 100);
    else c = (unsigned int) (temp2 * 100);

    return c;
}

Calling code:

r = convert(temp1, temp2, temp3);


问:
Simple Alexa skill with logging
I've a simple Alexa Skill - developed in the Alexa developer console with some simple JS in the index.js. Alexa is doing well in the Test-Tab (just responding with an 'Hello' to the launchEvent.

I now wanted to implement some logging via console.log(...)

But all I can find on information is: "Just do console.log and you'll find the output somewhere in the Cloudwatch"

But in AWS Cloudwatch, I can create "LogGroups" under "Logs" - but how do I connect such a log group with my Alexa skill? Or do the console.log outputs appear somewhere else automatically?

答:
Ok, the solution was not to login with my AWS/AlexaDev account into the AWS console and look in THAT cloudwatch.
I've to use the "Logs: Amazon Cloudwatch"-Link in the lower left corner of the Alexa Coding View. Then I'm navigated to "another" Cloudwatch list with all my logs in it - but I'm then auto-loggedin as a complete different user: "VoiceHubSSORole"

Title: Simple Alexa skill with logging


问:
US state border color not changing in Highmaps
I'm trying to achieve the effect of having state borders wider than county borders, as shown in this example.

Apparently the Highcharts.grep method is deprecated, so this is what I did to extract the state borders (in Typescript):

```<code>var lines = Highcharts.geojson(geojsonMap, 'mapline');

var borderLines = lines
            .filter((line:any) => line.properties['hc-group'] === '__border_lines__');
</code>```

And the chart series:

```<code>    series = [{
        name: 'unemployment',
        borderWidth: 0.2,
        borderColor: 'white',
        states: {
            hover: {
                color: 'black'
            }
        },
        dataLabels: {
            enabled: false,
        },
        type: 'map',
        data: data,
    }, {
        type: 'mapline',
        name: 'State borders',
        data: borderLines,
        color: 'white',
        shadow: false
    }]
</code>```

Problem is that the lines are not white, they are red and I cannot change the color and/or width. This is the screenshot:

The lines are there, so they are loaded correctly. How to change the color/width?

Update: Example after changing lineWidth:

答:
You need to change lineWidth and color properties:

```<code>series: [..., {
    type: 'mapline',
    color: 'blue',
    lineWidth: 5,
    ...
}]
</code>```

Live demo: https://jsfiddle.net/BlackLabel/4Lnxuam0/

API Reference: https://api.highcharts.com/highmaps/series.mapline.color

Body:
I'm trying to achieve the effect of having state borders wider than county borders, as shown in this example.

Apparently the Highcharts.grep method is deprecated, so this is what I did to extract the state borders (in Typescript):

var lines = Highcharts.geojson(geojsonMap, 'mapline');

var borderLines = lines
            .filter((line:any) => line.properties['hc-group'] === '__border_lines__');

And the chart series:

    series = [{
        name: 'unemployment',
        borderWidth: 0.2,
        borderColor: 'white',
        states: {
            hover: {
                color: 'black'
            }
        },
        dataLabels: {
            enabled: false,
        },
        type: 'map',
        data: data,
    }, {
        type: 'mapline',
        name: 'State borders',
        data: borderLines,
        color: 'white',
        shadow: false
    }]

Problem is that the lines are not white, they are red and I cannot change the color and/or width. This is the screenshot:

The lines are there, so they are loaded correctly. How to change the color/width?

Update: Example after changing lineWidth:

Body:
You need to change lineWidth and color properties:

series: [..., {
    type: 'mapline',
    color: 'blue',
    lineWidth: 5,
    ...
}]

Live demo: https://jsfiddle.net/BlackLabel/4Lnxuam0/

API Reference: https://api.highcharts.com/highmaps/series.mapline.color


问:
Angular Material Table change specific row content
I have Angular 7 with Material table:

```<code><mat-table #table [dataSource]="dataSource" matSort>

    <ng-container matColumnDef="Extension">
        <mat-header-cell *matHeaderCellDef (click)="sortData('agentExtn')" class="pointer" [ngClass]="getSortClass('agentExtn')" id="ExtnHeader" >
        {{ ExtnHeader | translate }} <div></div >
        </mat-header-cell> <mat-cell *matCellDef="let element" class="ExtnCol"> {{ element.Extn }} </mat-cell>
    </ng-container>

    <ng-container matColumnDef="Play">
        <mat-header-cell *matHeaderCellDef>{{ 'MAIN.PLAY' | translate }}</mat-header-cell>
        <mat-cell *matCellDef="let element">
            <button id="play" class="float-right icon-link" mat-icon-button matTooltip="{{ 'MAIN.PLAY' | translate }}" (click)="    $event.stopPropagation(); playRecord(element.recordId)" >
                <i class="fa fa-play" aria-hidden="true"></i>
            </button>
        </mat-cell>
    </ng-container>

    <mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>

    <mat-row *matRowDef="let row; columns: displayedColumns" [ngClass]="{ 'highlight-row': selectedRow == row.MediaRecord.$.recordId, pointer: true }" (click)="showRecordDetailsDialog(row)">
    </mat-row>
</mat-table>
</code>```

So rows looks similar to following:

On the click of the Play icon, an audio element is displayed somewhere else on the screen.

Now, I want the Play icon of that particular row to replaced by Pause icon. Also, if the user clicks Play icon of another row, the previous row with Pause icon should be replaced by Play icon.

How can I do this? How can I get reference to the particular rows and replace those particular icons?

答:
Make another array isPlaying[] of booleans initialized to false (or add a new column to the existing one) where you save the state of each row, and make the icon change based on that array.Make another array (or add a new column to the existing one) where you save the state of each row, and make the icon change based on that array.

```<code><mat-cell *matCellDef="let element; let i = index">
    <button id="play" class="float-right icon-link" mat-icon-button matTooltip="{{ 'MAIN.PLAY' | translate }}" (click)="    $event.stopPropagation(); playRecord(element.recordId, i)" >
        <i *ngIf="isPlaying[i]=false" class="fa fa-play" aria-hidden="true"></i>
        <i *ngIf="isPlaying[i]=true" class="fa fa-pause" aria-hidden="true"></i>
    </button>
</mat-cell>
</code>```

Your playRecord should play/pause according to isPlaying[i], that's why I passed i as a parameter.

Body:
I have Angular 7 with Material table:

<mat-table #table [dataSource]="dataSource" matSort>

    <ng-container matColumnDef="Extension">
        <mat-header-cell *matHeaderCellDef (click)="sortData('agentExtn')" class="pointer" [ngClass]="getSortClass('agentExtn')" id="ExtnHeader" >
        {{ ExtnHeader | translate }}

        </mat-header-cell> <mat-cell *matCellDef="let element" class="ExtnCol"> {{ element.Extn }} </mat-cell>
    </ng-container>

    <ng-container matColumnDef="Play">
        <mat-header-cell *matHeaderCellDef>{{ 'MAIN.PLAY' | translate }}</mat-header-cell>
        <mat-cell *matCellDef="let element">
            <button id="play" class="float-right icon-link" mat-icon-button matTooltip="{{ 'MAIN.PLAY' | translate }}" (click)="    $event.stopPropagation(); playRecord(element.recordId)" >

            </button>
        </mat-cell>
    </ng-container>

    <mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>

    <mat-row *matRowDef="let row; columns: displayedColumns" [ngClass]="{ 'highlight-row': selectedRow == row.MediaRecord.$.recordId, pointer: true }" (click)="showRecordDetailsDialog(row)">
    </mat-row>
</mat-table>

So rows looks similar to following:

On the click of the Play icon, an audio element is displayed somewhere else on the screen.

Now, I want the Play icon of that particular row to replaced by Pause icon. Also, if the user clicks Play icon of another row, the previous row with Pause icon should be replaced by Play icon.

How can I do this? How can I get reference to the particular rows and replace those particular icons?

Body:
Make another array isPlaying[] of booleans initialized to false (or add a new column to the existing one) where you save the state of each row, and make the icon change based on that array.Make another array (or add a new column to the existing one) where you save the state of each row, and make the icon change based on that array.

<mat-cell *matCellDef="let element; let i = index">
    <button id="play" class="float-right icon-link" mat-icon-button matTooltip="{{ 'MAIN.PLAY' | translate }}" (click)="    $event.stopPropagation(); playRecord(element.recordId, i)" >
        <i *ngIf="isPlaying[i]=false" class="fa fa-play" aria-hidden="true"></i>
        <i *ngIf="isPlaying[i]=true" class="fa fa-pause" aria-hidden="true"></i>
    </button>
</mat-cell>

Your playRecord should play/pause according to isPlaying[i], that's why I passed i as a parameter.


问:
trouble installing RVM on a mac
I am trying to set up a local Rails environment, and I am having issues with getting RVM installed.

Here is the error I get:

```<code>$ bash < <( curl http://rvm.io/releases/rvm-install-head )
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                Dload  Upload   Total   Spent    Left  Speed
100   185  100   185    0     0    136      0  0:00:01  0:00:01 --:--:--     0
bash: line 1: html: No such file or directory
bash: line 2: syntax error near unexpected token `<'
'ash: line 2: `<head><title>301 Moved Permanently</title></head>

The contents of my /usr/local folder are as follows:
bin          man
etc          mysql
hermes       mysql-5.1.56-osx10.5-x86_64
include      rvm
info         share
lib
</code>```

I have some working knowledge of what's going on here, but help on what I'm missing or whether I'm approaching this the wrong way would be greatly appreciated.

答:
You are missing the -s option to curl.

```<code>bash < <(curl -s https://rvm.io/releases/rvm-install-head )
</code>```

Title: trouble installing RVM on a mac

Body:
I am trying to set up a local Rails environment, and I am having issues with getting RVM installed.

Here is the error I get:

$ bash < <( curl http://rvm.io/releases/rvm-install-head )
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                Dload  Upload   Total   Spent    Left  Speed
100   185  100   185    0     0    136      0  0:00:01  0:00:01 --:--:--     0
bash: line 1: html: No such file or directory
bash: line 2: syntax error near unexpected token `<'
'ash: line 2: `<title>301 Moved Permanently</title>

The contents of my /usr/local folder are as follows:
bin          man
etc          mysql
hermes       mysql-5.1.56-osx10.5-x86_64
include      rvm
info         share
lib

I have some working knowledge of what's going on here, but help on what I'm missing or whether I'm approaching this the wrong way would be greatly appreciated.

Body:
You are missing the -s option to curl.

bash < <(curl -s https://rvm.io/releases/rvm-install-head )


问:
Cascading Drop Down in ASP.NET Core using Razor and jQuery
I've been trying to populate two dropdown list from my database. The first one is populated on form load, and I want to fill the second after the user selects a value in the first one.

I have followed and adapted this tutorial. But with no luck.

My Controller

using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Oracle.ManagedDataAccess.Client;
using MaterialProjectMaterials.Models;
using UserProfile.Models;
using System.Data;
using Microsoft.AspNetCore.Http;

namespace MaterialProject.Controllers
{
    public class MaterialsController : Controller
    {
        private readonly OracleConnection con = new OracleConnection(GetConString.ConString());

        public IActionResult Materials()
        {
            List<Brands> brandslist = new List<Brands>();
            brandslist.Insert(0, new Brands { BCodeID = 0, BDescr = "--Select Brand--" });
            //Getting Data from Database using EntityFrameworkCore
            con.Open();
            string b_query = "SELECT codeID, descr  FROM itemcategory WHERE codeID LIKE ('3%') AND LENGTH(codeID)= 3 and rownum<=2 ORDER BY descr";
            OracleCommand b_cmd = new OracleCommand(b_query, con);
            OracleDataAdapter b_da = new OracleDataAdapter(b_cmd);
            DataTable b_dt = new DataTable();
            b_da.Fill(b_dt);
            foreach (DataRow b_rb in b_dt.Rows)
            {
                brandslist.Add(new Brands
                {
                    BCodeID = Convert.ToInt64(b_rb["codeID"]),
                    BDescr = b_rb["descr"].ToString()
                });
            }
            con.Close();
            ViewBag.BrandsList = brandslist;
            return View();
        }

        [HttpPost]
        public IActionResult Materials(Brands objbrand, FormCollection formCollection)
        {
            //Validation
            if (objbrand.BCodeID == 0)
                ModelState.AddModelError("", "Select Brand");
            else if (objbrand.VCodeID == 0)
                ModelState.AddModelError("", "Select Volume");

            //Getting selected Value
            var BCodeID = HttpContext.Request.Form["BCodeID"].ToString();
            var VCodeID = HttpContext.Request.Form["VCodeID"].ToString();

            //Setting Data back to ViewBag after Posting Form
            List<Brands> brandslist = new List<Brands>();
            brandslist.Insert(0, new Brands { BCodeID = 0, BDescr = "--Select Brand--" });
            //Getting Data from Database
            con.Open();
            string b_query = "SELECT codeID, descr  FROM itemcategory WHERE codeID LIKE ('3%') AND LENGTH(codeID)= 3 ORDER BY descr";
            OracleCommand b_cmd = new OracleCommand(b_query, con);
            OracleDataAdapter b_da = new OracleDataAdapter(b_cmd);
            DataTable b_dt = new DataTable();
            b_da.Fill(b_dt);
            foreach (DataRow b_rb in b_dt.Rows)
            {
                brandslist.Add(new Brands
                {
                    BCodeID = Convert.ToInt64(b_rb["codeID"]),
                    BDescr = b_rb["descr"].ToString()
                });
            }
            con.Close();
            //Assing BCodeID to ViewBag.BrandsList
            ViewBag.BrandsList = brandslist;
            return View(objbrand);
        }

        public JsonResult GetVolumes(Int64? BCodeID)
        {
            if (BCodeID == null)
            {
                throw new ArgumentNullException(nameof(BCodeID));
            }

            List<Volume> volumelist = new List<Volume>();
            volumelist.Insert(0, new Volume { VCodeID = 0, VDescr = "--Select Volume--" });
            //Getting Data from Database
            con.Open();
            string v_query = "SELECT DISTINCT IG.CODEID, IG.DESCR FROM MATERIAL M INNER JOIN ITEMGROUP IG ON M.IGPID = IG.CODEID INNER JOIN ITEMCATEGORY IC ON '3' || SUBSTR(M.ICTID, 3, 2) = IC.CODEID WHERE M.ICTID LIKE('3%') AND IC.CODEID =" + BCodeID + "ORDER BY CODEID";
            OracleCommand v_cmd = new OracleCommand(v_query, con);
            OracleDataAdapter v_da = new OracleDataAdapter(v_cmd);
            DataTable v_dt = new DataTable();
            v_da.Fill(v_dt);
            foreach (DataRow v_dr in v_dt.Rows)
            {
                volumelist.Add(new Volume
                {
                    VCodeID = Convert.ToInt64(v_dr["codeID"]),
                    VDescr = v_dr["descr"].ToString()
                });
            }
            con.Close();
            return Json(new SelectList(volumelist, "VCodeID", "VDescr"));
        }
    }
}
```

<p>My View</p>

```@model MaterialProjectMaterials.Models.Brands
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

@{

    <form asp-controller="Materials" asp-action="Materials" method="post" class="form-horizontal" role="form">

                    Brands
                    <select asp-for="BCodeID" class="form-control"
                            asp-items="@(new SelectList(ViewBag.BrandsList, "BCodeID", "BDescr"))"></select>

                    Volume
                    <select class="form-control" id="vCodeID" name="vDescr" asp-for="VCodeID"
                            asp-items="@(new SelectList(string.Empty, "VCodeID", "VDescr"))"></select>

                    <input id="Submit1" type="submit" value="Submit" />

    </form>
}
```

<p>My Models</p>

<pre class="lang-cs prettyprint-override"><code>namespace MaterialProjectMaterials.Models
{

    public class MaterialsModel
    {
        public DbSet<Brands> Brands { get; set; }
        public DbSet<Volume> Volume { get; set; }
    }
}

namespace MaterialProjectMaterials.Models
{
    [Table("ITEMCATEGORY")]
    public class Brands
    {
        [Key]
        [Column("CODEID")]
        public Int64 BCodeID { get; set; }
        [Column("DESCR")]
        public string BDescr { get; set; }
        [NotMapped]
        public Int64 VCodeID { get; set; }
    }
}

namespace MaterialProjectMaterials.Models
{
    [Table("IT_MATERIAL_VOLUMES")]
    public class Volume
    {
        [Key]
        [Column("VCODEID")]
        public Int64 VCodeID { get; set; }
        [Column("VDESCR")]
        public string VDescr { get; set; }
        [Column("BDESCR")]
        public int BCodeID { get; set; }
    }
}
</code>```

The result when I run the project is that I can get the values in the first dropdownlist, but when I select a value I did not get anything back to the second dropdownlist.

I would appreciate any help.
Thanks in advance.

答:
Update 1

In the debugger I get the follows error concerning the javascrips

```<code>Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request starting HTTP/1.1 GET http://localhost:44373/lib/jquery/jquery.js
Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request finished in 3.5252ms 404
Unhandled exception at line 4, column 9 in https://localhost:44373/Home/Login
0x800a1391 - JavaScript runtime error: '$' is undefined
</code>```

as for the line

```<code>Unhandled exception at line 4, column 9 in https://localhost:44373/Home/Login
</code>```

it says that the script locate at ~/Home/Login but my script are at ~/Materials/Materials

Finally my .js files are locate at
~\MaterialProject\wwwroot\lib\jquery

Any help would appreciate a lot!

Update 2

I solve my problem

I use  instead of  and also I replace

```<code><div class="form-group">
            <div class="row">
                <div class="col-xs-12 col-sm-6 col-lg-4">
                    <label class="control-label">Volume</label>
                    <select class="form-control" id="vCodeID" name="vDescr" asp-for="VCodeID"
                            asp-items="@(new SelectList(string.Empty, "VCodeID", "VDescr"))"></select>
                </div>
            </div>
        </div>
</code>```

with

```<code><div class="form-group">
            <div class="row">
                <div class="col-xs-12 col-sm-6 col-lg-4">
                    <label asp-for="VDescr" class="control-label">Volume</label>
                    <select asp-for="VCodeID" class="form-control"
                            asp-items="@(new SelectList(string.Empty, "VCodeID", "VDescr"))"></select>
                </div>
            </div>
        </div>
</code>```

Body:
I've been trying to populate two dropdown list from my database. The first one is populated on form load, and I want to fill the second after the user selects a value in the first one.

I have followed and adapted this tutorial. But with no luck.

My Controller

using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Oracle.ManagedDataAccess.Client;
using MaterialProjectMaterials.Models;
using UserProfile.Models;
using System.Data;
using Microsoft.AspNetCore.Http;

namespace MaterialProject.Controllers
{
    public class MaterialsController : Controller
    {
        private readonly OracleConnection con = new OracleConnection(GetConString.ConString());

        public IActionResult Materials()
        {
            List<Brands> brandslist = new List<Brands>();
            brandslist.Insert(0, new Brands { BCodeID = 0, BDescr = "--Select Brand--" });
            //Getting Data from Database using EntityFrameworkCore
            con.Open();
            string b_query = "SELECT codeID, descr  FROM itemcategory WHERE codeID LIKE ('3%') AND LENGTH(codeID)= 3 and rownum<=2 ORDER BY descr";
            OracleCommand b_cmd = new OracleCommand(b_query, con);
            OracleDataAdapter b_da = new OracleDataAdapter(b_cmd);
            DataTable b_dt = new DataTable();
            b_da.Fill(b_dt);
            foreach (DataRow b_rb in b_dt.Rows)
            {
                brandslist.Add(new Brands
                {
                    BCodeID = Convert.ToInt64(b_rb["codeID"]),
                    BDescr = b_rb["descr"].ToString()
                });
            }
            con.Close();
            ViewBag.BrandsList = brandslist;
            return View();
        }

        [HttpPost]
        public IActionResult Materials(Brands objbrand, FormCollection formCollection)
        {
            //Validation
            if (objbrand.BCodeID == 0)
                ModelState.AddModelError("", "Select Brand");
            else if (objbrand.VCodeID == 0)
                ModelState.AddModelError("", "Select Volume");

            //Getting selected Value
            var BCodeID = HttpContext.Request.Form["BCodeID"].ToString();
            var VCodeID = HttpContext.Request.Form["VCodeID"].ToString();

            //Setting Data back to ViewBag after Posting Form
            List<Brands> brandslist = new List<Brands>();
            brandslist.Insert(0, new Brands { BCodeID = 0, BDescr = "--Select Brand--" });
            //Getting Data from Database
            con.Open();
            string b_query = "SELECT codeID, descr  FROM itemcategory WHERE codeID LIKE ('3%') AND LENGTH(codeID)= 3 ORDER BY descr";
            OracleCommand b_cmd = new OracleCommand(b_query, con);
            OracleDataAdapter b_da = new OracleDataAdapter(b_cmd);
            DataTable b_dt = new DataTable();
            b_da.Fill(b_dt);
            foreach (DataRow b_rb in b_dt.Rows)
            {
                brandslist.Add(new Brands
                {
                    BCodeID = Convert.ToInt64(b_rb["codeID"]),
                    BDescr = b_rb["descr"].ToString()
                });
            }
            con.Close();
            //Assing BCodeID to ViewBag.BrandsList
            ViewBag.BrandsList = brandslist;
            return View(objbrand);
        }

        public JsonResult GetVolumes(Int64? BCodeID)
        {
            if (BCodeID == null)
            {
                throw new ArgumentNullException(nameof(BCodeID));
            }

            List<Volume> volumelist = new List<Volume>();
            volumelist.Insert(0, new Volume { VCodeID = 0, VDescr = "--Select Volume--" });
            //Getting Data from Database
            con.Open();
            string v_query = "SELECT DISTINCT IG.CODEID, IG.DESCR FROM MATERIAL M INNER JOIN ITEMGROUP IG ON M.IGPID = IG.CODEID INNER JOIN ITEMCATEGORY IC ON '3' || SUBSTR(M.ICTID, 3, 2) = IC.CODEID WHERE M.ICTID LIKE('3%') AND IC.CODEID =" + BCodeID + "ORDER BY CODEID";
            OracleCommand v_cmd = new OracleCommand(v_query, con);
            OracleDataAdapter v_da = new OracleDataAdapter(v_cmd);
            DataTable v_dt = new DataTable();
            v_da.Fill(v_dt);
            foreach (DataRow v_dr in v_dt.Rows)
            {
                volumelist.Add(new Volume
                {
                    VCodeID = Convert.ToInt64(v_dr["codeID"]),
                    VDescr = v_dr["descr"].ToString()
                });
            }
            con.Close();
            return Json(new SelectList(volumelist, "VCodeID", "VDescr"));
        }
    }
}

My View

@model MaterialProjectMaterials.Models.Brands
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

@{

    <form asp-controller="Materials" asp-action="Materials" method="post" class="form-horizontal" role="form">

                    Brands
                    <select asp-for="BCodeID" class="form-control"
                            asp-items="@(new SelectList(ViewBag.BrandsList, "BCodeID", "BDescr"))"></select>

                    Volume
                    <select class="form-control" id="vCodeID" name="vDescr" asp-for="VCodeID"
                            asp-items="@(new SelectList(string.Empty, "VCodeID", "VDescr"))"></select>

                    <input id="Submit1" type="submit" value="Submit" />

    </form>
}

My Models

namespace MaterialProjectMaterials.Models
{

    public class MaterialsModel
    {
        public DbSet<Brands> Brands { get; set; }
        public DbSet<Volume> Volume { get; set; }
    }
}

namespace MaterialProjectMaterials.Models
{
    [Table("ITEMCATEGORY")]
    public class Brands
    {
        [Key]
        [Column("CODEID")]
        public Int64 BCodeID { get; set; }
        [Column("DESCR")]
        public string BDescr { get; set; }
        [NotMapped]
        public Int64 VCodeID { get; set; }
    }
}

namespace MaterialProjectMaterials.Models
{
    [Table("IT_MATERIAL_VOLUMES")]
    public class Volume
    {
        [Key]
        [Column("VCODEID")]
        public Int64 VCodeID { get; set; }
        [Column("VDESCR")]
        public string VDescr { get; set; }
        [Column("BDESCR")]
        public int BCodeID { get; set; }
    }
}

The result when I run the project is that I can get the values in the first dropdownlist, but when I select a value I did not get anything back to the second dropdownlist.

I would appreciate any help.
Thanks in advance.

Body:
Update 1

In the debugger I get the follows error concerning the javascrips

Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request starting HTTP/1.1 GET http://localhost:44373/lib/jquery/jquery.js
Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request finished in 3.5252ms 404
Unhandled exception at line 4, column 9 in https://localhost:44373/Home/Login
0x800a1391 - JavaScript runtime error: '$' is undefined

as for the line

Unhandled exception at line 4, column 9 in https://localhost:44373/Home/Login

it says that the script locate at ~/Home/Login but my script are at ~/Materials/Materials

Finally my .js files are locate at
~\MaterialProject\wwwroot\lib\jquery

Any help would appreciate a lot!

Update 2

I solve my problem

I use  instead of  and also I replace

<div class="form-group">
            <div class="row">
                <div class="col-xs-12 col-sm-6 col-lg-4">
                    <label class="control-label">Volume</label>
                    <select class="form-control" id="vCodeID" name="vDescr" asp-for="VCodeID"
                            asp-items="@(new SelectList(string.Empty, "VCodeID", "VDescr"))"></select>
                </div>
            </div>
        </div>

with

<div class="form-group">
            <div class="row">
                <div class="col-xs-12 col-sm-6 col-lg-4">
                    <label asp-for="VDescr" class="control-label">Volume</label>
                    <select asp-for="VCodeID" class="form-control"
                            asp-items="@(new SelectList(string.Empty, "VCodeID", "VDescr"))"></select>
                </div>
            </div>
        </div>


问:
Modify the given program to use a loop to output
This program outputs a downwards facing arrow composed of a rectangle and a right triangle. The arrow dimensions are defined by user specified arrow base height, arrow base width, and arrow head width.

Modify the given program to use a loop to output an arrow base of height arrow_base_height.

(1 pt)

Modify the given program to use a loop to output an arrow base of width arrow_base_width.

(1 pt)

Modify the given program to use a loop to output an arrow head of width arrow_head_width.

(2 pts)

Modify the given program to only accept an arrow head width that is larger than the arrow base width. Use a loop to continue prompting the user for an arrow head width until the value is larger than the arrow base width.

(1 pt)

Code:

```<code>while arrow_head_width <= arrow_base_width:
    print ('Enter arrow head width: ')
    arrow_head_width = int(input())
</code>```

Example output for arrow_base_height = 5, arrow_base_width = 2, and arrow_head_width = 4:

Enter arrow base height: 5
Enter arrow base width: 2
Enter arrow head width: 4
**
**
**
**
**
****
***
**
*
```

答:
Try this:

```<code>arrow_head_height = int(input('Enter Head Height'))
arrow_base_height = int(input('Enter Base Height'))
arrow_base_width = int(input('Enter Base Width'))

while arrow_base_height > 0:
    print(arrow_base_width*'*')
    arrow_base_height -= 1
    if arrow_base_height == 0:
        for i in range(arrow_head_height,0,-1):
            print(i*'*')
</code>```

Body:
This program outputs a downwards facing arrow composed of a rectangle and a right triangle. The arrow dimensions are defined by user specified arrow base height, arrow base width, and arrow head width.

Modify the given program to use a loop to output an arrow base of height arrow_base_height.

(1 pt)

Modify the given program to use a loop to output an arrow base of width arrow_base_width.

(1 pt)

Modify the given program to use a loop to output an arrow head of width arrow_head_width.

(2 pts)

Modify the given program to only accept an arrow head width that is larger than the arrow base width. Use a loop to continue prompting the user for an arrow head width until the value is larger than the arrow base width.

(1 pt)

Code:

while arrow_head_width <= arrow_base_width:
    print ('Enter arrow head width: ')
    arrow_head_width = int(input())

Example output for arrow_base_height = 5, arrow_base_width = 2, and arrow_head_width = 4:

Enter arrow base height: 5
Enter arrow base width: 2
Enter arrow head width: 4
**
**
**
**
**
****
***
**
*

Body:
Try this:

arrow_head_height = int(input('Enter Head Height'))
arrow_base_height = int(input('Enter Base Height'))
arrow_base_width = int(input('Enter Base Width'))

while arrow_base_height > 0:
    print(arrow_base_width*'*')
    arrow_base_height -= 1
    if arrow_base_height == 0:
        for i in range(arrow_head_height,0,-1):
            print(i*'*')


问:
How to set a dynamic position for a popup?
I have a list of items. When I click on one of them, a popup should appear above them, but this doesn't happen, in fact the popup always appears in the same position.
How can I change the position of the popup so that it only appears above the clicked item?

This is my CSS:

```<code>popup {
  position: relative;
  display: inline-block;
  cursor: pointer;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}
popup .popuptext {
  visibility: hidden;
  width: 160px;
  background-color: #555;
  color: #fff;
  text-align: center;
  border-radius: 6px;
  padding: 8px 0;
  position: absolute;
  z-index: 1;
  bottom: 125%;
  left: 50%;
  margin-left: -80px;
}
popup .show {
  visibility: visible;
  -webkit-animation: fadeIn 1s;
  animation: fadeIn 1s;
}
</code>```

Instead this is the template of my component:

```<code>template:'<li> <div class="popup"> <button v-on:click="aggiornaClicked"> {{ todo.name }} </button> <span class="popuptext" id="myPopup"> Acquistato! </span> </div> </li>'
</code>```

答:
$(".content button").click(function(){
  $(this).parent().children(".popup").addClass("show")
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>*{
  margin:0;
  padding:0;
}
.content{
width:30%;
height:100px;
display:flex;
  margin-top:10px;
  background:red;
  color:white;
align-items:center;
  position:relative;
  flex-wrap:wrap;
}
 p{
  width:100%;
   text-align:center;

}
button{
  width:50%;
  margin:0 auto;
}
.popup{
  opacity:0;
  position:absolute;
  top:50%;
  left:50%;
  transform:translate(-50%,-50%)
}
.show.popup{
  opacity:1
}</code>```

some text

  <button>show</button>

this is a popup

some text

  <button>show</button>

this is a popup

```

this is similar to what you trying to do!

Body:
I have a list of items. When I click on one of them, a popup should appear above them, but this doesn't happen, in fact the popup always appears in the same position.
How can I change the position of the popup so that it only appears above the clicked item?

This is my CSS:

popup {
  position: relative;
  display: inline-block;
  cursor: pointer;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}
popup .popuptext {
  visibility: hidden;
  width: 160px;
  background-color: #555;
  color: #fff;
  text-align: center;
  border-radius: 6px;
  padding: 8px 0;
  position: absolute;
  z-index: 1;
  bottom: 125%;
  left: 50%;
  margin-left: -80px;
}
popup .show {
  visibility: visible;
  -webkit-animation: fadeIn 1s;
  animation: fadeIn 1s;
}

Instead this is the template of my component:

template:'

 <button v-on:click="aggiornaClicked"> {{ todo.name }} </button>  Acquistato!

'

Body:
$(".content button").click(function(){
  $(this).parent().children(".popup").addClass("show")
});

*{
  margin:0;
  padding:0;
}
.content{
width:30%;
height:100px;
display:flex;
  margin-top:10px;
  background:red;
  color:white;
align-items:center;
  position:relative;
  flex-wrap:wrap;
}
 p{
  width:100%;
   text-align:center;

}
button{
  width:50%;
  margin:0 auto;
}
.popup{
  opacity:0;
  position:absolute;
  top:50%;
  left:50%;
  transform:translate(-50%,-50%)
}
.show.popup{
  opacity:1
}

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="content">
  <p>some text</p>
  <button>show</button>
  <div class="popup"><p>this is a popup</p></div>
</div>
<div class="content">
  <p>some text</p>
  <button>show</button>
  <div class="popup"><p>this is a popup</p></div>
</div>

this is similar to what you trying to do!


问:
How to fix Refused to display in a frame because it set 'X-Frame-Options' to 'sameorigin
I'm getting an error while using an i-frame in angular. It refused to display in a frame because it set 'X-Frame-Options' to 'sameorigin'

Refused to display 'https://docs.google.com/gview?url=https://subtreebucket.s3.amazonaws.com/docsFile_1559124133664_dummy.pdf' in a frame because it set 'X-Frame-Options' to 'sameorigin'.

答:
Please use santizer with safe pipe and then include the link as below

```<code><iframe class="doc" src="https://docs.google.com/gview?url=https://subtreebucket.s3.amazonaws.com/docsFile_1559124133664_dummy.pdf&embedded=true"></iframe>
</code>```

Make sure you are using embedded=true while adding source in the iframe. It'll definitely work

Body:
Please use santizer with safe pipe and then include the link as below

<iframe class="doc" src="https://docs.google.com/gview?url=https://subtreebucket.s3.amazonaws.com/docsFile_1559124133664_dummy.pdf&embedded=true"></iframe>

Make sure you are using embedded=true while adding source in the iframe. It'll definitely work


问:
Serialize child collections with interfaces
I have an interface like so

```<code>public interface IA{
    IEnumerable<IB> Items {get;set;}
}

public interface IB{
    int ID {get;set;}
}
</code>```

If I try to serialize the interface I get an error

```<code>Cannot serialize interface
</code>```

If I create a concrete version of the interface, I can't create a concrete version of the collection.

```<code>public class classA:IA{
   public IEnumerable<B> Items {get;set;}  //this doesn't match the interface
}
</code>```

but if I do the below we still have the serialization problem

```<code>public class classA:IA{
   public IEnumerable<IB> Items {get;set;}
}
</code>```

答: The Serializable attribute cannot be inherited from a base class. Add it to child class and try again.</p>

Body:
I have an interface like so

public interface IA{
    IEnumerable<IB> Items {get;set;}
}

public interface IB{
    int ID {get;set;}
}

If I try to serialize the interface I get an error

Cannot serialize interface

If I create a concrete version of the interface, I can't create a concrete version of the collection.

public class classA:IA{
   public IEnumerable Items {get;set;}  //this doesn't match the interface
}

but if I do the below we still have the serialization problem

public class classA:IA{
   public IEnumerable<IB> Items {get;set;}
}


问:
How to set a timeout in Spring 5 WebFlux WebClient
I'm trying to set timeout on my WebClient, here is the current code :

```<code>SslContext sslContext = SslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build();

ClientHttpConnector httpConnector = new ReactorClientHttpConnector(opt -> {
    opt.sslContext(sslContext);
    HttpClientOptions option = HttpClientOptions.builder().build();
    opt.from(option);
});
return WebClient.builder().clientConnector(httpConnector).defaultHeader("Authorization", xxxx)
                .baseUrl(this.opusConfig.getBaseURL()).build();
</code>```

I need to add timeout and also pooling strategy, I was thinking of something like that :

```<code>PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
cm.setMaxTotal(this.applicationConfig.getHttpClientMaxPoolSize());
cm.setDefaultMaxPerRoute(this.applicationConfig.getHttpClientMaxPoolSize());
cm.closeIdleConnections(this.applicationConfig.getServerIdleTimeout(), TimeUnit.MILLISECONDS);

RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(this.applicationConfig.getHttpClientSocketTimeout())
        .setConnectTimeout(this.applicationConfig.getHttpClientConnectTimeout())
        .setConnectionRequestTimeout(this.applicationConfig.getHttpClientRequestTimeout()).build();

CloseableHttpClient httpClient = HttpClients.custom().setDefaultRequestConfig(requestConfig).setConnectionManager(cm).build();
</code>```

But I can't figure out how to set the httpClient in my webclient

答:
Based on the above comment if you want to add a Socket Timeout just add it as another option in the same timeoutClient.</p>

```<code>TcpClient timeoutClient = TcpClient.create()
    .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, SECONDS*10) //Connect Timeout
    .option(ChannelOption.SO_TIMEOUT,1000) // Socket Timeout
    .doOnConnected(
        c -> c.addHandlerLast(new ReadTimeoutHandler(SECONDS))
              .addHandlerLast(new WriteTimeoutHandler(SECONDS)));
return webClientBuilder.baseUrl(YOUR_URL)
       .clientConnector(new ReactorClientHttpConnector(HttpClient.from(timeoutClient)))
       .build();
</code>```

Body:
I'm trying to set timeout on my WebClient, here is the current code :

SslContext sslContext = SslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build();

ClientHttpConnector httpConnector = new ReactorClientHttpConnector(opt -> {
    opt.sslContext(sslContext);
    HttpClientOptions option = HttpClientOptions.builder().build();
    opt.from(option);
});
return WebClient.builder().clientConnector(httpConnector).defaultHeader("Authorization", xxxx)
                .baseUrl(this.opusConfig.getBaseURL()).build();

I need to add timeout and also pooling strategy, I was thinking of something like that :

PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
cm.setMaxTotal(this.applicationConfig.getHttpClientMaxPoolSize());
cm.setDefaultMaxPerRoute(this.applicationConfig.getHttpClientMaxPoolSize());
cm.closeIdleConnections(this.applicationConfig.getServerIdleTimeout(), TimeUnit.MILLISECONDS);

RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(this.applicationConfig.getHttpClientSocketTimeout())
        .setConnectTimeout(this.applicationConfig.getHttpClientConnectTimeout())
        .setConnectionRequestTimeout(this.applicationConfig.getHttpClientRequestTimeout()).build();

CloseableHttpClient httpClient = HttpClients.custom().setDefaultRequestConfig(requestConfig).setConnectionManager(cm).build();

But I can't figure out how to set the httpClient in my webclient

Body:
Based on the above comment if you want to add a Socket Timeout just add it as another option in the same timeoutClient.

TcpClient timeoutClient = TcpClient.create()
    .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, SECONDS*10) //Connect Timeout
    .option(ChannelOption.SO_TIMEOUT,1000) // Socket Timeout
    .doOnConnected(
        c -> c.addHandlerLast(new ReadTimeoutHandler(SECONDS))
              .addHandlerLast(new WriteTimeoutHandler(SECONDS)));
return webClientBuilder.baseUrl(YOUR_URL)
       .clientConnector(new ReactorClientHttpConnector(HttpClient.from(timeoutClient)))
       .build();