问:
Why does the App engine (python3 - standard environment) generate aborted connections when connecting to a cloud sql -2nd Gen Mysql instance?
I'm currently developing a project with python 3.7, Django 2.1, Mysql as database.

I'm deploying it in google cloud app engine standard environment and for the database I'm using a cloud SQL - MySql 2nd gen instance.

The application works well, however when I analyze the logs I see these errors:

"aborted connection - Got an error reading communication packets"

In this case the connection is being closed by my app (django).If I configure my app to have persistent connections and I put wait_timeout (i.e 60) in the config of the cloud sql, the error is:

"aborted connection - Got timeout reading communication packets".

I just determined that it's not a problem with sql cloud, or with the configuration of my application, but that it's an app engine problem. I came to this conclusion in the following way:

if I connect to the sql cloud instance through Mysql workbench, no connection is aborted

Similarly if I run my application on a local server, but connecting to cloud sql (through the cloud_sql_proxy), no error is generated and everything works perfect.

So my conclusion is that it is a problem of how the app engine connects to the cloud sql instance.

Why does this happen? How could it be solved?

答:
The "Aborted connection" messages you're seeing, are usually triggered when a connection is closed improperly or there is a networking anomaly between the server and the client.

Sometimes Cloud SQL instances and GAE have long-live idle connections. In order to address this issue, it is recommended to set "wait_timeout' flag below 600 seconds - as you've already attempted to do so.

Another possible solution, is to implement application-level keepalives. SQLAlchemy provides “pre-ping” for this. Otherwise, generate activity on all open connections by sending a simple SQL statement such as "SELECT 1;" regularly, at least once every 5 minutes. Also consider using statements in your code like “with db.connect() as conn:” to control the connection’s lifetime.


来源: stackexchange

问:
Are non-generic collections in .NET obsolete?
Put differently:

Is there a good reason to choose a loosely-typed collection over a type-safe one (HashTable vs. Dictionary)? Are they still there only for compatibility?

As far as I understand, generic collections not only are type-safe, but their performance is better.

Here's a comprehensive article on the topic: An Extensive Examination of Data Structures Using C# 2.0.

答:
With regard to using non-generic collections for storing heterogeneous collections of stuff, you can always use List<object> to accomplish the same thing.  For this reason alone, I'd say there's almost no reason at all to touch the non-generic collections ever again.

The exception to this would be to maintain compatibility with systems written in other languages, or against previous versions of the .NET framework, but that's a pretty "edgy" case if you ask me.

OwnerDisplayName: guillermooo

ContentLicense: CC BY-SA 3.0

LastEditorDisplayName: guillermooo

OwnerDisplayName: Mel

ContentLicense: CC BY-SA 2.5


问:
Resizing image with ImageMagick and Ruby on Rails
I have been trying to use Imagemagick to resize images uploaded by a user as a square.

Currently, I am using the ! like so - 640x640!

This works fine if the image i feed it is a resolution of 640x640 or bigger - it resizes and makes it into a square as expected.

The problem is that if either the height or width of the image is smaller than 640, then it wont square it out. For instance if the image is 480x600, it wont do anything to the image. Similarly if the image is 680x456 then it will resize it to 640x456

How can i make it so that it will always square the image to a maximum size of 640x640? If the image is greater than 640x640, then i want it to resize to 640x640. If the image is smaller than 640x640, i.e. 480x600, i want it to resize to 480x480

I'm doing it in rails, within the paperclip attachment definition, like this:

```<code>has_attached_file :avatar, :styles => { :medium => "640x640!", :thumb => "150x150!" }, :default_url => "/images/:style/missing.png"
</code>```

答:
First, Require the library

```<code>  require 'rubygems'
  require 'mini_magick'
</code>```

Second, You have to get the image first

```<code>image = MiniMagick::Image.open("PathOfTheImage")
</code>```

Next, resize it

```<code>image.resize "640x640!"
</code>```

finally, save the image

```<code>image.write "output.png"
</code>```

and use the output image afterwards.

Body:
I have been trying to use Imagemagick to resize images uploaded by a user as a square.

Currently, I am using the ! like so - 640x640!

This works fine if the image i feed it is a resolution of 640x640 or bigger - it resizes and makes it into a square as expected.

The problem is that if either the height or width of the image is smaller than 640, then it wont square it out. For instance if the image is 480x600, it wont do anything to the image. Similarly if the image is 680x456 then it will resize it to 640x456

How can i make it so that it will always square the image to a maximum size of 640x640? If the image is greater than 640x640, then i want it to resize to 640x640. If the image is smaller than 640x640, i.e. 480x600, i want it to resize to 480x480

I'm doing it in rails, within the paperclip attachment definition, like this:

has_attached_file :avatar, :styles => { :medium => "640x640!", :thumb => "150x150!" }, :default_url => "/images/:style/missing.png"

Body:
First, Require the library

  require 'rubygems'
  require 'mini_magick'

Second, You have to get the image first

image = MiniMagick::Image.open("PathOfTheImage")

Next, resize it

image.resize "640x640!"

finally, save the image

image.write "output.png"

and use the output image afterwards.

ContentLicense: CC BY-SA 4.0


问:
"How do I display the cout<<"Fever"; because I am not familiar with string array and it is stuck at the selection part also?
```<code>string sick[5] = { "FEVER","FLUE","FOOD POISONING" };

for (int r = 0; r < 5; r++)
{
    if(sick[r].compare("FEVER") == 0)
    {
        found = true;
        cout << "Fever";
    }
}
</code>```

答:
Just use operator== and output directly with a new-line, something like:

```<code>if (sick[r] == "FEVER")
{
    found = true;
    cout << sick[r] << '\n';
}
</code>```

Body:
Just use operator== and output directly with a new-line, something like:

if (sick[r] == "FEVER")
{
    found = true;
    cout << sick[r] << '\n';
}


问:
How to convert dynamically generated javascript table into json/xml and how to save that file?
I've a function in javascript which creates table of properties dynamically:

```<code>// update table
PropertyWindow.prototype._update = function (text) {

  if (text === void 0) { text = "<no properties to display>"; }
  this._propertyWindow.html(text);

};
PropertyWindow.prototype._onModelStructureReady = function () {

  this._assemblyTreeReadyOccurred = true;
  this._update();

};
// create row for property table
PropertyWindow.prototype._createRow = function (key, property, classStr) {

  if (classStr === void 0) { classStr = ""; }
  var tableRow = document.createElement("tr");
  tableRow.id = "propertyTableRow_" + key + "_" + property;
  if (classStr.length > 0) {
    tableRow.classList.add(classStr);
  }
  var keyDiv = document.createElement("td");
  keyDiv.id = "propertyDiv_" + key;
  keyDiv.innerHTML = key;
  var propertyDiv = document.createElement("td");
  propertyDiv.id = "propertyDiv_" + property;
  propertyDiv.innerHTML = property;
  tableRow.appendChild(keyDiv);
  tableRow.appendChild(propertyDiv);

  return tableRow;
};
</code>```

I want to take that generated table into json/xml and save this into a new file, how would I do this?

答:
You can basically loop through the generated table like below and convert it into json with the following code

```<code>var myRows = [];
var $headers = $("th");
//your table path here inside the selector
var $rows = $("tbody tr").each(function(index) {
  $cells = $(this).find("td");
  myRows[index] = {};
  $cells.each(function(cellIndex) {
    myRows[index][$($headers[cellIndex]).html()] = $(this).html();
  });
});

// Let's put this in the object like you want and convert to JSON (Note: jQuery will also do this for you on the Ajax request)
var myObj = {};
myObj.myrows = myRows;
alert(JSON.stringify(myObj));
</code>```

Possible duplicate

Body:
I've a function in javascript which creates table of properties dynamically:

