问:
Dynamically add widgets to a column's children in flutter
I'm creating a quiz app and need to display mcq options dynamically based on how many options there are for a particular question.

So for example:

Now the code for the buttons is here :

    final quizOptions = Container(
      width: MediaQuery.of(context).size.width,
      child: Center(
        child: Column(
          children: <Widget>[
            SimpleRoundButton(
                backgroundColor: Color.fromRGBO(58, 66, 86, 1.0),
                buttonText: Text(questions[questionNum].options[0],
                    style: TextStyle(
                        color: Colors.white
                    ),
                ),
                textColor: Colors.white,
                onPressed: (){},
            ),
            SimpleRoundButton(
                backgroundColor: Color.fromRGBO(58, 66, 86, 1.0),
                buttonText: Text(questions[questionNum].options[1],
                    style: TextStyle(
                        color: Colors.white
                    ),
                ),
                textColor: Colors.white,
                onPressed: (){},
            ),
          ],
        ),
      ),
    );
```

<p>As you can see, what I am able to do is to "fix" 2 buttons. Is there a way to dynamically add buttons based on how many options there are for that particular question ?</p>

<p>I have a list named <code>questions</code> and it is a list of questions (which is a class):</p>

<pre class="lang-dart prettyprint-override"><code>class Question {
  String title;
  List options;
  String imagePath;

  Question(
      {this.title, this.options, this.imagePath,});
}

//Example:
Question(
 title: "How fast does the drone go ?",
 options: ['80km/h', '90km/h', '100km/h'],
 imagePath: "assets/images/drones1.jpg",
)
</code>```

答:
You should iterate through your options to create SimpleRoundButton

```<code>...................................
    child: Column(
              children: questions[questionNum].options.map<Widget>(
                (option) =>  SimpleRoundButton(
                    backgroundColor: Color.fromRGBO(58, 66, 86, 1.0),
                    buttonText: Text(option,
                        style: TextStyle(
                            color: Colors.white
                        ),
                    ),
                    textColor: Colors.white,
                    onPressed: (){},
                ),
           ).toList(),
.........................
</code>```

Body:
I'm creating a quiz app and need to display mcq options dynamically based on how many options there are for a particular question.

So for example:

Now the code for the buttons is here :

    final quizOptions = Container(
      width: MediaQuery.of(context).size.width,
      child: Center(
        child: Column(
          children: <Widget>[
            SimpleRoundButton(
                backgroundColor: Color.fromRGBO(58, 66, 86, 1.0),
                buttonText: Text(questions[questionNum].options[0],
                    style: TextStyle(
                        color: Colors.white
                    ),
                ),
                textColor: Colors.white,
                onPressed: (){},
            ),
            SimpleRoundButton(
                backgroundColor: Color.fromRGBO(58, 66, 86, 1.0),
                buttonText: Text(questions[questionNum].options[1],
                    style: TextStyle(
                        color: Colors.white
                    ),
                ),
                textColor: Colors.white,
                onPressed: (){},
            ),
          ],
        ),
      ),
    );

As you can see, what I am able to do is to "fix" 2 buttons. Is there a way to dynamically add buttons based on how many options there are for that particular question ?

I have a list named questions and it is a list of questions (which is a class):

class Question {
  String title;
  List options;
  String imagePath;

  Question(
      {this.title, this.options, this.imagePath,});
}

//Example:
Question(
 title: "How fast does the drone go ?",
 options: ['80km/h', '90km/h', '100km/h'],
 imagePath: "assets/images/drones1.jpg",
)

Body:
You should iterate through your options to create SimpleRoundButton

