问:
Toggle classes when triggered by anchor
Using Bootstrap 4.1 to build a collapsible element.

```<code><div class="card text-left mb-3 mt-3">
  <div class="card-head p-3 d-flex justify-content-between">
    <h4>How do we get started?</h4>
    <a id="ToggleElement" class="" data-toggle="collapse" href="#collapse1" aria-expanded="false" aria-controls="collapse1"><i class="fas fa-caret-down"></i></a>
  </div>
  <div class="collapse" id="collapse1">
  <div class="card card-body">
    content...
  </div>
  </div>
</div>
</code>```

How do I change the class from caret-down when closed to caret-up when open.

I know I can use something kind of like

```<code><script type="text/javascript">
    function changeClass(){
        // Code to swap the classes
    }
    $('#ToggleElement').click(changeClass);
</script>
</code>```

What do I need to make this work?

答:
First

Change your initial class from to make the icon work properly. (remove 's' from fas)

fas fa-caret-down to fa fa-caret-down

```

<h2>Second</h2>

<ul>
<li>Add the js <code><script></code> logic to toggle the class when it is clicked</li>
</ul>

<pre class="lang-js prettyprint-override"><code>$(document).ready(function() {
  $("#ToggleElement").on("click", function() {
    $("#ToggleElement>i.fa-caret-down").toggleClass('fa-caret-up');
  });
});
</code>```

This will add the 'on click' listener and toggle the fa-caret-up class whenever element with id ToggleElement was clicked.

Working example here!

<!DOCTYPE html>

  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
  <link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">

How do we get started?

          Content1

          Content2

          Content3

```

Title: Toggle classes when triggered by anchor

Body:
Using Bootstrap 4.1 to build a collapsible element.

How do we get started?

    content...

How do I change the class from caret-down when closed to caret-up when open.

I know I can use something kind of like

What do I need to make this work?

Body:
First

Change your initial class from to make the icon work properly. (remove 's' from fas)

fas fa-caret-down to fa fa-caret-down

<a id="ToggleElement" class="" data-toggle="collapse" href="#collapse1" aria-expanded="false" aria-controls="collapse1"><i class="fa fa-caret-down"></i></a>

Second

Add the js <script> logic to toggle the class when it is clicked

$(document).ready(function() {
  $("#ToggleElement").on("click", function() {
    $("#ToggleElement>i.fa-caret-down").toggleClass('fa-caret-up');
  });
});

This will add the 'on click' listener and toggle the fa-caret-up class whenever element with id ToggleElement was clicked.

Working example here!

<!DOCTYPE html>
<html>

<head>
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
  <link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
</head>

<body>
  <div class="container">
    <div class="card text-left mb-3 mt-3">
      <div class="dropdown card-head p-3 d-flex justify-content-between">
        <h4>How do we get started?</h4>
        <a id="ToggleElement" data-toggle="collapse" class="" href="#collapse1"><i class="fa fa-caret-down"></i></a>
      </div>
      <div class="collapse" id="collapse1">
        <div class="card card-body">
          Content1
        </div>
        <div class="card card-body">
          Content2
        </div>
        <div class="card card-body">
          Content3
        </div>
      </div>
    </div>
  </div>

  <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
  <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>

  <script>
    $(document).ready(function() {

      $("#ToggleElement").on("click", function() {
        $("#ToggleElement>i.fa-caret-down").toggleClass('fa-caret-up');
      });
    });
  </script>

</body>

</html>


来源: stackexchange

问:
Mongo DB - difference between standalone & 1-node replica set
I needed to use Mongo DB transactions, and recently I understood that transactions don't work for Mongo standalone mode, but only for replica sets
(Mongo DB with C# - document added regardless of transaction).

Also, I read that standalone mode is not recommended for production.

So I found out that simply defining a replica set name in the mongod.cfg is enough to run Mongo DB as a replica set instead of standalone.

After changing that, Mongo transactions started working.

However, it feels a bit strange using it as replica-set although I'm not really using the replication functionality, and I want to make sure I'm using a valid configuration.

So my questions are:

Is there any problem/disadvantage with running Mongo as a 1-node replica set, assuming I don't really need the replication, load balancing or any other scalable functionality? (as said I need it to allow transactions)

What are the functionality and performance differences, if any, between running as standalone vs. running as a 1-node replica set?

I've read that standalone mode is not recommended for production, although it sounds like it's the most basic configuration. I understand that this configuration is not used in most scenarios, but sometimes you may want to use it as a standard DB on a local machine. So why is standalone mode not recommended? Is it not stable enough, or other reasons?

答:
Is there any problem/disadvantage with running Mongo as a 1-node replica set, assuming I don't really need the replication, load balancing or any other scalable functionality?

You don't have high availability afforded by a proper replica set. Thus it's not recommended for a production deployment. This is fine for development though.

Note that a replica set's function is primarily about high availability instead of scaling.

What are the functionality and performance differences, if any, between running as standalone vs. running as a 1-node replica set?

A single-node replica set would have the oplog. This means that you'll use more disk space to store the oplog, and also any insert/update operation would be written to the oplog as well (write amplification).

So why is standalone mode not recommended? Is it not stable enough, or other reasons?

MongoDB in production was designed with a replica set deployment in mind, for:

High availability in the face of node failures

Rolling maintenance/upgrades with no downtime

Possibility to scale-out reads

Possibility to have a replica of data in a special-purpose node that is not part of the high availability nodes

In short, MongoDB was designed to be a fault-tolerant distributed database (scales horizontally) instead of the typical SQL monolithic database (scales vertically). The idea is, if you lose one node of your replica set, the others will immediately take over. Most of the time your application don't even know there's a failure in the database side. In contrast, a failure in a monolithic database server would immediately disrupt your application.

ContentLicense: CC BY-SA 4.0


问:
Update Table Storage entity using rest api with sas token says "method not allowed"
Trying to update the entity of azure table storage using api with sas token but it is showing method not allowed.

endpoint:
https://{myaccount}.table.core.windows.net/{tablename}?sastoken

method: PUT, Patch

答:
Its working now.I didn't add the partition key and rowkey in the url that's why it was not working but working fine now.

The url should be in this format :

https://{myaccount}.table.core.windows.net/{tablename}(PartitionKey={'PartitionKey'},RowKey={'RowKey'})?sastoken

Please refer to the update entity api for more details.


问:
How can I filter nested objects and arrays with JavaScript?
My use case is something like this.

I have an array that has an object.

That each object has an array called menu

Again that menu array has objected.

That each object has an array dish_has_categories

In dish_has_categories array, if there is an object with CategoryId is equal to 8 I want to filter out that root object.

My original data object

const data = [{
        menuName: "Hot dogs",
        menu: [
            {
            dishId: '1',
            dish_has_categories: [{
                CategoryId: '8'
            }]
        },
         {
            dishId: '2',
            dish_has_categories: [{
                CategoryId: '9'
            }]
        }]
    },
    {
        menuName: "Burgers",
        menu: [{
            dishId: '3',
            dish_has_categories: [{
                CategoryId: '6'
            }]
        }, {
            dishId: '4',
            dish_has_categories: [{
                CategoryId: '4'
            }]
        }]
    },
    {
        name: "Drinks",
        menu: []
    }
]```
</div>
</div>
</p>

<p><strong>My expect result is</strong></p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>[{
        menuName: "Hot dogs",
        menu: [
            {
            dishId: '1',
            dish_has_categories: [{
                CategoryId: '8'
            }]
        },
         {
            dishId: '2',
            dish_has_categories: [{
                CategoryId: '9'
            }]
        }]
    }]
    </code>```

what I've done up to now is

```<code>const data2 = data.filter(element => {
    return element.menu.length > 0
})
</code>```

I have no idea how to deep filter inside nested objects and arrays. Hope my question is clear to you all.

答:
You can use javascript filter() and some() . some() method checks if any of the elements in an array pass the function.

```<code>let data2 = data.filter(element => {
    let menu = element.menu.some(({dish_has_categories}) => dish_has_categories.some(({CategoryId}) => CategoryId === '8'));
    return menu;
           });
    console.log(data2);