// update table
PropertyWindow.prototype._update = function (text) {

  if (text === void 0) { text = "<no properties to display>"; }
  this._propertyWindow.html(text);

};
PropertyWindow.prototype._onModelStructureReady = function () {

  this._assemblyTreeReadyOccurred = true;
  this._update();

};
// create row for property table
PropertyWindow.prototype._createRow = function (key, property, classStr) {

  if (classStr === void 0) { classStr = ""; }
  var tableRow = document.createElement("tr");
  tableRow.id = "propertyTableRow_" + key + "_" + property;
  if (classStr.length > 0) {
    tableRow.classList.add(classStr);
  }
  var keyDiv = document.createElement("td");
  keyDiv.id = "propertyDiv_" + key;
  keyDiv.innerHTML = key;
  var propertyDiv = document.createElement("td");
  propertyDiv.id = "propertyDiv_" + property;
  propertyDiv.innerHTML = property;
  tableRow.appendChild(keyDiv);
  tableRow.appendChild(propertyDiv);

  return tableRow;
};

I want to take that generated table into json/xml and save this into a new file, how would I do this?

Body:
You can basically loop through the generated table like below and convert it into json with the following code

var myRows = [];
var $headers = $("th");
//your table path here inside the selector
var $rows = $("tbody tr").each(function(index) {
  $cells = $(this).find("td");
  myRows[index] = {};
  $cells.each(function(cellIndex) {
    myRows[index][$($headers[cellIndex]).html()] = $(this).html();
  });
});

// Let's put this in the object like you want and convert to JSON (Note: jQuery will also do this for you on the Ajax request)
var myObj = {};
myObj.myrows = myRows;
alert(JSON.stringify(myObj));

Possible duplicate


问:
Chrome Extension - not sending cookies in the request
I've read tons of questions on SO, tried multiple things but to no luck. My question would be similar, but I'm posting because I've tried everything but still not succeeded.

I want to check whether there's a user session maintained at my server. I've a webservice which returns a boolean value, based on the cookies received.

It's the responsibility of the browser to send cookies (if any) while requesting the server. So, when I request via the chrome-extension, theoretically the browser should send along the cookies too. However, it does not.

Here's my code:-

content.js

```<code>fetch('https://zoffers.in/apis/shops/get_aff_url/', {
    credentials: 'include',
    mode: 'cors',
    async: false,
    method: 'POST',
    headers: {
        'Content-Type': 'application/json'
    },
    body: JSON.stringify({
        name: 'Hubot',
        login: 'hubot',
    })
})
.then(function(data) {

})
.catch(function(error) {

})
</code>```

Manifest.json

```<code>{
    "manifest_version": 2,
    "version": "0.1",
    "content_scripts": [{
        "matches": [
            "https://*/*/"
        ],
        "js": ["js/content.js"],
        "run_at": "document_start"
    }],
    "browser_action": {
        // "default_icon": "icon.png",
        "default_popup": "popup.html",
        "default_title": "Click here!"
    },
    "permissions": [
        "identity",
        "identity.email",
        "tabs",
        "notifications",
        "cookies",
        "https://zoffers.in/"
    ]
}
</code>```

What wrong am I doing? Can anyone please help me through it.

UPDATED

content.js

```<code>message = {
    'event_type': 'Event1',
}
chrome.runtime.sendMessage(message);
</code>```

background.js

```<code>chrome.runtime.onMessage.addListener(
    function(request, sender, sendResponse){
        if(request.event_type === 'Event1'){
            chrome.tabs.query({active: true, currentWindow: true}, function(tabs){
                fetch('https://zoffers.in/apis/shops/get_aff_url/', {
                    credentials: 'include',
                    mode: 'cors',
                    async: false,
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json'
                    },
                    body: JSON.stringify({
                        name: 'Hubot',
                        login: 'hubot',
                    })
                })
                .then(function(data) {

                })
                .catch(function(error) {

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

Have added background.js to manifest.json file. But still not working.

答: You can use standard Cookies api and access cookies for any URL that is available.</p>

Body:
I've read tons of questions on SO, tried multiple things but to no luck. My question would be similar, but I'm posting because I've tried everything but still not succeeded.

I want to check whether there's a user session maintained at my server. I've a webservice which returns a boolean value, based on the cookies received.

It's the responsibility of the browser to send cookies (if any) while requesting the server. So, when I request via the chrome-extension, theoretically the browser should send along the cookies too. However, it does not.

Here's my code:-

content.js

fetch('https://zoffers.in/apis/shops/get_aff_url/', {
    credentials: 'include',
    mode: 'cors',
    async: false,
    method: 'POST',
    headers: {
        'Content-Type': 'application/json'
    },
    body: JSON.stringify({
        name: 'Hubot',
        login: 'hubot',
    })
})
.then(function(data) {

})
.catch(function(error) {

})

Manifest.json

{
    "manifest_version": 2,
    "version": "0.1",
    "content_scripts": [{
        "matches": [
            "https://*/*/"
        ],
        "js": ["js/content.js"],
        "run_at": "document_start"
    }],
    "browser_action": {
        // "default_icon": "icon.png",
        "default_popup": "popup.html",
        "default_title": "Click here!"
    },
    "permissions": [
        "identity",
        "identity.email",
        "tabs",
        "notifications",
        "cookies",
        "https://zoffers.in/"
    ]
}

What wrong am I doing? Can anyone please help me through it.

UPDATED

content.js

message = {
    'event_type': 'Event1',
}
chrome.runtime.sendMessage(message);

background.js

chrome.runtime.onMessage.addListener(
    function(request, sender, sendResponse){
        if(request.event_type === 'Event1'){
            chrome.tabs.query({active: true, currentWindow: true}, function(tabs){
                fetch('https://zoffers.in/apis/shops/get_aff_url/', {
                    credentials: 'include',
                    mode: 'cors',
                    async: false,
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json'
                    },
                    body: JSON.stringify({
                        name: 'Hubot',
                        login: 'hubot',
                    })
                })
                .then(function(data) {

                })
                .catch(function(error) {

                })
            }
        }
    }
);

Have added background.js to manifest.json file. But still not working.


问:
Angular 7- How to sum time string elements of two arrays?
I have two arrays of different time string.

```<code>startingTime: string["09:00:00", "5:50:00", "6:30:00"];
duration: string["0:15:00", "01:00:00", "01:00:00"];
</code>```

I want to sum these arrays in final like

```<code>endingTime: string ["09:15:00", "6:50:00", "7:30:00"]
</code>```

I'm building Single page application using angular 7,trying to use momentjs but not sure how to implement it.
I would appreciate any help.

答:
```<code>addTimes(start, end) {
  var a = start.split(":");
  var seconds = (+a[0]) * 60 * 60 + (+a[1]) * 60 + (+a[2]);
  var b = end.split(":");
  var seconds2 = (+b[0]) * 60 * 60 + (+b[1]) * 60 + (+b[2]);

  var date = new Date(1970, 0, 1);
  date.setSeconds(seconds + seconds2);
  var c = date.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1");
  return c;
}

addDurationToHours() {
  let hours = ["09:00:00", "5:50:00", "6:30:00"];
  let duration = ["0:15:00", "01:00:00", "01:00:00"];

  let newArray = [];
  hours.forEach( ( hour, index ) => {
    newArray.push( this.addTimes(hour, duration[index]))
  })
  console.log ( newArray )
  return newArray;
}
</code>```

I referred Adding HH:MM:SS strings in Javascript for addTimes() method

Body:
I have two arrays of different time string.

startingTime: string["09:00:00", "5:50:00", "6:30:00"];
duration: string["0:15:00", "01:00:00", "01:00:00"];

I want to sum these arrays in final like

endingTime: string ["09:15:00", "6:50:00", "7:30:00"]

I'm building Single page application using angular 7,trying to use momentjs but not sure how to implement it.
I would appreciate any help.

Body:
addTimes(start, end) {
  var a = start.split(":");
  var seconds = (+a[0]) * 60 * 60 + (+a[1]) * 60 + (+a[2]);
  var b = end.split(":");
  var seconds2 = (+b[0]) * 60 * 60 + (+b[1]) * 60 + (+b[2]);

  var date = new Date(1970, 0, 1);
  date.setSeconds(seconds + seconds2);
  var c = date.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1");
  return c;
}

addDurationToHours() {
  let hours = ["09:00:00", "5:50:00", "6:30:00"];
  let duration = ["0:15:00", "01:00:00", "01:00:00"];

  let newArray = [];
  hours.forEach( ( hour, index ) => {
    newArray.push( this.addTimes(hour, duration[index]))
  })
  console.log ( newArray )
  return newArray;
}

I referred Adding HH:MM:SS strings in Javascript for addTimes() method


问:
Is there any way I can load a class in webworker instead of just plain javascript file?
I want to load a file in webworker but its not a plain javascript file. It is a class. So, instead of writing javascript file url in
    new Worker(filename.js);

I am initializing the class by writing
    new Worker(new ClassName());

It is reading the file and loading it properly. It even shows the console.log message in constructor. But when the control moves to postMessage method in main file, it throws error.

The application I am working on has a very complex structure. We have a common module that contains several classes which are executing some common functionalities throughout the application. The functionality I am working on can cause the performance issues if I execute it directly in the application. So, I am loading it in a webworker. Since its a class so I have to invoke it using new keyword. So instead of:

```<code>var ww = new Worker(filename.js);
</code>```

I am writing:

```<code>var ww = new Worker(new ClassName());
</code>```

Now, it invokes the class, it console logs the statement written in constructor but when in the main file it executes postMessage, javascript throws an error and stops the method from execution.

See the code below:

mainFile.js

```<code>    var ww = new Worker(new CommonWebWorker());
        ww.postMessage('LOAD');
        ww.onmessage = function (e) {
            console.log(e.data);
    }