...................................
    child: Column(
              children: questions[questionNum].options.map<Widget>(
                (option) =>  SimpleRoundButton(
                    backgroundColor: Color.fromRGBO(58, 66, 86, 1.0),
                    buttonText: Text(option,
                        style: TextStyle(
                            color: Colors.white
                        ),
                    ),
                    textColor: Colors.white,
                    onPressed: (){},
                ),
           ).toList(),
.........................


来源: stackexchange

问:
calculating price with two values
So I have something like this...

I have a form where you select your gender and input your weight. each gender has different ranges of prices for example if your a male and your weight is greater than 200 your price is 20, if your a female and your weight is greater than 200 your price is 15, and if your male and your weight is less than 200 your price is 10, for the female if her weight is less than 200 her price is 7     . i have been trying to make it possible with jquery and PHP but it only seems to work with select option and won't work with input data.

this is my index.php

```<code>   <div class="container">

      <div class="row">
       <div class="col-xs-3 col-xs-offset-2">
        <h3>gender:</h3>
        <!-- select gender -->
         <select class="form-control" id="gender">
         <option>female</option>
        <option>male</option>
         </select>
        </div>
       <div class="col-xs-3">
         <h3>weight </h3>
          <!-- input weight -->
       <input type="" name="weight" id="weight">
        </div>

         </div>
      <div id="ticketInfo">
        <h3 id="yourTicket">No gender Selected</h3>
     </div>
     </div>
    <script src="js/jquery-1.12.2.js"></script>
   <script src="js/bootstrap.js"></script>
     <script src="js/scripts.js"></script>
</code>```

this is my script

```<code>  function Ticket(gender, weight) {
  this.gender=gender;
  this.weight=weight;

     }

   Ticket.prototype.getPrice=function() {
     var price;

   if((this.gender==="male ")||(this.weight=>"200 ")){
       price=20;
        }
    if((this.gender==="female ")||(this.weight=>"200 ")) {
      price=15;
     }
     if((this.gender==="male ")||(this.weight=<"200 ")) {
    price=10;
    }
   if((this.gender==="female ")||(this.weight=<"200 ")) {
    price=7;
   }

  return price;
 }

$("select").change(function() {
  var genderOptions=[];
  $("select option:selected").each(function() {
   genderOptions.push($(this).text() + " ");
 });
 var newTicket = new
 Ticket(genderOptions[0],genderOptions[1],genderOptions[2]);
 $("#yourTicket").text(newTicket.gender + newTicket.weight + " $" +
 newTicket.getPrice().toFixed(2));
   });
</code>```

at the end in trying to multiply the price by the weight. any help will be really appreciated, thanks in advance.

答:
Your question is unclear.as per my understanding I provide you a solution.

You have mistakes in your if condition. for eg. you need to check as >= instead you checked as => which is wrong.

Also it should be && instead of ||

And you missed to pass the weight variable to the Ticket class.

remove quotes around 200 in your if condition

you have pushed a space in genderOptions. so I removed it.

I fixed these issues.

function Ticket(gender, weight) {
  this.gender=gender;
  this.weight=weight;
}

Ticket.prototype.getPrice=function() {
  var price;
  if(this.gender==="male" && this.weight > 200 ){
    price=20;
  }
  else if(this.gender==="female" && this.weight > 200 ) {
    price=15;
  }
  else if(this.gender==="male" && this.weight <= 200 ) {
    price=10;
  }
  else if(this.gender==="female" && this.weight <= 200 ) {
    price=7;
  }
  return price;
}

$("select").change(function() {
  var genderOptions=[];
  $("select option:selected").each(function() {
    genderOptions.push($(this).text());
  });

  var newTicket = new Ticket(genderOptions[0] , $('#weight').val());
  var multiplyVal = newTicket.weight * newTicket.getPrice();
  $("#yourTicket").text(newTicket.gender + newTicket.weight + " $" + newTicket.getPrice().toFixed(2) + " and your multiplied value is " + multiplyVal);
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>   <div class="row">
       <div class="col-xs-3 col-xs-offset-2">
        <h3>gender:</h3>
        <!-- select gender -->
         <select class="form-control" id="gender">
         <option value="female">female</option>
        <option value="male">male</option>
         </select>
        </div>
       <div class="col-xs-3">
         <h3>weight </h3>
          <!-- input weight -->
       <input type="" name="weight" id="weight">
        </div>

         </div>
      <div id="ticketInfo">
        <h3 id="yourTicket">No gender Selected</h3>
     </div>
     </div></code>```

ContentLicense: CC BY-SA 4.0

Title: calculating price with two values

Body:
So I have something like this...

I have a form where you select your gender and input your weight. each gender has different ranges of prices for example if your a male and your weight is greater than 200 your price is 20, if your a female and your weight is greater than 200 your price is 15, and if your male and your weight is less than 200 your price is 10, for the female if her weight is less than 200 her price is 7     . i have been trying to make it possible with jquery and PHP but it only seems to work with select option and won't work with input data.

this is my index.php

gender:

         <select class="form-control" id="gender">
         <option>female</option>
        <option>male</option>
         </select>

weight

       <input type="" name="weight" id="weight">

No gender Selected

this is my script

  function Ticket(gender, weight) {
  this.gender=gender;
  this.weight=weight;

     }

   Ticket.prototype.getPrice=function() {
     var price;

   if((this.gender==="male ")||(this.weight=>"200 ")){
       price=20;
        }
    if((this.gender==="female ")||(this.weight=>"200 ")) {
      price=15;
     }
     if((this.gender==="male ")||(this.weight=<"200 ")) {
    price=10;
    }
   if((this.gender==="female ")||(this.weight=<"200 ")) {
    price=7;
   }

  return price;
 }

$("select").change(function() {
  var genderOptions=[];
  $("select option:selected").each(function() {
   genderOptions.push($(this).text() + " ");
 });
 var newTicket = new
 Ticket(genderOptions[0],genderOptions[1],genderOptions[2]);
 $("#yourTicket").text(newTicket.gender + newTicket.weight + " $" +
 newTicket.getPrice().toFixed(2));
   });

at the end in trying to multiply the price by the weight. any help will be really appreciated, thanks in advance.

Body:
Your question is unclear.as per my understanding I provide you a solution.

You have mistakes in your if condition. for eg. you need to check as >= instead you checked as => which is wrong.

Also it should be && instead of ||

And you missed to pass the weight variable to the Ticket class.

remove quotes around 200 in your if condition

you have pushed a space in genderOptions. so I removed it.

I fixed these issues.

function Ticket(gender, weight) {
  this.gender=gender;
  this.weight=weight;
}

Ticket.prototype.getPrice=function() {
  var price;
  if(this.gender==="male" && this.weight > 200 ){
    price=20;
  }
  else if(this.gender==="female" && this.weight > 200 ) {
    price=15;
  }
  else if(this.gender==="male" && this.weight <= 200 ) {
    price=10;
  }
  else if(this.gender==="female" && this.weight <= 200 ) {
    price=7;
  }
  return price;
}

$("select").change(function() {
  var genderOptions=[];
  $("select option:selected").each(function() {
    genderOptions.push($(this).text());
  });

  var newTicket = new Ticket(genderOptions[0] , $('#weight').val());
  var multiplyVal = newTicket.weight * newTicket.getPrice();
  $("#yourTicket").text(newTicket.gender + newTicket.weight + " $" + newTicket.getPrice().toFixed(2) + " and your multiplied value is " + multiplyVal);
});

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>   <div class="row">
       <div class="col-xs-3 col-xs-offset-2">
        <h3>gender:</h3>
        <!-- select gender -->
         <select class="form-control" id="gender">
         <option value="female">female</option>
        <option value="male">male</option>
         </select>
        </div>
       <div class="col-xs-3">
         <h3>weight </h3>
          <!-- input weight -->
       <input type="" name="weight" id="weight">
        </div>

         </div>
      <div id="ticketInfo">
        <h3 id="yourTicket">No gender Selected</h3>
     </div>
     </div>


问:
EXTJS bar chart vertical bar is not coming at correct(center) position. How to make it?
I am trying to change the width of the bar in extjs bar chart. While changing bar width, it is moving to left side. It is not coming in correct(center) position

fiddle link : https://fiddle.sencha.com/#view/editor&fiddle/2sfi

I tried to set align center. but it is not working

```<code>Ext.application({
name : 'Fiddle',

    launch : function() {
        var chart = Ext.create('Ext.chart.CartesianChart', {
            legend       : {
                docked : 'right'
            },
            insetPadding : 40,
            flipXY       : false,
            store        : {
                fields : ['month', 'data1', 'data2', 'data3', 'data4' ],
                data   : [
                    { month : 1, data1 : 20, data2 : 37, data3 : 35, data4 : 4 },
                    { month : 2, data1 : 20, data2 : 37, data3 : 36, data4 : 5 },
                    { month : 3, data1 : 19, data2 : 36, data3 : 37, data4 : 4 },
                    { month : 4, data1 : 18, data2 : 36, data3 : 38, data4 : 5 },
                    { month : 5, data1 : 18, data2 : 35, data3 : 39, data4 : 4 },
                    { month : 6, data1 : 17, data2 : 34, data3 : 42, data4 : 4 },
                    { month : 7, data1 : 16, data2 : 34, data3 : 43, data4 : 4 },
                    { month : 8, data1 : 16, data2 : 33, data3 : 44, data4 : 4 },
                    { month : 9, data1 : 16, data2 : 32, data3 : 44, data4 : 4 },
                    { month : 10, data1 : 16, data2 : 32, data3 : 45, data4 : 4 },
                    { month : 11, data1 : 15, data2 : 31, data3 : 46, data4 : 4 },
                    { month : 12, data1 : 15, data2 : 31, data3 : 47, data4 : 4 }
                ]
            },
            axes         : [
                {
                    type              : 'numeric',
                    position          : 'left',
                    adjustByMajorUnit : true,
                    fields            : 'data1',
                    grid              : true,

                    minimum           : 0
                },
                {
                    type     : 'category',
                    position : 'bottom',
                    fields   : 'month',
                    grid     : true
                }
            ],
            series       : [
                {
                    type    : 'bar',
                    title   : [ 'IE'],
                    xField  : 'month',
                    yField  : [ 'data1'],
                    renderer: function(sprite, record, attr, index, store) {
                    return Ext.apply(attr, {
                        width: 1,
                    });
                    },
                    stacked : false
                }
            ]
        });

        Ext.create('Ext.Window', {
            width       : 500,
            height      : 400,
            title       : 'Grouped Bar Chart',
            autoShow    : true,
            layout      : 'fit',
            items       : chart
        });[![enter image description here][1]][1]
    }
});
</code>```

the bar need to be come in the position of 1(horizontal) not before one
if i removed belllow code from renderer, bar width is getting increase and it is aligning correctly.

return Ext.apply(attr, {
                            width: 1,
                        });

答:
After setting maxBarWidth bars are aligning at correct position.

style: {
                opacity: 1,
                stroke: 10,
                maxBarWidth: 1
            }

Body:
I am trying to change the width of the bar in extjs bar chart. While changing bar width, it is moving to left side. It is not coming in correct(center) position

fiddle link : https://fiddle.sencha.com/#view/editor&fiddle/2sfi

I tried to set align center. but it is not working

Ext.application({
name : 'Fiddle',

    launch : function() {
        var chart = Ext.create('Ext.chart.CartesianChart', {
            legend       : {
                docked : 'right'
            },
            insetPadding : 40,
            flipXY       : false,
            store        : {
                fields : ['month', 'data1', 'data2', 'data3', 'data4' ],
                data   : [
                    { month : 1, data1 : 20, data2 : 37, data3 : 35, data4 : 4 },
                    { month : 2, data1 : 20, data2 : 37, data3 : 36, data4 : 5 },
                    { month : 3, data1 : 19, data2 : 36, data3 : 37, data4 : 4 },
                    { month : 4, data1 : 18, data2 : 36, data3 : 38, data4 : 5 },
                    { month : 5, data1 : 18, data2 : 35, data3 : 39, data4 : 4 },
                    { month : 6, data1 : 17, data2 : 34, data3 : 42, data4 : 4 },
                    { month : 7, data1 : 16, data2 : 34, data3 : 43, data4 : 4 },
                    { month : 8, data1 : 16, data2 : 33, data3 : 44, data4 : 4 },
                    { month : 9, data1 : 16, data2 : 32, data3 : 44, data4 : 4 },
                    { month : 10, data1 : 16, data2 : 32, data3 : 45, data4 : 4 },
                    { month : 11, data1 : 15, data2 : 31, data3 : 46, data4 : 4 },
                    { month : 12, data1 : 15, data2 : 31, data3 : 47, data4 : 4 }
                ]
            },
            axes         : [
                {
                    type              : 'numeric',
                    position          : 'left',
                    adjustByMajorUnit : true,
                    fields            : 'data1',
                    grid              : true,

                    minimum           : 0
                },
                {
                    type     : 'category',
                    position : 'bottom',
                    fields   : 'month',
                    grid     : true
                }
            ],
            series       : [
                {
                    type    : 'bar',
                    title   : [ 'IE'],
                    xField  : 'month',
                    yField  : [ 'data1'],
                    renderer: function(sprite, record, attr, index, store) {
                    return Ext.apply(attr, {
                        width: 1,
                    });
                    },
                    stacked : false
                }
            ]
        });

        Ext.create('Ext.Window', {
            width       : 500,
            height      : 400,
            title       : 'Grouped Bar Chart',
            autoShow    : true,
            layout      : 'fit',
            items       : chart
        });[![enter image description here][1]][1]
    }
});

the bar need to be come in the position of 1(horizontal) not before one
if i removed belllow code from renderer, bar width is getting increase and it is aligning correctly.

return Ext.apply(attr, {
                            width: 1,
                        });


问:
Show message after checking a checkbox - HTML Contact form
I tried following the steps of this link but I can't make it work.

I am trying to make it so that in a contact form, made in WordPress through HTML, if the user checks a box something else will show up. I implemented the code that appears in the link in my webpage and added the CSS (not SCSS) to the custom CSS page detail that Wordpress allows you to do. But even though I think I followed all the right steps the message that should appear only if the box is checked is always shown.

The example that was given I shortened it to

```<code><form name="Inscripción" method="POST" onsubmit="return" form_validation()="" action="../customer-details.php">.
<input type="radio" name="choice-animals" id="choice-animals-dogs"><br>
<label for="choice-animals-dogs">I like dogs more</label><p></p>.
<div class="reveal-if-active"> Anything you want in here. </div>
</form>
</code>```

And the CSS added was

```<code>.reveal-if-active {
  opacity: 0;
  max-height: 0;
  overflow: hidden;
}
input[type="radio"]:checked ~ .reveal-if-active,
input[type="checkbox"]:checked ~ .reveal-if-active {
  opacity: 1;
  max-height: 100px; /* little bit of a magic number :( */
  overflow: visible;
}
</code>```

Thank you for any help you might provide!

答:
I have checked your code it seems working for me. if CSS code not working for you. you can use below jquery code to display the message on radio checked.</p>

```<code><head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script>
    jQuery(document).ready(function(){
        jQuery('.reveal-if-active').hide();
        jQuery('input[type="radio"]').change(function() {
            if (jQuery(this).is(':checked')) {
                jQuery('.reveal-if-active').show();
            }
        });

    });
</script>
</head>

<form name="Inscripción" method="POST" onsubmit="return" form_validation="" action="../customer-details.php">.
<input type="radio" name="choice-animals" id="choice-animals-dogs"><br>
<label for="choice-animals-dogs">I like dogs more</label><p></p>.
<div class="reveal-if-active"> Anything you want in here. </div>
</form>
</code>```

Body:
I tried following the steps of this link but I can't make it work.

I am trying to make it so that in a contact form, made in WordPress through HTML, if the user checks a box something else will show up. I implemented the code that appears in the link in my webpage and added the CSS (not SCSS) to the custom CSS page detail that Wordpress allows you to do. But even though I think I followed all the right steps the message that should appear only if the box is checked is always shown.

The example that was given I shortened it to

<form name="Inscripción" method="POST" onsubmit="return" form_validation()="" action="../customer-details.php">.
<input type="radio" name="choice-animals" id="choice-animals-dogs">

I like dogs more

.

 Anything you want in here.

</form>

And the CSS added was

.reveal-if-active {
  opacity: 0;
  max-height: 0;
  overflow: hidden;
}
input[type="radio"]:checked ~ .reveal-if-active,
input[type="checkbox"]:checked ~ .reveal-if-active {
  opacity: 1;
  max-height: 100px; /* little bit of a magic number :( */
  overflow: visible;
}

Thank you for any help you might provide!

Body:
I have checked your code it seems working for me. if CSS code not working for you. you can use below jquery code to display the message on radio checked.

<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script>
    jQuery(document).ready(function(){
        jQuery('.reveal-if-active').hide();
        jQuery('input[type="radio"]').change(function() {
            if (jQuery(this).is(':checked')) {
                jQuery('.reveal-if-active').show();
            }
        });

    });
</script>
</head>

<form name="Inscripción" method="POST" onsubmit="return" form_validation="" action="../customer-details.php">.
<input type="radio" name="choice-animals" id="choice-animals-dogs"><br>
<label for="choice-animals-dogs">I like dogs more</label><p></p>.
<div class="reveal-if-active"> Anything you want in here. </div>
</form>


问:
Login Error: There is an error in logging you into this application. Please try again later
I am getting this error. When I try to sign in with facebook to my app.
When I first time authentication it will correctly working. After I unistalled my application and now trying to sign in with Facebook on that I am getting this error.

Another Issue : After authenticate in device1 and try to login with facebook on device2 also same error is getting.

Solution I Found : when I remove App authentication from Facebook App Settings it is working in above scenario's but this is not an good solution how we can tell to users to do this action?

```<code>btnFbLogin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(accessToken != null) {
                    boolean expires = accessToken.isExpired();
                    if(!expires) {
                        performFbLoginOrSignUp(accessToken);
                    }
                } else {
                    LoginButton loginButton = (LoginButton) findViewById(R.id.login_button);
                    callbackManager = CallbackManager.Factory.create();

                    if (loginButton != null) {
                        loginButton.setReadPermissions("public_profile", "email", "user_friends");

                        if (CommonUtil.isConnectingToInternet(LoginActivity.this)) {
                            loginButton.performClick();

                            loginButton.setPressed(true);

                            loginButton.invalidate();

                            loginButton.registerCallback(callbackManager, mCallBack);

                            loginButton.setPressed(false);

                            loginButton.invalidate();
                        }
                    }
                }
            }
        });
