问:
Health Check failed - Atlassian's Localstack
Pretty much as the title says said.

I'm trying to run localstack, via docker on CentOS 7, having nothing but trouble.

Today's problem is ERROR:localstack.services.kinesis.kinesis_starter:Kinesis health check failed: Could not connect to the endpoint URL: http://localhost.localdomain:4568/

which apparently is cause for the entire thing to restart, and that is less than ideal when the s3 mock doesn't persist...

And rather than struggle through that I figured it would just be easier to not have kinesis run, at all, or even better; to only run the services that I'm attempting to use.

I assumed the SERVICES environment var might help, but it seems to only specify ports. If I exclude services from the provided list they run regardless...

Is there any way I can choose a subset of the services provided in localstack?

EDIT

So after some fiddling, reading, etc...
managed to get things started via localstack start --docker

Previously user didn't have appropriate privilege, and running sudo localstack start --docker apparently ignores environment vars I have set.
But that's remedied now and I'm just starting S3 and SES services.

So now S3 runs into the same error;
ERROR:localstack.services.s3.s3_starter:S3 health check failed: Could not connect to the endpoint URL: http://localhost.localdomain:4572/
Even though I can make use of it myself, it's working fine, this check fails.

MORE EDIT

So I'm just not going to use LocalStack.
Not even sure where the issue lies, could be in boto or the config of my VM, but I have better things to do than track that down for little gain...

Might check in again in the future, see what's up then.

答:
You can use the SERVICES environment variable.

For example, to start only S3 and DynamoDB:

```<code>SERVICES=s3,dynamodb localstack start
</code>```

Or, to start LocalStack in a Docker container:

```<code>SERVICES=s3,dynamodb localstack start --docker
</code>```

(Note: This assumes that you have installed LocalStack via pip install localstack)

Body:
You can use the SERVICES environment variable.

For example, to start only S3 and DynamoDB:

SERVICES=s3,dynamodb localstack start

Or, to start LocalStack in a Docker container:

SERVICES=s3,dynamodb localstack start --docker

(Note: This assumes that you have installed LocalStack via pip install localstack)


来源: stackexchange

问:
Passing the data in the tables from database to modal
I am trying to pass the data in the table to a modal textbox through a clickable row. The data's are already displayed in the table. When row is clicked, it displays the modal but the textboxes are blank. The data's in the table was from the database.

This is the codes:

Php:

```<code>  <!DOCTYPE html>
  <html>
<head>
    <title></title>

    <meta name = "viewport" content = "width= device-width, initial-scale=1">
    <link rel = "stylesheet" href = "bs/css/bootstrap.css">

    <script src = "bs/js/jquery.min.js"></script>
    <script src = "bs/js/bootstrap.min.js"></script>

    <meta charset="utf-8">

</head>
<body>
    <div class="container">
        <div class="header">
            <?php include("header.php"); ?>
        </div>
        <div class = "navigation">
            <?php include("navigator.php"); ?>
        </div>
    </div>

    <center>
    <style>
        table tr:not(:first-child){
            cursor: pointer;
        }
        table tr:not(:first-child)hover{
            background-color:azure;
            color:black;

        }
    </style>

    <?php
        include("dbConfig.php");

        $result = mysqli_query ($con, "SELECT * FROM information");
        echo "<table id=table border = 1 width = 50%>
            <tr>
            <th align = center> Control # </th>
            <th> Last Name </th>
            <th> First Name </th>
            <th> Contact Number </th>
            </tr>";
        while($row=mysqli_fetch_array($result)){
            echo "<form action = method =post>";
            echo "<tr data-toggle=modal data-target=#fmodal name = pass type = submit>";
            echo "<td id='cn'>".$row['Control_Number']. "</td>";
            echo "<td>".$row['Last_Name']. "</td>";
            echo "<td>".$row['First_Name']. "</td>";
            echo "<td>".$row['Contact_Number']. "</td>";
            echo "</tr>";
            echo "</form>";
        }
        echo "</table>";

        if(isset($_POST['submit'])){
            $res = mysqli_query($con, "SELECT * FROM information WHERE Control_Number=$_POST[cn]");
            while($rowval = mysqli_fetch_array($res)){
                $controlnumber= $rowval['Control_Number'];
                $lastname= $rowval['Last_Name'];
                $firstname= $rowval['First_Name'];
                $contactnumber= $rowval['Contact_Number'];
            }
        }
    ?>

    <div class = "modal fade" id = "fmodal" role = "dialog">
        <div class = "modal-dialog" role = "document">
            <div class = "modal-content">
                <div class = "modal-header">
                    <button type = "button" class = "close" data-dismiss = "modal">×</button>
                    <h4>FORM</h4>
                </div>
                <div class = "modal-body text-center">
                    <label>Control Number:</label>
                    <input class = "input-lg" type = "text" id = "Control_Number" value = '<?php echo $controlnumber; ?>'><br>
                    <label>Last Name:</label>
                    <input class = "input-lg" type = "text" id = "Last_Name" value = '<?php echo $lastname; ?>'><br>
                    <label>First Name:</label>
                    <input class = "input-lg" type = "text" id = "First_Name" value = '<?php echo $firstname; ?>'><br>
                    <label>Contact Number:</label>
                    <input class = "input-lg" type = "text" id = "Contact_Number" value = '<?php echo $contactnumber; ?>'><br>
                </div>
            </div>
        </div>
    </div>
    </center>
</body>
</code>```

答:
@MYxx here is what you wanted. Here i have used OOPS PHP  MYSQLi Prepare JQuery Ajax and JSON to send and received data and display in modal.

Why MYSQLi PREPARED STATEMENTS because it prevents SQL INJECTION for more info click on this link sql injection

If you are new to PHP and MySQL then don't worry, you will get adjusted to this soon.  If you are having problems understanding this answer, I will be happy to help you.

index.php

```<code>    <?php
    include('Table_info.php');

    $tbl_data = new Table_info();
?>
<!DOCTYPE html>
<html>
<head>
    <title>Welcome</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
  <div class="row">
    <table class="table table-hover table-bordered">
        <thead>
            <tr>
                <th>#</th>
                <th> First Name </th>
                <th> Last Name </th>
                <th> Contact Number </th>
                <th> Control Number </th>
                <th> Action</th>
            </tr>
        </thead>
        <tbody>
            <?php
                $tbl_data->show_table();

            ?>
        </tbody>
    </table>
  </div>
</div>

<!-- ADDED THE MUSIC MODAL-->
<div class="container">
  <div class="modal fade" id="fmodal" role="dialog">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal">×</button>
              <h4 class="modal-title">User data</h4>
            </div>
            <div class="modal-body" id="userdata_div">
                <form action="" method="post" enctype="multipart/form-data">
                    <div class="form-group">
                        <input type="hidden" name="id" id="id" value="">
                        <p>Firstname</p>
                        <input type="text" name="fname" id="fname">
                    </div>

                    <div class="form-group">
                        <p>Lastname</p>
                        <input type="text" name="lname" id="lname">
                    </div>

                    <div class="form-group">
                        <p>Contact_Number</p>
                        <input type="text" name="Contact_Number" id="Contact_Number">
                    </div>

                    <div class="form-group">
                        <p>Lastname</p>
                        <input type="text" name="Control_Number" id="Control_Number">
                    </div>

                    <div class="form-group text-center" style="margin:0;">
                        <input type="submit" name="submit_btn" class="btn btn-default" style="border:1px solid #451;">
                    </div>
                </form>
            </div>
            <div class="modal-footer">
              <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
  </div>
</div>

<script>
$(document).ready(function(){
    getdata();
});

function getdata(){
    $('.open_model_btn').click(function(){
        $('#fmodal').modal();
        var id = $(this).attr('id');

        //alert('works');

        $.ajax({
            type:'POST',
            url:'Table_info.php',
            data:{slno_id:id},
            success:function(data){
                var res = JSON.parse(data);

                for(var i in res){
                    $('#id').val(res[i].id);
                    $('#fname').val(res[i].First_Name);
                    $('#lname').val(res[i].Last_Name);
                    $('#Contact_Number').val(res[i].Contact_Number);
                    $('#Control_Number').val(res[i].Control_Number);
                }
            }
        });

        $('#id, #fname, #lname, #Contact_Number, #Control_Number').val('');
    });
}
</script>
</body>
</html>
</code>```

PHP Class file name: Table_info.php