</code>```

CommonWebWorker.js

```<code>'use strict';

class CommonWebWorker {
    constructor() {
        console.log("commonWebWorker invoked");
        this.onmessage = function (e) {
            this.postMessage((e.data === 'LOAD' ? 'Loading...' : 'Loading Error'));
        }
    }
}

module.exports = CommonWebWorker;
</code>```

I expect that the file will load in the background through WebWorker but actually it is breaking and throwing below mentioned error

GET http://localhost:3000/[object%20Object] 404 (Not Found)

Any kind of help is much appreciated.

答:
The reason for the error is that Worker expects a URL string as its first parameter, not an object. So it converts it to a string, and when you do that on most objects you get "[object Object]" (although I would have expected "[object CommonWebWorker]" from your code, but I assume you're using a transpiler or something outputting ES5 code, which would give you "[object Object]" instead).

Your main page and your work are completely different JavaScript environments. You can certainly use a class in your worker if you want, but you'd need to instantiate it in the worker, e.g.:

```<code>class CommonWebWorker {
 // ...
}
new CommonWebWorker(); // To instantiate it
</code>```

Your worker can also import the class from another JavaScript file via importScripts (before too long it'll be able to use ES2015+ module syntax instead), so if you want to use the same class in multiple workers, you could put it in its own file and do:

```<code>importScripts("common-web-worker.js");
new CommonWebWorker(); // To instantiate it
</code>```

Once ES2015+ syntax is widely available in workers¹, you'd start your worker with the relevant module flag (new Worker("worker.js", {type: "module"})), and do this instead:

```<code>import CommonWebWorker from "./common-web-worker.js";
new CommonWebWorker();
</code>```

¹ I checked just a month ago or so, and the only browser supporting it was Chrome behind a --enable-experimental-web-platform-features flag. But this stuff changes fast... :-)

Body:
I want to load a file in webworker but its not a plain javascript file. It is a class. So, instead of writing javascript file url in
    new Worker(filename.js);

I am initializing the class by writing
    new Worker(new ClassName());

It is reading the file and loading it properly. It even shows the console.log message in constructor. But when the control moves to postMessage method in main file, it throws error.

The application I am working on has a very complex structure. We have a common module that contains several classes which are executing some common functionalities throughout the application. The functionality I am working on can cause the performance issues if I execute it directly in the application. So, I am loading it in a webworker. Since its a class so I have to invoke it using new keyword. So instead of:

var ww = new Worker(filename.js);

I am writing:

var ww = new Worker(new ClassName());

Now, it invokes the class, it console logs the statement written in constructor but when in the main file it executes postMessage, javascript throws an error and stops the method from execution.

See the code below:

mainFile.js

    var ww = new Worker(new CommonWebWorker());
        ww.postMessage('LOAD');
        ww.onmessage = function (e) {
            console.log(e.data);
    }

CommonWebWorker.js

'use strict';

class CommonWebWorker {
    constructor() {
        console.log("commonWebWorker invoked");
        this.onmessage = function (e) {
            this.postMessage((e.data === 'LOAD' ? 'Loading...' : 'Loading Error'));
        }
    }
}

module.exports = CommonWebWorker;

I expect that the file will load in the background through WebWorker but actually it is breaking and throwing below mentioned error

GET http://localhost:3000/[object%20Object] 404 (Not Found)

Any kind of help is much appreciated.

Body:
The reason for the error is that Worker expects a URL string as its first parameter, not an object. So it converts it to a string, and when you do that on most objects you get "[object Object]" (although I would have expected "[object CommonWebWorker]" from your code, but I assume you're using a transpiler or something outputting ES5 code, which would give you "[object Object]" instead).

Your main page and your work are completely different JavaScript environments. You can certainly use a class in your worker if you want, but you'd need to instantiate it in the worker, e.g.:

class CommonWebWorker {
 // ...
}
new CommonWebWorker(); // To instantiate it

Your worker can also import the class from another JavaScript file via importScripts (before too long it'll be able to use ES2015+ module syntax instead), so if you want to use the same class in multiple workers, you could put it in its own file and do:

importScripts("common-web-worker.js");
new CommonWebWorker(); // To instantiate it

Once ES2015+ syntax is widely available in workers¹, you'd start your worker with the relevant module flag (new Worker("worker.js", {type: "module"})), and do this instead:

import CommonWebWorker from "./common-web-worker.js";
new CommonWebWorker();

¹ I checked just a month ago or so, and the only browser supporting it was Chrome behind a --enable-experimental-web-platform-features flag. But this stuff changes fast... :-)


问:
How to sent id from one page to another when click on submit?
I have a database which consists of question_id, question, and options. Where I'll display the question and options. When the user clicked on submit I want to store the option they clicked and the question_id.
I am able to store the option they clicked but want to know how to store the question_id.

```<code>$user_email = $_SESSION['email'];
$query1="SELECT * FROM votes WHERE user_email='$user_email'";
$query2="SELECT * FROM poll_question WHERE status='1'";
$fetch2 = mysqli_query($con,$query2);
<html>
  <head>
    <body>
      <div class="container">
        <br />
        <br />
        <br />
        <div class="row">
          <div class="col-md-6">
          <?

            while( $row2 = mysqli_fetch_array($fetch2))
            {
             ?>
              <form method="post" class="poll_form">
                <h3><?echo $row2['question']?>?</h3>
                <br />
                <div class="radio">
                 <label><h4><input type="radio" name="poll_option" class="poll_option" value=<?echo $row2['option1']?> /><?echo $row2['option1']?></h4></label>
                </div>
                <div class="radio">
                 <label><h4><input type="radio" name="poll_option" class="poll_option" value=<?echo $row2['option1']?> /> <?echo $row2['option2']?></h4></label>
                </div>

                <br />
                <?php
                  if( $count >0)
                    {  ?>
                      <button disabled="disabled" alt="<?php echo $row2['question_id']; ?>" rel="<?php echo $user_email; ?>" class="btn btn-primary poll_option" title="<?php echo $ip; ?>">Submit</button>
                       <h>You selected : <? echo $row1['vote_option']; ?></h>
                       <br>
                       <p id="demo"></p>
                       <?php
                    }
                  else
                    { ?>
                        <button  alt="<?php echo $row2['question_id']; ?>" rel="<?php echo $user_email; ?>" class="btn btn-primary poll_option" title="<?php echo $ip; ?>">Submit</button>
                      <?
                    }
                    ?>
                </form>
           <? }
          } ?>
      <br />
  </div>
 </div>
   <br />
   <br />
   <br />
