问:
Makefile doesn't understand g++ but terminal does

Makefile

```<code># Assignments
#########################################################
CC := g++
SRC := src
BUILD := build
INCLUDE := include
TARGET := bin/driver
LIB := lib
TESTS := tests

CFLAGS := -g -Wall -Wextra

PATH := -I $(INCLUDE)

#########################################################

driver: Logbook.o Entry.o main.o
    g++ Logbook.o Entry.o main.o -o driver

main.o: main.cpp
    g++ -c main.cpp

Logbook.o:
    g++ -c $(PATH) $(LIB)/Logbook.cpp

Entry.o:
    g++ -c $(PATH) $(LIB)/Entry.cpp

test:
    g++ -c $(PATH) $(LIB)/Logbook.cpp

clean:
    rm -f *.o *.exe driver
</code>```

STDOUT

```<code>mint@mint-VirtualBox ~/Desktop/Logbook $ ls
googletest  include  lib  main.cpp  Makefile  README.md  src
mint@mint-VirtualBox ~/Desktop/Logbook $ make
g++ -c -I include lib/Logbook.cpp
make: g++: Command not found
Makefile:47: recipe for target 'Logbook.o' failed
make: *** [Logbook.o] Error 127
mint@mint-VirtualBox ~/Desktop/Logbook $ ls
googletest  include  lib  main.cpp  Makefile  README.md  src
mint@mint-VirtualBox ~/Desktop/Logbook $ g++ -c -I include lib/Logbook.cpp
mint@mint-VirtualBox ~/Desktop/Logbook $ ls
googletest  include  lib  Logbook.o  main.cpp  Makefile  README.md  src
mint@mint-VirtualBox ~/Desktop/Logbook $
</code>```

The result expected is that g++ works while being called from inside the makefile but clearly doesn't

What exactly is going on here? there are tabs where there should be and running the compilation command while in the terminal works but the Makefile just doesn't want to agree that the g++ command exists.

答:
Don't call the variable PATH, it overrides the default environment variable that tells the Makefile where to look for binaries. Just rename it to CCFLAGS or so.

```<code>CCFLAGS := -I $(INCLUDE)

Logbook.o:
    g++ -c $(CCFLAGS) $(LIB)/Logbook.cpp
</code>```

More details on PATH e.g. here: https://en.wikipedia.org/wiki/PATH_(variable)

Body:
Makefile

# Assignments
#########################################################
CC := g++
SRC := src
BUILD := build
INCLUDE := include
TARGET := bin/driver
LIB := lib
TESTS := tests

CFLAGS := -g -Wall -Wextra

PATH := -I $(INCLUDE)

#########################################################

driver: Logbook.o Entry.o main.o
    g++ Logbook.o Entry.o main.o -o driver

main.o: main.cpp
    g++ -c main.cpp

Logbook.o:
    g++ -c $(PATH) $(LIB)/Logbook.cpp

Entry.o:
    g++ -c $(PATH) $(LIB)/Entry.cpp

test:
    g++ -c $(PATH) $(LIB)/Logbook.cpp

clean:
    rm -f *.o *.exe driver

STDOUT

mint@mint-VirtualBox ~/Desktop/Logbook $ ls
googletest  include  lib  main.cpp  Makefile  README.md  src
mint@mint-VirtualBox ~/Desktop/Logbook $ make
g++ -c -I include lib/Logbook.cpp
make: g++: Command not found
Makefile:47: recipe for target 'Logbook.o' failed
make: *** [Logbook.o] Error 127
mint@mint-VirtualBox ~/Desktop/Logbook $ ls
googletest  include  lib  main.cpp  Makefile  README.md  src
mint@mint-VirtualBox ~/Desktop/Logbook $ g++ -c -I include lib/Logbook.cpp
mint@mint-VirtualBox ~/Desktop/Logbook $ ls
googletest  include  lib  Logbook.o  main.cpp  Makefile  README.md  src
mint@mint-VirtualBox ~/Desktop/Logbook $

The result expected is that g++ works while being called from inside the makefile but clearly doesn't

What exactly is going on here? there are tabs where there should be and running the compilation command while in the terminal works but the Makefile just doesn't want to agree that the g++ command exists.

Body:
Don't call the variable PATH, it overrides the default environment variable that tells the Makefile where to look for binaries. Just rename it to CCFLAGS or so.

CCFLAGS := -I $(INCLUDE)

Logbook.o:
    g++ -c $(CCFLAGS) $(LIB)/Logbook.cpp

More details on PATH e.g. here: https://en.wikipedia.org/wiki/PATH_(variable)


来源: stackexchange

问:
Add data to dynamic array name
I would like to add data to an array using JavaScript/Vue.js.

Well, this is no problem:

```<code>methods: {
    add: function add(e) {
        e.preventDefault();
        if (!this.newName) return;

        this.config.names.firstnames.push(this.newName);
        this.newName = '';
    },
}
</code>```

But: I would like to make this.config.names.firstnames dynamic.

If this.type == "firstnames" the data should be added to  this.config.names.firstnames. If this.type == "lastnames" the data should be added to this.config.names.lastnames. So the element to push to should be the value of this.type.

How can I solve that the most elegant way?

答:
Since your type is exactly correlated to the key on the names object you can use the bracket notation:

this.config.names[this.type].push(this.newName)

ContentLicense: CC BY-SA 3.0

Title: Add data to dynamic array name

Body:
I would like to add data to an array using JavaScript/Vue.js.

Well, this is no problem:

methods: {
    add: function add(e) {
        e.preventDefault();
        if (!this.newName) return;

        this.config.names.firstnames.push(this.newName);
        this.newName = '';
    },
}

But: I would like to make this.config.names.firstnames dynamic.

If this.type == "firstnames" the data should be added to  this.config.names.firstnames. If this.type == "lastnames" the data should be added to this.config.names.lastnames. So the element to push to should be the value of this.type.

How can I solve that the most elegant way?


问:
Creating custom grid number (24) for Bootstrap 4
I have a project and I want to integrate some bootstrap into my html files for ui development. I know that the standard grid size is 12 and I wanted to change the number of grid spaces from 12 to 24. I know there is a way to do it from the documentation but I dont know how to where to integrate it.

This is the bootstrap documentation

```<code>$grid-columns:               12 !default;
$grid-gutter-width-base:     30px !default;
$grid-gutter-widths: (
  xs: $grid-gutter-width-base,
  sm: $grid-gutter-width-base,
  md: $grid-gutter-width-base,
  lg: $grid-gutter-width-base,
  xl: $grid-gutter-width-base
) !default;
</code>```

Where do I put it in my code.

```<code>CSS file
HTML file
Js file
....
</code>```

答:
$grid-columns is a SASS variable. You can use SASS to change the grid to 24 columns like this...

```<code>$grid-columns:           24;
$grid-gutter-width-base: 15px;

@import "bootstrap";
</code>```

Demo https://codeply.com/go/C0Uh7PokEl

The variable names have change slightly as of Bootstrap 4.0.0:

```<code>$grid-columns:      24;
$grid-gutter-width: 12px;

@import "bootstrap";
</code>```

Also see: How to get bootstrap 4 24 grid

Bootstrap 4 Customizer

Body:
I have a project and I want to integrate some bootstrap into my html files for ui development. I know that the standard grid size is 12 and I wanted to change the number of grid spaces from 12 to 24. I know there is a way to do it from the documentation but I dont know how to where to integrate it.

This is the bootstrap documentation

$grid-columns:               12 !default;
$grid-gutter-width-base:     30px !default;
$grid-gutter-widths: (
  xs: $grid-gutter-width-base,
  sm: $grid-gutter-width-base,
  md: $grid-gutter-width-base,
  lg: $grid-gutter-width-base,
  xl: $grid-gutter-width-base
) !default;

Where do I put it in my code.

CSS file
HTML file
Js file
....

Body:
$grid-columns is a SASS variable. You can use SASS to change the grid to 24 columns like this...

$grid-columns:           24;
$grid-gutter-width-base: 15px;

@import "bootstrap";

Demo https://codeply.com/go/C0Uh7PokEl

The variable names have change slightly as of Bootstrap 4.0.0:

$grid-columns:      24;
$grid-gutter-width: 12px;

@import "bootstrap";

Also see: How to get bootstrap 4 24 grid

Bootstrap 4 Customizer

ContentLicense: CC BY-SA 4.0


问:
How to check if the exact vector is a subset of another vector of a list
I skimmed similar posts and I have tried them but I still could not solve my problem.

I have a list of vector such as following

```<code>y2 <- c(0,0,NA,0,0,0,0)
y <- c(0,0,0,NA,NA,0)
x <- c(0,0,0,0)
li <-list(y2,y,x)
</code>```

I am trying to drop the vector from the list li, if an exact vector is a subset of another one.

For example, in my case I should have y2 and y as result and have x dropped from the list since x is an exact subset of y2.

I wrote the following script but it just gives the y2 as result, and ignores y:

```<code>UniquePath <- function(PATHS)
{
  for(j in length(PATHS):1)
  {
    for(i in 1:length(PATHS))
    {
      if((i!=j)&(isTRUE(all(is.element(PATHS[[j]],PATHS[[i]])))))
      {
        PATHS<-PATHS[-j]
        break
      }
      else
      {
        next
      }
    }
  }
  return(PATHS)
}
</code>```

答:
I think this might be what you are looking for.

```<code>uniquePath <- function(l){
  idxs <- 1:length(l)
  tmp <- lapply(l, table, useNA='always')
  l2 <- lapply(idxs, function(i){
    res <- l[[i]]
    for(j in idxs[-i]){
      if ( all(res %in% l[[j]]) & all(tmp[[i]] <= tmp[[j]])){
        res <- NULL; break
      }
    }
    res
  })
  Filter(Negate(is.null), l2)
}
</code>```

Some examples:

```<code>y2 <- c(0,0,NA,0,0,0,0); y <- c(0,0,0,NA,NA,0); x <- c(0,0,0,0)
li <-list(y2 = y2,y = y,x = x)
## This is your example, where x is subset of both y and y2
uniquePath(li)
# [[1]]
# [1]  0  0 NA  0  0  0  0
#
# [[2]]
# [1]  0  0  0 NA NA  0

x <- c(0,0,0,0); y <- c(0,NA,0,0,0); y2 <- c(NA,NA,0,0,0,0)
l <- list(x,y,y2)
## Here x is a subset of y and y is a subset of y2
uniquePath(l)
# [[1]]
# [1] NA NA  0  0  0  0
</code>```

Body:
I skimmed similar posts and I have tried them but I still could not solve my problem.

I have a list of vector such as following

y2 <- c(0,0,NA,0,0,0,0)
y <- c(0,0,0,NA,NA,0)
x <- c(0,0,0,0)
li <-list(y2,y,x)

I am trying to drop the vector from the list li, if an exact vector is a subset of another one.

For example, in my case I should have y2 and y as result and have x dropped from the list since x is an exact subset of y2.

I wrote the following script but it just gives the y2 as result, and ignores y:

UniquePath <- function(PATHS)
{
  for(j in length(PATHS):1)
  {
    for(i in 1:length(PATHS))
    {
      if((i!=j)&(isTRUE(all(is.element(PATHS[[j]],PATHS[[i]])))))
      {
        PATHS<-PATHS[-j]
        break
      }
      else
      {
        next
      }
    }
  }
  return(PATHS)
}

