问:
"javafx.fxml.LoadException" when loading fxml
The error is being produced at showAdminLoginScene() method,
However if I modify this method and I put another fxml file from the same package to load, it loads just fine :  here's my Main :

```<code>package application;

import java.io.IOException;

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

public class Main extends Application {
  private Stage primaryStage;
  private static BorderPane mainLayout;
  @Override
public void start(Stage primaryStage) throws IOException {
    this.primaryStage= primaryStage;
    this.primaryStage.setTitle("LAU LABS");
    showMainView();
}
private void showMainView() throws IOException{
    FXMLLoader loader=new FXMLLoader();
    loader.setLocation(Main.class.getResource("MainView.fxml"));

    mainLayout=loader.load();

    Scene scene=new Scene(mainLayout);
    primaryStage.setScene(scene);
    primaryStage.show();
}

public static void showAdminLoginScene() {
    FXMLLoader loader=new FXMLLoader();
    loader.setLocation(Main.class.getResource("AdminLogin.fxml"));
    BorderPane adminLogin;
    try {
        adminLogin = loader.load();
        mainLayout.setCenter(adminLogin);
        } catch (IOException e) {
        e.printStackTrace();
    }

}
public static void showAdminLoggedIn() {
    FXMLLoader loader=new FXMLLoader();
    loader.setLocation(Main.class.getResource("AdminLoggedIn.fxml"));
    AnchorPane adminLoggedIn;
    try {
        adminLoggedIn = loader.load();
        mainLayout.setCenter(adminLoggedIn);
    } catch (IOException e) {
        System.out.println("the error is in Main, ShowAdminLoggedIn");
    }

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

And here's my controller class :

```<code>package application;

import java.awt.Label;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.io.IOException;

import javafx.fxml.FXML;

public class AdminLoginController {
   @FXML private TextField txtUsername;
   @FXML private TextField txtPassword;
   @FXML private Label lblStatus;
   private Main main;

public void Login(ActionEvent event) {
   if(txtUsername.getText().equals("user")&&
         txtPassword.getText().equals("pass")){
    main.showAdminLoggedIn();
}
else{
    lblStatus.setText("Login Failed!");
}
}
}
</code>```

Here's my fxml :

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

<?import com.gluonhq.charm.glisten.control.TextField?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.PasswordField?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.text.Text?>

<BorderPane xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.AdminLoginController">
   <center>
      <AnchorPane prefHeight="300.0" prefWidth="300.0">
         <children>
            <TextField fx:id="txtUsername" layoutX="56.0" layoutY="79.0" prefHeight="26.0" prefWidth="189.0" />
            <PasswordField fx:id="txtPassword" layoutX="56.0" layoutY="150.0" prefHeight="26.0" prefWidth="189.0" />
            <Button layoutX="56.0" layoutY="227.0" mnemonicParsing="false" onAction="#Login" prefHeight="32.0" prefWidth="189.0" style="-fx-background-color: #004c3c;" text="Login" />
            <Text fill="#004c3c" layoutX="56.0" layoutY="75.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Username" wrappingWidth="60.98307228088379" />
            <Text fill="#004c3c" layoutX="56.0" layoutY="146.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Password" />
            <Button layoutX="1.0" minWidth="52.0" mnemonicParsing="false" prefHeight="39.0" prefWidth="52.0" style="-fx-background-color: Transparent;" />
            <ImageView fitHeight="35.0" fitWidth="200.0" layoutX="10.0" layoutY="14.0" pickOnBounds="true" preserveRatio="true">
               <image>
                  <Image url="@BackButton.png" />
               </image>
            </ImageView>
            <Label fx:id="lblStatus" layoutX="56.0" layoutY="202.0" prefHeight="16.0" prefWidth="189.0" style="-fx-text-fill: Red;" text="Status: " />
         </children>
      </AnchorPane>
   </center>
</BorderPane>
</code>```

They're all in the same package named "application" (the fxml, controller and main)

That's the error :

```<code>javafx.fxml.LoadException:
/C:/Users/Owner/Documents/UNI/programming/workspace/Lau/bin/application/AdminLogin.fxml

    at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
    at javafx.fxml.FXMLLoader.importClass(FXMLLoader.java:2848)
    at javafx.fxml.FXMLLoader.processImport(FXMLLoader.java:2692)
    at javafx.fxml.FXMLLoader.processProcessingInstruction(FXMLLoader.java:2661)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2517)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409)
    at application.Main.showAdminLoginScene(Main.java:39)
    at application.MainViewController.goAdminLogin(MainViewController.java:8)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at sun.reflect.misc.Trampoline.invoke(Unknown Source)
    at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at sun.reflect.misc.MethodUtil.invoke(Unknown Source)
    at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1771)
    at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1657)
    at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
    at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
    at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
    at javafx.event.Event.fireEvent(Event.java:198)
    at javafx.scene.Node.fireEvent(Node.java:8413)
    at javafx.scene.control.Button.fire(Button.java:185)
    at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:182)
    at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:96)
    at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89)
    at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
    at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
    at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
    at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
    at javafx.event.Event.fireEvent(Event.java:198)
    at javafx.scene.Scene$MouseHandler.process(Scene.java:3757)
    at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
    at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
    at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:381)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$354(GlassViewEventHandler.java:417)
    at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:416)
    at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
    at com.sun.glass.ui.View.notifyMouse(View.java:937)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.gluonhq.charm.glisten.control.TextField
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at javafx.fxml.FXMLLoader.loadTypeForPackage(FXMLLoader.java:2916)
    at javafx.fxml.FXMLLoader.loadType(FXMLLoader.java:2905)
    at javafx.fxml.FXMLLoader.importClass(FXMLLoader.java:2846)
    ... 65 more
</code>```

答:
You're missing Gluon's Charm library, you should add it in your build automation tool:

For maven project:

```<code><dependencies>
...
<dependency>
    <groupId>com.gluonhq</groupId>
    <artifactId>charm-glisten</artifactId>
    <version>4.4.1</version> // Change version as needed
</dependency>
...
</dependencies>
<repositories>
       <repository>
         <id>nexus-com-gluonhq</id>
         <name>Nexus repo</name>
         <url>http://nexus.gluonhq.com/nexus/content/repositories/releases</url>
       </repository>
</repositories>
</code>```

for Gradle:

.

```<code>..
repositories {
    ....
    maven {
        url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
    }
   ...
}

dependencies {
    compile 'com.gluonhq:charm-glisten:4.4.1'
    ...
}
</code>```

By the way, in your controller class use javafx.scene.control instead of java.awt as you're using JavaFX project

Body:
The error is being produced at showAdminLoginScene() method,
However if I modify this method and I put another fxml file from the same package to load, it loads just fine :  here's my Main :

package application;

import java.io.IOException;

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

public class Main extends Application {
  private Stage primaryStage;
  private static BorderPane mainLayout;
  @Override
public void start(Stage primaryStage) throws IOException {
    this.primaryStage= primaryStage;
    this.primaryStage.setTitle("LAU LABS");
    showMainView();
}
private void showMainView() throws IOException{
    FXMLLoader loader=new FXMLLoader();
    loader.setLocation(Main.class.getResource("MainView.fxml"));

    mainLayout=loader.load();

    Scene scene=new Scene(mainLayout);
    primaryStage.setScene(scene);
    primaryStage.show();
}

public static void showAdminLoginScene() {
    FXMLLoader loader=new FXMLLoader();
    loader.setLocation(Main.class.getResource("AdminLogin.fxml"));
    BorderPane adminLogin;
    try {
        adminLogin = loader.load();
        mainLayout.setCenter(adminLogin);
        } catch (IOException e) {
        e.printStackTrace();
    }

}
public static void showAdminLoggedIn() {
    FXMLLoader loader=new FXMLLoader();
    loader.setLocation(Main.class.getResource("AdminLoggedIn.fxml"));
    AnchorPane adminLoggedIn;
    try {
        adminLoggedIn = loader.load();
        mainLayout.setCenter(adminLoggedIn);
    } catch (IOException e) {
        System.out.println("the error is in Main, ShowAdminLoggedIn");
    }

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

And here's my controller class :

package application;

import java.awt.Label;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.io.IOException;

import javafx.fxml.FXML;

public class AdminLoginController {
   @FXML private TextField txtUsername;
   @FXML private TextField txtPassword;
   @FXML private Label lblStatus;
   private Main main;

public void Login(ActionEvent event) {
   if(txtUsername.getText().equals("user")&&
         txtPassword.getText().equals("pass")){
    main.showAdminLoggedIn();
}
else{
    lblStatus.setText("Login Failed!");
}
}
}

Here's my fxml :

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

<?import com.gluonhq.charm.glisten.control.TextField?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.PasswordField?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.text.Text?>

<BorderPane xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.AdminLoginController">

      <AnchorPane prefHeight="300.0" prefWidth="300.0">
         <children>
            <TextField fx:id="txtUsername" layoutX="56.0" layoutY="79.0" prefHeight="26.0" prefWidth="189.0" />
            <PasswordField fx:id="txtPassword" layoutX="56.0" layoutY="150.0" prefHeight="26.0" prefWidth="189.0" />
            <Button layoutX="56.0" layoutY="227.0" mnemonicParsing="false" onAction="#Login" prefHeight="32.0" prefWidth="189.0" style="-fx-background-color: #004c3c;" text="Login" />
            <Text fill="#004c3c" layoutX="56.0" layoutY="75.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Username" wrappingWidth="60.98307228088379" />
            <Text fill="#004c3c" layoutX="56.0" layoutY="146.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Password" />
            <Button layoutX="1.0" minWidth="52.0" mnemonicParsing="false" prefHeight="39.0" prefWidth="52.0" style="-fx-background-color: Transparent;" />
            <ImageView fitHeight="35.0" fitWidth="200.0" layoutX="10.0" layoutY="14.0" pickOnBounds="true" preserveRatio="true">
               <image>
                  <Image url="@BackButton.png" />
               </image>
            </ImageView>

         </children>
      </AnchorPane>

</BorderPane>

They're all in the same package named "application" (the fxml, controller and main)

That's the error :

javafx.fxml.LoadException:
/C:/Users/Owner/Documents/UNI/programming/workspace/Lau/bin/application/AdminLogin.fxml

    at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
    at javafx.fxml.FXMLLoader.importClass(FXMLLoader.java:2848)
    at javafx.fxml.FXMLLoader.processImport(FXMLLoader.java:2692)
    at javafx.fxml.FXMLLoader.processProcessingInstruction(FXMLLoader.java:2661)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2517)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409)
    at application.Main.showAdminLoginScene(Main.java:39)
    at application.MainViewController.goAdminLogin(MainViewController.java:8)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at sun.reflect.misc.Trampoline.invoke(Unknown Source)
    at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at sun.reflect.misc.MethodUtil.invoke(Unknown Source)
    at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1771)
    at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1657)
    at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
    at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
    at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
    at javafx.event.Event.fireEvent(Event.java:198)
    at javafx.scene.Node.fireEvent(Node.java:8413)
    at javafx.scene.control.Button.fire(Button.java:185)
    at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:182)
    at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:96)
    at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89)
    at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
    at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
    at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
    at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
    at javafx.event.Event.fireEvent(Event.java:198)
    at javafx.scene.Scene$MouseHandler.process(Scene.java:3757)
    at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
    at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
    at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:381)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$354(GlassViewEventHandler.java:417)
    at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:416)
    at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
    at com.sun.glass.ui.View.notifyMouse(View.java:937)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.gluonhq.charm.glisten.control.TextField
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at javafx.fxml.FXMLLoader.loadTypeForPackage(FXMLLoader.java:2916)
    at javafx.fxml.FXMLLoader.loadType(FXMLLoader.java:2905)
    at javafx.fxml.FXMLLoader.importClass(FXMLLoader.java:2846)
    ... 65 more