</div>
</body>
<script type="text/javascript">
    $(document).ready(function(){

        $(".poll_form").submit(function(event){
            event.preventDefault();   //prevents the form from submitting normally
                var poll_option = '';

                $('button.poll_option').each(function(){

                     if($(this).prop("checked"))
                         {
                             poll_option = $(this).val();

                             var option=poll_option;

                         }

                     var url = '<?php echo SITE_URL; ?>';
                     });
                $.post("poll_vote.php",$('.poll_form').serialize(),
                function(data)
                    {
                      if(data=="User Created Success"){

                           window.setTimeout(function () {
                                location.href ="<?php echo SITE_URL; ?>poll.php";
                            }, 100);
                      }
                      else{

                          $("#result").html(data);
                      }
                     }
                  );
             //to reset form data
        });
    });
    <? } ?>
    </script>

</html>
</code>```

Using th below function I am sending the poll_option to other where I kept the inset operation. Now I want to send the question_id also

答:
Create a hidden input filed in your form</p>

```<code><input type="hidden" name="question_id" value="<?php echo $row2['question_id']; ?>">
</code>```

Body:
I have a database which consists of question_id, question, and options. Where I'll display the question and options. When the user clicked on submit I want to store the option they clicked and the question_id.
I am able to store the option they clicked but want to know how to store the question_id.

$user_email = $_SESSION['email'];
$query1="SELECT * FROM votes WHERE user_email='$user_email'";
$query2="SELECT * FROM poll_question WHERE status='1'";
$fetch2 = mysqli_query($con,$query2);

          <?

            while( $row2 = mysqli_fetch_array($fetch2))
            {
             ?>
              <form method="post" class="poll_form">

<?echo $row2['question']?>?

<input type="radio" name="poll_option" class="poll_option" value=<?echo $row2['option1']?> /><?echo $row2['option1']?>

<input type="radio" name="poll_option" class="poll_option" value=<?echo $row2['option1']?> /> <?echo $row2['option2']?>

                <?php
                  if( $count >0)
                    {  ?>
                      <button disabled="disabled" alt="<?php echo $row2['question_id']; ?>" rel="<?php echo $user_email; ?>" class="btn btn-primary poll_option" title="<?php echo $ip; ?>">Submit</button>
                       <h>You selected : <? echo $row1['vote_option']; ?></h>

                       <?php
                    }
                  else
                    { ?>
                        <button  alt="<?php echo $row2['question_id']; ?>" rel="<?php echo $user_email; ?>" class="btn btn-primary poll_option" title="<?php echo $ip; ?>">Submit</button>
                      <?
                    }
                    ?>
                </form>
           <? }
          } ?>

Using th below function I am sending the poll_option to other where I kept the inset operation. Now I want to send the question_id also

Body:
Create a hidden input filed in your form

<input type="hidden" name="question_id" value="<?php echo $row2['question_id']; ?>">


问:
Binary XML runtime exception when trying to start activity
I'm trying to launch the application, but I get a RuntimeException stating that "RuntimeException: Unable to start activity ". Can someone help me?

Here's the code:

```<code>public class MainActivity extends AppCompatActivity {
    LinearLayout splash_screen;
    WebView myWebView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        myWebView = (WebView)findViewById(R.id.webview);
        splash_screen = (LinearLayout) findViewById(R.id.splash_screen);
        myWebView.loadUrl("https://www.africanshooting.com");
        WebSettings webSettings = myWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        myWebView.setWebViewClient(new MyWebViewClient());
        if (!isConnected())
        {
            AlertDialog alert = new AlertDialog.Builder(this)
                    .setIcon(android.R.drawable.ic_dialog_alert)
                    .setTitle("Internet Connection")
                    .setMessage("Oups!il semblerait que vous n'etes pas connecter verifier vos parametres reseau")
                    .setPositiveButton("Fermer", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            finish();
                        }
                    }).create();
                    alert.show();
        }

    }
    private class MyWebViewClient extends WebViewClient {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            return false;
        }
        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            splash_screen.setVisibility(View.VISIBLE);
            view.setVisibility(View.INVISIBLE);

        }
        @Override
        public void onPageFinished(WebView view, String url) {
            splash_screen.setVisibility(View.GONE);
            view.setVisibility(View.VISIBLE);
            super.onPageFinished(view, url);
        }
    }  private boolean isConnected() {
        ConnectivityManager connectivityManager= (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo networkInfo= connectivityManager.getActiveNetworkInfo();
        return networkInfo != null && networkInfo.isConnected();
    }
}
</code>```

And here's the log:

```<code>E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.africanshooting, PID: 25248
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.africanshooting/com.example.africanshooting.MainActivity}: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.support.constraint.RelativeLayout
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2667)
        at android.app.ActivityThread.-wrap11(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1501)
        at android.os.Handler.dispatchMessage(Handler.java:111)
        at android.os.Looper.loop(Looper.java:207)
        at android.app.ActivityThread.main(ActivityThread.java:5788)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
     Caused by: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.support.constraint.RelativeLayout
        at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
        at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
        at com.example.africanshooting.MainActivity.onCreate(MainActivity.java:24)
        at android.app.Activity.performCreate(Activity.java:6309)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2532)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2667)
        at android.app.ActivityThread.-wrap11(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1501)
        at android.os.Handler.dispatchMessage(Handler.java:111)
        at android.os.Looper.loop(Looper.java:207)
        at android.app.ActivityThread.main(ActivityThread.java:5788)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
     Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.constraint.RelativeLayout
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
        at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
        at com.example.africanshooting.MainActivity.onCreate(MainActivity.java:24)
        at android.app.Activity.performCreate(Activity.java:6309)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2532)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2667)
        at android.app.ActivityThread.-wrap11(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1501)
        at android.os.Handler.dispatchMessage(Handler.java:111)
        at android.os.Looper.loop(Looper.java:207)
        at android.app.ActivityThread.main(ActivityThread.java:5788)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.constraint.RelativeLayout" on path: DexPathList[[zip file "/data/app/com.example.africanshooting-2/base.apk"],nativeLibraryDirectories=[/data/app/com.example.africanshooting-2/lib/arm, /vendor/lib, /system/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
        at android.view.LayoutInflater.createView(LayoutInflater.java:583)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
        at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
        at com.example.africanshooting.MainActivity.onCreate(MainActivity.java:24)
        at android.app.Activity.performCreate(Activity.java:6309)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2532)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2667)
        at android.app.ActivityThread.-wrap11(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1501)
        at android.os.Handler.dispatchMessage(Handler.java:111)
        at android.os.Looper.loop(Looper.java:207)
        at android.app.ActivityThread.main(ActivityThread.java:5788)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
        Suppressed: java.lang.ClassNotFoundException: android.support.constraint.RelativeLayout
        at java.lang.Class.classForName(Native Method)
        at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
        at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