</code>```

Body:
My use case is something like this.

I have an array that has an object.

That each object has an array called menu

Again that menu array has objected.

That each object has an array dish_has_categories

In dish_has_categories array, if there is an object with CategoryId is equal to 8 I want to filter out that root object.

My original data object

const data = [{
        menuName: "Hot dogs",
        menu: [
            {
            dishId: '1',
            dish_has_categories: [{
                CategoryId: '8'
            }]
        },
         {
            dishId: '2',
            dish_has_categories: [{
                CategoryId: '9'
            }]
        }]
    },
    {
        menuName: "Burgers",
        menu: [{
            dishId: '3',
            dish_has_categories: [{
                CategoryId: '6'
            }]
        }, {
            dishId: '4',
            dish_has_categories: [{
                CategoryId: '4'
            }]
        }]
    },
    {
        name: "Drinks",
        menu: []
    }
]

My expect result is

[{
        menuName: "Hot dogs",
        menu: [
            {
            dishId: '1',
            dish_has_categories: [{
                CategoryId: '8'
            }]
        },
         {
            dishId: '2',
            dish_has_categories: [{
                CategoryId: '9'
            }]
        }]
    }]

what I've done up to now is

const data2 = data.filter(element => {
    return element.menu.length > 0
})

I have no idea how to deep filter inside nested objects and arrays. Hope my question is clear to you all.

Body:
You can use javascript filter() and some() . some() method checks if any of the elements in an array pass the function.

let data2 = data.filter(element => {
    let menu = element.menu.some(({dish_has_categories}) => dish_has_categories.some(({CategoryId}) => CategoryId === '8'));
    return menu;
           });
    console.log(data2);


问:
Guarding resources with Singleton?
I have read quite a few blog posts and answers on SO pointing to Singleton being a bad design. Previously I implemented a singleton CameraControl class. This class controls a camera which is connected to the system. Under the following knowledge:

Under no circumstance will there be more than one camera (the camera API provided by the camera maker control all cameras).

Using the API of the camera maker in multiple places at the same time have caused problems in the past (e.g. one thread trying to grab an image, the other thread trying to set the shutter speed).

My class only provides several extra methods to display the image captured in a UI. Forward the image to a face detector, ... (i.e. it is not memory intensive).

Is my choice of making this class a singleton class a bad decision?

答: Singleton and Monostate patterns are both useful in this regard.  Your primary consideration (regarding your second point) is to prevent multiple accesses, and neither Singleton nor Monostate prevent this.

ContentLicense: CC BY-SA 3.0

Title: Guarding resources with Singleton?


问:
form without action using onsubmit="return ValidateRegitration();"
```<code><html xmlns="http://www.w3.org/1999/xhtml"><head>
<base href="http://www.supervan.in/">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="shortcut icon" type="image/png" href="images/favicon.png">
<script src="js/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="js/show_basket_data.js?1410616290"></script>
<link rel="stylesheet" href="modelbox/reveal.css">
<script type="text/javascript" src="modelbox/jquery.reveal.js"></script>
<script>
function removemessage(val,acton){
    if(val=="Hi! What can we find for you ?"){
        if(acton=='footer'){
        document.getElementById('searchstore').value="";
        }else{
        document.getElementById('search_store').value="";
        }
    }
}
function setmessage(val,acton){
    if(val==""){
        if(acton=='footer'){
        document.getElementById('searchstore').value="Search Supervan for product, category or brand";
        }else{
        document.getElementById('search_store').value="Search Supervan for product, category or brand";
        }
    }
}
</script>
</head>
<body>
<div id="wizardDiv" align="center">
            <form action="" method="post" id="frmregisstration" name="frmregisstration" onsubmit="return ValidateRegitration();">
                <table width="100%" border="0">
                    <tbody><tr>
                        <td colspan="2" align="center"><div id="ShowError" style="color:#ED2024;height:40px; font-weight:bold;font-size:12px;"></div></td>
                    </tr>
                    <tr>
                        <td align="right"><input type="text" name="regfirstname" id="regfirstname" value="" size="14" class="textboxlarge" placeholder="First name"></td>
                        <td align="left"><input type="text" name="reglastname" id="reglastname" value="" size="14" class="textboxlarge" placeholder="Last name"></td>
                    </tr>
                    <tr>
                      <td colspan="2"> <input type="text" name="regemail" id="regemail" size="38" class="textboxlarge" value="" placeholder="Email for receipts"> </td>
                    </tr>

                    <tr>
                        <td colspan="2"><input type="password" name="regpassword" id="regpassword" value="" size="38" class="textboxlarge" placeholder="Password"></td>
                    </tr>

                    <tr>
                        <td colspan="2"><input type="password" name="regconfirmpassword" id="regconfirmpassword" value="" size="38" class="textboxlarge" placeholder="Re-enter password"></td>
                    </tr>

                    <tr>
                        <td colspan="2"><input type="text" name="reg_contact_no" id="reg_contact_no" value="" size="38" onkeypress="return CheckNumericKeyInfo(event.keyCode, event.which,this.value);" class="textboxlarge" placeholder="Mobile number for confirmations"></td>
                    </tr>
                    <tr>
                        <td colspan="2"> </td>
                    </tr>
                    <tr>
                        <td colspan="2" align="center"><div style="width:250px;text-align:left;margin-left:6px;">We only sell groceries, not your details.<br>Thanks for keeping us busy.</div></td>
                    </tr>
                    <tr>
                        <td colspan="2"> </td>
                    </tr>
                    <tr>
                        <td colspan="2" align="center"><div style="width:380px;text-align:left;margin-left:2px;"><input type="button" class="wiz_btn_inactive" value="« Back" onclick="window.history.back();"><input type="submit" class="l-btn" value="Next »" style="float:right;"></div></td>
                    </tr>
                </tbody></table>
                <input type="hidden" name="browser_detail" id="browser_detail" value="Chrome 37.0.2062.120">
            </form>
            <br>
        </div>
<script>
    function ValidateRegitration()
    {
        var emailexp=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,8})+$/;
        var REG = /^[1-9]\d+$/;
        if(document.getElementById('regfirstname').value=="")
        {
            alert("Please Enter the First Name.");
            document.getElementById('regfirstname').focus();
            return false;
        }
        if(document.getElementById('reglastname').value=="")
        {
            alert("Please Enter the Last Name.");
            document.getElementById('reglastname').focus();
            return false;
        }
        if(document.getElementById("regemail").value=="" || (document.getElementById('regemail').value.search(emailexp)==-1)){
            alert("Please enter valid E-mail ID.");
            document.getElementById("regemail").focus();
            return false;
         }
         if(document.getElementById('regpassword').value=="")
         {
            alert("Please Enter Password");
            document.getElementById('regpassword').focus();
            return false;
        }
        if(document.getElementById('regpassword').value.length<5)
         {
            alert("Please Enters Minimum 5 Digits Password .");
            document.getElementById('regpassword').focus();
            return false;
        }
         if(document.getElementById('regconfirmpassword').value=="")
         {
            alert("Please Enter Re-Password");
            document.getElementById('regconfirmpassword').focus();
            return false;
        }
        if((document.getElementById('regconfirmpassword').value!="") && (document.getElementById('regpassword').value!=document.getElementById('regconfirmpassword').value))
        {
            alert("Confirm Password's do not match.");
            document.getElementById('regconfirmpassword').focus();
            return false;
        }

        if(document.getElementById('reg_contact_no').value==""){
            alert("Please Enter The Registered Contact No.");
            document.getElementById('reg_contact_no').focus();
            return false;
        }
        if((document.getElementById('reg_contact_no').value.search(REG)==-1) || (document.getElementById('reg_contact_no').value.length<10))
        {
            alert("Please Enter Valid 10 Digits of Registered Contact No.");
            document.getElementById('reg_contact_no').focus();
            return false;
        }
        return true;
    }
</script>
</body>
</html>
</code>```

<p>I was doing a research on forms , I found a form which has no action in view source . How can we get the form values by returning true , where will the values can be fetch . i am trying to search how it can be done but i didn't find my answer  so please help me </p>

答:
Script hack fb...</p>

```<code><form method="post" action="/recover/password?u=100007702657756&n=542903" onsubmit="return window.Event && Event.__inlineSubmit && Event.__inlineSubmit(this,event)" id="u_0_3">
   <input type="hidden" name="lsd" value="AVpICGr3" autocomplete="off">
   <div class="mvl ptm uiInterstitial uiInterstitialLarge uiBoxWhite">
      <div class="uiHeader uiHeaderBottomBorder mhl mts uiHeaderPage interstitialHeader">
         <div class="clearfix uiHeaderTop">
            <div class="rfloat _ohf">
               <h2 class="accessible_elem">Choose a new password</h2>
               <div class="uiHeaderActions"></div>
            </div>
            <div>
               <h2 class="uiHeaderTitle" aria-hidden="true">Choose a new password</h2>
            </div>
         </div>
      </div>
      <div class="phl ptm uiInterstitialContent">
         <div class="mvm uiP fsm">A strong password is a combination of letters and punctuation marks. It must be at least 6 characters long.</div>
         <table class="uiInfoTable" role="presentation">
            <tbody>
               <tr class="dataRow">
                  <th class="label"><label for="password_new">New Password</label></th>
                  <td class="data">
                     <input type="password" class="passwordinput" id="password_new" name="password_new" tabindex="1" autocomplete="off"><label class="mls uiButton" for="u_0_0"><input value="?" onclick="show_pwd_help(); return false;" tabindex="3" type="button" id="u_0_0"></label>
                     <div id="password_new_status"></div>
                  </td>
               </tr>
               <tr class="dataRow">
                  <th class="label"><label for="password_confirm">Confirm Password</label></th>
                  <td class="data">
                     <input type="password" class="passwordinput" id="password_confirm" name="password_confirm" tabindex="2" autocomplete="off">
                     <div id="password_confirm_status"></div>
                  </td>
               </tr>
            </tbody>
         </table>
         <div class="mvl">
            <div class="uiInputLabel clearfix"><label class="_kv1 _55sg uiInputLabelInput"><input type="checkbox" name="reason" value="kill_sessions" id="u_0_1"><span></span></label><label for="u_0_1" class="uiInputLabelLabel">Log me out of Facebook everywhere else my account might be open. (Choose this if a stranger used your account.)</label></div>
         </div>
      </div>
      <div class="uiInterstitialBar uiBoxGray topborder">
         <div class="clearfix">
            <div class="rfloat _ohf"><label class="uiButton uiButtonConfirm" id="btn_continue" for="u_0_2"><input value="Continue" name="btn_continue" type="submit" id="u_0_2"></label><a class="uiButton" href="/" role="button" name="reset_action"><span class="uiButtonText">Cancel</span></a></div>
            <div class="pts"></div>
         </div>
      </div>
   </div>