</code>```

In Facebook example also having an issue :
GitHub link of Facebook example

Steps to reproduce :

Launch the app Login with Facebook Authenticate FB profile.

Un_install the app and install again.

Now try to  Login with Facebook.

The above error will occur. because we already authenticated so need to access fb profile. but here we facing the issue.

Here already authenticated page is not showing.

I am using Native FB app with the device Xiaomi Redmi Note 3

答:
I refer this,

https://developers.facebook.com/docs/android/getting-started

or just add below code in onCreate() method, which will return key hash.

```<code> // Add code to print out the key hash
try {
    PackageInfo info = getPackageManager().getPackageInfo(
            "com.facebook.samples.hellofacebook",
            PackageManager.GET_SIGNATURES);
    for (Signature signature : info.signatures) {
        MessageDigest md = MessageDigest.getInstance("SHA");
        md.update(signature.toByteArray());
        Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
        }
} catch (NameNotFoundException e) {

} catch (NoSuchAlgorithmException e) {

}
</code>```

Add above code to retrieve key,that key you can store

https://developers.facebook.com/docs/facebook-login/android

here. Now It will work.

It worked for me, hope will work for you too.

OR

This command may not give you latest keyhash.

keytool -exportcert -alias YOUR_RELEASE_KEY_ALIAS -keystore YOUR_RELEASE_KEY_PATH | openssl sha1 -binary | openssl base64

To get latest or active keyhash from android studio search 'hash'  in your android studio's Logcat or android monitor while app is running and throwing above error. You will get different keyhash which is active. After pasting this searched keyhash in your console setting you may log be able to your app.

Body:
I am getting this error. When I try to sign in with facebook to my app.
When I first time authentication it will correctly working. After I unistalled my application and now trying to sign in with Facebook on that I am getting this error.

Another Issue : After authenticate in device1 and try to login with facebook on device2 also same error is getting.

Solution I Found : when I remove App authentication from Facebook App Settings it is working in above scenario's but this is not an good solution how we can tell to users to do this action?

btnFbLogin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(accessToken != null) {
                    boolean expires = accessToken.isExpired();
                    if(!expires) {
                        performFbLoginOrSignUp(accessToken);
                    }
                } else {
                    LoginButton loginButton = (LoginButton) findViewById(R.id.login_button);
                    callbackManager = CallbackManager.Factory.create();

                    if (loginButton != null) {
                        loginButton.setReadPermissions("public_profile", "email", "user_friends");

                        if (CommonUtil.isConnectingToInternet(LoginActivity.this)) {
                            loginButton.performClick();

                            loginButton.setPressed(true);

                            loginButton.invalidate();

                            loginButton.registerCallback(callbackManager, mCallBack);

                            loginButton.setPressed(false);

                            loginButton.invalidate();
                        }
                    }
                }
            }
        });

In Facebook example also having an issue :
GitHub link of Facebook example

Steps to reproduce :

Launch the app Login with Facebook Authenticate FB profile.

Un_install the app and install again.

Now try to  Login with Facebook.

The above error will occur. because we already authenticated so need to access fb profile. but here we facing the issue.

Here already authenticated page is not showing.

I am using Native FB app with the device Xiaomi Redmi Note 3

Body:
I refer this,

https://developers.facebook.com/docs/android/getting-started

or just add below code in onCreate() method, which will return key hash.

 // Add code to print out the key hash
try {
    PackageInfo info = getPackageManager().getPackageInfo(
            "com.facebook.samples.hellofacebook",
            PackageManager.GET_SIGNATURES);
    for (Signature signature : info.signatures) {
        MessageDigest md = MessageDigest.getInstance("SHA");
        md.update(signature.toByteArray());
        Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
        }
} catch (NameNotFoundException e) {

} catch (NoSuchAlgorithmException e) {

}

Add above code to retrieve key,that key you can store

https://developers.facebook.com/docs/facebook-login/android

here. Now It will work.

It worked for me, hope will work for you too.

OR

This command may not give you latest keyhash.

keytool -exportcert -alias YOUR_RELEASE_KEY_ALIAS -keystore YOUR_RELEASE_KEY_PATH | openssl sha1 -binary | openssl base64

To get latest or active keyhash from android studio search 'hash'  in your android studio's Logcat or android monitor while app is running and throwing above error. You will get different keyhash which is active. After pasting this searched keyhash in your console setting you may log be able to your app.


问:
Q: I can't understand "var variable = {" in jquery
I'm modifying the jQuery source code which another person has programmed.

But there was a var definition which I can't understand.

I had no idea about this code, so I googled and searching, but couldn't find any answers.

js

```<code>var isMobile = {
  Android: function() {
    return navigator.userAgent.match(/Android/i);
  },
    BlackBerry: function() {
    return navigator.userAgent.match(/BlackBerry/i);
  },
    iOS: function() {
    return navigator.userAgent.match(/iPhone|iPad|iPod/i);
  },
    Opera: function() {
    return navigator.userAgent.match(/Opera Mini/i);
  },
    Windows: function() {
    return navigator.userAgent.match(/IEMobile/i);
  },
    any: function() {
    return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
  }
};
</code>```

I want to know what does this code mean.

Also, I'd like to know the syntax, such as

js

```<code> var isMobile = {
   Android: function() {
     return window.navigator.userAgent.match(/Android/i);
 },
</code>```

What Android: means?

答:
This code is defining an object and assigning it to a variable named “isMobile”.

“Android” is a property of that object, and its value is a function.

The function performs a test on the browser’s user agent string to determine whether it is running in an android browser.

All of this together allows other code to determine whether it’s running in an android browser by calling isMobile.Android().

Or iOS by calling isMobile.iOS(), and so on.

isMobile.any() iterates over the other functions, invoking them to see if any of them are true; so if you want to know if you’re running on a mobile device but don’t care specifically which kind, you’d use this.

Every browser provides a variable called navigator that contains information about the browser, including a userAgent property that gives clues about which browser and version it is. I'm running Brave, and here's what navigator looks like for me. I've highlighted the userAgent part.

userAgent values can be kind of infuriating. I'm running Brave but the userAgent string mentions Mozilla, Gecko, Chrome, and Safari. Ugh. But that's a whole other can of worms.

As I said, you can look for clues about what browser you're running in this value. To do so, this code is using regular expressions. Regular expressions are a powerful pattern-matching syntax used to find substrings or patterns within strings. Far too complicated for me to explain in detail here, but as an example, the expression userAgent.match(/iPhone|iPad|iPod/i) is looking for any of the words "iPhone", "iPad", or "iPod" in the userAgent value. (The part between the slashes is the pattern, and the trailing i is a flag to make the search case-insensitive.)

Body:
I'm modifying the jQuery source code which another person has programmed.

But there was a var definition which I can't understand.

I had no idea about this code, so I googled and searching, but couldn't find any answers.

js

var isMobile = {
  Android: function() {
    return navigator.userAgent.match(/Android/i);
  },
    BlackBerry: function() {
    return navigator.userAgent.match(/BlackBerry/i);
  },
    iOS: function() {
    return navigator.userAgent.match(/iPhone|iPad|iPod/i);
  },
    Opera: function() {
    return navigator.userAgent.match(/Opera Mini/i);
  },
    Windows: function() {
    return navigator.userAgent.match(/IEMobile/i);
  },
    any: function() {
    return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
  }
};

I want to know what does this code mean.

Also, I'd like to know the syntax, such as

js

 var isMobile = {
   Android: function() {
     return window.navigator.userAgent.match(/Android/i);
 },

What Android: means?


问:
Could not resolve all files for configuration ':app:debugCompileClasspath'. > Could not find com.android.support:support-v4:28.1.0
Im facing this problem after upgrade react-native 0.59 to build 32 bit and 64 bit version

error when i try do run-android :

error when i do ./gradlew installDebug --info

this my code for build.gradle

buildscript {
    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.google.com'
            name 'Google'
        }

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0'
        classpath 'com.google.gms:google-services:4.0.1'
        classpath 'com.github.triplet.gradle:play-publisher:1.2.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

def googlePlayServicesVersion = '15.0.1'

allprojects {
    repositories {
    google()
    mavenLocal()
    jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
        maven { url "https://jitpack.io" }
        maven {
            url 'https://maven.google.com'
            name 'Google'
        }
        configurations.all {
            resolutionStrategy {
                force "com.google.android.gms:play-services-vision:$googlePlayServicesVersion"
            }
        }
    }
}

ext {
    buildToolsVersion = "28.0.3"
    minSdkVersion = 16
    compileSdkVersion = 26
    targetSdkVersion = 26
    supportLibVersion = "26.1.0"
}```
</div>
</div>
</p>

<p><code>app/build.gradle</code></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>implementation project(':react-native-vector-icons')
    implementation project(':react-native-splash-screen')
    implementation project(':react-native-sqlite-storage')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
    implementation 'com.android.support:support-v4:28.1.0.'
    implementation "com.facebook.react:react-native:+"  // From node_modules

    implementation ('com.android.support:exifinterface:26.0.0-alpha1') {
        force = true;
    }

    implementation "com.google.android.gms:play-services-base:15.0.1"
    implementation "com.google.firebase:firebase-core:16.0.1"
    implementation "com.google.firebase:firebase-messaging:17.1.0"
}</code>```

react-native-cli: 2.0.1

react-native: 0.59.0-rc.3

答:
Add google() to below:

```<code>allprojects {
    repositories {
        google() // <=== here
        jcenter()
    }
}
</code>```

Body:
Im facing this problem after upgrade react-native 0.59 to build 32 bit and 64 bit version

error when i try do run-android :

error when i do ./gradlew installDebug --info

this my code for build.gradle

buildscript {
    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.google.com'
            name 'Google'
        }

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0'
        classpath 'com.google.gms:google-services:4.0.1'
        classpath 'com.github.triplet.gradle:play-publisher:1.2.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

def googlePlayServicesVersion = '15.0.1'

allprojects {
    repositories {
    google()
    mavenLocal()
    jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
        maven { url "https://jitpack.io" }
        maven {
            url 'https://maven.google.com'
            name 'Google'
        }
        configurations.all {
            resolutionStrategy {
                force "com.google.android.gms:play-services-vision:$googlePlayServicesVersion"
            }
        }
    }
}

ext {
    buildToolsVersion = "28.0.3"
    minSdkVersion = 16
    compileSdkVersion = 26
    targetSdkVersion = 26
    supportLibVersion = "26.1.0"
}

app/build.gradle

implementation project(':react-native-vector-icons')
    implementation project(':react-native-splash-screen')
    implementation project(':react-native-sqlite-storage')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
    implementation 'com.android.support:support-v4:28.1.0.'
    implementation "com.facebook.react:react-native:+"  // From node_modules

    implementation ('com.android.support:exifinterface:26.0.0-alpha1') {
        force = true;
    }

    implementation "com.google.android.gms:play-services-base:15.0.1"
    implementation "com.google.firebase:firebase-core:16.0.1"
    implementation "com.google.firebase:firebase-messaging:17.1.0"
}

react-native-cli: 2.0.1

react-native: 0.59.0-rc.3

Body:
Add google() to below:

allprojects {
    repositories {
        google() // <=== here
        jcenter()
    }
}


答:
isMobile is returning an object with key-value pairs. The keys are, e.g. Android, and Blackberry, and their values are basically methods/functions that are only invoked when you try to access them. E.g. by invoking isMobile.Android() will actually invoke the function and check if the user agent matches a string of your choice.

You can see isMobile as an object with methods accessible by keys, which you can call to check if the browser's user agents matches certain criteria.

Title: Q: I can't understand "var variable = {" in jquery


问:
What does Liskov Substitution Principle preserve?
As I've read the substitution of objects of a concrete type by instances of a subclass of that concrete type must preserve a program's correctness, a program's invariants.

I'd like to know what exactly is meant by correctness and invariants of a program?

答:
Let's say you have a class Animal and someone asks you what it's supposed to do, what it can be used for, and how you can judge whether or not it is correctly implemented.  Imagine that you gave a complete and detailed answer that didn't leave anything out.  Now...

If class Cow is a subclass of class Animal, then everything in your answer about Animal must also apply to Cow.


问:
Switch to tab 2 from a button on tab 1 using angular-mat-tab
I am using angular material mat-tab content.

My code looks like -

<mat-tab-group>
  <mat-tab label="First"> Content 1 </mat-tab>
  <mat-tab label="Second"> Content 2 </mat-tab>
  <mat-tab label="Third"> Content 3 </mat-tab>
</mat-tab-group>
```