</code>```

答:
change your root layout name from

<p>OR change rootlayout to other layout which you want ,if u want to use realtive layout then just use

Body:
I'm trying to launch the application, but I get a RuntimeException stating that "RuntimeException: Unable to start activity ". Can someone help me?

Here's the code:

public class MainActivity extends AppCompatActivity {
    LinearLayout splash_screen;
    WebView myWebView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        myWebView = (WebView)findViewById(R.id.webview);
        splash_screen = (LinearLayout) findViewById(R.id.splash_screen);
        myWebView.loadUrl("https://www.africanshooting.com");
        WebSettings webSettings = myWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        myWebView.setWebViewClient(new MyWebViewClient());
        if (!isConnected())
        {
            AlertDialog alert = new AlertDialog.Builder(this)
                    .setIcon(android.R.drawable.ic_dialog_alert)
                    .setTitle("Internet Connection")
                    .setMessage("Oups!il semblerait que vous n'etes pas connecter verifier vos parametres reseau")
                    .setPositiveButton("Fermer", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            finish();
                        }
                    }).create();
                    alert.show();
        }

    }
    private class MyWebViewClient extends WebViewClient {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            return false;
        }
        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            splash_screen.setVisibility(View.VISIBLE);
            view.setVisibility(View.INVISIBLE);

        }
        @Override
        public void onPageFinished(WebView view, String url) {
            splash_screen.setVisibility(View.GONE);
            view.setVisibility(View.VISIBLE);
            super.onPageFinished(view, url);
        }
    }  private boolean isConnected() {
        ConnectivityManager connectivityManager= (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo networkInfo= connectivityManager.getActiveNetworkInfo();
        return networkInfo != null && networkInfo.isConnected();
    }
}

And here's the log:

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.africanshooting, PID: 25248
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.africanshooting/com.example.africanshooting.MainActivity}: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.support.constraint.RelativeLayout
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2667)
        at android.app.ActivityThread.-wrap11(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1501)
        at android.os.Handler.dispatchMessage(Handler.java:111)
        at android.os.Looper.loop(Looper.java:207)
        at android.app.ActivityThread.main(ActivityThread.java:5788)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
     Caused by: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.support.constraint.RelativeLayout
        at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
        at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
        at com.example.africanshooting.MainActivity.onCreate(MainActivity.java:24)
        at android.app.Activity.performCreate(Activity.java:6309)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2532)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2667)
        at android.app.ActivityThread.-wrap11(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1501)
        at android.os.Handler.dispatchMessage(Handler.java:111)
        at android.os.Looper.loop(Looper.java:207)
        at android.app.ActivityThread.main(ActivityThread.java:5788)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
     Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.constraint.RelativeLayout
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
        at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
        at com.example.africanshooting.MainActivity.onCreate(MainActivity.java:24)
        at android.app.Activity.performCreate(Activity.java:6309)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2532)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2667)
        at android.app.ActivityThread.-wrap11(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1501)
        at android.os.Handler.dispatchMessage(Handler.java:111)
        at android.os.Looper.loop(Looper.java:207)
        at android.app.ActivityThread.main(ActivityThread.java:5788)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.constraint.RelativeLayout" on path: DexPathList[[zip file "/data/app/com.example.africanshooting-2/base.apk"],nativeLibraryDirectories=[/data/app/com.example.africanshooting-2/lib/arm, /vendor/lib, /system/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
        at android.view.LayoutInflater.createView(LayoutInflater.java:583)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
        at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
        at com.example.africanshooting.MainActivity.onCreate(MainActivity.java:24)
        at android.app.Activity.performCreate(Activity.java:6309)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2532)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2667)
        at android.app.ActivityThread.-wrap11(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1501)
        at android.os.Handler.dispatchMessage(Handler.java:111)
        at android.os.Looper.loop(Looper.java:207)
        at android.app.ActivityThread.main(ActivityThread.java:5788)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
        Suppressed: java.lang.ClassNotFoundException: android.support.constraint.RelativeLayout
        at java.lang.Class.classForName(Native Method)
        at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
        at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:504)

Body:
change your root layout name from

OR change rootlayout to other layout which you want ,if u want to use realtive layout then just use


问:
Symfony 4 framework session handler error
I'm using symfony 4, What does error stands for ?

Warning: SessionHandler::read(): open(/var/lib/php/sessions/sess_634q91mh896b6aa4jpjvlihmar, O_RDWR) failed: Permission denied (13)

答: Not related to symfony 4, but you have to fix permissions in your /var/lib/php/sessions/ directory  </p>


问:
Azure Cognitive Services - Batch Transcription API responds with error message "The recording URI is invalid."
Steps Followed:

I created a speech services instance in West US.

I have the right headers(Content-Type and Ocp-Apim-Subscription-Key)

I make a POST request to https://westus.cris.ai/api/speechtotext/v2.0/transcriptions/ with below request payload

```<code>{
  "recordingsUrl": "https://transcribehm97c1.blob.core.windows.net/audio-files/2019-04-04_Blockchain%20explained%20with%20TruStory%27s%20Preethi%20Kasireddy.mp3?st=2019-05-27T12%3A19%3A27Z&se=2019-12-31T12%3A19%3A00Z&sp=rl&sv=2018-03-28&sr=b&sig=HFBvGl1pmCM95MNU9U3yniMNXrUMT6RmPb36F32cxrY%3D",
  "models": [],
  "locale": "en-US",
  "name": "I dont know why this is not working",
  "description": "Someone please send help",
  "properties": {
    "ProfanityFilterMode": "Masked",
    "PunctuationMode": "DictatedAndAutomatic"
  }
}
</code>```

I get a “202 Accepted” response with below headers. This confirms that the request body is valid.

```<code>location: https://westus.cris.ai/api/speechtotext/v2.0/transcriptions/69b7abf4-6383-4490-88a9-9fd42a77e470
</code>```

When I make a GET Request to the above location, I see this

```<code>{
  "recordingsUrl": "https://transcribehm97c1.blob.core.windows.net/audio-files/2019-04-04_Blockchain explained with TruStory's Preethi Kasireddy.mp3?st=2019-05-27T12:19:27Z&se=2019-12-31T12:19:00Z&sp=rl&sv=2018-03-28&sr=b&sig=HFBvGl1pmCM95MNU9U3yniMNXrUMT6RmPb36F32cxrY%3D",
  "resultsUrls": {},
  "models": [“I have removed this for brevity”],
  "statusMessage": "The recordings URI is invalid.",
  "id": "69b7abf4-6383-4490-88a9-9fd42a77e470",
  "createdDateTime": "2019-05-27T12:43:39Z",
  "lastActionDateTime": "2019-05-27T12:43:50Z",
  "status": "Failed",
  "locale": "en-US",
  "name": "I dont know why this is not working",
  "description": "Someone please send help",
  "properties": {
    "ProfanityFilterMode": "Masked",
    "PunctuationMode": "DictatedAndAutomatic"
  }
}
</code>```

The transcriptions fails for some URL's while passing for others for blobs in the same storage although they are all valid URL’s. The SAS URI in the request is valid till end of the
year.

I have re-tried the same request multiple times via code and Postman and it fails.

Link to Swagger Page : https://westus.cris.ai/swagger/ui/index

答: The issue may be due to the audio file size. Please refer the core features for REST API as the REST support only short Audio.</p>

Body:
Steps Followed:

I created a speech services instance in West US.

I have the right headers(Content-Type and Ocp-Apim-Subscription-Key)

I make a POST request to https://westus.cris.ai/api/speechtotext/v2.0/transcriptions/ with below request payload

{
  "recordingsUrl": "https://transcribehm97c1.blob.core.windows.net/audio-files/2019-04-04_Blockchain%20explained%20with%20TruStory%27s%20Preethi%20Kasireddy.mp3?st=2019-05-27T12%3A19%3A27Z&se=2019-12-31T12%3A19%3A00Z&sp=rl&sv=2018-03-28&sr=b&sig=HFBvGl1pmCM95MNU9U3yniMNXrUMT6RmPb36F32cxrY%3D",
  "models": [],
  "locale": "en-US",
  "name": "I dont know why this is not working",
  "description": "Someone please send help",
  "properties": {
    "ProfanityFilterMode": "Masked",
    "PunctuationMode": "DictatedAndAutomatic"
  }
}

I get a “202 Accepted” response with below headers. This confirms that the request body is valid.

location: https://westus.cris.ai/api/speechtotext/v2.0/transcriptions/69b7abf4-6383-4490-88a9-9fd42a77e470

When I make a GET Request to the above location, I see this

{
  "recordingsUrl": "https://transcribehm97c1.blob.core.windows.net/audio-files/2019-04-04_Blockchain explained with TruStory's Preethi Kasireddy.mp3?st=2019-05-27T12:19:27Z&se=2019-12-31T12:19:00Z&sp=rl&sv=2018-03-28&sr=b&sig=HFBvGl1pmCM95MNU9U3yniMNXrUMT6RmPb36F32cxrY%3D",
  "resultsUrls": {},
  "models": [“I have removed this for brevity”],
  "statusMessage": "The recordings URI is invalid.",
  "id": "69b7abf4-6383-4490-88a9-9fd42a77e470",
  "createdDateTime": "2019-05-27T12:43:39Z",
  "lastActionDateTime": "2019-05-27T12:43:50Z",
  "status": "Failed",
  "locale": "en-US",
  "name": "I dont know why this is not working",
  "description": "Someone please send help",
  "properties": {
    "ProfanityFilterMode": "Masked",
    "PunctuationMode": "DictatedAndAutomatic"
  }
}

The transcriptions fails for some URL's while passing for others for blobs in the same storage although they are all valid URL’s. The SAS URI in the request is valid till end of the
year.

I have re-tried the same request multiple times via code and Postman and it fails.

Link to Swagger Page : https://westus.cris.ai/swagger/ui/index


问:
Find Button Code in Eclipse
I am trying to see the code associated to a button in eclipse, but without success..

How can i see all the code associated to the button?

see also find class associated by button id

答:
Press Alt-Shift-F2 and click on the button you are interested in. This will open the "Plug-in Menu Spy", and display a pop-up with something like this (when clicking on the "Debug" toolbar button):

```<code>The active contribution item identifier:
    org.eclipse.debug.internal.ui.actions.DebugDropDownAction