Body:
I think this might be what you are looking for.

uniquePath <- function(l){
  idxs <- 1:length(l)
  tmp <- lapply(l, table, useNA='always')
  l2 <- lapply(idxs, function(i){
    res <- l[[i]]
    for(j in idxs[-i]){
      if ( all(res %in% l[[j]]) & all(tmp[[i]] <= tmp[[j]])){
        res <- NULL; break
      }
    }
    res
  })
  Filter(Negate(is.null), l2)
}

Some examples:

y2 <- c(0,0,NA,0,0,0,0); y <- c(0,0,0,NA,NA,0); x <- c(0,0,0,0)
li <-list(y2 = y2,y = y,x = x)
## This is your example, where x is subset of both y and y2
uniquePath(li)
# [[1]]
# [1]  0  0 NA  0  0  0  0
#
# [[2]]
# [1]  0  0  0 NA NA  0

x <- c(0,0,0,0); y <- c(0,NA,0,0,0); y2 <- c(NA,NA,0,0,0,0)
l <- list(x,y,y2)
## Here x is a subset of y and y is a subset of y2
uniquePath(l)
# [[1]]
# [1] NA NA  0  0  0  0


问:
Create linked list relationship between nodes having same relation to other nodes in neo4j
As in this figure

is it possible to create a linked-list relationship between all (:B) nodes that share a relationship [:R] with the same (:A) node, for all (:A) nodes in the database. If order is important, then assume there is a property order in all (:B) nodes.

答:
I'm assuming that you have an order property in each :B node. I'm using this sample data:

```<code>CREATE (a1:A)-[:R]->(:B {order : 1}), (a1)-[:R]->(:B {order : 2}), (a1)-[:R]->(:B {order : 3})
CREATE (a2:A)-[:R]->(:B {order : 1}), (a2)-[:R]->(:B {order : 2}), (a2)-[:R]->(:B {order : 3})
</code>```

Then you can use this Cypher query:

```<code>// match pairs of :B when b2.order is equal to b1.order plus one
MATCH (a:A)-[:R]->(b1:B), (a)-[:R]->(b2:B)
WHERE b2.order = b1.order + 1
// Create the relation between :B nodes
CREATE (b1)-[:NETX]->(b2)
</code>```

The output will be:

Body:
I'm assuming that you have an order property in each :B node. I'm using this sample data:

CREATE (a1:A)-[:R]->(:B {order : 1}), (a1)-[:R]->(:B {order : 2}), (a1)-[:R]->(:B {order : 3})
CREATE (a2:A)-[:R]->(:B {order : 1}), (a2)-[:R]->(:B {order : 2}), (a2)-[:R]->(:B {order : 3})

Then you can use this Cypher query:

// match pairs of :B when b2.order is equal to b1.order plus one
MATCH (a:A)-[:R]->(b1:B), (a)-[:R]->(b2:B)
WHERE b2.order = b1.order + 1
// Create the relation between :B nodes
CREATE (b1)-[:NETX]->(b2)

The output will be:


问:
Eclipse Runnable JAR file export failed. No resources selected
i'm trying to export a Runnable Jar in order to run my project with .bat file, however when trying to export a Runnable jar it fails with massage:

"Jar creation failed. See details for additional information."
< < Details :
No resources selected. See details for additional information.
 Could not find main method from given launch configuration.

Using Windows Server 2012, newest eclipse, jdk and jre. cleaning didn't change anything, nor copying the project to a new one.

Downgrading to 1.8 didn't help as well, I looked at some suggestions for the last couple of hours, none helped.

Of-curse I have static void main(String[] args) in my Runner.java class, and if you click "Run" (with same Run Configuration) from Eclipse it works perfect.

Couldn't find a solution as of now.

6/12 - Update: Adding screenshots of the export process as howlger asked.

I've also tried new workspace according to Akshay Bahadur's suggestion, same result.

https://s3.amazonaws.com/stackover/Screenshot_141.png

https://s3.amazonaws.com/stackover/Screenshot_142.png

https://s3.amazonaws.com/stackover/Screenshot_143.png

6/12 - 2nd Update: Adding
Run Configuration:
https://s3.amazonaws.com/stackover/Screenshot_149.png

7/12 - 3nd Update: Adding
About Eclipse:

Eclipse IDE for Java Developers
Version: Oxygen.1a Release (4.7.1a)
Build id: 20171005-1200
OS: Windows Server 2012 R2, v.6.3, x86_64 / win32

https://s3.amazonaws.com/stackover/Screenshot_155.png

and the main() function is plain Java - no Maven or Gradle:

```<code>public static void main(String[] args) {
    boolean errorNotHappened = true;
    boolean errorWithMailNotHappened = true;
    boolean performDownload = true;
    boolean performEmailSent = true;
    boolean performDataManipulation = true;

    System.out.println("***~~~*** Starting job. If you want more details - turn on debug mode");

    //Downloader d = new Downloader();
    printMsg("Date to use with files: "+getDateToUse());
    printMsg("Write mail for date: "+getYasterdayNiceDate());

    if (performDownload)
    {
        Downloader d = new Downloader();
        d.connectAnd(); //connect to pair server
        errorNotHappened = d.downloadFiles();
        d.disconnectFromServer();
    }

    if (errorNotHappened && performDataManipulation)
    {
        Manipulator m = new Manipulator();
        errorNotHappened = m.work();
        m.terminateManipulator();
    }

    if (performEmailSent)
    {
        GoogleMailer gmail = new GoogleMailer();
        gmail.startMailingService();
        if (errorNotHappened)
            errorWithMailNotHappened = gmail.sendMailWithAttach();
        else
            gmail.sendFailedMail();
        if(!errorWithMailNotHappened)
        {
            gmail.sendFailedMail();
        }
    }
    System.out.println("***~~~*** Job ended.");

}
</code>```

答:
I fixed the problem, I exported the project as an archive file. Then I opened up a new workspace and imported the the archived project. After that I tried to export the project as a runnable jar, after two tries the jar runs as is it should.

I still don't know what the exact cause was but I hope someone how has run into the same problem finds this helpful.

See

Eclipse cannot create runnable jar - No resources selected

Body:
i'm trying to export a Runnable Jar in order to run my project with .bat file, however when trying to export a Runnable jar it fails with massage:

"Jar creation failed. See details for additional information."
< < Details :
No resources selected. See details for additional information.
 Could not find main method from given launch configuration.

Using Windows Server 2012, newest eclipse, jdk and jre. cleaning didn't change anything, nor copying the project to a new one.

Downgrading to 1.8 didn't help as well, I looked at some suggestions for the last couple of hours, none helped.

Of-curse I have static void main(String[] args) in my Runner.java class, and if you click "Run" (with same Run Configuration) from Eclipse it works perfect.

Couldn't find a solution as of now.

6/12 - Update: Adding screenshots of the export process as howlger asked.

I've also tried new workspace according to Akshay Bahadur's suggestion, same result.

https://s3.amazonaws.com/stackover/Screenshot_141.png

https://s3.amazonaws.com/stackover/Screenshot_142.png

https://s3.amazonaws.com/stackover/Screenshot_143.png

6/12 - 2nd Update: Adding
Run Configuration:
https://s3.amazonaws.com/stackover/Screenshot_149.png

7/12 - 3nd Update: Adding
About Eclipse:

Eclipse IDE for Java Developers
Version: Oxygen.1a Release (4.7.1a)
Build id: 20171005-1200
OS: Windows Server 2012 R2, v.6.3, x86_64 / win32

https://s3.amazonaws.com/stackover/Screenshot_155.png

and the main() function is plain Java - no Maven or Gradle:

public static void main(String[] args) {
    boolean errorNotHappened = true;
    boolean errorWithMailNotHappened = true;
    boolean performDownload = true;
    boolean performEmailSent = true;
    boolean performDataManipulation = true;

    System.out.println("***~~~*** Starting job. If you want more details - turn on debug mode");

    //Downloader d = new Downloader();
    printMsg("Date to use with files: "+getDateToUse());
    printMsg("Write mail for date: "+getYasterdayNiceDate());

    if (performDownload)
    {
        Downloader d = new Downloader();
        d.connectAnd(); //connect to pair server
        errorNotHappened = d.downloadFiles();
        d.disconnectFromServer();
    }

    if (errorNotHappened && performDataManipulation)
    {
        Manipulator m = new Manipulator();
        errorNotHappened = m.work();
        m.terminateManipulator();
    }

    if (performEmailSent)
    {
        GoogleMailer gmail = new GoogleMailer();
        gmail.startMailingService();
        if (errorNotHappened)
            errorWithMailNotHappened = gmail.sendMailWithAttach();
        else
            gmail.sendFailedMail();
        if(!errorWithMailNotHappened)
        {
            gmail.sendFailedMail();
        }
    }
    System.out.println("***~~~*** Job ended.");

}


问:
Updating and Transitioning Data on graph using D3 and Socket

I am trying to get a line graph made using D3.JS to update using data being brought in from a web socket.

I used this simple D3 Line Graph as a base: http://bl.ocks.org/d3noob/b3ff6ae1c120eea654b5

I've got the socket connection with the graph, the two issues I'm getting that I can't seem to work around are as follows:

The graph shifts updating for a few data points and afterward continues shifting but doesn't show any new points, the axis at the bottom doesn't transition either.

When updating to the next point, it jumps abruptly. I've looked into how to get it to transition smoothly, but no solutions I've found have worked, only causing different errors.

```<code>    var socket = io('http://localhost:3000');
    socket.on('data1', function(msg){

      //add data to the queue
      data.push({
       time: ++t,
       value: parseInt(msg.data)/10
     })

     tick();
    });

     // Set the dimensions of the canvas / graph
      var margin = {top: 30, right: 20, bottom: 30, left: 50},
          width = 600 - margin.left - margin.right,
          height = 270 - margin.top - margin.bottom;

      var n = 40,
        random = d3.randomNormal(0, .2),
        data = d3.range(n).map(random);
        // Adds the svg canvas
        var svg = d3.select(".data")
            .append("svg")
                .attr("width", width + margin.left + margin.right)
                .attr("height", height + margin.top + margin.bottom)
                .attr("id", "graph")
            .append("g")
                .attr("transform",
                      "translate(" + margin.left + "," + margin.top + ")");

    var x = d3.scaleLinear()
        .domain([0, n - 1])
        .range([0, width]);
    var y = d3.scaleLinear()
        .domain([-1, 1])
        .range([height, 0]);
    var line = d3.line()
        .x(function(d, i) { return x(i); })
        .y(function(d, i) { return y(d); });

    svg.append("defs").append("clipPath")
      .attr("id", "clip")
      .append("rect")
      .attr("width", width)
      .attr("height", height);

    var xAxis = d3.axisBottom(10).tickFormat(function(d){ return d.x;});
    var widthScale = d3.scaleLinear()
        .domain([0, 120])
        .range([0, width]);
    var axis = d3.axisLeft()
        .scale(widthScale);

    var path = svg.append("g")
      .attr("clip-path", "url(#clip)")
      .append("path")
      .data([data])
      .attr("class", "line");

    function tick() {
    //  console.log(data.length);
      // update the domains
      x.domain([t - n + 2, t]);

      // redraw the line
      svg.select(".line")
        .attr("d", line)
        .attr("transform", null);

      // slide the x-axis left
      axis.transition()
        .duration(duration)
        .ease("linear")
        .call(x.axis);

      // slide the line left
      path.transition()
        .duration(duration)
        .ease("linear")
        .attr("transform", "translate(" + x(t - n) + ")");

      // pop the old data point off the front
      if (data.length > 20) data.shift();

    }

<!-- What do you expect the result to be? -->

<!-- What is the actual result you get? (Please include any errors.) -->
</code>```