<p>I want to implement something like</p>

<pre class="lang-html prettyprint-override"><code><mat-tab-group>
  <mat-tab label="First">
      <button mat-button>Go to tab 2</button>
      <button mat-button>Go to tab 3</button>
  </mat-tab>
  <mat-tab label="Second">
      <button mat-button>Go to tab 1</button>
  </mat-tab>
  <mat-tab label="Third">
      <button mat-button>Go to tab 1</button>
  </mat-tab>
</mat-tab-group>

</code>```

How to implement this functionality of on clicking on buttons it should go to different tabs?

答:
We can use tab group template reference to change the selected index of the tab

<mat-tab-group #tabGroup>
  <mat-tab label="First">
     <button mat-button (click)="tabGroup.selectedIndex=1">Go to tab 2</button>
     <button mat-button (click)="tabGroup.selectedIndex=2">Go to tab 3</button>
  </mat-tab>
  <mat-tab label="Second">
     <button mat-button (click)="tabGroup.selectedIndex=0">Go to tab 1</button>
  </mat-tab>
  <mat-tab label="Third">
     <button mat-button (click)="tabGroup.selectedIndex=0">Go to tab 1</button>
  </mat-tab>
</mat-tab-group>

```

Body:
I am using angular material mat-tab content.

My code looks like -

<mat-tab-group>
  <mat-tab label="First"> Content 1 </mat-tab>
  <mat-tab label="Second"> Content 2 </mat-tab>
  <mat-tab label="Third"> Content 3 </mat-tab>
</mat-tab-group>

I want to implement something like

<mat-tab-group>
  <mat-tab label="First">
      <button mat-button>Go to tab 2</button>
      <button mat-button>Go to tab 3</button>
  </mat-tab>
  <mat-tab label="Second">
      <button mat-button>Go to tab 1</button>
  </mat-tab>
  <mat-tab label="Third">
      <button mat-button>Go to tab 1</button>
  </mat-tab>
</mat-tab-group>

How to implement this functionality of on clicking on buttons it should go to different tabs?


问:
Group by a column in Hive
I am trying to write a hive query to solve the below problem. Can I get some pointers on solving the problem?

I have a sale table with 3 columns (ID, codes, amount). I want to group by ID column, and have the codes and amount related to an ID, in a single row.

Sample Input

```<code>ID  codes   amount

100  20      30
100  10      15
100  11      12
200  30      40
200  40      50
</code>```

Expected Output

```<code>Id  code1 code2 code3 amount1 amount2 amount3

100  20    10    11     30      15      12
200  30    40           40      50
</code>```

答: you need to do  you can get more detail  </p>

Title: Group by a column in Hive

Body:
I am trying to write a hive query to solve the below problem. Can I get some pointers on solving the problem?

I have a sale table with 3 columns (ID, codes, amount). I want to group by ID column, and have the codes and amount related to an ID, in a single row.

Sample Input

ID  codes   amount

100  20      30
100  10      15
100  11      12
200  30      40
200  40      50

Expected Output

Id  code1 code2 code3 amount1 amount2 amount3

100  20    10    11     30      15      12
200  30    40           40      50

Body: you need to do  you can get more detail


答:
There is no 28.1.0 of support-v4. The latest version of com.android.support:support-v4 is 28.0.0 as per maven.google.com:

```<code>implementation 'com.android.support:support-v4:28.0.0'
</code>```

Title: Could not resolve all files for configuration ':app:debugCompileClasspath'. > Could not find com.android.support:support-v4:28.1.0

Body:
There is no 28.1.0 of support-v4. The latest version of com.android.support:support-v4 is 28.0.0 as per maven.google.com:

implementation 'com.android.support:support-v4:28.0.0'


问:
Android MotionLayout setGuidelinePercent not working on alpha4 release
I have a MotionLayout for a swipe transition in my app. Currently I just updated from 2.0.0-alpha3 to 2.0.0-alpha4 release and some things are not working as before.
There is "myView" which is a layout that should expand from the bottom of the screen to a header view. It has a constraint top to a Guideline which I need to control programmatically (based on some user actions).

There were no other changes in the code, so downgrading to alpha3 makes everything work as expected.

The code is pretty basic:

<MotionScene xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:motion="http://schemas.android.com/apk/res-auto">

    <Transition
        motion:constraintSetEnd="@id/end"
        motion:constraintSetStart="@id/start"
        motion:duration="1000"
        motion:interpolator="linear">

        <OnSwipe
            motion:dragDirection="dragUp"
            motion:touchAnchorId="@id/myView"
            motion:touchAnchorSide="top" />

    </Transition>

    <ConstraintSet android:id="@+id/start">
        <Constraint
            android:id="@id/myView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            motion:layout_constraintStart_toStartOf="parent"
            motion:layout_constraintTop_toTopOf="@id/myGuideline" />
    </ConstraintSet>

    <ConstraintSet android:id="@+id/end">
        <Constraint
            android:id="@id/myView"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            motion:layout_constraintBottom_toBottomOf="parent"
            motion:layout_constraintStart_toStartOf="parent"
            motion:layout_constraintTop_toBottomOf="@id/someHeaderView" />
    </ConstraintSet>