```<code>    <?php
    class Table_info{
        private $link;

        function __construct(){
            $this->link = new mysqli('localhost','root','','example');

            if($this->link->connect_error){
                die ('connection failed'.$this->link->connect_error);
            }
        }

        function show_table(){
            $sql = $this->link->stmt_init();
            $i=1;
            if($sql->prepare("SELECT id,First_Name,Last_Name,Contact_Number,Control_Number FROM information")){
                $sql->bind_result($id,$First_Name,$Last_Name,$Contact_Number,$Control_Number);

                $sql->execute();

                $sql->store_result();

                if($sql->num_rows > 0){
                    while($sql->fetch()){
            ?>
                        <tr>
                            <td><?php echo $i;?></td>
                            <td><?php echo $First_Name;?></td>
                            <td><?php echo $Last_Name;?></td>
                            <td><?php echo $Contact_Number;?></td>
                            <td><?php echo $Control_Number;?></td>
                            <td><button class="btn btn-success open_model_btn" id="<?php echo $id;?>">Show</button></td>
                        </tr>
            <?php
                        $i++;
                    }
                }

            }
            else
            {
                echo 'Error'.$this->link->error;
            }
        }

        function get_data_modal($slnoid){
            $sql = $this->link->stmt_init();
            $i=1;
            if($sql->prepare("SELECT id,First_Name,Last_Name,Contact_Number,Control_Number FROM information WHERE id=?")){
            $sql->bind_param('i',$slnoid);
                $sql->bind_result($id,$First_Name,$Last_Name,$Contact_Number,$Control_Number);

                $sql->execute();

                $sql->store_result();

                if($sql->num_rows > 0){
                    while($sql->fetch()){
                        $arr[] = array(
                            'id'=>$id,
                            'First_Name'=>$First_Name,
                            'Last_Name'=>$Last_Name,
                            'Contact_Number'=>$Contact_Number,
                            'Control_Number'=>$Control_Number,
                            'report'=>'Success'
                        );
                    }

                    echo json_encode($arr);
                }
                else
                {
                    $arr = array(
                            'statuss'=>false,
                            'report'=>'No data available'
                        );

                    echo json_encode($arr);
                }
            }
            else
            {
                $err = 'Error'.$this->link->error;

                $arr = array(
                        'statuss'=>false,
                        'report'=>$err
                    );

                echo json_encode($arr);
            }
        }
    }

    $tbl_data = new Table_info();

    if(isset($_POST['slno_id'])){
        $slnoid = $_POST['slno_id'];

        $tbl_data->get_data_modal($slnoid);
    }
?>
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I am trying to pass the data in the table to a modal textbox through a clickable row. The data's are already displayed in the table. When row is clicked, it displays the modal but the textboxes are blank. The data's in the table was from the database.

This is the codes:

Php:

  <!DOCTYPE html>

    <title></title>

    <meta name = "viewport" content = "width= device-width, initial-scale=1">
    <link rel = "stylesheet" href = "bs/css/bootstrap.css">

    <meta charset="utf-8">

            <?php include("header.php"); ?>

            <?php include("navigator.php"); ?>

    <?php
        include("dbConfig.php");

        $result = mysqli_query ($con, "SELECT * FROM information");
        echo "

             Control #
             Last Name
             First Name
             Contact Number

";
        while($row=mysqli_fetch_array($result)){
            echo "<form action = method =post>";
            echo "
";
            echo "".$row['Control_Number']. "	";
            echo "".$row['Last_Name']. "	";
            echo "".$row['First_Name']. "	";
            echo "".$row['Contact_Number']. "	";
            echo "
";
            echo "</form>";
        }
        echo "
";

        if(isset($_POST['submit'])){
            $res = mysqli_query($con, "SELECT * FROM information WHERE Control_Number=$_POST[cn]");
            while($rowval = mysqli_fetch_array($res)){
                $controlnumber= $rowval['Control_Number'];
                $lastname= $rowval['Last_Name'];
                $firstname= $rowval['First_Name'];
                $contactnumber= $rowval['Contact_Number'];
            }
        }
    ?>

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

FORM

                    Control Number:
                    <input class = "input-lg" type = "text" id = "Control_Number" value = '<?php echo $controlnumber; ?>'>

                    Last Name:
                    <input class = "input-lg" type = "text" id = "Last_Name" value = '<?php echo $lastname; ?>'>

                    First Name:
                    <input class = "input-lg" type = "text" id = "First_Name" value = '<?php echo $firstname; ?>'>

                    Contact Number:
                    <input class = "input-lg" type = "text" id = "Contact_Number" value = '<?php echo $contactnumber; ?>'>

Body:
@MYxx here is what you wanted. Here i have used OOPS PHP  MYSQLi Prepare JQuery Ajax and JSON to send and received data and display in modal.

Why MYSQLi PREPARED STATEMENTS because it prevents SQL INJECTION for more info click on this link sql injection

If you are new to PHP and MySQL then don't worry, you will get adjusted to this soon.  If you are having problems understanding this answer, I will be happy to help you.

index.php

    <?php
    include('Table_info.php');

    $tbl_data = new Table_info();
?>
<!DOCTYPE html>
<html>
<head>
    <title>Welcome</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
  <div class="row">
    <table class="table table-hover table-bordered">
        <thead>
            <tr>
                <th>#</th>
                <th> First Name </th>
                <th> Last Name </th>
                <th> Contact Number </th>
                <th> Control Number </th>
                <th> Action</th>
            </tr>
        </thead>
        <tbody>
            <?php
                $tbl_data->show_table();

            ?>
        </tbody>
    </table>
  </div>
</div>

<!-- ADDED THE MUSIC MODAL-->
<div class="container">
  <div class="modal fade" id="fmodal" role="dialog">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal">&times;</button>
              <h4 class="modal-title">User data</h4>
            </div>
            <div class="modal-body" id="userdata_div">
                <form action="" method="post" enctype="multipart/form-data">
                    <div class="form-group">
                        <input type="hidden" name="id" id="id" value="">
                        <p>Firstname</p>
                        <input type="text" name="fname" id="fname">
                    </div>

                    <div class="form-group">
                        <p>Lastname</p>
                        <input type="text" name="lname" id="lname">
                    </div>

                    <div class="form-group">
                        <p>Contact_Number</p>
                        <input type="text" name="Contact_Number" id="Contact_Number">
                    </div>

                    <div class="form-group">
                        <p>Lastname</p>
                        <input type="text" name="Control_Number" id="Control_Number">
                    </div>

                    <div class="form-group text-center" style="margin:0;">
                        <input type="submit" name="submit_btn" class="btn btn-default" style="border:1px solid #451;">
                    </div>
                </form>
            </div>
            <div class="modal-footer">
              <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
  </div>
</div>

<script>
$(document).ready(function(){
    getdata();
});

function getdata(){
    $('.open_model_btn').click(function(){
        $('#fmodal').modal();
        var id = $(this).attr('id');

        //alert('works');

        $.ajax({
            type:'POST',
            url:'Table_info.php',
            data:{slno_id:id},
            success:function(data){
                var res = JSON.parse(data);

                for(var i in res){
                    $('#id').val(res[i].id);
                    $('#fname').val(res[i].First_Name);
                    $('#lname').val(res[i].Last_Name);
                    $('#Contact_Number').val(res[i].Contact_Number);
                    $('#Control_Number').val(res[i].Control_Number);
                }
            }
        });

        $('#id, #fname, #lname, #Contact_Number, #Control_Number').val('');
    });
}
</script>
</body>
</html>

PHP Class file name: Table_info.php

    <?php
    class Table_info{
        private $link;

        function __construct(){
            $this->link = new mysqli('localhost','root','','example');

            if($this->link->connect_error){
                die ('connection failed'.$this->link->connect_error);
            }
        }

        function show_table(){
            $sql = $this->link->stmt_init();
            $i=1;
            if($sql->prepare("SELECT id,First_Name,Last_Name,Contact_Number,Control_Number FROM information")){
                $sql->bind_result($id,$First_Name,$Last_Name,$Contact_Number,$Control_Number);

                $sql->execute();

                $sql->store_result();

                if($sql->num_rows > 0){
                    while($sql->fetch()){
            ?>
                        <tr>
                            <td><?php echo $i;?></td>
                            <td><?php echo $First_Name;?></td>
                            <td><?php echo $Last_Name;?></td>
                            <td><?php echo $Contact_Number;?></td>
                            <td><?php echo $Control_Number;?></td>
                            <td><button class="btn btn-success open_model_btn" id="<?php echo $id;?>">Show</button></td>
                        </tr>
            <?php
                        $i++;
                    }
                }

            }
            else
            {
                echo 'Error'.$this->link->error;
            }
        }

        function get_data_modal($slnoid){
            $sql = $this->link->stmt_init();
            $i=1;
            if($sql->prepare("SELECT id,First_Name,Last_Name,Contact_Number,Control_Number FROM information WHERE id=?")){
            $sql->bind_param('i',$slnoid);
                $sql->bind_result($id,$First_Name,$Last_Name,$Contact_Number,$Control_Number);

                $sql->execute();

                $sql->store_result();

                if($sql->num_rows > 0){
                    while($sql->fetch()){
                        $arr[] = array(
                            'id'=>$id,
                            'First_Name'=>$First_Name,
                            'Last_Name'=>$Last_Name,
                            'Contact_Number'=>$Contact_Number,
                            'Control_Number'=>$Control_Number,
                            'report'=>'Success'
                        );
                    }

                    echo json_encode($arr);
                }
                else
                {
                    $arr = array(
                            'statuss'=>false,
                            'report'=>'No data available'
                        );

                    echo json_encode($arr);
                }
            }
            else
            {
                $err = 'Error'.$this->link->error;

                $arr = array(
                        'statuss'=>false,
                        'report'=>$err
                    );

                echo json_encode($arr);
            }
        }
    }

    $tbl_data = new Table_info();

    if(isset($_POST['slno_id'])){
        $slnoid = $_POST['slno_id'];

        $tbl_data->get_data_modal($slnoid);
    }
?>


问:
Goroutine and Workgroup Issue
I'm trying to print a set of Big Jobs ("1,2", "3,4", "5") in combination with Extra Jobs ("one", "two", "three") and using Goroutines and Workgroups to do so.

I am expecting the following output (not exactly in this order, but the internal Workgroups should finish first before the outer ones):

```<code>Big Job being done: 1,2
1_one
1_two
1_three
2_one
2_two
2_three
Big Job 1,2 is Done!
Big Job being done: 3,4
3_one
3_two
3_three
4_one
4_two
4_three
Big Job 3,4 is Done!
Big Job being done: 5
5_one
5_two
5_three
Big Job 5 is Done!
All Big Jobs are done!
</code>```

Go Playground Link: https://play.golang.org/p/Hvbcmw06WY

However, when I run my code, I get the following output instead:

```<code>Big job  1,2  is Done!
Big job  3,4  is Done!
Big job  5  is Done!
Big Job being done: 5
5_three
Big Job being done: 1,2
1_three
Big Job being done: 3,4
3_three
5_one
5_two
1_one
1_two
3_one
3_two
fatal error: all goroutines are asleep - deadlock!
</code>```

As you can see, the second portion of the Big Jobs (2 and 4) were somehow "lost" inside the goroutines.

Also, the All Big Jobs are done! message is never reached because all goroutines fall asleep somehow, even though each Waitgroup should have finished already (though the missing 2 and 4 portions might have something to do with it).

I also noticed that for some reason the Done messages are being printed first (although I'm assuming that the Print functions are simply having trouble catching up with the Goroutines).

Here is the non-Goroutine version of what I want to accomplish: https://play.golang.org/p/zZpfyIbbn8

Any idea what I might be doing wrong?

答:
jobWG.Wait() is inside the for _, job := range jobs loop when it should be outside.
Here is a fixed version https://play.golang.org/p/KNLS0y8xLg

Title: Goroutine and Workgroup Issue

Body:
I'm trying to print a set of Big Jobs ("1,2", "3,4", "5") in combination with Extra Jobs ("one", "two", "three") and using Goroutines and Workgroups to do so.

I am expecting the following output (not exactly in this order, but the internal Workgroups should finish first before the outer ones):

Big Job being done: 1,2
1_one
1_two
1_three
2_one
2_two
2_three
Big Job 1,2 is Done!
Big Job being done: 3,4
3_one
3_two
3_three
4_one
4_two
4_three
Big Job 3,4 is Done!
Big Job being done: 5
5_one
5_two
5_three
Big Job 5 is Done!
All Big Jobs are done!

Go Playground Link: https://play.golang.org/p/Hvbcmw06WY

However, when I run my code, I get the following output instead:

Big job  1,2  is Done!
Big job  3,4  is Done!
Big job  5  is Done!
Big Job being done: 5
5_three
Big Job being done: 1,2
1_three
Big Job being done: 3,4
3_three
5_one
5_two
1_one
1_two
3_one
3_two
fatal error: all goroutines are asleep - deadlock!

As you can see, the second portion of the Big Jobs (2 and 4) were somehow "lost" inside the goroutines.

Also, the All Big Jobs are done! message is never reached because all goroutines fall asleep somehow, even though each Waitgroup should have finished already (though the missing 2 and 4 portions might have something to do with it).

I also noticed that for some reason the Done messages are being printed first (although I'm assuming that the Print functions are simply having trouble catching up with the Goroutines).

Here is the non-Goroutine version of what I want to accomplish: https://play.golang.org/p/zZpfyIbbn8

Any idea what I might be doing wrong?


问:
Edit hashmap in JSF or Primefaces datatable
I have an object that represents a service provider. In that object I have this hashmap

```<code>private Map<MetaDataKeys, String> metaData;
</code>```

The "MetaDatatKeys" is a enum that looks like this,

```<code>public enum MetaDataKeys {
    PROVIDER_NAME, PROVIDER_CONTACT_NAME, PROVIDER_SERVICE_RADIUS;
}
</code>```

I would like to display the hashmap key/value pairs in a datatable or similar for editing, something along the lines of,

```<code>            <p:dataTable id="providerDatatable" var="infoMap" value="#{editUserBean.editUser.metaData}">
                <p:column><h:outputText value="#{infoMap.key.metaData}"/></p:column>
                <p:column><h:inputText value="#{infoMap.key.value}"/></p:column>
            </p:dataTable>