I also get these two errors on the console if that helps:

Error:  attribute d: Expected number, "…733.68421052632,NaNL-108719.7368…".

Uncaught TypeError: axis.transition is not a function

答: What version of d3 are you using?  Would it happen to be 4.12?  I've started getting "transition is not a function" errors since I updated to 4.12.  Downgrading to 4.11 might resolve the problem.</p>

Body:
I am trying to get a line graph made using D3.JS to update using data being brought in from a web socket.

I used this simple D3 Line Graph as a base: http://bl.ocks.org/d3noob/b3ff6ae1c120eea654b5

I've got the socket connection with the graph, the two issues I'm getting that I can't seem to work around are as follows:

The graph shifts updating for a few data points and afterward continues shifting but doesn't show any new points, the axis at the bottom doesn't transition either.

When updating to the next point, it jumps abruptly. I've looked into how to get it to transition smoothly, but no solutions I've found have worked, only causing different errors.

    var socket = io('http://localhost:3000');
    socket.on('data1', function(msg){

      //add data to the queue
      data.push({
       time: ++t,
       value: parseInt(msg.data)/10
     })

     tick();
    });

     // Set the dimensions of the canvas / graph
      var margin = {top: 30, right: 20, bottom: 30, left: 50},
          width = 600 - margin.left - margin.right,
          height = 270 - margin.top - margin.bottom;

      var n = 40,
        random = d3.randomNormal(0, .2),
        data = d3.range(n).map(random);
        // Adds the svg canvas
        var svg = d3.select(".data")
            .append("svg")
                .attr("width", width + margin.left + margin.right)
                .attr("height", height + margin.top + margin.bottom)
                .attr("id", "graph")
            .append("g")
                .attr("transform",
                      "translate(" + margin.left + "," + margin.top + ")");

    var x = d3.scaleLinear()
        .domain([0, n - 1])
        .range([0, width]);
    var y = d3.scaleLinear()
        .domain([-1, 1])
        .range([height, 0]);
    var line = d3.line()
        .x(function(d, i) { return x(i); })
        .y(function(d, i) { return y(d); });

    svg.append("defs").append("clipPath")
      .attr("id", "clip")
      .append("rect")
      .attr("width", width)
      .attr("height", height);

    var xAxis = d3.axisBottom(10).tickFormat(function(d){ return d.x;});
    var widthScale = d3.scaleLinear()
        .domain([0, 120])
        .range([0, width]);
    var axis = d3.axisLeft()
        .scale(widthScale);

    var path = svg.append("g")
      .attr("clip-path", "url(#clip)")
      .append("path")
      .data([data])
      .attr("class", "line");

    function tick() {
    //  console.log(data.length);
      // update the domains
      x.domain([t - n + 2, t]);

      // redraw the line
      svg.select(".line")
        .attr("d", line)
        .attr("transform", null);

      // slide the x-axis left
      axis.transition()
        .duration(duration)
        .ease("linear")
        .call(x.axis);

      // slide the line left
      path.transition()
        .duration(duration)
        .ease("linear")
        .attr("transform", "translate(" + x(t - n) + ")");

      // pop the old data point off the front
      if (data.length > 20) data.shift();

    }

I also get these two errors on the console if that helps:

Error:  attribute d: Expected number, "…733.68421052632,NaNL-108719.7368…".

Uncaught TypeError: axis.transition is not a function


问:
Significant new inventions in computing since 1980
This question arose from comments about different kinds of progress in computing over the last 50 years or so.

I was asked by some of the other participants to raise it as a question to the whole forum.

The basic idea here is not to bash the current state of things but to try to understand something about the progress of coming up with fundamental new ideas and principles.

I claim that we need really new ideas in most areas of computing, and I would like to know of any important and powerful ones that have been done recently. If we can't really find them, then we should ask "Why?" and "What should we be doing?"

答: Games With a Purpose - Collective intelligence tools like Luis von Ahn and his team are developing might have been a dream before 1980, but there wasn't a widely deployed network with millions of people available and a need (e.g. reCAPTCHA) to actually make it happen. </p>

OwnerDisplayName: Alan Kay

ContentLicense: CC BY-SA 2.5

LastEditorDisplayName: Out Into Space

OwnerDisplayName: Jeff Moser


问:
PHP on an IIS server
I have designed a PHP based website which needs to run on a local server. Unfortunately I have developed this on a WAMP server using Apache. The machine on which this website will be placed on only supports the IIS server and I am not allowed to install Apache on this this machine.

How do I run PHP code on an IIS server?

答:
You can get it installed and include the right infrastructure (IIS, WinCache, and FastCGI, and URL Rewrite) with a single click using Web Platform Installer:

To install PHP 5.2 use:
http://www.microsoft.com/web/gallery/install.aspx?appid=PHP52

To install PHP 5.3 use:
http://www.microsoft.com/web/gallery/install.aspx?appid=PHP53

Title: PHP on an IIS server


问:
Combine two collections with predicate using Stream API
I have two collections of type Entity.

```<code>class Entity {
    long id;
    // other fields
}

Collection<Entity> first = ...
Collection<Entity> second = ...
</code>```

I need to combine them in a such way that all elements in first should be replaced by elements from second if their ids are equal.

So, e.g if first contains [{"id": 1}, {"id": 2}, {"id": 3}] and second contains [{"id": 3}, {"id": 4}, {"id": 5}]

the result should be like this: [{"id": 1}, {"id": 2}, {"id": 3}, {"id": 4}, {"id": 5}] where {"id": 3} from second replaced {"id": 3} from first.

Is there a way how to implement it in a Java 8 way, using Stream API.

答:
The stream form of first.removeAll(second).addAll(second) so to say:

```<code>Stream<Entity> result = Stream.concat(
    first.stream().filter(entity -> !second.contains(entity)),
    second.stream());
</code>```

This assumes that the equal entities in second differ from first by a non-id field value, not relevant for equality.

Body:
I have two collections of type Entity.

class Entity {
    long id;
    // other fields
}

Collection<Entity> first = ...
Collection<Entity> second = ...

I need to combine them in a such way that all elements in first should be replaced by elements from second if their ids are equal.

So, e.g if first contains [{"id": 1}, {"id": 2}, {"id": 3}] and second contains [{"id": 3}, {"id": 4}, {"id": 5}]

the result should be like this: [{"id": 1}, {"id": 2}, {"id": 3}, {"id": 4}, {"id": 5}] where {"id": 3} from second replaced {"id": 3} from first.

Is there a way how to implement it in a Java 8 way, using Stream API.

Body:
The stream form of first.removeAll(second).addAll(second) so to say:

Stream<Entity> result = Stream.concat(
    first.stream().filter(entity -> !second.contains(entity)),
    second.stream());

This assumes that the equal entities in second differ from first by a non-id field value, not relevant for equality.


问:
Angular Cli proxy working in one env but return ECONNRESET in another
first time asking questions here so please let me know if I am missing any of the best practices.

I am working on an Angular 4 application that uses proxy to simplify the communication between front and back end of the application.

The proxy setting is the following:

```<code> {
  "/api": {
    "target": "http://localhost:9000",
    "secure": false
  },
  "/auth": {
    "target": "http://localhost:9000",
    "secure": false
  }
}
</code>```

In my main computer, when I run the part of the application that would call the proxy I get the following error.

```<code>[HPM] Error occurred while trying to proxy request /auth/google from localhost:4200 to http://localhost:9000 (ECONNRESET) (https://nodejs.org/api/errors.html#errors_common_system_errors)
</code>```

The chrome console displays a 504 error.

The command I used to run all the servers

```<code>concurrently \"mongod\" \"ng serve -pc proxy.conf.json --open\" \"tsc -w -p server\" \"nodemon dist/server/app.js\"
</code>```

When the application is building, I can see that the proxy has been set up by the program, but the same error still happens.

```<code>[1] [HPM] Proxy created: /api/**  ->  http://localhost:9000
[1] [HPM] Subscribed to http-proxy events:  [ 'error', 'close' ]
[1] [HPM] Proxy created: /auth/**  ->  http://localhost:9000
[1] [HPM] Subscribed to http-proxy events:  [ 'error', 'close' ]
</code>```

However, when I try to run it on another computer that I have (exact same code, node setting, network environment etc.), the proxy is working.

I tried to replicate the error by making all application related setting identical between two computers (node version, npm version, clean installed all node packages and even pulled the application clean from github on both computers), but the error still persists on one but not the other.

Can someone make some suggestions on where should I look or what I should do next to identify the root cause of this problem? Thanks!

Things I've done so far:

Reinstall all npm packages

Restart Computer

Pulled application again from git

Running all the commands (for DB, server, and client) independently

nodejs version: 6.10.3

npm version: 5.6.0

答:
Per suggestion of a friend, I ended up running

```<code>sudo lsof -i :9000
</code>```

to see if there is anything in 9000 that could potentially interfere with the port. There ended up being few php listeners in the same port that is running while the node server is running - and those php listeners are the culprit of the error.

So I ran the following command to kill the listeners and the problem because resolved.

```<code>kill -kill `lsof -t -i tcp:9000`
</code>```

Have no idea why node didn't spew out the "port in use" error but oh well its resolved now.

Rationale of the story: check your ports to make sure its not occupied.

Body:
first time asking questions here so please let me know if I am missing any of the best practices.

I am working on an Angular 4 application that uses proxy to simplify the communication between front and back end of the application.

The proxy setting is the following:

 {
  "/api": {
    "target": "http://localhost:9000",
    "secure": false
  },
  "/auth": {
    "target": "http://localhost:9000",
    "secure": false
  }
}

In my main computer, when I run the part of the application that would call the proxy I get the following error.

[HPM] Error occurred while trying to proxy request /auth/google from localhost:4200 to http://localhost:9000 (ECONNRESET) (https://nodejs.org/api/errors.html#errors_common_system_errors)

The chrome console displays a 504 error.

The command I used to run all the servers

concurrently \"mongod\" \"ng serve -pc proxy.conf.json --open\" \"tsc -w -p server\" \"nodemon dist/server/app.js\"

When the application is building, I can see that the proxy has been set up by the program, but the same error still happens.