</MotionScene>
```

<p>The problem is that in release alpha3, I could use something like this(and it worked):</p>

```myMotionLayout.getConstraintSet(R.id.start)?.setGuidelinePercent(R.id.myGuideline, guidelinePercentage)
```

<p>Now that I upgraded to <code>2.0.0-alpha4</code>, this is no longer working and I can't understand why. It always takes the default one, from the xml and is never changed whenever I try to do it dynamically.</p>

<p>What I'm trying to do is to change the starting point of the transition based on some dynamic data (available at the beginning of the Fragment or when the user is returning to it). If you have a better idea of how I can implement this using MotionLayout, please give me a hint.</p>

<p>Gradle implementation:</p>

```implementation "com.android.support.constraint:constraint-layout:2.0.0-alpha4"
```

答:
I noticed a similar regression introduced in the alpha4 release. Through trial and error, and the following bug report, I was able to get my ConstraintSet changes to be applied programatically in a MotionLayout (beta1 release). It appears the clone method does not work for MotionLayout, and getConstraintSet should be used instead (as you've done). Looks like the step you're missing is constraintSet.applyTo(motion_layout). I also needed to re-apply the MotionLayout description xml at the end.

implementation
  "androidx.constraintlayout:constraintlayout:2.0.0-beta1"

Steps:

```<code>val constraintSet = motion_layout.getConstraintSet(R.id.motion_layout)
constraintSet.clear(R.id.txt_view, ConstraintSet.BOTTOM)
constraintSet.applyTo(motion_layout)
// If using a MotionLayout description xml file, re-apply it
motion_explore_article.loadLayoutDescription(R.xml.slide_over_image)
</code>```

Bug report:
https://issuetracker.google.com/issues/131874827

Body:
I have a MotionLayout for a swipe transition in my app. Currently I just updated from 2.0.0-alpha3 to 2.0.0-alpha4 release and some things are not working as before.
There is "myView" which is a layout that should expand from the bottom of the screen to a header view. It has a constraint top to a Guideline which I need to control programmatically (based on some user actions).

There were no other changes in the code, so downgrading to alpha3 makes everything work as expected.

The code is pretty basic:

<MotionScene xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:motion="http://schemas.android.com/apk/res-auto">

    <Transition
        motion:constraintSetEnd="@id/end"
        motion:constraintSetStart="@id/start"
        motion:duration="1000"
        motion:interpolator="linear">

        <OnSwipe
            motion:dragDirection="dragUp"
            motion:touchAnchorId="@id/myView"
            motion:touchAnchorSide="top" />

    </Transition>

    <ConstraintSet android:id="@+id/start">
        <Constraint
            android:id="@id/myView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            motion:layout_constraintStart_toStartOf="parent"
            motion:layout_constraintTop_toTopOf="@id/myGuideline" />
    </ConstraintSet>

    <ConstraintSet android:id="@+id/end">
        <Constraint
            android:id="@id/myView"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            motion:layout_constraintBottom_toBottomOf="parent"
            motion:layout_constraintStart_toStartOf="parent"
            motion:layout_constraintTop_toBottomOf="@id/someHeaderView" />
    </ConstraintSet>
</MotionScene>

The problem is that in release alpha3, I could use something like this(and it worked):

myMotionLayout.getConstraintSet(R.id.start)?.setGuidelinePercent(R.id.myGuideline, guidelinePercentage)

Now that I upgraded to 2.0.0-alpha4, this is no longer working and I can't understand why. It always takes the default one, from the xml and is never changed whenever I try to do it dynamically.

What I'm trying to do is to change the starting point of the transition based on some dynamic data (available at the beginning of the Fragment or when the user is returning to it). If you have a better idea of how I can implement this using MotionLayout, please give me a hint.

Gradle implementation:

implementation "com.android.support.constraint:constraint-layout:2.0.0-alpha4"

Body:
I noticed a similar regression introduced in the alpha4 release. Through trial and error, and the following bug report, I was able to get my ConstraintSet changes to be applied programatically in a MotionLayout (beta1 release). It appears the clone method does not work for MotionLayout, and getConstraintSet should be used instead (as you've done). Looks like the step you're missing is constraintSet.applyTo(motion_layout). I also needed to re-apply the MotionLayout description xml at the end.

implementation
  "androidx.constraintlayout:constraintlayout:2.0.0-beta1"

Steps:

val constraintSet = motion_layout.getConstraintSet(R.id.motion_layout)
constraintSet.clear(R.id.txt_view, ConstraintSet.BOTTOM)
constraintSet.applyTo(motion_layout)
// If using a MotionLayout description xml file, re-apply it
motion_explore_article.loadLayoutDescription(R.xml.slide_over_image)

Bug report:
https://issuetracker.google.com/issues/131874827


答:
You need to update so many things in your configuration.

First, update google service version to 4.2.0 by updating this

```<code>classpath 'com.google.gms:google-services:4.2.0'
</code>```

Also, update the build configuration

```<code>ext {
    buildToolsVersion = "28.0.3"
    minSdkVersion = 16
    compileSdkVersion = 28
    targetSdkVersion = 28
    supportLibVersion = "28.0.0"
}
</code>```

And the dependency update

```<code>implementation 'com.android.support:appcompat-v7:28.0.0' // 28.0.0 is now live
implementation 'com.android.support:support-v4:28.0.0' // instead 28.1.0
</code>```

Body:
You need to update so many things in your configuration.

First, update google service version to 4.2.0 by updating this

classpath 'com.google.gms:google-services:4.2.0'

Also, update the build configuration

ext {
    buildToolsVersion = "28.0.3"
    minSdkVersion = 16
    compileSdkVersion = 28
    targetSdkVersion = 28
    supportLibVersion = "28.0.0"
}

And the dependency update

implementation 'com.android.support:appcompat-v7:28.0.0' // 28.0.0 is now live
implementation 'com.android.support:support-v4:28.0.0' // instead 28.1.0


问:
Delphi Network programming
I have a classic client/server (fat client and database) program written in Delphi 2006. When certain conditions are met in the client, I need to notify all the other clients very quickly. Up until now this has been done using UDP broadcasts, but this is no longer viable as clients now connect from outside the LAN and the UDP broadcast is limited to the local network.

I'm aware of the Indy libraries but am not really sure of which components to use and how to structure it. I'm guessing I'll need to have a server that the clients connect to which will receive and distribute the messages...? Any samples out there to get me started?

Are there any other component sets or technologies I should look at instead/as well?

答:
FirebirdSQL project use the concept of notifications as being server-client connections that send a string to the client. For this, the db server uses an other port. And require the client to register it's interesting of receiving a certain type of notification through an API call.

You could use the same idea.

OwnerDisplayName: Marius

ContentLicense: CC BY-SA 2.5

Title: Delphi Network programming

LastEditorDisplayName: Jim McKeeth

OwnerDisplayName: Fabricio Araujo


问:
How to import xml package to databricks
Any one follow the following links before about xml
https://github.com/databricks/spark-xml

I just keep having problem on importing import com.databricks.spark.xml._

Error

My databricks version

Actually I also want to know how to install the package

```<code>$SPARK_HOME/bin/spark-shell --packages com.databricks:spark-xml_2.12:0.5.0
</code>```

答:
Use this dependency in Android Studio:

```<code>// https://mvnrepository.com/artifact/com.databricks/spark-xml
compile group: 'com.databricks', name: 'spark-xml_2.12', version: '0.5.0'
</code>```

For further assistance, follow this link:

https://mvnrepository.com/artifact/com.databricks

Title: How to import xml package to databricks

Body:
Any one follow the following links before about xml
https://github.com/databricks/spark-xml

I just keep having problem on importing import com.databricks.spark.xml._

Error

My databricks version

Actually I also want to know how to install the package

$SPARK_HOME/bin/spark-shell --packages com.databricks:spark-xml_2.12:0.5.0

Body:
Use this dependency in Android Studio:

// https://mvnrepository.com/artifact/com.databricks/spark-xml
compile group: 'com.databricks', name: 'spark-xml_2.12', version: '0.5.0'

For further assistance, follow this link:

https://mvnrepository.com/artifact/com.databricks


问:
traversing object in react but exiting due to return statement issue
I have a react component that is accepting a json object from an api call. I want to traverse the folder/file json object and render them inside the component return statement in a tree manor. I am calling the traveseFolder cunction within the html of react componenet. I want it traverse through the ojbect and render each objects name and path with each iteration. I noticed that they only way for me to render is to return the div that is dynamically generated. The issue is that the return call is exiting the traversal function. How can i get around this to render and then keep going through the function...

here is my code:

```<code>    const traverseFolder = (current:any) => {
        console.log(current)
        for(let i = 0; i < current.length; i++){
            // console.log(current[i]['text'])
            if(current[i]){
                console.log(current[i])
                if(current[i]['children'].length > 0){
                    console.log('# of children: ' + current[i]['children'].length)
                    console.log('folder found: ' + current[i]['text'])
                    return(
                        <div>
                            <span>{current[i]['text']}</span>
                        </div>
                    )
                    for(let j = 0; j < current[i]['children'].length; j++){
                        traverseFolder(current[i]['children'][j])
                    }
                }
                if(current[i]['children'].length === 0){
                    console.log('file found: ' + current[i]['text'])
                    return(
                        <div>
                            <span>{current[i]['text']}</span>
                            <span>{current[i]['path']}</span>
                        </div>
                    )
                }
            }
        }
    }

    return (
        <Dialog
            className={classNames(themeClass, styles.helpDialog)}
            title="Help"
            icon="help"
            isOpen={isOpen}
            onClose={mainStore.hideHelpDialog}
        >
        <div>
            {
                folderLoading ? (
                    <div>
                        {
                            traverseFolder(files)
                        }
                    </div>
                ) : (
                    <Spinner />
                )
            }

        </div>
        </Dialog>
    );
