问:
PDFBox: Unable to save pdf while running on tomcat
This PDFBOX Example when i run from the main method & run java application then it successfully saving pdf document. But if the same code while running from  doGet method of servlet on Tomcat server, then its NOT saving the pdf file. Very confuse can you help me why? do i have to add some external libarary to support for Tomcat server, please help..

Note :

i have debugged doGet method its getting call not throuwing any

exception Tomcat 6, PDFBox 1.87, all PDFbox dependecies i have
included in classpath

```<code>/* this is the servlet method which is saving pdf file, but the same if run from Main then it saves the "hello world.pdf"*/
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException {
      try {
          PDDocument  document = new PDDocument();
             PDPage page = new PDPage();
             document.addPage( page );
             // Create a new font object selecting one of the PDF base fonts
             PDFont font = PDType1Font.HELVETICA_BOLD;
             // Start a new content stream which will "hold" the to be created content
             PDPageContentStream contentStream = new PDPageContentStream(document, page);
             // Define a text content stream using the selected font, moving the cursor and drawing the text "Hello World"
             contentStream.beginText();
             contentStream.setFont( font, 12 );
             contentStream.moveTextPositionByAmount( 100, 700 );
             contentStream.drawString( "Hello World1" );
             contentStream.endText();
             // Make sure that the content stream is closed:
             contentStream.close();
             // Save the results and ensure that the document is properly closed:
             document.save( "Hello World.pdf");

             document.close();

             response.setContentType("text/html");
          PrintWriter out = response.getWriter();
              out.println("<iframe height=\"100%\"   width=\"100%\" src=\"http://eurecaproject.eu/files/4613/9886/3802/report3.pdf\" ></iframe>");

    } catch (Exception e) {
        // TODO Auto-generated catch block

        System.out.println(e);
    }

}
</code>```

答:
Here is the example code: Sorry I am little bit busy so I can't test your code right now, but I am sure this will help you. Just add few lines while call doGet() or doPost() just check once what I am using. I spent many hours to find this solution. It will definitely work. If it won't work, please let me know.

I hope that you have already downloaded the pdfbox jar, so then you can import classes by default.

```<code>//you can use servlet to create pdf

@SuppressWarnings("javadoc")

public class Billing extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {

    private static final long serialVersionUID = 1L;

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        performTask(request, response);
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,
            IOException {
        performTask(request, response);
    }

    private void performTask(HttpServletRequest request, HttpServletResponse response) throws ServletException,
            IOException {

            //Create pdf
            PDDocument document = new PDDocument();

            //Create Page
            PDPage page = new PDPage();

            //Adding the page
            document.addPage(page);

           //Loading the page
           File file = new File("D:/akash/my_doc.pdf");
           //writing text
           contentStream.beginText();
           contentStream.newLineAtOffset(295, 757);
           contentStream.setFont(PDType1Font.HELVETICA_BOLD, 12);
           contentStream.showText("CHIMERA TRANSPLANT RESEARCH FOUNDATION");
           contentStream.endText();

           //Saving the document
           document.save("D:/akash/my_doc.pdf");

           //Closing the document
            document.close();
   }
}
</code>```

Body:
This PDFBOX Example when i run from the main method & run java application then it successfully saving pdf document. But if the same code while running from  doGet method of servlet on Tomcat server, then its NOT saving the pdf file. Very confuse can you help me why? do i have to add some external libarary to support for Tomcat server, please help..

Note :

i have debugged doGet method its getting call not throuwing any

exception Tomcat 6, PDFBox 1.87, all PDFbox dependecies i have
included in classpath

/* this is the servlet method which is saving pdf file, but the same if run from Main then it saves the "hello world.pdf"*/
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException {
      try {
          PDDocument  document = new PDDocument();
             PDPage page = new PDPage();
             document.addPage( page );
             // Create a new font object selecting one of the PDF base fonts
             PDFont font = PDType1Font.HELVETICA_BOLD;
             // Start a new content stream which will "hold" the to be created content
             PDPageContentStream contentStream = new PDPageContentStream(document, page);
             // Define a text content stream using the selected font, moving the cursor and drawing the text "Hello World"
             contentStream.beginText();
             contentStream.setFont( font, 12 );
             contentStream.moveTextPositionByAmount( 100, 700 );
             contentStream.drawString( "Hello World1" );
             contentStream.endText();
             // Make sure that the content stream is closed:
             contentStream.close();
             // Save the results and ensure that the document is properly closed:
             document.save( "Hello World.pdf");

             document.close();

             response.setContentType("text/html");
          PrintWriter out = response.getWriter();
              out.println("");

    } catch (Exception e) {
        // TODO Auto-generated catch block

        System.out.println(e);
    }

}

Body:
Here is the example code: Sorry I am little bit busy so I can't test your code right now, but I am sure this will help you. Just add few lines while call doGet() or doPost() just check once what I am using. I spent many hours to find this solution. It will definitely work. If it won't work, please let me know.

I hope that you have already downloaded the pdfbox jar, so then you can import classes by default.

//you can use servlet to create pdf

@SuppressWarnings("javadoc")

public class Billing extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {

    private static final long serialVersionUID = 1L;

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        performTask(request, response);
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,
            IOException {
        performTask(request, response);
    }

    private void performTask(HttpServletRequest request, HttpServletResponse response) throws ServletException,
            IOException {

            //Create pdf
            PDDocument document = new PDDocument();

            //Create Page
            PDPage page = new PDPage();

            //Adding the page
            document.addPage(page);

           //Loading the page
           File file = new File("D:/akash/my_doc.pdf");
           //writing text
           contentStream.beginText();
           contentStream.newLineAtOffset(295, 757);
           contentStream.setFont(PDType1Font.HELVETICA_BOLD, 12);
           contentStream.showText("CHIMERA TRANSPLANT RESEARCH FOUNDATION");
           contentStream.endText();

           //Saving the document
           document.save("D:/akash/my_doc.pdf");

           //Closing the document
            document.close();
   }
}


来源: stackexchange

问:
What is an IIS application pool?
What exactly is an application pool?  What is its purpose?</p>

答:
I second the top voted answer, but feel like adding little more details here if anyone finds it useful.

short version:

IIS runs any website you configure in a process named w3wp.exe. IIS
Application pool is feature in IIS which allows each website or a part
of it to run under a corresponding w3wp.exe process. So you can run
100 websites all in a single w3wp.exe or 100 different w3wp.exe. E.g.
run 3 websites in same application pool(same w3wp.exe) to save memory
usage. ,run 2 different websites in two different application pools so
that each can run under separate user account(called application pool
identity). run a website in one application pool and a subsite
'website/app' under a different application pool.

Longer version:

Every website or a part of the website,you can run under an application pool.You can control some basic settings of the website using an application pool.

You would like the website to run under a different w3wp.exe process.Then create a new application pool and assign that to the website.

You would like to run the website and all it's code under a different user account(e.g under Admin privileges),you can run do that by changing Application Pool Identity.

You would like to run a particular application under .net framework 4.0 or 2.0.

You would like to make sure the website in 32 bit mode or have a scheduled recycle of the w3wp.exe process etc.All such things are controlled from iis application pool.

ContentLicense: CC BY-SA 2.5

Title: What is an IIS application pool?

ContentLicense: CC BY-SA 4.0


问:
R installed.packages() randomly stopped working on windows 7
installed.packages() command in R lists your installed packages.  Mine was working for almost a year and then this command randomly started throwing an error.  As this is a built-in command, I am not even sure how to "reinstall" it or address this.  Any ideas how to fix the error and get the command working again?

```<code>> installed.packages()
Error in gzfile(file, mode) : cannot open the connection
In addition: Warning message:
In gzfile(file, mode) :
  cannot open compressed file `'C:\Users\Mitch\AppData\Local\Temp\Rtmp6Dawpa/libloc_190_4464fd2b.rds', probable reason 'No such file or directory'`
</code>```

One suggestion on here involved this in combination:

.libPaths()

installed.packages(lib.loc = 'my path')

The results of this produced yet another error as shown here.  Looks like an issue with the installed file still but how to address is the question:

```<code>> installed.packages(lib.loc = 'C:/ProgramFilesCoders/R/R-3.3.2/library')
Error in gzfile(file, mode) : cannot open the connection
In addition: Warning message:
In gzfile(file, mode) :
  cannot open compressed file 'C:\Users\Mitch\AppData\Local\Temp\Rtmp6Dawpa/libloc_190_4464fd2b.rds', probable reason 'No such file or directory'
>
</code>```

答:
That is odd.

What version of R are you running, standard R or Microsoft R? And did you recently update?

If you did recently update, perhaps your packages did not get copied over, hence the 'No such file or directory' statement.