The active contribution location URI:
    toolbar:org.eclipse.debug.ui.launchActionSet?after=org.eclipse.debug.internal.ui.actions.DebugDropDownAction
The active action set identifier:
    org.eclipse.debug.ui.launchActionSet
</code>```

Now you know that the contributed action is DebugDropDownAction, which (if you have the proper sources) you can open using "Open Type" (Ctrl-Shift-T).

(There is also a "Plug-in Selection Spy" bound to Alt-Shift-F1 which will display similar information about the current selection.)

Title: Find Button Code in Eclipse

Body:
Press Alt-Shift-F2 and click on the button you are interested in. This will open the "Plug-in Menu Spy", and display a pop-up with something like this (when clicking on the "Debug" toolbar button):

The active contribution item identifier:
    org.eclipse.debug.internal.ui.actions.DebugDropDownAction
The active contribution location URI:
    toolbar:org.eclipse.debug.ui.launchActionSet?after=org.eclipse.debug.internal.ui.actions.DebugDropDownAction
The active action set identifier:
    org.eclipse.debug.ui.launchActionSet

Now you know that the contributed action is DebugDropDownAction, which (if you have the proper sources) you can open using "Open Type" (Ctrl-Shift-T).

(There is also a "Plug-in Selection Spy" bound to Alt-Shift-F1 which will display similar information about the current selection.)


问:
Is there a function to format numbers in influxdb
I'm using grafana to connect to influxdb and display indicator data. I'm using SQL `select sum (siz) from quotes'like this. Is there a function that can format it in the form of 1,111,111? No such function has been found in the document.</p>

答:
Unfortunately, this isn't something that can be done by InfluxDB. Grafana has a long standing issue to provide this functionality:

https://github.com/grafana/grafana/issues/4252

However, this was something that was added to Chronograf a while back:

https://github.com/influxdata/chronograf/issues/3608


问:
Google Places Autocomplete returns PLACES_API_ACCESS_NOT_CONFIGURED
I'm using Google Places Autocomplete API in my Application. Recently I have changed my package name. Then i have created a new project in Google Developers Console and added the API Key to my project.
I have Enabled the Google Maps SDK for Android and Places API.
Now only detecting current location is works, Places AutoComplete Search returns "PLACES_API_ACCESS_NOT_CONFIGURED".</p>

答: i think you have to Enable the Google Places API for Android in developers console and check on the credentials page that your key is still present. Hope this helps


问:
How to deploy web console by docker, docker run -d -p 80:80 -v <host_absolute_path>:/var/lib/mongodb --name, What is host absolute path?
I'm trying to deploy Apache Ignite Web console on Linux(CentOS 7), but to run docker, i have to set host_absolute_path of MongoDB, How to handle it?

<host_absolute_path> is a path on your host machine where MongoDB will create database files. This folder should be created before docker run. Go to Docker->Preferences->File Sharing and create the directory there or use the other way that suits your more.
Can anybody explain step by step?