[1] [HPM] Proxy created: /api/**  ->  http://localhost:9000
[1] [HPM] Subscribed to http-proxy events:  [ 'error', 'close' ]
[1] [HPM] Proxy created: /auth/**  ->  http://localhost:9000
[1] [HPM] Subscribed to http-proxy events:  [ 'error', 'close' ]

However, when I try to run it on another computer that I have (exact same code, node setting, network environment etc.), the proxy is working.

I tried to replicate the error by making all application related setting identical between two computers (node version, npm version, clean installed all node packages and even pulled the application clean from github on both computers), but the error still persists on one but not the other.

Can someone make some suggestions on where should I look or what I should do next to identify the root cause of this problem? Thanks!

Things I've done so far:

Reinstall all npm packages

Restart Computer

Pulled application again from git

Running all the commands (for DB, server, and client) independently

nodejs version: 6.10.3

npm version: 5.6.0

Body:
Per suggestion of a friend, I ended up running

sudo lsof -i :9000

to see if there is anything in 9000 that could potentially interfere with the port. There ended up being few php listeners in the same port that is running while the node server is running - and those php listeners are the culprit of the error.

So I ran the following command to kill the listeners and the problem because resolved.

kill -kill `lsof -t -i tcp:9000`

Have no idea why node didn't spew out the "port in use" error but oh well its resolved now.

Rationale of the story: check your ports to make sure its not occupied.


问:
TypeError in using React app with jquery plugins
I created an app with react-create-app command and i use the react 16. i want to use katrik-v fileinput (a jquery plugin) too. that is my code:

```<code>import React, { Component } from 'react';
import { Grid, Cell }  from 'react-foundation';
import Header from './Heaader';
import $, { jQuery } from 'jquery';

class New extends Component {

componentDidMount(){
    $(document).find('#root').find('#test-upload').fileinput();
}

render(){
    return (
        <div>
          <Grid type="x">
               <Cell medium={2} large={2} >
                    <label htmlFor="image" className="text-right middle">
                           <p className="form-label">Images</p></label>
               </Cell>
               <Cell medium={8} large={8}>
                    <div className="file-loading">
                        <input id="test-upload" ref='fff' type="file"
                        multiple />
                    </div>
               </Cell>
         </Grid>
      </div>)
}
}
export default New;
</code>```

When I call it in the index.js:

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

I'm facing this error:

TypeError:
  __WEBPACK_IMPORTED_MODULE_4_jquery___default(...)(...).find(...).find(...).fileinput
  is not a function.

           $(document).find('#root').find('#test-upload').fileinput()

what is the problem?

In general, how can these two be merged?(a jquery plugin and react app)

Body:
I created an app with react-create-app command and i use the react 16. i want to use katrik-v fileinput (a jquery plugin) too. that is my code:

import React, { Component } from 'react';
import { Grid, Cell }  from 'react-foundation';
import Header from './Heaader';
import $, { jQuery } from 'jquery';

class New extends Component {

componentDidMount(){
    $(document).find('#root').find('#test-upload').fileinput();
}

render(){
    return (

          <Grid type="x">
               <Cell medium={2} large={2} >

Images

               </Cell>
               <Cell medium={8} large={8}>

                        <input id="test-upload" ref='fff' type="file"
                        multiple />

               </Cell>
         </Grid>

)
}
}
export default New;

When I call it in the index.js:

ReactDOM.render(<App />, document.getElementById('root'));

I'm facing this error:

TypeError:
  __WEBPACK_IMPORTED_MODULE_4_jquery___default(...)(...).find(...).find(...).fileinput
  is not a function.

           $(document).find('#root').find('#test-upload').fileinput()

what is the problem?

In general, how can these two be merged?(a jquery plugin and react app)

Body:
In order to use jQuery plugins with React apps, you should pull jQuery out of the webpack process.

Include jQuery and the plugins as static files or via CDN using <script> tags in your public/index.html.

To use jQuery in your React files, add

/* global $ */

to your class files as if it were an import line.


答:
How about the following using a recursive function.

```<code># Your sample data
y2 <- c(0,0,NA,0,0,0,0)
y <- c(0,0,0,NA,NA,0)
x <- c(0,0,0,0)
li <-list(y2 = y2,y = y,x = x)
</code>```

I define a recursive function collapseList that recursively removes list entries if they are an ordered subset of other list entries.

```<code># Recursive function to collapse entries
collapseList <- function(lst) {
    s <- sapply(lst, paste, collapse = "");
    if (sum(grepl(s[1], s)) > 1) {
        lst <- lst[-1];
        collapseList(lst);
    }
    else lst;
}
</code>```

Output based on your sample list:

```<code># Order list by number of list elements
li <- li[order(sapply(li, length))];

li <- collapseList(li);
li;
#$y
#[1]  0  0  0 NA NA  0
#
#$y2
#[1]  0  0 NA  0  0  0  0
</code>```

@storaged example

```<code>li <- list(
    x = c(0,0,0,0),
    y = c(0,NA,0,0,0),
    y2 = c(NA,NA,0,0,0,0));

li <- li[order(sapply(li, length))];
collapseList(li);
#$y
#[1]  0 NA  0  0  0
#
#$y2
#[1] NA NA  0  0  0  0
</code>```

Title: How to check if the exact vector is a subset of another vector of a list

Body:
How about the following using a recursive function.

# Your sample data
y2 <- c(0,0,NA,0,0,0,0)
y <- c(0,0,0,NA,NA,0)
x <- c(0,0,0,0)
li <-list(y2 = y2,y = y,x = x)

I define a recursive function collapseList that recursively removes list entries if they are an ordered subset of other list entries.

# Recursive function to collapse entries
collapseList <- function(lst) {
    s <- sapply(lst, paste, collapse = "");
    if (sum(grepl(s[1], s)) > 1) {
        lst <- lst[-1];
        collapseList(lst);
    }
    else lst;
}

Output based on your sample list:

# Order list by number of list elements
li <- li[order(sapply(li, length))];

li <- collapseList(li);
li;
#$y
#[1]  0  0  0 NA NA  0
#
#$y2
#[1]  0  0 NA  0  0  0  0

@storaged example

li <- list(
    x = c(0,0,0,0),
    y = c(0,NA,0,0,0),
    y2 = c(NA,NA,0,0,0,0));

li <- li[order(sapply(li, length))];
collapseList(li);
#$y
#[1]  0 NA  0  0  0
#
#$y2
#[1] NA NA  0  0  0  0


问:
Writing data to tables in Azure Sql Database via Azure Function causes deadlock
I'm sitting here trying to figure out a way to solve a problem I have with deadlocks when writing data to database via Azure function.

What I'm doing in the workflow is:

Getting data/content via Logic App from Servicebus queue.

Sending the data to a Azure function.

Processing the data in the Azure Function by extracting all the importent
data from the object and enqueue the inserts before making a transaction to the Azure SQL database.

But because the logic app starts "threading up" / starts many "instances" when the transaction to the database is writing data to the same tables as another insert transaction I get deadlocks.

Does anyone know of any good ways to solve this or maybe some known techniques to tackle such a problem?

答:
You don't need Logic Apps to handle Service Bus messages in Azure Functions. Functions have Service Bus Trigger to do that directly within Function Apps.

When you do that, you can control the amount of parallel executions by changing host.json file. For Service Bus the parameter is maxConcurrentCalls, which is 16 by default, but you can set it to 1.

Of course, that will limit the throughput that you can expect from your Function, since all messages on an app instance will be processed sequentially. So you need to balance the parameters for your specific use case.


问:
Cannot get property 'compileSdkVersion' on extra properties extension as it does not exist Open File
I imported a project downloaded from GitHub into my Android Studio project as module.
The "Import module..." wizard worked fine, but when the Adroid Studio tried to rebuild the project, it returned me this error:

```<code>Cannot get property 'compileSdkVersion' on extra properties extension as it does not exist Open File
</code>```

The error is related to this line in the "build.gradle" file of the imported module:

```<code>compileSdkVersion rootProject.compileSdkVersion
</code>```

I tried to add "ext" section in the project "build.gradle" like this:

```<code>ext {
    compileSdkVersion 26
}
</code>```

But in this way I receive a new error:

```<code>Gradle DSL method not found: 'compileSdkVersion()' Possible causes: ...
</code>```

答:
Change your .gradle android part to this

```<code>android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "your App id"
        minSdkVersion 18
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
</code>```

Body:
I imported a project downloaded from GitHub into my Android Studio project as module.
The "Import module..." wizard worked fine, but when the Adroid Studio tried to rebuild the project, it returned me this error:

Cannot get property 'compileSdkVersion' on extra properties extension as it does not exist Open File

The error is related to this line in the "build.gradle" file of the imported module:

compileSdkVersion rootProject.compileSdkVersion

I tried to add "ext" section in the project "build.gradle" like this:

ext {
    compileSdkVersion 26
}

But in this way I receive a new error:

Gradle DSL method not found: 'compileSdkVersion()' Possible causes: ...

Body:
Change your .gradle android part to this

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "your App id"
        minSdkVersion 18
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}


问:
SonarQube scanner can't connect to server
I faced the issue with the sonar-scanner-cli which can't connect to the SonarQube server. Scan is run from within the docker container. Docker connects to SonarQube server through proxy so I thought that it was the issue but I tried to set proxy environment variables and also pass proxy parameters to the scanner. That didn't help. Also other binaries like yum or gradle can connect to external repos without problem from the same container.

SonarQube server version: 6.7.0.33306.

```<code>13:12:28.858 INFO: Scanner configuration file: /home/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQube_2.8/sonar-scanner-2.8/conf/sonar-scanner.properties
13:12:28.869 INFO: Project root configuration file: NONE
13:12:28.937 INFO: SonarQube Scanner 2.8
13:12:28.937 INFO: Java 1.8.0_151 Oracle Corporation (64-bit)
13:12:28.937 INFO: Linux
3.10.0-693.2.2.el7.x86_64 amd64
13:12:29.854 DEBUG: keyStore is :
13:12:29.854 DEBUG: keyStore type is : jks
13:12:29.854 DEBUG: keyStore provider is :
13:12:29.854 DEBUG: init keystore
13:12:29.854 DEBUG: init keymanager of type SunX509
13:12:30.067 DEBUG: Create : /home/jenkins/.sonar/cache
13:12:30.074 INFO: User cache: /home/jenkins/.sonar/cache
13:12:30.074 DEBUG: Create : /home/jenkins/.sonar/cache/_tmp
13:12:30.075 DEBUG: Extract sonar-scanner-api-batch in temp...
13:12:30.088 DEBUG: Get bootstrap index...
13:12:30.089 DEBUG: Download: https://hostname/batch_bootstrap/index
13:12:30.133 ERROR: SonarQube server [https://hostname] can not be reached
13:12:30.133 INFO:
------------------------------------------------------------------------
13:12:30.133 INFO: EXECUTION FAILURE
13:12:30.134 INFO:
------------------------------------------------------------------------
13:12:30.134 INFO: Total time: 1.342s
13:12:30.153 INFO: Final Memory: 4M/148M
13:12:30.154 INFO:
------------------------------------------------------------------------
13:12:30.154 ERROR: Error during SonarQube Scanner execution org.sonarsource.scanner.api.internal.ScannerException: Unable to execute SonarQube
    at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory$1.run(IsolatedLauncherFactory.java:84)
    at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory$1.run(IsolatedLauncherFactory.java:71)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:71)
    at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:67)
    at org.sonarsource.scanner.api.EmbeddedScanner.doStart(EmbeddedScanner.java:218)
    at org.sonarsource.scanner.api.EmbeddedScanner.start(EmbeddedScanner.java:156)
    at org.sonarsource.scanner.cli.Main.execute(Main.java:72)
    at org.sonarsource.scanner.cli.Main.main(Main.java:61) Caused by: java.lang.IllegalStateException: Fail to download libraries from server
    at org.sonarsource.scanner.api.internal.Jars.downloadFiles(Jars.java:93)
    at org.sonarsource.scanner.api.internal.Jars.download(Jars.java:70)
    at org.sonarsource.scanner.api.internal.JarDownloader.download(JarDownloader.java:39)
    at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory$1.run(IsolatedLauncherFactory.java:75)  ... 8 more Caused by: java.net.ConnectException: Failed to connect to hostname/IP:443
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.io.RealConnection.connectSocket(RealConnection.java:187)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.io.RealConnection.buildConnection(RealConnection.java:170)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.io.RealConnection.connect(RealConnection.java:111)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:187)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:123)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:93)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:296)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:248)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.RealCall.getResponse(RealCall.java:243)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:201)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.RealCall.getResponseWithInterceptorChain(RealCall.java:163)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.RealCall.execute(RealCall.java:57)
    at org.sonarsource.scanner.api.internal.ServerConnection.callUrl(ServerConnection.java:113)
    at org.sonarsource.scanner.api.internal.ServerConnection.downloadString(ServerConnection.java:98)
    at org.sonarsource.scanner.api.internal.Jars.downloadFiles(Jars.java:78)
        ... 11 more
</code>```

