问:
How to separate nested table conspicuously?
How can i separate nested table in lower table as conspicuously as in upper table?

Upper table is not proper though.

I am trying to get Settlements  Finance Time 3  Time 5  Bad Good in a single line in lower table.

Here is my code:

.my-table {
  border: 1px solid #000;
}

.my-table tr:nth-child(even) {
  background: #ddd;
}

.my-table tr:nth-child(odd) {
  background: #fff;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><table class="my-table">
  <tr>
    <th>Service</th>
    <th>Provider</th>
    <th>Check</th>
    <th>Marker</th>
    <th>Captured Time</th>
    <th>Final Time</th>
    <th>Status</th>
    <th>Comments</th>
  </tr>
  <tr>
    <th>Sub Heading</th>
  </tr>
  <tr>
    <td>Custody C</td>
    <td>I</td>
    <td>
      <table>
        <tr>
          <td>Settlements</td>
          <td>Finance</td>
          <td>Time 3</td>
          <td>Time 5</td>
          <td>Bad</td>
          <td>Good</td>
        </tr>
      </table>
      <table>
        <tr>
          <td>Crossroad</td>
          <td>
            <table>
              <tr>
                <td>Complete</td>
              </tr>
              <tr>
                <td>Partial</td>
              </tr>
            </table>
          </td>
          <td>
            <table>
              <tr>
                <td>Time 4a</td>
              </tr>
              <tr>
                <td>Time 4b</td>
              </tr>
            </table>
          </td>
          <td>
            <table>
              <tr>
                <td>Time 6a</td>
              </tr>
              <tr>
                <td>Time 6b</td>
              </tr>
            </table>
          </td>
          <td>Ok</td>
          <td>danke</td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<br>
<table class="my-table">
  <tr>
    <th>Service</th>
    <th>Provider</th>
    <th>Check</th>
    <th>Marker</th>
    <th>Captured Time</th>
    <th>Final Time</th>
    <th>Status</th>
    <th>Comments</th>
  </tr>
  <tr>
    <th>Sub Heading</th>
  </tr>
  <tr>
    <td>Custody T</td>
    <td>G</td>
    <td>
      <table>
        <tr>
          <td>Trades</td>
        </tr>
        <tr>
          <td>Position</td>
        </tr>
      </table>
    </td>
    <td>Latest</td>
    <td>TIME 1</td>
    <td>TIME 2</td>
    <td>Good</td>
    <td>My Comments</td>
  </tr>

  <tr>
    <td>Custody C</td>
    <td>I</td>
    <td>
      <table>
        <tr>
          <td>Settlements</td>
        </tr>
        <tr>
          <td>Crossroad</td>
        </tr>
      </table>
    </td>
    <td>
      <table>
        <tr>
          <td>Finance</td>
        </tr>
        <tr>
          <td>
            <table>
              <tr>
                <td>Complete</td>
              </tr>
              <tr>
                <td>Partial</td>
              </tr>
            </table>
          </td>

        </tr>
      </table>
    </td>
    <td>
      <table>
        <tr>
          <td>Time 3</td>
        </tr>
        <tr>
          <td>
            <table>
              <tr>
                <td>Time 4a</td>
              </tr>
              <tr>
                <td>Time 4b</td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
    <td>
      <table>
        <tr>
          <td>
            Time 5
          </td>
        </tr>
        <tr>
          <td>
            <table>
              <tr>
                <td>Time 6a</td>
              </tr>
              <tr>
                <td>Time 6b</td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
    <td>
      <table>
        <tr>
          <td>Bad</td>
        </tr>
        <tr>
          <td>Ok</td>
        </tr>
      </table>
    </td>
    <td>
      <table>
        <tr>
          <td>Good</td>
        </tr>
        <tr>
          <td>danke</td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>

  </tr>
</table></code>```

答:
To answer the question:

I am trying to get Settlements Finance Time 3 Time 5 Bad Good in a single line in lower table.

Vertically aligning your table cells will bring the content to the top of the cells, regardless of how many lines of content follows.

```<code>.my-table td {
  vertical-align: top;
}
</code>```

JSFiddle Example: https://jsfiddle.net/jennifergoncalves/y1Lr0mzw/

Please let me know if I missed what you were trying to accomplish.

Body:
How can i separate nested table in lower table as conspicuously as in upper table?

Upper table is not proper though.

I am trying to get Settlements  Finance Time 3  Time 5  Bad Good in a single line in lower table.

Here is my code:

.my-table {
  border: 1px solid #000;
}

.my-table tr:nth-child(even) {
  background: #ddd;
}

.my-table tr:nth-child(odd) {
  background: #fff;
}

    Service
    Provider
    Check
    Marker
    Captured Time
    Final Time
    Status
    Comments

    Sub Heading

    Custody C
    I

          Settlements
          Finance
          Time 3
          Time 5
          Bad
          Good

          Crossroad

                Complete

                Partial

                Time 4a

                Time 4b

                Time 6a

                Time 6b

          Ok
          danke

    Service
    Provider
    Check
    Marker
    Captured Time
    Final Time
    Status
    Comments

    Sub Heading

    Custody T
    G

          Trades

          Position

    Latest
    TIME 1
    TIME 2
    Good
    My Comments

    Custody C
    I

          Settlements

          Crossroad

          Finance

                Complete

                Partial

          Time 3

                Time 4a

                Time 4b

            Time 5

                Time 6a

                Time 6b

          Bad

          Ok

          Good

          danke

Body:
To answer the question:

I am trying to get Settlements Finance Time 3 Time 5 Bad Good in a single line in lower table.

Vertically aligning your table cells will bring the content to the top of the cells, regardless of how many lines of content follows.

.my-table td {
  vertical-align: top;
}

JSFiddle Example: https://jsfiddle.net/jennifergoncalves/y1Lr0mzw/

Please let me know if I missed what you were trying to accomplish.


来源: stackexchange

问:
Does Windows 7 IE 11 support video streaming without plugins
I have a very specific target audience that I need to stream live video to (not prerecorded), that must run stock Internet Explorer 11 on Windows 7. This means without Flash, Silverlight or any other plugins. Is this possible? My fears are that it is not, but I thought I would ask just in case I'm missing some special feature.

To reiterate:

1 Only needs to support 1 browser, IE 11 running under Window 7

2 No browser plugins

3 JavaScript is ok

Please note that I already tried broadway, it was not performant enough.

答:
Sadly, MPEG-DASH is not available for IE11 under Windows 7 as MSE (Media Source Extensions) is not supported by this config (see MSE documentation).

As far as I could read, Flash is the only reliable way to play DASH on IE11+Win7. Yes, this is very sad. It works only for Win 8.1+.

Same problem with HLS, it is only natively supported by Edge on Win10.

Did you manage to find an acceptable compromise? I'm also looking for a solution for the same setup.

ContentLicense: CC BY-SA 3.0


问:
java.sql.SQLException: No suitable driver found for jdbc::mysql://localhost:3306/asd eroor
```<code>import java.sql.*;

class Mysqll{
    public static void main(String args[]){
        try{
        Class.forName("com.mysql.jdbc.Driver");
        Connection con = DriverManager.getConnection("jdbc::mysql://localhost:3306/asd","root","qwerty");
        Statement st = con.createStatement();

        ResultSet rs = st.executeQuery("select * from abc");

        while(rs.next())
        {
            System.out.println(rs.getInt(1) + "   " + rs.getString(2));
        }
        con.close();
        }
        catch(Exception e)
        {
            System.out.println(e);
        }
    }
}
</code>```

I am new to jdbc programming. So plese help.
Getting this Exception while running the program.

```<code>java.sql.SQLException: No suitable driver found for jdbc::mysql://localhost:3306/asd
</code>```

I had copied mysql-connector.jar file into jre/lib/ext folder.
Thanx in advance.

答:
The connection string being passed to DriverManager is a URL. The formatting matters, and your problem is due to an extra colon between jdbc and mysql (verified by testing on my own system).

Replace jdbc::mysql: with jdbc:mysql:.

Body:
import java.sql.*;

class Mysqll{
    public static void main(String args[]){
        try{
        Class.forName("com.mysql.jdbc.Driver");
        Connection con = DriverManager.getConnection("jdbc::mysql://localhost:3306/asd","root","qwerty");
        Statement st = con.createStatement();

        ResultSet rs = st.executeQuery("select * from abc");

        while(rs.next())
        {
            System.out.println(rs.getInt(1) + "   " + rs.getString(2));
        }
        con.close();
        }
        catch(Exception e)
        {
            System.out.println(e);
        }
    }
}

I am new to jdbc programming. So plese help.
Getting this Exception while running the program.

java.sql.SQLException: No suitable driver found for jdbc::mysql://localhost:3306/asd

I had copied mysql-connector.jar file into jre/lib/ext folder.
Thanx in advance.


问:
Conversion from 'char' to non-scalar type 'Vector<char>' error thrown unknown reason
Error Thrown Unknown Reason

```<code>#include "std_lib_facilities.h"

int main()
{
    vector<char> shape = ('a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a');
    return(0);
}
</code>```

that one line with the vector throws this error that I've never seen before nor can figure out...

:: g++ TicTacToe.cpp -o TTT

TicTacToe.cpp: In function int main()':

TicTacToe.cpp:5: error: conversion fromchar' to non-scalar type `Vector' requested

See in each tic-tac-toe box it will start as _ and then go to either X or O, I'm doing this without a graphics library so its terminal graphics.

答: vector doesn't have such a constructor. See the valid constructors.</p>

ContentLicense: CC BY-SA 2.5

Body:
Error Thrown Unknown Reason

#include "std_lib_facilities.h"

int main()
{
    vector<char> shape = ('a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a');
    return(0);
}

that one line with the vector throws this error that I've never seen before nor can figure out...

:: g++ TicTacToe.cpp -o TTT

TicTacToe.cpp: In function int main()':

TicTacToe.cpp:5: error: conversion fromchar' to non-scalar type `Vector' requested

See in each tic-tac-toe box it will start as _ and then go to either X or O, I'm doing this without a graphics library so its terminal graphics.


问:
Error printing a vector with names
I have a vector named "list" and I want to print the names that are in the list but it says

operator "<<" matches these operand

operand types are: std::ostream << std::string

Why do I have this error and how cand I fix it?

```<code>#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
vector<string> list;

vector<string> getAll() {     //I tried to use this function instread of "list"(list is used below) but it's the same result.
    return list;
}

int main() {

    list.push_back("Ion");
    list.push_back("Gabi");
    list.push_back("Sabrina");

    for (string i : list)
        std::cout << i;           //HERE

    }
</code>```

答: You have missed to add library for string, include it, by #include <string>. The header <string> also declares the stream inserter.

Title: Error printing a vector with names

Body:
I have a vector named "list" and I want to print the names that are in the list but it says

operator "<<" matches these operand

operand types are: std::ostream << std::string

Why do I have this error and how cand I fix it?

#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
vector<string> list;

vector<string> getAll() {     //I tried to use this function instread of "list"(list is used below) but it's the same result.
    return list;
}

int main() {

    list.push_back("Ion");
    list.push_back("Gabi");
    list.push_back("Sabrina");

    for (string i : list)
        std::cout << i;           //HERE

    }


问:
Scoring and Ranking the models in R
I am doing predictive modelling of Multivariate Time series Data in R using various models such as Arima, H2O.Randomforest, glmnet, lm and few other models.

I created a function to select a model of our choice and do prediction.

```<code>Model1 <- function(){
  ..
  return()
}
Model2 <- function(){
  ...
  return()
}
 Model3 <- function(){
  ...
  return()
}
main <- function(n){
  if(n == 1) {
   Model1()
  }
  else if(n == 2){
    Model2()
  }
  else if(n == 3){
    Model3()
  }}
</code>```

Now I am supposed to automate these models which gives RMSE and MAPE by finding accuracy between predicted and observed value. I would like to provide scores (eg. out of 5) for each based on the performance. For example, if Arima gives a low RMSE than other models, it will be scored high and the second lowest RMSE model will score a less than Arima and so on.

And every time i run those models with different input Data , it must give the mean score of a model. what I mean to say is,

```<code>1. for model1 it will give scores of each model, let's say *s1*.
2. for model2 run it give scores of each model, and let's call it *s2*.
</code>```

And i want a mean score of that model every time i run it with different input. It is more like scoring and ranking method.

Are there any methods or packages in R that can give a glimpse of how it is done? or any examples? Any suggestions would be very helpful. I have even shared my question here on Cross validated.

Thank you.

答:
To the best of my knowledge there is no single one package that does all that for you without some work from your side. You will need to look for packages that provide ways to do what you need.

Since you haven't provided any reproducible data and only voiced a general idea of what you would like as an example I can only give you a broad idea on what to expect, how I would do this sort of thing and what problems you most likely will encounter:

1. Model Fitting

You need to have a good idea of how you want to fit the models to the data. Take ARIMA for example: It has three orders (p, d, q). By what order do you want to fit your data? A simple ARIMA(1,0,1) model? Or do you need a higher order? There are, again, methods of best fit e. g. by fitting different orders and then selecting the order with the best(lowest) AIC. This article from quantstart is a nice example for a univariate series + code example for estimating different orders and picking the most suitable one.

Check out to what degree you need to set this up for your other models (H2O.Randomforest, glmnet, lm, etc.) aswell. Set this process up in functions.

2. Model Selection

So in Step 1 you fitted your various models to the time series data and have different results. Now you need to combine your goodness-of-fit criteria RMSE/MAPE) in a list/vector. Either they are already part of the output-object from your respective model or you need to compute them yourself. If they already are part of the estimation process, all the better. As part of the function for estimating the process, add, if necessary, the computation and then add the results for the model to the previously mentioned list/vector.