If you haven't updated, I would install a newer version and see if it fixes the issue.

If your uncertain, you can always use the updateR function to check if you have the latest version and choose to install it or not.

```<code>library(installr)
updateR()
</code>```

Good luck,

ContentLicense: CC BY-SA 3.0

Body:
installed.packages() command in R lists your installed packages.  Mine was working for almost a year and then this command randomly started throwing an error.  As this is a built-in command, I am not even sure how to "reinstall" it or address this.  Any ideas how to fix the error and get the command working again?

> installed.packages()
Error in gzfile(file, mode) : cannot open the connection
In addition: Warning message:
In gzfile(file, mode) :
  cannot open compressed file `'C:\Users\Mitch\AppData\Local\Temp\Rtmp6Dawpa/libloc_190_4464fd2b.rds', probable reason 'No such file or directory'`

One suggestion on here involved this in combination:

.libPaths()

installed.packages(lib.loc = 'my path')

The results of this produced yet another error as shown here.  Looks like an issue with the installed file still but how to address is the question:

> installed.packages(lib.loc = 'C:/ProgramFilesCoders/R/R-3.3.2/library')
Error in gzfile(file, mode) : cannot open the connection
In addition: Warning message:
In gzfile(file, mode) :
  cannot open compressed file 'C:\Users\Mitch\AppData\Local\Temp\Rtmp6Dawpa/libloc_190_4464fd2b.rds', probable reason 'No such file or directory'
>

Body:
That is odd.

What version of R are you running, standard R or Microsoft R? And did you recently update?

If you did recently update, perhaps your packages did not get copied over, hence the 'No such file or directory' statement.

If you haven't updated, I would install a newer version and see if it fixes the issue.

If your uncertain, you can always use the updateR function to check if you have the latest version and choose to install it or not.

library(installr)
updateR()

Good luck,


问:
Performance of Java enums
I was thinking about using enum type to manage i18n in a Java game I'm developing but I was curious about performance issues that can occur when working with enums that have lots of elements (thousands I think).

Actually I'm trying something like:

```<code>public enum Text {
  STRING1,
  STRING2,
  STRING3;

  public String text() {
    return text;
  }

  public String setText() {
    this.text = text;
  }
}
</code>```

Then to load them I can just fill the fields:

```<code>static
{
  Text.STRING1.setText("My localized string1");
  Text.STRING2.setText("My localized string2");
  Text.STRING3.setText("My localized string3");
}
</code>```

Of course when I'll have to manage many languages I'll load them from a file.

What I'm asking is

is an obect allocated (in addition to the string) for every element? (I guess yes, since enums are implemented with objects)

how is the right element retrieved from the enum? is it static at compile time? (I mean when somewhere I use Text.STRING1.text()). So it should be constant complexity or maybe they are just replaced during the compiling phase..

in general, is it a good approach or should I look forward something else?

Thanks

答:
Found and adapted a nice mix of enums and ResourceBundle:

```<code>public enum Text {
  YELL, SWEAR, BEG, GREET /* and more */ ;

  /** Resources for the default locale */
  private static final ResourceBundle res =
    ResourceBundle.getBundle("com.example.Messages");

  /** @return the locale-dependent message */
  public String toString() {
    return res.getString(name() + ".string");
  }
}
</code>```

```<code># File com/example/Messages.properties
# default language (english) resources
YELL.string=HEY!
SWEAR.string=§$%&
BEG.string=Pleeeeeease!
GREET.string=Hello player!
</code>```

```<code># File com/example/Messages_de.properties
# german language resources
YELL.string=HEY!
SWEAR.string=%&$§
BEG.string=Biiiiiitte!
GREET.string=Hallo Spieler!
</code>```

Title: Performance of Java enums

Body:
I was thinking about using enum type to manage i18n in a Java game I'm developing but I was curious about performance issues that can occur when working with enums that have lots of elements (thousands I think).

Actually I'm trying something like:

public enum Text {
  STRING1,
  STRING2,
  STRING3;

  public String text() {
    return text;
  }

  public String setText() {
    this.text = text;
  }
}

Then to load them I can just fill the fields:

static
{
  Text.STRING1.setText("My localized string1");
  Text.STRING2.setText("My localized string2");
  Text.STRING3.setText("My localized string3");
}

Of course when I'll have to manage many languages I'll load them from a file.

What I'm asking is

is an obect allocated (in addition to the string) for every element? (I guess yes, since enums are implemented with objects)

how is the right element retrieved from the enum? is it static at compile time? (I mean when somewhere I use Text.STRING1.text()). So it should be constant complexity or maybe they are just replaced during the compiling phase..

in general, is it a good approach or should I look forward something else?

Thanks

Body:
Found and adapted a nice mix of enums and ResourceBundle:

public enum Text {
  YELL, SWEAR, BEG, GREET /* and more */ ;

  /** Resources for the default locale */
  private static final ResourceBundle res =
    ResourceBundle.getBundle("com.example.Messages");

  /** @return the locale-dependent message */
  public String toString() {
    return res.getString(name() + ".string");
  }
}

# File com/example/Messages.properties
# default language (english) resources
YELL.string=HEY!
SWEAR.string=§$%&
BEG.string=Pleeeeeease!
GREET.string=Hello player!

# File com/example/Messages_de.properties
# german language resources
YELL.string=HEY!
SWEAR.string=%&$§
BEG.string=Biiiiiitte!
GREET.string=Hallo Spieler!


问:
Combine 2 arrays into 1 in all possible ways in JavaScript
My goal is to merge 2 arrays in all possible ways, in a way that, the 1st array will always be the first part of the cell, and the 2nd array will always be in the 2nd part of the cell.

My last attempt, which is the closest but not exactly what I need:

```<code>function combineArrays(array1, array2) {
    let arr = [];
    for (let i = 0; i < array1.length; i++) {
        arr[i] = array1[i];
    }
    for (let i = 0, j = 0; i < array1.length; i++) {
        arr[i] += array2[j];
        if (array2[j + 1]) {
            j++;
        }
        else {
            j = 0;
        }
    }
    return arr;
}
</code>```

Edit:

For example, array A and array B:

A: [ "I", "You", "He", "She" ]

B: [ "am", "is", "are" ]

Expected result:

[

"I am", "You am", "He am", "She am",

"I is", "You is', "He is", "She is",

"I are", "You are", "He are", "She are"

]

答:
let a = ["I", "You", "He", "She"];
let b = ["am", "is", "are"];
let result = b.map(b => a.map(a => a + ' ' + b));

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

<p>If you don't want the nested arrays:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>let a = ["I", "You", "He", "She"];
let b = ["am", "is", "are"];
let result = b.reduce((arr, b) => arr.concat(a.map(a => a + ' ' + b)), []);

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

For n amount of arrays:

    let a = ["I", "You", "He", "She"];
    let b = ["am", "is", "are"];
    let c = ["good", "bad", "happy"];
    let crossProduct = (a, b) => b.reduce((arr, b) => arr.concat(a.map(a => a + ' ' + b)), []);

    let result = [a, b, c].reduce(crossProduct);

    console.log(result);```

Body:
My goal is to merge 2 arrays in all possible ways, in a way that, the 1st array will always be the first part of the cell, and the 2nd array will always be in the 2nd part of the cell.

My last attempt, which is the closest but not exactly what I need:

function combineArrays(array1, array2) {
    let arr = [];
    for (let i = 0; i < array1.length; i++) {
        arr[i] = array1[i];
    }
    for (let i = 0, j = 0; i < array1.length; i++) {
        arr[i] += array2[j];
        if (array2[j + 1]) {
            j++;
        }
        else {
            j = 0;
        }
    }
    return arr;
}

Edit:

For example, array A and array B:

A: [ "I", "You", "He", "She" ]

B: [ "am", "is", "are" ]

Expected result:

[

"I am", "You am", "He am", "She am",

"I is", "You is', "He is", "She is",

"I are", "You are", "He are", "She are"

]

Body:
let a = ["I", "You", "He", "She"];
let b = ["am", "is", "are"];
let result = b.map(b => a.map(a => a + ' ' + b));

console.log(result);

If you don't want the nested arrays:

let a = ["I", "You", "He", "She"];
let b = ["am", "is", "are"];
let result = b.reduce((arr, b) => arr.concat(a.map(a => a + ' ' + b)), []);

console.log(result);

For n amount of arrays:

    let a = ["I", "You", "He", "She"];
    let b = ["am", "is", "are"];
    let c = ["good", "bad", "happy"];
    let crossProduct = (a, b) => b.reduce((arr, b) => arr.concat(a.map(a => a + ' ' + b)), []);

    let result = [a, b, c].reduce(crossProduct);

    console.log(result);


问:
Convert string into slug with single-hyphen delimiters only
I would  like to sanitize a string in to a URL so this is what I basically need:

Everything must be removed except alphanumeric characters and spaces and dashed.

Spaces should be converter into dashes.

Eg.

```<code>This, is the URL!
</code>```

must return

```<code>this-is-the-url
</code>```

答:
All previous asnwers deal with url, but in case some one will need to sanitize string for login (e.g.) and keep it as text, here is you go:</p>

```<code>function sanitizeText($str) {
    $withSpecCharacters = htmlspecialchars($str);
    $splitted_str = str_split($str);
    $result = '';
    foreach ($splitted_str as $letter){
        if (strpos($withSpecCharacters, $letter) !== false) {
            $result .= $letter;
        }
    }
    return $result;
}