答: I think you should verify your firewall. In most systems, port 9000 is not open and it is a common source of failure.</p>

Body:
I faced the issue with the sonar-scanner-cli which can't connect to the SonarQube server. Scan is run from within the docker container. Docker connects to SonarQube server through proxy so I thought that it was the issue but I tried to set proxy environment variables and also pass proxy parameters to the scanner. That didn't help. Also other binaries like yum or gradle can connect to external repos without problem from the same container.

SonarQube server version: 6.7.0.33306.

13:12:28.858 INFO: Scanner configuration file: /home/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQube_2.8/sonar-scanner-2.8/conf/sonar-scanner.properties
13:12:28.869 INFO: Project root configuration file: NONE
13:12:28.937 INFO: SonarQube Scanner 2.8
13:12:28.937 INFO: Java 1.8.0_151 Oracle Corporation (64-bit)
13:12:28.937 INFO: Linux
3.10.0-693.2.2.el7.x86_64 amd64
13:12:29.854 DEBUG: keyStore is :
13:12:29.854 DEBUG: keyStore type is : jks
13:12:29.854 DEBUG: keyStore provider is :
13:12:29.854 DEBUG: init keystore
13:12:29.854 DEBUG: init keymanager of type SunX509
13:12:30.067 DEBUG: Create : /home/jenkins/.sonar/cache
13:12:30.074 INFO: User cache: /home/jenkins/.sonar/cache
13:12:30.074 DEBUG: Create : /home/jenkins/.sonar/cache/_tmp
13:12:30.075 DEBUG: Extract sonar-scanner-api-batch in temp...
13:12:30.088 DEBUG: Get bootstrap index...
13:12:30.089 DEBUG: Download: https://hostname/batch_bootstrap/index
13:12:30.133 ERROR: SonarQube server [https://hostname] can not be reached
13:12:30.133 INFO:
------------------------------------------------------------------------
13:12:30.133 INFO: EXECUTION FAILURE
13:12:30.134 INFO:
------------------------------------------------------------------------
13:12:30.134 INFO: Total time: 1.342s
13:12:30.153 INFO: Final Memory: 4M/148M
13:12:30.154 INFO:
------------------------------------------------------------------------
13:12:30.154 ERROR: Error during SonarQube Scanner execution org.sonarsource.scanner.api.internal.ScannerException: Unable to execute SonarQube
    at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory$1.run(IsolatedLauncherFactory.java:84)
    at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory$1.run(IsolatedLauncherFactory.java:71)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:71)
    at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:67)
    at org.sonarsource.scanner.api.EmbeddedScanner.doStart(EmbeddedScanner.java:218)
    at org.sonarsource.scanner.api.EmbeddedScanner.start(EmbeddedScanner.java:156)
    at org.sonarsource.scanner.cli.Main.execute(Main.java:72)
    at org.sonarsource.scanner.cli.Main.main(Main.java:61) Caused by: java.lang.IllegalStateException: Fail to download libraries from server
    at org.sonarsource.scanner.api.internal.Jars.downloadFiles(Jars.java:93)
    at org.sonarsource.scanner.api.internal.Jars.download(Jars.java:70)
    at org.sonarsource.scanner.api.internal.JarDownloader.download(JarDownloader.java:39)
    at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory$1.run(IsolatedLauncherFactory.java:75)  ... 8 more Caused by: java.net.ConnectException: Failed to connect to hostname/IP:443
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.io.RealConnection.connectSocket(RealConnection.java:187)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.io.RealConnection.buildConnection(RealConnection.java:170)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.io.RealConnection.connect(RealConnection.java:111)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:187)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:123)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:93)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:296)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:248)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.RealCall.getResponse(RealCall.java:243)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:201)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.RealCall.getResponseWithInterceptorChain(RealCall.java:163)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.RealCall.execute(RealCall.java:57)
    at org.sonarsource.scanner.api.internal.ServerConnection.callUrl(ServerConnection.java:113)
    at org.sonarsource.scanner.api.internal.ServerConnection.downloadString(ServerConnection.java:98)
    at org.sonarsource.scanner.api.internal.Jars.downloadFiles(Jars.java:78)
        ... 11 more


问:
Can't close mail view controller when clicking Cancel, Save Draft or Delete Draft
I'm implementing a mail controller in my app but I can't figure out why it won't close when clicking save draft or delete draft. The window gets stuck on the email screen and I can't click "Cancel" a second time either.</p>

```<code>@IBAction func emailButtonTapped(_ sender: UIButton) {
    guard MFMailComposeViewController.canSendMail() else {
        if !MFMailComposeViewController.canSendMail() {
            print("Can not send email")
            return
        }
        return
    }

    func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
        dismiss(animated: true, completion: nil)
    }

    let mailComposer = MFMailComposeViewController()
    mailComposer.mailComposeDelegate = self

    mailComposer.setToRecipients(["example@example.com"])
    mailComposer.setSubject("Look at this")
    mailComposer.setMessageBody("Hello, this is an email from the app I made.", isHTML: false)

    present(mailComposer, animated: true, completion: nil)
}
</code>```

答:
Can you try this once instead:</p>

```<code>    func mailComposeController(controller: MFMailComposeViewController, didFinishWithResult result: MFMailComposeResult, error: NSError?) {

    // Dismiss the mail compose view controller.
    controller.dismissViewControllerAnimated(true, completion: nil)
}
</code>```

Body:
I'm implementing a mail controller in my app but I can't figure out why it won't close when clicking save draft or delete draft. The window gets stuck on the email screen and I can't click "Cancel" a second time either.

@IBAction func emailButtonTapped(_ sender: UIButton) {
    guard MFMailComposeViewController.canSendMail() else {
        if !MFMailComposeViewController.canSendMail() {
            print("Can not send email")
            return
        }
        return
    }

    func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
        dismiss(animated: true, completion: nil)
    }

    let mailComposer = MFMailComposeViewController()
    mailComposer.mailComposeDelegate = self

    mailComposer.setToRecipients(["example@example.com"])
    mailComposer.setSubject("Look at this")
    mailComposer.setMessageBody("Hello, this is an email from the app I made.", isHTML: false)

    present(mailComposer, animated: true, completion: nil)
}

Body:
Can you try this once instead:

    func mailComposeController(controller: MFMailComposeViewController, didFinishWithResult result: MFMailComposeResult, error: NSError?) {

    // Dismiss the mail compose view controller.
    controller.dismissViewControllerAnimated(true, completion: nil)
}


问:
Matching multiple BEM modifiers in Sass
I am using BEM, and have an element with multiple modifiers:

```

<p>I'm using SCSS and taking advantage of it to write nested rules compatible with BEM. If I want to write a rule where an element (like the above) has <em>both</em> the m1 and m2 modifier, is there a way to write that compatible with the way I'm currently writing them? This is the kind of syntax I'm after, but results in a syntax error:</p>

<pre class="lang-css prettyprint-override"><code>.block {
    display: block;

    &__element {
        display: inline;

        &--m1 {
            background-color: red;
        }

        &--m2 {
            background-color: green;
        }

        // Syntax error
        &--m1&--m2 {
            background-color: yellow;
        }
    }
}
</code>```

I can think of ways around this by using attribute selectors, but is there a neater way?

For the record, the compiled attribute selector should be:

.block__element--m1.block__element--m2
```

答:
Store selector names in variables. Sassmeister demo.

```<code>.block {
  $module: ".block";

  &__element {
    $this: "#{$module}__element";

    &--m1#{$this}--m2 {
        background-color: yellow;
    }
  }
}
</code>```

Generated css:

```<code>.block__element--m1.block__element--m2 {
  background-color: yellow;
}
</code>```

Title: Matching multiple BEM modifiers in Sass

Body:
I am using BEM, and have an element with multiple modifiers:

I'm using SCSS and taking advantage of it to write nested rules compatible with BEM. If I want to write a rule where an element (like the above) has both the m1 and m2 modifier, is there a way to write that compatible with the way I'm currently writing them? This is the kind of syntax I'm after, but results in a syntax error:

.block {
    display: block;

    &__element {
        display: inline;

        &--m1 {
            background-color: red;
        }

        &--m2 {
            background-color: green;
        }

        // Syntax error
        &--m1&--m2 {
            background-color: yellow;
        }
    }
}

I can think of ways around this by using attribute selectors, but is there a neater way?

For the record, the compiled attribute selector should be:

.block__element--m1.block__element--m2

Body:
Store selector names in variables. Sassmeister demo.

.block {
  $module: ".block";

  &__element {
    $this: "#{$module}__element";

    &--m1#{$this}--m2 {
        background-color: yellow;
    }
  }
}

Generated css:

.block__element--m1.block__element--m2 {
  background-color: yellow;
}


问:
D3js change ticks x and y axis
I'm new to D3JS, and I've followed a tutorial on making a line graph at CodeTuts.

The chart I want to make should show the amount of users per hour and category of device. Since I want to be able to see at which time people will switch to tablet or mobile instead of desktop, I've made three arrays.

The arrays are build like this:

```<code>var desktop = [
{
  'hour': 01,
  'users': 20
},
{
 'hour': 08,
 'users': 800
}
];
</code>```

My graph looks like this now:

I would like to get to know how to set the xaxis values as:

```<code>00 , 01, 02, 03, 04 ,05, etc..
</code>```

and The yaxis should have the focus on the lowest device categories (mobile and desktop, so the yaxis should be something like:

```<code>00, 10, 20, 30, 40, 50, 60, 70, 80, 100, [maxvalue of users in desktop array]
</code>```

So something like this it should be:

My  code:

```<code>function makeChart(desktopData,mobileData,tabletData){
    var WIDTH = 1200,
        HEIGHT = 300,
        MARGINS = {
                top:20,
            right:20,
            bottom:20,
            left:50
        }
    var vis = d3.select("#visualisation"),
        WIDTH = 1200,
        HEIGHT = 300,
        MARGINS = {
            top: 20,
            right: 20,
            bottom: 20,
            left: 50
        },
        xScale = d3.scale.linear().range([MARGINS.left, WIDTH - MARGINS.right]).domain([00,23]),
        yScale = d3.scale.linear().range([HEIGHT - MARGINS.top, MARGINS.bottom]).domain([00,100]),
        xAxis = d3.svg.axis()
            .scale(xScale),

        yAxis = d3.svg.axis()
            .scale(yScale)
            .orient("left");

    vis.append("svg:g")
        .attr("class","axis")
        .attr("transform", "translate(0," + (HEIGHT - MARGINS.bottom) + ")")
        .call(xAxis);

    vis.append("svg:g")
        .attr("class","axis")
        .attr("transform", "translate(" + (MARGINS.left) + ",0)")
        .call(yAxis);

    var lineGen = d3.svg.line()
        .x(function(d){
            return xScale(d.uur);
        })
        .y(function(d){
            return yScale(d.pageviews);
        });
    vis.append('svg:path')
        .attr('d', lineGen(desktopData))
        .attr('stroke','deepskyblue')
        .attr('stroke-width',2)
        .attr('fill','none');

    vis.append('svg:path')
        .attr('d', lineGen(mobileData))
        .attr('stroke','orange')
        .attr('stroke-width',2)
        .attr('fill','none');

    vis.append('svg:path')
        .attr('d', lineGen(tabletData))
        .attr('stroke','deeppink')
        .attr('stroke-width',2)
        .attr('fill','none');
}
</code>```

答:
To force ticks values on axis, you can use ticks() or tickValues() (and even tickFormat() if you need to have a specific format displayed).

For instance:

```<code>var xAxis = d3.svg.axis()
    .scale(xScale)
    .ticks(24); // Will display 24 ticks (for 24 hours on x axis)