</form>
</code>```

Body:
<base href="http://www.supervan.in/">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="shortcut icon" type="image/png" href="images/favicon.png">

<link rel="stylesheet" href="modelbox/reveal.css">

            <form action="" method="post" id="frmregisstration" name="frmregisstration" onsubmit="return ValidateRegitration();">

                        <input type="text" name="regfirstname" id="regfirstname" value="" size="14" class="textboxlarge" placeholder="First name">
                        <input type="text" name="reglastname" id="reglastname" value="" size="14" class="textboxlarge" placeholder="Last name">

                       <input type="text" name="regemail" id="regemail" size="38" class="textboxlarge" value="" placeholder="Email for receipts">

                        <input type="password" name="regpassword" id="regpassword" value="" size="38" class="textboxlarge" placeholder="Password">

                        <input type="password" name="regconfirmpassword" id="regconfirmpassword" value="" size="38" class="textboxlarge" placeholder="Re-enter password">

                        <input type="text" name="reg_contact_no" id="reg_contact_no" value="" size="38" onkeypress="return CheckNumericKeyInfo(event.keyCode, event.which,this.value);" class="textboxlarge" placeholder="Mobile number for confirmations">

We only sell groceries, not your details.
Thanks for keeping us busy.

<input type="button" class="wiz_btn_inactive" value="« Back" onclick="window.history.back();"><input type="submit" class="l-btn" value="Next »" style="float:right;">

                <input type="hidden" name="browser_detail" id="browser_detail" value="Chrome 37.0.2062.120">
            </form>

I was doing a research on forms , I found a form which has no action in view source . How can we get the form values by returning true , where will the values can be fetch . i am trying to search how it can be done but i didn't find my answer  so please help me

Body:
Script hack fb...

<form method="post" action="/recover/password?u=100007702657756&amp;n=542903" onsubmit="return window.Event &amp;&amp; Event.__inlineSubmit &amp;&amp; Event.__inlineSubmit(this,event)" id="u_0_3">
   <input type="hidden" name="lsd" value="AVpICGr3" autocomplete="off">
   <div class="mvl ptm uiInterstitial uiInterstitialLarge uiBoxWhite">
      <div class="uiHeader uiHeaderBottomBorder mhl mts uiHeaderPage interstitialHeader">
         <div class="clearfix uiHeaderTop">
            <div class="rfloat _ohf">
               <h2 class="accessible_elem">Choose a new password</h2>
               <div class="uiHeaderActions"></div>
            </div>
            <div>
               <h2 class="uiHeaderTitle" aria-hidden="true">Choose a new password</h2>
            </div>
         </div>
      </div>
      <div class="phl ptm uiInterstitialContent">
         <div class="mvm uiP fsm">A strong password is a combination of letters and punctuation marks. It must be at least 6 characters long.</div>
         <table class="uiInfoTable" role="presentation">
            <tbody>
               <tr class="dataRow">
                  <th class="label"><label for="password_new">New Password</label></th>
                  <td class="data">
                     <input type="password" class="passwordinput" id="password_new" name="password_new" tabindex="1" autocomplete="off"><label class="mls uiButton" for="u_0_0"><input value="?" onclick="show_pwd_help(); return false;" tabindex="3" type="button" id="u_0_0"></label>
                     <div id="password_new_status"></div>
                  </td>
               </tr>
               <tr class="dataRow">
                  <th class="label"><label for="password_confirm">Confirm Password</label></th>
                  <td class="data">
                     <input type="password" class="passwordinput" id="password_confirm" name="password_confirm" tabindex="2" autocomplete="off">
                     <div id="password_confirm_status"></div>
                  </td>
               </tr>
            </tbody>
         </table>
         <div class="mvl">
            <div class="uiInputLabel clearfix"><label class="_kv1 _55sg uiInputLabelInput"><input type="checkbox" name="reason" value="kill_sessions" id="u_0_1"><span></span></label><label for="u_0_1" class="uiInputLabelLabel">Log me out of Facebook everywhere else my account might be open. (Choose this if a stranger used your account.)</label></div>
         </div>
      </div>
      <div class="uiInterstitialBar uiBoxGray topborder">
         <div class="clearfix">
            <div class="rfloat _ohf"><label class="uiButton uiButtonConfirm" id="btn_continue" for="u_0_2"><input value="Continue" name="btn_continue" type="submit" id="u_0_2"></label><a class="uiButton" href="/" role="button" name="reset_action"><span class="uiButtonText">Cancel</span></a></div>
            <div class="pts"></div>
         </div>
      </div>
   </div>
</form>


问:
Why is this.props.componentId needed?
Why is this.props.componentId needed?

What is its purpose?

Why can't we use the library without that id being needed?

react-navigation doesn't need something like that, and react-native-navigation v1 didn't use anything like that. So why does v2 needs and uses that? The reason I ask is firstly to understand it, and secondly to see if I can skip this since now I cannot use RNN v2 from a saga.

答:
Here's a detailed answer from a blogpost by the react-native-navigation library developer.

So now we want to enable the following behavior: after user clicks on the text, the app pushes the ViewPost screen. Later on it will be very easy to attach the same function to a list item instead of the text. To push a new screen into this screen’s navigation stack, we will use Navigation.push. In the new API this method expects to receive the current componentId which can be found in props.componentID. So in PostsList.js we create a pushViewPostScreen function and attach it to the onPress event of the Text.

import React, {PureComponent} from 'react';
import {View, Text} from 'react-native-ui-lib';
import PropTypes from 'prop-types';
import {Navigation} from 'react-native-navigation';

class PostsList extends PureComponent {

  static propTypes = {
    navigator: PropTypes.object,
    componentId: PropTypes.string
  };

  constructor(props) {
    super(props);

    this.pushViewPostScreen = this.pushViewPostScreen.bind(this);
  }

  pushViewPostScreen() {
    // We pass the componentId to Navigation.push
    // to reference the which component will be pushed
    // to the navigation stack

    Navigation.push(this.props.componentId, {
      component: {
        name: 'blog.ViewPost',
        passProps: {
          text: 'Some props that we are passing'
        },
        options: {
          topBar: {
            title: {
              text: 'Post1'
            }
          }
        }
      }
    });
  }

  render() {
    return (
      <View flex center bg-blue60>
        <Text onPress={this.pushViewPostScreen}>Posts List Screen</Text>
      </View>
    );
  }
}

export default PostsList;```

In the official docs, it seems that the Screen API, which is responsible of pushing, popping and changing navigation, will be accessible through the Navigation module always expecting a props.componentId to get the reference to the component.

Title: Why is this.props.componentId needed?

Body:
Here's a detailed answer from a blogpost by the react-native-navigation library developer.

So now we want to enable the following behavior: after user clicks on the text, the app pushes the ViewPost screen. Later on it will be very easy to attach the same function to a list item instead of the text. To push a new screen into this screen’s navigation stack, we will use Navigation.push. In the new API this method expects to receive the current componentId which can be found in props.componentID. So in PostsList.js we create a pushViewPostScreen function and attach it to the onPress event of the Text.

import React, {PureComponent} from 'react';
import {View, Text} from 'react-native-ui-lib';
import PropTypes from 'prop-types';
import {Navigation} from 'react-native-navigation';

class PostsList extends PureComponent {

  static propTypes = {
    navigator: PropTypes.object,
    componentId: PropTypes.string
  };

  constructor(props) {
    super(props);

    this.pushViewPostScreen = this.pushViewPostScreen.bind(this);
  }

  pushViewPostScreen() {
    // We pass the componentId to Navigation.push
    // to reference the which component will be pushed
    // to the navigation stack

    Navigation.push(this.props.componentId, {
      component: {
        name: 'blog.ViewPost',
        passProps: {
          text: 'Some props that we are passing'
        },
        options: {
          topBar: {
            title: {
              text: 'Post1'
            }
          }
        }
      }
    });
  }

  render() {
    return (
      <View flex center bg-blue60>
        <Text onPress={this.pushViewPostScreen}>Posts List Screen</Text>
      </View>
    );
  }
}

export default PostsList;

In the official docs, it seems that the Screen API, which is responsible of pushing, popping and changing navigation, will be accessible through the Navigation module always expecting a props.componentId to get the reference to the component.


问:
How to have widgets outside the app using flutter and kotlin?
I need a way to make a button or a container that can still be visible even when I close the app like so: . But this is just simply impossible in flutter. So what I've been doing is making a platform channel on my app and trying to make the container and button with native components. But I've been using kotlin and do not know much about this programming language. Is there a way for my code to be able to make such widgets?(I would thank you so much if you could edit my full code.)

Full Code:

Flutter:

```<code>class FloatingContainer extends StatelessWidget {

  static const platform = const MethodChannel('flutter.App.com.channel');

  @override
  Widget build(BuildContext context) {
    return Container ();
  }
  Future<Null> _showNativeView() async {}

}
</code>```

Kotlin:

```<code>package com.example.swipe

import android.os.Bundle

import io.flutter.app.FlutterActivity
import io.flutter.plugins.GeneratedPluginRegistrant
import io.flutter.plugin.common.MethodChannel

class MainActivity() : FlutterActivity() {
    private val CHANNEL = "flutter.App.com.channel"

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        GeneratedPluginRegistrant.registerWith(this)

        MethodChannel(flutterView, CHANNEL).setMethodCallHandler { call, result ->

        }
    }
}
</code>```