Rank the list by your desired criteria (ascending/descending and highest/lowest) and give that list as an output.
Additionally you probably want to add the results from the best fit, which you can do by appending the highest ranked result to your output.

Again, without specific code examples and problems you face it's difficult to help you. Try setting up something concrete and if you run into specific problems you can always ask for help here. Providing dummy-data and the code you used will greatly improve your chance on answers to your problems.

Title: Scoring and Ranking the models in R

Body:
I am doing predictive modelling of Multivariate Time series Data in R using various models such as Arima, H2O.Randomforest, glmnet, lm and few other models.

I created a function to select a model of our choice and do prediction.

Model1 <- function(){
  ..
  return()
}
Model2 <- function(){
  ...
  return()
}
 Model3 <- function(){
  ...
  return()
}
main <- function(n){
  if(n == 1) {
   Model1()
  }
  else if(n == 2){
    Model2()
  }
  else if(n == 3){
    Model3()
  }}

Now I am supposed to automate these models which gives RMSE and MAPE by finding accuracy between predicted and observed value. I would like to provide scores (eg. out of 5) for each based on the performance. For example, if Arima gives a low RMSE than other models, it will be scored high and the second lowest RMSE model will score a less than Arima and so on.

And every time i run those models with different input Data , it must give the mean score of a model. what I mean to say is,

1. for model1 it will give scores of each model, let's say *s1*.
2. for model2 run it give scores of each model, and let's call it *s2*.

And i want a mean score of that model every time i run it with different input. It is more like scoring and ranking method.

Are there any methods or packages in R that can give a glimpse of how it is done? or any examples? Any suggestions would be very helpful. I have even shared my question here on Cross validated.

Thank you.


问:
Elastic Search sorting and ranking
I am using elastic search version 2.x. And I have two records which are indexed as:

bathroom wall tile (as "nickname" indexed document column)

tile wall bathroom (as "nickname" indexed document column)

When I am trying to search for phrase "tile wall bathroom" ideally second should appear first because that is exact match and after that first will appear because all the 3 words matches(tile, wall and bathroom).

I put sorting in my query based on columns. Below is my elastic search query:

```<code>{
                          "query" : {
                                "filtered" : {
                                      "query" : {
                                            "query_string": {
                                                "query": "*tile wall bathroom*",
                                                "fields": [
                                                    "nickname",
                                                    "comments",
                                                    "category_name",
                                                    "subcategory_name",
                                                    "document_name",
                                                    "web_links",
                                                    "document_extension",
                                                    "property_name",
                                                    "document_content"
                                                ],
                                                "analyze_wildcard": true
                                            }
                                      },
                                      "filter" : {
                                            "and" : [
                                                  {"term" : {"property_id" : "6"}}
                                            ]
                                      }
                                }
                          },
                          "size": 10,
                          "sort": ["nickname", "comments", "web_links", "document_name"]
                    }
</code>```

For reference please find attached image.

Thanks in advance!!!

答:
All of your 3 terms hit, since both document-fields consist of "bathroom", "tile" and "wall". So it is common to retrieve both documents as hits. As you suggest, in general when sorted by score the first document should be ranked higher than the second one.

Since your first sort-field is the "nickname"-field, you get this result set where firstly all documents are sorted in alphabetical order on their "nickname"-fields (b in "bathroom wall tile" comes before t "tile wall bathroom", etc). This excludes sort by relevance-score on your search-request. You may use "nickname" as secondary sort parameter and the "_score"-field as first one instead.

You may as well check your query with the Elasticsearch-explain functionality.

Cheers, Dominik

Edit: Please try to run your query against the Elasticsearch-Explain-API, which enables to understand how your result has been computed. Furthermore, you may run a match-query against your data to see if your results improve against the usage of "query_string". Hereby, you may also leave out the sort-parameters to rank the results only by their relevance-score.

```<code>{
    "query": {
        "match": {
            "nickname": "tile wall bathroom"
        },
        "size": 10,
        "sort": ["_score", "nickname", "comments", "web_links", "document_name"]
    }
}
</code>```

Title: Elastic Search sorting and ranking

Body:
I am using elastic search version 2.x. And I have two records which are indexed as:

bathroom wall tile (as "nickname" indexed document column)

tile wall bathroom (as "nickname" indexed document column)

When I am trying to search for phrase "tile wall bathroom" ideally second should appear first because that is exact match and after that first will appear because all the 3 words matches(tile, wall and bathroom).

I put sorting in my query based on columns. Below is my elastic search query:

{
                          "query" : {
                                "filtered" : {
                                      "query" : {
                                            "query_string": {
                                                "query": "*tile wall bathroom*",
                                                "fields": [
                                                    "nickname",
                                                    "comments",
                                                    "category_name",
                                                    "subcategory_name",
                                                    "document_name",
                                                    "web_links",
                                                    "document_extension",
                                                    "property_name",
                                                    "document_content"
                                                ],
                                                "analyze_wildcard": true
                                            }
                                      },
                                      "filter" : {
                                            "and" : [
                                                  {"term" : {"property_id" : "6"}}
                                            ]
                                      }
                                }
                          },
                          "size": 10,
                          "sort": ["nickname", "comments", "web_links", "document_name"]
                    }

For reference please find attached image.

Thanks in advance!!!

Body:
All of your 3 terms hit, since both document-fields consist of "bathroom", "tile" and "wall". So it is common to retrieve both documents as hits. As you suggest, in general when sorted by score the first document should be ranked higher than the second one.

Since your first sort-field is the "nickname"-field, you get this result set where firstly all documents are sorted in alphabetical order on their "nickname"-fields (b in "bathroom wall tile" comes before t "tile wall bathroom", etc). This excludes sort by relevance-score on your search-request. You may use "nickname" as secondary sort parameter and the "_score"-field as first one instead.

You may as well check your query with the Elasticsearch-explain functionality.

Cheers, Dominik

Edit: Please try to run your query against the Elasticsearch-Explain-API, which enables to understand how your result has been computed. Furthermore, you may run a match-query against your data to see if your results improve against the usage of "query_string". Hereby, you may also leave out the sort-parameters to rank the results only by their relevance-score.

{
    "query": {
        "match": {
            "nickname": "tile wall bathroom"
        },
        "size": 10,
        "sort": ["_score", "nickname", "comments", "web_links", "document_name"]
    }
}


问:
php & mysql please select an other date- message is not appearing
I have two issues and both are linked.  First, "already booked - please select another date" is not appearing, if two clients select the same product (pg_no) and date (Date).  These fields are  UNIQUE CONSTRAINT.

Second, when data is inserted or submitted localhost shows complete address
    http://localhost/lstcomp/index.php?note=submitted. But when  it fails the localhost shows only : http://localhost/lstcomp/

```<code><?php
//connecting string
include("dbconnect.php");
//assigning
$name  = $_REQUEST['Name'];
$tele  = $_REQUEST['Tele'];
$city  = $_REQUEST['City'];
// UNIQUE CONSTRAINT
$pg_no = $_REQUEST['pg_no']; //product
$date  = $_REQUEST['Date']; //date

//checking if pg_no and Date are same
$check = mysqli_query($db_connect, "SELECT * FROM lstclient WHERE pg_no='{$pg_no}', Date='{$date}'");

{
    echo "Already booked  please select another date<br/>";
}
//if not same then insert data
 else
{
    $query = mysqli_query($db_connect, "INSERT INTO lstclient(pg_no,Name,Tele,City,Date) VALUES('$pg_no','$name','$tele','$city','$date')") or die(mysql_error());
}
mysqli_close($db_connect);

// messaging
if ($query) {
    header("location:index.php?note=failed");
} else {
    header("location:index.php?note=success");
}

?>
</code>```

答:
There are a few problems:

The file fails to parse because of the dangling else; it's not paired with an if-statement.

```<code>{
    echo "Already booked  please select another date<br/>";
}
//if not same then insert data
else
{
    $query = mysqli_query($db_connect, "INSERT INTO lstclient(pg_no,Name,Tele,City,Date) VALUES('$pg_no','$name','$tele','$city','$date')") or die(mysql_error());
}
</code>```

It looks like you're intending to use the result from your SELECT statement ($check), however...

The SELECT statement is invalid; WHERE clauses are separated with AND or OR, not commas.

When inserting the row into the database table, you're dying on mysql_error when you've been using the mysqli extension.