docker run -d -p 80:80 -v <host_absolute_path>:/var/lib/mongodb --name web-console-standalone apacheignite/web-console-standalone
```

答:
<host_absolute_path> is just a path on your local machine. MongoDB is embedded into the docker image. You need to specify a path where MongoDB will store data.
It's required because data need to survive restarts of the container. For example you can run:

docker run -it --rm -p 8080:80 -v /home/user/mongodb:/var/lib/mongodb apacheignite/web-console-standalone:2.7.0

It will run Web console 2.7.0 on 8080 port of the host machine and store data in /home/user/mongodb. This directory should be already present when you start the container.


问:
How to link user input from a string and int
I want to create an application where the user can enter items and the price, then show the most expensive and the cheapest item.

I'm totally new to C# and have no programming experience of any language, started to learn 2,5 weeks ago. I don't understand how I can link the item with the price and then do the calculation. The penny hasn't dropped yet in terms of how I can build an application :(

```<code>        ItemInput();
        PricingInput();

    }

    private static void ItemInput()
    {
        Console.WriteLine("Add your items and price, once you're done, type 'end' ");
        AskForTheItem();
        AskForThePrice();
    }

    static void AskForTheItem()
    {

            while (itemPrice != "end")
            {
                Console.Write("Add your item:");
                string item = Console.ReadLine();
                Console.Write("Add the price:");
                int price = int.Parse(Console.ReadLine());
                itemPrice = Console.ReadLine();

            }
            Console.WriteLine("Add your item: ");
       name = Console.ReadLine();
        numberOfItems++;
    }
    static void AskForThePrice()
    {
        Console.WriteLine("Add the price: ");
        price = int.Parse(Console.ReadLine());
        numberOfPrice++;
    }
    private static void PricingInput()
    {
        Console.WriteLine($"The cheapest item is: {name} and the most expensive item is: {name} ");
</code>```

答:
Welcome to StackOverflow! Your question seems to be pretty broad but I think what you'd need is some first steps into object-oriented programming with classes.

Your code seems like a good start but for storing the information you'll need some objects.

You can create your own objects using a class. In this case you class would need a property for its name and one for it's price.
Defining the class would be as follows (you should do that in a new file):

```<code>class MyItem{
    public string Name { get; set; }
    public int Price { get; set; }
}
</code>```

Then at the start of the class with the AskForTheItems method and probably also the Main method, you need to add a List to store the items. You'd do that like this:

```<code>private static List<MyItem> items = new List<MyItem>();
</code>```

For the method which gets the items, you'll need to some adjustments. You also don't need the numberOfItems-variable anymore since you can just call items.Count if you need it.

```<code>private static void AskForTheItems()
{
    do
    {
        Console.WriteLine("Add your item:");
        // get the name
        Console.Write("Name: ");
        string name = Console.ReadLine();
        // get and convert the price
        Console.Write("Price: ");
        int price = int.Parse(Console.ReadLine());

        // create the item and fill it with the values
        MyItem item = new MyItem();
        item.Name = name;
        item.Price = price;

        // add the item to your list
        items.Add(item);

        // ask if the user want's to add another one
        Console.WriteLine("Again? (y/n)");
    }
    while (Console.ReadKey(true).Key != ConsoleKey.N);
}
</code>```

Printing the cheapest and most expensive one is fairly easy using Linq (there might even be an easier/better way).

```<code>private static void PrintCheapestAndMostExpensive() {
    // get the first item where the price is the same as the minimum of all prices in the list
    MyItem cheapestItem = items.First(i => i.Price == items.Min(i2 => i2.Price));
    // get the first item where the price is the same as the maximum of all prices in the list
    MyItem mostExpensiveItem = items.First(i => i.Price == items.Max(i2 => i2.Price));

    Console.WriteLine($"The cheapest item is: {cheapestItem.Name} and the most expensive item is: {mostExpensiveItem.Name}");
}
</code>```

I hope this helps. If you have any questions, feel free to ask - I'll try to explain anything you don't understand yet.

By the way there a are few things I didn't do/cover because I feel like it'd be a bit too much to explain for a small program like this. Currently there is no error handling when converting the input-string to an int (bad). There are also easier ways to write the initialisation for the item but I figured this way it's easier to understand.

Also with this code it always prints the first item which has the lowest price. If there are two which both have the lowest price, this might be a problem.

Linq itself is fairly hard (but very very important), that's why I would strongly reccomend you to read something about it. I'd happily explain the Linq I used here with more detail but since it's such a huge topic, I won't cover much more.

Body:
I want to create an application where the user can enter items and the price, then show the most expensive and the cheapest item.

I'm totally new to C# and have no programming experience of any language, started to learn 2,5 weeks ago. I don't understand how I can link the item with the price and then do the calculation. The penny hasn't dropped yet in terms of how I can build an application :(

        ItemInput();
        PricingInput();

    }

    private static void ItemInput()
    {
        Console.WriteLine("Add your items and price, once you're done, type 'end' ");
        AskForTheItem();
        AskForThePrice();
    }

    static void AskForTheItem()
    {

            while (itemPrice != "end")
            {
                Console.Write("Add your item:");
                string item = Console.ReadLine();
                Console.Write("Add the price:");
                int price = int.Parse(Console.ReadLine());
                itemPrice = Console.ReadLine();

            }
            Console.WriteLine("Add your item: ");
       name = Console.ReadLine();
        numberOfItems++;
    }
    static void AskForThePrice()
    {
        Console.WriteLine("Add the price: ");
        price = int.Parse(Console.ReadLine());
        numberOfPrice++;
    }
    private static void PricingInput()
    {
        Console.WriteLine($"The cheapest item is: {name} and the most expensive item is: {name} ");

Body:
Welcome to StackOverflow! Your question seems to be pretty broad but I think what you'd need is some first steps into object-oriented programming with classes.

Your code seems like a good start but for storing the information you'll need some objects.

You can create your own objects using a class. In this case you class would need a property for its name and one for it's price.
Defining the class would be as follows (you should do that in a new file):

class MyItem{
    public string Name { get; set; }
    public int Price { get; set; }
}

Then at the start of the class with the AskForTheItems method and probably also the Main method, you need to add a List to store the items. You'd do that like this:

private static List<MyItem> items = new List<MyItem>();

For the method which gets the items, you'll need to some adjustments. You also don't need the numberOfItems-variable anymore since you can just call items.Count if you need it.

private static void AskForTheItems()
{
    do
    {
        Console.WriteLine("Add your item:");
        // get the name
        Console.Write("Name: ");
        string name = Console.ReadLine();
        // get and convert the price
        Console.Write("Price: ");
        int price = int.Parse(Console.ReadLine());

        // create the item and fill it with the values
        MyItem item = new MyItem();
        item.Name = name;
        item.Price = price;

        // add the item to your list
        items.Add(item);

        // ask if the user want's to add another one
        Console.WriteLine("Again? (y/n)");
    }
    while (Console.ReadKey(true).Key != ConsoleKey.N);
}

Printing the cheapest and most expensive one is fairly easy using Linq (there might even be an easier/better way).

private static void PrintCheapestAndMostExpensive() {
    // get the first item where the price is the same as the minimum of all prices in the list
    MyItem cheapestItem = items.First(i => i.Price == items.Min(i2 => i2.Price));
    // get the first item where the price is the same as the maximum of all prices in the list
    MyItem mostExpensiveItem = items.First(i => i.Price == items.Max(i2 => i2.Price));

    Console.WriteLine($"The cheapest item is: {cheapestItem.Name} and the most expensive item is: {mostExpensiveItem.Name}");
}

I hope this helps. If you have any questions, feel free to ask - I'll try to explain anything you don't understand yet.

By the way there a are few things I didn't do/cover because I feel like it'd be a bit too much to explain for a small program like this. Currently there is no error handling when converting the input-string to an int (bad). There are also easier ways to write the initialisation for the item but I figured this way it's easier to understand.

Also with this code it always prints the first item which has the lowest price. If there are two which both have the lowest price, this might be a problem.

Linq itself is fairly hard (but very very important), that's why I would strongly reccomend you to read something about it. I'd happily explain the Linq I used here with more detail but since it's such a huge topic, I won't cover much more.


问:
WordPress include custom field in search
I have a custom post type of post_type_1 in WordPress, I also have a custom field  in that post type of custom_field_data

I am doing a search for apples by querying posts using wp_query like this...

```<code>$search_term = 'apples';

$args = array(
    'post_type'      => array('post_type_1'),
    'post_status'    => array('publish'),
    'posts_per_page' => -1,
    's'              => sanitize_text_field( $search_term)
);

$results= new WP_Query( $args );
</code>```

This works correctly and returns all posts with apples in the title, but I would also like to extend the search to the custom field custom_field_data so the query will return all posts with apples in either title or custom field.

What is my best approach? I have tried using a meta_query but haven't been successful. Does anybody have an example?

答:
Use below code will work for custom field search.

```<code>$custom_field = $_GET['custom_field '] != '' ? $_GET['custom_field '] : '';
$search_term = 'apples';

$args = array(
    'post_type'      => array('post_type_1'),
    'post_status'    => array('publish'),
    'posts_per_page' => -1,
    's'              => sanitize_text_field( $search_term),
    'meta_query'    =>  array(
                          array(
                                'key'     => 'custom_field_key',
                                'value'   => $custom_field ,
                                'compare' => 'LIKE',
                                ),
                            )
    );
$results= new WP_Query( $args );
</code>```

Tested and works well.

Body:
I have a custom post type of post_type_1 in WordPress, I also have a custom field  in that post type of custom_field_data

I am doing a search for apples by querying posts using wp_query like this...

$search_term = 'apples';

$args = array(
    'post_type'      => array('post_type_1'),
    'post_status'    => array('publish'),
    'posts_per_page' => -1,
    's'              => sanitize_text_field( $search_term)
);

$results= new WP_Query( $args );

This works correctly and returns all posts with apples in the title, but I would also like to extend the search to the custom field custom_field_data so the query will return all posts with apples in either title or custom field.

What is my best approach? I have tried using a meta_query but haven't been successful. Does anybody have an example?

Body:
Use below code will work for custom field search.

$custom_field = $_GET['custom_field '] != '' ? $_GET['custom_field '] : '';
$search_term = 'apples';

$args = array(
    'post_type'      => array('post_type_1'),
    'post_status'    => array('publish'),
    'posts_per_page' => -1,
    's'              => sanitize_text_field( $search_term),
    'meta_query'    =>  array(
                          array(
                                'key'     => 'custom_field_key',
                                'value'   => $custom_field ,
                                'compare' => 'LIKE',
                                ),
                            )
    );
$results= new WP_Query( $args );

Tested and works well.


问:
Keep scroll position in ListView when adding new item on top
I am using a ListView.builder to render a chat.

The scenario is the following: A user types in a new chat message, when that happens i am storing the new message in state and therefore the itemCount is increased by one.

If i am at the end of the list, I see the new item directly at the top, everything is OK.

However, if I am in the middle of the chat and an item is added, the view scrolls a little bit. How can I disable this behaviour? I guess it kinda makes sense because the scroll offset is still the same double in the ScrollControllers state, but if there is one more item, it looks like it scrolls...

Is there a good way to do this? I guess the manual approach would be to measure the height of the new item and manually set the correct ScrollController offset again.. but meeeh

答:
This is a solution for items with static/constant height (height: 100) added on top of the list.

When I detect that list length has changed I change offset position by hardcoded item height by calling _scrollController.jumpTo(newOffect).

It works well. The list stays at the current position when a new item is added to the top, with no jumps visible.

```<code>class FeedWidget extends StatefulWidget {
  FeedWidget({
    Key key,
  }) : super(key: key);

  @override
  State<StatefulWidget> createState() => _FeedWidgetState();
}

class _FeedWidgetState extends State<FeedWidget> {
  var _scrollController = ScrollController();
  var _itemsLength = 0;

  @override
  Widget build(BuildContext context) {
    return StreamBuilder<List<FeedItem>>(
      stream: Provider.of<FeedRepository>(context).getAll(),
      builder: (BuildContext context, AsyncSnapshot<List<FeedItem>> items) {
        print('Loaded feed data $items');
        switch (items.connectionState) {
          case ConnectionState.waiting:
            return Center(child: CircularProgressIndicator());
          default:
            final newItemsLength = items.data.length;
            if (_itemsLength != 0 && _itemsLength != newItemsLength) {
              final newItemsCount = newItemsLength - _itemsLength;
              print('New items detected: $newItemsCount');
              final newOffset = _scrollController.offset +
                  100 * newItemsCount; //item height is 100
              print(
                  'Setting new offest ${_scrollController.offset} -> $newOffset');
              _scrollController.jumpTo(newOffset);
            }
            print('Items length new = $newItemsLength old = $_itemsLength}');
            _itemsLength = newItemsLength;
            return Flexible(
                child: ListView(
                    key: PageStorageKey('feed'), //keeps scroll position
                    controller: _scrollController,
                    padding: EdgeInsets.only(top: 8, bottom: 32),
                    children: items.data
                        .map((element) => FeedItemCard(item: element)) //item height is 100
                        .toList()));
        }
      },
    );
  }
}

</code>```

Body:
This is a solution for items with static/constant height (height: 100) added on top of the list.

When I detect that list length has changed I change offset position by hardcoded item height by calling _scrollController.jumpTo(newOffect).

It works well. The list stays at the current position when a new item is added to the top, with no jumps visible.

class FeedWidget extends StatefulWidget {
  FeedWidget({
    Key key,
  }) : super(key: key);

  @override
  State<StatefulWidget> createState() => _FeedWidgetState();
}

class _FeedWidgetState extends State<FeedWidget> {
  var _scrollController = ScrollController();
  var _itemsLength = 0;

  @override
  Widget build(BuildContext context) {
    return StreamBuilder<List<FeedItem>>(
      stream: Provider.of<FeedRepository>(context).getAll(),
      builder: (BuildContext context, AsyncSnapshot<List<FeedItem>> items) {
        print('Loaded feed data $items');
        switch (items.connectionState) {
          case ConnectionState.waiting:
            return Center(child: CircularProgressIndicator());
          default:
            final newItemsLength = items.data.length;
            if (_itemsLength != 0 && _itemsLength != newItemsLength) {
              final newItemsCount = newItemsLength - _itemsLength;
              print('New items detected: $newItemsCount');
              final newOffset = _scrollController.offset +
                  100 * newItemsCount; //item height is 100
              print(
                  'Setting new offest ${_scrollController.offset} -> $newOffset');
              _scrollController.jumpTo(newOffset);
            }
            print('Items length new = $newItemsLength old = $_itemsLength}');
            _itemsLength = newItemsLength;
            return Flexible(
                child: ListView(
                    key: PageStorageKey('feed'), //keeps scroll position
                    controller: _scrollController,
                    padding: EdgeInsets.only(top: 8, bottom: 32),
                    children: items.data
                        .map((element) => FeedItemCard(item: element)) //item height is 100
                        .toList()));
        }
      },
    );
  }
}


问:
Making space for added bytecode (machine code) in a Windows PE executable
This question is related to reverse engineering / binary patching on Windows.

I need a free tool exist to allow me to add assembler (or machine code) to an already built executable. I am not talking about Java or .NET but native bytecode (x86 machine code).

Also, What if I need more space? Do I have to add another section? what tool exists for expanding a PE exe?

答:
If you want to actually edit the PE file itself, for Olly to do the trick you'll have to supplement it with a tool that can take running process and reconstruct a PE file, like LordPE. LordPE might be able to add sections for you, it does it for its own purposes.

For editing the binary to add sections, you could also try out the "Stud PE" tool, it can add sections for you, but you'll have to tinker with the file itself to get the assembly bytes that you want into the binary.

The easiest way to do this by hand is to increase the size of the last section in the binary (the section's SizeOfRawData field in the PE header), increase the PE header's SizeOfImage field, and drop your bytes at the end of the file.  You may also need to set the executable flag for the last section (in the PE header).


答:
```<code> private static void ItemInput()
    {
         PricingInput(AskForTheItem());
    }

    static Dictionary<String, int> AskForTheItem()
    {

            var result = new Dictionary<String, int>();
            Console.WriteLine("Add your items and price, once you're done, type empty item ");
            while (1)
            {
                Console.Write("Add your item or keep empty :");
                string item = Console.ReadLine();
                if(String.IsNullOrEmpty(item)) return result;
                Console.Write("Add the price:");
                while(!int.TryParse(out var price, Console.ReadLine())                 Console.Write("Wrong price, please Add the price:");
                result.Add(item, price);
            }
    }

    private static void PricingInput(Dictionary<String,int> list)
    {
        String minItem = null;
        int minPrice = -1;
        String maxItem = null;
        int maxPrice = -1;
        foreach(var i in list) {
            if(price<0 || i.Value<price) { minItem = i.Key; minPrice=i.Value;}
            if( i.Value>price) { maxItem = i.Key; maxPrice=i.Value;}
        Console.WriteLine($"The cheapest item is: {1} and the most expensive item is: {2} ",minItem,maxItem); }
</code>```

Title: How to link user input from a string and int


问:
Can the notebook generated from papermill be outputted with a live running kernel?
When papermill generates a notebook, a .ipynb file is created in the output path that says it is not running in the jupyter home page. I would prefer that when the notebook has finished executing, it remains running with a live kernel so I can interact with any variables inside of it. Instead now I have to re-run the cells to get the variables that were generated in the notebook. This is especially cumbersome for any time intensive notebooks.

I am generating the notebooks using execute_notebook function.

My feeling is that this is not possible because while the new notebook is being executed it never shows "Running" in my jupyter homepage. Is what I am asking for even possible with papermill or is there another way of achieving this that is scalable?

答:
As far as I am aware there are several options for that. Papermill used to allow recording variables in the notebook using papermill.record(), which has been deprecated; I believe you can get an older version and still use it.

Another option they suggest is to use scrapbook. You can find more about it here.

You can also use %store magic:
Share data between IPython Notebooks

Finally you can simply write into flat files either by using python's context manager functionality:

```<code>with open('<dir>', 'w') as file:
    file.write(<var_of_choice>)

import json
with open(<out_path>, "a+") as file:
    json.dump(<var_of_choice>, file)
</code>```

If your notebooks load a lot of data it may be sub-optimal to leave kernels running.

Body:
As far as I am aware there are several options for that. Papermill used to allow recording variables in the notebook using papermill.record(), which has been deprecated; I believe you can get an older version and still use it.

Another option they suggest is to use scrapbook. You can find more about it here.

You can also use %store magic:
Share data between IPython Notebooks

Finally you can simply write into flat files either by using python's context manager functionality:

with open('<dir>', 'w') as file:
    file.write(<var_of_choice>)

import json
with open(<out_path>, "a+") as file:
    json.dump(<var_of_choice>, file)

If your notebooks load a lot of data it may be sub-optimal to leave kernels running.


问:
how to align multiple line text as the column of the table
I have to display text as follows(please notice that the month should be properly aligned with the months of other two rows, time should be properly aligned with the time of other two rows and so is the date as follows):

and all these values are coming from two way data binding inside a div in an angular 7 project as follows:

```<code><div *ngFor="let date of dates">
{{date.month}} {{date.day}} {{date.time}}
<div>
</code>```

please help me to display these values in the exact same style style.

答:
HTML:

```<code><div [ngClass]="'container'" *ngFor="let date of dates">
   <div>{{date.month}}</div>
   <div>{{date.day}}</div>
   <div>{{date.time}}</div>
</div>
</code>```

CSS:

```<code>.container{
  width:100%;
  overflow:hidden;
}

.container > div{
  width:33.333%;
  float:left;
}
</code>```

Body:
I have to display text as follows(please notice that the month should be properly aligned with the months of other two rows, time should be properly aligned with the time of other two rows and so is the date as follows):

and all these values are coming from two way data binding inside a div in an angular 7 project as follows:

{{date.month}} {{date.day}} {{date.time}}

please help me to display these values in the exact same style style.

Body:
HTML:

<div [ngClass]="'container'" *ngFor="let date of dates">
   <div>{{date.month}}</div>
   <div>{{date.day}}</div>
   <div>{{date.time}}</div>
</div>

CSS:

.container{
  width:100%;
  overflow:hidden;
}

.container > div{
  width:33.333%;
  float:left;
}