</code>```

In my backing bean "editUser" is the object that contains the map.

what is the best way to go about this? I have not been successful in even getting the table to render and populate with values. In searching most examples use a string or a primitive for the key.

答:
You should make iteration in the datatable by Map.entrySet() it's better way. If you try to do itaration by Map.keySet() and than take value by key you can take O(n^2).

For your task realisation looks like:

```<code><p:dataTable id="providerDatatable" var="infoMap" value="#{editUserBean.editUser.metaData.entrySet()}">
    <p:column><h:outputText value="#{infoMap.key}"/></p:column>
    <p:column><h:inputText value="#{infoMap.value}"/></p:column>
</p:dataTable>
</code>```

To edit table row you can you use p:cellEditor more info about this component you can find at the Primefaces show case

Body:
I have an object that represents a service provider. In that object I have this hashmap

private Map<MetaDataKeys, String> metaData;

The "MetaDatatKeys" is a enum that looks like this,

public enum MetaDataKeys {
    PROVIDER_NAME, PROVIDER_CONTACT_NAME, PROVIDER_SERVICE_RADIUS;
}

I would like to display the hashmap key/value pairs in a datatable or similar for editing, something along the lines of,

<h:outputText value="#{infoMap.key.metaData}"/>

<h:inputText value="#{infoMap.key.value}"/>

In my backing bean "editUser" is the object that contains the map.

what is the best way to go about this? I have not been successful in even getting the table to render and populate with values. In searching most examples use a string or a primitive for the key.

Body:
You should make iteration in the datatable by Map.entrySet() it's better way. If you try to do itaration by Map.keySet() and than take value by key you can take O(n^2).

For your task realisation looks like:

<p:dataTable id="providerDatatable" var="infoMap" value="#{editUserBean.editUser.metaData.entrySet()}">
    <p:column><h:outputText value="#{infoMap.key}"/></p:column>
    <p:column><h:inputText value="#{infoMap.value}"/></p:column>
</p:dataTable>

To edit table row you can you use p:cellEditor more info about this component you can find at the Primefaces show case


问:
How to create a login using google in chrome extension
I just recently building an plugin in which I need to integrate Google Login. I searched and found chrome.identity to authenticate user using google account but that does not work well.

So I came across a solution by using this code below

```<code>    var manifest = chrome.runtime.getManifest();
    var clientId = encodeURIComponent(manifest.oauth2.client_id);
    var scopes = encodeURIComponent(manifest.oauth2.scopes.join(' '));
    var redirectUri = encodeURIComponent('urn:ietf:wg:oauth:2.0:oob:auto');

    var url = 'https://accounts.google.com/o/oauth2/v2/auth' +
              '?client_id=' + clientId +
              '&response_type=code' +
              '&redirect_uri=' + redirectUri +
              '&scope=' + scopes;

    var RESULT_PREFIX = ['Success', 'Denied', 'Error'];
    chrome.tabs.create({'url': 'about:blank'}, function(authenticationTab) {
        chrome.tabs.onUpdated.addListener(function googleAuthorizationHook(tabId, changeInfo, tab) {
            if (tabId === authenticationTab.id) {

                var titleParts = tab.title.split(' ', 2);

                var result = titleParts[0];
                if (titleParts.length == 2 && RESULT_PREFIX.indexOf(result) >= 0) {
                    chrome.tabs.onUpdated.removeListener(googleAuthorizationHook);
                    chrome.tabs.remove(tabId);

                    var response = titleParts[1];
                    switch (result) {
                        case 'Success':
                            // Example: id_token=<YOUR_BELOVED_ID_TOKEN>&authuser=0&hd=<SOME.DOMAIN.PL>&session_state=<SESSION_SATE>&prompt=<PROMPT>
                            console.log("suc:"+response);
                        break;
                        case 'Denied':
                            // Example: error_subtype=access_denied&error=immediate_failed
                            console.log("denied:"+response);
                        break;
                        case 'Error':
                            // Example: 400 (OAuth2 Error)!!1
                            console.log("error:"+response);
                        break;
                    }
                }
            }
        });

        chrome.tabs.update(authenticationTab.id, {'url': url});
    });
</code>```

In which if I remove v2 from the url variable then it always gives error in the turn with id_token but if I add v2 then its success and return code.

So now I read google documentation which said that now create a post request using client_id and client_secret but I chrome app create credential on google console which does not have client_secret

Now what should I do ? Is there anything that I missed or do wrong here and I also came across one of the chrome extension Screencastify use google login.

Can anyone explain how they do it ?

答:
There's an official OAuth tutorial here for Chrome extensions/apps which you can refer to.

There's another blog tutorial here:

Step 1: Copy library

You will need to copy the oauth2 library into your chrome extension root into a directory called oauth2.

Step 2: Inject content script

Then you need to modify your manifest.json file to include a content script at the redirect URL used by the Google adapter. The "matches" redirect URI can be looked up in the table above:

```<code>"content_scripts": [
  {
    "matches": ["http://www.google.com/robots.txt*"],
    "js": ["oauth2/oauth2_inject.js"],
    "run_at": "document_start"
  }
],
</code>```

Step 3: Allow access token URL

Also, you will need to add a permission to Google's access token granting URL, since the library will do an XHR against it. The access token URI can be looked up in the table above as well.

```<code>"permissions": [
  "https://accounts.google.com/o/oauth2/token"
]
</code>```

Step 4: Include the OAuth 2.0 library

Next, in your extension's code, you should include the OAuth 2.0 library:

```<code><script src="/oauth2/oauth2.js"></script>
</code>```

Step 5: Configure the OAuth 2.0 endpoint

And configure your OAuth 2 connection by providing clientId, clientSecret and apiScopes from the registration page. The authorize() method may create a new popup window for the user to grant your extension access to the OAuth2 endpoint.

```<code>var googleAuth = new OAuth2('google', {
  client_id: '17755888930840',
  client_secret: 'b4a5741bd3d6de6ac591c7b0e279c9f',
  api_scope: 'https://www.googleapis.com/auth/tasks'
});