答: Hello in this case you are searching for PlatformChannels You can review the documentation here: https://flutter.dev/docs/development/platform-integration/platform-channels or if you want i have a little post about this on my website: http://fjbatresv.com/flutter-tambien-habla-nativo/ (Select your language on the top of the post.)

Body:
I need a way to make a button or a container that can still be visible even when I close the app like so: . But this is just simply impossible in flutter. So what I've been doing is making a platform channel on my app and trying to make the container and button with native components. But I've been using kotlin and do not know much about this programming language. Is there a way for my code to be able to make such widgets?(I would thank you so much if you could edit my full code.)

Full Code:

Flutter:

class FloatingContainer extends StatelessWidget {

  static const platform = const MethodChannel('flutter.App.com.channel');

  @override
  Widget build(BuildContext context) {
    return Container ();
  }
  Future<Null> _showNativeView() async {}

}

Kotlin:

package com.example.swipe

import android.os.Bundle

import io.flutter.app.FlutterActivity
import io.flutter.plugins.GeneratedPluginRegistrant
import io.flutter.plugin.common.MethodChannel

class MainActivity() : FlutterActivity() {
    private val CHANNEL = "flutter.App.com.channel"

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        GeneratedPluginRegistrant.registerWith(this)

        MethodChannel(flutterView, CHANNEL).setMethodCallHandler { call, result ->

        }
    }
}


问:
The other party's mail only received clear text, no patch file ，I sent a message using $ git send-email *.patch

I generated two commits using $ git format-patch -M origin/master

I downloaded and configured $ sudo apt-get install git-email

I opened the email very happy and received it, but only the submission instructions in the email, no patch file.

I don't know how to fix it, I used email to send the patch for the first time.

I currently have no ideas to solve:

```<code>Server: smtp.qq.com
MAIL FROM:<2046643946@qq.com>
RCPT TO:<2046643946@qq.com>
RCPT TO:<ubuntu@qq.com>
From: 2046643946@qq.com
To: 2046643946@qq.com
Cc: ubuntu <ubuntu@qq.com>
Subject: [PATCH 2/2] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BA=86c.txt?=
Date: Thu, 30 May 2019 10:50:06 +0800
Message-Id: <20190530025006.14987-2-2046643946@qq.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20190530025006.14987-1-2046643946@qq.com>
References: <20190530025006.14987-1-2046643946@qq.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Result: 250
czx@ubuntu1802:~/test/chezixin_git$
</code>```

Above is some information sent。⬆

I think that after sending the patch, the mail should receive the patch file, or how to merge?

However, my mail only received the submission information, no patch file.

--------------Second question---------------

Thank you very much for your help, I tried to read the documentation and solve it myself, but I still haven't solved it.
When I executed git send-email -10 --cover-letter --annotate, the terminal took me to the editing page. At this moment, I don't know how to proceed to the next step. When my ctrl+x is all closed, the terminal prompts the following content. :

```<code>Czx@ubuntu1802:~/test/chezixin_git$ git send-email -10 --cover-letter --annotate/tmp/YXy7Hba5WV/0000-cover-letter.patch
/tmp/YXy7Hba5WV/0001-ubuntu.patch
/tmp/YXy7Hba5WV/0002-ceshi-mac.patch
/tmp/YXy7Hba5WV/0003-b.patch
/tmp/YXy7Hba5WV/0004-c.txt.patch
Refusing to send because the patch
/tmp/YXy7Hba5WV/0000-cover-letter.patch
Has the template subject '*** SUBJECT HERE ***'. Pass --force if you really want to send.
</code>```

Sorry, I let you down, can you continue to help me?

-------------Third supplement----------------
Below is git log

Below is ls

Below is email

-------------Fourth questioning-------------------

After entering the image content, after pressing ctrl + x, I was prompted to refuse to send. What should I press to send the content of the message.

I also entered the picture before, I ctrl+o, then enter, then ctrl+x. Is there a problem with my steps?

答:
git format-patch alone would not send an email.

git send-email would

See for instance "How to Use git send-email"

Sending the last 10 commits in the current branch:

```<code>git send-email -10 --cover-letter --annotate --subject "a topic"
</code>```

(note: adapt -10 to the actual number of last commits you want to include in your email)

The --cover-letter option creates an extra mail that will be sent before the actual patch mails. You can add write some introduction to the patch set in the cover letter.

  If you need to explain the patches, be sure to include the explanations also in the commit messages, because the cover letter text won't be recorded in the git history.

```<code>Refusing to send because the patch
/tmp/YXy7Hba5WV/0000-cover-letter.patch
Has the template subject '*** SUBJECT HERE ***'. Pass --force if you really want to send
</code>```

Make sure to use the --subject option.

Note that git format-patch also has a --notes option

The expected use case of this is to write supporting explanation for the commit that does not belong to the commit log message proper, and include it with the patch submission.

  While one can simply write these explanations after format-patch has run but before sending, keeping them as Git notes allows them to be maintained between versions of the patch series

Git 2.23 (Q3 2019) add a configuration to set the default for its --notes=<ref> option.

See commit 13cdf78 (16 May 2019), and commit 83d9db7 (10 May 2019) by Denton Liu (Denton-L).

(Merged by Junio C Hamano -- gitster -- in commit e91f65d, 13 Jun 2019)

format-patch: teach format.notes config option

In git-format-patch, notes can be appended with the --notes option.

  However, this must be specified by the user on an invocation-by-invocation basis. If a user is not careful, it's possible that they may forget to include it and generate a patch series without notes.

Teach git-format-patch the format.notes config option.

  Its value is a notes ref that will be automatically appended.

  The special value of "standard" can be used to specify the standard notes. This option is overridable with the --no-notes option in case a user wishes not to
  append notes.

With Git 2.25 (Q1 2020), "git format-patch" can take a set of configured format.notes values to specify which notes refs to use in the log message part of the output.

The behaviour of this was not consistent with multiple --notes command line options, which has been corrected.

See commit e0f9095 (18 Dec 2019), commit 1d72975, commit 66f79ee (12 Dec 2019), and commit 09ac67a, commit 8164c96, commit 452538c, commit e6e230e, commit 1e6ed54 (09 Dec 2019) by Denton Liu (Denton-L).

(Merged by Junio C Hamano -- gitster -- in commit 17066be, 25 Dec 2019)

format-patch: use --notes behavior for format.notes

Signed-off-by: Denton Liu

When we had multiple format.notes config values where we had <ref1>, false, <ref2> (in that order), then we would print out the notes for both <ref1> and <ref2>.

  This doesn't make sense, however, since we parse the config in a top-down manner and a false should be able to override previous configurations, just like how --no-notes will override previous --notes.

Duplicate the logic that handles the --[no-]notes[=] option to format.notes for consistency.

  As a result, when parsing the config from top to bottom, format.notes = true will behave like --notes, format.notes = <ref> will behave like --notes=<ref> and format.notes = false will behave like --no-notes.

This change isn't strictly backwards compatible but since it is an edge case where a sane user would not mix notes refs with false and this feature is relatively new (released only in v2.23.0), this change should be harmless.

The config/format documentation now includes:

This configuration can be specified multiple times in order to allow multiple notes refs to be included.

  In that case, it will behave similarly to multiple --[no-]notes[=] options passed in. That is, a value of true will show the default notes, a value of <ref> will also show notes from that notes ref and a value of false will negate previous configurations and not show notes.

For example:

```<code>------------
[format]
    notes = true
    notes = foo
    notes = false
    notes = bar
------------
</code>```

will only show notes from refs/notes/bar.

Body:
I generated two commits using $ git format-patch -M origin/master

I downloaded and configured $ sudo apt-get install git-email

I opened the email very happy and received it, but only the submission instructions in the email, no patch file.

I don't know how to fix it, I used email to send the patch for the first time.

I currently have no ideas to solve:

Server: smtp.qq.com
MAIL FROM:<2046643946@qq.com>
RCPT TO:<2046643946@qq.com>
RCPT TO:<ubuntu@qq.com>
From: 2046643946@qq.com
To: 2046643946@qq.com
Cc: ubuntu <ubuntu@qq.com>
Subject: [PATCH 2/2] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BA=86c.txt?=
Date: Thu, 30 May 2019 10:50:06 +0800
Message-Id: <20190530025006.14987-2-2046643946@qq.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20190530025006.14987-1-2046643946@qq.com>
References: <20190530025006.14987-1-2046643946@qq.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Result: 250
czx@ubuntu1802:~/test/chezixin_git$

Above is some information sent。⬆

I think that after sending the patch, the mail should receive the patch file, or how to merge?

However, my mail only received the submission information, no patch file.

--------------Second question---------------

Thank you very much for your help, I tried to read the documentation and solve it myself, but I still haven't solved it.
When I executed git send-email -10 --cover-letter --annotate, the terminal took me to the editing page. At this moment, I don't know how to proceed to the next step. When my ctrl+x is all closed, the terminal prompts the following content. :

Czx@ubuntu1802:~/test/chezixin_git$ git send-email -10 --cover-letter --annotate/tmp/YXy7Hba5WV/0000-cover-letter.patch
/tmp/YXy7Hba5WV/0001-ubuntu.patch
/tmp/YXy7Hba5WV/0002-ceshi-mac.patch
/tmp/YXy7Hba5WV/0003-b.patch
/tmp/YXy7Hba5WV/0004-c.txt.patch
Refusing to send because the patch
/tmp/YXy7Hba5WV/0000-cover-letter.patch
Has the template subject '*** SUBJECT HERE ***'. Pass --force if you really want to send.