You're vulnerable to SQL injection attacks; if pg_no happened to be '; DELETE FROM users; --, as an example, your user table would be deleted. You're already using the mysqli extension, so use parameter binding and prepared statements. Reference

Body:
I have two issues and both are linked.  First, "already booked - please select another date" is not appearing, if two clients select the same product (pg_no) and date (Date).  These fields are  UNIQUE CONSTRAINT.

Second, when data is inserted or submitted localhost shows complete address
    http://localhost/lstcomp/index.php?note=submitted. But when  it fails the localhost shows only : http://localhost/lstcomp/

<?php
//connecting string
include("dbconnect.php");
//assigning
$name  = $_REQUEST['Name'];
$tele  = $_REQUEST['Tele'];
$city  = $_REQUEST['City'];
// UNIQUE CONSTRAINT
$pg_no = $_REQUEST['pg_no']; //product
$date  = $_REQUEST['Date']; //date

//checking if pg_no and Date are same
$check = mysqli_query($db_connect, "SELECT * FROM lstclient WHERE pg_no='{$pg_no}', Date='{$date}'");

{
    echo "Already booked  please select another date
";
}
//if not same then insert data
 else
{
    $query = mysqli_query($db_connect, "INSERT INTO lstclient(pg_no,Name,Tele,City,Date) VALUES('$pg_no','$name','$tele','$city','$date')") or die(mysql_error());
}
mysqli_close($db_connect);

// messaging
if ($query) {
    header("location:index.php?note=failed");
} else {
    header("location:index.php?note=success");
}

?>

Body:
There are a few problems:

The file fails to parse because of the dangling else; it's not paired with an if-statement.

{
    echo "Already booked  please select another date<br/>";
}
//if not same then insert data
else
{
    $query = mysqli_query($db_connect, "INSERT INTO lstclient(pg_no,Name,Tele,City,Date) VALUES('$pg_no','$name','$tele','$city','$date')") or die(mysql_error());
}

It looks like you're intending to use the result from your SELECT statement ($check), however...

The SELECT statement is invalid; WHERE clauses are separated with AND or OR, not commas.

When inserting the row into the database table, you're dying on mysql_error when you've been using the mysqli extension.

You're vulnerable to SQL injection attacks; if pg_no happened to be '; DELETE FROM users; --, as an example, your user table would be deleted. You're already using the mysqli extension, so use parameter binding and prepared statements. Reference


问:
Timepicker with 15 minute intervals
I have a custom dialog with a timepicker and a datepicker. I want to set the timepicker's minute spinner collection to [0, 15, 30, 45] ie 15 min intervals.

Now i see several solutions but none seem to cover the fact that the UI will show the next and previous minutes as -1 and +1 minutes of selected minute eg 29, 30, 31 are shown to user.

Also, im not clear on how i attach my custom timepicker to an activity - do i not need a customerTimePicker xml component to do this?

So in short - do i adjust the native timepicker or need to build a custom xml and class?

What i have at present
Layout:

```<code><TimePicker
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/timePicker_fixture"
    android:layout_weight="1" />
</code>```

Activity

```<code>TimePicker timePicker_fixture = (TimePicker) dialog.findViewById(R.id.timePicker_fixture);
timePicker_fixture.setIs24HourView(true);
</code>```

A suggested custom class (how do i use this - do i need a custom xml component in my layout?)

```<code>public class CustomTimePickerDialog extends TimePickerDialog {

    private final static int TIME_PICKER_INTERVAL = 15;
    private TimePicker timePicker;
    private final OnTimeSetListener callback;

    public CustomTimePickerDialog(Context context, OnTimeSetListener callBack,
                                  int hourOfDay, int minute, boolean is24HourView) {
        super(context, TimePickerDialog.THEME_HOLO_LIGHT, callBack, hourOfDay, minute / TIME_PICKER_INTERVAL,
                is24HourView);
        this.callback = callBack;
    }

    @Override
    public void onClick(DialogInterface dialog, int which) {
        if (callback != null && timePicker != null) {
            timePicker.clearFocus();
            callback.onTimeSet(timePicker, timePicker.getCurrentHour(),
                    timePicker.getCurrentMinute() * TIME_PICKER_INTERVAL);
        }
    }

    @Override
    protected void onStop() {
    }

    @Override
    public void onAttachedToWindow() {
        super.onAttachedToWindow();
        try {
            Class<?> classForid = Class.forName("com.android.internal.R$id");
            Field timePickerField = classForid.getField("timePicker");
            this.timePicker = (TimePicker) findViewById(timePickerField
                    .getInt(null));
            Field field = classForid.getField("minute");

            NumberPicker mMinuteSpinner = (NumberPicker) timePicker
                    .findViewById(field.getInt(null));
            mMinuteSpinner.setMinValue(0);
            mMinuteSpinner.setMaxValue((60 / TIME_PICKER_INTERVAL) - 1);
            List<String> displayedValues = new ArrayList<String>();
            for (int i = 0; i < 60; i += TIME_PICKER_INTERVAL) {
                displayedValues.add(String.format("%02d", i));
            }
            mMinuteSpinner.setDisplayedValues(displayedValues
                    .toArray(new String[0]));
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

}
</code>```

答:
The answer above didn't work for me in Android 7 Nougat, basically the date picker is changed completely by the Clock mode... I kind of merge this code with https://gist.github.com/jeffdgr8/6bc5f990bf0c13a7334ce385d482af9f, then it set by default the mode of the TimePickerDialog to show the Spinner controls, and then it runs the code to show only 15minuts intervals.

The result is here: https://gist.github.com/smaugho/14dae83f3284fa05455ee0a9e4f13099

Title: Timepicker with 15 minute intervals

Body:
I have a custom dialog with a timepicker and a datepicker. I want to set the timepicker's minute spinner collection to [0, 15, 30, 45] ie 15 min intervals.

Now i see several solutions but none seem to cover the fact that the UI will show the next and previous minutes as -1 and +1 minutes of selected minute eg 29, 30, 31 are shown to user.

Also, im not clear on how i attach my custom timepicker to an activity - do i not need a customerTimePicker xml component to do this?

So in short - do i adjust the native timepicker or need to build a custom xml and class?

What i have at present
Layout:

<TimePicker
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/timePicker_fixture"
    android:layout_weight="1" />

Activity

TimePicker timePicker_fixture = (TimePicker) dialog.findViewById(R.id.timePicker_fixture);
timePicker_fixture.setIs24HourView(true);

A suggested custom class (how do i use this - do i need a custom xml component in my layout?)

public class CustomTimePickerDialog extends TimePickerDialog {

    private final static int TIME_PICKER_INTERVAL = 15;
    private TimePicker timePicker;
    private final OnTimeSetListener callback;

    public CustomTimePickerDialog(Context context, OnTimeSetListener callBack,
                                  int hourOfDay, int minute, boolean is24HourView) {
        super(context, TimePickerDialog.THEME_HOLO_LIGHT, callBack, hourOfDay, minute / TIME_PICKER_INTERVAL,
                is24HourView);
        this.callback = callBack;
    }

    @Override
    public void onClick(DialogInterface dialog, int which) {
        if (callback != null && timePicker != null) {
            timePicker.clearFocus();
            callback.onTimeSet(timePicker, timePicker.getCurrentHour(),
                    timePicker.getCurrentMinute() * TIME_PICKER_INTERVAL);
        }
    }

    @Override
    protected void onStop() {
    }