</code>```

For your y axis, you have to define the scale domain from 0 to the max value.
Instead of

```<code>yScale = d3.scale.linear()
    .range([HEIGHT - MARGINS.top, MARGINS.bottom])
    .domain([00,100]), // All values above 100 will be out of the chart
</code>```

Define the domain as follow (here using d3.max()):

```<code>var maxValue = d3.max(desktopArray, function(d){ return d.users });

var yScale = d3.scale.linear()
    .range([HEIGHT - MARGINS.top, MARGINS.bottom])
    .domain([00, maxValue]),
</code>```

Title: D3js change ticks x and y axis

Body:
I'm new to D3JS, and I've followed a tutorial on making a line graph at CodeTuts.

The chart I want to make should show the amount of users per hour and category of device. Since I want to be able to see at which time people will switch to tablet or mobile instead of desktop, I've made three arrays.

The arrays are build like this:

var desktop = [
{
  'hour': 01,
  'users': 20
},
{
 'hour': 08,
 'users': 800
}
];

My graph looks like this now:

I would like to get to know how to set the xaxis values as:

00 , 01, 02, 03, 04 ,05, etc..

and The yaxis should have the focus on the lowest device categories (mobile and desktop, so the yaxis should be something like:

00, 10, 20, 30, 40, 50, 60, 70, 80, 100, [maxvalue of users in desktop array]

So something like this it should be:

My  code:

function makeChart(desktopData,mobileData,tabletData){
    var WIDTH = 1200,
        HEIGHT = 300,
        MARGINS = {
                top:20,
            right:20,
            bottom:20,
            left:50
        }
    var vis = d3.select("#visualisation"),
        WIDTH = 1200,
        HEIGHT = 300,
        MARGINS = {
            top: 20,
            right: 20,
            bottom: 20,
            left: 50
        },
        xScale = d3.scale.linear().range([MARGINS.left, WIDTH - MARGINS.right]).domain([00,23]),
        yScale = d3.scale.linear().range([HEIGHT - MARGINS.top, MARGINS.bottom]).domain([00,100]),
        xAxis = d3.svg.axis()
            .scale(xScale),

        yAxis = d3.svg.axis()
            .scale(yScale)
            .orient("left");

    vis.append("svg:g")
        .attr("class","axis")
        .attr("transform", "translate(0," + (HEIGHT - MARGINS.bottom) + ")")
        .call(xAxis);

    vis.append("svg:g")
        .attr("class","axis")
        .attr("transform", "translate(" + (MARGINS.left) + ",0)")
        .call(yAxis);

    var lineGen = d3.svg.line()
        .x(function(d){
            return xScale(d.uur);
        })
        .y(function(d){
            return yScale(d.pageviews);
        });
    vis.append('svg:path')
        .attr('d', lineGen(desktopData))
        .attr('stroke','deepskyblue')
        .attr('stroke-width',2)
        .attr('fill','none');

    vis.append('svg:path')
        .attr('d', lineGen(mobileData))
        .attr('stroke','orange')
        .attr('stroke-width',2)
        .attr('fill','none');

    vis.append('svg:path')
        .attr('d', lineGen(tabletData))
        .attr('stroke','deeppink')
        .attr('stroke-width',2)
        .attr('fill','none');
}

Body:
To force ticks values on axis, you can use ticks() or tickValues() (and even tickFormat() if you need to have a specific format displayed).

For instance:

var xAxis = d3.svg.axis()
    .scale(xScale)
    .ticks(24); // Will display 24 ticks (for 24 hours on x axis)

For your y axis, you have to define the scale domain from 0 to the max value.
Instead of

yScale = d3.scale.linear()
    .range([HEIGHT - MARGINS.top, MARGINS.bottom])
    .domain([00,100]), // All values above 100 will be out of the chart

Define the domain as follow (here using d3.max()):

var maxValue = d3.max(desktopArray, function(d){ return d.users });

var yScale = d3.scale.linear()
    .range([HEIGHT - MARGINS.top, MARGINS.bottom])
    .domain([00, maxValue]),


问:
How to use spring data jpa to access keycloak DB
I am keycloak freshman and using keycloak to controll access authority in my project now.
But when i called some restAPIs whitch provided by keycloak itself,i found some APIs can not meet our requirement.For example,i would query users info by id list.
but keycloak only provided api to query all users.

So,i think can i use jpa to access DB of keycloak directly?

But i searched many info from network but found nothings,is there someone would give me some help or example.

Thanks.

答:
You can query a user by id using this REST endpoint

```<code>{baseUrl}/admin/realms/{realm}/users/{userId}
</code>```

You can query Keycloak database using JDBC or Hibernate (a JPA provider). You just need to connect to the database as to a usual database, using an URL like this:

jdbc:mysql://localhost:3306/keycloak

And map necessary data to entity classes. For example, for a users table

```<code>@Entity
@Table(name = "user_entity")
class User {

  @Column(name = "ID")
  private String id;

  @Column(name = "USERNAME")
  private String userName;

}
</code>```

Body:
You can query a user by id using this REST endpoint

{baseUrl}/admin/realms/{realm}/users/{userId}

You can query Keycloak database using JDBC or Hibernate (a JPA provider). You just need to connect to the database as to a usual database, using an URL like this:

jdbc:mysql://localhost:3306/keycloak

And map necessary data to entity classes. For example, for a users table

@Entity
@Table(name = "user_entity")
class User {

  @Column(name = "ID")
  private String id;

  @Column(name = "USERNAME")
  private String userName;

}


问:
Java Script error "Cannot read property 'clientWidth' of null" with modal
I'm having issues with Java Script with this code Not Answered.

Got it working in https://jsfiddle.net/p3kdbquh/2/ but not locally

```<code>  $('#myModal').modal('show');

var particleCount = 300;
var particleMax   = 1000;
var sky           = document.querySelector('.modal');
var canvas        = document.createElement('canvas');
var ctx           = canvas.getContext('2d');
var width         = sky.clientWidth; //THIS LINE
var height        = sky.clientHeight;
var i             = 0;
var active        = false;
var snowflakes    = [];
var snowflake;
canvas.style.position = 'absolute';
canvas.style.left = canvas.style.top = '0';

var Snowflake = function () {
  this.x = 0;
  this.y = 0;
  this.vy = 0;
  this.vx = 0;
  this.r = 0;

  this.reset();
};

Snowflake.prototype.reset = function() {
  this.x = Math.random() * width;
  this.y = Math.random() * -height;
  this.vy = 1 + Math.random() * 3;
  this.vx = 0.5 - Math.random();
  this.r = 1 + Math.random() * 2;
  this.o = 0.5 + Math.random() * 0.5;
};

function generateSnowFlakes() {
  snowflakes = [];
  for (i = 0; i < particleMax; i++) {
    snowflake = new Snowflake();
    snowflake.reset();
    snowflakes.push(snowflake);
  }
}

generateSnowFlakes();

function update() {
  ctx.clearRect(0, 0, width, height);

  if (!active) {
    return;
  }

  for (i = 0; i < particleCount; i++) {
    snowflake = snowflakes[i];
    snowflake.y += snowflake.vy;
    snowflake.x += snowflake.vx;

    ctx.globalAlpha = snowflake.o;
    ctx.beginPath();
    ctx.arc(snowflake.x, snowflake.y, snowflake.r, 0, Math.PI * 2, false);
    ctx.closePath();
    ctx.fill();

    if (snowflake.y > height) {
      snowflake.reset();
    }
  }

  requestAnimFrame(update);
}

function onResize() {
  width = sky.clientWidth;
  height = sky.clientHeight;
  canvas.width = width;
  canvas.height = height;
  ctx.fillStyle = '#FFF';

  var wasActive = active;
  active = width > 600;

  if (!wasActive && active) {
    requestAnimFrame(update);
  }
}

// shim layer with setTimeout fallback
window.requestAnimFrame = (function() {
  return  window.requestAnimationFrame       ||
          window.webkitRequestAnimationFrame ||
          window.mozRequestAnimationFrame    ||
          function( callback ){
            window.setTimeout(callback, 1000 / 60);
          };
})();

onResize();
window.addEventListener('resize', onResize, false);

sky.appendChild(canvas);

var gui = new dat.GUI();
gui.add(window, 'particleCount').min(1).max(particleMax).step(1).name('Particles count').onFinishChange(function() {
  requestAnimFrame(update);
});
</code>```

I've read about this and seen that it has to do with the document.querySelector('.modal'); the class defined but my aspx code has the same name so it shouldn't return null.

this is the code in the client side with the modal properly defined

```<code><head runat="server">
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
<%--        <link rel="stylesheet" href="Content/bootstrap.min.css" />--%>
      <link rel="stylesheet" type="text/css" href="Style/Site.css" />
    <link rel="stylesheet" href="Style/animate.min.css" />

     <script src="Scripts/jquery-1.9.1.min.js"></script>
    <script src="Scripts/bootstrap.min.js"></script>
            <script src="Script/query.js"></script>

</head>
<body>
  <div class="modal fade" id="myModal" tabindex="-1" role="dialog">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
            <div class="top-image">
              <img src="https://tutsplus.github.io/merry-christmas-web-app-build/images/xmas-tree.png" alt="" />
            </div>
            <h1 class="modal-title">I wish you</h4>
          </div>
          <div class="modal-body">
            <p>Merry Christmas and Happy Holidays!</p>
            <hr />
            <p>Its time to say "<span>Thank You!</span>"</p>
          </div>
          <div class="modal-footer">
            <div class="img-footer">
            </div>
          </div>
        </div><!-- /.modal-content -->
      </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
    </body>