Body:
You're missing Gluon's Charm library, you should add it in your build automation tool:

For maven project:

<dependencies>
...
<dependency>
    <groupId>com.gluonhq</groupId>
    <artifactId>charm-glisten</artifactId>
    <version>4.4.1</version> // Change version as needed
</dependency>
...
</dependencies>
<repositories>
       <repository>
         <id>nexus-com-gluonhq</id>
         <name>Nexus repo</name>
         <url>http://nexus.gluonhq.com/nexus/content/repositories/releases</url>
       </repository>
</repositories>

for Gradle:

.

..
repositories {
    ....
    maven {
        url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
    }
   ...
}

dependencies {
    compile 'com.gluonhq:charm-glisten:4.4.1'
    ...
}

By the way, in your controller class use javafx.scene.control instead of java.awt as you're using JavaFX project


来源: stackexchange

问:
Setting Jenkins build with different color than red in case of time-out
Sometimes, some of our builds in Jenkins reaching timeout and getting failed. This is fine by me, but quite confusing since one cannot know with first glance that the job terminated by timeout.

Is there any way coloring such build with different color, instead of the ordinary red one?

答:
Yes you can customize the color of build status using "Modern Status" plugin

https://plugins.jenkins.io/modernstatus/

ContentLicense: CC BY-SA 3.0

ContentLicense: CC BY-SA 4.0


问:
find_element_by_partial_link_text ascii code issue
http://www.m2sys.com/.

When I click on CloudApper™ under Solutions I get an ascii code error.

I find the element using:

```<code>driver.find_element_by_partial_link_text('CloudApper™')
</code>```

How can I click the partial link?

答:
Try the following,

first, you need to interact with the menu:

```<code>driver.find_element_by_id("menu-item-15554").click();
</code>```

then click on the actual element:

```<code>driver.find_element_by_xpath("//a[contains(@href, 'cloudapper-modularized-framework-enterprise-cloud-application')]").click();
</code>```

Body:
http://www.m2sys.com/.

When I click on CloudApper™ under Solutions I get an ascii code error.

I find the element using:

driver.find_element_by_partial_link_text('CloudApper™')

How can I click the partial link?

Body:
Try the following,

first, you need to interact with the menu:

driver.find_element_by_id("menu-item-15554").click();

then click on the actual element:

driver.find_element_by_xpath("//a[contains(@href, 'cloudapper-modularized-framework-enterprise-cloud-application')]").click();


问:
Shuffle multiple javascript arrays in the same way
I've got two arrays

```<code>var mp3 = ['sing.mp3','song.mp3','tune.mp3','jam.mp3',etc];
var ogg = ['sing.ogg','song.ogg','tune.ogg','jam.ogg',etc];
</code>```

i need to shuffle both arrays so that they come out the same way, ex:

```<code>var mp3 = ['tune.mp3','song.mp3','jam.mp3','sing.mp3',etc];
var ogg = ['tune.ogg','song.ogg','jam.ogg','sing.ogg',etc];
</code>```

there's a few posts on stackoverflow that shuffle arrays in different ways--this one is pretty great--but none of them demonstrate how to shuffle two arrays in the same exact way.

thnx!

答:
</p>

```<code><script>
var arrayList= ['a','b','c','d','e','f','g'];
arrayList.sort(function(){
    return 0.5 - Math.random()
})

document.getElementById("output").innerHTML  = arrayList;

<script>
</code>```

Body:
I've got two arrays

var mp3 = ['sing.mp3','song.mp3','tune.mp3','jam.mp3',etc];
var ogg = ['sing.ogg','song.ogg','tune.ogg','jam.ogg',etc];

i need to shuffle both arrays so that they come out the same way, ex:

var mp3 = ['tune.mp3','song.mp3','jam.mp3','sing.mp3',etc];
var ogg = ['tune.ogg','song.ogg','jam.ogg','sing.ogg',etc];

there's a few posts on stackoverflow that shuffle arrays in different ways--this one is pretty great--but none of them demonstrate how to shuffle two arrays in the same exact way.

thnx!


问:
Latest version of Glide giving dependency error
I have upgraded the version of Glide from 4.0.0-RC0 to 4.4.0. But it is giving me an error saying

```<code>Error:Module 'com.github.bumptech.glide:glide:4.4.0' depends on one or more Android Libraries but is a jar
</code>```

It is not saying which jar or any other information.
Does anybody know how to fix this? I am also attaching the entries for Glide in my build.gradle

```<code>compile 'com.github.bumptech.glide:glide:4.4.0'
compile 'com.github.bumptech.glide:okhttp3-integration:4.4.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.4.0'
compile 'com.github.bumptech.glide:annotations:4.4.0'
</code>```

EDIT :  I am using the support library version 27.0.1

答:
You can use it like this in your build. Simply:</p>

```<code>dependencies {
implementation 'com.github.bumptech.glide:glide:4.4.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.4.0'
}
</code>```

Body:
I have upgraded the version of Glide from 4.0.0-RC0 to 4.4.0. But it is giving me an error saying

Error:Module 'com.github.bumptech.glide:glide:4.4.0' depends on one or more Android Libraries but is a jar

It is not saying which jar or any other information.
Does anybody know how to fix this? I am also attaching the entries for Glide in my build.gradle

compile 'com.github.bumptech.glide:glide:4.4.0'
compile 'com.github.bumptech.glide:okhttp3-integration:4.4.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.4.0'
compile 'com.github.bumptech.glide:annotations:4.4.0'

EDIT :  I am using the support library version 27.0.1

Body:
You can use it like this in your build. Simply:

dependencies {
implementation 'com.github.bumptech.glide:glide:4.4.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.4.0'
}


问:
javascript: listen for postMessage events from specific iframe
I have multiple iframes in a page. Now I have one message event listener for the page, which gets the messages from all of the iframes. I have a workaround to know from which iframe the message is coming.

I would like to make event listeners for each iframe separately. Is this possible?

答:
You must listen on the global message event of the window object, but you can filter the source iframe using the source property of MessageEvent.

Example:

```<code>const childWindow = document.getElementById('test-frame').contentWindow;
window.addEventListener('message', message => {
    if (message.source !== childWindow) {
        return; // Skip message in this event listener
    }

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

Body:
You must listen on the global message event of the window object, but you can filter the source iframe using the source property of MessageEvent.

Example:

const childWindow = document.getElementById('test-frame').contentWindow;
window.addEventListener('message', message => {
    if (message.source !== childWindow) {
        return; // Skip message in this event listener
    }

    // ...
});


问:
How to reverse a for loop in a bash script
I need to reverse a for loop in a bash script. There is a directory with videos named after %Y%m.mp4 (201701.mp4; 201702.mp4, 201703.mp4, ...). The loop should start with the oldest filename (e.g. 201712.mp4) How to reverse my for loop?</p>

```<code>outputdir="/path/to/video/monthly/"

for file in "$outputdir"*.mp4
do

echo $file