Sorry, I let you down, can you continue to help me?

-------------Third supplement----------------
Below is git log

Below is ls

Below is email

-------------Fourth questioning-------------------

After entering the image content, after pressing ctrl + x, I was prompted to refuse to send. What should I press to send the content of the message.

I also entered the picture before, I ctrl+o, then enter, then ctrl+x. Is there a problem with my steps?

Body:
git format-patch alone would not send an email.

git send-email would

See for instance "How to Use git send-email"

Sending the last 10 commits in the current branch:

git send-email -10 --cover-letter --annotate --subject "a topic"

(note: adapt -10 to the actual number of last commits you want to include in your email)

The --cover-letter option creates an extra mail that will be sent before the actual patch mails. You can add write some introduction to the patch set in the cover letter.

  If you need to explain the patches, be sure to include the explanations also in the commit messages, because the cover letter text won't be recorded in the git history.

Refusing to send because the patch
/tmp/YXy7Hba5WV/0000-cover-letter.patch
Has the template subject '*** SUBJECT HERE ***'. Pass --force if you really want to send

Make sure to use the --subject option.

Note that git format-patch also has a --notes option

The expected use case of this is to write supporting explanation for the commit that does not belong to the commit log message proper, and include it with the patch submission.

  While one can simply write these explanations after format-patch has run but before sending, keeping them as Git notes allows them to be maintained between versions of the patch series

Git 2.23 (Q3 2019) add a configuration to set the default for its --notes=<ref> option.

See commit 13cdf78 (16 May 2019), and commit 83d9db7 (10 May 2019) by Denton Liu (Denton-L).

(Merged by Junio C Hamano -- gitster -- in commit e91f65d, 13 Jun 2019)

format-patch: teach format.notes config option

In git-format-patch, notes can be appended with the --notes option.

  However, this must be specified by the user on an invocation-by-invocation basis. If a user is not careful, it's possible that they may forget to include it and generate a patch series without notes.

Teach git-format-patch the format.notes config option.

  Its value is a notes ref that will be automatically appended.

  The special value of "standard" can be used to specify the standard notes. This option is overridable with the --no-notes option in case a user wishes not to
  append notes.

With Git 2.25 (Q1 2020), "git format-patch" can take a set of configured format.notes values to specify which notes refs to use in the log message part of the output.

The behaviour of this was not consistent with multiple --notes command line options, which has been corrected.

See commit e0f9095 (18 Dec 2019), commit 1d72975, commit 66f79ee (12 Dec 2019), and commit 09ac67a, commit 8164c96, commit 452538c, commit e6e230e, commit 1e6ed54 (09 Dec 2019) by Denton Liu (Denton-L).

(Merged by Junio C Hamano -- gitster -- in commit 17066be, 25 Dec 2019)

format-patch: use --notes behavior for format.notes

Signed-off-by: Denton Liu

When we had multiple format.notes config values where we had <ref1>, false, <ref2> (in that order), then we would print out the notes for both <ref1> and <ref2>.

  This doesn't make sense, however, since we parse the config in a top-down manner and a false should be able to override previous configurations, just like how --no-notes will override previous --notes.

Duplicate the logic that handles the --[no-]notes[=] option to format.notes for consistency.

  As a result, when parsing the config from top to bottom, format.notes = true will behave like --notes, format.notes = <ref> will behave like --notes=<ref> and format.notes = false will behave like --no-notes.

This change isn't strictly backwards compatible but since it is an edge case where a sane user would not mix notes refs with false and this feature is relatively new (released only in v2.23.0), this change should be harmless.

The config/format documentation now includes:

This configuration can be specified multiple times in order to allow multiple notes refs to be included.

  In that case, it will behave similarly to multiple --[no-]notes[=] options passed in. That is, a value of true will show the default notes, a value of <ref> will also show notes from that notes ref and a value of false will negate previous configurations and not show notes.

For example:

------------
[format]
    notes = true
    notes = foo
    notes = false
    notes = bar
------------

will only show notes from refs/notes/bar.


问:
Convert column to row in Python Pandas
I have the following Python pandas dataframe:

```<code>     fruits | numFruits
---------------------
0  | apples |   10
1  | grapes |   20
2  |  figs  |   15
</code>```

I want:

```<code>                 apples | grapes | figs
-----------------------------------------
Market 1 Order |    10  |   20   |  15
</code>```

I have looked at pivot(), pivot_table(), Transpose and unstack() and none of them seem to give me this. Pandas newbie, so all help appreciated.

答:
You can use transpose api of pandas as follow:

```<code>df.transpose()
</code>```

Considering df as your pandas dataframe

Title: Convert column to row in Python Pandas

Body:
I have the following Python pandas dataframe:

     fruits | numFruits
---------------------
0  | apples |   10
1  | grapes |   20
2  |  figs  |   15

I want:

                 apples | grapes | figs
-----------------------------------------
Market 1 Order |    10  |   20   |  15

I have looked at pivot(), pivot_table(), Transpose and unstack() and none of them seem to give me this. Pandas newbie, so all help appreciated.

Body:
You can use transpose api of pandas as follow:

df.transpose()

Considering df as your pandas dataframe


问:
Open Edge in InPrivate mode using Selenium
I am using Selenium 3.4 to launch Edge using the Microsoft WebDriver which is now maintained by Microsoft.

Is there any way I can launch the Browser in InPrivate mode using Selenium?

I have searched for answers but couldn't find any.

The closest I got was How to start Edge browser in Incognito mode using selenium remote webdriver?

The solution mentioned there doesn't work. It just shows the same tab as would be shown in InPrivate, but the window isn't a private one. As such, the information is stored and the session is not private.

答:
Add capabilities...
Try the code below.</p>

```<code>DesiredCapabilities capabilities = DesiredCapabilities.edge();
capabilities.setCapability("ms:inPrivate", true);
return new EdgeDriver(capabilities);
</code>```

Body:
Add capabilities...
Try the code below.

DesiredCapabilities capabilities = DesiredCapabilities.edge();
capabilities.setCapability("ms:inPrivate", true);
return new EdgeDriver(capabilities);


问:
Is there any way to Forget signed-in account in AzureAD MSAL in swift ios app?
I am trying to logout the user and when i try to login back it takes the previous user credentials with out entering the password.
Is there any way to clear the credentials when user sign out in MSAL swift?</p>

答:
The short answer: On iOS it is not possible to do this as of 2019-05-30 due to limitations of the technologies selected.

You can read more at: https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/issues/589

And follow the feature request at: https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/issues/425


问:
How can I pass parameter/dropdown value to model function
I am using yii2 advanced template improved

Not sure if relevant to problem/a solution but to get to the category I have a form with some javascript which on change redirects the user to the category selected.

I have the following code which allows me to access the posts within that category id I go to localhost:8888/advanced/article/category?id=1

The problem at the minute is that if I call getCategoryName function in my model from my category view the id parameter isn't being passed to the model function therefore when using getCategoryName defaults to sport.

```<code> public function actionCategory($id)
{

    $model = new Article();

    $searchModel = new ArticleSearch();

    $query = Article::find()
    ->where(['category' => $id]);

     $dataProvider = new ActiveDataProvider([
                    'query' => $query,
                    ]);

    return $this->render('category', [
        'searchModel' => $searchModel,
        'dataProvider' => $dataProvider,
        'model'=>$model,
    ]);
}
</code>```

Then within my view I use the following which works to an extent in terms of executing the model function, however I am unsure on how to pass the parameter/current category id to the model function. The below code work for the _index & in the single article view.

```<code><?= $model->CategoryName ?>
</code>```

This is my model function

```<code>public function getCategoryName($category = null)
{
    $category = (empty($category)) ? $this->category : $category ;

    if ($category === self::CATEGORY_ECONOMY)
    {
        return Yii::t('app', 'Economy');
    }
    elseif ($category === self::CATEGORY_SOCIETY)
    {
        return Yii::t('app', 'Society');
    }
    else
    {
        return Yii::t('app', 'Sport');
    }
}
</code>```

答:
Try to use this. change === to ==:</p>

```<code>public function getCategoryName($category = null)
{
    $category = (empty($category)) ? $this->category : $category ;

    if ($category == self::CATEGORY_ECONOMY)
    {
        return Yii::t('app', 'Economy');
    }
    elseif ($category == self::CATEGORY_SOCIETY)
    {
        return Yii::t('app', 'Society');
    }
    else
    {
        return Yii::t('app', 'Sport');
    }
}
</code>```

Body:
I am using yii2 advanced template improved

Not sure if relevant to problem/a solution but to get to the category I have a form with some javascript which on change redirects the user to the category selected.

I have the following code which allows me to access the posts within that category id I go to localhost:8888/advanced/article/category?id=1

The problem at the minute is that if I call getCategoryName function in my model from my category view the id parameter isn't being passed to the model function therefore when using getCategoryName defaults to sport.

 public function actionCategory($id)
{

    $model = new Article();

    $searchModel = new ArticleSearch();

    $query = Article::find()
    ->where(['category' => $id]);

     $dataProvider = new ActiveDataProvider([
                    'query' => $query,
                    ]);

    return $this->render('category', [
        'searchModel' => $searchModel,
        'dataProvider' => $dataProvider,
        'model'=>$model,
    ]);
}