</code>```

I got the code from this page "https://codepen.io/nunofidalgo/pen/zrYoVr"

Can anyone help please

Error i get from the consola

答:
The whole issue with this was the positioning of my scripts in the HTML page, i had to position it before closing the body tag and that solved the issue.
Thanks everyone for your help</p>

Body:
I'm having issues with Java Script with this code Not Answered.

Got it working in https://jsfiddle.net/p3kdbquh/2/ but not locally

  $('#myModal').modal('show');

var particleCount = 300;
var particleMax   = 1000;
var sky           = document.querySelector('.modal');
var canvas        = document.createElement('canvas');
var ctx           = canvas.getContext('2d');
var width         = sky.clientWidth; //THIS LINE
var height        = sky.clientHeight;
var i             = 0;
var active        = false;
var snowflakes    = [];
var snowflake;
canvas.style.position = 'absolute';
canvas.style.left = canvas.style.top = '0';

var Snowflake = function () {
  this.x = 0;
  this.y = 0;
  this.vy = 0;
  this.vx = 0;
  this.r = 0;

  this.reset();
};

Snowflake.prototype.reset = function() {
  this.x = Math.random() * width;
  this.y = Math.random() * -height;
  this.vy = 1 + Math.random() * 3;
  this.vx = 0.5 - Math.random();
  this.r = 1 + Math.random() * 2;
  this.o = 0.5 + Math.random() * 0.5;
};

function generateSnowFlakes() {
  snowflakes = [];
  for (i = 0; i < particleMax; i++) {
    snowflake = new Snowflake();
    snowflake.reset();
    snowflakes.push(snowflake);
  }
}

generateSnowFlakes();

function update() {
  ctx.clearRect(0, 0, width, height);

  if (!active) {
    return;
  }

  for (i = 0; i < particleCount; i++) {
    snowflake = snowflakes[i];
    snowflake.y += snowflake.vy;
    snowflake.x += snowflake.vx;

    ctx.globalAlpha = snowflake.o;
    ctx.beginPath();
    ctx.arc(snowflake.x, snowflake.y, snowflake.r, 0, Math.PI * 2, false);
    ctx.closePath();
    ctx.fill();

    if (snowflake.y > height) {
      snowflake.reset();
    }
  }

  requestAnimFrame(update);
}

function onResize() {
  width = sky.clientWidth;
  height = sky.clientHeight;
  canvas.width = width;
  canvas.height = height;
  ctx.fillStyle = '#FFF';

  var wasActive = active;
  active = width > 600;

  if (!wasActive && active) {
    requestAnimFrame(update);
  }
}

// shim layer with setTimeout fallback
window.requestAnimFrame = (function() {
  return  window.requestAnimationFrame       ||
          window.webkitRequestAnimationFrame ||
          window.mozRequestAnimationFrame    ||
          function( callback ){
            window.setTimeout(callback, 1000 / 60);
          };
})();

onResize();
window.addEventListener('resize', onResize, false);

sky.appendChild(canvas);

var gui = new dat.GUI();
gui.add(window, 'particleCount').min(1).max(particleMax).step(1).name('Particles count').onFinishChange(function() {
  requestAnimFrame(update);
});

I've read about this and seen that it has to do with the document.querySelector('.modal'); the class defined but my aspx code has the same name so it shouldn't return null.

this is the code in the client side with the modal properly defined

        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
<%--        <link rel="stylesheet" href="Content/bootstrap.min.css" />--%>
      <link rel="stylesheet" type="text/css" href="Style/Site.css" />
    <link rel="stylesheet" href="Style/animate.min.css" />

            <button type="button" class="close" data-dismiss="modal" aria-label="Close">×</button>

I wish you

Merry Christmas and Happy Holidays!

Its time to say "Thank You!"

I got the code from this page "https://codepen.io/nunofidalgo/pen/zrYoVr"

Can anyone help please

Error i get from the consola


问:
How to execute an insert stored procedure using PDO and PHP form variables?
Good Evening All,

I'm very new to PDO prepared statements and need some guidance/gentle nudges.  I've created the following MySQL stored procedure:

```<code>-- --------------------------------------------------------------------------------
-- Routine DDL
-- --------------------------------------------------------------------------------
DELIMITER $$

CREATE DEFINER=`root`@`%` PROCEDURE `RegInsert`(
IN p_regid int,
IN p_username VARCHAR(45),
IN p_password VARCHAR(45),
IN p_confpassword VARCHAR(45),
IN p_status INT(1),
IN p_salutation VARCHAR(45),
IN p_firstname VARCHAR(45),
IN p_lastname VARCHAR(45),
IN p_jobtitle VARCHAR(45),
IN p_telephone VARCHAR(45),
IN p_companyname VARCHAR(45),
IN p_industry VARCHAR(45),
IN p_address VARCHAR(45),
IN p_city VARCHAR(45),
IN p_state VARCHAR(45),
IN p_country VARCHAR(45),
IN p_postalcode VARCHAR(45),
IN p_regtype VARCHAR(45),
IN p_interest VARCHAR(45),
IN p_hdsprovider VARCHAR(45)
)
BEGIN
Insert into regdata(
RegID,
UserName,
Password,
Confpassword,
Status,
Salutation,
FirstName,
LastName,
JobTitle,
Telephone,
Companyname,
Industry,
Address,
City,
Country,
State,
PostalCode,
RegType,
Interests,
HDSprovider
)
values(
p_regid,
p_username,
p_password,
p_confpassword,
p_status,
p_salutation,
p_firstname,
p_lastname,
p_jobtitle,
p_telephone,
p_companyname,
p_industry,
p_address,
p_city,
p_country,
p_state,
p_postalcode,
p_regtype,
p_interest,
p_hdsprovider
);
END
</code>```

In reading the documentation on PDO, I understand that the following statement is used to open the connection and the try catch block sets the parameters.  That's where I'm getting confused.  Here's my code block thus far:

```<code><?php
require once ("/home/somedir/pdo_connect.php")
try{
$dbh=pdo_connect.php();
$stmt = $dbh->prepare("CALL RegInsert(?)");
$stmt->bindParam
}
catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
?>
</code>```

Questions:

1.  What is the correct syntax for associating my procedure input parameters with my PHP form variables?  Is it something like:

```<code>$_Post['salutation'] = p_salutation
</code>```

Reginsert.php contains the above PDO statements.  How do I call it from my submit button on the form?

Do you suggest creating a separate file and container function for the confirmation email?  If so, how do I trigger that file to run after reginsert.php runs without errors?

Thanks so much for helping this sleep-deprived newbie.  It's much appreciated!!

EDIT:

Here's the revised code for reginsert.php.  When I provide valid form data and press submit, a record is not inserted into the database.  Can you steer me in the right direction?

```<code><?php
require once ("/home/mydir/pdo_connect.php")
try{
$dbh=pdo_connect.php();
$stmt = $dbh->prepare('CALL RegInsert(?)');
$stmt->bindParam(':p_username',$email_address,PDO::PARAM_STR,45);
$stmt->bindParam(':p_password',$create_password,PDO::PARAM_STR,45);
$stmt->bindParam(':p_confpassword',$confirm_password,PDO::PARAM_STR,45);
$stmt->bindParam(':p_salutation',$salutation2,PDO::PARAM_STR,45);
$stmt->bindParam(':p_firstname',$first_name,PDO::PARAM_STR,45);
$stmt->bindParam(':p_lastname',$last_name,PDO::PARAM_STR,45);
$stmt->bindParam(':p_jobtitle',$job_title,PDO::PARAM_STR,45);
$stmt->bindParam(':p_telephone',$telephone,PDO::PARAM_STR,45);
$stmt->bindParam(':p_companyname',$company_name,PDO::PARAM_STR,45);
$stmt->bindParam(':p_industry',$industry,PDO::PARAM_STR,45);
$stmt->bindParam(':p_address',$address,PDO::PARAM_STR,45);
$stmt->bindParam(':p_city',$city,PDO::PARAM_STR,45);
$stmt->bindParam(':p_state',$state,PDO::PARAM_STR,45);
$stmt->bindParam(':p_country',$country,PDO::PARAM_STR,45);
$stmt->bindParam(':p_postalcode',$postal_code,PDO::PARAM_STR,45);
$stmt->bindParam(':p_regtype',$partner_customer_other,PDO::PARAM_STR,45);
$stmt->bindParam(':p_interest',$interests,PDO::PARAM_STR,45);
$stmt->bindParam(':p_hdsprovider',$provider_partner,PDO::PARAM_STR,45);
$stmt->bindParam(':p_passwordremindquestion',$password_reminder_question,PDO::PARAM_STR,45);
$stmt->bindParam(':p_passwordremindanswer',$password_reminder_answer,PDO::PARAM_STR,45);
$stmt->execute();
}
catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
?>
</code>```

答:
I came here looking for advice (found on google.) Before I even tested mine, however, I could see that you are not only using one place-holder (the ? mark) for your query (the routine call) but you are also trying to send named parameters to that.

Your code should probably look more like this

```<code>$stmt = $dbh->prepare('CALL RegInsert(:p_username, :p_password, :p_confpassword[, ...])');
$stmt->bindParam(':p_username',$email_address,PDO::PARAM_STR,45);
$stmt->bindParam(':p_password',$create_password,PDO::PARAM_STR,45);
$stmt->bindParam(':p_confpassword',$confirm_password,PDO::PARAM_STR,45);
// ...
</code>```

I only had one parameter for my routine, but it worked using the named variation (possibly a little over-kill for me.)

Body:
Good Evening All,

I'm very new to PDO prepared statements and need some guidance/gentle nudges.  I've created the following MySQL stored procedure:

-- --------------------------------------------------------------------------------
-- Routine DDL
-- --------------------------------------------------------------------------------
DELIMITER $$

CREATE DEFINER=`root`@`%` PROCEDURE `RegInsert`(
IN p_regid int,
IN p_username VARCHAR(45),
IN p_password VARCHAR(45),
IN p_confpassword VARCHAR(45),
IN p_status INT(1),
IN p_salutation VARCHAR(45),
IN p_firstname VARCHAR(45),
IN p_lastname VARCHAR(45),
IN p_jobtitle VARCHAR(45),
IN p_telephone VARCHAR(45),
IN p_companyname VARCHAR(45),
IN p_industry VARCHAR(45),
IN p_address VARCHAR(45),
IN p_city VARCHAR(45),
IN p_state VARCHAR(45),
IN p_country VARCHAR(45),
IN p_postalcode VARCHAR(45),
IN p_regtype VARCHAR(45),
IN p_interest VARCHAR(45),
IN p_hdsprovider VARCHAR(45)
)
BEGIN
Insert into regdata(
RegID,
UserName,
Password,
Confpassword,
Status,
Salutation,
FirstName,
LastName,
JobTitle,
Telephone,
Companyname,
Industry,
Address,
City,
Country,
State,
PostalCode,
RegType,
Interests,
HDSprovider
)
values(
p_regid,
p_username,
p_password,
p_confpassword,
p_status,
p_salutation,
p_firstname,
p_lastname,
p_jobtitle,
p_telephone,
p_companyname,
p_industry,
p_address,
p_city,
p_country,
p_state,
p_postalcode,
p_regtype,
p_interest,
p_hdsprovider
);
END

In reading the documentation on PDO, I understand that the following statement is used to open the connection and the try catch block sets the parameters.  That's where I'm getting confused.  Here's my code block thus far:

<?php
require once ("/home/somedir/pdo_connect.php")
try{
$dbh=pdo_connect.php();
$stmt = $dbh->prepare("CALL RegInsert(?)");
$stmt->bindParam
}
catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "
";
die();
}
?>

Questions:

1.  What is the correct syntax for associating my procedure input parameters with my PHP form variables?  Is it something like:

$_Post['salutation'] = p_salutation

Reginsert.php contains the above PDO statements.  How do I call it from my submit button on the form?

Do you suggest creating a separate file and container function for the confirmation email?  If so, how do I trigger that file to run after reginsert.php runs without errors?

Thanks so much for helping this sleep-deprived newbie.  It's much appreciated!!

EDIT:

Here's the revised code for reginsert.php.  When I provide valid form data and press submit, a record is not inserted into the database.  Can you steer me in the right direction?

<?php
require once ("/home/mydir/pdo_connect.php")
try{
$dbh=pdo_connect.php();
$stmt = $dbh->prepare('CALL RegInsert(?)');
$stmt->bindParam(':p_username',$email_address,PDO::PARAM_STR,45);
$stmt->bindParam(':p_password',$create_password,PDO::PARAM_STR,45);
$stmt->bindParam(':p_confpassword',$confirm_password,PDO::PARAM_STR,45);
$stmt->bindParam(':p_salutation',$salutation2,PDO::PARAM_STR,45);
$stmt->bindParam(':p_firstname',$first_name,PDO::PARAM_STR,45);
$stmt->bindParam(':p_lastname',$last_name,PDO::PARAM_STR,45);
$stmt->bindParam(':p_jobtitle',$job_title,PDO::PARAM_STR,45);
$stmt->bindParam(':p_telephone',$telephone,PDO::PARAM_STR,45);
$stmt->bindParam(':p_companyname',$company_name,PDO::PARAM_STR,45);
$stmt->bindParam(':p_industry',$industry,PDO::PARAM_STR,45);
$stmt->bindParam(':p_address',$address,PDO::PARAM_STR,45);
$stmt->bindParam(':p_city',$city,PDO::PARAM_STR,45);
$stmt->bindParam(':p_state',$state,PDO::PARAM_STR,45);
$stmt->bindParam(':p_country',$country,PDO::PARAM_STR,45);
$stmt->bindParam(':p_postalcode',$postal_code,PDO::PARAM_STR,45);
$stmt->bindParam(':p_regtype',$partner_customer_other,PDO::PARAM_STR,45);
$stmt->bindParam(':p_interest',$interests,PDO::PARAM_STR,45);
$stmt->bindParam(':p_hdsprovider',$provider_partner,PDO::PARAM_STR,45);
$stmt->bindParam(':p_passwordremindquestion',$password_reminder_question,PDO::PARAM_STR,45);
$stmt->bindParam(':p_passwordremindanswer',$password_reminder_answer,PDO::PARAM_STR,45);
$stmt->execute();
}
catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "
";
die();
}
?>

Body:
I came here looking for advice (found on google.) Before I even tested mine, however, I could see that you are not only using one place-holder (the ? mark) for your query (the routine call) but you are also trying to send named parameters to that.

Your code should probably look more like this

$stmt = $dbh->prepare('CALL RegInsert(:p_username, :p_password, :p_confpassword[, ...])');
$stmt->bindParam(':p_username',$email_address,PDO::PARAM_STR,45);
$stmt->bindParam(':p_password',$create_password,PDO::PARAM_STR,45);
$stmt->bindParam(':p_confpassword',$confirm_password,PDO::PARAM_STR,45);
// ...

I only had one parameter for my routine, but it worked using the named variation (possibly a little over-kill for me.)


问:
Setting CustomComponent(TEDIT) MaxLength Property not working
I have created a new component which is derived from TEdit. In the below code, I am setting MaxLength Property to 10 after setting AllowValues to true.

I set the component on form and set the AllowValues to true and run the application and edit box is allowing more than 10 characters. whats wrong with my code?

```<code>unit DummyEdit;