googleAuth.authorize(function() {
  // Ready for action
});
</code>```

Step 6: Use the access token

Now that your user has an access token via auth.getAccessToken(), you can request protected data by adding the accessToken as a request header

```<code>xhr.setRequestHeader('Authorization', 'OAuth ' + myAuth.getAccessToken())
</code>```

or by passing it as part of the URL (depending on the server implementation):

```<code>myUrl + '?oauth_token=' + myAuth.getAccessToken();
</code>```

Note: if you have multiple OAuth 2.0 endpoints that you would like to authorize with, you can do that too! Just inject content scripts and add permissions for all of the providers you would like to authorize with.

And here's the actual github sample using those concepts.

ContentLicense: CC BY-SA 4.0

Body:
I just recently building an plugin in which I need to integrate Google Login. I searched and found chrome.identity to authenticate user using google account but that does not work well.

So I came across a solution by using this code below

    var manifest = chrome.runtime.getManifest();
    var clientId = encodeURIComponent(manifest.oauth2.client_id);
    var scopes = encodeURIComponent(manifest.oauth2.scopes.join(' '));
    var redirectUri = encodeURIComponent('urn:ietf:wg:oauth:2.0:oob:auto');

    var url = 'https://accounts.google.com/o/oauth2/v2/auth' +
              '?client_id=' + clientId +
              '&response_type=code' +
              '&redirect_uri=' + redirectUri +
              '&scope=' + scopes;

    var RESULT_PREFIX = ['Success', 'Denied', 'Error'];
    chrome.tabs.create({'url': 'about:blank'}, function(authenticationTab) {
        chrome.tabs.onUpdated.addListener(function googleAuthorizationHook(tabId, changeInfo, tab) {
            if (tabId === authenticationTab.id) {

                var titleParts = tab.title.split(' ', 2);

                var result = titleParts[0];
                if (titleParts.length == 2 && RESULT_PREFIX.indexOf(result) >= 0) {
                    chrome.tabs.onUpdated.removeListener(googleAuthorizationHook);
                    chrome.tabs.remove(tabId);

                    var response = titleParts[1];
                    switch (result) {
                        case 'Success':
                            // Example: id_token=<YOUR_BELOVED_ID_TOKEN>&authuser=0&hd=<SOME.DOMAIN.PL>&session_state=<SESSION_SATE>&prompt=<PROMPT>
                            console.log("suc:"+response);
                        break;
                        case 'Denied':
                            // Example: error_subtype=access_denied&error=immediate_failed
                            console.log("denied:"+response);
                        break;
                        case 'Error':
                            // Example: 400 (OAuth2 Error)!!1
                            console.log("error:"+response);
                        break;
                    }
                }
            }
        });

        chrome.tabs.update(authenticationTab.id, {'url': url});
    });

In which if I remove v2 from the url variable then it always gives error in the turn with id_token but if I add v2 then its success and return code.

So now I read google documentation which said that now create a post request using client_id and client_secret but I chrome app create credential on google console which does not have client_secret

Now what should I do ? Is there anything that I missed or do wrong here and I also came across one of the chrome extension Screencastify use google login.

Can anyone explain how they do it ?

Body:
There's an official OAuth tutorial here for Chrome extensions/apps which you can refer to.

There's another blog tutorial here:

Step 1: Copy library

You will need to copy the oauth2 library into your chrome extension root into a directory called oauth2.

Step 2: Inject content script

Then you need to modify your manifest.json file to include a content script at the redirect URL used by the Google adapter. The "matches" redirect URI can be looked up in the table above:

"content_scripts": [
  {
    "matches": ["http://www.google.com/robots.txt*"],
    "js": ["oauth2/oauth2_inject.js"],
    "run_at": "document_start"
  }
],

Step 3: Allow access token URL

Also, you will need to add a permission to Google's access token granting URL, since the library will do an XHR against it. The access token URI can be looked up in the table above as well.

"permissions": [
  "https://accounts.google.com/o/oauth2/token"
]

Step 4: Include the OAuth 2.0 library

Next, in your extension's code, you should include the OAuth 2.0 library:

<script src="/oauth2/oauth2.js"></script>

Step 5: Configure the OAuth 2.0 endpoint

And configure your OAuth 2 connection by providing clientId, clientSecret and apiScopes from the registration page. The authorize() method may create a new popup window for the user to grant your extension access to the OAuth2 endpoint.

var googleAuth = new OAuth2('google', {
  client_id: '17755888930840',
  client_secret: 'b4a5741bd3d6de6ac591c7b0e279c9f',
  api_scope: 'https://www.googleapis.com/auth/tasks'
});

googleAuth.authorize(function() {
  // Ready for action
});

Step 6: Use the access token

Now that your user has an access token via auth.getAccessToken(), you can request protected data by adding the accessToken as a request header

xhr.setRequestHeader('Authorization', 'OAuth ' + myAuth.getAccessToken())

or by passing it as part of the URL (depending on the server implementation):

myUrl + '?oauth_token=' + myAuth.getAccessToken();

Note: if you have multiple OAuth 2.0 endpoints that you would like to authorize with, you can do that too! Just inject content scripts and add permissions for all of the providers you would like to authorize with.

And here's the actual github sample using those concepts.


问:
What to put in revision section in SBT for Postgres dependency
I'm adding a dependency to PostGres 9.6 in the library in my build.sbt file, but I'm unsure of what to put in the revision portion, or what those fields mean:

```<code>"postgresql" % "postgresql" % "9.6-???-?.jdbc?"
</code>```

I've seen older ones on Stackoverflow such as:

```<code>"postgresql" % "postgresql" % "9.1-901-1.jdbc4"
</code>```

And I know the 9.1 means version 9.1 and the jdbc4 is well... JDBC4. But how do I know what do the other fields mean and where would I get them?

Thanks!

答:
See the GitHub project page. The correct syntax to use the (current) newest driver:

```<code>"org.postgresql" % "postgresql" % "42.1.1"
</code>```

Dont forget to run update

Body:
I'm adding a dependency to PostGres 9.6 in the library in my build.sbt file, but I'm unsure of what to put in the revision portion, or what those fields mean:

"postgresql" % "postgresql" % "9.6-???-?.jdbc?"

I've seen older ones on Stackoverflow such as:

"postgresql" % "postgresql" % "9.1-901-1.jdbc4"

And I know the 9.1 means version 9.1 and the jdbc4 is well... JDBC4. But how do I know what do the other fields mean and where would I get them?

Thanks!

Body:
See the GitHub project page. The correct syntax to use the (current) newest driver:

"org.postgresql" % "postgresql" % "42.1.1"

Dont forget to run update


问:
Errors occurred:Technical error: Unexpected response returned by server. Import stopped. - Prestashop 1.7.1.1
I'm importing my old prestashop data to new site with updated prestashop (ver. 1.7.1.1). When I'm importing the category csv file I got this error

Errors occurred:Technical error: Unexpected response returned by server. Import stopped.

I've got other csv's naming products,customers and manufacturers. So which csv is first imported to prestashop ? I've got bit confused here.
Is there anyone can help me ? Any help is appreciated. I'm attaching the screenshot of error here.

答:
I found that it is badly handled exceptions during the import AJAX request. In my case, it was caused by one value in the feature field in the csv import file that was larger than 255 chars. I solved it by increasing the size attribute in FeatureValue.php file on line 53.

The best way how to more info about Your problem is open Chrome Debugging tool where You get more information in case of exception during the report.


问:
Fetching and displaying data from core data
Aim :

To be able to display the days selected and the time picked by the user in the same row of the table view. The time should appear at the top and the days selected should appear at the bottom, both in the same row, just like an alarm clock.

Work :

This is the relationship I've got setup :

and this is how I save the days that are selected from a UITable and the time from a UIDatepicker when the save button is tapped :

```<code>@IBAction func saveButnTapped(_ sender: AnyObject)
    {
        let context =  (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext //creates an object of a property in AppDelegate.swift so we can access it

        let bob = Bob(context: context)

        //save the time from UIDatePicker to core data
        let dateFormatter = DateFormatter()
        dateFormatter.dateFormat = "HH:mm"
        bob.timeToPing = dateFormatter.string(from: timePicked.date)

        // save the days selected to core data
        for weekday in filteredWeekdays
        {
            var day = Days(context: context) //create new Days object
            day.daysSelected = weekday as NSObject? //append selected weekday
            bob.addToTimeAndDaysLink(day) //for every loop add day object to bob object
        }

        //Save the data to core data
        (UIApplication.shared.delegate as! AppDelegate).saveContext()

        //after saving data, show the first view controller
        navigationController!.popViewController(animated: true)
    }
</code>```

Now that the data is once saved, I get the data :

```<code>func getData()
{
    let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext

    do
    {
        bobs = try context.fetch(Bob.fetchRequest())
    }
    catch
    {
        print("Fetching failed")
    }

}
</code>```

Attempt to get the days selected :

I tried to follow this, the below comments and a formerly deleted answer to this question to do this :

```<code>func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
    let cell = UITableViewCell()

    let bob = bobs[indexPath.row]
    cell.textLabel?.text = bob.timeToPing?.description

    // retrieve the days that are selected
    var daysArray: [Days] = []
    daysArray = bob.timeAndDaysLink?.allObjects as! [Days]

    for days in daysArray
    {
        print (days.daysSelected?.description)
        cell.textLabel?.text = days.daysSelected! as! String

    }

    return cell
}
</code>```

EDIT :
print(daysArray) gives this  :

```<code>[<Days: 0x6080000a5880> (entity: Days; id: 0xd000000000040000 <x-coredata://30B28771-0569-41D3-8BFB-D2E07A261BF4/Days/p1> ; data: <fault>)]
</code>```

print(daysArray[0]) gives this :

```<code><Days: 0x6080000a5880> (entity: Days; id: 0xd000000000040000 <x-coredata://30B28771-0569-41D3-8BFB-D2E07A261BF4/Days/p1> ; data: <fault>)
</code>```

How to save days

```<code>let weekdays = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
var filteredWeekdays: [String] = []
 @NSManaged public var daysSelectedbyUser: NSSet
</code>```

And then

```<code>override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
    {
        selectedWeekdays()

    }

    override func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath)
    {
        selectedWeekdays()
    }

    func selectedWeekdays()
    {
        if let selectedRows = tableView.indexPathsForSelectedRows
        {
            let rows = selectedRows.filter {$0.section == 0}.map{ $0.row}
            filteredWeekdays = rows.map{ weekdays[$0] }
            print(filteredWeekdays)
        }
    }
</code>```

Many thanks!

答:
OK based on your latest comment that the crash occur on this line:

cell.textLabel?.text = days.value(forKey: "daySelected") as! String

It's clearly pointing to the typo you've made in key name. You have: daySelected and should be (based on your core data model) daysSelected, but nevertheless it's not very good approach to use values for your core data entity and also force type like that. To make it better I suggest replacing this line with:

cell.textLabel?.text = days.daysSelected!

This should be already a String since this is a String in CoreData. In case it's optional (should be an optional), you shouldn't force it. I will assume that whenever data will be not there you will just display empty cell, so even better it will be:

cell.textLabel?.text = days.daysSelected ?? ""

This will produce empty string to text, whenever (for some reason) data will be not there.

EDIT

So for additional piece of code you put in your question:

In your CoreData field daysSelected is type of String?, right?
Then you assign timeAndDateLink to NSSet<String>, right? But expected value here should be NSSet<Days>.

So let's edit your input code a bit ( i will put comment on every line):

```<code>let bob = Bob(context: context) /* create new Bob object */
for weekday in filteredWeekdays {
    var day = Days(context: context) /* create new Days object */
    day.daysSelected = weekday /* append selected weekday */
    bob.addToTimeAndDaysLink(day) /* for every loop add day object to bob object */
}
</code>```

I hope everything is clear in above example. You may have a problem with a compiler in that case, because if you choose generate class for entities you will endup with two func with the same name but different parameter (in Swift this should be two different functions, but Xcode sometimes pointing to the wrong one). If you hit that problem try:

```<code>let bob = Bob(context: context) /* create new Bob object */
var output: NSMutableSet<Days> = NSMutableSet()
for weekday in filteredWeekdays {
    var day = Days(context: context) /* create new Days object */
    day.daysSelected = weekday /* append selected weekday */
    output.add(day)
}
bob.addToTimeAndDaysLink(output) /* this will assign output set to bob object */
</code>```

You should also rename your Days entity to Day to avoid future confusion that we have right now, days as array will only be in relation from other entities to this not entity itself.

Body:
Aim :

To be able to display the days selected and the time picked by the user in the same row of the table view. The time should appear at the top and the days selected should appear at the bottom, both in the same row, just like an alarm clock.

Work :

This is the relationship I've got setup :

and this is how I save the days that are selected from a UITable and the time from a UIDatepicker when the save button is tapped :

@IBAction func saveButnTapped(_ sender: AnyObject)
    {
        let context =  (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext //creates an object of a property in AppDelegate.swift so we can access it

        let bob = Bob(context: context)

        //save the time from UIDatePicker to core data
        let dateFormatter = DateFormatter()
        dateFormatter.dateFormat = "HH:mm"
        bob.timeToPing = dateFormatter.string(from: timePicked.date)

        // save the days selected to core data
        for weekday in filteredWeekdays
        {
            var day = Days(context: context) //create new Days object
            day.daysSelected = weekday as NSObject? //append selected weekday
            bob.addToTimeAndDaysLink(day) //for every loop add day object to bob object
        }

        //Save the data to core data
        (UIApplication.shared.delegate as! AppDelegate).saveContext()

        //after saving data, show the first view controller
        navigationController!.popViewController(animated: true)
    }

Now that the data is once saved, I get the data :

func getData()
{
    let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext

    do
    {
        bobs = try context.fetch(Bob.fetchRequest())
    }
    catch
    {
        print("Fetching failed")
    }

}

Attempt to get the days selected :

I tried to follow this, the below comments and a formerly deleted answer to this question to do this :

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
    let cell = UITableViewCell()

    let bob = bobs[indexPath.row]
    cell.textLabel?.text = bob.timeToPing?.description

    // retrieve the days that are selected
    var daysArray: [Days] = []
    daysArray = bob.timeAndDaysLink?.allObjects as! [Days]

    for days in daysArray
    {
        print (days.daysSelected?.description)
        cell.textLabel?.text = days.daysSelected! as! String

    }

    return cell
}

EDIT :
print(daysArray) gives this  :

[<Days: 0x6080000a5880> (entity: Days; id: 0xd000000000040000 <x-coredata://30B28771-0569-41D3-8BFB-D2E07A261BF4/Days/p1> ; data: <fault>)]

print(daysArray[0]) gives this :

<Days: 0x6080000a5880> (entity: Days; id: 0xd000000000040000 <x-coredata://30B28771-0569-41D3-8BFB-D2E07A261BF4/Days/p1> ; data: <fault>)

How to save days

let weekdays = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
var filteredWeekdays: [String] = []
 @NSManaged public var daysSelectedbyUser: NSSet

And then

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
    {
        selectedWeekdays()

    }

    override func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath)
    {
        selectedWeekdays()
    }

    func selectedWeekdays()
    {
        if let selectedRows = tableView.indexPathsForSelectedRows
        {
            let rows = selectedRows.filter {$0.section == 0}.map{ $0.row}
            filteredWeekdays = rows.map{ weekdays[$0] }
            print(filteredWeekdays)
        }
    }

Many thanks!

Body:
OK based on your latest comment that the crash occur on this line:

cell.textLabel?.text = days.value(forKey: "daySelected") as! String

It's clearly pointing to the typo you've made in key name. You have: daySelected and should be (based on your core data model) daysSelected, but nevertheless it's not very good approach to use values for your core data entity and also force type like that. To make it better I suggest replacing this line with:

cell.textLabel?.text = days.daysSelected!

This should be already a String since this is a String in CoreData. In case it's optional (should be an optional), you shouldn't force it. I will assume that whenever data will be not there you will just display empty cell, so even better it will be:

cell.textLabel?.text = days.daysSelected ?? ""

This will produce empty string to text, whenever (for some reason) data will be not there.

EDIT

So for additional piece of code you put in your question:

In your CoreData field daysSelected is type of String?, right?
Then you assign timeAndDateLink to NSSet<String>, right? But expected value here should be NSSet<Days>.

So let's edit your input code a bit ( i will put comment on every line):

let bob = Bob(context: context) /* create new Bob object */
for weekday in filteredWeekdays {
    var day = Days(context: context) /* create new Days object */
    day.daysSelected = weekday /* append selected weekday */
    bob.addToTimeAndDaysLink(day) /* for every loop add day object to bob object */
}

I hope everything is clear in above example. You may have a problem with a compiler in that case, because if you choose generate class for entities you will endup with two func with the same name but different parameter (in Swift this should be two different functions, but Xcode sometimes pointing to the wrong one). If you hit that problem try:

let bob = Bob(context: context) /* create new Bob object */
var output: NSMutableSet<Days> = NSMutableSet()
for weekday in filteredWeekdays {
    var day = Days(context: context) /* create new Days object */
    day.daysSelected = weekday /* append selected weekday */
    output.add(day)
}
bob.addToTimeAndDaysLink(output) /* this will assign output set to bob object */

You should also rename your Days entity to Day to avoid future confusion that we have right now, days as array will only be in relation from other entities to this not entity itself.


问:
Import all modules from a directory at once [NODE]
```<code>MyApp
├── main.js
└── modules
    ├── a.js
    ├── b.js
    ├── c.js
    ├── d.js
    ├── e.js
</code>```

In my NodeJS app, how can I import all my custom modules (a,b,c,d,e) in my main.js file at once?

I have long list of modules and I dont want to import them all separately.

答:
Create an index.js in the modules/ folder:

```<code>const a = require('./a')
const b = require('./b')
const c = require('./c')
const d = require('./d')
const e = require('./e')

module.exports = {
  a,
  b,
  c,
  d,
  e
}
</code>```

Then just import the module in main.js:

```<code>const modules = require('./modules')
modules.a
</code>```

Alternatively you could loop through the directory and dynamically import each module.

Body:
MyApp
├── main.js
└── modules
    ├── a.js
    ├── b.js
    ├── c.js
    ├── d.js
    ├── e.js

In my NodeJS app, how can I import all my custom modules (a,b,c,d,e) in my main.js file at once?

I have long list of modules and I dont want to import them all separately.

Body:
Create an index.js in the modules/ folder:

const a = require('./a')
const b = require('./b')
const c = require('./c')
const d = require('./d')
const e = require('./e')

module.exports = {
  a,
  b,
  c,
  d,
  e
}

Then just import the module in main.js:

const modules = require('./modules')
modules.a

Alternatively you could loop through the directory and dynamically import each module.


问:
parked domain gives me SSL errors
i build wordpress website in 000webhostapp
and tried to put parked domain from freenom website
then got an error when i tried to see my website throught
https or Http
enter image description here

i tried plugin SSL but not usefull also
also changed the url from setting tab also not worked

答:
This is the expected behavior. You cannot just point your domain to their server since there is no certificate matching you domain there. And with the free hosting their will be no way to provide your own certificate. From 000webhostapp's Web Hosting FAQ & Knowledge Base:

SSL certificates, do you support SSL?

  We do not support SSL certificates and https secure connections.
  However you can upgrade your account and enjoy full benefits of SSL

Title: parked domain gives me SSL errors


问:
Python TFlearn - Loss too high
After fixing my problem of shape of input I ran my program, the problem is that the total loss printed by the program is way too high (if I compare it for example to the one from the quickstart tutorial).

My goal is to predict the congestion of future entry by using past data (I have more than 10M of entry with the score tagged on) so I shouldn't have problem with training.

Here is my code:

```<code>import numpy as np
import tflearn

# Load CSV file, indicate that the first column represents labels
from tflearn.data_utils import load_csv
data, labels = load_csv('nowcastScaled.csv', has_header=True, n_classes=2)

# Preprocessing function
def preprocess(data):
    return np.array(data, dtype=np.float32)

# Preprocess data
data = preprocess(data)

# Build neural network
net = tflearn.input_data(shape=[None, 2])
net = tflearn.fully_connected(net, 32)
net = tflearn.fully_connected(net, 32)
net = tflearn.fully_connected(net, 2, activation='linear')
data = np.reshape(data, (-1, 2))
labels = np.reshape(labels, (-1, 2))
net = tflearn.regression(net, optimizer='adam', learning_rate=0.001,
                         loss='categorical_crossentropy')

# Define model
model = tflearn.DNN(net)
# Start training (apply gradient descent algorithm)
model.fit(data, labels, n_epoch=15, batch_size=16, show_metric=True)

# Training
model.save('test_Model')
model.load('test_Model')
score = model.evaluate(data, labels, batch_size=16)
</code>```

My excel file have this kind of look (2 column, 100 000 lignes)

```<code>calculed_at , congestion
1 , 56
2 , 21
</code>```

This is what the results look like (15 epoch):

```<code>Training samples: 50000
Validation samples: 0
....
--
Training Step: 40625  | total loss: 15.27961 | time: 17.659s
| Adam | epoch: 013 | loss: 15.27961 - acc: 0.7070 -- iter: 50000/50000
--
Training Step: 43750  | total loss: 15.66268 | time: 17.549s
| Adam | epoch: 014 | loss: 15.66268 - acc: 0.7247 -- iter: 50000/50000
--
Training Step: 46875  | total loss: 15.94696 | time: 18.037s
| Adam | epoch: 015 | loss: 15.94696 - acc: 0.7581 -- iter: 50000/50000
--
</code>```

Have you an idea about what could cause such high loss? It seem strange since the accuracy printed doesn't seem too bad. Thank you for your help.

Edit: It seemed to be a good moment when I took theses values since when I tried just now I had total loss exceeding 280 (and an accuracy below 0,3 or barely above).

答: For time series, you construct the input/output samples by considering frames of time  window. In each window if the samples are {0, 1, ...N} select the first N-1 samples as input and the last sample  as output. Then you can do regression to do time prediction.

Title: Python TFlearn - Loss too high

Body:
After fixing my problem of shape of input I ran my program, the problem is that the total loss printed by the program is way too high (if I compare it for example to the one from the quickstart tutorial).

My goal is to predict the congestion of future entry by using past data (I have more than 10M of entry with the score tagged on) so I shouldn't have problem with training.

Here is my code:

import numpy as np
import tflearn

# Load CSV file, indicate that the first column represents labels
from tflearn.data_utils import load_csv
data, labels = load_csv('nowcastScaled.csv', has_header=True, n_classes=2)

# Preprocessing function
def preprocess(data):
    return np.array(data, dtype=np.float32)

# Preprocess data
data = preprocess(data)

# Build neural network
net = tflearn.input_data(shape=[None, 2])
net = tflearn.fully_connected(net, 32)
net = tflearn.fully_connected(net, 32)
net = tflearn.fully_connected(net, 2, activation='linear')
data = np.reshape(data, (-1, 2))
labels = np.reshape(labels, (-1, 2))
net = tflearn.regression(net, optimizer='adam', learning_rate=0.001,
                         loss='categorical_crossentropy')

# Define model
model = tflearn.DNN(net)
# Start training (apply gradient descent algorithm)
model.fit(data, labels, n_epoch=15, batch_size=16, show_metric=True)

# Training
model.save('test_Model')
model.load('test_Model')
score = model.evaluate(data, labels, batch_size=16)

My excel file have this kind of look (2 column, 100 000 lignes)

calculed_at , congestion
1 , 56
2 , 21

This is what the results look like (15 epoch):

Training samples: 50000
Validation samples: 0
....
--
Training Step: 40625  | total loss: 15.27961 | time: 17.659s
| Adam | epoch: 013 | loss: 15.27961 - acc: 0.7070 -- iter: 50000/50000
--
Training Step: 43750  | total loss: 15.66268 | time: 17.549s
| Adam | epoch: 014 | loss: 15.66268 - acc: 0.7247 -- iter: 50000/50000
--
Training Step: 46875  | total loss: 15.94696 | time: 18.037s
| Adam | epoch: 015 | loss: 15.94696 - acc: 0.7581 -- iter: 50000/50000
--

Have you an idea about what could cause such high loss? It seem strange since the accuracy printed doesn't seem too bad. Thank you for your help.

Edit: It seemed to be a good moment when I took theses values since when I tried just now I had total loss exceeding 280 (and an accuracy below 0,3 or barely above).


问:
How to add | remove css class in angular element?
How to add | remove css class in angular element?

Access to angular element is via: this.elementRef.nativeElement (import { ElementRef } from '@angular/core';).
CSS class name is myclass.

答:
```<code>constructor(public elementRef: ElementRef, private renderer: Renderer)
{
        this.renderer.setElementClass(this.elementRef, 'class');
   // or

            this.elementRef.nativeElement.classList.add('class');

}
</code>```

Using Renderer

Using addClass on Native element

Body:
constructor(public elementRef: ElementRef, private renderer: Renderer)
{
        this.renderer.setElementClass(this.elementRef, 'class');
   // or

            this.elementRef.nativeElement.classList.add('class');

}

Using Renderer

Using addClass on Native element


问:
Displaying PDF to Browser with PHP not working
Using php's ability to call upon the browser to display a given PDF it doesn't work on my web host. But it works on my local xamp server with apache.

PHP:

```<code>    $title = $_GET['title'];
    $loc = $_GET['loc'];

    header("Content-type: application/pdf");
    header("Content-Disposition: inline; filename=".$title);
    @readfile($loc);
</code>```

Expected Output: Supposed to be the PDF document being rendered like it does on my local web server.

Actual but unwanted output:
%PDF-1.6 %���� 1638 0 obj <> endobj xref 1638 44 0000000016 00000 n ...

Can be seen here:
http://neilau.me/view.php?title=business-studies-hsc-notes-2006.pdf&loc=pdf/criteria/business-studies/2006/business-studies-hsc-notes-2006.pdf

Is this fixed through changing something on my cpanel? As my code isn't faulty... It works on my local web server.

答:
You need to make sure you are not sending any text before writing headers.

Example of what not to do:

```<code><!DOCTYPE html>
<html>
...
<?php
header("Content-type: application/pdf");
</code>```

Example of how to fix that:

```<code><?php
header("Content-type: application/pdf");
?>
<!DOCTYPE html>
<html>
...
</code>```

In addition your script is very insecure. Here's what you should do, your entire PHP script should be:

```<code><?php
$loc = filter_input(INPUT_GET,"loc");
$title = filter_input(INPUT_GET,'title')?:basename($loc);
if (!is_readable($loc)) {
    http_response_code(404);
    echo "Cannot find that file";
    die();
}
if (strtolower(pathInfo($loc,PATHINFO_EXTENSION)) != "pdf") {
   http_response_code(403);
    echo "You are not allowed access to that file";
    die();
}

header("Content-type: application/pdf");
header("Content-Disposition: inline; filename=".$title);
header("Content-Length: ".filesize($loc));
readfile($loc);
</code>```

If you want to show things like a page title or a frame around it, you should use an iframe in another "wrapper" page:

```<code><?php
$loc = filter_input(INPUT_GET,"loc");
$title = filter_input(INPUT_GET,'title')?:basename($loc);
?>
<html><head><title>My title</title></head>
<body>
<iframe src="/view.php?<?php echo ($loc?"loc=$loc":"").($title?"title=$title":"") ?>">
</iframe>
</body>
<html>
</code>```

Body:
Using php's ability to call upon the browser to display a given PDF it doesn't work on my web host. But it works on my local xamp server with apache.

PHP:

    $title = $_GET['title'];
    $loc = $_GET['loc'];

    header("Content-type: application/pdf");
    header("Content-Disposition: inline; filename=".$title);
    @readfile($loc);

Expected Output: Supposed to be the PDF document being rendered like it does on my local web server.

Actual but unwanted output:
%PDF-1.6 %���� 1638 0 obj <> endobj xref 1638 44 0000000016 00000 n ...

Can be seen here:
http://neilau.me/view.php?title=business-studies-hsc-notes-2006.pdf&loc=pdf/criteria/business-studies/2006/business-studies-hsc-notes-2006.pdf

Is this fixed through changing something on my cpanel? As my code isn't faulty... It works on my local web server.

Body:
You need to make sure you are not sending any text before writing headers.

Example of what not to do:

<!DOCTYPE html>
<html>
...
<?php
header("Content-type: application/pdf");

Example of how to fix that:

<?php
header("Content-type: application/pdf");
?>
<!DOCTYPE html>
<html>
...

In addition your script is very insecure. Here's what you should do, your entire PHP script should be:

<?php
$loc = filter_input(INPUT_GET,"loc");
$title = filter_input(INPUT_GET,'title')?:basename($loc);
if (!is_readable($loc)) {
    http_response_code(404);
    echo "Cannot find that file";
    die();
}
if (strtolower(pathInfo($loc,PATHINFO_EXTENSION)) != "pdf") {
   http_response_code(403);
    echo "You are not allowed access to that file";
    die();
}

header("Content-type: application/pdf");
header("Content-Disposition: inline; filename=".$title);
header("Content-Length: ".filesize($loc));
readfile($loc);

If you want to show things like a page title or a frame around it, you should use an iframe in another "wrapper" page:

<?php
$loc = filter_input(INPUT_GET,"loc");
$title = filter_input(INPUT_GET,'title')?:basename($loc);
?>
<html><head><title>My title</title></head>
<body>
<iframe src="/view.php?<?php echo ($loc?"loc=$loc":"").($title?"title=$title":"") ?>">
</iframe>
</body>
<html>


问:
Animated mask and hide circle on hover with css
I wanna make info box with this design.

This design is important to me. When mouse is over the circle, I need some animation and transform design to this...

jsFiddle Example :

.wrapper{
    width:400px;
    height:200px;
    background: white;
    position: relative;
}
.mask {
    width: 100%;
    height: 100%;
    background: green;
    background-size: cover;
    transition: 0.4s ease;
    clip-path: circle(80px at 50% 50%);
    position: relative;
}
.mask:hover {
    clip-path:  circle(100% at 50% 50%);
}
.wrapper:after {
    content: ' ';
    display: block;
    position: relative;
    width: 160px;
    height: 160px;
    top: calc(-50% - 83px);
    left: calc(50% - 83px);
    border-radius: 50%;
    background:transparent;
    border: 3px solid #fff;
    box-shadow: 0px 0px 6px #aaa;
    pointer-events: none;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="wrapper">
    <div id="map-canvas" class="mask">

    </div>
</div></code>```

But I don't know how to hide the circle.

Is there any solution how to make and hide that circle with border and shadow ?

答:
You can just unset the border and box-shadow on :hover and transition that change, too, if you want.

.wrapper{
  width:400px;
  height:200px;
  background: white;
  position: relative;
}
.mask {
  width: 100%;
  height: 100%;
  background: green;
  background-size: cover;
  clip-path: circle(80px at 50% 50%);
  position: relative;
}
.mask, .wrapper:after {
  transition: 0.4s ease;
}
.wrapper:hover .mask {
  clip-path:  circle(100% at 50% 50%);
}
.wrapper:hover:after {
  border: 0;
  box-shadow: none;
}
.wrapper:after {
  content: ' ';
  display: block;
  position: relative;
  width: 160px;
  height: 160px;
  top: calc(-50% - 83px);
  left: calc(50% - 83px);
  border-radius: 50%;
  background:transparent;
  border: 3px solid #fff;
  box-shadow: 0px 0px 6px #aaa;
  pointer-events: none;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><br/>
<br/>
<div class="wrapper">
  <div id="map-canvas" class="mask">
  </div>
</div></code>```

Body:
I wanna make info box with this design.

This design is important to me. When mouse is over the circle, I need some animation and transform design to this...

jsFiddle Example :

.wrapper{
    width:400px;
    height:200px;
    background: white;
    position: relative;
}
.mask {
    width: 100%;
    height: 100%;
    background: green;
    background-size: cover;
    transition: 0.4s ease;
    clip-path: circle(80px at 50% 50%);
    position: relative;
}
.mask:hover {
    clip-path:  circle(100% at 50% 50%);
}
.wrapper:after {
    content: ' ';
    display: block;
    position: relative;
    width: 160px;
    height: 160px;
    top: calc(-50% - 83px);
    left: calc(50% - 83px);
    border-radius: 50%;
    background:transparent;
    border: 3px solid #fff;
    box-shadow: 0px 0px 6px #aaa;
    pointer-events: none;
}

But I don't know how to hide the circle.

Is there any solution how to make and hide that circle with border and shadow ?

Body:
You can just unset the border and box-shadow on :hover and transition that change, too, if you want.

.wrapper{
  width:400px;
  height:200px;
  background: white;
  position: relative;
}
.mask {
  width: 100%;
  height: 100%;
  background: green;
  background-size: cover;
  clip-path: circle(80px at 50% 50%);
  position: relative;
}
.mask, .wrapper:after {
  transition: 0.4s ease;
}
.wrapper:hover .mask {
  clip-path:  circle(100% at 50% 50%);
}
.wrapper:hover:after {
  border: 0;
  box-shadow: none;
}
.wrapper:after {
  content: ' ';
  display: block;
  position: relative;
  width: 160px;
  height: 160px;
  top: calc(-50% - 83px);
  left: calc(50% - 83px);
  border-radius: 50%;
  background:transparent;
  border: 3px solid #fff;
  box-shadow: 0px 0px 6px #aaa;
  pointer-events: none;
}

<br/>
<br/>
<div class="wrapper">
  <div id="map-canvas" class="mask">
  </div>
</div>


问:
How to configure ActiveMQ to assign an 'anonymous' user and role to non-authenticated users
I wish to set up a ActiveMQ instance (primarily as a STOMP server) which will service requests from two types of clients:

authenticated users which can read and write to topics

non-authenticated users which can only read from topics

I have been using the SimpleAuthenticationBroker so far and I cannot see anyway to configure the above situation, nor do I see any bit in the code which recognises a wildcard for a user to pass authentication.

If I configure the server to use the authentication broker, it will expect ALL connections to authenticate, which is what I don't want.

The only solution I think I can see is to provide my own implementation to support the functionality I require, but I would love to find some way built into the server.

答:
This is not currently supported by ActiveMQ security implementation, but you can always define a user that can connect without a password with read-only privileges.

You can raise Jira enhancement request (https://issues.apache.org/activemq/browse/AMQ) for this non-authenticated users feature and better yet provide a patch for current plugins.

OwnerDisplayName: magicbadger

ContentLicense: CC BY-SA 2.5

OwnerDisplayName: Dejan Bosanac


问:
Profile picture default size
AS in facebook,orkut what should be  the profile pic settings height,width etc so that the image is clear and do not have any distortion when viewing it</p>

```<code>     <img src="image.gif"  style="height:75px;width:130px;"  />
</code>```

答: They should be whatever the natural dimensions of the image are.</p>

Title: Profile picture default size


问:
How to simplify `case` iteraction when the code is almost the same
I have this code in my controller:

```<code>def search(conn, %{"q" => param}) do
    locale = conn |> get_session(:locale)
    case locale do
      "pt" ->
        searchEmpresas = Skeleton.Customers.Empresa |> Skeleton.Customers.search_pt(param)
        searchLojas = Skeleton.Customers.Loja |> Skeleton.Customers.search_pt(param)
        searchEventos = Skeleton.News.Evento |> Skeleton.News.search_pt(param)
      "es" ->
        searchEmpresas = Skeleton.Customers.Empresa |> Skeleton.Customers.search_es(param)
        searchLojas = Skeleton.Customers.Loja |> Skeleton.Customers.search_es(param)
        searchEventos = Skeleton.News.Evento |> Skeleton.News.search_es(param)
      "fr" ->
        searchEmpresas = Skeleton.Customers.Empresa |> Skeleton.Customers.search_fr(param)
        searchLojas = Skeleton.Customers.Loja |> Skeleton.Customers.search_fr(param)
        searchEventos = Skeleton.News.Evento |> Skeleton.News.search_fr(param)
      "de" ->
        searchEmpresas = Skeleton.Customers.Empresa |> Skeleton.Customers.search_de(param)
        searchLojas = Skeleton.Customers.Loja |> Skeleton.Customers.search_de(param)
        searchEventos = Skeleton.News.Evento |> Skeleton.News.search_de(param)
      _ ->
        searchEmpresas = Skeleton.Customers.Empresa |> Skeleton.Customers.search(param)
        searchLojas = Skeleton.Customers.Loja |> Skeleton.Customers.search(param)
        searchEventos = Skeleton.News.Evento |> Skeleton.News.search(param)
    end
    render(conn, "search.html", searchEmpresas: searchEmpresas, searchLojas: searchLojas, searchEventos: searchEventos)
  end
</code>```

The code is the same except for the ending _pt/es/de/fr in the search function.

Is there a way to simplify this greatly?

Is there a way to generate this code as we do in Phoenix Templates using:

```<code><%= for i <- ["pt", "es", "de", "fr"] do %>
   i ->
        searchEmpresas = Skeleton.Customers.Empresa |> Skeleton.Customers.search_<%=i%>(param)
        searchLojas = Skeleton.Customers.Loja |> Skeleton.Customers.search_<%=i%>(param)
        searchEventos = Skeleton.News.Evento |> Skeleton.News.search_<%=i%>(param)
<%end%>
</code>```

答:
Is there a way to simplify this greatly?

Yes, you can first generate the function name as an atom dynamically using if/2 and then use apply/3 to call it.

```<code>def search(conn, %{"q" => param}) do
  locale = conn |> get_session(:locale)
  f = if locale in ~w(pt es fr de), do: :"search_#{locale}", else: :search
  searchEmpresas = apply(Skeleton.Customers, f, [Skeleton.Customers.Empresa, param])
  searchLojas = apply(Skeleton.Customers, f, [Skeleton.Customers.Loja, param])
  searchEventos = apply(Skeleton.News, f, [Skeleton.News.Evento, param])
  render(conn, "search.html", searchEmpresas: searchEmpresas, searchLojas: searchLojas, searchEventos: searchEventos)
end
</code>```

Is there a way to generate this code as we do in Phoenix Templates using:

You could use macros for this, but I'd use the code above which uses apply/3.

Body:
I have this code in my controller:

def search(conn, %{"q" => param}) do
    locale = conn |> get_session(:locale)
    case locale do
      "pt" ->
        searchEmpresas = Skeleton.Customers.Empresa |> Skeleton.Customers.search_pt(param)
        searchLojas = Skeleton.Customers.Loja |> Skeleton.Customers.search_pt(param)
        searchEventos = Skeleton.News.Evento |> Skeleton.News.search_pt(param)
      "es" ->
        searchEmpresas = Skeleton.Customers.Empresa |> Skeleton.Customers.search_es(param)
        searchLojas = Skeleton.Customers.Loja |> Skeleton.Customers.search_es(param)
        searchEventos = Skeleton.News.Evento |> Skeleton.News.search_es(param)
      "fr" ->
        searchEmpresas = Skeleton.Customers.Empresa |> Skeleton.Customers.search_fr(param)
        searchLojas = Skeleton.Customers.Loja |> Skeleton.Customers.search_fr(param)
        searchEventos = Skeleton.News.Evento |> Skeleton.News.search_fr(param)
      "de" ->
        searchEmpresas = Skeleton.Customers.Empresa |> Skeleton.Customers.search_de(param)
        searchLojas = Skeleton.Customers.Loja |> Skeleton.Customers.search_de(param)
        searchEventos = Skeleton.News.Evento |> Skeleton.News.search_de(param)
      _ ->
        searchEmpresas = Skeleton.Customers.Empresa |> Skeleton.Customers.search(param)
        searchLojas = Skeleton.Customers.Loja |> Skeleton.Customers.search(param)
        searchEventos = Skeleton.News.Evento |> Skeleton.News.search(param)
    end
    render(conn, "search.html", searchEmpresas: searchEmpresas, searchLojas: searchLojas, searchEventos: searchEventos)
  end

The code is the same except for the ending _pt/es/de/fr in the search function.

Is there a way to simplify this greatly?

Is there a way to generate this code as we do in Phoenix Templates using:

<%= for i <- ["pt", "es", "de", "fr"] do %>
   i ->
        searchEmpresas = Skeleton.Customers.Empresa |> Skeleton.Customers.search_<%=i%>(param)
        searchLojas = Skeleton.Customers.Loja |> Skeleton.Customers.search_<%=i%>(param)
        searchEventos = Skeleton.News.Evento |> Skeleton.News.search_<%=i%>(param)
<%end%>

Body:
Is there a way to simplify this greatly?

Yes, you can first generate the function name as an atom dynamically using if/2 and then use apply/3 to call it.

def search(conn, %{"q" => param}) do
  locale = conn |> get_session(:locale)
  f = if locale in ~w(pt es fr de), do: :"search_#{locale}", else: :search
  searchEmpresas = apply(Skeleton.Customers, f, [Skeleton.Customers.Empresa, param])
  searchLojas = apply(Skeleton.Customers, f, [Skeleton.Customers.Loja, param])
  searchEventos = apply(Skeleton.News, f, [Skeleton.News.Evento, param])
  render(conn, "search.html", searchEmpresas: searchEmpresas, searchLojas: searchLojas, searchEventos: searchEventos)
end

Is there a way to generate this code as we do in Phoenix Templates using:

You could use macros for this, but I'd use the code above which uses apply/3.


问:
Error running app: Default Activity not found
I am new to Android Studio. I am using it now in the hope of obtaining some error messages that will explain why my APK couldn't be run in Blue Stacks. The APK was built in Unity.

After installing Android Studio, a phone emulator etc, I still couldn't run the APK. It said:

```<code>Error running app: Default Activity not found
</code>```

There has been a post about this error in Stack Overflow. However, my AndroidManifest.xml looks fine to me. I have also tried 'Invalidate Caches / Restart' to no avail. When I went to Edit Configurations > Launch Options > Specified Activity, I could not see any activity for me to select.

Below is my AndroidManifest:

```<code><?xml version="1.0" encoding="utf-8"?>
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:theme="@ref/0x01030006"
    android:versionCode="91"
    android:versionName="91"
    android:installLocation="2"
    package="com.quizjungle.android"
    platformBuildVersionCode="25"
    platformBuildVersionName="7.1.1">

    <supports-screens
        android:anyDensity="true"
        android:smallScreens="true"
        android:normalScreens="true"
        android:largeScreens="true"
        android:xlargeScreens="true" />

    <uses-sdk
        android:minSdkVersion="15"
        android:targetSdkVersion="25" />

    <application
        android:label="@ref/0x7f060050"
        android:icon="@ref/0x7f02004c"
        android:debuggable="false"
        android:banner="@ref/0x7f02004b"
        android:isGame="true">

        <activity
            android:label="@ref/0x7f060050"
            android:name="com.unity3d.player.UnityPlayerNativeActivity"
            android:launchMode="2"
            android:screenOrientation="1"
            android:configChanges="0x40000fff">

            <intent-filter>

                <action
                    android:name="android.intent.action.MAIN" />

                <category
                    android:name="android.intent.category.LAUNCHER" />

                <category
                    android:name="android.intent.category.LEANBACK_LAUNCHER" />
            </intent-filter>

            <meta-data
                android:name="unityplayer.UnityActivity"
                android:value="true" />

            <meta-data
                android:name="unityplayer.ForwardNativeEventsToDalvik"
                android:value="true" />
        </activity>

        <activity
            android:theme="@ref/0x01030011"
            android:name="com.facebook.unity.FBUnityLoginActivity"
            android:configChanges="0x40000fff" />

        <activity
            android:theme="@ref/0x01030011"
            android:name="com.facebook.unity.FBUnityDialogsActivity"
            android:configChanges="0x40000fff" />

        <activity
            android:name="com.facebook.unity.FBUnityAppLinkActivity"
            android:exported="true" />

        <activity
            android:name="com.facebook.unity.FBUnityDeepLinkingActivity"
            android:exported="true" />

        <activity
            android:name="com.facebook.unity.FBUnityGameRequestActivity" />

        <activity
            android:name="com.facebook.unity.FBUnityCreateGameGroupActivity" />

        <activity
            android:name="com.facebook.unity.FBUnityJoinGameGroupActivity" />

        <activity
            android:name="com.facebook.unity.AppInviteDialogActivity" />

        <meta-data
            android:name="com.facebook.sdk.ApplicationId"
            android:value="1479999760.000000" />

        <provider
            android:name="com.facebook.FacebookContentProvider"
            android:exported="true"
            android:authorities="com.facebook.app.FacebookContentProvider365740347105248" />

        <activity
            android:theme="@ref/0x01030011"
            android:name="com.chartboost.sdk.CBImpressionActivity"
            android:excludeFromRecents="true"
            android:configChanges="0x4a0"
            android:hardwareAccelerated="true" />

        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@ref/0x7f050000" />

        <activity
            android:theme="@ref/0x7f08000f"
            android:name="com.facebook.FacebookActivity"
            android:configChanges="0x5b0" />

        <activity
            android:name="com.facebook.CustomTabActivity"
            android:exported="true" />

        <activity
            android:name="com.facebook.CustomTabMainActivity" />

        <service
            android:name="com.google.android.gms.measurement.AppMeasurementService"
            android:enabled="true"
            android:exported="false" />

        <receiver
            android:name="com.google.android.gms.measurement.AppMeasurementReceiver"
            android:enabled="true"
            android:exported="false" />

        <receiver
            android:name="com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver"
            android:permission="android.permission.INSTALL_PACKAGES"
            android:enabled="true">

            <intent-filter>

                <action
                    android:name="com.android.vending.INSTALL_REFERRER" />
            </intent-filter>
        </receiver>

        <provider
            android:name="com.google.firebase.provider.FirebaseInitProvider"
            android:exported="false"
            android:authorities="com.quizjungle.android.firebaseinitprovider"
            android:initOrder="100" />

        <service
            android:name="com.google.firebase.iid.FirebaseInstanceIdService"
            android:exported="true">

            <intent-filter
                android:priority="-500">

                <action
                    android:name="com.google.firebase.INSTANCE_ID_EVENT" />
            </intent-filter>
        </service>

        <receiver
                android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver"
            android:permission="com.google.android.c2dm.permission.SEND"
            android:exported="true">

            <intent-filter>

                <action
                    android:name="com.google.android.c2dm.intent.RECEIVE" />

                <action
                    android:name="com.google.android.c2dm.intent.REGISTRATION" />

                <category
                    android:name="com.quizjungle.android" />
            </intent-filter>
        </receiver>

        <receiver
        android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver"
            android:exported="false" />

        <activity
            android:theme="@ref/0x01030011"
            android:name="com.unity.purchasing.googleplay.PurchaseActivity"
            android:configChanges="0x40000fff" />

        <activity
            android:theme="@ref/0x0103000f"
            android:name="com.google.android.gms.ads.AdActivity"
            android:configChanges="0xfb0" />

        <activity
            android:theme="@ref/0x7f080000"
        android:name="com.google.android.gms.ads.purchase.InAppPurchaseActivity" />

        <activity
            android:theme="@ref/0x01030010"
            android:name="com.google.android.gms.common.api.GoogleApiActivity"
            android:exported="false" />
    </application>

    <uses-permission
        android:name="android.permission.INTERNET" />

    <uses-permission
        android:name="android.permission.ACCESS_NETWORK_STATE" />

    <uses-permission
        android:name="android.permission.ACCESS_WIFI_STATE" />

    <uses-permission
        android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <uses-permission
        android:name="android.permission.android.permission.READ_PHONE_STATE" />

    <uses-permission
        android:name="android.permission.WAKE_LOCK" />

    <permission
        android:name="com.quizjungle.android.permission.C2D_MESSAGE"
        android:protectionLevel="0x2" />

    <uses-permission
        android:name="com.google.android.c2dm.permission.RECEIVE" />

    <uses-permission
        android:name="com.quizjungle.android.permission.C2D_MESSAGE" />

    <uses-permission
        android:name="com.android.vending.BILLING" />

    <uses-feature
        android:glEsVersion="0x20000" />

    <uses-feature
        android:name="android.hardware.touchscreen"
        android:required="false" />

    <uses-feature
        android:name="android.hardware.touchscreen.multitouch"
        android:required="false" />

    <uses-feature
        android:name="android.hardware.touchscreen.multitouch.distinct"
        android:required="false" />
</manifest>
</code>```

What should I do to run the APK?

* UPDATE *

I don't know if this helps. When I ran 'Analyze APK...', I got the following:

* Update 2 *
There is also a red exclamation sign next to my manifest in Android Studio which reads 'URI is not registered.', pointing to this line:

```<code>xmlns:android="http://schemas.android.com/apk/res/android"
</code>```

答:
Try adding this code to your Manifest:</p>

```<code><category android:name="android.intent.category.LAUNCHER" />
</code>```

Body:
I am new to Android Studio. I am using it now in the hope of obtaining some error messages that will explain why my APK couldn't be run in Blue Stacks. The APK was built in Unity.

After installing Android Studio, a phone emulator etc, I still couldn't run the APK. It said:

Error running app: Default Activity not found

There has been a post about this error in Stack Overflow. However, my AndroidManifest.xml looks fine to me. I have also tried 'Invalidate Caches / Restart' to no avail. When I went to Edit Configurations > Launch Options > Specified Activity, I could not see any activity for me to select.

Below is my AndroidManifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:theme="@ref/0x01030006"
    android:versionCode="91"
    android:versionName="91"
    android:installLocation="2"
    package="com.quizjungle.android"
    platformBuildVersionCode="25"
    platformBuildVersionName="7.1.1">

    <supports-screens
        android:anyDensity="true"
        android:smallScreens="true"
        android:normalScreens="true"
        android:largeScreens="true"
        android:xlargeScreens="true" />

    <uses-sdk
        android:minSdkVersion="15"
        android:targetSdkVersion="25" />

    <application
        android:label="@ref/0x7f060050"
        android:icon="@ref/0x7f02004c"
        android:debuggable="false"
        android:banner="@ref/0x7f02004b"
        android:isGame="true">

        <activity
            android:label="@ref/0x7f060050"
            android:name="com.unity3d.player.UnityPlayerNativeActivity"
            android:launchMode="2"
            android:screenOrientation="1"
            android:configChanges="0x40000fff">

            <intent-filter>

                <action
                    android:name="android.intent.action.MAIN" />

                <category
                    android:name="android.intent.category.LAUNCHER" />

                <category
                    android:name="android.intent.category.LEANBACK_LAUNCHER" />
            </intent-filter>

            <meta-data
                android:name="unityplayer.UnityActivity"
                android:value="true" />

            <meta-data
                android:name="unityplayer.ForwardNativeEventsToDalvik"
                android:value="true" />
        </activity>

        <activity
            android:theme="@ref/0x01030011"
            android:name="com.facebook.unity.FBUnityLoginActivity"
            android:configChanges="0x40000fff" />

        <activity
            android:theme="@ref/0x01030011"
            android:name="com.facebook.unity.FBUnityDialogsActivity"
            android:configChanges="0x40000fff" />

        <activity
            android:name="com.facebook.unity.FBUnityAppLinkActivity"
            android:exported="true" />

        <activity
            android:name="com.facebook.unity.FBUnityDeepLinkingActivity"
            android:exported="true" />

        <activity
            android:name="com.facebook.unity.FBUnityGameRequestActivity" />

        <activity
            android:name="com.facebook.unity.FBUnityCreateGameGroupActivity" />

        <activity
            android:name="com.facebook.unity.FBUnityJoinGameGroupActivity" />

        <activity
            android:name="com.facebook.unity.AppInviteDialogActivity" />

        <meta-data
            android:name="com.facebook.sdk.ApplicationId"
            android:value="1479999760.000000" />

        <provider
            android:name="com.facebook.FacebookContentProvider"
            android:exported="true"
            android:authorities="com.facebook.app.FacebookContentProvider365740347105248" />

        <activity
            android:theme="@ref/0x01030011"
            android:name="com.chartboost.sdk.CBImpressionActivity"
            android:excludeFromRecents="true"
            android:configChanges="0x4a0"
            android:hardwareAccelerated="true" />

        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@ref/0x7f050000" />

        <activity
            android:theme="@ref/0x7f08000f"
            android:name="com.facebook.FacebookActivity"
            android:configChanges="0x5b0" />

        <activity
            android:name="com.facebook.CustomTabActivity"
            android:exported="true" />

        <activity
            android:name="com.facebook.CustomTabMainActivity" />

        <service
            android:name="com.google.android.gms.measurement.AppMeasurementService"
            android:enabled="true"
            android:exported="false" />

        <receiver
            android:name="com.google.android.gms.measurement.AppMeasurementReceiver"
            android:enabled="true"
            android:exported="false" />

        <receiver
            android:name="com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver"
            android:permission="android.permission.INSTALL_PACKAGES"
            android:enabled="true">

            <intent-filter>

                <action
                    android:name="com.android.vending.INSTALL_REFERRER" />
            </intent-filter>
        </receiver>

        <provider
            android:name="com.google.firebase.provider.FirebaseInitProvider"
            android:exported="false"
            android:authorities="com.quizjungle.android.firebaseinitprovider"
            android:initOrder="100" />

        <service
            android:name="com.google.firebase.iid.FirebaseInstanceIdService"
            android:exported="true">

            <intent-filter
                android:priority="-500">

                <action
                    android:name="com.google.firebase.INSTANCE_ID_EVENT" />
            </intent-filter>
        </service>

        <receiver
                android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver"
            android:permission="com.google.android.c2dm.permission.SEND"
            android:exported="true">

            <intent-filter>

                <action
                    android:name="com.google.android.c2dm.intent.RECEIVE" />

                <action
                    android:name="com.google.android.c2dm.intent.REGISTRATION" />

                <category
                    android:name="com.quizjungle.android" />
            </intent-filter>
        </receiver>

        <receiver
        android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver"
            android:exported="false" />

        <activity
            android:theme="@ref/0x01030011"
            android:name="com.unity.purchasing.googleplay.PurchaseActivity"
            android:configChanges="0x40000fff" />

        <activity
            android:theme="@ref/0x0103000f"
            android:name="com.google.android.gms.ads.AdActivity"
            android:configChanges="0xfb0" />

        <activity
            android:theme="@ref/0x7f080000"
        android:name="com.google.android.gms.ads.purchase.InAppPurchaseActivity" />

        <activity
            android:theme="@ref/0x01030010"
            android:name="com.google.android.gms.common.api.GoogleApiActivity"
            android:exported="false" />
    </application>

    <uses-permission
        android:name="android.permission.INTERNET" />

    <uses-permission
        android:name="android.permission.ACCESS_NETWORK_STATE" />

    <uses-permission
        android:name="android.permission.ACCESS_WIFI_STATE" />

    <uses-permission
        android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <uses-permission
        android:name="android.permission.android.permission.READ_PHONE_STATE" />

    <uses-permission
        android:name="android.permission.WAKE_LOCK" />

    <permission
        android:name="com.quizjungle.android.permission.C2D_MESSAGE"
        android:protectionLevel="0x2" />

    <uses-permission
        android:name="com.google.android.c2dm.permission.RECEIVE" />

    <uses-permission
        android:name="com.quizjungle.android.permission.C2D_MESSAGE" />

    <uses-permission
        android:name="com.android.vending.BILLING" />

    <uses-feature
        android:glEsVersion="0x20000" />

    <uses-feature
        android:name="android.hardware.touchscreen"
        android:required="false" />

    <uses-feature
        android:name="android.hardware.touchscreen.multitouch"
        android:required="false" />

    <uses-feature
        android:name="android.hardware.touchscreen.multitouch.distinct"
        android:required="false" />
</manifest>

What should I do to run the APK?

* UPDATE *

I don't know if this helps. When I ran 'Analyze APK...', I got the following:

* Update 2 *
There is also a red exclamation sign next to my manifest in Android Studio which reads 'URI is not registered.', pointing to this line:

xmlns:android="http://schemas.android.com/apk/res/android"

Body:
Try adding this code to your Manifest:

<category android:name="android.intent.category.LAUNCHER" />


问:
Toggle Startpage and login form in a SPA (AngularJS)
I would like to define a startpage only with logo and two buttons (SignIn, LogIn). Only when the user click one of these buttons the registerform or loginform will displayed. The startpage has a toggleFunction as "sidebar" in angular material.

startpage:

form:

How can I achieve this with angularjs and angular material?

答: You can hide all the elements in the start up of the page except two buttons and once you click a button you should hide two buttons and show the specific form.Make sure to keep alignments correctly. You can use this documentation https://docs.angularjs.org/api/ng/directive/ngShow</p>


问:
Why does element[class=noquotes] work?
As per MDN attribute selector in css has the following syntax:

```<code>div[attr="actualValue"]
</code>```

Or like this example:

```<code><div class="test"></div>

div[class="test"]
</code>```

But I noticed that the quotes around the test are not needed as:

```<code>div[class=test]
</code>```

Example:

div[class=test] {
  background: #6ea7b2;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="test">I am a div</div></code>```

Why is this? Does w3c spec allow attribute selection without quotes around the value?

答:
From the specification:

Attribute values must be CSS identifiers or strings.

"test" is a string, which is fine.

test is an identifier, which is fine.

Title: Why does element[class=noquotes] work?

Body:
As per MDN attribute selector in css has the following syntax:

div[attr="actualValue"]

Or like this example:

div[class="test"]

But I noticed that the quotes around the test are not needed as:

div[class=test]

Example:

div[class=test] {
  background: #6ea7b2;
}

I am a div

Why is this? Does w3c spec allow attribute selection without quotes around the value?