echo sanitizeText('ОРРииыфвсси ajvnsakjvnHB "&nvsp;\n" <script>alert()</script>');
//ОРРииыфвсси ajvnsakjvnHB &nvsp;\n scriptalert()/script
//No injections possible, all info at max keeped
</code>```

Body:
I would  like to sanitize a string in to a URL so this is what I basically need:

Everything must be removed except alphanumeric characters and spaces and dashed.

Spaces should be converter into dashes.

Eg.

This, is the URL!

must return

this-is-the-url

Body:
All previous asnwers deal with url, but in case some one will need to sanitize string for login (e.g.) and keep it as text, here is you go:

function sanitizeText($str) {
    $withSpecCharacters = htmlspecialchars($str);
    $splitted_str = str_split($str);
    $result = '';
    foreach ($splitted_str as $letter){
        if (strpos($withSpecCharacters, $letter) !== false) {
            $result .= $letter;
        }
    }
    return $result;
}

echo sanitizeText('ОРРииыфвсси ajvnsakjvnHB "&nvsp;\n" <script>alert()</script>');
//ОРРииыфвсси ajvnsakjvnHB &nvsp;\n scriptalert()/script
//No injections possible, all info at max keeped


问:
How to set column width in Kendo Grid
I have to set some fixed column width in Kendo Grid which has no column headers.That means I get data simlar to below with single column "foo_data" and am hiding this column header and showing in the kendo Grid as is.The columns and rows in the Grid are dynamic ie.in the below example there are 9  columns  and 6 rows sometimes I may get 3 columns and 5 rows. I am using Kendo Ui,Angularjs and bootstrap frameworks.I want more space between columns in the Grid.How can I achieve this ? Any help would be highly appreciated.

```<code>var foo_data= [{"1 AAA BBB CCC 44444444444444444 555555555555555555 67777777777777777 333333333333333  99999999999"},
               "2  AAA BBB CCC 44444444444444444 555555555555555555 67777777777777777 333333333333333  99999999999"},
               "3  AAA BBB CCC 44444444444444444 555555555555555555 67777777777777777 333333333333333  99999999999"},
               "4  AAA BBB CCC 44444444444444444 555555555555555555 67777777777777777 333333333333333  99999999999"},
               "5  AAA BBB CCC 44444444444444444 555555555555555555 67777777777777777 333333333333333  99999999999"},
               "6  AAA BBB CCC 44444444444444444 555555555555555555 67777777777777777 333333333333333  99999999999"}];
</code>```

Hiding column header in the Kendo Grid:

```<code>columns: [{
    field: "foo_data",
    headerAttributes: {
           style: "display; none"
    }
</code>```

答:
You can use the width in column array in kendo grid. Look at the below code.

 columns: [{
        field: "foo_data",
        headerAttributes: {
               style: "display; none"
        },
        width: 175
```

the width is in pixels.it will increase the column width to 175 pixels

Title: How to set column width in Kendo Grid

Body:
I have to set some fixed column width in Kendo Grid which has no column headers.That means I get data simlar to below with single column "foo_data" and am hiding this column header and showing in the kendo Grid as is.The columns and rows in the Grid are dynamic ie.in the below example there are 9  columns  and 6 rows sometimes I may get 3 columns and 5 rows. I am using Kendo Ui,Angularjs and bootstrap frameworks.I want more space between columns in the Grid.How can I achieve this ? Any help would be highly appreciated.

var foo_data= [{"1 AAA BBB CCC 44444444444444444 555555555555555555 67777777777777777 333333333333333  99999999999"},
               "2  AAA BBB CCC 44444444444444444 555555555555555555 67777777777777777 333333333333333  99999999999"},
               "3  AAA BBB CCC 44444444444444444 555555555555555555 67777777777777777 333333333333333  99999999999"},
               "4  AAA BBB CCC 44444444444444444 555555555555555555 67777777777777777 333333333333333  99999999999"},
               "5  AAA BBB CCC 44444444444444444 555555555555555555 67777777777777777 333333333333333  99999999999"},
               "6  AAA BBB CCC 44444444444444444 555555555555555555 67777777777777777 333333333333333  99999999999"}];

Hiding column header in the Kendo Grid:

columns: [{
    field: "foo_data",
    headerAttributes: {
           style: "display; none"
    }

Body:
You can use the width in column array in kendo grid. Look at the below code.

 columns: [{
        field: "foo_data",
        headerAttributes: {
               style: "display; none"
        },
        width: 175

the width is in pixels.it will increase the column width to 175 pixels


答:
```<code>select `type`, date(`timestamp`) as the_date, count(*) as counter
from MyTable
group by `type`, date(`timestamp`)
</code>```

Title: Count number of rows in each day grouped by another field

Body:
For the purpose of drawing an activity chart, how can we count number of rows for each type (distinct field value) in each day?

Consider a table with a date field and a field for each type:

CREATE TABLE TableName
    (`PK` int, `type` varchar(1), `timestamp` datetime)
;

INSERT INTO TableName
    (`PK`, `type`, `timestamp`)
VALUES
    (11, 'Q', '2013-01-04 22:23:56'),
    (7, 'A', '2013-01-03 22:23:41'),
    (8, 'C', '2013-01-04 22:23:42'),
    (10, 'Q', '2013-01-05 22:23:56'),
    (5, 'C', '2013-01-03 22:23:25'),
    (12, 'Q', '2013-01-05 22:23:57'),
    (6, 'Q', '2013-01-07 22:23:40'),
    (4, 'Q', '2013-01-02 22:23:23'),
    (9, 'A', '2013-01-05 22:23:55'),
    (1, 'A', '2013-01-08 21:29:38'),
    (2, 'Q', '2013-01-02 21:31:59'),
    (3, 'C', '2013-01-04 21:32:22')
;

For example output can be (last field is the count of rows with that type and in that day):

'Q', 2013-01-04, 1
'C', 2013-01-04, 2
'A', 2013-01-03, 1
'C', 2013-01-03, 2
and so on...


问:
Use Flash Event System or build own Observer Design Pattern?
In this cookbook someone advocates to build own Observer Design Pattern:
http://cookbooks.adobe.com/post_Using_Observer_Pattern_instead_of_Events-18232.html

Is it really faster as for performance ?

答:
The author of that article didn't claim that it is any faster in performance.

Instead, it is an alternate architecture.  Using the built-in eventing system, you subscribe to the publisher for events.  In this article, there is a singleton "data bus" that aggregates events that you subscribe to.

Ultimately, it solves a different problem, IMO.  The ObserverManager in that article sends out events that can be picked up by any object in the system.  It is great for events like "Play a movie", "Pause a movie", "Navigate to a link", etc where anyone can publish it and anyone can subscribe to it.  It is loosely coupled.  Kind of like a CB radio.

The eventing pattern in Flex/Flash, on the other hand, is more intimate.  A property on a model object changed, and the UI wants to display it, for instance.  Events go object to object.  It is more tightly coupled -- the objects need to have references to each other.  Kind of like a telephone call (or, since it is one-way, a telegraph, perhaps?)


问:
Select from different tables using CONDITION using PL SQL
So I have a table with info that I want

```<code>TABLE_1
id
name
</code>```

And a lot of other tables with the same type of data

```<code>TABLE_x
id
order

TABLE_y
id
order
</code>```

...

```<code>TABLE_z
id
order
</code>```

What I want: depending on the name from TABLE_1 I want to acess the att order of other table.

Example:

```<code>TABLE_1
name = x
</code>```

I want to access TABLE_x and check the order.
But if

```<code>TABLE 1
name = z
</code>```

I want to access TABLE_z etc.

I thought about this piece:

```<code>SELECT *
FROM TABLE_1
INNER JOIN (
CASE (SELECT name FROM TABLE_1)
WHEN 'x' THEN TABLE_x on TABLE_1.id=TABLE_x.id
WHEN 'y' THEN TABLE_y on TABLE_1.id=TABLE_y.id
WHEN 'z' THEN TABLE_z on TABLE_1.id=TABLE_z.id)
</code>```

I can't use the case statement in here.

Need your help!

答:
I don't recommend what immediately follows, but look closely at one possible solution:

```<code>-- NOT RECOMMENDED...
WITH t1 AS (
    SELECT MIN(name) name FROM table_1
)
SELECT table_x.ordr FROM t1 JOIN table_x ON ('x' = t1.name)
UNION ALL
SELECT table_y.ordr FROM t1 JOIN table_y ON ('y' = t1.name)
UNION ALL
SELECT table_z.ordr FROM t1 JOIN table_z ON ('z' = t1.name)
/
</code>```

If you think about what the database needs to do to satisfy that query, you'll realize it's a lot of individual queries, with at most 1 of them returning data.  That could be a lot of work, which is why it's not recommended.  You're likely much better off running an initial query against table_1, with the result driving the target of a subsequent query.  With sqlplus, you might opt for something like:

```<code>COLUMN name NEW_VALUE name NOPRINT
SELECT MIN(name) name FROM table_1
/
SELECT ordr FROM table_&&name
/
</code>```

Do give some thought to error situations, such as when the name from query 1 doesn't match any existing table, or if there are no rows in table_1.

Body:
So I have a table with info that I want

TABLE_1
id
name

And a lot of other tables with the same type of data

TABLE_x
id
order

TABLE_y
id
order

...

TABLE_z
id
order

What I want: depending on the name from TABLE_1 I want to acess the att order of other table.

Example:

TABLE_1
name = x

I want to access TABLE_x and check the order.
But if

TABLE 1
name = z

I want to access TABLE_z etc.

I thought about this piece:

SELECT *
FROM TABLE_1
INNER JOIN (
CASE (SELECT name FROM TABLE_1)
WHEN 'x' THEN TABLE_x on TABLE_1.id=TABLE_x.id
WHEN 'y' THEN TABLE_y on TABLE_1.id=TABLE_y.id
WHEN 'z' THEN TABLE_z on TABLE_1.id=TABLE_z.id)

I can't use the case statement in here.

Need your help!

Body:
I don't recommend what immediately follows, but look closely at one possible solution:

-- NOT RECOMMENDED...
WITH t1 AS (
    SELECT MIN(name) name FROM table_1
)
SELECT table_x.ordr FROM t1 JOIN table_x ON ('x' = t1.name)
UNION ALL
SELECT table_y.ordr FROM t1 JOIN table_y ON ('y' = t1.name)
UNION ALL
SELECT table_z.ordr FROM t1 JOIN table_z ON ('z' = t1.name)
/

If you think about what the database needs to do to satisfy that query, you'll realize it's a lot of individual queries, with at most 1 of them returning data.  That could be a lot of work, which is why it's not recommended.  You're likely much better off running an initial query against table_1, with the result driving the target of a subsequent query.  With sqlplus, you might opt for something like:

COLUMN name NEW_VALUE name NOPRINT
SELECT MIN(name) name FROM table_1
/
SELECT ordr FROM table_&&name
/

Do give some thought to error situations, such as when the name from query 1 doesn't match any existing table, or if there are no rows in table_1.


问:
Prestashop 1.7.1.1 multilanguage redirect issue
I am experiencing a problem with a Prestashop website.

When I try to access the cart page (domain.com/cart), the page redirects to the homepage. This also happens when I go to "domain.com/index.php?controller=cart".

This is only happening for the cart page and when I look at network activity in chrome's devtools, I see that there is a 302 that redirects to /fr/ (The french version of this page) but leaves out the /cart/.

When I access the history page for example (domain.com?index.php?controller=history) the 302 redirects to /fr/history instead of just /fr/. (I don't know If this has anything to do with the issue)

P.S: The CartController.php file has not been changed and has no overrides.

Does anybody know where this problem might come from ?

Please help, thank you !!

答:
You should use your htaccess and make a 301 redirect or use a module for redirecting on multilang shop (https://addons.prestashop.com/fr/url-redirections/21318-redirections-url-301-auto-repare-multishop-seo.html). I think it's a bug from Prestashop core code.

Here is the .htaccess code if necessary :

```<code>Redirect "/cart" "/fr/cart"
</code>```

Body:
You should use your htaccess and make a 301 redirect or use a module for redirecting on multilang shop (https://addons.prestashop.com/fr/url-redirections/21318-redirections-url-301-auto-repare-multishop-seo.html). I think it's a bug from Prestashop core code.

Here is the .htaccess code if necessary :

Redirect "/cart" "/fr/cart"


问:
npm install SyntaxError: Unexpected token u in JSON at position 163836 (bluebird)
When I do npm install I get this error:

```<code>Unexpected token u in JSON at position 163836
</code>```

This is the log:

```<code>0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'install' ]
2 info using npm@5.0.3
3 info using node@v8.1.3
4 verbose npm-session c0d8f22cf8f053a1
5 silly install runPreinstallTopLevelLifecycles
6 silly preinstall bitcointrackerserver@1.0.0
7 info lifecycle bitcointrackerserver@1.0.0~preinstall: bitcointrackerserver@1.0.0
8 silly lifecycle bitcointrackerserver@1.0.0~preinstall: no script for preinstall, continuing
9 silly install loadCurrentTree
10 silly install readLocalPackageData
11 silly install loadIdealTree
12 silly install cloneCurrentTreeToIdealTree
13 silly install loadShrinkwrap
14 verbose stack SyntaxError: Unexpected token u in JSON at position 163836
14 verbose stack     at JSON.parse (<anonymous>)
14 verbose stack     at module.exports (C:\Program Files\nodejs\node_modules\npm\lib\utils\parse-json.js:3:15)
14 verbose stack     at BB.join (C:\Program Files\nodejs\node_modules\npm\lib\install\read-shrinkwrap.js:31:20)
14 verbose stack     at tryCatcher (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\util.js:16:23)
14 verbose stack     at Holder$3._callFunction (eval at generateHolderClass (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\join.js:92:16), <anonymous>:14:44)
14 verbose stack     at Holder$3.checkFulfillment (eval at generateHolderClass (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\join.js:92:16), <anonymous>:29:30)
14 verbose stack     at Promise.eval (eval at thenCallback (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\join.js:14:16), <anonymous>:6:20)
14 verbose stack     at Promise._settlePromise (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:566:21)
14 verbose stack     at Promise._settlePromise0 (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:614:10)
14 verbose stack     at Promise._settlePromises (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:693:18)
14 verbose stack     at Promise._fulfill (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:638:18)
14 verbose stack     at Promise._settlePromise (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:582:21)
14 verbose stack     at Promise._settlePromise0 (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:614:10)
14 verbose stack     at Promise._settlePromises (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:693:18)
14 verbose stack     at Promise._fulfill (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:638:18)
14 verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\nodeback.js:42:21
15 verbose cwd D:\Projects\xampp\htdocs\bitcointrackerserver_updated
16 verbose Windows_NT 10.0.15063
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
18 verbose node v8.1.3
19 verbose npm  v5.0.3
20 error Unexpected token u in JSON at position 163836
21 verbose exit [ 1, true ]
</code>```

Package.json:

```<code>{
      "name": "bitcointrackerserver",
      "version": "1.0.0",
      "description": "Using latest JavaScript features on the server",
      "repository": {
        "type": "git",
        "url": "git+https://github.com/vmasto/express-babel.git"
      },
      "author": "Vassilis Mastorostergios <vmasto@gmail.com>",
      "license": "MIT",
      "main": "dist/index.js",
      "engines": {
        "node": "~6.9.1",
        "npm": ">=3.10.0"
      },
      "scripts": {
        "prestart": "npm run -s build",
        "start": "node dist/index.js",
        "dev": "nodemon src/index.js --exec \"node -r dotenv/config -r babel-register\"",
        "clean": "rimraf dist",
        "build": "npm run clean && mkdir -p dist && babel src -s -D -d dist",
        "test": "jest --watch",
        "lint": "esw -w src test"
      },
      "keywords": [
        "express",
        "babel",
        "boilerplate",
        "scaffold",
        "es6",
        "es2015",
        "es2016",
        "es2017",
        "jest",
        "eslint"
      ],
      "dependencies": {
        "axios": "^0.16.2",
        "babel-cli": "^6.24.1",
        "babel-preset-env": "^1.4.0",
        "bluebird": "^3.5.0",
        "body-parser": "^1.17.1",
        "check-proxy": "^0.1.3",
        "express": "^4.15.2",
        "https-proxy-agent": "^2.0.0",
        "morgan": "^1.7.0",
        "pug": "^2.0.0-beta11",
        "request": "^2.81.0",
        "rimraf": "^2.6.1"
      },
      "devDependencies": {
        "babel-jest": "^20.0.0",
        "babel-register": "^6.24.1",
        "dotenv": "^4.0.0",
        "eslint": "^3.19.0",
        "eslint-plugin-import": "^2.2.0",
        "eslint-plugin-jest": "^20.0.0",
        "eslint-watch": "^3.1.0",
        "jest": "^20.0.0",
        "nodemon": "^1.11.0",
        "supertest": "^3.0.0"
      },
      "babel": {
        "presets": [
          [
            "env",
            {
              "targets": {
                "node": "current"
              }
            }
          ]
        ]
      },
      "eslintConfig": {
        "plugins": [
          "import",
          "jest"
        ],
        "parserOptions": {
          "ecmaVersion": 2017,
          "sourceType": "module"
        },
        "env": {
          "node": true,
          "jest": true
        },
        "extends": [
          "eslint:recommended"
        ],
        "rules": {
          "jest/no-focused-tests": 2,
          "jest/no-identical-title": 2
        }
      },
      "jest": {
        "testEnvironment": "node"
      },
      "bugs": {
        "url": "https://github.com/vmasto/express-babel/issues"
      },
      "homepage": "https://github.com/vmasto/express-babel#readme",
      "directories": {
        "test": "test"
      }
    }
</code>```

I cant find anything how to fix it, I tried to reinstall NodeJS but it didn't work. Also tried to clear the cache.

Anyone an idea why and how to fix? because I didn't wrote that code obviously

答:
Your version of node v8.1.3 and npm v5.0.3, does not support a dependency in package.json. I have checked with npm 4.1.2 and node v6.9.3 and it installs perfectly with node v6.9.3 and npm 4.1.2.

So my suggestion is for you to use nvm to change the node version.

```<code>nvm install 6.9.3
nvm use v6.9.3
</code>```

To change the node version to supported version.

Update me on how it goes;

Good Luck;

Body:
When I do npm install I get this error:

Unexpected token u in JSON at position 163836

This is the log:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'install' ]
2 info using npm@5.0.3
3 info using node@v8.1.3
4 verbose npm-session c0d8f22cf8f053a1
5 silly install runPreinstallTopLevelLifecycles
6 silly preinstall bitcointrackerserver@1.0.0
7 info lifecycle bitcointrackerserver@1.0.0~preinstall: bitcointrackerserver@1.0.0
8 silly lifecycle bitcointrackerserver@1.0.0~preinstall: no script for preinstall, continuing
9 silly install loadCurrentTree
10 silly install readLocalPackageData
11 silly install loadIdealTree
12 silly install cloneCurrentTreeToIdealTree
13 silly install loadShrinkwrap
14 verbose stack SyntaxError: Unexpected token u in JSON at position 163836
14 verbose stack     at JSON.parse (<anonymous>)
14 verbose stack     at module.exports (C:\Program Files\nodejs\node_modules\npm\lib\utils\parse-json.js:3:15)
14 verbose stack     at BB.join (C:\Program Files\nodejs\node_modules\npm\lib\install\read-shrinkwrap.js:31:20)
14 verbose stack     at tryCatcher (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\util.js:16:23)
14 verbose stack     at Holder$3._callFunction (eval at generateHolderClass (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\join.js:92:16), <anonymous>:14:44)
14 verbose stack     at Holder$3.checkFulfillment (eval at generateHolderClass (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\join.js:92:16), <anonymous>:29:30)
14 verbose stack     at Promise.eval (eval at thenCallback (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\join.js:14:16), <anonymous>:6:20)
14 verbose stack     at Promise._settlePromise (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:566:21)
14 verbose stack     at Promise._settlePromise0 (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:614:10)
14 verbose stack     at Promise._settlePromises (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:693:18)
14 verbose stack     at Promise._fulfill (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:638:18)
14 verbose stack     at Promise._settlePromise (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:582:21)
14 verbose stack     at Promise._settlePromise0 (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:614:10)
14 verbose stack     at Promise._settlePromises (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:693:18)
14 verbose stack     at Promise._fulfill (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:638:18)
14 verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\nodeback.js:42:21
15 verbose cwd D:\Projects\xampp\htdocs\bitcointrackerserver_updated
16 verbose Windows_NT 10.0.15063
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
18 verbose node v8.1.3
19 verbose npm  v5.0.3
20 error Unexpected token u in JSON at position 163836
21 verbose exit [ 1, true ]

Package.json:

{
      "name": "bitcointrackerserver",
      "version": "1.0.0",
      "description": "Using latest JavaScript features on the server",
      "repository": {
        "type": "git",
        "url": "git+https://github.com/vmasto/express-babel.git"
      },
      "author": "Vassilis Mastorostergios <vmasto@gmail.com>",
      "license": "MIT",
      "main": "dist/index.js",
      "engines": {
        "node": "~6.9.1",
        "npm": ">=3.10.0"
      },
      "scripts": {
        "prestart": "npm run -s build",
        "start": "node dist/index.js",
        "dev": "nodemon src/index.js --exec \"node -r dotenv/config -r babel-register\"",
        "clean": "rimraf dist",
        "build": "npm run clean && mkdir -p dist && babel src -s -D -d dist",
        "test": "jest --watch",
        "lint": "esw -w src test"
      },
      "keywords": [
        "express",
        "babel",
        "boilerplate",
        "scaffold",
        "es6",
        "es2015",
        "es2016",
        "es2017",
        "jest",
        "eslint"
      ],
      "dependencies": {
        "axios": "^0.16.2",
        "babel-cli": "^6.24.1",
        "babel-preset-env": "^1.4.0",
        "bluebird": "^3.5.0",
        "body-parser": "^1.17.1",
        "check-proxy": "^0.1.3",
        "express": "^4.15.2",
        "https-proxy-agent": "^2.0.0",
        "morgan": "^1.7.0",
        "pug": "^2.0.0-beta11",
        "request": "^2.81.0",
        "rimraf": "^2.6.1"
      },
      "devDependencies": {
        "babel-jest": "^20.0.0",
        "babel-register": "^6.24.1",
        "dotenv": "^4.0.0",
        "eslint": "^3.19.0",
        "eslint-plugin-import": "^2.2.0",
        "eslint-plugin-jest": "^20.0.0",
        "eslint-watch": "^3.1.0",
        "jest": "^20.0.0",
        "nodemon": "^1.11.0",
        "supertest": "^3.0.0"
      },
      "babel": {
        "presets": [
          [
            "env",
            {
              "targets": {
                "node": "current"
              }
            }
          ]
        ]
      },
      "eslintConfig": {
        "plugins": [
          "import",
          "jest"
        ],
        "parserOptions": {
          "ecmaVersion": 2017,
          "sourceType": "module"
        },
        "env": {
          "node": true,
          "jest": true
        },
        "extends": [
          "eslint:recommended"
        ],
        "rules": {
          "jest/no-focused-tests": 2,
          "jest/no-identical-title": 2
        }
      },
      "jest": {
        "testEnvironment": "node"
      },
      "bugs": {
        "url": "https://github.com/vmasto/express-babel/issues"
      },
      "homepage": "https://github.com/vmasto/express-babel#readme",
      "directories": {
        "test": "test"
      }
    }

I cant find anything how to fix it, I tried to reinstall NodeJS but it didn't work. Also tried to clear the cache.

Anyone an idea why and how to fix? because I didn't wrote that code obviously

Body:
Your version of node v8.1.3 and npm v5.0.3, does not support a dependency in package.json. I have checked with npm 4.1.2 and node v6.9.3 and it installs perfectly with node v6.9.3 and npm 4.1.2.

So my suggestion is for you to use nvm to change the node version.

nvm install 6.9.3
nvm use v6.9.3

To change the node version to supported version.

Update me on how it goes;

Good Luck;


问:
Multiple paths in location element of web.config
How can I specify multiple paths in one location element in web.config?

```<code><location path="Images">
    <system.web>
        <authorization>
            <allow users="?" />
        </authorization>
    </system.web>
</location>
</code>```

We would like to add styles and images to location, e.g. <location path="images, styles">.

Is it possible to put multiple paths in location element (and how would I do that)?

答:
You cannot do this unless they share the same root folder. I've been known to dump images/styles/javascript into a single folder like "_res" or "_system" and authorize that folder

More info on the location element: http://msdn.microsoft.com/en-us/library/b6x6shw7(v=vs.71).aspx

On the path attribute:

Specifies the resource that the contained configuration settings apply to. Using location with a missing path attribute applies the configuration settings to the current directory and all child directories. If location is used with no path attribute and allowOverride is False, configuration settings cannot be altered by Web.config files that are in child directories.

Body:
How can I specify multiple paths in one location element in web.config?

<location path="Images">
    <system.web>
        <authorization>
            <allow users="?" />
        </authorization>
    </system.web>
</location>

We would like to add styles and images to location, e.g. <location path="images, styles">.

Is it possible to put multiple paths in location element (and how would I do that)?


问:
Why does my compiler gives me a Segmentation Fault when I execute this code?
```<code>#include<iostream>
#include<cstdio>
#include<cstdlib>

using namespace std;

struct Node {
    int data;
    Node* next;
};

struct Node* takeInput(){
    struct Node* head;
    cout<<"Enter element:";
    int data;
    cin>>data;
    while(data!=-1){
        struct Node* newNode=new (struct Node);
        newNode->data=data;
        newNode->next=NULL;

        if(head==NULL){
            head=newNode;
        }
        else{
            struct Node* temp=new (struct Node);
            while(temp->next!=NULL){
                temp=temp->next;
            }
            temp->next=newNode;
        }
        cout<<"Enter next element: ";
        cin>>data;
    }
    return head;
}

void print(struct Node* head){

    while(head->next!=NULL){
        cout<<head->data<<"->";
        head=head->next;
    }
}

int main(){
    struct Node* head = new (struct Node);
    head = takeInput();
    print(head);
}
</code>```

The segmentation fault occurs when the print() function executes.
Without the execution of the print function the code runs perfectly. The code takes the input from the user but crashes when I try to print the Linked List.
I am using a gcc compiler with Code Blocks IDE on a Linux OS.

答:
Your code is full of accesses to uninitialized variables, dereferencing uninitialized members, and producing memory leaks

if(head==NULL), where head is a local variable without initialiser

while(temp->next!=NULL), where temp has just been created and next never assigned

while(head->next!=NULL), where head is a function argument, which is possibly NULL

struct Node* head = new (struct Node); head = takeInput() leaks.

struct Node* temp=new (struct Node); ... temp=temp->next leaks.

Without changing your code to much, the following should work:

```<code>struct Node* takeInput(struct Node* head) {
    cout<<"Enter element:";
    int data;
    cin>>data;
    while(data!=-1){
        struct Node* newNode=new (struct Node);
        newNode->data=data;
        newNode->next=NULL;

        if(head==NULL){
            head=newNode;
        }
        else{
            struct Node* temp=head;  // start at the head
            while(temp->next!=NULL){
                temp=temp->next;
            }
            temp->next=newNode;
        }
        cout<<"Enter next element: ";
        cin>>data;
    }
    return head;
}

void print(struct Node* head){

    while(head!=NULL){  // test head, not it's successor
        cout<<head->data<<"->";
        head=head->next;
    }
}

int main(){
    struct Node* head = takeInput(NULL);

    print(head);
}
</code>```

Body:
#include<iostream>
#include<cstdio>
#include<cstdlib>

using namespace std;

struct Node {
    int data;
    Node* next;
};

struct Node* takeInput(){
    struct Node* head;
    cout<<"Enter element:";
    int data;
    cin>>data;
    while(data!=-1){
        struct Node* newNode=new (struct Node);
        newNode->data=data;
        newNode->next=NULL;

        if(head==NULL){
            head=newNode;
        }
        else{
            struct Node* temp=new (struct Node);
            while(temp->next!=NULL){
                temp=temp->next;
            }
            temp->next=newNode;
        }
        cout<<"Enter next element: ";
        cin>>data;
    }
    return head;
}

void print(struct Node* head){

    while(head->next!=NULL){
        cout<data<<"->";
        head=head->next;
    }
}

int main(){
    struct Node* head = new (struct Node);
    head = takeInput();
    print(head);
}

The segmentation fault occurs when the print() function executes.
Without the execution of the print function the code runs perfectly. The code takes the input from the user but crashes when I try to print the Linked List.
I am using a gcc compiler with Code Blocks IDE on a Linux OS.

Body:
Your code is full of accesses to uninitialized variables, dereferencing uninitialized members, and producing memory leaks

if(head==NULL), where head is a local variable without initialiser

while(temp->next!=NULL), where temp has just been created and next never assigned

while(head->next!=NULL), where head is a function argument, which is possibly NULL

struct Node* head = new (struct Node); head = takeInput() leaks.

struct Node* temp=new (struct Node); ... temp=temp->next leaks.

Without changing your code to much, the following should work:

struct Node* takeInput(struct Node* head) {
    cout<<"Enter element:";
    int data;
    cin>>data;
    while(data!=-1){
        struct Node* newNode=new (struct Node);
        newNode->data=data;
        newNode->next=NULL;

        if(head==NULL){
            head=newNode;
        }
        else{
            struct Node* temp=head;  // start at the head
            while(temp->next!=NULL){
                temp=temp->next;
            }
            temp->next=newNode;
        }
        cout<<"Enter next element: ";
        cin>>data;
    }
    return head;
}

void print(struct Node* head){

    while(head!=NULL){  // test head, not it's successor
        cout<<head->data<<"->";
        head=head->next;
    }
}

int main(){
    struct Node* head = takeInput(NULL);

    print(head);
}


问:
WHERE CLAUSE WITH MULTIPLE CONDITIONS NOT WORKING
On trying the following code i get the error:

```<code>Cursor cursor1 = db.rawQuery("SELECT * FROM " + TABLE_TRAVEL +
                " WHERE " + KEY_CITY + " = ? AND  " + KEY_STATE + " = ?",null);
</code>```

E/AndroidRuntime: FATAL EXCEPTION: main
                                                                               Process: com.anvipuri.databaseplaces, PID: 11773
                                                                               java.lang.RuntimeException: Unable to start activity
  ComponentInfo{com.anvipuri.databaseplaces/com.anvipuri.databaseplaces.MainActivity}:
  android.database.CursorIndexOutOfBoundsException: Index -1 requested,
  with a size of 6
                                                                                at
  android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
                                                                                at
  android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
                                                                                at android.app.ActivityThread.-wrap12(ActivityThread.java)
                                                                                at
  android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
                                                                                at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                at android.os.Looper.loop(Looper.java:154)
                                                                                at android.app.ActivityThread.main(ActivityThread.java:6119)
                                                                                at java.lang.reflect.Method.invoke(Native Method)
                                                                                at
  com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
                                                                                Caused by: android.database.CursorIndexOutOfBoundsException: Index -1
  requested, with a size of 6
                                                                                at
  android.database.AbstractCursor.checkPosition(AbstractCursor.java:460)
                                                                                at
  android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:136)
                                                                                at
  android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:50)
                                                                                at
  com.anvipuri.databaseplaces.DatabaseHelper.findOnep(DatabaseHelper.java:132)
                                                                                at
  com.anvipuri.databaseplaces.MainActivity.onCreate(MainActivity.java:119)
                                                                                at android.app.Activity.performCreate(Activity.java:6679)
                                                                                at
  android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
                                                                                at
  android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
                                                                                at
  android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
                                                                                at android.app.ActivityThread.-wrap12(ActivityThread.java)
                                                                                at
  android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
                                                                                at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                at android.os.Looper.loop(Looper.java:154)
                                                                                at android.app.ActivityThread.main(ActivityThread.java:6119)
                                                                                at java.lang.reflect.Method.invoke(Native Method)
                                                                                at
  com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

答:
You should do

```<code>if(cursor.moveToFirst()) {
    do {
        Obj obj = createObjectFromCursor(cursor);
    } while(cursor.moveToNext());
}
</code>```

Or at least you shouldn't forget to call moveToPosition() or moveToFirst() so that you initialize the cursor's index from the default -1.

Body:
On trying the following code i get the error:

Cursor cursor1 = db.rawQuery("SELECT * FROM " + TABLE_TRAVEL +
                " WHERE " + KEY_CITY + " = ? AND  " + KEY_STATE + " = ?",null);

E/AndroidRuntime: FATAL EXCEPTION: main
                                                                               Process: com.anvipuri.databaseplaces, PID: 11773
                                                                               java.lang.RuntimeException: Unable to start activity
  ComponentInfo{com.anvipuri.databaseplaces/com.anvipuri.databaseplaces.MainActivity}:
  android.database.CursorIndexOutOfBoundsException: Index -1 requested,
  with a size of 6
                                                                                at
  android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
                                                                                at
  android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
                                                                                at android.app.ActivityThread.-wrap12(ActivityThread.java)
                                                                                at
  android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
                                                                                at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                at android.os.Looper.loop(Looper.java:154)
                                                                                at android.app.ActivityThread.main(ActivityThread.java:6119)
                                                                                at java.lang.reflect.Method.invoke(Native Method)
                                                                                at
  com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
                                                                                Caused by: android.database.CursorIndexOutOfBoundsException: Index -1
  requested, with a size of 6
                                                                                at
  android.database.AbstractCursor.checkPosition(AbstractCursor.java:460)
                                                                                at
  android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:136)
                                                                                at
  android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:50)
                                                                                at
  com.anvipuri.databaseplaces.DatabaseHelper.findOnep(DatabaseHelper.java:132)
                                                                                at
  com.anvipuri.databaseplaces.MainActivity.onCreate(MainActivity.java:119)
                                                                                at android.app.Activity.performCreate(Activity.java:6679)
                                                                                at
  android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
                                                                                at
  android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
                                                                                at
  android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
                                                                                at android.app.ActivityThread.-wrap12(ActivityThread.java)
                                                                                at
  android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
                                                                                at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                at android.os.Looper.loop(Looper.java:154)
                                                                                at android.app.ActivityThread.main(ActivityThread.java:6119)
                                                                                at java.lang.reflect.Method.invoke(Native Method)
                                                                                at
  com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

Body:
You should do

if(cursor.moveToFirst()) {
    do {
        Obj obj = createObjectFromCursor(cursor);
    } while(cursor.moveToNext());
}

Or at least you shouldn't forget to call moveToPosition() or moveToFirst() so that you initialize the cursor's index from the default -1.


问:
Bootstrap nav not centered
I have a Bootstrap menu that that is slightly aligned to the left for some reason, I can't debug it.  It doesn't have any rows, but the container is fluid and changing this to fixed makes it unresponsive in mobiles.

This is the live example. https://codepen.io/anon/pen/qjKbQM

This is the HTML code:

```<code><nav class="navbar navbar-default" style="border:1px solid red";>
  <div class="container-fluid">
<div class="container">
      <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="#">UP</a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">
         <li><a href="#"><span class="glyphicon glyphicon-th" aria-hidden="true"></span> DEVIS GRATUIT</a></li>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Nos Ressource <span class="caret"></span></a>
          <ul class="dropdown-menu">
              <li>
        <a href="/fiches-conseils" target="" data-drupal-link-system-path="node/578">Toutes nos ressources</a>
              </li>
          <li>
        <a href="/fiches-conseils" target="" data-drupal-link-system-path="node/578">Fiches conseils</a>
              </li>
          <li>
        <a href="/nos-fiches-metiers" target="" data-drupal-link-system-path="node/1099">Fiches métiers</a>
              </li>
          <li>
        <a href="/foire-aux-questions" title="FAQ" target="" data-drupal-link-system-path="node/1079">Foire aux questions</a>
              </li>
          <li>
        <a href="/revue-de-presse" target="" data-drupal-link-system-path="node/480">Revue de presse</a>
              </li>
          <li>
        <a href="https://blog.cacomptepourmoi.fr/" target="_blank">Le Blog</a>
              </li>
        </ul>
        </li>
      <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Nos Fonctionalites <span class="caret"></span></a>
          <ul class="dropdown-menu">
              <li>
        <a href="/nos-fonctionnalites" target="" data-drupal-link-system-path="node/474">Toutes nos fonctionnalités</a>
              </li>
          <li class="">
        <a href="/nos-fonctionnalites#indicateurs" target="" data-drupal-link-system-path="node/474">Mes indicateurs</a>
              </li>
          <li class="">
        <a href="/nos-fonctionnalites#macompta" target="" data-drupal-link-system-path="node/474">Ma comptabilité </a>
              </li>
          <li class="">
        <a href="/nos-fonctionnalites#devisfactures" target="" data-drupal-link-system-path="node/474">Mes devis et factures</a>
              </li>
          <li class="">
        <a href="/nos-fonctionnalites#monbudget" target="" data-drupal-link-system-path="node/474">Mon budget</a>
              </li>
          <li>
        <a href="/nos-fonctionnalites#socialrh" target="" data-drupal-link-system-path="node/474">Mon social-RH</a>
              </li>
          <li class="">
        <a href="/nos-fonctionnalites#coffrefort" target="" data-drupal-link-system-path="node/474">Mon coffre-fort</a>
              </li>
          </ul>
      </li>
      <li><a href="#">Accounts</a></li>
      <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Notre Cabinet <span class="caret"></span></a>
          <ul class="dropdown-menu">
              <li>
        <a href="/qui-sommes-nous" target="" data-drupal-link-system-path="node/1088">Tout sur notre cabinet</a>
              </li>
          <li class="">
        <a href="/qui-sommes-nous" target="" data-drupal-link-system-path="node/1088">Qui sommes-nous ?</a>
              </li>
          <li>
        <a href="/pourquoi-nous-choisir" title="Choisir Ça Compte pour Moi" target="" data-drupal-link-system-path="node/669">Pourquoi nous choisir ?</a>
              </li>
          <li>
        <a href="/ca-compte-pour-moi-en-5-etapes" title="Les étapes pour devenir client" target="" data-drupal-link-system-path="node/1089">Comment devenir client ?</a>
              </li>
          <li>
        <a href="/notre-equipe" title="Découvrez notre équipe" target="" data-drupal-link-system-path="node/630">Notre équipe</a>
              </li>
          <li>
        <a href="/vos-questions-nos-reponses" target="" data-drupal-link-system-path="node/1087">Vos questions, nos réponses</a>
              </li>
          <li class="">
        <a href="/temoignages-clients" title="Témoignages de nos clients" target="" data-drupal-link-system-path="node/969">Témoignages clients</a>
              </li>
          <li class="">
        <a href="/recrutement" target="" data-drupal-link-system-path="node/446">Recrutement</a>
              </li>
          </ul>
      </li>
      <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Nos Solutions <span class="caret"></span></a>
          <ul class="dropdown-menu">
              <li>
        <a href="/nos-solutions" target="" data-drupal-link-system-path="node/374">Toutes nos solutions</a>
              </li>
          <li class="">
        <a href="/nos-solutions/tpe" target="" data-drupal-link-system-path="node/392">TPE / Consultants</a>
              </li>
          <li>
        <a href="/nos-solutions/createur" target="" data-drupal-link-system-path="node/388">Porteurs de projet</a>
              </li>
          <li>
        <a href="/nos-solutions/sci-location-meublee" target="" data-drupal-link-system-path="node/497">SCI / Locations meublées</a>
              </li>
          <li class="">
        <a href="/nos-solutions/paye-salaire" target="" data-drupal-link-system-path="node/394">Paye des salariés</a>
              </li>
          <li class="">
        <a href="/nos-solutions/profession-liberale" target="" data-drupal-link-system-path="node/757">Professions Libérales</a>
              </li>
          <li class="">
        <a href="/nos-solutions/association" target="" data-drupal-link-system-path="node/761">Associations</a>
              </li>
          <li class="">
        <a href="/nos-solutions" title="Les solutions de comptabilité en ligne" target="" data-drupal-link-system-path="node/374">Toutes nos solutions</a>
              </li>
          </ul>
      </li>
      </ul>
    </div><!-- /.navbar-collapse -->
</div>
  </div><!-- /.container-fluid -->
</nav>
</code>```

And this is the css :

```<code>.navbar-default {
  font-size: 1.15em;
  font-weight: 400;
  border: 0px;
  border-radius: 0px;
  background: #021a2f !important;
}

.navbar-default .navbar-nav>li>a {
  color: white;
}

.navbar-default .navbar-nav>li>a:hover {
  color: #cbf0ff;
}

.navbar-default .navbar-brand {
  color: #002433;
}

.navbar-default .navbar-brand:hover {
  color: #ffffff;
  text-shadow: 1px -1px 8px #b3e9ff;
}

.navbar-default .navbar-nav>.open>a, .navbar-default .navbar-nav>.open>a:hover, .navbar-default .navbar-nav>.open>a:focus {
  background-color: #004059;
  color: white;
}

.navbar-default .navbar-toggle {
  border: none;
}

.navbar-default .navbar-collapse, .navbar-default .navbar-form {
  border: none;
}
.navbar-default .navbar-toggle:hover, .navbar-default .navbar-toggle:focus {
  background-color: #002433;
}

.navbar-default .navbar-toggle .icon-bar {
}

.dropdown-menu {
  background-color: #004059;
  color: white;
  border: 0px;
  border-radius: 2px;
  padding-top: 10px;
  padding-bottom: 10px;
}

.dropdown-menu>li>a {
  background-color: #004059;
  color: white;
}

.dropdown-menu>li>a:hover, .dropdown-menu>li>a:focus {
  background-color: #004059;
  color:white;
}

.dropdown-menu .divider {
    height: 1px;
    margin: 9px 0;
    overflow: hidden;
    background-color: #003246;
}

.navbar-default .navbar-nav .open .dropdown-menu>li>a {
    color: #ffffff;
}

@media (max-width: 767px) {
  .dropdown-menu>li>a {
    background-color: #006b96;
    color: #ffffff;
  }
  .dropdown-menu>li>a:hover {
    color: #ffffff;
  }

  .navbar-default .navbar-nav .open .dropdown-menu>li>a:focus, .navbar-default .navbar-nav .open .dropdown-menu>li>a:hover {
    color: #ffffff;
    background-color: transparent;
  }

  .dropdown-menu .divider {
    height: 1px;
    margin: 9px 0;
    overflow: hidden;
    background-color: #005577;
  }
}
</code>```

How can I make the menus be centered without loosing the responsiveness of the navbar?

答:
Add below css to get

```<code>.nav.customCl {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-flow: row wrap;
}
</code>```

And use this class in following html

```<code><ul class="nav navbar-nav customCl"
</code>```

codepen link

Title: Bootstrap nav not centered

Body:
I have a Bootstrap menu that that is slightly aligned to the left for some reason, I can't debug it.  It doesn't have any rows, but the container is fluid and changing this to fixed makes it unresponsive in mobiles.

This is the live example. https://codepen.io/anon/pen/qjKbQM

This is the HTML code:

      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        Toggle navigation

      </button>
      UP

 DEVIS GRATUIT

          Nos Ressource

        Toutes nos ressources

        Fiches conseils

        Fiches métiers

        Foire aux questions

        Revue de presse

        Le Blog

          Nos Fonctionalites

        Toutes nos fonctionnalités

        Mes indicateurs

        Ma comptabilité

        Mes devis et factures

        Mon budget

        Mon social-RH

        Mon coffre-fort

Accounts

          Notre Cabinet

        Tout sur notre cabinet

        Qui sommes-nous ?

        Pourquoi nous choisir ?

        Comment devenir client ?

        Notre équipe

        Vos questions, nos réponses

        Témoignages clients

        Recrutement

          Nos Solutions

        Toutes nos solutions

        TPE / Consultants

        Porteurs de projet

        SCI / Locations meublées

        Paye des salariés

        Professions Libérales

        Associations

        Toutes nos solutions

And this is the css :

.navbar-default {
  font-size: 1.15em;
  font-weight: 400;
  border: 0px;
  border-radius: 0px;
  background: #021a2f !important;
}

.navbar-default .navbar-nav>li>a {
  color: white;
}

.navbar-default .navbar-nav>li>a:hover {
  color: #cbf0ff;
}

.navbar-default .navbar-brand {
  color: #002433;
}

.navbar-default .navbar-brand:hover {
  color: #ffffff;
  text-shadow: 1px -1px 8px #b3e9ff;
}

.navbar-default .navbar-nav>.open>a, .navbar-default .navbar-nav>.open>a:hover, .navbar-default .navbar-nav>.open>a:focus {
  background-color: #004059;
  color: white;
}

.navbar-default .navbar-toggle {
  border: none;
}

.navbar-default .navbar-collapse, .navbar-default .navbar-form {
  border: none;
}
.navbar-default .navbar-toggle:hover, .navbar-default .navbar-toggle:focus {
  background-color: #002433;
}

.navbar-default .navbar-toggle .icon-bar {
}

.dropdown-menu {
  background-color: #004059;
  color: white;
  border: 0px;
  border-radius: 2px;
  padding-top: 10px;
  padding-bottom: 10px;
}

.dropdown-menu>li>a {
  background-color: #004059;
  color: white;
}

.dropdown-menu>li>a:hover, .dropdown-menu>li>a:focus {
  background-color: #004059;
  color:white;
}

.dropdown-menu .divider {
    height: 1px;
    margin: 9px 0;
    overflow: hidden;
    background-color: #003246;
}

.navbar-default .navbar-nav .open .dropdown-menu>li>a {
    color: #ffffff;
}

@media (max-width: 767px) {
  .dropdown-menu>li>a {
    background-color: #006b96;
    color: #ffffff;
  }
  .dropdown-menu>li>a:hover {
    color: #ffffff;
  }

  .navbar-default .navbar-nav .open .dropdown-menu>li>a:focus, .navbar-default .navbar-nav .open .dropdown-menu>li>a:hover {
    color: #ffffff;
    background-color: transparent;
  }

  .dropdown-menu .divider {
    height: 1px;
    margin: 9px 0;
    overflow: hidden;
    background-color: #005577;
  }
}

How can I make the menus be centered without loosing the responsiveness of the navbar?

Body:
Add below css to get

.nav.customCl {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-flow: row wrap;
}

And use this class in following html

<ul class="nav navbar-nav customCl"

codepen link


问:
Issues logging out in Angular 4 app using Auth0
I have an Angular 4 app and am using Auth0 for login and signup. When you click login it takes you to Auth0's own page where you enter your credentials. Auth0 checks them and then sends you back to a callback url of your choice with a jwt in the url. I then store the tokens in localStorage.

Auth0 recommends that when you log out you simply delete the tokens and expiry date in the localStorage thus:

```<code>public logout(): void {
// Remove tokens and expiry time from localStorage
localStorage.removeItem('access_token');
localStorage.removeItem('id_token');
localStorage.removeItem('expires_at');
// Go back to the home route
this.router.navigate(['/signup']);
</code>```

}

This works fine but then when I try to log in again I am not taken to Auth0's login page but instead the callback url with the token in it is automatically returned. This is not what I want because it means I am not really logged out. The only way to get around it is to delete "Cookies and other site data" in Chrome but as far as I can see there are no cookies (besides google analytics).

Can anyone explain what is happening here and how to fix it in the logout function above.

答:
In addition to clearing the user's session at your application (by removing the tokens stored at localStorage), you might also want to clear the session created at Auth0 (i.e. the identity provider), by redirecting the user to https://your-auth0-domain/v2/logout.
Take a look at Auth0's logout doc for more information on sessions and details on the logout features.

Body:
I have an Angular 4 app and am using Auth0 for login and signup. When you click login it takes you to Auth0's own page where you enter your credentials. Auth0 checks them and then sends you back to a callback url of your choice with a jwt in the url. I then store the tokens in localStorage.

Auth0 recommends that when you log out you simply delete the tokens and expiry date in the localStorage thus:

public logout(): void {
// Remove tokens and expiry time from localStorage
localStorage.removeItem('access_token');
localStorage.removeItem('id_token');
localStorage.removeItem('expires_at');
// Go back to the home route
this.router.navigate(['/signup']);

}

This works fine but then when I try to log in again I am not taken to Auth0's login page but instead the callback url with the token in it is automatically returned. This is not what I want because it means I am not really logged out. The only way to get around it is to delete "Cookies and other site data" in Chrome but as far as I can see there are no cookies (besides google analytics).

Can anyone explain what is happening here and how to fix it in the logout function above.


问:
pop_back() return value in std::list?
I am confused with that, that pop_back() std::list method does not have return value, but how can I then get value from some list and store it in another, for example list of ints?

I assume that this is easy, but I am not familiar with C++, I tried to find solution, but maybe here I can get concrete answer about how to do that.

答:
pop_back() returning a reference to the deleted element would not be desirable, as the reference would immediately be to an invalid element. If you'd like to copy construct the last element of a list to another then delete the element from the first list, you can use the below code. If you don't need to delete the element, just omit the call to std::list::pop_back().</p>

```<code>std::list<int> firstList{1, 2, 3, 4, 5, 6};
std::list<int> secondList{1, 2, 3, 4};
secondList.push_back(firstList.back()); //the 6 from firstList has now been copied to secondList
firstList.pop_back(); //the 6 from firstList has now been removed
</code>```

Title: pop_back() return value in std::list?

Body:
pop_back() returning a reference to the deleted element would not be desirable, as the reference would immediately be to an invalid element. If you'd like to copy construct the last element of a list to another then delete the element from the first list, you can use the below code. If you don't need to delete the element, just omit the call to std::list::pop_back().

std::list<int> firstList{1, 2, 3, 4, 5, 6};
std::list<int> secondList{1, 2, 3, 4};
secondList.push_back(firstList.back()); //the 6 from firstList has now been copied to secondList
firstList.pop_back(); //the 6 from firstList has now been removed


问:
How to have border color change on image hover/mousover?
I know how to add a border to images, but how do I change the color of the border on image hover/mouseover, I would like to to this to multiple images on the same page, so far I have failed to find a plugin that does this.

I spent like 5 hours looking for a plugin to do this, feel my pain!!!

Basically, I want an image to do what a button does. When user hovers the mouse over the button the color of the border changes.

答:
You can use outline instead

```<code>.imgclass:hover {
   outline: 1px solid red;
}
</code>```

This way you do not have any movements or corallations with other elements

Body:
You can use outline instead

.imgclass:hover {
   outline: 1px solid red;
}

This way you do not have any movements or corallations with other elements