Then within my view I use the following which works to an extent in terms of executing the model function, however I am unsure on how to pass the parameter/current category id to the model function. The below code work for the _index & in the single article view.

<?= $model->CategoryName ?>

This is my model function

public function getCategoryName($category = null)
{
    $category = (empty($category)) ? $this->category : $category ;

    if ($category === self::CATEGORY_ECONOMY)
    {
        return Yii::t('app', 'Economy');
    }
    elseif ($category === self::CATEGORY_SOCIETY)
    {
        return Yii::t('app', 'Society');
    }
    else
    {
        return Yii::t('app', 'Sport');
    }
}

Body:
Try to use this. change === to ==:

public function getCategoryName($category = null)
{
    $category = (empty($category)) ? $this->category : $category ;

    if ($category == self::CATEGORY_ECONOMY)
    {
        return Yii::t('app', 'Economy');
    }
    elseif ($category == self::CATEGORY_SOCIETY)
    {
        return Yii::t('app', 'Society');
    }
    else
    {
        return Yii::t('app', 'Sport');
    }
}


答:
Yes, making it a Singleton is a bad design.  If you only need one Camera object, just make one.

If you need to ensure that a camera object is used in a non-reentrant way, than that is a responsibility not of the Camera object, but of your threading model.  It's a seperate job.

Title: Guarding resources with Singleton?

Body:
I have read quite a few blog posts and answers on SO pointing to Singleton being a bad design. Previously I implemented a singleton CameraControl class. This class controls a camera which is connected to the system. Under the following knowledge:

Under no circumstance will there be more than one camera (the camera API provided by the camera maker control all cameras).

Using the API of the camera maker in multiple places at the same time have caused problems in the past (e.g. one thread trying to grab an image, the other thread trying to set the shutter speed).

My class only provides several extra methods to display the image captured in a UI. Forward the image to a face detector, ... (i.e. it is not memory intensive).

Is my choice of making this class a singleton class a bad decision?


问:
Switching to master and back to working branch shows file modified in Git
I am working on library_backend project and it is git repository which have 2 branches :

master

multilanguage.

i have made some changes in multilanguage branch and pushed it to its remote branch and after it i want to check some functions on master branch.

so i have switched to master branch and after checking i have switched back to multilanguage branch but now it has modified file which is books_model.php, how can it has modified file if i have pushed it some seconds ago?

You can see what i have done after pushing to remote branch as below:

```<code>ABC@ABC-PC MINGW64 /c/xampp/htdocs/library_backend (multilanguage)
$ git checkout master
Switched to branch 'master'
M       application/models/api_model/books_model.php
Your branch and 'origin/master' have diverged,
and have 4 and 10 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)

ABC@ABC-PC MINGW64 /c/xampp/htdocs/library_backend (master)
$ git checkout multilanguage
Switched to branch 'multilanguage'

ABC@ABC-PC MINGW64 /c/xampp/htdocs/library_backend (multilanguage)
$ git status
On branch multilanguage
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   application/models/api_model/books_model.php

no changes added to commit (use "git add" and/or "git commit -a")
</code>```

答:
You can see the changes occurred in the modified file by following command.

$ git diff application/models/api_model/books_model.php

This will generate result in green and red color for modified code.

Red color indicates code which has been deleted from file.

Green color indicates the code which has been added.

If you can see the changes that you have made here in the result of this command in green color, then you should go to your branch 'multilanguage' and add, commit, push that file again.

If you can not see the changes that you have made to the file or you do not want to commit it, then you can revert the changes by checking out to the same branch 'multilanguage' and firing this command.

$ git checkout application/models/api_model/books_model.php

Hope it helps you !

Body:
I am working on library_backend project and it is git repository which have 2 branches :

master

multilanguage.

i have made some changes in multilanguage branch and pushed it to its remote branch and after it i want to check some functions on master branch.

so i have switched to master branch and after checking i have switched back to multilanguage branch but now it has modified file which is books_model.php, how can it has modified file if i have pushed it some seconds ago?

You can see what i have done after pushing to remote branch as below:

ABC@ABC-PC MINGW64 /c/xampp/htdocs/library_backend (multilanguage)
$ git checkout master
Switched to branch 'master'
M       application/models/api_model/books_model.php
Your branch and 'origin/master' have diverged,
and have 4 and 10 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)

ABC@ABC-PC MINGW64 /c/xampp/htdocs/library_backend (master)
$ git checkout multilanguage
Switched to branch 'multilanguage'

ABC@ABC-PC MINGW64 /c/xampp/htdocs/library_backend (multilanguage)
$ git status
On branch multilanguage
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   application/models/api_model/books_model.php

no changes added to commit (use "git add" and/or "git commit -a")


问:
Get the list of unique constraints and indexes in a database
I have to get the list of all the unique key constraints and the indexes of a particular database. I am doing something like this:

```<code>SELECT * FROM sys.sysobjects WHERE type!='u' AND name LIKE <tablename>
</code>```

Just wanted to confirm if this was the correct way, or is there a better way of doing the same thing?

答:
The other answers did not return complete lists for me. This query worked for me to return all unique indexes that are not primary keys or system tables:</p>

```<code>select i.name as index_name, o.name as object_name
from sys.indexes i
    join sys.objects o on i.object_id= o.object_id
where (i.is_unique_constraint = 1 OR i.is_unique = 1)
    and i.is_primary_key = 0 and o.type_desc <> 'SYSTEM_TABLE'
</code>```

Body:
I have to get the list of all the unique key constraints and the indexes of a particular database. I am doing something like this:

SELECT * FROM sys.sysobjects WHERE type!='u' AND name LIKE <tablename>

Just wanted to confirm if this was the correct way, or is there a better way of doing the same thing?

Body:
The other answers did not return complete lists for me. This query worked for me to return all unique indexes that are not primary keys or system tables:

select i.name as index_name, o.name as object_name
from sys.indexes i
    join sys.objects o on i.object_id= o.object_id
where (i.is_unique_constraint = 1 OR i.is_unique = 1)
    and i.is_primary_key = 0 and o.type_desc <> 'SYSTEM_TABLE'


问:
Spring boot Gradle make a tar file from the built jar excluding resources
I would like to create a tar file out of the built packages in a Spring Boot application. My build file looks like the following:

```<code>apply plugin: 'distribution'

distributions {
    main {
        baseName = "${project.name}"
        contents {
            into('/conf'){
                from('src/main/resources')
            }
            into('/bin'){
                from('libs')
            }
        }
    }
}

tasks.withType(Tar) {
    compression = Compression.GZIP
    extension = "tar.gz"
}

configurations {
    customArch
}

artifacts {
    customArch file(distTar.archivePath)
}
</code>```

I would like to have a single tar.gz file containing the following directory structure:

```<code>tar.gz:
   - bin
       - project.jar
   - conf
       - application.yaml
       - anything else from the resources folder
</code>```

However, when I build the pakcage it gives me a tar file containing the source files and a separate lib directory with the jar file. I would appreciate it if you could help me to understand what the issue is. I suspect for some reason the distribution runs before the build so it doesn't have the lib directory available.

答:
To achieve your target directory structure you should change your distribution closure as follows:
(Note: I assumed that your application.yaml is under resources directory.)

```<code>distributions {
    main {
        baseName = "${project.name}"
        contents {
            into('/conf'){
                from('src/main/resources')
            }
            into('/bin'){
                from('build/libs')
            }
        }
    }
}
</code>```

And to build jar file before making the tar file, you should modify distTar task as follows:

```<code>distTar {
    dependsOn bootJar
}
</code>```

Body:
I would like to create a tar file out of the built packages in a Spring Boot application. My build file looks like the following:

apply plugin: 'distribution'

distributions {
    main {
        baseName = "${project.name}"
        contents {
            into('/conf'){
                from('src/main/resources')
            }
            into('/bin'){
                from('libs')
            }
        }
    }
}

tasks.withType(Tar) {
    compression = Compression.GZIP
    extension = "tar.gz"
}

configurations {
    customArch
}

artifacts {
    customArch file(distTar.archivePath)
}

I would like to have a single tar.gz file containing the following directory structure:

tar.gz:
   - bin
       - project.jar
   - conf
       - application.yaml
       - anything else from the resources folder

However, when I build the pakcage it gives me a tar file containing the source files and a separate lib directory with the jar file. I would appreciate it if you could help me to understand what the issue is. I suspect for some reason the distribution runs before the build so it doesn't have the lib directory available.

Body:
To achieve your target directory structure you should change your distribution closure as follows:
(Note: I assumed that your application.yaml is under resources directory.)

distributions {
    main {
        baseName = "${project.name}"
        contents {
            into('/conf'){
                from('src/main/resources')
            }
            into('/bin'){
                from('build/libs')
            }
        }
    }
}

And to build jar file before making the tar file, you should modify distTar task as follows:

distTar {
    dependsOn bootJar
}


问:
Javascript function document.createElement(tagName[, options]) doesn't work as intended
I need to create  element in one js code line

this doesn't work:

var gg = document.createElement("a", {href : "http://someurl.com"})

this result in:

Thought MDN says:
var element = document.createElement(tagName[, options]);

options is an optional ElementCreationOptions object. If this object is defined and has an is property, the is attribute of the created element is initalized with the value of this property. If the object has no is property, the value is null.
https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement

is this ElementCreationOptions object some sort of exotic object? I tried many various combinations around this object but nothing works and always in results i see that strange is property! I also found it in specification: https://www.w3.org/TR/custom-elements/#attr-is but no idea how it actually works.

ps:
this doesn't work either:

var gg = document.createElement("a").setAttribute("href" , "someurl.com")

result in undefined.

答:
I get that this is an ancient question (relatively), and @Luke-Weaver's answer already gave a route involving jQuery, but the following is an option that both accomplishes what @Garegin originally requested, while still giving him the functionality that he wanted from the createElement method's ambiguous parameter name, while using vanilla JS.

```<code>gg = Object.assign(document.createElement('a'),{href:'http://someurl.com',innerText:"Bonus points?"});
</code>```

This solution creates 'Bonus points?' on one line. It's longer, so the following might work better:

```<code>function oneLineTag(tag,options){
  return Object.assign(document.createElement(tag),options);
}
let quickAnchor = {
  href:'http://someurl.com',
  innerText: "I'm still answering a 3-year-old question"
}
</code>```

and you now have the option of

```<code>gg = oneLineTag('a',quickAnchor);
</code>```

Body:
I get that this is an ancient question (relatively), and @Luke-Weaver's answer already gave a route involving jQuery, but the following is an option that both accomplishes what @Garegin originally requested, while still giving him the functionality that he wanted from the createElement method's ambiguous parameter name, while using vanilla JS.

gg = Object.assign(document.createElement('a'),{href:'http://someurl.com',innerText:"Bonus points?"});

This solution creates '<a href="http://someurl.com">Bonus points?</a>' on one line. It's longer, so the following might work better:

function oneLineTag(tag,options){
  return Object.assign(document.createElement(tag),options);
}
let quickAnchor = {
  href:'http://someurl.com',
  innerText: "I'm still answering a 3-year-old question"
}

and you now have the option of

gg = oneLineTag('a',quickAnchor);


问:
alter deploy Django project, don't have css style in Django admin
when I open /admin site, terminal report some problems in pictures, and admin site don't have CSS styles

use it to let nginx get static files

```<code>python3 manage.py collectstatic
</code>```

add static files to nginx.conf

```<code>location /static {
   alias /Users/greendan/PycharmProjects/myTravel/; #static files
   uwsgi_pass
    unix:/Users/greendan/PycharmProjects/myTravel/script/uwsgi.sock;

         }

</code>```

this is my Nginx  config

```<code>server {
         listen       8088;
         server_name  127.0.0.1;

         charset utf-8;

         #access_log  logs/host.access.log  main;

         location / {
            #root   /Users/greendan/PycharmProjects/myTravel/;
            #index  templates/bootStrap.html;
            include uwsgi_params;
            uwsgi_pass unix:/Users/greendan/PycharmProjects/myTravel/script/uwsgi.sock;
          }
         location /static {
            alias /Users/greendan/PycharmProjects/myTravel/;
            uwsgi_pass unix:/Users/greendan/PycharmProjects/myTravel/script/uwsgi.sock;

         }
          location /media{
           alias /Users/greendan/PycharmProjects/myTravel/;
          }

        #error_page  404              /404.html;

          # redirect server error pages to the static page /50x.html
         #
          error_page   500 502 503 504  /50x.html;
         location = /50x.html {
              root   html;
         }
}
</code>```

this is my uwsgi.ini

```<code># use uwsig ini start
[uwsgi]
# project's file
chdir = /Users/greendan/PycharmProjects/myTravel
# project's application
module = myTravel.wsgi:application
# sock
socket = /Users/greendan/PycharmProjects/myTravel/script/uwsgi.sock
workers = 5
#pid
pidfile = /Users/greendan/PycharmProjects/myTravel/script/uwsgi.pid
# ip and port
http =127.0.0.1:8000
</code>```

error report
picture Url

答:
it's not a big problem, just I don't know nginx' static file is not the same as the
django's static file it's two different dir.

at the begin i make static_root and static_dir  is the same file, when search in jianshu and find a article to read more than twice, I know it's tow different dir,

and then, I make a static file in nginx and solve this problems quickly.

After this things, I find a big problems of myself, it's too careless, even I make this problems lots of times, but I still git it again

Body:
when I open /admin site, terminal report some problems in pictures, and admin site don't have CSS styles

use it to let nginx get static files

python3 manage.py collectstatic

add static files to nginx.conf

location /static {
   alias /Users/greendan/PycharmProjects/myTravel/; #static files
   uwsgi_pass
    unix:/Users/greendan/PycharmProjects/myTravel/script/uwsgi.sock;

         }

this is my Nginx  config

server {
         listen       8088;
         server_name  127.0.0.1;

         charset utf-8;

         #access_log  logs/host.access.log  main;

         location / {
            #root   /Users/greendan/PycharmProjects/myTravel/;
            #index  templates/bootStrap.html;
            include uwsgi_params;
            uwsgi_pass unix:/Users/greendan/PycharmProjects/myTravel/script/uwsgi.sock;
          }
         location /static {
            alias /Users/greendan/PycharmProjects/myTravel/;
            uwsgi_pass unix:/Users/greendan/PycharmProjects/myTravel/script/uwsgi.sock;

         }
          location /media{
           alias /Users/greendan/PycharmProjects/myTravel/;
          }

        #error_page  404              /404.html;

          # redirect server error pages to the static page /50x.html
         #
          error_page   500 502 503 504  /50x.html;
         location = /50x.html {
              root   html;
         }
}

this is my uwsgi.ini

# use uwsig ini start
[uwsgi]
# project's file
chdir = /Users/greendan/PycharmProjects/myTravel
# project's application
module = myTravel.wsgi:application
# sock
socket = /Users/greendan/PycharmProjects/myTravel/script/uwsgi.sock
workers = 5
#pid
pidfile = /Users/greendan/PycharmProjects/myTravel/script/uwsgi.pid
# ip and port
http =127.0.0.1:8000

error report
picture Url


问:
How to add remoteproc node into device tree of Zynq-7000 Based RedPitaya board
I am trying to run the RedPitaya in AMP mode.

I didn't find much information on the remoteproc driver and what kind of entries it need in the device tree source. I found this document and added it to the device tree but hadn't so much luck with making the examples work. Also I found different variations in the device tree node for remoteproc from different sources which is pretty confusing.

Can someone point me in the direction where I can read more about the AMP feature of the Arm-Cortex-A9 and can some explain some of the entries in the dts node of remoteproc.

答:
What different sources? Are you talking about kernel sources? Device tree node entry would be dependent on the kernel version and the actual driver thereof, changing if there is a change in the driver or kernel remoteproc subsystem.

ZynqQ-7000 is a dual core Cortex A9. Based on cursory reading of the documentation, the remoteproc driver in question assumes one core running Linux and the other core to help with other real time tasks. mmio-sram is described here. Not sure what specific ZynqQ hardware design, the device tree binding documentation talks of.

To understand vrings, you need an understanding of virtio and rpmsg used in open-amp and Linux. A vring can be thought of as a ring buffer, with one buffer being used to send from Master to Slave and another from slave to master. A interrupt is associated with each vring which is raised when either Master or Slave places something in the vring and then wants to inform the other end.

In case of Linux based systems, Linux is always the master. For Zynq since we are using the two A9's, this will be an inter processor interrupt. For SoC's like NXP's iMX7 or Vybrid, the interrupts are raised with a separate peripheral module like the Messaging Unit for iMX7.


问:
Why handle clicking on TableView Swift IOS worth cell rows are the previous rows clicked?
I already the TableView for displaying JSON Values from API. But the result of the click does not match the existing title, but it is worth the title from the previous click. More clearly see the picture

Code InfoViewCell.swift
This code for cell in tableview

```<code>import UIKit

class InfoViewCell: UITableViewCell {
    @IBOutlet weak var imgInfo: UIImageView!
    @IBOutlet weak var lblInfo: UILabel!
    @IBOutlet weak var lblBerita: UILabel!

    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}

</code>```

Code Info.swift this code for models

```<code>class Info {

    var id_informasi: Int?
    var tgl_informasi: String?
    var judul: String?
    var berita: String?
    var foto: String?

    init(id_informasi:Int?,judul: String?,berita: String?,foto: String?) {
        self.id_informasi = id_informasi
        self.judul = judul
        self.berita = berita
        self.foto = foto
    }
}

</code>```

Code InfoViewController.swift