    @Override
    public void onAttachedToWindow() {
        super.onAttachedToWindow();
        try {
            Class<?> classForid = Class.forName("com.android.internal.R$id");
            Field timePickerField = classForid.getField("timePicker");
            this.timePicker = (TimePicker) findViewById(timePickerField
                    .getInt(null));
            Field field = classForid.getField("minute");

            NumberPicker mMinuteSpinner = (NumberPicker) timePicker
                    .findViewById(field.getInt(null));
            mMinuteSpinner.setMinValue(0);
            mMinuteSpinner.setMaxValue((60 / TIME_PICKER_INTERVAL) - 1);
            List<String> displayedValues = new ArrayList<String>();
            for (int i = 0; i < 60; i += TIME_PICKER_INTERVAL) {
                displayedValues.add(String.format("%02d", i));
            }
            mMinuteSpinner.setDisplayedValues(displayedValues
                    .toArray(new String[0]));
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

}


问:
PowerBuilder, function saveas generates empty files under Windows 10
I recently upgraded my computer to WINDOWS 10 and I am having troubles with the saveas function.

Using PowerBuilder 11.5 Build 2506 under WINDOWS 10.
When I Use the function 'saveas' in order to generate a PDF file from a datawindow, it creates an empty file.

Does anyone have encountered this before ?

Thank you in advance.

答: PowerBuilder does not have the native ability to generate PDFs prior to the most current version (2017 - which is now available from Appeon).  You must have been using some other tool (OCX, PDF printer type control, or Ghostscript) to do this.  Were these upgraded?  Also, PB 11.5 is not certified to run under Windows 10</p>


问:
How does app know if it started from a crash
Whenever I start the app I want to know if the app recovered from a crash. Can I store it in a flag ?

Do the crash and regular app exit scenario go through the same steps(lifecycle) in android ?

答:
Try to add Exception handling to the code to whatever is causing a crash.</p>

```<code>try{
   //code causing the crash
} catch (Exception e){
   //code to set flags whenever an event causing crash occurs.
}
</code>```

Body:
Try to add Exception handling to the code to whatever is causing a crash.

try{
   //code causing the crash
} catch (Exception e){
   //code to set flags whenever an event causing crash occurs.
}


问:
Web API Optional parameters in the middle
I have the following route mapping or WEB API

```<code>[Route("Foo/Id/{id=1}/bar")]
</code>```

I want to make Id optional as above however from client side no matter what I call it route doesn't match and I get 404
I try things like

```<code>Foo/Id//bar
</code>```

But doesn't work. Is there way to use optional parameters with web api if the parameter is not at the end?

答:
You could not use // in URL.
The only way to make things you want is to map 2 routes for one endpoint.
For examle</p>

```<code>config.Routes.MapHttpRoute(
   name: "BarRoute",
   routeTemplate: "Foo/Id/{id}/bar",
   defaults: new { controller = "Foo" });

config.Routes.MapHttpRoute(
   name: "BarDefaultRoute",
   routeTemplate: "Foo/Id/bar",
   defaults: new { controller = "Foo" });
</code>```

Body:
I have the following route mapping or WEB API

[Route("Foo/Id/{id=1}/bar")]

I want to make Id optional as above however from client side no matter what I call it route doesn't match and I get 404
I try things like

Foo/Id//bar

But doesn't work. Is there way to use optional parameters with web api if the parameter is not at the end?

Body:
You could not use // in URL.
The only way to make things you want is to map 2 routes for one endpoint.
For examle

config.Routes.MapHttpRoute(
   name: "BarRoute",
   routeTemplate: "Foo/Id/{id}/bar",
   defaults: new { controller = "Foo" });

config.Routes.MapHttpRoute(
   name: "BarDefaultRoute",
   routeTemplate: "Foo/Id/bar",
   defaults: new { controller = "Foo" });


问:
Create line after text with css
Im trying to make a line after each of my h2 tags. I can´t figure out how I should tell the width, cause the lenght of the h2 headlines is differ from h2 to h2.

I use the :after method to create lines

```<code>       h2:after {
       position: absolute;
       content: "";
       height: 2px;
       background-color: #242424;
       width: 50%;
       margin-left: 15px;
       top: 50%;
       }
</code>```

Check code here: http://jsfiddle.net/s9gHf/
As you can see the line get too wide, and make the website too wide.

答:
Here is another, in my opinion even simpler solution using a flex wrapper:

.wrapper {
  display: flex;
  align-items: center;
}

.line {
  border-top: 1px solid grey;
  flex-grow: 1;
  margin: 0 10px;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="wrapper">
  <p>Text</p>
  <div class="line"></div>
</div></code>```

External link

Title: Create line after text with css

Body:
Im trying to make a line after each of my h2 tags. I can´t figure out how I should tell the width, cause the lenght of the h2 headlines is differ from h2 to h2.

I use the :after method to create lines

       h2:after {
       position: absolute;
       content: "";
       height: 2px;
       background-color: #242424;
       width: 50%;
       margin-left: 15px;
       top: 50%;
       }

Check code here: http://jsfiddle.net/s9gHf/
As you can see the line get too wide, and make the website too wide.

Body:
Here is another, in my opinion even simpler solution using a flex wrapper:

.wrapper {
  display: flex;
  align-items: center;
}

.line {
  border-top: 1px solid grey;
  flex-grow: 1;
  margin: 0 10px;
}

<div class="wrapper">
  <p>Text</p>
  <div class="line"></div>
</div>

External link

ContentLicense: CC BY-SA 4.0


问:
session_start hangs
since a few hours our server hangs every time you do a session_start.

For testing purposes i created a script which looks like this:

```<code><?php
session_start();
?>
</code>```

Calling it from the console hangs and it can't even be stopped with ctrl-c, only kill -9 works. The same for calling it via Apache. /var/lib/php/session/ stays empty but permissions are absolutely fine, www can write and also has read permissions for all parent folders.

According to the admins there were no changes made on the server and there is no special code registered for sessions. The Server is CentOS 4 or 5 and yesterday everything was working perfectly. We rebooted the server and updated PHP, but nothing changed.

I've ran out of ideas, any suggestions?

UPDATE

We solved this problem by moving the project to another server, so while the problem still exists on one server there is no immediate need for a solution anymore.
I will keep the question open in case someone has an idea for others having a similar problem in the future, though.

答:
To throw another answer into the mix for those going bananas, I had a session_start() dying only in particular cases and scripts. The reason my session was dying was ultimately because I was storing a lot of data in them after a particularly intensive script, and ultimately the call to session_start() was exhausting the 'memory_limit' setting in php.ini.

After increasing 'memory_limit', those session_start() calls no longer killed my script.

Title: session_start hangs

Body:
since a few hours our server hangs every time you do a session_start.

For testing purposes i created a script which looks like this:

<?php
session_start();
?>

Calling it from the console hangs and it can't even be stopped with ctrl-c, only kill -9 works. The same for calling it via Apache. /var/lib/php/session/ stays empty but permissions are absolutely fine, www can write and also has read permissions for all parent folders.

According to the admins there were no changes made on the server and there is no special code registered for sessions. The Server is CentOS 4 or 5 and yesterday everything was working perfectly. We rebooted the server and updated PHP, but nothing changed.

I've ran out of ideas, any suggestions?

UPDATE

We solved this problem by moving the project to another server, so while the problem still exists on one server there is no immediate need for a solution anymore.
I will keep the question open in case someone has an idea for others having a similar problem in the future, though.


问:
Is it possible to put a tuple in an enum with Swift?
If I have the following enum:

```<code>enum FruitTuple
{
    static let Apple = (shape:"round",colour:"red")
    static let Orange = (shape:"round",colour:"orange")
    static let Banana = (shape:"long",colour:"yellow")
}
</code>```

Then I have the following function:

```<code>static func PrintFruit(fruit:FruitTuple)
{
    let shape:String = fruit.shape
    let colour:String = fruit.colour

    print("Fruit is \(shape) and \(colour)")
}
</code>```

On the fruit.shape and fruit.colour I get the error:

Value of type 'FruitTuple' has no member 'shape'

Fair enough, so I alter the enum to have a type:

```<code>enum FruitTuple:(shape:String, colour:String)
{
    static let Apple = (shape:"round",colour:"red")
    static let Orange = (shape:"round",colour:"orange")
    static let Banana = (shape:"long",colour:"yellow")
}
</code>```

But then on the enum declaration I get the error:

Inheritance from non-named type '(shape: String, colour: String)'

So, the question is: Is it even possible to have a tuple in an enum and be able to reference it's component parts in such a way? Am I just missing something fundamental here?

答:
As pointed out by @MartinR. Also, according to Apple docs, "enumeration cases can specify associated values of any type to be stored along with each different case value". If you want to keep using enum, you may need to do something like:

```<code>static func PrintFruit(fruit:FruitTuple.Apple)
{
    let shape:String = fruit.shape
    let colour:String = fruit.colour

    print("Fruit is \(shape) and \(colour)")
}
</code>```

I'm not certain of what you want, but I guess using typealias could help achieve your goal.

```<code>typealias FruitTuple = (shape: String, colour: String)

enum Fruit
{
    static let apple = FruitTuple("round" , "red")
    static let orange = FruitTuple("round", "orange")
    static let banana = FruitTuple("long", "yellow")
}

func printFruit(fruitTuple: FruitTuple)
{
    let shape:String = fruitTuple.shape
    let colour:String = fruitTuple.colour
}
</code>```

Body:
If I have the following enum:

enum FruitTuple
{
    static let Apple = (shape:"round",colour:"red")
    static let Orange = (shape:"round",colour:"orange")
    static let Banana = (shape:"long",colour:"yellow")
}

Then I have the following function:

static func PrintFruit(fruit:FruitTuple)
{
    let shape:String = fruit.shape
    let colour:String = fruit.colour

    print("Fruit is \(shape) and \(colour)")
}

On the fruit.shape and fruit.colour I get the error:

Value of type 'FruitTuple' has no member 'shape'

Fair enough, so I alter the enum to have a type:

enum FruitTuple:(shape:String, colour:String)
{
    static let Apple = (shape:"round",colour:"red")
    static let Orange = (shape:"round",colour:"orange")
    static let Banana = (shape:"long",colour:"yellow")
}

But then on the enum declaration I get the error:

Inheritance from non-named type '(shape: String, colour: String)'

So, the question is: Is it even possible to have a tuple in an enum and be able to reference it's component parts in such a way? Am I just missing something fundamental here?

Body:
As pointed out by @MartinR. Also, according to Apple docs, "enumeration cases can specify associated values of any type to be stored along with each different case value". If you want to keep using enum, you may need to do something like:

static func PrintFruit(fruit:FruitTuple.Apple)
{
    let shape:String = fruit.shape
    let colour:String = fruit.colour

    print("Fruit is \(shape) and \(colour)")
}

I'm not certain of what you want, but I guess using typealias could help achieve your goal.

typealias FruitTuple = (shape: String, colour: String)

enum Fruit
{
    static let apple = FruitTuple("round" , "red")
    static let orange = FruitTuple("round", "orange")
    static let banana = FruitTuple("long", "yellow")
}

func printFruit(fruitTuple: FruitTuple)
{
    let shape:String = fruitTuple.shape
    let colour:String = fruitTuple.colour
}


问:
angular datatable and datatable plugin is not working
this will be show as "$scope.RegionData.withDOM is not a function" and also "$scope.RegionData.withButtons is not a function".

and also it will show as " DTColumnBuilder is not defined".

```<code>  <div ng-controller="RegionController">
   <div class="col-lg-12">
    <div class="panel-body">
        <div class="table-responsive">
              <table datatable="" dt-options="dtOptions" dt-columns="dtColumns" class="table table-striped table-bordered table-hover">
           </table>
        </div>
    </div>
  </div>
  </div>
</code>```

in my controller code is written as calling so api is return in json format.

```<code>     .controller('RegionController', function( $scope , regionService) {
     $scope.dtOptions = $scope.RegionData
     .withDOM("<'row'<'col-sm-4'l><'col-sm-4 text-center'B><'col-sm-4'f>>tp")
    .withButtons(
        [
        {extend: 'copy',className: 'btn-sm'},
        {extend: 'csv',title: 'ExampleFile', className: 'btn-sm'},
        {extend: 'pdf', title: 'ExampleFile', className: 'btn-sm'},
        {extend: 'print',className: 'btn-sm'}
        ]
    );
     $scope.dtColumns =
     [
            DTColumnBuilder.newColumn('region_id').withTitle('Region ID'),
            DTColumnBuilder.newColumn('region_name').withTitle('Region Name'),
            DTColumnBuilder.newColumn('region_code').withTitle('Region Code'),
            DTColumnBuilder.newColumn('created_by').withTitle('Created By')

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

an also my index file as to be  written as

```<code>  <link rel="stylesheet" href="app/bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css" />
<!-- App styles -->
<link rel="stylesheet" href="app/fonts/pe-icon-7-stroke/css/pe-icon-7-stroke.css" />
<link rel="stylesheet" href="app/fonts/pe-icon-7-stroke/css/helper.css" />
<link rel="stylesheet" href="app/styles/style.css">

<script type="text/javascript" src="app/bower_components/jquery/dist/jquery.min.js"></script>
<script type="text/javascript" src="app/bower_components/jquery-ui/jquery-ui.min.js"></script>
<script type="text/javascript" src="app/bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>

<script type="text/javascript" src="app/JSCRIPT/bootstrap/dist/js/bootstrap.min.js"></script>

<script type="text/javascript" src="app/bower_components/Flot/jquery.flot.js"></script>
<script type="text/javascript" src="app/bower_components/Flot/jquery.flot.resize.js"></script>
<script type="text/javascript" src="app/bower_components/Flot/jquery.flot.pie.js"></script>

<script type="text/javascript" src="app/bower_components/flot.curvedlines/curvedLines.js"></script>
<script type="text/javascript" src="app/bower_components/jquery.flot.spline/index.js"></script>
<script type="text/javascript" src="app/bower_components/metisMenu/dist/metisMenu.min.js"></script>
<script type="text/javascript" src="app/bower_components/iCheck/icheck.min.js"></script>

<script type="text/javascript" src="app/bower_components/datatables/media/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="app/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
<script type="text/javascript" src="app/bower_components/pdfmake/build/pdfmake.min.js"></script>
<script type="text/javascript" src="app/bower_components/pdfmake/build/vfs_fonts.js"></script>
<script type="text/javascript" src="app/bower_components/datatables.net-buttons/js/buttons.html5.min.js"></script>
<script type="text/javascript" src="app/bower_components/datatables.net-buttons/js/buttons.print.min.js"></script>
<script type="text/javascript" src="app/bower_components/datatables.net-buttons/js/dataTables.buttons.min.js"></script>
<script type="text/javascript" src="app/bower_components/datatables.net-buttons-bs/js/buttons.bootstrap.min.js"></script>

<script type="text/javascript" src="app/angular/angular.js"></script>
<script type="text/javascript" src="app/angular/angular-route.js"></script>
<script type="text/javascript" src="app/bower_components/angular-flot/angular-flot.js"></script>
<script type="text/javascript" src="app/bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js"></script>
<script type="text/javascript" src="app/bower_components/angular-datatables/dist/plugins/buttons/angular-datatables.buttons.min.js"></script>
<script type="text/javascript" src="app/bower_components/angular-datatables/dist/angular-datatables.min.js"></script>
</code>```

and this div is shown to table.

答:
You missed to inject DTOptionsBuilder and DTColumnBuilder inside your controller.

So install *angular-datatable* first. Then in your contoller inject: DTOptionsBuilder and DTColumnBuilder.

Ex:

```<code> .controller('RegionController', function( $scope , regionService, DTOptionsBuilder, DTColumnBuilder) { }
</code>```

Body:
this will be show as "$scope.RegionData.withDOM is not a function" and also "$scope.RegionData.withButtons is not a function".

and also it will show as " DTColumnBuilder is not defined".

in my controller code is written as calling so api is return in json format.

     .controller('RegionController', function( $scope , regionService) {
     $scope.dtOptions = $scope.RegionData
     .withDOM("<'row'<'col-sm-4'l><'col-sm-4 text-center'B><'col-sm-4'f>>tp")
    .withButtons(
        [
        {extend: 'copy',className: 'btn-sm'},
        {extend: 'csv',title: 'ExampleFile', className: 'btn-sm'},
        {extend: 'pdf', title: 'ExampleFile', className: 'btn-sm'},
        {extend: 'print',className: 'btn-sm'}
        ]
    );
     $scope.dtColumns =
     [
            DTColumnBuilder.newColumn('region_id').withTitle('Region ID'),
            DTColumnBuilder.newColumn('region_name').withTitle('Region Name'),
            DTColumnBuilder.newColumn('region_code').withTitle('Region Code'),
            DTColumnBuilder.newColumn('created_by').withTitle('Created By')

     ];
});

an also my index file as to be  written as

  <link rel="stylesheet" href="app/bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css" />

<link rel="stylesheet" href="app/fonts/pe-icon-7-stroke/css/pe-icon-7-stroke.css" />
<link rel="stylesheet" href="app/fonts/pe-icon-7-stroke/css/helper.css" />
<link rel="stylesheet" href="app/styles/style.css">

and this div is shown to table.

Body:
You missed to inject DTOptionsBuilder and DTColumnBuilder inside your controller.

So install *angular-datatable* first. Then in your contoller inject: DTOptionsBuilder and DTColumnBuilder.

Ex:

 .controller('RegionController', function( $scope , regionService, DTOptionsBuilder, DTColumnBuilder) { }


问:
TypeScript array methods not working
I am wrestling with some serious issues. I was trying to use in my code several array methods like push, includes, filter. None of them works.

     ERROR TypeError: Cannot read property 'push' of undefined

Simple use of push:

```<code>  users: User[];
  user = new User('','','','','','','','','');

  addUser(user){
    this.usersService.addUser(user)
    .subscribe(
      user => this.users.push(user),
      error => this.errMsg = <any> error);
  }
</code>```

UPDATE: Accidentally commented out initialization of Users.

```<code>this.getUsers();

if(this.users.find(this.checkLogin) === undefined){
  console.log('OK no login like this');
}else{
  console.log('Login like this exists');
}
checkLogin(element){
  return element === this.user.login;
}

getUsers(){
  this.usersService.getUsers()
  .subscribe(
    users => this.users = users,
    error => this.errMsg = <any> error);
}
</code>```

Still getting error:

ERROR TypeError: Cannot read property 'find' of undefined

答:
Change:

```<code> users: User[];
</code>```

To:

```<code>  users: User[] = [];
</code>```

Title: TypeScript array methods not working

Body:
I am wrestling with some serious issues. I was trying to use in my code several array methods like push, includes, filter. None of them works.

     ERROR TypeError: Cannot read property 'push' of undefined

Simple use of push:

  users: User[];
  user = new User('','','','','','','','','');

  addUser(user){
    this.usersService.addUser(user)
    .subscribe(
      user => this.users.push(user),
      error => this.errMsg = <any> error);
  }

UPDATE: Accidentally commented out initialization of Users.

this.getUsers();

if(this.users.find(this.checkLogin) === undefined){
  console.log('OK no login like this');
}else{
  console.log('Login like this exists');
}
checkLogin(element){
  return element === this.user.login;
}

getUsers(){
  this.usersService.getUsers()
  .subscribe(
    users => this.users = users,
    error => this.errMsg = <any> error);
}

Still getting error:

ERROR TypeError: Cannot read property 'find' of undefined

Body:
Change:

 users: User[];

To:

  users: User[] = [];


问:
How can I construct the equivalent of this PHP foreach() rendering in Vue.js?
I know this is a very silly question but im new to vuejs and i would like to know how to convert this simple php code to vuejs

```<code><div>
<?php
 foreach( $array as $key => $value){
  if($key == 0){
    echo '<div>'.$key.'</div>';
  }else{
   echo '<div>'.$value.'</div>';
  }
}
?>
<div>
</code>```

it should go something like this :

```<code><div>
 <div v-for="(item, key) in items" v-if="key == 0">{{key}}</div>
 <div v-else>{{item}}</div>
</div>
</code>```

答:
Try this:

```<code><template v-for="(item, index) in items">
  <div v-if="index === 0">{{index}}</div>
  <div v-else>{{item}}</div>
</template>
</code>```

JSFiddle

Body:
I know this is a very silly question but im new to vuejs and i would like to know how to convert this simple php code to vuejs

<?php
 foreach( $array as $key => $value){
  if($key == 0){
    echo '
'.$key.'
';
  }else{
   echo '
'.$value.'
';
  }
}
?>

it should go something like this :

{{key}}

{{item}}

Body:
Try this:

<template v-for="(item, index) in items">
  <div v-if="index === 0">{{index}}</div>
  <div v-else>{{item}}</div>
</template>

JSFiddle


问:
Find Latest Record With Specific Values
I want to find the row with the latest Date in the group. However, if that row has some specific value in specific column, then we must eliminate the row completely
For Ex in the following table:

```<code> ID   FK_ID    DateTiME     Value
  1     1     2017-06-01    a
  2     1     2017-06-02    a
  3     2     2017-06-04    b
  4     2     2017-06-03    a
  5     2     2017-06-01    b
  6     3     2017-01-01    c
  7     3     2017-01-01    a
</code>```

Here I want the output as

```<code>FK_ID   DateTime
  1    2017-06-02
  3    2017-01-01
</code>```

I want to group on FK_ID and then want the Max DateTime Value from the Group. However, If the selected Row of the Group has Value as b then we should skip the row entirely and don't want it in the output.

For Example, in the above table(1), the row with Max DateTime for FK_ID 2 is

```<code>  3     2     2017-06-04    b
</code>```

However, as the value for this row is b, we don't want it in the output.

答:
Use row_number</p>

```<code>With CTE as
(
select t1.*, row_number() over (partition by FK_ID order by datetime desc) rn
from MyTable t1
)
select *
from CTE
where rn = 1
and value <> 'b'
</code>```

Title: Find Latest Record With Specific Values

Body:
I want to find the row with the latest Date in the group. However, if that row has some specific value in specific column, then we must eliminate the row completely
For Ex in the following table:

 ID   FK_ID    DateTiME     Value
  1     1     2017-06-01    a
  2     1     2017-06-02    a
  3     2     2017-06-04    b
  4     2     2017-06-03    a
  5     2     2017-06-01    b
  6     3     2017-01-01    c
  7     3     2017-01-01    a

Here I want the output as

FK_ID   DateTime
  1    2017-06-02
  3    2017-01-01

I want to group on FK_ID and then want the Max DateTime Value from the Group. However, If the selected Row of the Group has Value as b then we should skip the row entirely and don't want it in the output.

For Example, in the above table(1), the row with Max DateTime for FK_ID 2 is

  3     2     2017-06-04    b

However, as the value for this row is b, we don't want it in the output.

Body:
Use row_number

With CTE as
(
select t1.*, row_number() over (partition by FK_ID order by datetime desc) rn
from MyTable t1
)
select *
from CTE
where rn = 1
and value <> 'b'


答:
Here is one way to this</p>

```<code>select top 1 with ties *
from yourtable a
where not exists(select 1  from yourtable b where a.FK_ID =b.FK_ID and b.Value = 'b')
order by row_number()over(partition by FK_ID order by [DateTiME] desc)
</code>```

Title: Find Latest Record With Specific Values

Body:
Here is one way to this

select top 1 with ties *
from yourtable a
where not exists(select 1  from yourtable b where a.FK_ID =b.FK_ID and b.Value = 'b')
order by row_number()over(partition by FK_ID order by [DateTiME] desc)


问:
Why aren't my Google maps overlays not drawn on first update?
I was following the Google-maps overlay example and have modified it to fit my needs. This is my new draw prototype for USGSOverlay:

```<code>USGSOverlay.prototype.draw = function()
{
    //need to use projection to get image position from latLng to Px
    var overlayProjection = this.getProjection();
    var mapPos = new google.maps.LatLng(this.y_, this.x_);
    var posInPx = overlayProjection.fromLatLngToDivPixel(mapPos);

    //calculate the size in current zoom
    //imageScaleFactor is a global variable placed on top in document
    var dx = Math.abs(this.img_.naturalWidth * Math.pow(2, map.getZoom()) * imageScaleFactor);
    var dy = (dx / this.img_.naturalWidth) * this.img_.naturalHeight;

    // Resize the image's div to fit the indicated dimensions.
    //places the image so that the given input (x_, y_) is in the center
    var div = this.div_;
    div.style.left = posInPx.x - dx / 2 + 'px';
    div.style.top = posInPx.y - dy / 2 + 'px';
    div.style.width = dx + 'px';
    div.style.height = dy + 'px';
};
</code>```

When I load the page for the first time my overlays would not appear until I translated the map for a long enough distance or zoomed in/out.

答:
The problem is that I the operations this.img_.naturalWidth and this.img_.naturalHeight was taking too long and didn't give a value in time for the map to be initiated where I assume it runs the draw function for each overlay once.

My solution was to add a listener for the image in the onAdd prototype for USGSOverlay:

```<code>var thisOverlay = this;
//draw country when image is finished loading
this.img_.onload = function(e){
    thisOverlay.draw();
}
</code>```

This will call the draw function of the overlay once it's image is loaded.

The thisOverlay variable is needed because the object itself cannot be accessed from the onload function as far as I can tell.

Body:
I was following the Google-maps overlay example and have modified it to fit my needs. This is my new draw prototype for USGSOverlay:

USGSOverlay.prototype.draw = function()
{
    //need to use projection to get image position from latLng to Px
    var overlayProjection = this.getProjection();
    var mapPos = new google.maps.LatLng(this.y_, this.x_);
    var posInPx = overlayProjection.fromLatLngToDivPixel(mapPos);

    //calculate the size in current zoom
    //imageScaleFactor is a global variable placed on top in document
    var dx = Math.abs(this.img_.naturalWidth * Math.pow(2, map.getZoom()) * imageScaleFactor);
    var dy = (dx / this.img_.naturalWidth) * this.img_.naturalHeight;

    // Resize the image's div to fit the indicated dimensions.
    //places the image so that the given input (x_, y_) is in the center
    var div = this.div_;
    div.style.left = posInPx.x - dx / 2 + 'px';
    div.style.top = posInPx.y - dy / 2 + 'px';
    div.style.width = dx + 'px';
    div.style.height = dy + 'px';
};

When I load the page for the first time my overlays would not appear until I translated the map for a long enough distance or zoomed in/out.

Body:
The problem is that I the operations this.img_.naturalWidth and this.img_.naturalHeight was taking too long and didn't give a value in time for the map to be initiated where I assume it runs the draw function for each overlay once.

My solution was to add a listener for the image in the onAdd prototype for USGSOverlay:

var thisOverlay = this;
//draw country when image is finished loading
this.img_.onload = function(e){
    thisOverlay.draw();
}

This will call the draw function of the overlay once it's image is loaded.

The thisOverlay variable is needed because the object itself cannot be accessed from the onload function as far as I can tell.


问:
Allowing both email and username login in django project
I'm creating a django project for a school, and there are three main kinds of users - parents, teachers, and students. For parents and teachers, I would like them to login using email (they are currently using email logins for a legacy system).

However, for students, I would like them to login using the conventional username approach (since young kids don't have emails). Is this possible to do in Django or is there only one User Authentication model allowed?

答:
You can create separate AuthenticationEmailBackend just for logging by email and add it to AUTHENTICATION_BACKENDS in settings. In this way different AUTHENTICATION_BACKENDS are used as alternatives if authentication fails for previous AUTHENTICATION_BACKENDS.

app/auth.py

```<code>from django.contrib.auth import get_user_model
from django.contrib.auth.models import User

class AuthenticationEmailBackend(object):
    def authenticate(self, username=None, password=None, **kwargs):
        UserModel = get_user_model()
        try:
            user = UserModel.objects.get(email=username)
        except UserModel.DoesNotExist:
            return None
        else:
            if getattr(user, 'is_active', False) and user.check_password(password):
                return user
        return None

    def get_user(self, user_id):
        try:
            return User.objects.get(pk=user_id)
        except User.DoesNotExist:
            return None
</code>```

settings.py

```<code>AUTHENTICATION_BACKENDS = (
    "django.contrib.auth.backends.ModelBackend",
    ...
    "app.auth.AuthenticationEmailBackend",
)
</code>```

If you leave default django.contrib.auth.backends.ModelBackend in a list users can login by either username or email.

Body:
You can create separate AuthenticationEmailBackend just for logging by email and add it to AUTHENTICATION_BACKENDS in settings. In this way different AUTHENTICATION_BACKENDS are used as alternatives if authentication fails for previous AUTHENTICATION_BACKENDS.

app/auth.py

from django.contrib.auth import get_user_model
from django.contrib.auth.models import User

class AuthenticationEmailBackend(object):
    def authenticate(self, username=None, password=None, **kwargs):
        UserModel = get_user_model()
        try:
            user = UserModel.objects.get(email=username)
        except UserModel.DoesNotExist:
            return None
        else:
            if getattr(user, 'is_active', False) and user.check_password(password):
                return user
        return None

    def get_user(self, user_id):
        try:
            return User.objects.get(pk=user_id)
        except User.DoesNotExist:
            return None

settings.py

AUTHENTICATION_BACKENDS = (
    "django.contrib.auth.backends.ModelBackend",
    ...
    "app.auth.AuthenticationEmailBackend",
)

If you leave default django.contrib.auth.backends.ModelBackend in a list users can login by either username or email.


问:
Python Pandas replace NaN in one column with value from corresponding row of second column
I am working with this Pandas DataFrame in Python.

```<code>File    heat    Farheit Temp_Rating
   1    YesQ         75         N/A
   1    NoR         115         N/A
   1    YesA         63         N/A
   1    NoT          83          41
   1    NoY         100          80
   1    YesZ         56          12
   2    YesQ        111         N/A
   2    NoR          60         N/A
   2    YesA         19         N/A
   2    NoT         106          77
   2    NoY          45          21
   2    YesZ         40          54
   3    YesQ         84         N/A
   3    NoR          67         N/A
   3    YesA         94         N/A
   3    NoT          68          39
   3    NoY          63          46
   3    YesZ         34          81
</code>```

I need to replace all NaNs in the Temp_Rating column with the value from the Farheit column.

This is what I need:

```<code>File        heat    Temp_Rating
   1        YesQ             75
   1         NoR            115
   1        YesA             63
   1        YesQ             41
   1         NoR             80
   1        YesA             12
   2        YesQ            111
   2         NoR             60
   2        YesA             19
   2         NoT             77
   2         NoY             21
   2        YesZ             54
   3        YesQ             84
   3         NoR             67
   3        YesA             94
   3         NoT             39
   3         NoY             46
   3        YesZ             81
</code>```

If I do a Boolean selection, I can pick out only one of these columns at a time. The problem is if I then try to join them, I am not able to do this while preserving the correct order.

How can I only find Temp_Rating rows with the NaNs and replace them with the value in the same row of the Farheit column?

答:
The above mentioned solutions did not work for me. The method I used was:</p>

```<code>df.loc[df['foo'].isnull(),'foo'] = df['bar']
</code>```

Body:
I am working with this Pandas DataFrame in Python.

File    heat    Farheit Temp_Rating
   1    YesQ         75         N/A
   1    NoR         115         N/A
   1    YesA         63         N/A
   1    NoT          83          41
   1    NoY         100          80
   1    YesZ         56          12
   2    YesQ        111         N/A
   2    NoR          60         N/A
   2    YesA         19         N/A
   2    NoT         106          77
   2    NoY          45          21
   2    YesZ         40          54
   3    YesQ         84         N/A
   3    NoR          67         N/A
   3    YesA         94         N/A
   3    NoT          68          39
   3    NoY          63          46
   3    YesZ         34          81

I need to replace all NaNs in the Temp_Rating column with the value from the Farheit column.

This is what I need:

File        heat    Temp_Rating
   1        YesQ             75
   1         NoR            115
   1        YesA             63
   1        YesQ             41
   1         NoR             80
   1        YesA             12
   2        YesQ            111
   2         NoR             60
   2        YesA             19
   2         NoT             77
   2         NoY             21
   2        YesZ             54
   3        YesQ             84
   3         NoR             67
   3        YesA             94
   3         NoT             39
   3         NoY             46
   3        YesZ             81

If I do a Boolean selection, I can pick out only one of these columns at a time. The problem is if I then try to join them, I am not able to do this while preserving the correct order.

How can I only find Temp_Rating rows with the NaNs and replace them with the value in the same row of the Farheit column?

Body:
The above mentioned solutions did not work for me. The method I used was:

df.loc[df['foo'].isnull(),'foo'] = df['bar']


问:
Division of two numbers always returns an integer value
Using the formula "(4/3)*3.14*pow(radius,3)", the number returned always yields to an integer. Any ideas on how to get a floating point number from the formula?

Code:

```<code>#include<iostream>
#include<math.h>

using namespace std;

int main(){
    float radius, v;
    cout<<"Enter value of radius";cin>>radius;
    v = (4/3)*3.14*pow(radius, 3);
    cout<<"volume of sphere: "<<v<<endl;
    system("pause");return 0;
}
</code>```

答:
The answer is 1 because, 4 and 3 are integers, and in C++ integer divided by integer yields another integer, so 4/3 = 1.

But to correct that, all you need to do is this,
Change the integer to a floating point decimal number, for e.g. 4 could be written as 4.0 instead.

```<code>(4.0/3)*3.14*pow(radius,3)
</code>```

Thats all and you are good to go.

Body:
Using the formula "(4/3)*3.14*pow(radius,3)", the number returned always yields to an integer. Any ideas on how to get a floating point number from the formula?

Code:

#include<iostream>
#include<math.h>

using namespace std;

int main(){
    float radius, v;
    cout<<"Enter value of radius";cin>>radius;
    v = (4/3)*3.14*pow(radius, 3);
    cout<<"volume of sphere: "<<v<<endl;
    system("pause");return 0;
}

Body:
The answer is 1 because, 4 and 3 are integers, and in C++ integer divided by integer yields another integer, so 4/3 = 1.

But to correct that, all you need to do is this,
Change the integer to a floating point decimal number, for e.g. 4 could be written as 4.0 instead.

(4.0/3)*3.14*pow(radius,3)

Thats all and you are good to go.


问:
Slide element 100% up and all subsequent siblings by the same amount?
Consider this document:

```<code><div id="container" class="no-panel">
  <div id="panel">
    <!-- Can be any DOM with arbitrary, variable height.
         120px is hardcoded only for the demo. -->
    <div style="height: 120px">Some Contents</div>
  </div>
  <div id="contents">
    <!-- Can be any DOM with arbitrary, variable height.
         300px is hardcoded only for the demo. -->
    <div style="height: 300px">Some Contents</div>
  </div>
</div>
</code>```

Both #panel and #contents are supposed to be as tall as their contents, and not more (in the example I forced their height using arbitrary child div's - just  for the demo).

I want to apply a class to #container that will make #panel slide all the way up (so it becomes invisible behind the top border of the viewport). At the same time, #contents should slide up by the same amount #panel did. I like that to be animated too (in the demo I used :hover instead of the class).

How can I do that without using JS? It has to work in Chrome / Firefox, but I don't care about other browsers.

I tried setting translateY(-100%), which works fine on #panel, but then #contents would move 100% relative to its height, not to #panel's height, which is way too much.

Absolute positioning wouldn't work as then I'd need to fix the height of #panel which I'm trying not to do (it's contents are supposed to vary).

JSFiddle with an example on how I'd like it to work. - but with hardcoded value which I don't want.

答:
The main problem here is that when you move something using transform, the elements position/size in the document flow doesn't actually change, it is only the elements visual position that changes.

This technique is also AFAIK the only one, where you can move an element its own unknown height (or width), though since its siblings doesn't know if it moved, they won't move either.

You have 2 options here, (CSS based), where you either nest the container inside the panel, as lee comstock suggest in their answer, or use the max-height trick, where you set it on the panel with a value higher than what you expect it ever can be.

If you can nest them, that would most efficient solution, as it will be fully dynamic

#container {
  width: 100%;
  height: 100%;
}
#panel, #contents {
  transition: max-height 0.2s ease-in;   /*  changed from "all" to "max-height"  */
}
#panel {
  background-color: tomato;
  width: 100%;
  height: auto;

  max-height: 200px;                     /*  added  */
  overflow: hidden;                      /*  added  */
}
#contents {
  background-color: crimson;
  width: 100%;
}
#container:hover #panel {
  max-height: 0;                         /*  changed property  */
}

* {
  box-sizing: border-box;
}
html, body {
  padding: 0;
  margin: 0;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div id="container" class="no-panel">
  <div id="panel">
    <div style="height: 120px">
      Some Panel Contents
    </div>
  </div>
  <div id="contents">
    <div style="height: 800px">
      Some Contents Contents
    </div>
  </div>
</div></code>```

Body:
Consider this document:

Some Contents

Some Contents

Both #panel and #contents are supposed to be as tall as their contents, and not more (in the example I forced their height using arbitrary child div's - just  for the demo).

I want to apply a class to #container that will make #panel slide all the way up (so it becomes invisible behind the top border of the viewport). At the same time, #contents should slide up by the same amount #panel did. I like that to be animated too (in the demo I used :hover instead of the class).

How can I do that without using JS? It has to work in Chrome / Firefox, but I don't care about other browsers.

I tried setting translateY(-100%), which works fine on #panel, but then #contents would move 100% relative to its height, not to #panel's height, which is way too much.

Absolute positioning wouldn't work as then I'd need to fix the height of #panel which I'm trying not to do (it's contents are supposed to vary).

JSFiddle with an example on how I'd like it to work. - but with hardcoded value which I don't want.

Body:
The main problem here is that when you move something using transform, the elements position/size in the document flow doesn't actually change, it is only the elements visual position that changes.

This technique is also AFAIK the only one, where you can move an element its own unknown height (or width), though since its siblings doesn't know if it moved, they won't move either.

You have 2 options here, (CSS based), where you either nest the container inside the panel, as lee comstock suggest in their answer, or use the max-height trick, where you set it on the panel with a value higher than what you expect it ever can be.

If you can nest them, that would most efficient solution, as it will be fully dynamic

#container {
  width: 100%;
  height: 100%;
}
#panel, #contents {
  transition: max-height 0.2s ease-in;   /*  changed from "all" to "max-height"  */
}
#panel {
  background-color: tomato;
  width: 100%;
  height: auto;

  max-height: 200px;                     /*  added  */
  overflow: hidden;                      /*  added  */
}
#contents {
  background-color: crimson;
  width: 100%;
}
#container:hover #panel {
  max-height: 0;                         /*  changed property  */
}

* {
  box-sizing: border-box;
}
html, body {
  padding: 0;
  margin: 0;
}

<div id="container" class="no-panel">
  <div id="panel">
    <div style="height: 120px">
      Some Panel Contents
    </div>
  </div>
  <div id="contents">
    <div style="height: 800px">
      Some Contents Contents
    </div>
  </div>
</div>


问:
Highcharts series (column) names of x axis
I have a script that returns a chart (Highcharts) and it works fine apart from not displaying the names of the columns on the x axis. Can anyone see where I have gone wrong.

My Json:
    [{"data":[30.95]},{"data":[2.38]},{"data":[66.67]}]

My script:

```<code>$(function () {

var colors = ['#FF0000','#FF9900','#009900'];
colorIterator = 0;
var chart;
$(document).ready(function() {

$.getJSON("../charts/1-2-4-reports_chart.php?TAG=<?php echo $_POST['SectionVar'];?>&From=<?php echo $StartDate;?>&To=<?php echo $EndDate;?>", function(json) {

chart = new Highcharts.Chart({
chart: {
renderTo: 'container1',
type: 'column',
height: 200,
marginRight: 25,
marginBottom: 25,
plotBackgroundColor: '#FCFFC5',
style: {
fontFamily: 'serif',
fontSize: '8px',
}
},

title: {
text: 'Net Promoter Score: <?php echo $_POST['SectionVar'];?>',
x: -20,
style: {
fontFamily: 'Tahoma',
color: '#000000',
fontWeight: 'normal',
fontSize: '11px'
} //center
},

subtitle: {
text: '',
},

xAxis: {
categories: ['Detractors', 'Passives', 'Promoters'],
title: {
text: ''

}
},

yAxis: {

//reversedStacks: false,
endOnTick: false,
max:101,
showFirstLabel: false,
lineColor:'#999',
lineWidth:1,
tickColor:'#666',
tickWidth:1,
tickLength:2,
tickInterval: 10,
gridLineColor:'#ddd',
title: {
text: '',
style: {
fontFamily: 'Tahoma',
color: '#000000',
fontWeight: 'bold',
fontSize: '8px'
}
},
plotLines: [{
color: '#808080'
}]
},

credits: {
enabled: false
},

tooltip: {
formatter: function() {
return '<b>Guest responses: '+ this.y +'<br/>'+ this.series.name +'</b><br/>Month:'+
this.x;
}
},

navigation: {
buttonOptions: {
verticalAlign: 'top',
y: -10,
x: -20
}
},

legend: {
enabled: false,
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -10,
y: 100,
borderWidth: 1
},

colors: [
'#FF0000',
'#FF9900',
'#009900',
],

plotOptions: {
column: {
colorByPoint: false
},

series: {
type: 'column',
cursor: 'pointer',
pointWidth: 30,
point: {
events: {
//click: function() {
//location.href = "feedback-items_detractors_iframe.php?FromDate1=<?php echo $StartDate;?>&ToDate1=<?php echo $EndDate;?> target='iframe2'";
//}
}
},

legendIndex:0,

dataLabels: {
enabled: true,
color: '#000000',
align: 'center',
cursor: 'pointer',
//borderRadius: 5,
//backgroundColor: 'rgba(252, 255, 255, 255)',
//borderWidth: 1,
//borderColor: '#AAA',
y: -6,
format: '{y:.2f} %', // one decimal
y: -20, // 10 pixels down from the top
this.series.name
style: {
textShadow: false,
fontSize: '8px',
fontFamily: 'Verdana, sans-serif'
}
}
}

},

exporting: {
chartOptions: { // specific options for the exported image
plotOptions: {
series: {
dataLabels: {
enabled: true
}
}
}
},
fallbackToExportServer: false
},

series: json,

});
});

});

});
</code>```

Many thanks in advance for your time.

答:
You made some syntax errors in your code, fixed version below:

```<code>$(function() {

  var colors = ['#FF0000', '#FF9900', '#009900'];
  var colorIterator = 0;
  var chart;

  $(document).ready(function() {
    const json = [{"data":[30.95]},{"data":[2.38]},{"data":[66.67]}]
    setTimeout(function() {
      chart = Highcharts.chart('container', {
        chart: {
          renderTo: 'container1',
          type: 'column',
          height: 200,
          marginRight: 25,
          marginBottom: 25,
          plotBackgroundColor: '#FCFFC5',
          style: {
            fontFamily: 'serif',
            fontSize: '8px',
          }
        },

        title: {
          text: '',
          x: -20,
          style: {
            fontFamily: 'Tahoma',
            color: '#000000',
            fontWeight: 'normal',
            fontSize: '11px'
          } //center
        },

        subtitle: {
          text: '',
        },

        xAxis: {
          categories: ['Detractors', 'Passives', 'Promoters'],
          title: {
            text: ''

          }
        },

        yAxis: {

          //reversedStacks: false,
          endOnTick: false,
          max: 101,
          showFirstLabel: false,
          lineColor: '#999',
          lineWidth: 1,
          tickColor: '#666',
          tickWidth: 1,
          tickLength: 2,
          tickInterval: 10,
          gridLineColor: '#ddd',
          title: {
            text: '',
            style: {
              fontFamily: 'Tahoma',
              color: '#000000',
              fontWeight: 'bold',
              fontSize: '8px'
            }
          },
          plotLines: [{
            color: '#808080'
          }]
        },

        credits: {
          enabled: false
        },

        tooltip: {
          formatter: function() {
            return '<b>Guest responses: ' + this.y + '<br/>' + this.series.name + '</b><br/>Month:' +
              this.x;
          }
        },

        navigation: {
          buttonOptions: {
            verticalAlign: 'top',
            y: -10,
            x: -20
          }
        },

        legend: {
          enabled: false,
          layout: 'vertical',
          align: 'right',
          verticalAlign: 'top',
          x: -10,
          y: 100,
          borderWidth: 1
        },

        colors: [
          '#FF0000',
          '#FF9900',
          '#009900',
        ],

        plotOptions: {
          column: {
            colorByPoint: false
          }
        },

        series: {
          type: 'column',
          cursor: 'pointer',
          pointWidth: 30,
          point: {
            events: {
            }
          },

          legendIndex: 0,

          dataLabels: {
            enabled: true,
            color: '#000000',
            align: 'center',
            cursor: 'pointer',
            y: -6,
            format: '{y:.2f} %', // one decimal
            y: -20, // 10 pixels down from the top
            style: {
              textShadow: false,
              fontSize: '8px',
              fontFamily: 'Verdana, sans-serif'
            }
          }
        },

        exporting: {
          chartOptions: { // specific options for the exported image
            plotOptions: {
              series: {
                dataLabels: {
                  enabled: true
                }
              }
            }
          },
          fallbackToExportServer: false
        },
        series: json,
      });
    });
  });
});
</code>```

https://jsfiddle.net/0kjojak9/

Body:
I have a script that returns a chart (Highcharts) and it works fine apart from not displaying the names of the columns on the x axis. Can anyone see where I have gone wrong.

My Json:
    [{"data":[30.95]},{"data":[2.38]},{"data":[66.67]}]

My script:

$(function () {

var colors = ['#FF0000','#FF9900','#009900'];
colorIterator = 0;
var chart;
$(document).ready(function() {

$.getJSON("../charts/1-2-4-reports_chart.php?TAG=<?php echo $_POST['SectionVar'];?>&From=<?php echo $StartDate;?>&To=<?php echo $EndDate;?>", function(json) {

chart = new Highcharts.Chart({
chart: {
renderTo: 'container1',
type: 'column',
height: 200,
marginRight: 25,
marginBottom: 25,
plotBackgroundColor: '#FCFFC5',
style: {
fontFamily: 'serif',
fontSize: '8px',
}
},

title: {
text: 'Net Promoter Score: <?php echo $_POST['SectionVar'];?>',
x: -20,
style: {
fontFamily: 'Tahoma',
color: '#000000',
fontWeight: 'normal',
fontSize: '11px'
} //center
},

subtitle: {
text: '',
},

xAxis: {
categories: ['Detractors', 'Passives', 'Promoters'],
title: {
text: ''

}
},

yAxis: {

//reversedStacks: false,
endOnTick: false,
max:101,
showFirstLabel: false,
lineColor:'#999',
lineWidth:1,
tickColor:'#666',
tickWidth:1,
tickLength:2,
tickInterval: 10,
gridLineColor:'#ddd',
title: {
text: '',
style: {
fontFamily: 'Tahoma',
color: '#000000',
fontWeight: 'bold',
fontSize: '8px'
}
},
plotLines: [{
color: '#808080'
}]
},

credits: {
enabled: false
},

tooltip: {
formatter: function() {
return 'Guest responses: '+ this.y +'
'+ this.series.name +'
Month:'+
this.x;
}
},

navigation: {
buttonOptions: {
verticalAlign: 'top',
y: -10,
x: -20
}
},

legend: {
enabled: false,
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -10,
y: 100,
borderWidth: 1
},

colors: [
'#FF0000',
'#FF9900',
'#009900',
],

plotOptions: {
column: {
colorByPoint: false
},

series: {
type: 'column',
cursor: 'pointer',
pointWidth: 30,
point: {
events: {
//click: function() {
//location.href = "feedback-items_detractors_iframe.php?FromDate1=<?php echo $StartDate;?>&ToDate1=<?php echo $EndDate;?> target='iframe2'";
//}
}
},

legendIndex:0,

dataLabels: {
enabled: true,
color: '#000000',
align: 'center',
cursor: 'pointer',
//borderRadius: 5,
//backgroundColor: 'rgba(252, 255, 255, 255)',
//borderWidth: 1,
//borderColor: '#AAA',
y: -6,
format: '{y:.2f} %', // one decimal
y: -20, // 10 pixels down from the top
this.series.name
style: {
textShadow: false,
fontSize: '8px',
fontFamily: 'Verdana, sans-serif'
}
}
}

},

exporting: {
chartOptions: { // specific options for the exported image
plotOptions: {
series: {
dataLabels: {
enabled: true
}
}
}
},
fallbackToExportServer: false
},

series: json,

});
});

});

});

Many thanks in advance for your time.

Body:
You made some syntax errors in your code, fixed version below:

$(function() {

  var colors = ['#FF0000', '#FF9900', '#009900'];
  var colorIterator = 0;
  var chart;

  $(document).ready(function() {
    const json = [{"data":[30.95]},{"data":[2.38]},{"data":[66.67]}]
    setTimeout(function() {
      chart = Highcharts.chart('container', {
        chart: {
          renderTo: 'container1',
          type: 'column',
          height: 200,
          marginRight: 25,
          marginBottom: 25,
          plotBackgroundColor: '#FCFFC5',
          style: {
            fontFamily: 'serif',
            fontSize: '8px',
          }
        },

        title: {
          text: '',
          x: -20,
          style: {
            fontFamily: 'Tahoma',
            color: '#000000',
            fontWeight: 'normal',
            fontSize: '11px'
          } //center
        },

        subtitle: {
          text: '',
        },

        xAxis: {
          categories: ['Detractors', 'Passives', 'Promoters'],
          title: {
            text: ''

          }
        },

        yAxis: {

          //reversedStacks: false,
          endOnTick: false,
          max: 101,
          showFirstLabel: false,
          lineColor: '#999',
          lineWidth: 1,
          tickColor: '#666',
          tickWidth: 1,
          tickLength: 2,
          tickInterval: 10,
          gridLineColor: '#ddd',
          title: {
            text: '',
            style: {
              fontFamily: 'Tahoma',
              color: '#000000',
              fontWeight: 'bold',
              fontSize: '8px'
            }
          },
          plotLines: [{
            color: '#808080'
          }]
        },

        credits: {
          enabled: false
        },

        tooltip: {
          formatter: function() {
            return '<b>Guest responses: ' + this.y + '<br/>' + this.series.name + '</b><br/>Month:' +
              this.x;
          }
        },

        navigation: {
          buttonOptions: {
            verticalAlign: 'top',
            y: -10,
            x: -20
          }
        },

        legend: {
          enabled: false,
          layout: 'vertical',
          align: 'right',
          verticalAlign: 'top',
          x: -10,
          y: 100,
          borderWidth: 1
        },

        colors: [
          '#FF0000',
          '#FF9900',
          '#009900',
        ],

        plotOptions: {
          column: {
            colorByPoint: false
          }
        },

        series: {
          type: 'column',
          cursor: 'pointer',
          pointWidth: 30,
          point: {
            events: {
            }
          },

          legendIndex: 0,

          dataLabels: {
            enabled: true,
            color: '#000000',
            align: 'center',
            cursor: 'pointer',
            y: -6,
            format: '{y:.2f} %', // one decimal
            y: -20, // 10 pixels down from the top
            style: {
              textShadow: false,
              fontSize: '8px',
              fontFamily: 'Verdana, sans-serif'
            }
          }
        },

        exporting: {
          chartOptions: { // specific options for the exported image
            plotOptions: {
              series: {
                dataLabels: {
                  enabled: true
                }
              }
            }
          },
          fallbackToExportServer: false
        },
        series: json,
      });
    });
  });
});

https://jsfiddle.net/0kjojak9/


问:
Excel 2010: Compare two columns (A and C), find exact match string then subtract their values
I have data as below where I need to compare two columns (A and C), find exact match in column A and C "string" then subtract their values - for example subtract column (B - D) and put result in column E.</p>

```<code>A         B       C         D           E
String1   500    String1    300
String2   1000   String1    400
String3   1500   String1    600
                 String2    750
                 String2    845
                 String2    1350
                 String3    1200
                 String3    1400
                 String3    1700
                 String1    1775
</code>```

答:
You can use in E1:

```<code>=SUMIF($C$1:$C$10,A1,$D$1:$D$10)-B1
</code>```

or

```<code>=B1-SUMIF($C$1:$C$10,A1,$D$1:$D$10)
</code>```

B1 is the number next to first string

A1 is the first string

Sumif will sum column D if in C string= A1

change C1:C10 and D1:D10 to correspond the last row in your Data and keep $ for fixed references.

and drag the formula down till the end of column A

Body:
I have data as below where I need to compare two columns (A and C), find exact match in column A and C "string" then subtract their values - for example subtract column (B - D) and put result in column E.

A         B       C         D           E
String1   500    String1    300
String2   1000   String1    400
String3   1500   String1    600
                 String2    750
                 String2    845
                 String2    1350
                 String3    1200
                 String3    1400
                 String3    1700
                 String1    1775

Body:
You can use in E1:

=SUMIF($C$1:$C$10,A1,$D$1:$D$10)-B1

or

=B1-SUMIF($C$1:$C$10,A1,$D$1:$D$10)

B1 is the number next to first string

A1 is the first string

Sumif will sum column D if in C string= A1

change C1:C10 and D1:D10 to correspond the last row in your Data and keep $ for fixed references.

and drag the formula down till the end of column A


问:
Conversion from 'char' to non-scalar type 'Vector<char>' error thrown unknown reason
Error Thrown Unknown Reason

```<code>#include "std_lib_facilities.h"

int main()
{
    vector<char> shape = ('a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a');
    return(0);
}
</code>```

that one line with the vector throws this error that I've never seen before nor can figure out...

:: g++ TicTacToe.cpp -o TTT

TicTacToe.cpp: In function int main()':

TicTacToe.cpp:5: error: conversion fromchar' to non-scalar type `Vector' requested

See in each tic-tac-toe box it will start as _ and then go to either X or O, I'm doing this without a graphics library so its terminal graphics.

答:
Such vector initialization isn't possible in current C++. You can use :

```<code>vector<char> shape(9, 'a');
</code>```

which will have the desired effect (create a vector of size 9 where all elements are set to '_').

If boost is an option, Boost.Assign provides the kind of syntax you wanted to achieve initially, although in this particular case using the appropriate std::vector constructor is largely sufficient.

Body:
Error Thrown Unknown Reason

#include "std_lib_facilities.h"

int main()
{
    vector<char> shape = ('a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a');
    return(0);
}

that one line with the vector throws this error that I've never seen before nor can figure out...

:: g++ TicTacToe.cpp -o TTT

TicTacToe.cpp: In function int main()':

TicTacToe.cpp:5: error: conversion fromchar' to non-scalar type `Vector' requested

See in each tic-tac-toe box it will start as _ and then go to either X or O, I'm doing this without a graphics library so its terminal graphics.

Body:
Such vector initialization isn't possible in current C++. You can use :

vector<char> shape(9, 'a');

which will have the desired effect (create a vector of size 9 where all elements are set to '_').

If boost is an option, Boost.Assign provides the kind of syntax you wanted to achieve initially, although in this particular case using the appropriate std::vector constructor is largely sufficient.


问:
Auto calculate value including decimals
I have a html form where users add hours to 5 input fields (days of the week).

The total hours is then displayed at the bottom of the form.

This is working fine for rounded hours, but when adding something like 7.4 the total is rounding it to 7

See below:
Is there a way to add the decimals too?

$(document).ready(function() {
  $('.calc').change(function() {
    var total = 0;
    $('.calc').each(function() {
      if ($(this).val() != '') {
        total += parseInt($(this).val());
      }
    });
    $('#total').html(total);
  });
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" class="form-control  calc" name='mon'>
<input type="text" class="form-control  calc" name='tue'>
<span id="total"></span></code>```

答:
You need to use parseFloat instead because parseInt will round off.

```<code>total += parseFloat($(this).val());
</code>```

>>Sample Demo<<

Title: Auto calculate value including decimals

Body:
I have a html form where users add hours to 5 input fields (days of the week).

The total hours is then displayed at the bottom of the form.

This is working fine for rounded hours, but when adding something like 7.4 the total is rounding it to 7

See below:
Is there a way to add the decimals too?

$(document).ready(function() {
  $('.calc').change(function() {
    var total = 0;
    $('.calc').each(function() {
      if ($(this).val() != '') {
        total += parseInt($(this).val());
      }
    });
    $('#total').html(total);
  });
});

<input type="text" class="form-control  calc" name='mon'>
<input type="text" class="form-control  calc" name='tue'>

Body:
You need to use parseFloat instead because parseInt will round off.

total += parseFloat($(this).val());

>>Sample Demo<<


问:
Node JS and Coinbase
I am trying to integrate Coinbase with Node Js, but I am unable to execute the code given on the tutorial page. My code is

```<code>`var coinbase = require('coinbase');
var client   = new coinbase.Client({'apiKey': mykey, 'apiSecret': mysecret});

client.getAccounts({}, function(err, accounts) {
  accounts.forEach(function(acct) {
    console.log('my bal: ' + acct.balance.amount + ' for ' + acct.name);
  });
});`
</code>```

I get t the following error:

accounts.forEach(account => {
           ^
  typeError: Cannot read property 'forEach' of null
  Looking forward to your answer! Thanks!

答:
hello you can use like this</p>

```<code>client.getAccounts({}, function(err, accounts) {
  accounts.forEach(function(acct) {
    console.log(acct.name + ': ' + acct.balance.amount + ' ' + acct.id );
  });
});
</code>```

Title: Node JS and Coinbase

Body:
I am trying to integrate Coinbase with Node Js, but I am unable to execute the code given on the tutorial page. My code is

`var coinbase = require('coinbase');
var client   = new coinbase.Client({'apiKey': mykey, 'apiSecret': mysecret});

client.getAccounts({}, function(err, accounts) {
  accounts.forEach(function(acct) {
    console.log('my bal: ' + acct.balance.amount + ' for ' + acct.name);
  });
});`

I get t the following error:

accounts.forEach(account => {
           ^
  typeError: Cannot read property 'forEach' of null
  Looking forward to your answer! Thanks!

Body:
hello you can use like this

client.getAccounts({}, function(err, accounts) {
  accounts.forEach(function(acct) {
    console.log(acct.name + ': ' + acct.balance.amount + ' ' + acct.id );
  });
});