interface

uses
  SysUtils, Classes, Controls, StdCtrls,Dialogs,Windows,Messages;

type
  TDUMMYEdit = class(TEdit)
  private
    { Private declarations }
    FAllowValues : Boolean;
    FMaxLength: Integer;
    Procedure SetAllowValues(Value : Boolean);
    procedure SetMaxLength(Value: Integer);
  protected
    { Protected declarations }
  public
    { Public declarations }
  published
    { Published declarations }
    Property AllowValues : Boolean read FAllowValues write SetAllowValues;
    property MaxLength: Integer read FMaxLength write SetMaxLength default 0;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('DUMMY', [TDUMMYEdit]);
end;

{ TDUMMYEdit }

procedure TDUMMYEdit.SetAllowValues(Value: Boolean);
begin
  if FAllowValues <> value then
    FAllowValues := Value;
  if FAllowValues then
    MaxLength := 10
  else
    MaxLength := 0;
end;

procedure TDUMMYEdit.SetMaxLength(Value: Integer);
begin
  if FMaxLength <> Value then
  begin
    FMaxLength := Value;
    if HandleAllocated then SendMessage(Handle, EM_LIMITTEXT, Value, 0);
  end;
end;

end.
</code>```

答:
Working on an answer I realized that you re-invented the MaxLength property for your custom edit. Was that your intention? Unless I'm mistaken all that currently differs is that you accidentally introduced the bug that is topic of this question. Your code should work if you hadn't introduced that property.

So one way to solve your issue is to remove the MaxLength property from TDUMMYEdit, instead rely on the one TCustomEdit implements.

Your issue is that when your code takes effect during component streaming from DFM, no Handle is allocated, HandleAllocated returns False and your EM_LIMITTEXT message will not be sent. Setting the AllowValues property later on, e.g. in an event handler of your form, would work as you'd expect, as at that time, a handle is allocated.

A way to fix this can be found looking atTCustomEdit in Vcl.StdCtrls - code you might have taken as example, it looks very similar - the procedure DoSetMaxLength - which will send the same message you are trying to send - will also be called in TCustomEdit.CreateWnd, at a time where there is a valid Handle created. A fix for your code would then look like this:

```<code>  TDUMMYEdit = class(TEdit)
  private
    { Private declarations }
    FAllowValues : Boolean;
    FMaxLength: Integer;
    Procedure SetAllowValues(Value : Boolean);
    procedure SetMaxLength(Value: Integer);
  protected
    { Protected declarations }
    procedure CreateWnd; override;
  public
    { Public declarations }
  published
    { Published declarations }
    Property AllowValues : Boolean read FAllowValues write SetAllowValues;
    property MaxLength: Integer read FMaxLength write SetMaxLength default 0;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('DUMMY', [TDUMMYEdit]);
end;

{ TDUMMYEdit }

...
procedure TDUMMYEdit.CreateWnd;
begin
  inherited CreateWnd;
  SendMessage(Handle, EM_LIMITTEXT, FMaxLength, 0);
end;
...
</code>```

Body:
I have created a new component which is derived from TEdit. In the below code, I am setting MaxLength Property to 10 after setting AllowValues to true.

I set the component on form and set the AllowValues to true and run the application and edit box is allowing more than 10 characters. whats wrong with my code?

unit DummyEdit;

interface

uses
  SysUtils, Classes, Controls, StdCtrls,Dialogs,Windows,Messages;

type
  TDUMMYEdit = class(TEdit)
  private
    { Private declarations }
    FAllowValues : Boolean;
    FMaxLength: Integer;
    Procedure SetAllowValues(Value : Boolean);
    procedure SetMaxLength(Value: Integer);
  protected
    { Protected declarations }
  public
    { Public declarations }
  published
    { Published declarations }
    Property AllowValues : Boolean read FAllowValues write SetAllowValues;
    property MaxLength: Integer read FMaxLength write SetMaxLength default 0;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('DUMMY', [TDUMMYEdit]);
end;

{ TDUMMYEdit }

procedure TDUMMYEdit.SetAllowValues(Value: Boolean);
begin
  if FAllowValues <> value then
    FAllowValues := Value;
  if FAllowValues then
    MaxLength := 10
  else
    MaxLength := 0;
end;

procedure TDUMMYEdit.SetMaxLength(Value: Integer);
begin
  if FMaxLength <> Value then
  begin
    FMaxLength := Value;
    if HandleAllocated then SendMessage(Handle, EM_LIMITTEXT, Value, 0);
  end;
end;

end.

Body:
Working on an answer I realized that you re-invented the MaxLength property for your custom edit. Was that your intention? Unless I'm mistaken all that currently differs is that you accidentally introduced the bug that is topic of this question. Your code should work if you hadn't introduced that property.

So one way to solve your issue is to remove the MaxLength property from TDUMMYEdit, instead rely on the one TCustomEdit implements.

Your issue is that when your code takes effect during component streaming from DFM, no Handle is allocated, HandleAllocated returns False and your EM_LIMITTEXT message will not be sent. Setting the AllowValues property later on, e.g. in an event handler of your form, would work as you'd expect, as at that time, a handle is allocated.

A way to fix this can be found looking atTCustomEdit in Vcl.StdCtrls - code you might have taken as example, it looks very similar - the procedure DoSetMaxLength - which will send the same message you are trying to send - will also be called in TCustomEdit.CreateWnd, at a time where there is a valid Handle created. A fix for your code would then look like this:

  TDUMMYEdit = class(TEdit)
  private
    { Private declarations }
    FAllowValues : Boolean;
    FMaxLength: Integer;
    Procedure SetAllowValues(Value : Boolean);
    procedure SetMaxLength(Value: Integer);
  protected
    { Protected declarations }
    procedure CreateWnd; override;
  public
    { Public declarations }
  published
    { Published declarations }
    Property AllowValues : Boolean read FAllowValues write SetAllowValues;
    property MaxLength: Integer read FMaxLength write SetMaxLength default 0;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('DUMMY', [TDUMMYEdit]);
end;

{ TDUMMYEdit }

...
procedure TDUMMYEdit.CreateWnd;
begin
  inherited CreateWnd;
  SendMessage(Handle, EM_LIMITTEXT, FMaxLength, 0);
end;
...


问:
Resize view to fit superview after transform
I have a innerview within a view, I have pinned innerview to view using autolayout.
Now I am rotating innerview using transform

```<code>self.innerView.transform = CGAffineTransform(rotationAngle: CGFloat(M_PI_2))
</code>```

After transform, innerview is showing outside.

How can I fit innerview to view after transform means innerview should not go beyond view.

Please have a look at attached images.

答:
To fit innerview into outterview Increase height constraint of your outer view while you transform inner view

```<code>self.innerView.transform = CGAffineTransform(rotationAngle: CGFloat(M_PI_2))

self.outterViewHgtConst.constant = self.innerView.frame.height+40
</code>```

Hope this will help you

Body:
I have a innerview within a view, I have pinned innerview to view using autolayout.
Now I am rotating innerview using transform

self.innerView.transform = CGAffineTransform(rotationAngle: CGFloat(M_PI_2))

After transform, innerview is showing outside.

How can I fit innerview to view after transform means innerview should not go beyond view.

Please have a look at attached images.

Body:
To fit innerview into outterview Increase height constraint of your outer view while you transform inner view

self.innerView.transform = CGAffineTransform(rotationAngle: CGFloat(M_PI_2))

self.outterViewHgtConst.constant = self.innerView.frame.height+40

Hope this will help you