</code>```

答:
Here case is you are returning dom and code below return statement is not executing. You can add folder travarsel logic inside return statement. Code can be done as follow.</p>

```<code>const traverseFolder = (current:any) => {
        console.log(current)
        for(let i = 0; i < current.length; i++){
            // console.log(current[i]['text'])
            if(current[i]){
                console.log(current[i])
                if(current[i]['children'].length > 0){
                    console.log('# of children: ' + current[i]['children'].length)
                    console.log('folder found: ' + current[i]['text'])
                    return(
                        <div>
                            <span>{current[i]['text']}</span>
                            {
                              current[i]['children'].map((ele) =>
                                traverseFolder(ele)
                            }
                        </div>
                    )
                }
                if(current[i]['children'].length === 0){
                    console.log('file found: ' + current[i]['text'])
                    return(
                        <div>
                            <span>{current[i]['text']}</span>
                            <span>{current[i]['path']}</span>
                        </div>
                    )
                }
            }
        }
    }

    return (
        <Dialog
            className={classNames(themeClass, styles.helpDialog)}
            title="Help"
            icon="help"
            isOpen={isOpen}
            onClose={mainStore.hideHelpDialog}
        >
        <div>
            {
                folderLoading ? (
                    <div>
                        {
                            traverseFolder(files)
                        }
                    </div>
                ) : (
                    <Spinner />
                )
            }

        </div>
        </Dialog>
    );
</code>```

Body:
I have a react component that is accepting a json object from an api call. I want to traverse the folder/file json object and render them inside the component return statement in a tree manor. I am calling the traveseFolder cunction within the html of react componenet. I want it traverse through the ojbect and render each objects name and path with each iteration. I noticed that they only way for me to render is to return the div that is dynamically generated. The issue is that the return call is exiting the traversal function. How can i get around this to render and then keep going through the function...

here is my code:

    const traverseFolder = (current:any) => {
        console.log(current)
        for(let i = 0; i < current.length; i++){
            // console.log(current[i]['text'])
            if(current[i]){
                console.log(current[i])
                if(current[i]['children'].length > 0){
                    console.log('# of children: ' + current[i]['children'].length)
                    console.log('folder found: ' + current[i]['text'])
                    return(

                            {current[i]['text']}

                    )
                    for(let j = 0; j < current[i]['children'].length; j++){
                        traverseFolder(current[i]['children'][j])
                    }
                }
                if(current[i]['children'].length === 0){
                    console.log('file found: ' + current[i]['text'])
                    return(

                            {current[i]['text']}
                            {current[i]['path']}

                    )
                }
            }
        }
    }

    return (
        <Dialog
            className={classNames(themeClass, styles.helpDialog)}
            title="Help"
            icon="help"
            isOpen={isOpen}
            onClose={mainStore.hideHelpDialog}
        >

            {
                folderLoading ? (

                        {
                            traverseFolder(files)
                        }

                ) : (
                    <Spinner />
                )
            }

        </Dialog>
    );

Body:
Here case is you are returning dom and code below return statement is not executing. You can add folder travarsel logic inside return statement. Code can be done as follow.

const traverseFolder = (current:any) => {
        console.log(current)
        for(let i = 0; i < current.length; i++){
            // console.log(current[i]['text'])
            if(current[i]){
                console.log(current[i])
                if(current[i]['children'].length > 0){
                    console.log('# of children: ' + current[i]['children'].length)
                    console.log('folder found: ' + current[i]['text'])
                    return(
                        <div>
                            <span>{current[i]['text']}</span>
                            {
                              current[i]['children'].map((ele) =>
                                traverseFolder(ele)
                            }
                        </div>
                    )
                }
                if(current[i]['children'].length === 0){
                    console.log('file found: ' + current[i]['text'])
                    return(
                        <div>
                            <span>{current[i]['text']}</span>
                            <span>{current[i]['path']}</span>
                        </div>
                    )
                }
            }
        }
    }

    return (
        <Dialog
            className={classNames(themeClass, styles.helpDialog)}
            title="Help"
            icon="help"
            isOpen={isOpen}
            onClose={mainStore.hideHelpDialog}
        >
        <div>
            {
                folderLoading ? (
                    <div>
                        {
                            traverseFolder(files)
                        }
                    </div>
                ) : (
                    <Spinner />
                )
            }

        </div>
        </Dialog>
    );


问:
Angularjs Custom Directive not changing DOM

Use ng-if in Angularjs Directive

I have a showTaskDetailView$ stream that I can subscribe to and I can push a boolean value through it.

```<code>angular.module('Project').directive('something', () => {
    return {
        restrict: 'E',
        template: '<div>something: {{toggleValue}}</div>',
        replace: true,
        link() {
            something();
            function something() {
                showTaskDetailView$.subscribe(value => {
                    let toggleValue = value;
                    console.log(toggleValue);
                });
            }
        }
    };
});
</code>```

When I run this directive and I change the showTaskDetailView$ value I see the new value in my console.log. But nothing is happening in the DOM.

答:
Your toggleValue is a local variable and not binded to $scope. For DOM to update you need to add toggelValue on $scope.

Change your link function to:

```<code>link(scope) {
        something();
        function something() {
            showTaskDetailView$.subscribe(value => {
                scope.toggleValue = value; <-------------
                console.log(scope.toggleValue);
            });
        }
    }
</code>```

Now you should see the updated DOM. Read more here:

Body:
Use ng-if in Angularjs Directive

I have a showTaskDetailView$ stream that I can subscribe to and I can push a boolean value through it.

angular.module('Project').directive('something', () => {
    return {
        restrict: 'E',
        template: '
something: {{toggleValue}}
',
        replace: true,
        link() {
            something();
            function something() {
                showTaskDetailView$.subscribe(value => {
                    let toggleValue = value;
                    console.log(toggleValue);
                });
            }
        }
    };
});

When I run this directive and I change the showTaskDetailView$ value I see the new value in my console.log. But nothing is happening in the DOM.

Body:
Your toggleValue is a local variable and not binded to $scope. For DOM to update you need to add toggelValue on $scope.

Change your link function to:

link(scope) {
        something();
        function something() {
            showTaskDetailView$.subscribe(value => {
                scope.toggleValue = value; <-------------
                console.log(scope.toggleValue);
            });
        }
    }

Now you should see the updated DOM. Read more here:


问:
multiple iteration is done for creating the generic filters
I am trying to develop a generic filter component which can have many fields to filter on like color,
size, price range etc and each field might have different types of elements like color may have
checkboxes, radio button and price range might have input element, dropdown etc. To support such varied
cases, I tried to go with this pattern but here I have to iterate the same things multiple times.

I am not sure of this data structure. If anyone has suggestion please help me to improve this code but
the main problem here is "multiple iteration". How can i improve this code?

```<code>const filterParams = {
  field: {
    id     : 1, label  : 'Field', content: <FieldFilter />
  },
  employee: {
    id     : 1, label  : 'Employee', content: <Employee />
  }
}

<Filter filterParams={filterParams} activeFilterParam="field" />
</code>```

```<code>const Filter = ({ filterParams, activeFilterParam }) => {
  const [show, setShow]=useState(false)
  return (
    <>
      <Button secondary icon={filter} onClick={() => setShow(!show)}>Filter</Button>
      {show && (
        <Card style={{ marginTop: 10 }}>
          <Card.Content>
            <Tabs activeTab={activeFilterParam}>
              <Tabs.List
                render={() => {
                  return (
                    Object.keys(filterParams).map(filterParam => {
                      return (
                        <Tabs.Tab key={filterParam} id={filterParam}>{filterParams[filterParam].label}</Tabs.Tab>
                      )
                    }))
                }} />
              <Tabs.Panels>
                {Object.keys(filterParams).map(filterParam => {
                  return (
                    <Tabs.Panel key={filterParam} panelId={filterParam}>{filterParams[filterParam].content}</Tabs.Panel>
                  )
                })}
              </Tabs.Panels>
            </Tabs>
          </Card.Content>
          <Card.Footer>
            <Button>
              <Button.Content style={{ marginRight: 10 }}>Save</Button.Content>
              <Button.Content secondary onClick={()=>setShow(!show)}>Cancel</Button.Content>
            </Button>
          </Card.Footer>
        </Card>
      )}
    </>
  )
}
</code>```

答:
If you're not liking the multiple calls to Object.keys(filterParams).map, you could move the loop to the top of the component function.  Something like the below might work:

```<code>const Filter = ({ filterParams, activeFilterParam }) => {
  const [show, setShow]=useState(false)

  const {tabs, panels} = Object.keys(filterParams)
    .reduce((acc, filterParam) => {
      acc.tabs.push(
        <Tabs.Tab key={filterParam} id={filterParam}>{filterParams[filterParam].label}</Tabs.Tab>
      );
      acc.panels.push(
        <Tabs.Panel key={filterParam} panelId={filterParam}>{filterParams[filterParam].content}</Tabs.Panel>
      );
      return acc;
    }, { tabs: [], panels: [] });

  return (
    ...
        <Card style={{ marginTop: 10 }}>
          <Card.Content>
            <Tabs activeTab={activeFilterParam}>
              <Tabs.List render={() => tabs} />
              <Tabs.Panels>
                {panels}
              </Tabs.Panels>
            </Tabs>
            ...
        </Card>
    ...
  )
}

</code>```

Note that I haven't run this - it likely won't be quite right, but should give the general idea...

Body:
I am trying to develop a generic filter component which can have many fields to filter on like color,
size, price range etc and each field might have different types of elements like color may have
checkboxes, radio button and price range might have input element, dropdown etc. To support such varied
cases, I tried to go with this pattern but here I have to iterate the same things multiple times.

I am not sure of this data structure. If anyone has suggestion please help me to improve this code but
the main problem here is "multiple iteration". How can i improve this code?

const filterParams = {
  field: {
    id     : 1, label  : 'Field', content: <FieldFilter />
  },
  employee: {
    id     : 1, label  : 'Employee', content: <Employee />
  }
}

<Filter filterParams={filterParams} activeFilterParam="field" />

const Filter = ({ filterParams, activeFilterParam }) => {
  const [show, setShow]=useState(false)
  return (
    <>
      <Button secondary icon={filter} onClick={() => setShow(!show)}>Filter</Button>
      {show && (
        <Card style={{ marginTop: 10 }}>
          <Card.Content>
            <Tabs activeTab={activeFilterParam}>
              <Tabs.List
                render={() => {
                  return (
                    Object.keys(filterParams).map(filterParam => {
                      return (
                        <Tabs.Tab key={filterParam} id={filterParam}>{filterParams[filterParam].label}</Tabs.Tab>
                      )
                    }))
                }} />
              <Tabs.Panels>
                {Object.keys(filterParams).map(filterParam => {
                  return (
                    <Tabs.Panel key={filterParam} panelId={filterParam}>{filterParams[filterParam].content}</Tabs.Panel>
                  )
                })}
              </Tabs.Panels>
            </Tabs>
          </Card.Content>
          <Card.Footer>
            <Button>
              <Button.Content style={{ marginRight: 10 }}>Save</Button.Content>
              <Button.Content secondary onClick={()=>setShow(!show)}>Cancel</Button.Content>
            </Button>
          </Card.Footer>
        </Card>
      )}
    </>
  )
}

Body:
If you're not liking the multiple calls to Object.keys(filterParams).map, you could move the loop to the top of the component function.  Something like the below might work:

const Filter = ({ filterParams, activeFilterParam }) => {
  const [show, setShow]=useState(false)

  const {tabs, panels} = Object.keys(filterParams)
    .reduce((acc, filterParam) => {
      acc.tabs.push(
        <Tabs.Tab key={filterParam} id={filterParam}>{filterParams[filterParam].label}</Tabs.Tab>
      );
      acc.panels.push(
        <Tabs.Panel key={filterParam} panelId={filterParam}>{filterParams[filterParam].content}</Tabs.Panel>
      );
      return acc;
    }, { tabs: [], panels: [] });

  return (
    ...
        <Card style={{ marginTop: 10 }}>
          <Card.Content>
            <Tabs activeTab={activeFilterParam}>
              <Tabs.List render={() => tabs} />
              <Tabs.Panels>
                {panels}
              </Tabs.Panels>
            </Tabs>
            ...
        </Card>
    ...
  )
}

Note that I haven't run this - it likely won't be quite right, but should give the general idea...


问:
Push JHipster 6.0.1 to Gitlab repository
After having everything ready to deploy, I realized JHipster doesn't have a Dockerfile anymore and the packaging is done with jib. The generated gitlab-ci.yml has a docker-push stage with a command like this:

```<code>./mvnw jib:build -Djib.to.image=$IMAGE_TAG -Djib.to.auth.username=gitlab-ci-token  -Djib.to.auth.password=$CI_BUILD_TOKEN
</code>```

but it fails with

```<code>[ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:0.9.11:build (default-cli) on project test-project: Obtaining project build output files failed; make sure you have compiled your project before trying to build the image. (Did you accidentally run "mvn clean jib:build" instead of "mvn clean compile jib:build"?): /builds/amatos/test-project/target/classes -> [Help 1]
</code>```

As that failed, I tried to run the command locally like this:

```<code>./mvnw jib:build -Djib.to.image=registry.gitlab.com/amatos/test-project:v6.0.1 -Djib.to.auth.username=amatos -Djib.to.auth.password=password
</code>```

but instead of trying to connect to Gitlab's registry, it tries to connect to registry.hub.docker.com:

```<code>[INFO] Retrieving registry credentials for registry.hub.docker.com...
</code>```

What I would like to know is: how do I set it to connect to Gitlab instead of Docker Hub?

答:
This is followed by jhipster/generator-jhipster issue 9761 which states:

as the docker-push is done in another stage, there is a missing - target/classes in the previous stage.

  It is needed by jib. It should look like:

```<code>maven-package:
  stage: package
  script:
    - ./mvnw verify -Pprod -DskipTests -Dmaven.repo.local=$MAVEN_USER_HOME
  artifacts:
    paths:
      - target/*.jar
      - target/classes
    expire_in: 1 day
</code>```

Possibly addressed by PR (merged) 9762, commit 50cc009, which is only in master, not yet referenced by any tag.

Body:
After having everything ready to deploy, I realized JHipster doesn't have a Dockerfile anymore and the packaging is done with jib. The generated gitlab-ci.yml has a docker-push stage with a command like this:

./mvnw jib:build -Djib.to.image=$IMAGE_TAG -Djib.to.auth.username=gitlab-ci-token  -Djib.to.auth.password=$CI_BUILD_TOKEN

but it fails with

[ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:0.9.11:build (default-cli) on project test-project: Obtaining project build output files failed; make sure you have compiled your project before trying to build the image. (Did you accidentally run "mvn clean jib:build" instead of "mvn clean compile jib:build"?): /builds/amatos/test-project/target/classes -> [Help 1]

As that failed, I tried to run the command locally like this:

./mvnw jib:build -Djib.to.image=registry.gitlab.com/amatos/test-project:v6.0.1 -Djib.to.auth.username=amatos -Djib.to.auth.password=password

but instead of trying to connect to Gitlab's registry, it tries to connect to registry.hub.docker.com:

[INFO] Retrieving registry credentials for registry.hub.docker.com...

What I would like to know is: how do I set it to connect to Gitlab instead of Docker Hub?

Body:
This is followed by jhipster/generator-jhipster issue 9761 which states:

as the docker-push is done in another stage, there is a missing - target/classes in the previous stage.

  It is needed by jib. It should look like:

maven-package:
  stage: package
  script:
    - ./mvnw verify -Pprod -DskipTests -Dmaven.repo.local=$MAVEN_USER_HOME
  artifacts:
    paths:
      - target/*.jar
      - target/classes
    expire_in: 1 day

Possibly addressed by PR (merged) 9762, commit 50cc009, which is only in master, not yet referenced by any tag.


问:
Model Relationships not finding the property
I'm trying to create a relationship between two models. My first model is the User Model, the second one is Company.

I tried adding in the User model the hasMany('App\Comapny') property, and in the Company one, belongsTo('App\User').

// In User Model

```<code>public function companies(){
    return $this->hasMany('App\Company');
}
</code>```

// In Company Model

```<code>public function user(){
    return $this->belongsTo('App\User');
}
</code>```

// And in the controller:

```<code>$user_id = auth()->user('id');
$user = User::find($user_id);
return view('devices.show')->with('companies', $user->companies);
</code>```

It should return an array with all the companies that my User has when using "$user->comapnies", however, it returns this message instead:

Property [companies] does not exist on this collection instance.

Thanks, any help is welcome

答:
Try this,

```<code>$user_id = auth()->user->id;
$user = User::with('companies')->where('id', $user_id)->first();
return view('devices.show', compact('user'));
</code>```

Then you can access the company relation with
$user->company[index]->
in the view.

Body:
I'm trying to create a relationship between two models. My first model is the User Model, the second one is Company.

I tried adding in the User model the hasMany('App\Comapny') property, and in the Company one, belongsTo('App\User').

// In User Model

public function companies(){
    return $this->hasMany('App\Company');
}

// In Company Model

public function user(){
    return $this->belongsTo('App\User');
}

// And in the controller:

$user_id = auth()->user('id');
$user = User::find($user_id);
return view('devices.show')->with('companies', $user->companies);

It should return an array with all the companies that my User has when using "$user->comapnies", however, it returns this message instead:

Property [companies] does not exist on this collection instance.

Thanks, any help is welcome

Body:
Try this,

$user_id = auth()->user->id;
$user = User::with('companies')->where('id', $user_id)->first();
return view('devices.show', compact('user'));

Then you can access the company relation with
$user->company[index]->
in the view.


问:
How to give priority order for cucumber after hooks
I have implemented some cucumber after hooks. But without the priority order, I can not control which After hooks should run first. Sample code as follows

```<code>defineSupportCode(({ After, Before }) => {
After({ tags: '@dismiss_alert_after' }, () => {
    ActionUtil.click(element(by.partialButtonText('Okay')));
});

After(function (testCase: TestCase) {
    const signout: Signout = new Signout();
    return !(testCase.result.status === 'failed') ?
 signout.signoutApplication() : Promise.resolve();
    });
 });
</code>```

The ends of the test steps execution, first it's should execute the hook '@dismiss_alert_after' for scenarios which tagged as '@dismiss_alert_after' and after that, it should run the signout hook. But it's doesn't. How can I control the order of the hooks? Help much appreciated. Thanks

答:
After hooks are executed in the reverse order that they are defined.

https://github.com/cucumber/cucumber-js/blob/master/docs/support_files/api_reference.md

In Java is possible to configure the step order passing it as argument in the hook annotation, but I've not found docs about it in js, so I suppose it is not supported

Body:
I have implemented some cucumber after hooks. But without the priority order, I can not control which After hooks should run first. Sample code as follows

defineSupportCode(({ After, Before }) => {
After({ tags: '@dismiss_alert_after' }, () => {
    ActionUtil.click(element(by.partialButtonText('Okay')));
});

After(function (testCase: TestCase) {
    const signout: Signout = new Signout();
    return !(testCase.result.status === 'failed') ?
 signout.signoutApplication() : Promise.resolve();
    });
 });

The ends of the test steps execution, first it's should execute the hook '@dismiss_alert_after' for scenarios which tagged as '@dismiss_alert_after' and after that, it should run the signout hook. But it's doesn't. How can I control the order of the hooks? Help much appreciated. Thanks


问:
How to calculate inverse modular exponentation in c?
I want to take modular inverse(k≥1) of integer and then multiply the result to another integer, as explain in following expression:

```<code>result=((x^(-k)))*y mod z
</code>```

How can i implement this expression, where k≥1?

答:
You need to define four function:

```<code>uint64_t modular_exponentiation(uint64_t x, uint64_t y, uint64_t z)
{
    uint64_t res = 1;
    x = x % z;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1; // y = y/2
        x = (x*x) % z;
    }
    return res;
}

uint64_t moduloMultiplication(uint64_t a, uint64_t b,uint64_t z)
{
  uint64_t res = 0;
  a %= z;

  while (b)
  {
     if (b & 1)
        res = (res + a) % z;

     a = (2 * a) % p;
     b >>= 1;  // b = b / 2
   }
  return res;
}

void extendedEuclid(uint64_t A, uint64_t B)
{
uint64_t temp;
    if(B == 0)
    {
        d = A;
        x = 1;
        y = 0;
    }
    else
    {
        extendedEuclid(B,A%B);
        temp = x;
        x = y;
        y = temp - (A/B)*y;
    }
}

int modInverse(uint64_t A, uint64_t M)
{
    extendedEuclid(A,M);
    if (x < 0)
        x += M;
    return (x);
}
</code>```

In main():

```<code>uint64_t result=0x00;
result=modular_exponentiation(x,k,z);   // (x^k) mod z
result=modInverse(result,z);            // ((x^k)^-1) mod z == x^(-k) mod z
result=moduloMultiplication(result,y,z);// x^(-k) * y mod z
</code>```

Body:
I want to take modular inverse(k≥1) of integer and then multiply the result to another integer, as explain in following expression:

result=((x^(-k)))*y mod z

How can i implement this expression, where k≥1?

Body:
You need to define four function:

uint64_t modular_exponentiation(uint64_t x, uint64_t y, uint64_t z)
{
    uint64_t res = 1;
    x = x % z;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1; // y = y/2
        x = (x*x) % z;
    }
    return res;
}

uint64_t moduloMultiplication(uint64_t a, uint64_t b,uint64_t z)
{
  uint64_t res = 0;
  a %= z;

  while (b)
  {
     if (b & 1)
        res = (res + a) % z;

     a = (2 * a) % p;
     b >>= 1;  // b = b / 2
   }
  return res;
}

void extendedEuclid(uint64_t A, uint64_t B)
{
uint64_t temp;
    if(B == 0)
    {
        d = A;
        x = 1;
        y = 0;
    }
    else
    {
        extendedEuclid(B,A%B);
        temp = x;
        x = y;
        y = temp - (A/B)*y;
    }
}

int modInverse(uint64_t A, uint64_t M)
{
    extendedEuclid(A,M);
    if (x < 0)
        x += M;
    return (x);
}

In main():

uint64_t result=0x00;
result=modular_exponentiation(x,k,z);   // (x^k) mod z
result=modInverse(result,z);            // ((x^k)^-1) mod z == x^(-k) mod z
result=moduloMultiplication(result,y,z);// x^(-k) * y mod z


问:
Android studio keep importing old version of libraries
Android studio keeps importing old version of libraries even though my gradle are updated.

I'm trying to import the new notification builder

I'm trying to import the new notification builder but then my project won't give me the updated version of the library

I have these in my gradle :

```<code> implementation 'com.android.support:support-compat:28.0.0'
 implementation 'com.android.support:appcompat-v7:28.0.0'
</code>```

what else am I missing?
why is it keeps importing 25.3.0 library if I have 28.0.0 in my gradle

答: Try to clean up your .gradle and .idea directory under your project root directory.

Body:
Android studio keeps importing old version of libraries even though my gradle are updated.

I'm trying to import the new notification builder

I'm trying to import the new notification builder but then my project won't give me the updated version of the library

I have these in my gradle :

 implementation 'com.android.support:support-compat:28.0.0'
 implementation 'com.android.support:appcompat-v7:28.0.0'

what else am I missing?
why is it keeps importing 25.3.0 library if I have 28.0.0 in my gradle


问:
Running RabbitMQ+Celery in the same server as production environment
I'm running a Django app in an EC2 instance, which uses RabbitMQ + Celery for task queuing. Are there any drawbacks to running my RabbitMQ node from the same EC2 instance as my production app?</p>

答:
TLDR; If you can run on one EC2 you should but make it easy to scale today.

Both Joshnidhin and Giannis covered the RAM, IO and CPU aspects.

I have run production apps in single instances with containerization and slept with peace of mind that if tomorrow suddenly lots of people want what I have built, I can scale pretty quickly by deploying those containers on different instances instead of one single instance.

Docker allows you to put a limit on CPU consumption and memory usage for each container hence you can also be sure that they will not step into each other.

ContentLicense: CC BY-SA 3.0


答:
You will need the extended greatest common divisor to compute the inverse of x for modulus z. When x and zare relatively prime you have a * x + b * z = 1 = gcd(x, z). And thus, a * x = 1 - b * z or a * x = 1 mod z, and a is the inverse to x in the modulus z.

Now you may compute result with x^-1 = a mod z:

```<code>result = power(a, k) * y % z
</code>```

with ordinary integer arithmetic in C, where power() is the ordinary integer exponentiation.

Since the coefficients in such calculations can become very large very quickly, it is better to use ready-made libraries (e.g. gmp).

Title: How to calculate inverse modular exponentation in c?

Body:
You will need the extended greatest common divisor to compute the inverse of x for modulus z. When x and zare relatively prime you have a * x + b * z = 1 = gcd(x, z). And thus, a * x = 1 - b * z or a * x = 1 mod z, and a is the inverse to x in the modulus z.

Now you may compute result with x^-1 = a mod z:

result = power(a, k) * y % z

with ordinary integer arithmetic in C, where power() is the ordinary integer exponentiation.

Since the coefficients in such calculations can become very large very quickly, it is better to use ready-made libraries (e.g. gmp).


问:
React App shows a blank page when uploaded on Github , used the npm run deploy method
I am new to programming, can't really figure out where I made the mistake, I have attached the GitHub repository link, I just want to show my little project to my friends, hope I can get some help with that
https://github.com/cyumair/reactapp

package.json file

```<code>{
  "name": "friends",
  "version": "0.1.0",
  "private": true,
  "homepage": "https://github.com/cyumair/reactapp.git",
  "dependencies": {
    "gh": "^1.17.5",
    "pages": "0.0.16",
    "react": "^16.8.6",
    "react-dom": "^16.8.6",
    "react-router-dom": "^5.0.0",
    "react-scripts": "3.0.1",
    "tachyons": "^4.11.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "predeploy": "npm run build",
    "deploy": "gh-pages -d build"
  },
</code>```

答:
First, you should remove gh and pages and then, npm i -D gh-pages

Second, you should edit homepage: ./

and you may upload your website on GitHub.

In addition, this is my package.json

```<code>{
  "name": "my-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "lodash-es": "^4.17.11",
    "node-sass": "^4.11.0",
    "react": "^16.8.6",
    "react-dom": "^16.8.6",
    "react-redux": "^7.0.2",
    "react-scripts": "2.1.8",
    "react-spring": "^8.0.19",
    "react-swipe-card": "^0.1.4",
    "react-with-gesture": "^4.0.8",
    "redux": "^4.0.1",
    "redux-actions": "^2.6.5",
    "redux-saga": "^1.0.2",
    "vec-la": "^1.5.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "deploy": "gh-pages -d build"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ],
  "devDependencies": {
    "gh-pages": "^2.0.1"
  }
}
</code>```

Body:
I am new to programming, can't really figure out where I made the mistake, I have attached the GitHub repository link, I just want to show my little project to my friends, hope I can get some help with that
https://github.com/cyumair/reactapp

package.json file

{
  "name": "friends",
  "version": "0.1.0",
  "private": true,
  "homepage": "https://github.com/cyumair/reactapp.git",
  "dependencies": {
    "gh": "^1.17.5",
    "pages": "0.0.16",
    "react": "^16.8.6",
    "react-dom": "^16.8.6",
    "react-router-dom": "^5.0.0",
    "react-scripts": "3.0.1",
    "tachyons": "^4.11.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "predeploy": "npm run build",
    "deploy": "gh-pages -d build"
  },

Body:
First, you should remove gh and pages and then, npm i -D gh-pages

Second, you should edit homepage: ./

and you may upload your website on GitHub.

In addition, this is my package.json

{
  "name": "my-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "lodash-es": "^4.17.11",
    "node-sass": "^4.11.0",
    "react": "^16.8.6",
    "react-dom": "^16.8.6",
    "react-redux": "^7.0.2",
    "react-scripts": "2.1.8",
    "react-spring": "^8.0.19",
    "react-swipe-card": "^0.1.4",
    "react-with-gesture": "^4.0.8",
    "redux": "^4.0.1",
    "redux-actions": "^2.6.5",
    "redux-saga": "^1.0.2",
    "vec-la": "^1.5.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "deploy": "gh-pages -d build"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ],
  "devDependencies": {
    "gh-pages": "^2.0.1"
  }
}


问:
Getting object name in Objective-c
suppose i have a class Foo and an instance of this class myFoo:

```<code>Foo *myFoo;
</code>```

is there any method "dispalyFooObjectName" that can display the name of the object, for exmample :

```<code>NSLog(@"i was called from %s", [myFoo dispalyFooObjectName]);
</code>```

and the result will be :

```<code>i was called from myFoo
</code>```

答:
you can try this. override -(NSstring*)description  method like this

```<code>- (NSString*)description {
     return [NSString stringWithFormat:@"I'm called from foo"];//You can also print object's properties description here.
  }
</code>```

and use like this

```<code> NSLog(@"my Foo object %@",[myFoo description]);
</code>```

Title: Getting object name in Objective-c

Body:
suppose i have a class Foo and an instance of this class myFoo:

Foo *myFoo;

is there any method "dispalyFooObjectName" that can display the name of the object, for exmample :

NSLog(@"i was called from %s", [myFoo dispalyFooObjectName]);

and the result will be :

i was called from myFoo

Body:
you can try this. override -(NSstring*)description  method like this

- (NSString*)description {
     return [NSString stringWithFormat:@"I'm called from foo"];//You can also print object's properties description here.
  }

and use like this

 NSLog(@"my Foo object %@",[myFoo description]);


问:
I am getting dimension mismatch when creating a sequential model in tensorflow
Whenever I add a flatten layer between dense layers in sequential model or when I add a MaxPooling1D after a flatten layer, I am getting an error which looks like this:

Input 0 is incompatible with layer : expected ndim=3,
  found ndim=2

Here are my models where I found these errors:

```<code>#Model 1
model = Sequential()
from keras.layers import Flatten,Dense,MaxPooling1D
model.add(Flatten(input_shape=(28,28)))
model.add(Dense(256,activation="relu"))
model.add(Flatten())
model.add(Dense(128,activation="relu"))
model.add(Dense(64,activation="relu"))
model.add(Dense(10,activation="softmax"))

#Model2
model = Sequential()
from keras.layers import Flatten,Dense,MaxPooling1D
model.add(Flatten(input_shape=(28,28)))
model.add(MaxPooling1D(2))
model.add(Dense(256,activation="relu"))
model.add(Dense(128,activation="relu"))
model.add(Dense(64,activation="relu"))
model.add(Dense(10,activation="softmax"))
</code>```

I am using these models to work on fashion MNIST dataset where the input shape is 28X28.

Also, can anyone explain where did I go wrong when I am creating this model?
Thanks for the help.

答:
I hope you are using Keras with Tensorflow as backend. You have to expand dimensions of the image using numpy expand dimension function like</p>

```<code>import numpy as np

image=np.expand_dims(image,axis=0)
model.predict(image)
</code>```

Body:
Whenever I add a flatten layer between dense layers in sequential model or when I add a MaxPooling1D after a flatten layer, I am getting an error which looks like this:

Input 0 is incompatible with layer : expected ndim=3,
  found ndim=2

Here are my models where I found these errors:

#Model 1
model = Sequential()
from keras.layers import Flatten,Dense,MaxPooling1D
model.add(Flatten(input_shape=(28,28)))
model.add(Dense(256,activation="relu"))
model.add(Flatten())
model.add(Dense(128,activation="relu"))
model.add(Dense(64,activation="relu"))
model.add(Dense(10,activation="softmax"))

#Model2
model = Sequential()
from keras.layers import Flatten,Dense,MaxPooling1D
model.add(Flatten(input_shape=(28,28)))
model.add(MaxPooling1D(2))
model.add(Dense(256,activation="relu"))
model.add(Dense(128,activation="relu"))
model.add(Dense(64,activation="relu"))
model.add(Dense(10,activation="softmax"))

I am using these models to work on fashion MNIST dataset where the input shape is 28X28.

Also, can anyone explain where did I go wrong when I am creating this model?
Thanks for the help.

Body:
I hope you are using Keras with Tensorflow as backend. You have to expand dimensions of the image using numpy expand dimension function like

import numpy as np

image=np.expand_dims(image,axis=0)
model.predict(image)