done
</code>```

答:
You can list your files in a reserved order in the following way:

```<code>ls -1 $outputdir/*.mp4 | sort -r
</code>```

So in you script you can do:

```<code>outputdir="/path/to/video/monthly/"
for file in $(ls -1 $outputdir*.mp4 | sort -r)
do
   echo $file
done
</code>```

NOTE: As @PesaThe pointed out this solution would fail to work with filenames with spaces. If it is the case for you, you should quote the command: "$(ls -1 $outputdir*.mp4 | sort -r)" and use "$file"

UPDATE:
See the following test

```<code>mkdir test && cd $_
for i in {1..5}; do touch test_$i.txt; done
cd -
</code>```

And ls -1 test/*.txt will output:

```<code>test/test_1.txt
test/test_2.txt
test/test_3.txt
test/test_4.txt
test/test_5.txt
</code>```

And ls -1 test/*txt | sort -r will output:

```<code>test/test_5.txt
test/test_4.txt
test/test_3.txt
test/test_2.txt
test/test_1.txt
</code>```

Body:
I need to reverse a for loop in a bash script. There is a directory with videos named after %Y%m.mp4 (201701.mp4; 201702.mp4, 201703.mp4, ...). The loop should start with the oldest filename (e.g. 201712.mp4) How to reverse my for loop?

outputdir="/path/to/video/monthly/"

for file in "$outputdir"*.mp4
do

echo $file

done

Body:
You can list your files in a reserved order in the following way:

ls -1 $outputdir/*.mp4 | sort -r

So in you script you can do:

outputdir="/path/to/video/monthly/"
for file in $(ls -1 $outputdir*.mp4 | sort -r)
do
   echo $file
done

NOTE: As @PesaThe pointed out this solution would fail to work with filenames with spaces. If it is the case for you, you should quote the command: "$(ls -1 $outputdir*.mp4 | sort -r)" and use "$file"

UPDATE:
See the following test

mkdir test && cd $_
for i in {1..5}; do touch test_$i.txt; done
cd -

And ls -1 test/*.txt will output:

test/test_1.txt
test/test_2.txt
test/test_3.txt
test/test_4.txt
test/test_5.txt

And ls -1 test/*txt | sort -r will output:

test/test_5.txt
test/test_4.txt
test/test_3.txt
test/test_2.txt
test/test_1.txt


问:
How to remove angular expression attributes from element
I'd like to know whether it's possible to remove Angular expressions dynamically.
I tried the following without any success:

My button

```<code><button myDirective [disabled]="someExpression">Clippy</button>
</code>```

My Directive

```<code>@Directive({
   selector: '[myDirective]'
})
export class MyDirective {
   constructor(private element: ElementRef) {}

   ngOnInit() {
      this.element.nativeElement.removeAttribute('disabled');
   }
}
</code>```

The problem

Initially the button won't be disabled, but once someExpression re-evaluates it'll add the disabled attribute back to the element.

Just for clarification, I want to remove an Angular expression dynamically. In the above example it's [disabled]. But this can be any binding in the future. I want my directive to overrule the existing binding.

答:
As workaround you can try this:

@Directive({
  selector: '[myDirective]'
})
export class MyDirective {
  @Input() disabled;

  constructor(private element: ElementRef) { }

  ngOnChanges() {
    if (this.disabled) {
      this.element.nativeElement.removeAttribute('disabled');
    }
  }
}
```

Stackblitz Example

Body:
I'd like to know whether it's possible to remove Angular expressions dynamically.
I tried the following without any success:

My button

<button myDirective [disabled]="someExpression">Clippy</button>

My Directive

@Directive({
   selector: '[myDirective]'
})
export class MyDirective {
   constructor(private element: ElementRef) {}

   ngOnInit() {
      this.element.nativeElement.removeAttribute('disabled');
   }
}

The problem

Initially the button won't be disabled, but once someExpression re-evaluates it'll add the disabled attribute back to the element.

Just for clarification, I want to remove an Angular expression dynamically. In the above example it's [disabled]. But this can be any binding in the future. I want my directive to overrule the existing binding.

Body:
As workaround you can try this:

@Directive({
  selector: '[myDirective]'
})
export class MyDirective {
  @Input() disabled;

  constructor(private element: ElementRef) { }

  ngOnChanges() {
    if (this.disabled) {
      this.element.nativeElement.removeAttribute('disabled');
    }
  }
}

Stackblitz Example


问:
ASP.NET CustomValidator with ClientValidationFunction
I'm trying to validate an integer range with a CustomValidator. The range is set dynamically, so when either the min/max values on my usercontrol change, the client validation function is updated. However, I can't get the validation function to fire. I have this code:

```<code><asp:CustomValidator ID="vldAnswerValid" runat="server" ControlToValidate="txtAnswer" Display="Dynamic" SetFocusOnError="true" ValidationGroup="answer" OnServerValidate="vldAnswerValid_ServerValidate" Enabled='<%# !IsReadOnly %>' />
</code>```

Setting the function from the codebehind with:

```<code>vldAnswerValid.ClientValidationFunction = " function(oSrc, args){ alert(1); args.IsValid = false; } ";
</code>```

But there's no message displayed and no alert. Am I missing something?

答: Set EnableClientScript property to True.</p>

ContentLicense: CC BY-SA 2.5

Body:
I'm trying to validate an integer range with a CustomValidator. The range is set dynamically, so when either the min/max values on my usercontrol change, the client validation function is updated. However, I can't get the validation function to fire. I have this code:

<asp:CustomValidator ID="vldAnswerValid" runat="server" ControlToValidate="txtAnswer" Display="Dynamic" SetFocusOnError="true" ValidationGroup="answer" OnServerValidate="vldAnswerValid_ServerValidate" Enabled='<%# !IsReadOnly %>' />

Setting the function from the codebehind with:

vldAnswerValid.ClientValidationFunction = " function(oSrc, args){ alert(1); args.IsValid = false; } ";

But there's no message displayed and no alert. Am I missing something?


问:
Check for changes in the data of a form without using javascript
I currently have the below javascript to detect changes in my form.

```<code>form.addEventListener("input", function () {
        ChangesMade = true;
        console.log("Change");
    });
</code>```

I now need to include whether or not a change has been made in a call to the controller which means that the value can no long be stored in javascript as this is client side.

答:
You have a couple options...

1. Construct a view model with two instances of your model.  One the "original" instance, one the "changed" instance.  Bind the "original" fields to hidden inputs in your form, and bind the "changed" fields to your normal form elements.

Then, when the form is posted to the server, your controller action's input would have two instances to compare.  If the "changed" values are different from the "original" values, then the user changed something.

Note however that users can still change hidden inputs if they want to.  This is not a secure measure, but can be an effective one if "security" isn't a concern here.

2. Keep your view and controller interaction the same as it is, but when the data is posted to the controller you would use the identifier from that record to fetch the original from the database.

Using the posted model and the database-fetched model, compare the two.  If values are different then the user changed something.

Note however that this doesn't cover race conditions.  It's possible that another user changed the database values since this model was originally shown to this user.  You can get around this by adding timestamps of when data was changed, but it might not be enough to tell you what data was changed unless you keep audit copies of old records.  The complexity of that escalates quickly.

It's a trade-off between the two options of which one meets the actual needs of the system with acceptable drawbacks.

Body:
I currently have the below javascript to detect changes in my form.

form.addEventListener("input", function () {
        ChangesMade = true;
        console.log("Change");
    });

I now need to include whether or not a change has been made in a call to the controller which means that the value can no long be stored in javascript as this is client side.


问:
SQL Can't get User Input?
I'm learning SQL. I've heard that it's not possible to get user input in SQL? How are login and sign-ups made then? I'd really like to know if I just heard wrong or if you have to use another language or something like that to get input. Please explain? Thanks.</p>

答: SQL is a language that is used to communicate with relational databases. You cannot write a program in SQL, so you will have to use some other language for that. To interact with a database, use the database API of that language, which will allow you to send SQL statements to the database.</p>

Title: SQL Can't get User Input?


问:
how to add json file to android project
I am simply trying to add a .json file into my android studio project. Most of what I have run into has you create a folder and add it there but I want to simply move it over under app. Here Is my project image

How to add JSON files to my project

Add JSON file to app

答:
Put it androidTest/assets/
Just create file, like a SomeFile.json

Title: how to add json file to android project


问:
Use of [(ngModel)] within FormGroup
I have in my application a registration form. But within this registration form there is an optional 'password' and 'repeat password' input. Since I'd rather not use the FormControl object to retrieve these 2 values (other values are fine), I would like a workaround for the usage of ngModel within a <form>

MCVE

TS:

```<code>public password: string = '';
public passwordRe: string = '';
public registrationForm;

constructor(public fb: Formbuilder) {
    this.registrationForm = this.fb.group({
        'firstname' : [null, Validators.required],
        'lastname': [null, Validators.required]
    });
}
</code>```

HTML

```<code><form [formGroup]="registrationForm" (ngSubmit)="doSomething()">
    <div class="form-group"
            [ngClass]="{'has-error':!registrationForm.controls['firstname'].valid
                && registrationForm.controls['firstname'].touched}">
        <label>Firstname: *</label>
        <input class="form-control" type="text" placeholder="Firstname" [formControl]="registrationForm.controls['firstname']"/>
    </div>

    <div class="form-group"
            [ngClass]="{'has-error':!registrationForm.controls['lastname'].valid
                && registrationForm.controls['lastname'].touched}">
        <label>Lastname: *</label>
        <input class="form-control" type="text" placeholder="Lastname" [formControl]="registrationForm.controls['lastname']"/>
    </div>

    <!-- NG MODELS -->

    <input type="password" [(ngModel)]="password"/>
    <input type="password" [(ngModel)]="passwordRe" />

    <input type="submit" value="Some submit button"/>
</form>
</code>```

This page is shown on multiple pages as a child, via a selector. Placing the passwords on top, outside of the form would be the laziest solution, but I'd have to change some code to get that. (plus it doesn't look good) So I was wondering if there's a workaround for this specific issue.

答:
If you provide the attribute:

formControlName = "your form control name here"

in the input then they can co-exist like so;

```<code><input type="password"
       [(ngModel)] = "password"
       formControlName = "password"/>
</code>```

The formControlName must match the name provided in your FormGroup

```<code>this.formGroup = this._formBuilder.group({
  'password': new FormControl(this.password, [
     Validators.required,
     Validators.minLength(4)
  ])
});
</code>```

Title: Use of [(ngModel)] within FormGroup

Body:
I have in my application a registration form. But within this registration form there is an optional 'password' and 'repeat password' input. Since I'd rather not use the FormControl object to retrieve these 2 values (other values are fine), I would like a workaround for the usage of ngModel within a <form>

MCVE

TS:

public password: string = '';
public passwordRe: string = '';
public registrationForm;

constructor(public fb: Formbuilder) {
    this.registrationForm = this.fb.group({
        'firstname' : [null, Validators.required],
        'lastname': [null, Validators.required]
    });
}

HTML

<form [formGroup]="registrationForm" (ngSubmit)="doSomething()">

        Firstname: *
        <input class="form-control" type="text" placeholder="Firstname" [formControl]="registrationForm.controls['firstname']"/>

        Lastname: *
        <input class="form-control" type="text" placeholder="Lastname" [formControl]="registrationForm.controls['lastname']"/>

    <input type="password" [(ngModel)]="password"/>
    <input type="password" [(ngModel)]="passwordRe" />

    <input type="submit" value="Some submit button"/>
</form>

This page is shown on multiple pages as a child, via a selector. Placing the passwords on top, outside of the form would be the laziest solution, but I'd have to change some code to get that. (plus it doesn't look good) So I was wondering if there's a workaround for this specific issue.

Body:
If you provide the attribute:

formControlName = "your form control name here"

in the input then they can co-exist like so;

<input type="password"
       [(ngModel)] = "password"
       formControlName = "password"/>

The formControlName must match the name provided in your FormGroup

this.formGroup = this._formBuilder.group({
  'password': new FormControl(this.password, [
     Validators.required,
     Validators.minLength(4)
  ])
});


问:
Fill the holes in emgu cv
How can I fill the holes in binary image in emgu cv?
In Aforge.net it's easy, use Fillholes class.</p>

答:
you can use FillConvexPoly

```<code>image.FillConvexPoly(externalContours.ToArray(), new Gray(255));
</code>```

Title: Fill the holes in emgu cv

Body:
you can use FillConvexPoly

image.FillConvexPoly(externalContours.ToArray(), new Gray(255));


问:
asp pages and paypal button
I have an asp.net page in 3.5 that I have a pay pal button on but when I click on the button it just refreshes the page.  I think I need to encapsulate the paypal button in something so it is not trigging the refresh but goes to pay pal.

Anyone know a solution?  Can I use an updatePanel or iframe?

答:
Paypal pay now buttons as generated by paypal site have their own form tags in. ASP.Net pages are generated with the whole page within a form, so you now have a form within a form which wont work. If you opt for a paypal hosted button you can have code like this within the asp.net page which will work:-

<input type="hidden" name="cmd" value="_s-xclick"/>
To order the item name for £99
<input type="hidden" name="hosted_button_id" value="note to programmer-this value is generated by paypal"/>
<asp:ImageButton  ID="Button2" runat="server" PostBackUrl="https://www.paypal.com/cgi-bin/webscr" ImageUrl="https://www.paypal.com/en_US/i/btn/x-click-but23.gif" ImageAlign="AbsBottom" />

I know this is an old question, but I hope this helps someone else.

also, take a look here for a discussion of the issues and other possibe solutions.
http://www.blackbeltcoder.com/Articles/ecommerce/quick-and-dirty-buy-now-buttons-in-asp-net

Title: asp pages and paypal button


问:
MySQL Order by with two colums mix togather
I have this table

```<code>id   |    TOP    |    POS
1    |    60     |    1
2    |    50     |    2
3    |    40     |    3
4    |    30     |    4
5    |    20     |    5
6    |    10     |    6
</code>```

and I need result like this:

```<code>id   |    TOP    |    POS
1    |    60     |    1
6    |    10     |    6
2    |    50     |    2
5    |    20     |    5
3    |    40     |    3
4    |    30     |    4
</code>```

Basicaly I need order result by TOP column DESC but between each line put result from order by POS DESC column.

I tried use MOD but result was wrong

```<code>SELECT * FROM (
select
    @row := @row + 1 as row,
    a.*
from table a
order by TOP desc
) t ORDER BY IF(MOD(row, 2) = 1, TOP, POS);
</code>```

答:
In order to do what you want, you need two sortkeys: the row ordered by TOP and the row ordered by POS. This means tow queries you must join.

Then sort first by the lesser of these two keys (TOP60/POS1 has row #1 for TOP, TOP10/POS6 has row #1 for POS, so these two come first), and then by the TOP key (so TOP60/POS1 has precedence over TOP10/POS6).

```<code>select a1.*
from
(
  select
    @rowtop := @rowtop + 1 as row,
    a.*
  from mytable a
  cross join (select @rowtop := 0) vars
  order by top desc
) a1
join
(
  select
    @rowpos := @rowpos + 1 as row,
    a.*
  from mytable a
  cross join (select @rowpos := 0) vars
  order by pos desc
) a2 using(id)
order by least(a1.row, a2.row), a1.row;
</code>```

REXTESTER DEMO: http://rextester.com/ZKOL97078

Body:
I have this table

id   |    TOP    |    POS
1    |    60     |    1
2    |    50     |    2
3    |    40     |    3
4    |    30     |    4
5    |    20     |    5
6    |    10     |    6

and I need result like this:

id   |    TOP    |    POS
1    |    60     |    1
6    |    10     |    6
2    |    50     |    2
5    |    20     |    5
3    |    40     |    3
4    |    30     |    4

Basicaly I need order result by TOP column DESC but between each line put result from order by POS DESC column.

I tried use MOD but result was wrong

SELECT * FROM (
select
    @row := @row + 1 as row,
    a.*
from table a
order by TOP desc
) t ORDER BY IF(MOD(row, 2) = 1, TOP, POS);

Body:
In order to do what you want, you need two sortkeys: the row ordered by TOP and the row ordered by POS. This means tow queries you must join.

Then sort first by the lesser of these two keys (TOP60/POS1 has row #1 for TOP, TOP10/POS6 has row #1 for POS, so these two come first), and then by the TOP key (so TOP60/POS1 has precedence over TOP10/POS6).

select a1.*
from
(
  select
    @rowtop := @rowtop + 1 as row,
    a.*
  from mytable a
  cross join (select @rowtop := 0) vars
  order by top desc
) a1
join
(
  select
    @rowpos := @rowpos + 1 as row,
    a.*
  from mytable a
  cross join (select @rowpos := 0) vars
  order by pos desc
) a2 using(id)
order by least(a1.row, a2.row), a1.row;

REXTESTER DEMO: http://rextester.com/ZKOL97078


问:
Special HTML characters in meta tag description
My metatag description contains a text with accents or special caracteres.
I'm creating it in Controller MVC and I send to view through of viewbag.

By the way, my text html (when I use browser's view HTML sourcecode) is getting  with a different code.

Example:

orign text: Produtor's Event em 10 Kirkpatrick St, até N...

html text: Produtor's Event em 10 Kirkpatrick St, at&#233...

I need to care about this? Or I need to correct to a new code? How can I?

答:
The solution is easier.

Use @Html.Raw

<meta name="description" content="@Html.Raw(ViewBag.description)" />


问:
C free int array in function after writing value to other variable
i want to free memory allocated to int array in function after assign value from array element to integer variable.

I have code:

```<code> int u(int n)
   {
    int* values = (int*)malloc(sizeof(int)*n + 1);
    int out = 0;
    for (int i = 0; i < 3; i++)
      values[i] = 1;
    if (n < 3)
      return 1;
    else
    {
        for (int i = 3; i <= n; i++)
            values[i] = values[i - values[i - 1]] + values[i - values[i - 2]];
    }
    out = values[n];
    free(values);
    return out;
}
</code>```

Why cant i free memory allocated to array after write a value to another variable?
int out have another adress then allocated memory, all what i want to do its just give a value from array to another variable. Can somebody explain me why i cannot do it?

答:
Remember that sizeof(int)*n + 1 is equal to (sizeof(int)*n) + 1. You allocate space for n integer values, plus one byte.

That means your loop in the else case will write out of bounds (unless sizeof(int) == 1 which few if any platforms have, even historically). And writing out of bounds of allocated memory leads to undefined behavior.

Often, writing out of bounds messes up the private and internal data used by the memory allocator, leading to problems when calling free.

The solution is to either change the allocation so it allocates n + 1 integers (i.e. sizeof(int) * (n + 1)). Or to change the loop condition to i < n.

Body:
i want to free memory allocated to int array in function after assign value from array element to integer variable.

I have code:

 int u(int n)
   {
    int* values = (int*)malloc(sizeof(int)*n + 1);
    int out = 0;
    for (int i = 0; i < 3; i++)
      values[i] = 1;
    if (n < 3)
      return 1;
    else
    {
        for (int i = 3; i <= n; i++)
            values[i] = values[i - values[i - 1]] + values[i - values[i - 2]];
    }
    out = values[n];
    free(values);
    return out;
}

Why cant i free memory allocated to array after write a value to another variable?
int out have another adress then allocated memory, all what i want to do its just give a value from array to another variable. Can somebody explain me why i cannot do it?


问:
C# Replacing values from one dictionary to another
I have 2 dictionaries with the same keys but different values. I need to find in dictionary1 all values that are equal to 1 and replace them with the value in dictionary2. I could edit the first dictionary or better idea is to save the new values into another dictionary either way is fine. My idea was to use a foreach loop and then find any values in dictionary1 == 1 then go inside dictionary2 and extract that value for that key and save it into dictionary1 or another dictionary for that key.</p>

```<code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Practice_With_Dictionaries
{
    class Program
    {
        static void Main(string[] args)
        {

                object[] keys= new object[5];
                keys[0] = "1111";
                keys[1] = "2222";
                kesy[2] = "3333";
                kesy[3] = "4444";
                kesy[4] = "5555";

                object[] speed = new object[5];
                speed[0] = 1;
                speed[1] = 2;
                speed[2] = 1;
                speed[3] = 1;
                speed[4] = 5;

                object[] speed2 = new object[5];
                speed2[0] = 1;
                speed2[1] = 2;
                speed2[2] = 3;
                speed2[3] = 4;
                speed2[4] = 5;

   Dictionary<object, object> dictionary1 = new Dictionary<object,object>();
   Dictionary<object, object> dictionar2 = new Dictionary<object, object>();

                for (int iRow = 0; iRow < interfaceKeys.Length; iRow++)
                {

                  dictionary1.Add(keys[iRow], (double)speed[iRow]);
                  dictionary2.Add(keys[iRow], (double)speed2[iRow]);

                }

                // for each loop with if statements

        }
    }
}
</code>```

答:
you could do something like this

```<code>var dictionary1 = new Dictionary<string, string>
{
    {"a", "1"},
    {"b", "2"},
    {"c", "3"},
    {"d", "3"}
};

var dictionary2 = new Dictionary<string, string>
{
    {"a", "1"},
    {"b", "22"},
    {"c", "33"}
};

var result = dictionary1
    .Where(d => dictionary2.ContainsKey(d.Key) && dictionary2[d.Key] == d.Value);
</code>```

result will contain all values that have same keys in dictinary1 and dictinary2 with values in dictinary1.

Body:
I have 2 dictionaries with the same keys but different values. I need to find in dictionary1 all values that are equal to 1 and replace them with the value in dictionary2. I could edit the first dictionary or better idea is to save the new values into another dictionary either way is fine. My idea was to use a foreach loop and then find any values in dictionary1 == 1 then go inside dictionary2 and extract that value for that key and save it into dictionary1 or another dictionary for that key.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Practice_With_Dictionaries
{
    class Program
    {
        static void Main(string[] args)
        {

                object[] keys= new object[5];
                keys[0] = "1111";
                keys[1] = "2222";
                kesy[2] = "3333";
                kesy[3] = "4444";
                kesy[4] = "5555";

                object[] speed = new object[5];
                speed[0] = 1;
                speed[1] = 2;
                speed[2] = 1;
                speed[3] = 1;
                speed[4] = 5;

                object[] speed2 = new object[5];
                speed2[0] = 1;
                speed2[1] = 2;
                speed2[2] = 3;
                speed2[3] = 4;
                speed2[4] = 5;

   Dictionary<object, object> dictionary1 = new Dictionary<object,object>();
   Dictionary<object, object> dictionar2 = new Dictionary<object, object>();

                for (int iRow = 0; iRow < interfaceKeys.Length; iRow++)
                {

                  dictionary1.Add(keys[iRow], (double)speed[iRow]);
                  dictionary2.Add(keys[iRow], (double)speed2[iRow]);

                }

                // for each loop with if statements

        }
    }
}

Body:
you could do something like this

var dictionary1 = new Dictionary<string, string>
{
    {"a", "1"},
    {"b", "2"},
    {"c", "3"},
    {"d", "3"}
};

var dictionary2 = new Dictionary<string, string>
{
    {"a", "1"},
    {"b", "22"},
    {"c", "33"}
};

var result = dictionary1
    .Where(d => dictionary2.ContainsKey(d.Key) && dictionary2[d.Key] == d.Value);

result will contain all values that have same keys in dictinary1 and dictinary2 with values in dictinary1.


问:
confusing time newrelic graph

In this graph left side graph which says web transaction graph it show seconds in Y-axis and maximum time approaching is 1750 ms which is 1.7 seconds while browser time shows 1.22s why is that . same goes on Apdex score graph, browser apdex score is 1.0 out of 7.0 which is great while if we see at the drawn graph it clearly shows that most of the requests lies in  0.5 - 0.75 seconds region so ain't apdex score should lie > 1.0 instead of sharp 1.0 seconds. I want to understand the graphs and times mentioned. Thanks in advance.

答:
For:

it show seconds in Y-axis and maximum time approaching is 1750 ms which is 1.7 seconds while browser time shows 1.22s why is that

At the point in time where the Web Transaction Time measures 1.7 seconds your throughput is 5+ individual transactions.  In addition, this is at the Overview (Application level), which could be across multiple different types of transactions.  You will not be able to compare this number to an individual browser transaction response time for these reasons.

For:

apdex score should lie > 1.0 instead of sharp 1.0 seconds.

The unit of measurement of Apdex is not seconds.  See here for calculating an Apdex score: https://docs.newrelic.com/docs/apm/new-relic-apm/apdex/apdex-measuring-user-satisfaction#score

Apdex score varies from 0 to 1, with 0 as the worst possible score (100% of response times were Frustrated), and 1 as the best possible score (100% of response times were Satisfied).

Title: confusing time newrelic graph


问:
helm search and fetch not showing updated chart after upload to chartmuseum
I am using Helm to manage services in a Kubernetes cluster and use a chartmuseum to manage charts of my services.

After I've added the repo with the command helm repo add URL, helm can interact with my repo, e.g. install available charts with helm install NAME, or view all charts with helm search.

Now I face the following problem:

After creating or updating a new chart, I upload it with the command:

curl --data-binary "@FILENAME.tgz" http://REPOURL:REPOPORT/api/charts.

When I perform helm search, I expect to see the new chart or the updated version of the chart. This is not the case. Further, when I perform helm fetch NAME, I receive the old version of the updated chart.

In order to see the new or updated chart and use it, I have to re-add the repo (with the same name, otherwise it gets confusing).

Is there a way to refresh the list of available charts, without re-adding the repo?

答: The state of a repository is cached on your disk. When you update the remote repository you need to run helm repo update to retrieve the update before you can access it.


问:
IRB analogue of python -i
I want to use IRB to run a script then give me an interactive prompt. I do this with python -i xy.py in Python, however irb xy.rb exits after execution.

```<code>> python --help

-i    When a script is passed as first argument or the -c option is
      used, enter interactive mode after executing the script or the
      command
</code>```

答:
```<code>irb -r xy.rb
</code>```

It simply requires the file mentioned before giving you a normal IRB prompt.

Title: IRB analogue of python -i

Body:
I want to use IRB to run a script then give me an interactive prompt. I do this with python -i xy.py in Python, however irb xy.rb exits after execution.

> python --help

-i    When a script is passed as first argument or the -c option is
      used, enter interactive mode after executing the script or the
      command

Body:
irb -r xy.rb

It simply requires the file mentioned before giving you a normal IRB prompt.


问:
Installing AODV protocol on Raspberry pi (https://github.com/erimatnor/aodv-uu)
I'm trying to install AODV protocol on Raspberry pi. After completing git clone from "https://github.com/erimatnor/aodv-uu" when I tried to do "make" and I am getting below error. Expecting your suggestion. Thank you!

make
  gcc -Wall -O3 -g -DDEBUG -DCONFIG_GATEWAY  -DDEBUG -o aodvd main.o list.o debug.o timer_queue.o aodv_socket.o aodv_hello.o aodv_neighbor.o aodv_timeout.o routing_table.o seek_list.o aodv_rreq.o aodv_rrep.o aodv_rerr.o nl.o locality.o
  aodv_neighbor.o: In function neighbor_add':
  /home/pi/aodv-uu/aodv_neighbor.c:68: undefined reference tohello_update_timeout'
  aodv_timeout.o: In function route_discovery_timeout':
  /home/pi/aodv-uu/aodv_timeout.c:98: undefined reference tort_table_update_timeout'
  aodv_rreq.o: In function rreq_route_discovery':
  /home/pi/aodv-uu/aodv_rreq.c:460: undefined reference tort_table_update_timeout'
  aodv_rreq.o: In function rreq_local_repair':
  /home/pi/aodv-uu/aodv_rreq.c:521: undefined reference tort_table_update_timeout'
  aodv_rrep.o: In function rrep_forward':
  /home/pi/aodv-uu/aodv_rrep.c:231: undefined reference tort_table_update_timeout'
  nl.o: In function nl_kaodv_callback':
  /home/pi/aodv-uu/nl.c:282: undefined reference tort_table_update_timeout'
  collect2: error: ld returned 1 exit status
  Makefile:112: recipe for target 'aodvd' failed
  make: *** [aodvd] Error 1

答:
The code available from sourceforge is the same code that is on github.  If you download the archive, you'll see that the latest modification date of any file there is 2010.  Given the age of this code, I wouldn't be surprised to find that things simply don't work anymore.

However, here's a quick workaround for your problem.  The root cause appears to be that the problem functions, like rt_table_update_timeout, are declared as inline, but that information seems to get lost somewhere in the build process such that other object files are trying to reference these as non-inline functions.

You can avoid this by opening defs.h, looking for this line:

```<code>#define NS_INLINE inline
</code>```

And replace it with:

```<code>#define NS_INLINE
</code>```

This will allow aodvd to compile correctly (make aodvd).  On my system, the kernel module will subsequently fail to compile:

```<code>cc1: fatal error: /lib/modules/4.13.15-100.fc25.x86_64/build/include/linux/modversions.h: No such file or directory
</code>```

As far as I can tell, the modversions.h file is no longer produced by modern Linux kernels.

Body:
The code available from sourceforge is the same code that is on github.  If you download the archive, you'll see that the latest modification date of any file there is 2010.  Given the age of this code, I wouldn't be surprised to find that things simply don't work anymore.

However, here's a quick workaround for your problem.  The root cause appears to be that the problem functions, like rt_table_update_timeout, are declared as inline, but that information seems to get lost somewhere in the build process such that other object files are trying to reference these as non-inline functions.

You can avoid this by opening defs.h, looking for this line:

#define NS_INLINE inline

And replace it with:

#define NS_INLINE

This will allow aodvd to compile correctly (make aodvd).  On my system, the kernel module will subsequently fail to compile:

cc1: fatal error: /lib/modules/4.13.15-100.fc25.x86_64/build/include/linux/modversions.h: No such file or directory

As far as I can tell, the modversions.h file is no longer produced by modern Linux kernels.


问:
Loader is not working
```<code><script src="https://code.jquery.com/jquery-2.1.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
     $('#sql').on ('click',function() {

       $('#loaderImg').show();

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

And html

```<code><div class="container">
  <h1 class="text-center"></h1>
  <div id="loaderImg" style="display:none;background-color:white;width:100%;height:660px;">
     <img src="25.gif" alt="loader1" style="height:100px; width:100px;position:relative;left:500px;top:300px"></div>
     <input type="submit"  name="sql"  id="sql" onclick="myFunction1()" value="Import Database"   class="btn btn-danger"">
</code>```

I have a button 'import database'.When i clicks the button the loader should be shown until the loading complete.But my problem is the  loader image disappear suddenly after displays for a second.How can i solve this??

答:
Weird, I tried your code on Codepen and it worked well. The only problem is, there is no closing  on your html. And after you close your container div, loading gif should play until you hide it again.

So my suggestions are, remove onclick from button because you are not using it, add closing
 at the end of your code.

I have no idea how big your project is but just in case if another plugin or javascript code interfers with your <input id='#sql'> element,

you may try to use $(document).on ('click', '#sql' ,function() {.....})

instead of $('#sql').on ('click',function() {...});

Title: Loader is not working

Body:
And html

     <input type="submit"  name="sql"  id="sql" onclick="myFunction1()" value="Import Database"   class="btn btn-danger"">

I have a button 'import database'.When i clicks the button the loader should be shown until the loading complete.But my problem is the  loader image disappear suddenly after displays for a second.How can i solve this??

Body:
Weird, I tried your code on Codepen and it worked well. The only problem is, there is no closing  on your html. And after you close your container div, loading gif should play until you hide it again.

So my suggestions are, remove onclick from button because you are not using it, add closing </div> at the end of your code.

I have no idea how big your project is but just in case if another plugin or javascript code interfers with your <input id='#sql'> element,

you may try to use $(document).on ('click', '#sql' ,function() {.....})

instead of $('#sql').on ('click',function() {...});


问:
What objects are in JProfiler 9.2 "CMS Old Gen" Memory Pool?
Using JProfiler 9.2, how can I see which Objects are in the memory pool "CMS Old Gen"?</p>

答: That information is unfortunately not provided by the JVM, only the statistocs are provided by the GC.</p>


问:
Android - How to read contents of a webpage
I'm writing an Android app that uses zxing (barcode scanner).  I've gotten to the point where the barcode scanner returns a product id (example: 798709102087), and I put that in a url (example: http://www.google.com/products?q=798709102087).

What I would like to do is once I construct that url string... I'd display the first result returned by that url.

Here's the flow:
1) They turn on my app
2) They select barcode scan
3) They scan the product (which automagically sends them back to the main page of my app)
4) The user is then shown the first product (if any) found on the google product site.

I don't need you guys to write code for me, I just need suggestions on how I should go about doing this!  I'm relatively new to Android apps, so be gentle!

Thanks for your help guys, and let me know if I can clarify anything.

答:
If you have the content of the search, you must parse it(StackOverFlow question) to get the first url product.

Once you have this URL you can use the WebView with loadURL

Byes


问:
How filling area with different colors in angular2, d3.js?
I made graphic in svg and d3.js on angular2. This is picture of graphic. In picture fact line is blue and plan value is dashed white.
Now need filling this graphic area with two colors(red and green).
When fact values more than plan values, fill red,
if plan values more than fact values, fill green.
I have one option for doing this:
Using gradient for colors. But I can't determine stop point for gradient.

this is my code in angular .ts file:

```<code>interface Point {
    x: number;
    y: number;
    x1: number;
    y1: number;}

getLinePointsArea () {
    return this.plan.values.map((val, i) => {
        return {
            x: i * this.lengthX,
            y: val,
            x1: i * this.lengthX,
            y1: this.fact.values[i]
        };
    })
}

getArea(){
    let points = this.getLinePointsArea();
    let area = d3.svg.area<Point>()
    .x(d => { return d.x })
    .y(d => { return d.y })
    .x1(d => { return d.x1 })
    .y1(d => { return d.y1 })
    .interpolate('cardinal');
    return area(points);
}

getPolygonPathArea () : string {
    let path = this.getArea();
    return path;
}
</code>```

And my code .html

```<code><svg xmlns="http://www.w3.org/2000/svg" id="lineChart" width="100%" height="100%">
<defs>
    <linearGradient id="planBg">
         <!-- <stop *ngFor="let s of stopData" [attr.offset]="s.offset" [ngClass]="s.style" /> -->
        <stop offset="100%" style="stop-color:#321F2A;stop-opacity:1" />
        <stop offset="100%" style="stop-color: transparent;stop-opacity:1" />
    </linearGradient>
</defs>
<g id="main" [attr.transform]="'translate('+padding.join(' ')+')'">
    <g id="main" [attr.transform]="'translate(120, 120)'">
        <g id="plan-gradient">
            <path [attr.d]="getPolygonPathArea()" fill="url(#planBg)"></path>
        </g>
    </g>
</g>
</code>```

What solutions do you have? Or how find stop position for gradient?
Sorry for my english. Thank you.

答:
I would recommend to just have one svg element on your html template,

make functions like "draw(...)", "update(...)" and so on in your .ts file,

and implement your d3 logic right in there like normal javascript,

otherwise you will have too less benefit of d3 usage and too much complexity in my opinion.

Body:
I made graphic in svg and d3.js on angular2. This is picture of graphic. In picture fact line is blue and plan value is dashed white.
Now need filling this graphic area with two colors(red and green).
When fact values more than plan values, fill red,
if plan values more than fact values, fill green.
I have one option for doing this:
Using gradient for colors. But I can't determine stop point for gradient.

this is my code in angular .ts file:

interface Point {
    x: number;
    y: number;
    x1: number;
    y1: number;}

getLinePointsArea () {
    return this.plan.values.map((val, i) => {
        return {
            x: i * this.lengthX,
            y: val,
            x1: i * this.lengthX,
            y1: this.fact.values[i]
        };
    })
}

getArea(){
    let points = this.getLinePointsArea();
    let area = d3.svg.area<Point>()
    .x(d => { return d.x })
    .y(d => { return d.y })
    .x1(d => { return d.x1 })
    .y1(d => { return d.y1 })
    .interpolate('cardinal');
    return area(points);
}

getPolygonPathArea () : string {
    let path = this.getArea();
    return path;
}

And my code .html

<svg xmlns="http://www.w3.org/2000/svg" id="lineChart" width="100%" height="100%">
<defs>
    <linearGradient id="planBg">

        <stop offset="100%" style="stop-color:#321F2A;stop-opacity:1" />
        <stop offset="100%" style="stop-color: transparent;stop-opacity:1" />
    </linearGradient>
</defs>
<g id="main" [attr.transform]="'translate('+padding.join(' ')+')'">
    <g id="main" [attr.transform]="'translate(120, 120)'">
        <g id="plan-gradient">
            <path [attr.d]="getPolygonPathArea()" fill="url(#planBg)"></path>
        </g>
    </g>
</g>

What solutions do you have? Or how find stop position for gradient?
Sorry for my english. Thank you.


问:
Resharper completion without overwriting existing code
In Resharper when I go back to edit some existing code.. eg. wanting to insert a String.Format into this code:

```<code><td>
    <%= Html.Encode(item.Address) %>
</td>
</code>```

I move the cursor to before 'item' and type in 'String.F', getting Resharper's intellisense completion list that includes the 'Format' method.

However if I press TAB then it replaces 'item' with '.Format()'

Is there a way to use completing without replacing the existing text?

答:
There is an actual setting now to disable this (annoying) behavior.

Go to the Options dialog (Menu -> Resharper -> Options).
In this Options dialog go to Environment -> IntelliSense -> Completion Characters.

Here you can set the Tab behavior to Insert instead of Replace.

Screenshot of Options

Resharper documentation about Completing Characters

This is an addition to the answer in 2010, for everyone that reaches this post via populair search engines ;)

Body:
In Resharper when I go back to edit some existing code.. eg. wanting to insert a String.Format into this code:

    <%= Html.Encode(item.Address) %>

I move the cursor to before 'item' and type in 'String.F', getting Resharper's intellisense completion list that includes the 'Format' method.

However if I press TAB then it replaces 'item' with '.Format()'

Is there a way to use completing without replacing the existing text?


问:
Describe api for google people contact/gmail contact using client library
I want details about fields of gmail contact. Using that, i want to create a form a like what is being shown in gmail contact creation page . I could get describe for salesforce contact. i need same for google contact. i give a sample format for lastName

```<code>       {
              "label": "Last Name",
              "name": "LastName",
              "type": "string",
              "createable": true,
              "updateable": true,
              "custom": false,
              "validations": {
                "required": true,
                "maxlength": 80
              },
              "scale": 0,
              "precision": 0,
              "fields": []
       }
</code>```

is there any possible to get this?

答:
The discovery service api describes all of the google apis you can probably get the information from that programmaticlly or you could just check the documentation

You can also check the documentation directly.

Link to People v1 discovery doc

Body:
I want details about fields of gmail contact. Using that, i want to create a form a like what is being shown in gmail contact creation page . I could get describe for salesforce contact. i need same for google contact. i give a sample format for lastName

       {
              "label": "Last Name",
              "name": "LastName",
              "type": "string",
              "createable": true,
              "updateable": true,
              "custom": false,
              "validations": {
                "required": true,
                "maxlength": 80
              },
              "scale": 0,
              "precision": 0,
              "fields": []
       }

is there any possible to get this?


问:
R - doParallel does not work with Student and Fisher tests
So I am using the R package doParallel to parallelized some steps of my script when I have to handle large list of elements to compute it faster.
Since this time all of the functions I used so far were wroking perfectly well with foreach() : I just had to specify my number of cores with registerDoParallel() and that was all!

I recently tried to use different statistics tests in R using var.test() and t.test() and I don't understand why but I realized that used in foreach() it wasn't working...
So to be more clear what I am basically doing is iterating over rows of 2 matrices of the same dimensions : each row , in each matrix, contains 5 numeric values and I do for example:

```<code>var.test(matrixA[1,],matrixB[1,])$p.value
</code>```

to extract, for row number 1, the corresponding p.value from the Fisher test made on 10 numeric values (2 groups of 5 values in each matrix's row number 1).
Problem is my matrices have millions of rows so I have to iterate over the number of rows, and I do this with the foreach() function:

```<code>p.values.res<-foreach(i=seq(dim(matrixA)[1])) %dopar%
  var.test(matrixA[i,],matrixB[i,])$p.value
</code>```

(Here I set registerDoParallel(cores = 6) prior to the foreach()).
I tried different tests : fisher test and student test (t.test()) and unfortunately none of them were working on my 6 cores, only one.

I also tried with "cl": registerDoParallel(cl = 4)
It doesn't work either.

I tried to restart R, to quit and reopen session, to restart computer: doesn't work.

Does anybody knows why it does not work, and how to fix that ?

My configuration: Linux Mint 18.2 Cinnamon 64-bit (3.4.6); Intel Core I7-6700 CPU; R version 3.4.3 (2017-11-30); RStudio Version 1.1.383 2009-2017.

here are 2 short examples of matrices

MatrixA:

```<code>0.7111111  0.7719298  0.7027027   0.6875000  0.6857143
0.8292683  0.6904762  0.8222222   0.8333333  0.6250000
0.8846154  0.5714286  0.8928571   0.8846154  0.9259259
0.9000000  0.5000000  0.9500000   0.8666667  0.8260870
0.8235294  0.3684211  0.9411765   0.8333333  0.8000000
0.5714286  0.2142857  0.6666667   0.5000000  0.5555556
</code>```

MatrixB:

```<code>0.5227273  0.7142857  0.7808219   0.6346154  0.7362637
0.9166667  0.7173913  0.8611111   0.7391304  0.7538462
0.8666667  0.6052632  0.8260870   0.7333333  0.9024390
0.9285714  0.5806452  0.8750000   0.6956522  0.8787879
0.8333333  0.5517241  0.8333333   0.6818182  0.8750000
0.7500000  0.2941176  0.6666667   0.4444444  0.7500000
</code>```

Thank you all in advance for your help.
Regards,

答:
Unfortunately I didn't find any solution to my problem with doParallel but I realized that I did not have to use it in the first place.

From the R package "genefilter" I find an alternative solution using the function rowttests() that is really fast for doing t-tests on large matrix.
The only comment I have against the function is that it assumes that variances are equal when calculating p-values (and you can't change that). Fortunately I am in this case.

So I just had to cbind() my 2 matrix, specify belonging groups as factors for columns.
And that's all !

```<code>bind_matrix<-cbind(matrixA,matrixB)
fact<-factor(c("A","A","A","A","A","B","B","B","B","B"))
p.vals<-rowttests(bind_matrix,fact)$p.values
</code>```

It takes few seconds and I tried it for a 10 millions rows matrix.

The solution is the same Fisher test, there is a function rowFtests().

So now I might ask for a speed efficient solution for Wilcoxon tests. If someone knows a function that works similarily to theses ones, comment it please.

Body:
So I am using the R package doParallel to parallelized some steps of my script when I have to handle large list of elements to compute it faster.
Since this time all of the functions I used so far were wroking perfectly well with foreach() : I just had to specify my number of cores with registerDoParallel() and that was all!

I recently tried to use different statistics tests in R using var.test() and t.test() and I don't understand why but I realized that used in foreach() it wasn't working...
So to be more clear what I am basically doing is iterating over rows of 2 matrices of the same dimensions : each row , in each matrix, contains 5 numeric values and I do for example:

var.test(matrixA[1,],matrixB[1,])$p.value

to extract, for row number 1, the corresponding p.value from the Fisher test made on 10 numeric values (2 groups of 5 values in each matrix's row number 1).
Problem is my matrices have millions of rows so I have to iterate over the number of rows, and I do this with the foreach() function:

p.values.res<-foreach(i=seq(dim(matrixA)[1])) %dopar%
  var.test(matrixA[i,],matrixB[i,])$p.value

(Here I set registerDoParallel(cores = 6) prior to the foreach()).
I tried different tests : fisher test and student test (t.test()) and unfortunately none of them were working on my 6 cores, only one.

I also tried with "cl": registerDoParallel(cl = 4)
It doesn't work either.

I tried to restart R, to quit and reopen session, to restart computer: doesn't work.

Does anybody knows why it does not work, and how to fix that ?

My configuration: Linux Mint 18.2 Cinnamon 64-bit (3.4.6); Intel Core I7-6700 CPU; R version 3.4.3 (2017-11-30); RStudio Version 1.1.383 2009-2017.

here are 2 short examples of matrices

MatrixA:

0.7111111  0.7719298  0.7027027   0.6875000  0.6857143
0.8292683  0.6904762  0.8222222   0.8333333  0.6250000
0.8846154  0.5714286  0.8928571   0.8846154  0.9259259
0.9000000  0.5000000  0.9500000   0.8666667  0.8260870
0.8235294  0.3684211  0.9411765   0.8333333  0.8000000
0.5714286  0.2142857  0.6666667   0.5000000  0.5555556

MatrixB:

0.5227273  0.7142857  0.7808219   0.6346154  0.7362637
0.9166667  0.7173913  0.8611111   0.7391304  0.7538462
0.8666667  0.6052632  0.8260870   0.7333333  0.9024390
0.9285714  0.5806452  0.8750000   0.6956522  0.8787879
0.8333333  0.5517241  0.8333333   0.6818182  0.8750000
0.7500000  0.2941176  0.6666667   0.4444444  0.7500000

Thank you all in advance for your help.
Regards,

Body:
Unfortunately I didn't find any solution to my problem with doParallel but I realized that I did not have to use it in the first place.

From the R package "genefilter" I find an alternative solution using the function rowttests() that is really fast for doing t-tests on large matrix.
The only comment I have against the function is that it assumes that variances are equal when calculating p-values (and you can't change that). Fortunately I am in this case.

So I just had to cbind() my 2 matrix, specify belonging groups as factors for columns.
And that's all !

bind_matrix<-cbind(matrixA,matrixB)
fact<-factor(c("A","A","A","A","A","B","B","B","B","B"))
p.vals<-rowttests(bind_matrix,fact)$p.values

It takes few seconds and I tried it for a 10 millions rows matrix.

The solution is the same Fisher test, there is a function rowFtests().

So now I might ask for a speed efficient solution for Wilcoxon tests. If someone knows a function that works similarily to theses ones, comment it please.


问:
How to trigger function when control is loaded
I work on my angularjs project.

Here is my cotroller:

```<code>(function () {
    "use strict";

    angular.module("dashboard").controller('dashboardController', ["$scope", "dashboardServices", dashboardController]);

    function dashboardController($scope, dashboardServices) {

        $scope.month = new Date().getMonth()+1;
        $scope.year = new Date().getFullYear();

        $scope.getRecords = function () {
            dashboardServices.getRecords($scope.year, $scope.month).then(function (response) {
                var result = dashboardServices.convert2json(response.data);
                $scope.report = result.ArrayOfDepartmentReport;
            });
        }
    }
})();
</code>```

How to make function  $scope.getRecords to be triggered when controll is loaded.

答:
Execution of your controller code happens only when the controller is loaded.

Put $scope.getRecords() at the bottom of the controller.

Body:
I work on my angularjs project.

Here is my cotroller:

(function () {
    "use strict";

    angular.module("dashboard").controller('dashboardController', ["$scope", "dashboardServices", dashboardController]);

    function dashboardController($scope, dashboardServices) {

        $scope.month = new Date().getMonth()+1;
        $scope.year = new Date().getFullYear();

        $scope.getRecords = function () {
            dashboardServices.getRecords($scope.year, $scope.month).then(function (response) {
                var result = dashboardServices.convert2json(response.data);
                $scope.report = result.ArrayOfDepartmentReport;
            });
        }
    }
})();

How to make function  $scope.getRecords to be triggered when controll is loaded.


问:
Model filters based on the currently authenticated user
I am working on an app, in which each user is assigned a particular region. For example, user 1 belongs to a region 'Phoenix', user 2 to 'Scottsdale', and user 3 to 'Tempe'. The region of each user is defined in the region_id column.

The app has 3 separate guards for 3 different user models (it's a marketplace with regional managers, providers, and customers). Virtually every model in the app has a region_id column, identifying to which region the resource belongs to.

I would like to simplify how the resources are queried. Currently, I am filtering each model/resource directly in the controller, e.g.:

```<code>$customers = Customer::where('region_id', Auth::user()->region_id);
</code>```

I would like to set such filters at the global level, to make sure that each authenticated user can see records only from their own region. It is important particularly for displaying the list of records in the current region, not checking whether the user can access/edit a particular single record.

I have looked into Query Scopes, but I am not able to access the currently authenticated user withing them. The only case when I can access the current user is when the global scope is defined in a closure, but this defeats the purpose of not having to define the same logic in each model (i.e. I cannot extract the filtering logic to a query scope class).

What would be a good alternative approach to consider? How can I set the global model filters based on a property of a currently authenticated user?

答:
I posted a similar question as a possible bug (was not sure whether this behavior was something expected) on Laravel Framework issue tracker on GitHub and found the answer there.

Turns out, you cannot access the authenticated user in the global query scope constructor, but it is accessible in the apply() method.

So instead of:

```<code>public function __construct() {
    $this->region_id = Auth::user()->region_id;
}

public function apply(Builder $builder, Model $model)
{
    $builder->where('region_id', $this->region_id);
}
</code>```

I had to do:

```<code>public function apply(Builder $builder, Model $model)
{
    $region_id = Auth::user()->region_id;

    $builder->where('region_id', $region_id);
}
</code>```

Link to the issue on GitHub here.

Body:
I am working on an app, in which each user is assigned a particular region. For example, user 1 belongs to a region 'Phoenix', user 2 to 'Scottsdale', and user 3 to 'Tempe'. The region of each user is defined in the region_id column.

The app has 3 separate guards for 3 different user models (it's a marketplace with regional managers, providers, and customers). Virtually every model in the app has a region_id column, identifying to which region the resource belongs to.

I would like to simplify how the resources are queried. Currently, I am filtering each model/resource directly in the controller, e.g.:

$customers = Customer::where('region_id', Auth::user()->region_id);

I would like to set such filters at the global level, to make sure that each authenticated user can see records only from their own region. It is important particularly for displaying the list of records in the current region, not checking whether the user can access/edit a particular single record.

I have looked into Query Scopes, but I am not able to access the currently authenticated user withing them. The only case when I can access the current user is when the global scope is defined in a closure, but this defeats the purpose of not having to define the same logic in each model (i.e. I cannot extract the filtering logic to a query scope class).

What would be a good alternative approach to consider? How can I set the global model filters based on a property of a currently authenticated user?

Body:
I posted a similar question as a possible bug (was not sure whether this behavior was something expected) on Laravel Framework issue tracker on GitHub and found the answer there.

Turns out, you cannot access the authenticated user in the global query scope constructor, but it is accessible in the apply() method.

So instead of:

public function __construct() {
    $this->region_id = Auth::user()->region_id;
}

public function apply(Builder $builder, Model $model)
{
    $builder->where('region_id', $this->region_id);
}

I had to do:

public function apply(Builder $builder, Model $model)
{
    $region_id = Auth::user()->region_id;

    $builder->where('region_id', $region_id);
}

Link to the issue on GitHub here.


问:
Xcode help - Upgrade current target for iPad
I upgraded current target for iPad (to try and make a universal app) without making any changes and it doesn't seem to have worked. The only .xib file that was added to the iPad resources folder was MainWindow-iPad.xib, and no others.

Anyway disregarding that I tried to switch the active executable to ipad simulator. It runs but the layout has gone completely crazy. I can't fix it because there is no .xib in the iPad resources folder. :/

答: You have to convert your other NIB files manually. Interface Builder has a menu command to get you started. Just open all your NIBs one after the other, convert them to iPad dimensions and save them under a new name. Then, in your code, make sure that you load the correct NIB file depending on the platform your app runs on. </p>


问:
JavaFX Spinner change is slow with click and hold of mouse button
The speed of Spinner update is slow when I click and hold the up/down arrow buttons. Is there a way to increase the change speed?

When I click, click, click with the mouse, the spinner values change as fast as I click. It also changes fast if I use the up/down arrows on the keyboard for each key press or if I hold down the up/down arrow keys. I want the values to change that fast when I click and hold on the arrow buttons.

Anyone know a way to do that?

答:
An alternative to changing the update speed might in some cases be adjusting the amount by which the value increments/decrements per update.

```<code>SpinnerValueFactory.IntegerSpinnerValueFactory intFactory =
(SpinnerValueFactory.IntegerSpinnerValueFactory) spinner.getValueFactory();
intFactory.setAmountToStepBy(100);
</code>```

Reference: http://news.kynosarges.org/2016/10/28/javafx-spinner-for-numbers/

Body:
An alternative to changing the update speed might in some cases be adjusting the amount by which the value increments/decrements per update.

SpinnerValueFactory.IntegerSpinnerValueFactory intFactory =
(SpinnerValueFactory.IntegerSpinnerValueFactory) spinner.getValueFactory();
intFactory.setAmountToStepBy(100);

Reference: http://news.kynosarges.org/2016/10/28/javafx-spinner-for-numbers/


问:
html tag input of type=”number” and culture based decimal separator
What I need is in English browser when I open website that has another culture and UI (i.e. Sweden) to see the proper decimal separator.

How to archive it?

```<code>  <input type="number" step="0.1"  pattern="[0-9]+([\,][0-9]+)?" min="0" max="5" />
</code>```

If even I apply any number like "0,1" with the next click of spinner Browser reset it to "0.2" which has a dot instead of comma.

So how to keep proper decimal separator?

Any clue how to fix it with jQuery?

答:
Currently answers provided with this thread lead to the solution of changing type="number" to type="text" which is step back from user point of view.

I handled this problem in different way.

Handling data from backend - form preparation.

Forms usually provide default values or values to edit for some field. That's why it is important how you provide values to input in form. Some frameworks can localize value for you before binding them to the form that's why values coming from your server (database and programming language) can be either comma separated or dot separated. If you provide 0.01 (most cases) as input value you will get no error in any browser on client side but if you provide value of 0,01 (localized value) the value will not be visible in the browser but will be provided in input as an attribute and you will get a console error: it is not proper number value. So the first thing to do is replacing "," with "." when rendering the form on server side so that on client side there is always dot separated value.

If you leave it at this point your form will be vulnerable to locale settings in the browser. If you print such form in Firefox with locale en-US you will see an input with dot separated value but if you print this form with Chrome with locale
fr-FR you will see no value which is comma separated. There is a simple solution if you want to enforce specific locale. With this attribute:

```<code><html lang="en-US" >
</code>```

you will get dots in your input type number and this one will give you comma separated value:

```<code><html lang="pl-PL" >
</code>```

The lang attribute can also be set at input itself.

Frontend handling.

In Firefox with form set to specific locale you will get a validation error if you will try to put dot or comma as a separator - according to your lang setting. So remember that you cannot set novalidate attribute on form otherwise the value sent on submit will be empty.
Chrome will automatically convert dot to comma or comma to dot for you.

Those are the basic rules for me.
Further if you use some JS methods such as parseFloat() you will get dots in the value so you will have to replace dots with comma if you are in comma-like locale.

Body:
What I need is in English browser when I open website that has another culture and UI (i.e. Sweden) to see the proper decimal separator.

How to archive it?

  <input type="number" step="0.1"  pattern="[0-9]+([\,][0-9]+)?" min="0" max="5" />

If even I apply any number like "0,1" with the next click of spinner Browser reset it to "0.2" which has a dot instead of comma.

So how to keep proper decimal separator?

Any clue how to fix it with jQuery?

Body:
Currently answers provided with this thread lead to the solution of changing type="number" to type="text" which is step back from user point of view.

I handled this problem in different way.

Handling data from backend - form preparation.

Forms usually provide default values or values to edit for some field. That's why it is important how you provide values to input in form. Some frameworks can localize value for you before binding them to the form that's why values coming from your server (database and programming language) can be either comma separated or dot separated. If you provide 0.01 (most cases) as input value you will get no error in any browser on client side but if you provide value of 0,01 (localized value) the value will not be visible in the browser but will be provided in input as an attribute and you will get a console error: it is not proper number value. So the first thing to do is replacing "," with "." when rendering the form on server side so that on client side there is always dot separated value.

If you leave it at this point your form will be vulnerable to locale settings in the browser. If you print such form in Firefox with locale en-US you will see an input with dot separated value but if you print this form with Chrome with locale
fr-FR you will see no value which is comma separated. There is a simple solution if you want to enforce specific locale. With this attribute:

<html lang="en-US" >

you will get dots in your input type number and this one will give you comma separated value:

<html lang="pl-PL" >

The lang attribute can also be set at input itself.

Frontend handling.

In Firefox with form set to specific locale you will get a validation error if you will try to put dot or comma as a separator - according to your lang setting. So remember that you cannot set novalidate attribute on form otherwise the value sent on submit will be empty.
Chrome will automatically convert dot to comma or comma to dot for you.

Those are the basic rules for me.
Further if you use some JS methods such as parseFloat() you will get dots in the value so you will have to replace dots with comma if you are in comma-like locale.


问:
Running Tensorflow on multiple gpu's
I have checked the website but as always it was not clear for me. Can anyone describes all of the steps (from very beginning) to run any tensorflow program on GPU's? </p>

答:
From Tensorflow official site:
https://www.tensorflow.org/tutorials/using_gpu</p>

```<code># Creates a graph.
c = []
for d in ['/device:GPU:2', '/device:GPU:3']:
  with tf.device(d):
    a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3])
    b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2])
    c.append(tf.matmul(a, b))
with tf.device('/cpu:0'):
  sum = tf.add_n(c)
# Creates a session with log_device_placement set to True.
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
# Runs the op.
print(sess.run(sum))
</code>```

Title: Running Tensorflow on multiple gpu's

Body:
From Tensorflow official site:
https://www.tensorflow.org/tutorials/using_gpu

# Creates a graph.
c = []
for d in ['/device:GPU:2', '/device:GPU:3']:
  with tf.device(d):
    a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3])
    b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2])
    c.append(tf.matmul(a, b))
with tf.device('/cpu:0'):
  sum = tf.add_n(c)
# Creates a session with log_device_placement set to True.
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
# Runs the op.
print(sess.run(sum))


问:
How to convert object to array to get the data?
My array coming like this

```<code>Array ( [0] => stdClass Object ( [ID] => 578 [post_author] => 1 [post_date] => 2011-01-18 07:23:17 [post_date_gmt] => 2011-01-18 07:23:17 [post_content] => Home WordPress is web software you can use to create a beautiful website or blog. We like to say that WordPress is both free and priceless at the same time. The core software is built by hundreds of community volunteers, and when you’re ready for more there are thousands of plugins and themes available to transform your site into almost anything you can imagine. Over 25 million people have chosen WordPress to power the place on the web they call “home” — we’d love you to join the family [post_title] => second post [post_excerpt] => [post_status] => publish [comment_status] => open
</code>```

when i write like this

```<code>$myposts = get_posts( $args );
$arrDt = (array) $myposts;
print_r($arrDt);
</code>```

but my problem is how can i get the values inside that object array.

please help.
Thnx
print_r($arrDt);

答:
It is just normal object access:

```<code>$obj = $arrDt[0];
echo $obj->ID;
echo $obj->post_author;
// etc.
</code>```

But it depends on what you want to do. I suggest to have a look at the get_posts examples. They use setup_postdata to load the post content in the current context. If you want to display the post, this is probably the cleaner solution.

Body:
My array coming like this

Array ( [0] => stdClass Object ( [ID] => 578 [post_author] => 1 [post_date] => 2011-01-18 07:23:17 [post_date_gmt] => 2011-01-18 07:23:17 [post_content] => Home WordPress is web software you can use to create a beautiful website or blog. We like to say that WordPress is both free and priceless at the same time. The core software is built by hundreds of community volunteers, and when you’re ready for more there are thousands of plugins and themes available to transform your site into almost anything you can imagine. Over 25 million people have chosen WordPress to power the place on the web they call “home” — we’d love you to join the family [post_title] => second post [post_excerpt] => [post_status] => publish [comment_status] => open

when i write like this

$myposts = get_posts( $args );
$arrDt = (array) $myposts;
print_r($arrDt);

but my problem is how can i get the values inside that object array.

please help.
Thnx
print_r($arrDt);

Body:
It is just normal object access:

$obj = $arrDt[0];
echo $obj->ID;
echo $obj->post_author;
// etc.

But it depends on what you want to do. I suggest to have a look at the get_posts examples. They use setup_postdata to load the post content in the current context. If you want to display the post, this is probably the cleaner solution.