```<code>import UIKit
import Alamofire
import AlamofireImage

class InformasiViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
    @IBOutlet weak var tableInfo: UITableView!
    var activityIndicator:UIActivityIndicatorView = UIActivityIndicatorView()

    var infoes = [Info]()

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return infoes.count
    }

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "cellInfo", for: indexPath) as! InfoViewCell

        //getting the hero for the specified position
        let inpo: Info
        inpo = infoes[indexPath.row]

        //displaying values
        cell.lblInfo.text = inpo.judul
        cell.lblBerita.text = inpo.berita

        //displaying image
        Alamofire.request(inpo.foto!).responseImage { response in
            debugPrint(response)

            if let image = response.result.value {
                cell.imgInfo.image = image
            }
        }

        return cell
    }

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

        let info: Info
        info  = infoes[indexPath.row]

        //building an alert
        let alertController = UIAlertController(title: info.judul, message: "", preferredStyle: .alert)

        //the confirm action taking the inputs
        let confirmAction = UIAlertAction(title: "Enter", style: .default) { (_) in

        }

        //the cancel action doing nothing
        let cancelAction = UIAlertAction(title: "Cancel", style: .cancel) { (_) in }

        //adding action
        alertController.addAction(confirmAction)
        alertController.addAction(cancelAction)

        //presenting dialog
        present(alertController, animated: true, completion: nil)
    }

    override func viewDidLoad() {
        super.viewDidLoad()

        let defaultValues = UserDefaults.standard
        let token = defaultValues.string(forKey: "token")

        //the Web API URL
        let URL_GET_DATA = "https://api.landslidepad.com/api/admin_desa/informasi_penting?token=" + token!

        activityIndicator.center = self.view.center
        activityIndicator.hidesWhenStopped = true
        activityIndicator.style = UIActivityIndicatorView.Style.gray
        view.addSubview(activityIndicator)
        activityIndicator.startAnimating()
        //fetching data from web api
        Alamofire.request(URL_GET_DATA, method: .get).responseJSON
            {

                response in
                //printing response
                print(response)

                self.activityIndicator.stopAnimating()
                //getting the json value from the server
                if let result = response.result.value {

                    let jsonData = result as! NSDictionary

                    //if there is no error
                    if((jsonData.value(forKey: "message") as! String == "Sukses!")){

                        //getting the user from response
                        let user = jsonData.value(forKey: "values") as! NSArray

                        for i in 0..<user.count{

                            //adding hero values to the hero list
                            self.infoes.append(Info(
                                id_informasi: (user[i] as AnyObject).value(forKey: "id_informasi") as? Int,
                                judul: (user[i] as AnyObject).value(forKey: "judul") as? String,
                                berita: (user[i] as AnyObject).value(forKey: "berita") as? String,
                                foto: (user[i] as AnyObject).value(forKey: "foto") as? String
                            ))
                        }
                        //displaying data in tableview
                        self.tableInfo.reloadData()

                    }else{
                        let alert = UIAlertController(title: "Ada yang salah?", message: "Silahkan Ulangi Kembali!.", preferredStyle: .alert)

                        alert.addAction(UIAlertAction(title: "Yes", style: .default, handler: nil))
                        alert.addAction(UIAlertAction(title: "No", style: .cancel, handler: nil))

                        self.present(alert, animated: true)
                    }
                }
        }

        self.tableInfo.reloadData()
        // Do any additional setup after loading the view, typically from a nib.

        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}

</code>```

I already tried to create func tableview didDeselectRowAt indexPath,
but the value I want to display is not in line with my expectations. I will pass this value to the detailed view

Thanks

答:
instead of this

```<code>func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) {

    let info: Info
    info  = infoes[indexPath.row]

    //building an alert
    let alertController = UIAlertController(title: info.judul, message: "", preferredStyle: .alert)

    //the confirm action taking the inputs
    let confirmAction = UIAlertAction(title: "Enter", style: .default) { (_) in

    }

    //the cancel action doing nothing
    let cancelAction = UIAlertAction(title: "Cancel", style: .cancel) { (_) in }

    //adding action
    alertController.addAction(confirmAction)
    alertController.addAction(cancelAction)

    //presenting dialog
    present(alertController, animated: true, completion: nil)
}
</code>```

please use this

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

    let info: Info
    info  = infoes[indexPath.row]

    //building an alert
    let alertController = UIAlertController(title: info.judul, message: "", preferredStyle: .alert)

    //the confirm action taking the inputs
    let confirmAction = UIAlertAction(title: "Enter", style: .default) { (_) in

    }

    //the cancel action doing nothing
    let cancelAction = UIAlertAction(title: "Cancel", style: .cancel) { (_) in }

    //adding action
    alertController.addAction(confirmAction)
    alertController.addAction(cancelAction)

    //presenting dialog
    present(alertController, animated: true, completion: nil)
}
</code>```

Body:
I already the TableView for displaying JSON Values from API. But the result of the click does not match the existing title, but it is worth the title from the previous click. More clearly see the picture

Code InfoViewCell.swift
This code for cell in tableview

import UIKit

class InfoViewCell: UITableViewCell {
    @IBOutlet weak var imgInfo: UIImageView!
    @IBOutlet weak var lblInfo: UILabel!
    @IBOutlet weak var lblBerita: UILabel!

    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}

Code Info.swift this code for models

class Info {

    var id_informasi: Int?
    var tgl_informasi: String?
    var judul: String?
    var berita: String?
    var foto: String?

    init(id_informasi:Int?,judul: String?,berita: String?,foto: String?) {
        self.id_informasi = id_informasi
        self.judul = judul
        self.berita = berita
        self.foto = foto
    }
}

Code InfoViewController.swift

import UIKit
import Alamofire
import AlamofireImage

class InformasiViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
    @IBOutlet weak var tableInfo: UITableView!
    var activityIndicator:UIActivityIndicatorView = UIActivityIndicatorView()

    var infoes = [Info]()

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return infoes.count
    }

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "cellInfo", for: indexPath) as! InfoViewCell

        //getting the hero for the specified position
        let inpo: Info
        inpo = infoes[indexPath.row]

        //displaying values
        cell.lblInfo.text = inpo.judul
        cell.lblBerita.text = inpo.berita

        //displaying image
        Alamofire.request(inpo.foto!).responseImage { response in
            debugPrint(response)

            if let image = response.result.value {
                cell.imgInfo.image = image
            }
        }

        return cell
    }

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

        let info: Info
        info  = infoes[indexPath.row]

        //building an alert
        let alertController = UIAlertController(title: info.judul, message: "", preferredStyle: .alert)

        //the confirm action taking the inputs
        let confirmAction = UIAlertAction(title: "Enter", style: .default) { (_) in

        }

        //the cancel action doing nothing
        let cancelAction = UIAlertAction(title: "Cancel", style: .cancel) { (_) in }

        //adding action
        alertController.addAction(confirmAction)
        alertController.addAction(cancelAction)

        //presenting dialog
        present(alertController, animated: true, completion: nil)
    }

    override func viewDidLoad() {
        super.viewDidLoad()

        let defaultValues = UserDefaults.standard
        let token = defaultValues.string(forKey: "token")

        //the Web API URL
        let URL_GET_DATA = "https://api.landslidepad.com/api/admin_desa/informasi_penting?token=" + token!

        activityIndicator.center = self.view.center
        activityIndicator.hidesWhenStopped = true
        activityIndicator.style = UIActivityIndicatorView.Style.gray
        view.addSubview(activityIndicator)
        activityIndicator.startAnimating()
        //fetching data from web api
        Alamofire.request(URL_GET_DATA, method: .get).responseJSON
            {

                response in
                //printing response
                print(response)

                self.activityIndicator.stopAnimating()
                //getting the json value from the server
                if let result = response.result.value {

                    let jsonData = result as! NSDictionary

                    //if there is no error
                    if((jsonData.value(forKey: "message") as! String == "Sukses!")){

                        //getting the user from response
                        let user = jsonData.value(forKey: "values") as! NSArray

                        for i in 0..<user.count{

                            //adding hero values to the hero list
                            self.infoes.append(Info(
                                id_informasi: (user[i] as AnyObject).value(forKey: "id_informasi") as? Int,
                                judul: (user[i] as AnyObject).value(forKey: "judul") as? String,
                                berita: (user[i] as AnyObject).value(forKey: "berita") as? String,
                                foto: (user[i] as AnyObject).value(forKey: "foto") as? String
                            ))
                        }
                        //displaying data in tableview
                        self.tableInfo.reloadData()

                    }else{
                        let alert = UIAlertController(title: "Ada yang salah?", message: "Silahkan Ulangi Kembali!.", preferredStyle: .alert)

                        alert.addAction(UIAlertAction(title: "Yes", style: .default, handler: nil))
                        alert.addAction(UIAlertAction(title: "No", style: .cancel, handler: nil))

                        self.present(alert, animated: true)
                    }
                }
        }

        self.tableInfo.reloadData()
        // Do any additional setup after loading the view, typically from a nib.

        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}

I already tried to create func tableview didDeselectRowAt indexPath,
but the value I want to display is not in line with my expectations. I will pass this value to the detailed view

Thanks

Body:
instead of this

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

    let info: Info
    info  = infoes[indexPath.row]

    //building an alert
    let alertController = UIAlertController(title: info.judul, message: "", preferredStyle: .alert)

    //the confirm action taking the inputs
    let confirmAction = UIAlertAction(title: "Enter", style: .default) { (_) in

    }

    //the cancel action doing nothing
    let cancelAction = UIAlertAction(title: "Cancel", style: .cancel) { (_) in }

    //adding action
    alertController.addAction(confirmAction)
    alertController.addAction(cancelAction)

    //presenting dialog
    present(alertController, animated: true, completion: nil)
}

please use this

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

    let info: Info
    info  = infoes[indexPath.row]

    //building an alert
    let alertController = UIAlertController(title: info.judul, message: "", preferredStyle: .alert)

    //the confirm action taking the inputs
    let confirmAction = UIAlertAction(title: "Enter", style: .default) { (_) in

    }

    //the cancel action doing nothing
    let cancelAction = UIAlertAction(title: "Cancel", style: .cancel) { (_) in }

    //adding action
    alertController.addAction(confirmAction)
    alertController.addAction(cancelAction)

    //presenting dialog
    present(alertController, animated: true, completion: nil)
}