问:
How to create UI like spotify's Equalizer UI in swift iOS
Hello i'm iOS fresher & don't have so much idea about creating complex UI, i want to create equalizer UI like spotify's equalizer UI. currently i had setup my equalizer using UISlider. What should i use to modify my UI like spotify'S EQ UI. It will be nice if you can help with Example code.
Thank you.

This is my EQ UI.

This is what i want to create. EQ UI of spotify.

答:
The approach could be simple:

Make the color of your sliders gauges clear so they are transparent

Read the values of your sliders and draw lines between them

Create a polygon with the coordinates of your sliders values + the two points at the bottom and fill it with a color gradient

As your sliders are equally spaced you can deduce their x position knowing the width of the graph container, the y value is the slider current value + some correction with the slider button size.


来源: stackexchange

问:
SciChart dynamic annotations
In the SciChart tutorials there are only instructions how to add a LabelProvider with hardcoded Label texts, that can be switched on different values (https://www.scichart.com/example/wpf-chart-example-stacked-column-side-by-side/). Is there any way to programmaticaly add and handle axis labels?

UPD: Idea is to mark columns with different labels, so that every column has a text label instead of numeric value on the main axis.

答: Solution is pretty obvious. To dynamically handle labels from ViewModel, you can bind a LabelProvider itself.

ContentLicense: CC BY-SA 4.0

Title: SciChart dynamic annotations


问:
How to show past dates for selection in bootstrap date picker?
I am currently able to select the dates from the present date and so on.</p>

答:
You can try this code:

$('#datepicker').datepicker({
    uiLibrary: 'bootstrap'
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://unpkg.com/gijgo@1.9.13/js/gijgo.min.js" type="text/javascript"></script>
<link href="https://unpkg.com/gijgo@1.9.13/css/gijgo.min.css" rel="stylesheet" type="text/css" />
<div class="container">
    <input id="datepicker" width="270" />
</div>

 </code>```

Body:
You can try this code:

$('#datepicker').datepicker({
    uiLibrary: 'bootstrap'
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://unpkg.com/gijgo@1.9.13/js/gijgo.min.js" type="text/javascript"></script>
<link href="https://unpkg.com/gijgo@1.9.13/css/gijgo.min.css" rel="stylesheet" type="text/css" />
<div class="container">
    <input id="datepicker" width="270" />
</div>


问:
Laravel 6 - How to get the value from controller's compact array in view/blade?
I am passing an array using compact from my Controller to a blade and I want to access them one by one in my view / blade template but I am always receiving this error:

Here's the content of my compact array:

Here's my snippet source code from the Controller:

```<code>//dd($flight_book_details);
    $flight_book_details = $request->all();
    return view('auth.register', compact('flight_book_details'));
</code>```

And here's my snippet source code in the view / blade template:

```<code><h2>
@foreach($flight_book_details as $flight_book_detail)
    {{$flight_book_detail->seat_quantity}}  //Trying to access the 'seat_quantity'
@endforeach
</h2>
</code>```

Question: Is there any other way to access the values from the compact in view?

答:
if you want to access seat_quantity you do not need to foreach loop through it,

    {{$flight_book_details['seat_quantity']}}

```

Body:
I am passing an array using compact from my Controller to a blade and I want to access them one by one in my view / blade template but I am always receiving this error:

Here's the content of my compact array:

Here's my snippet source code from the Controller:

//dd($flight_book_details);
    $flight_book_details = $request->all();
    return view('auth.register', compact('flight_book_details'));

And here's my snippet source code in the view / blade template:

@foreach($flight_book_details as $flight_book_detail)
    {{$flight_book_detail->seat_quantity}}  //Trying to access the 'seat_quantity'
@endforeach

Question: Is there any other way to access the values from the compact in view?

Body:
if you want to access seat_quantity you do not need to foreach loop through it,

<h2>
    {{$flight_book_details['seat_quantity']}}
</h2>


问:
'Fill' is not a member of 'System.Web.UI.WebControls.DataGrid' Error
I am developing a VB.NET program to search for text in a specified column from a Datagrid.  I am almost finished implementing this following the MS tutorial at:
http://support.microsoft.com/kb/815680

But now I have just one compilation error:

BC30456: 'Fill' is not a member of
  'System.Web.UI.WebControls.DataGrid'.

on the line that says:

```<code>dgTable.Fill(ds)
</code>```

The code related to this project is as follows.  Does anybody know how I can fix this please?

My global.vb file:

```<code>Namespace GlobalFunctions
    Public Class GlobalF
        Public Shared Function GlobalF_Load(ByVal dgTable As DataGrid)
            dgTable.Fill(ds)
            dv = New DataView(ds.Tables)
            dgTable.DataSource = dv
            dv.Sort = "Part No."
            CM = (System.Windows.Forms.CurrencyManager)
            dgTable.BindingContext([dv])
            Dim sender As New sender()

            dv.ListChanged += New ListChangedEventHandler(dv_ListChangedEvent)
        End Function

        Public Shared Function btnFind_Click(ByVal sender As Object, ByVal e As EventArgs)
            If (txtFind.Text = "") Then
                Response.write("Enter some criteria to find.")
                txtFind.Focus()
            Else
                Dim i As Int
                i = dv.Find(txtFind.Text)
                If (i > dv.Table.Rows.Count Or i < 0) Then
                    Response.Write("Record Not found")
                Else
                    CM.Position = i
                End If
            End If
        End Function

        Private Shared Function dv_ListChangedEvent(ByVal sender As Object, ByVal e As ListChangedEventArgs) Handles btnFind.ListChanged
            If (dv.Sort.Substring((dv.Sort.Length - 4), 4) = "DESC") Then
                lblFind.Text = "Enter Search Criteria " + dv.Sort.Substring(0, dv.Sort.Length - 5)
            Else
                lblFind.Text = "Enter Search Criteria " + dv.Sort
            End If
        End Function
</code>```

And my ASPX file:

```<code>        Public DSTableData As New System.Data.DataSet
        Public dv As New DataView

        Sub Main()
            '------------------------- Query database and get arrays for the chart and bind query results to datagrid ----------------------------------------

            If check1.Checked Then
                DSTableData = GlobalFunctions.GlobalF.FillSparePartsTable(1)
            Else
                DSTableData = GlobalFunctions.GlobalF.FillSparePartsTable(0)
            End If

            'dv = DataView(DSTableData(0))
            dgTable.DataSource = DSTableData
            dgTable.DataBind()

            GlobalFunctions.GlobalF.GlobalF_Load(dgTable)

        End Sub

        Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)
            If e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.Item Then
                Dim thepriority As Integer

...
</code>```

Now I have modified above code as follows:

```<code>Public Shared Function GlobalF_Load(ByVal dgTable As DataGrid)
            Dim dv As New DataView
            Dim ds As New DataSet
            dv = New DataView(ds.Tables())
            dgTable.DataSource = dv
            dv.Sort = "Part No."
            CM = (System.Windows.Forms.CurrencyManager)
            dgTable.BindingContext([dv])
            Dim sender As New sender()
</code>```

But now I get a different error:

BC30311: Value of type
  'System.Data.DataTableCollection'
  cannot be converted to
  'System.Data.DataTable'

Also, I'm not sure if it is good to be declaring these variables new like this since I believe I already call them new elsewhere in my code.

答:
Instead of:

```<code>dgTable.Fill(ds)
dv = New DataView(ds.Tables)
dgTable.DataSource = dv
</code>```

try:

```<code>dv= New DataView(ds.Tables("table name")
dgTable.DataSource = dv
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I am developing a VB.NET program to search for text in a specified column from a Datagrid.  I am almost finished implementing this following the MS tutorial at:
http://support.microsoft.com/kb/815680

But now I have just one compilation error:

BC30456: 'Fill' is not a member of
  'System.Web.UI.WebControls.DataGrid'.

on the line that says:

dgTable.Fill(ds)

The code related to this project is as follows.  Does anybody know how I can fix this please?

My global.vb file:

Namespace GlobalFunctions
    Public Class GlobalF
        Public Shared Function GlobalF_Load(ByVal dgTable As DataGrid)
            dgTable.Fill(ds)
            dv = New DataView(ds.Tables)
            dgTable.DataSource = dv
            dv.Sort = "Part No."
            CM = (System.Windows.Forms.CurrencyManager)
            dgTable.BindingContext([dv])
            Dim sender As New sender()

            dv.ListChanged += New ListChangedEventHandler(dv_ListChangedEvent)
        End Function

        Public Shared Function btnFind_Click(ByVal sender As Object, ByVal e As EventArgs)
            If (txtFind.Text = "") Then
                Response.write("Enter some criteria to find.")
                txtFind.Focus()
            Else
                Dim i As Int
                i = dv.Find(txtFind.Text)
                If (i > dv.Table.Rows.Count Or i < 0) Then
                    Response.Write("Record Not found")
                Else
                    CM.Position = i
                End If
            End If
        End Function

        Private Shared Function dv_ListChangedEvent(ByVal sender As Object, ByVal e As ListChangedEventArgs) Handles btnFind.ListChanged
            If (dv.Sort.Substring((dv.Sort.Length - 4), 4) = "DESC") Then
                lblFind.Text = "Enter Search Criteria " + dv.Sort.Substring(0, dv.Sort.Length - 5)
            Else
                lblFind.Text = "Enter Search Criteria " + dv.Sort
            End If
        End Function

And my ASPX file:

        Public DSTableData As New System.Data.DataSet
        Public dv As New DataView

        Sub Main()
            '------------------------- Query database and get arrays for the chart and bind query results to datagrid ----------------------------------------

            If check1.Checked Then
                DSTableData = GlobalFunctions.GlobalF.FillSparePartsTable(1)
            Else
                DSTableData = GlobalFunctions.GlobalF.FillSparePartsTable(0)
            End If

            'dv = DataView(DSTableData(0))
            dgTable.DataSource = DSTableData
            dgTable.DataBind()

            GlobalFunctions.GlobalF.GlobalF_Load(dgTable)

        End Sub

        Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)
            If e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.Item Then
                Dim thepriority As Integer

...

Now I have modified above code as follows:

Public Shared Function GlobalF_Load(ByVal dgTable As DataGrid)
            Dim dv As New DataView
            Dim ds As New DataSet
            dv = New DataView(ds.Tables())
            dgTable.DataSource = dv
            dv.Sort = "Part No."
            CM = (System.Windows.Forms.CurrencyManager)
            dgTable.BindingContext([dv])
            Dim sender As New sender()

But now I get a different error:

BC30311: Value of type
  'System.Data.DataTableCollection'
  cannot be converted to
  'System.Data.DataTable'

Also, I'm not sure if it is good to be declaring these variables new like this since I believe I already call them new elsewhere in my code.

Body:
Instead of:

dgTable.Fill(ds)
dv = New DataView(ds.Tables)
dgTable.DataSource = dv

try:

dv= New DataView(ds.Tables("table name")
dgTable.DataSource = dv


问:
Error response from daemon: Get https://registry-1.docker.io/v2/: dial tcp: lookup registry-1.docker.io on 192.168.65.1:53: no such host
I am new to dockers. When I am running the docker pull sonarqube I am getting the following error.

Error response from daemon: Get https://registry-1.docker.io/v2/: dial TCP: lookup registry-1.docker.io on 192.168.65.1:53: no such host

Can you please let me know why I am getting the error and how can I rectify this.

答:
You need to add to your /etc/hosts in terminal write

$ sudo nano /etc/hosts

add below line and save it, try to run command and it will be working

```<code>34.228.211.243  registry-1.docker.io
</code>```

Body:
You need to add to your /etc/hosts in terminal write

$ sudo nano /etc/hosts

add below line and save it, try to run command and it will be working

34.228.211.243  registry-1.docker.io


问:
How to set slicer value to first available value form table in Power BI?
I have a requirement that the selected value in slicer must be valid.

Let us suppose if I select a value in Store slicer and that store gets deleted from the company. The slicer will still show its name with no data in visuals interacting with the slicer.

Default Value Selected

Updated Slicer Value Manually

But I want only the relevant store selected in my Store slicer. I know its slicer's property to retain the value which is set in it while publishing the report, but is there any workaround for it.

答:
The essence of your question has been asked and covered in this thread:

Initial value of Power BI slicer based on another slicer choice

The answer is NO, but I can propose a workaround.

In the dimension table with stores, add a calculated column Rank which will determine the store with the highest sales. You may use RANKX function for that.

Add StoreName calculated column which returns the text value "The biggest store" (or "Top 1" - or whatever) and original store names for all the other stores. Use IF.

Put the column StoreName which contains "The biggest store" value to the slicer.

Add a visual (card, table) where you will display the original name of currently selected store.

Sort the column StoreName by Rank column designed for that purpose so that The biggest store will float up to the top position in the slicer. Here is how to sort the column by another column.

Since there is always a store with the highest sales you may always have that value ticked in the slicer and it will always show data.

In this example "The biggest store" is "Store for girls". I keep it selected on the slicer. Then I remove all the records of that store from fact table. Apply. And the slicer is still selected as "The biggest store" but now the biggest store means "Store for ladybirds".

Here is a sample file for download (with both approaches in M and DAX):

M Default Slicer Value.pbix

You can make DimStore table completely in DAX by adding calculated table:

```<code>DimStore_DAX =
SUMMARIZECOLUMNS (
    Sales[Store],
    "Sales", [Sale],
    "Rank", RANKX ( ALL ( Sales[Store] ), [Sale] ),
    "StoreName", IF ( RANKX ( ALL ( Sales[Store] ), [Sale] ) = 1, "The biggest store", VALUES ( Sales[Store] )
    )
)
</code>```

Body:
The essence of your question has been asked and covered in this thread:

Initial value of Power BI slicer based on another slicer choice

The answer is NO, but I can propose a workaround.

In the dimension table with stores, add a calculated column Rank which will determine the store with the highest sales. You may use RANKX function for that.

Add StoreName calculated column which returns the text value "The biggest store" (or "Top 1" - or whatever) and original store names for all the other stores. Use IF.

Put the column StoreName which contains "The biggest store" value to the slicer.

Add a visual (card, table) where you will display the original name of currently selected store.

Sort the column StoreName by Rank column designed for that purpose so that The biggest store will float up to the top position in the slicer. Here is how to sort the column by another column.

Since there is always a store with the highest sales you may always have that value ticked in the slicer and it will always show data.

In this example "The biggest store" is "Store for girls". I keep it selected on the slicer. Then I remove all the records of that store from fact table. Apply. And the slicer is still selected as "The biggest store" but now the biggest store means "Store for ladybirds".

Here is a sample file for download (with both approaches in M and DAX):

M Default Slicer Value.pbix

You can make DimStore table completely in DAX by adding calculated table:

DimStore_DAX =
SUMMARIZECOLUMNS (
    Sales[Store],
    "Sales", [Sale],
    "Rank", RANKX ( ALL ( Sales[Store] ), [Sale] ),
    "StoreName", IF ( RANKX ( ALL ( Sales[Store] ), [Sale] ) = 1, "The biggest store", VALUES ( Sales[Store] )
    )
)


问:
select in react doesn't update the label
When i implemented, it worked fine :

```<code> constructor() {
        super(...arguments);
        this.state={
          selectedValue :'' ,
}}
</code>```

Dropdown Code :

```<code>            <select
            className="ui dropdown"
          value={this.state.selectedValue || ''}
          onChange={e =>
            this.setState({
              selectedValue: e.target.value,
              validationError:
                e.target.value === ""
                  ? "You must select"
                  : ""
            })
          }>
          <option value="">--Select Station--</option>
          {this.state.stationList.map(team => (
            <option key={team.id} value={team.id}>
              {team.station}
            </option>
          ))}
        </select>
</code>```

Now on selecting the value label doesn't update on first time, Second time i click it show with previous label selected and on next time click previous last time label displayed

How can i make it work right like normal on select label should update!

see the video here for label error > video

答:
i don't know it should not work but i tried using

```<code>forcepdate()
</code>```

it worked with warnings so i did :

```<code> value={this.updateFunc(this.state.selectedValue)}
</code>```

and called it like:

```<code>updateFunc(e){
console(e);
}
</code>```

i don't think is nay right approach but this worked for me now so i go with this,
state doesn't update immediately, idea of using forceUpdate() brought me to this decision.

Body:
When i implemented, it worked fine :

 constructor() {
        super(...arguments);
        this.state={
          selectedValue :'' ,
}}

Dropdown Code :

            <select
            className="ui dropdown"
          value={this.state.selectedValue || ''}
          onChange={e =>
            this.setState({
              selectedValue: e.target.value,
              validationError:
                e.target.value === ""
                  ? "You must select"
                  : ""
            })
          }>
          <option value="">--Select Station--</option>
          {this.state.stationList.map(team => (
            <option key={team.id} value={team.id}>
              {team.station}
            </option>
          ))}
        </select>

Now on selecting the value label doesn't update on first time, Second time i click it show with previous label selected and on next time click previous last time label displayed

How can i make it work right like normal on select label should update!

see the video here for label error > video

Body:
i don't know it should not work but i tried using

forcepdate()

it worked with warnings so i did :

 value={this.updateFunc(this.state.selectedValue)}

and called it like:

updateFunc(e){
console(e);
}

i don't think is nay right approach but this worked for me now so i go with this,
state doesn't update immediately, idea of using forceUpdate() brought me to this decision.


问:
How to make bootstrap 4 child element display block inside row class
I tried to make child div as display block using d-block class but it's not working bootstrap 4 row class will take display flex, I tried to achieve through clearfix but no result please anyone help me on this.
Please anyone help me on this

Column 3

Lorem ipsum dolor sit amet, consectetur adipisicing elit...

Ut enim ad minim veniam, quis nostrud exercitation ul

Lorem ipsum dolor sit amet, consectetur adipisicing elit...

Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris...

```

答:
The bootstrap 4's .row class has following css:

```<code>.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -15px;
    margin-left: -15px;
}
</code>```

So, element with row class becomes flex-container and all immediate children of this container becomes flex-item or flex-child. so in your code the nested row becomes flex-child and by default for display: flex; the flex-direction property is set to row which makes all flex children sit next to each other on same row and their content decides there width.  Here flex-wrap: wrap; makes children wrap to next line if the flex-container doesn't have enough space.

So by adding d-block class if you were trying to make it take up full width, it will not as it is flex-child. To make it take up full available width you can use bootstrap's sizing class w-100 to force it to take up full available width instead of d-block.

Body:
The bootstrap 4's .row class has following css:

.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -15px;
    margin-left: -15px;
}

So, element with row class becomes flex-container and all immediate children of this container becomes flex-item or flex-child. so in your code the nested row becomes flex-child and by default for display: flex; the flex-direction property is set to row which makes all flex children sit next to each other on same row and their content decides there width.  Here flex-wrap: wrap; makes children wrap to next line if the flex-container doesn't have enough space.

So by adding d-block class if you were trying to make it take up full width, it will not as it is flex-child. To make it take up full available width you can use bootstrap's sizing class w-100 to force it to take up full available width instead of d-block.


问:
PHP CURL GET/POST Digest authentication
I am using curl method to fetch data from REST API. API requires digest authenticate. I have done digest authenticate but not working for post method. Working fine for GET method.

```<code>$username = 'username';
$password = 'password';

$method = 'GET';
// $method = 'POST';

//  FOR POST METHOD. API REQUIRE THIS FORMAT
// $fields = array('APIRquestData' => '{"name":"value","name1":["v4","v5"]}');

$url = "http://apiurl/getmethodname";
// $url = "http://apiurl/postmethodname";

$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch,CURLOPT_TIMEOUT, 30);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT, 30);
if($method == 'POST')
{
  $fieldsData = http_build_query($fields);
  curl_setopt($ch,CURLOPT_POSTFIELDS, $fieldsData);
}

curl_setopt($ch, CURLOPT_HEADER, 1)
$first_response = curl_exec($ch);
$info = curl_getinfo($ch);

preg_match('/WWW-Authenticate: Digest (.*)/', $first_response, $matches);

if(!empty($matches))
{
  $auth_header = $matches[1];
  $auth_header_array = explode(',', $auth_header);
  $parsed = array();

  foreach ($auth_header_array as $pair)
  {
    $vals = explode('=', $pair);
    $parsed[trim($vals[0])] = trim($vals[1], '" ');
  }

  $response_realm     = (isset($parsed['realm'])) ? $parsed['realm'] : "";
  $response_nonce     = (isset($parsed['nonce'])) ? $parsed['nonce'] : "";
  $response_opaque    = (isset($parsed['opaque'])) ? $parsed['opaque'] : "";

  $authenticate1 = md5($username.":".$response_realm.":".$password);
  $authenticate2 = md5($method.":".$url);

  $authenticate_response = md5($authenticate1.":".$response_nonce.":".$authenticate2);

  $request = sprintf('Authorization: Digest username="%s", realm="%s", nonce="%s", opaque="%s", uri="%s", response="%s"',
  $username, $response_realm, $response_nonce, $response_opaque, $url, $authenticate_response);

  $request_header = array($request);

  $ch = curl_init();
  curl_setopt($ch,CURLOPT_URL, $url);
  curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, false);
  curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch,CURLOPT_FOLLOWLOCATION, false);
  curl_setopt($ch,CURLOPT_TIMEOUT, 30);
  curl_setopt($ch,CURLOPT_CONNECTTIMEOUT, 30);

  if($method == 'POST')
  {
    $fieldsData = http_build_query($fields);
    curl_setopt($ch,CURLOPT_POSTFIELDS, $fieldsData);
  }
  curl_setopt($ch, CURLOPT_HTTPHEADER, $request_header);

  $result['response']         = curl_exec($ch);
  $result['info']             = curl_getinfo ($ch);
  $result['info']['errno']    = curl_errno($ch);
  $result['info']['errmsg']   = curl_error($ch);
}

/*
I am getting this as response

Array
(
  [response] =>

  HTTP Status 404 -
  type Status report
  message
  description The requested resource () is not available.
  [info] => Array
    (
        [url] => http://apiurl/postmethodname
        [content_type] => text/html;charset=ISO-8859-1
        [http_code] => 404
        [header_size] => 361
        [request_size] => 551
        [filetime] => -1
        [ssl_verify_result] => 0
        [redirect_count] => 0
        [total_time] => 0.109
        [namelookup_time] => 0
        [connect_time] => 0.063
        [pretransfer_time] => 0.063
        [size_upload] => 114
        [size_download] => 956
        [speed_download] => 8770
        [speed_upload] => 1045
        [download_content_length] => 956
        [upload_content_length] => 114
        [starttransfer_time] => 0.109
        [redirect_time] => 0
        [redirect_url] =>
        [primary_ip] => XXX.X.XX.XX
        [certinfo] => Array
            (
            )

        [primary_port] => 80
        [local_ip] => XX.XX.XX.XXX
        [local_port] => 58850
        [errno] => 0
        [errmsg] =>
    )
)
*/
</code>```

Response says that, 404 means URL not found. But URL is correct.

cURL Information 7.40.0

Thanks in advance.

答:
Thanks @Sufi, Working code for POST request (In case someone else needs this): </p>

```<code><?php
$username = 'username';
$password = 'password';

$url = "your url";

$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch,CURLOPT_TIMEOUT, 30);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch,CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HEADER, 1);
$first_response = curl_exec($ch);
$info = curl_getinfo($ch);

preg_match('/WWW-Authenticate: Digest (.*)/', $first_response, $matches);

if(!empty($matches))
{
  $auth_header = $matches[1];
  $auth_header_array = explode(',', $auth_header);
  $parsed = array();

  foreach ($auth_header_array as $pair)
  {
    $vals = explode('=', $pair);
    $parsed[trim($vals[0])] = trim($vals[1], '" ');
  }

  $response_realm     = (isset($parsed['realm'])) ? $parsed['realm'] : "";
  $response_nonce     = (isset($parsed['nonce'])) ? $parsed['nonce'] : "";
  $response_opaque    = (isset($parsed['opaque'])) ? $parsed['opaque'] : "";

  $authenticate1 = md5($username.":".$response_realm.":".$password);
  $authenticate2 = md5("POST:".$url);

  $authenticate_response = md5($authenticate1.":".$response_nonce.":".$authenticate2);

  $request = sprintf('Authorization: Digest username="%s", realm="%s", nonce="%s", opaque="%s", uri="%s", response="%s"',
  $username, $response_realm, $response_nonce, $response_opaque, $url, $authenticate_response);

  $request_header = array($request);
  $request_header[] = 'Content-Type:application/json';

  $ch = curl_init();
  curl_setopt($ch,CURLOPT_URL, $url);
  curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, false);
  curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch,CURLOPT_FOLLOWLOCATION, false);
  curl_setopt($ch,CURLOPT_TIMEOUT, 30);
  curl_setopt($ch,CURLOPT_CONNECTTIMEOUT, 30);
  curl_setopt($ch,CURLOPT_CUSTOMREQUEST, "POST");
  curl_setopt($ch, CURLOPT_HTTPHEADER, $request_header);

  $result['response']         = curl_exec($ch);
  $result['info']             = curl_getinfo ($ch);
  $result['info']['errno']    = curl_errno($ch);
  $result['info']['errmsg']   = curl_error($ch);

  var_dump($result);
}
?>
</code>```

Title: PHP CURL GET/POST Digest authentication

Body:
I am using curl method to fetch data from REST API. API requires digest authenticate. I have done digest authenticate but not working for post method. Working fine for GET method.

$username = 'username';
$password = 'password';

$method = 'GET';
// $method = 'POST';

//  FOR POST METHOD. API REQUIRE THIS FORMAT
// $fields = array('APIRquestData' => '{"name":"value","name1":["v4","v5"]}');

$url = "http://apiurl/getmethodname";
// $url = "http://apiurl/postmethodname";

$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch,CURLOPT_TIMEOUT, 30);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT, 30);
if($method == 'POST')
{
  $fieldsData = http_build_query($fields);
  curl_setopt($ch,CURLOPT_POSTFIELDS, $fieldsData);
}

curl_setopt($ch, CURLOPT_HEADER, 1)
$first_response = curl_exec($ch);
$info = curl_getinfo($ch);

preg_match('/WWW-Authenticate: Digest (.*)/', $first_response, $matches);

if(!empty($matches))
{
  $auth_header = $matches[1];
  $auth_header_array = explode(',', $auth_header);
  $parsed = array();

  foreach ($auth_header_array as $pair)
  {
    $vals = explode('=', $pair);
    $parsed[trim($vals[0])] = trim($vals[1], '" ');
  }

  $response_realm     = (isset($parsed['realm'])) ? $parsed['realm'] : "";
  $response_nonce     = (isset($parsed['nonce'])) ? $parsed['nonce'] : "";
  $response_opaque    = (isset($parsed['opaque'])) ? $parsed['opaque'] : "";

  $authenticate1 = md5($username.":".$response_realm.":".$password);
  $authenticate2 = md5($method.":".$url);

  $authenticate_response = md5($authenticate1.":".$response_nonce.":".$authenticate2);

  $request = sprintf('Authorization: Digest username="%s", realm="%s", nonce="%s", opaque="%s", uri="%s", response="%s"',
  $username, $response_realm, $response_nonce, $response_opaque, $url, $authenticate_response);

  $request_header = array($request);

  $ch = curl_init();
  curl_setopt($ch,CURLOPT_URL, $url);
  curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, false);
  curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch,CURLOPT_FOLLOWLOCATION, false);
  curl_setopt($ch,CURLOPT_TIMEOUT, 30);
  curl_setopt($ch,CURLOPT_CONNECTTIMEOUT, 30);

  if($method == 'POST')
  {
    $fieldsData = http_build_query($fields);
    curl_setopt($ch,CURLOPT_POSTFIELDS, $fieldsData);
  }
  curl_setopt($ch, CURLOPT_HTTPHEADER, $request_header);

  $result['response']         = curl_exec($ch);
  $result['info']             = curl_getinfo ($ch);
  $result['info']['errno']    = curl_errno($ch);
  $result['info']['errmsg']   = curl_error($ch);
}

/*
I am getting this as response

Array
(
  [response] =>

  HTTP Status 404 -
  type Status report
  message
  description The requested resource () is not available.
  [info] => Array
    (
        [url] => http://apiurl/postmethodname
        [content_type] => text/html;charset=ISO-8859-1
        [http_code] => 404
        [header_size] => 361
        [request_size] => 551
        [filetime] => -1
        [ssl_verify_result] => 0
        [redirect_count] => 0
        [total_time] => 0.109
        [namelookup_time] => 0
        [connect_time] => 0.063
        [pretransfer_time] => 0.063
        [size_upload] => 114
        [size_download] => 956
        [speed_download] => 8770
        [speed_upload] => 1045
        [download_content_length] => 956
        [upload_content_length] => 114
        [starttransfer_time] => 0.109
        [redirect_time] => 0
        [redirect_url] =>
        [primary_ip] => XXX.X.XX.XX
        [certinfo] => Array
            (
            )

        [primary_port] => 80
        [local_ip] => XX.XX.XX.XXX
        [local_port] => 58850
        [errno] => 0
        [errmsg] =>
    )
)
*/

Response says that, 404 means URL not found. But URL is correct.

cURL Information 7.40.0

Thanks in advance.

Body:
Thanks @Sufi, Working code for POST request (In case someone else needs this):

<?php
$username = 'username';
$password = 'password';

$url = "your url";

$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch,CURLOPT_TIMEOUT, 30);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch,CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HEADER, 1);
$first_response = curl_exec($ch);
$info = curl_getinfo($ch);

preg_match('/WWW-Authenticate: Digest (.*)/', $first_response, $matches);

if(!empty($matches))
{
  $auth_header = $matches[1];
  $auth_header_array = explode(',', $auth_header);
  $parsed = array();

  foreach ($auth_header_array as $pair)
  {
    $vals = explode('=', $pair);
    $parsed[trim($vals[0])] = trim($vals[1], '" ');
  }

  $response_realm     = (isset($parsed['realm'])) ? $parsed['realm'] : "";
  $response_nonce     = (isset($parsed['nonce'])) ? $parsed['nonce'] : "";
  $response_opaque    = (isset($parsed['opaque'])) ? $parsed['opaque'] : "";

  $authenticate1 = md5($username.":".$response_realm.":".$password);
  $authenticate2 = md5("POST:".$url);

  $authenticate_response = md5($authenticate1.":".$response_nonce.":".$authenticate2);

  $request = sprintf('Authorization: Digest username="%s", realm="%s", nonce="%s", opaque="%s", uri="%s", response="%s"',
  $username, $response_realm, $response_nonce, $response_opaque, $url, $authenticate_response);

  $request_header = array($request);
  $request_header[] = 'Content-Type:application/json';

  $ch = curl_init();
  curl_setopt($ch,CURLOPT_URL, $url);
  curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, false);
  curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch,CURLOPT_FOLLOWLOCATION, false);
  curl_setopt($ch,CURLOPT_TIMEOUT, 30);
  curl_setopt($ch,CURLOPT_CONNECTTIMEOUT, 30);
  curl_setopt($ch,CURLOPT_CUSTOMREQUEST, "POST");
  curl_setopt($ch, CURLOPT_HTTPHEADER, $request_header);

  $result['response']         = curl_exec($ch);
  $result['info']             = curl_getinfo ($ch);
  $result['info']['errno']    = curl_errno($ch);
  $result['info']['errmsg']   = curl_error($ch);

  var_dump($result);
}
?>


问:
How to connect to the mdf database?
Used by:

WPF Framework;

Entity Framework.

I get _studBindList.Count = 0.

How to connect to the mdf database?

Category.cs

```<code>using System.ComponentModel.DataAnnotations.Schema;

namespace WpfAppFrm
{
    [Table("Categories")]
    public class Category
    {
        public Category()
        {
            // this.Products = new ObservableCollection<Product>();
        }

        public int CategoryId { get; set; }
        public string Name { get; set; }

        // public virtual ObservableCollection<Product> Products { get; private set; }

    }
}
</code>```

ProductContext.cs

```<code>using System.Data.Entity;

namespace WpfAppFrm
{
    public class ProductContext : DbContext
    {
        // public ProductContext() : base("DefaultConnection")
        public ProductContext(string сonnectionString)
        {

        }

        public DbSet<Category> Categories { get; set; }
        // public DbSet<Product> Products { get; set; }
    }
}
</code>```

MainWindow.xaml.cs

```<code>//
using System.ComponentModel;
using System.Data.Entity;

namespace WpfAppFrm
{
    /// <summary>
    /// Логика взаимодействия для MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        // public static string сonnectionString = @"C:\test\DB\NorthwindC.mdf";
        public static string сonnectionString = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\test\DB\NorthwindC.mdf;Integrated Security=True;Connect Timeout=30";
        private ProductContext _context = new ProductContext(сonnectionString);

        public MainWindow()
        {
            InitializeComponent();
        }

        private void Window_Loaded_1(object sender, RoutedEventArgs e)
        {
            try
            {
                System.Windows.Data.CollectionViewSource categoryViewSource =
            ((System.Windows.Data.CollectionViewSource)(this.FindResource("categoryViewSource")));

                _context.Categories.Load();

                BindingList<Category> _studBindList = _context.Categories.Local.ToBindingList();

                categoryViewSource.Source = _context.Categories.Local;
            }
            catch (Exception ex)
            {

                throw;
            }
        }
    }
}
</code>```

MainWindow.xaml

```<code><Window x:Class="WpfAppFrm.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfAppFrm"
        mc:Ignorable="d"
        Title="MainWindow" Height="443.317" Width="243.069" Loaded="Window_Loaded_1">
        <Window.Resources>
            <CollectionViewSource x:Key="categoryViewSource"
                                d:DesignSource="{d:DesignInstance {x:Type local:Category}, CreateList=True}"/>
            <CollectionViewSource x:Key="categoryProductsViewSource" Source="{Binding Products, Source={StaticResource categoryViewSource}}"/>
        </Window.Resources>
    <Grid DataContext="{StaticResource categoryViewSource}" Margin="0,0,28,0">
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition Width="0*"/>
            <ColumnDefinition Width="0*"/>
        </Grid.ColumnDefinitions>
        <DataGrid x:Name="categoryDataGrid" AutoGenerateColumns="False" EnableRowVirtualization="True"
                    ItemsSource="{Binding}" Margin="13,13,3,257"
                    RowDetailsVisibilityMode="VisibleWhenSelected">
            <DataGrid.Columns>
                <DataGridTextColumn x:Name="categoryIdColumn" Binding="{Binding CategoryId}"
                                    Header="CategoryId" Width="SizeToHeader"/>
                <DataGridTextColumn x:Name="nameColumn" Binding="{Binding Name}"
                                    Header="Name" Width="SizeToHeader"/>
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
</Window>
</code>```

App.config

```<code><?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
    </startup>
</configuration>
</code>```

SQL table Categories

```<code>CREATE TABLE [dbo].[Categories] (
    [CategoryId] INT           IDENTITY (1, 1) NOT NULL,
    [Name]       NVARCHAR (40) NULL,
    PRIMARY KEY CLUSTERED ([CategoryId] ASC)
);
</code>```

Picture-1

Update-1

Picture-2

Update-2

Added methods:

AddEntity();

GetAll();

Method AddEntity().

```<code> public void AddEntity()
    {
        Category category = new Category
        {
            Name = "Name_Category_4"
        };

        _context.Categories.Add(category);
        _context.SaveChanges();
    }
</code>```

Method GetAll().

```<code>public void GetAll()
        {
            _context.Categories.Load();

            BindingList<Category> _studBindList = _context.Categories.Local.ToBindingList();
        }
</code>```

I ran debugging twice.

When I debugged a second time, I made a picture.

Picture-3

答: .mdf is a file format used by SQL Server. You can't directly connect to such a file. Instead you would need to import that file as a database into SQL Server (and if you don't have SQL Server you'll have to install that too).</p>

Title: How to connect to the mdf database?

Body:
Used by:

WPF Framework;

Entity Framework.

I get _studBindList.Count = 0.

How to connect to the mdf database?

Category.cs

using System.ComponentModel.DataAnnotations.Schema;

namespace WpfAppFrm
{
    [Table("Categories")]
    public class Category
    {
        public Category()
        {
            // this.Products = new ObservableCollection<Product>();
        }

        public int CategoryId { get; set; }
        public string Name { get; set; }

        // public virtual ObservableCollection<Product> Products { get; private set; }

    }
}

ProductContext.cs

using System.Data.Entity;

namespace WpfAppFrm
{
    public class ProductContext : DbContext
    {
        // public ProductContext() : base("DefaultConnection")
        public ProductContext(string сonnectionString)
        {

        }

        public DbSet<Category> Categories { get; set; }
        // public DbSet<Product> Products { get; set; }
    }
}

MainWindow.xaml.cs

//
using System.ComponentModel;
using System.Data.Entity;

namespace WpfAppFrm
{
    ///
    /// Логика взаимодействия для MainWindow.xaml
    ///
    public partial class MainWindow : Window
    {
        // public static string сonnectionString = @"C:\test\DB\NorthwindC.mdf";
        public static string сonnectionString = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\test\DB\NorthwindC.mdf;Integrated Security=True;Connect Timeout=30";
        private ProductContext _context = new ProductContext(сonnectionString);

        public MainWindow()
        {
            InitializeComponent();
        }

        private void Window_Loaded_1(object sender, RoutedEventArgs e)
        {
            try
            {
                System.Windows.Data.CollectionViewSource categoryViewSource =
            ((System.Windows.Data.CollectionViewSource)(this.FindResource("categoryViewSource")));

                _context.Categories.Load();

                BindingList<Category> _studBindList = _context.Categories.Local.ToBindingList();

                categoryViewSource.Source = _context.Categories.Local;
            }
            catch (Exception ex)
            {

                throw;
            }
        }
    }
}

MainWindow.xaml

<Window x:Class="WpfAppFrm.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfAppFrm"
        mc:Ignorable="d"
        Title="MainWindow" Height="443.317" Width="243.069" Loaded="Window_Loaded_1">
        <Window.Resources>
            <CollectionViewSource x:Key="categoryViewSource"
                                d:DesignSource="{d:DesignInstance {x:Type local:Category}, CreateList=True}"/>
            <CollectionViewSource x:Key="categoryProductsViewSource" Source="{Binding Products, Source={StaticResource categoryViewSource}}"/>
        </Window.Resources>
    <Grid DataContext="{StaticResource categoryViewSource}" Margin="0,0,28,0">
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition Width="0*"/>
            <ColumnDefinition Width="0*"/>
        </Grid.ColumnDefinitions>
        <DataGrid x:Name="categoryDataGrid" AutoGenerateColumns="False" EnableRowVirtualization="True"
                    ItemsSource="{Binding}" Margin="13,13,3,257"
                    RowDetailsVisibilityMode="VisibleWhenSelected">
            <DataGrid.Columns>
                <DataGridTextColumn x:Name="categoryIdColumn" Binding="{Binding CategoryId}"
                                    Header="CategoryId" Width="SizeToHeader"/>
                <DataGridTextColumn x:Name="nameColumn" Binding="{Binding Name}"
                                    Header="Name" Width="SizeToHeader"/>
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
</Window>

App.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
    </startup>
</configuration>

SQL table Categories

CREATE TABLE [dbo].[Categories] (
    [CategoryId] INT           IDENTITY (1, 1) NOT NULL,
    [Name]       NVARCHAR (40) NULL,
    PRIMARY KEY CLUSTERED ([CategoryId] ASC)
);

Picture-1

Update-1

Picture-2

Update-2

Added methods:

AddEntity();

GetAll();

Method AddEntity().

 public void AddEntity()
    {
        Category category = new Category
        {
            Name = "Name_Category_4"
        };

        _context.Categories.Add(category);
        _context.SaveChanges();
    }

Method GetAll().

public void GetAll()
        {
            _context.Categories.Load();

            BindingList<Category> _studBindList = _context.Categories.Local.ToBindingList();
        }

I ran debugging twice.

When I debugged a second time, I made a picture.

Picture-3


问:
How to get the Specific Form Field value using JQuery
I have a form

```<code><form id="post_comment" action="cmt.php" method="post">
   <input type="hidden" name="type" value="sub" />
   <textarea id="body"></textarea>
</form>
</code>```

I am accessing the form using this code

```<code>$("#post_comment").submit(function(event){

    var form = $(this);

});
</code>```

How can I get the value of <input type="hidden" name="type" value="sub" /> from this form.
I tried to get using form.input("type") but it is not working.

答:
Another approach for this

Consider if you have multiple forms with multiple input fields having name attribute than this code will be helpful for you :

```<code>$("#formId input[name='valueOfNameAttribute']").val()
$("#formId textarea[name='message']").val()
</code>```

Hope it'll help somebody.

Body:
I have a form

<form id="post_comment" action="cmt.php" method="post">
   <input type="hidden" name="type" value="sub" />
   <textarea id="body"></textarea>
</form>

I am accessing the form using this code

$("#post_comment").submit(function(event){

    var form = $(this);

});

How can I get the value of <input type="hidden" name="type" value="sub" /> from this form.
I tried to get using form.input("type") but it is not working.

Body:
Another approach for this

Consider if you have multiple forms with multiple input fields having name attribute than this code will be helpful for you :

$("#formId input[name='valueOfNameAttribute']").val()
$("#formId textarea[name='message']").val()

Hope it'll help somebody.


问:
Python "list order"
I have 2 troubles with my data, can anyone help me:

How can I get from this:

1.

```<code>k=[['1','7', 'U1'],
 ['1.5', '8', 'U1'],
 ['2', '5.5', 'U1']]
</code>```

get this

```<code>1,7,U1
1.5,8,U1
2,5.5,U1
</code>```

EDIT 2   I MAKE SOME CHANGE ON  second case:, still searching solution for this one:

2. And how to get, from this

```<code>l=array([[[ 4.24231542], 'U1'],
       [[ 3.41424819], 'U1'],
       [[ 2.17214734], 'U1'],], dtype=object)
</code>```

get

```<code>4.24231542,U1
3.41424819,U1
2.17214734,U1
</code>```

Thanks

Title: Python "list order"

Body:
I have 2 troubles with my data, can anyone help me:

How can I get from this:

1.

k=[['1','7', 'U1'],
 ['1.5', '8', 'U1'],
 ['2', '5.5', 'U1']]

get this

1,7,U1
1.5,8,U1
2,5.5,U1

EDIT 2   I MAKE SOME CHANGE ON  second case:, still searching solution for this one:

2. And how to get, from this

l=array([[[ 4.24231542], 'U1'],
       [[ 3.41424819], 'U1'],
       [[ 2.17214734], 'U1'],], dtype=object)

get

4.24231542,U1
3.41424819,U1
2.17214734,U1

Thanks

Body:
1)

for x in k:
    print(','.join(x))

2)

for x,y in l:
    print('%.8f,%s' % (x[0], y))


问:
Android Spinner with multiple choice
How do I create spinner which allows to choose multiple items, i.e spinner with check boxes?</p>

答:
I have written custom implementation of MultiSpinner. It's looking similar to normal spinner, but it has checkboxes instead of radiobuttons. Selected values are displayed on the spinner divided by comma. All values are checked by default. Try it:

```<code>package cz.destil.settleup.gui;

public class MultiSpinner extends Spinner implements
        OnMultiChoiceClickListener, OnCancelListener {

    private List<String> items;
    private boolean[] selected;
    private String defaultText;
    private MultiSpinnerListener listener;

    public MultiSpinner(Context context) {
        super(context);
    }

    public MultiSpinner(Context arg0, AttributeSet arg1) {
        super(arg0, arg1);
    }

    public MultiSpinner(Context arg0, AttributeSet arg1, int arg2) {
        super(arg0, arg1, arg2);
    }

    @Override
    public void onClick(DialogInterface dialog, int which, boolean isChecked) {
        if (isChecked)
            selected[which] = true;
        else
            selected[which] = false;
    }

    @Override
    public void onCancel(DialogInterface dialog) {
        // refresh text on spinner
        StringBuffer spinnerBuffer = new StringBuffer();
        boolean someSelected = false;
        for (int i = 0; i < items.size(); i++) {
            if (selected[i] == true) {
                spinnerBuffer.append(items.get(i));
                spinnerBuffer.append(", ");
                someSelected = true;
            }
        }
        String spinnerText;
        if (someSelected) {
            spinnerText = spinnerBuffer.toString();
            if (spinnerText.length() > 2)
                spinnerText = spinnerText.substring(0, spinnerText.length() - 2);
        } else {
            spinnerText = defaultText;
        }
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(getContext(),
                android.R.layout.simple_spinner_item,
                new String[] { spinnerText });
        setAdapter(adapter);
        listener.onItemsSelected(selected);
    }

    @Override
    public boolean performClick() {
        AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
        builder.setMultiChoiceItems(
                items.toArray(new CharSequence[items.size()]), selected, this);
        builder.setPositiveButton(android.R.string.ok,
                new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.cancel();
                    }
                });
        builder.setOnCancelListener(this);
        builder.show();
        return true;
    }

    public void setItems(List<String> items, String allText,
            MultiSpinnerListener listener) {
        this.items = items;
        this.defaultText = allText;
        this.listener = listener;

        // all selected by default
        selected = new boolean[items.size()];
        for (int i = 0; i < selected.length; i++)
            selected[i] = true;

        // all text on the spinner
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(getContext(),
                android.R.layout.simple_spinner_item, new String[] { allText });
        setAdapter(adapter);
    }

    public interface MultiSpinnerListener {
        public void onItemsSelected(boolean[] selected);
    }
}
</code>```

You use it in XML like this:

```<code><cz.destil.settleup.gui.MultiSpinner android:id="@+id/multi_spinner" />
</code>```

And you pass data to it in Java like this:

```<code>MultiSpinner multiSpinner = (MultiSpinner) findViewById(R.id.multi_spinner);
multiSpinner.setItems(items, getString(R.string.for_all), this);
</code>```

Also you need to implement the listener,which will return the same length array , with true or false to show selected to unselected..

```<code>public void onItemsSelected(boolean[] selected);
</code>```

Title: Android Spinner with multiple choice

Body:
I have written custom implementation of MultiSpinner. It's looking similar to normal spinner, but it has checkboxes instead of radiobuttons. Selected values are displayed on the spinner divided by comma. All values are checked by default. Try it:

package cz.destil.settleup.gui;

public class MultiSpinner extends Spinner implements
        OnMultiChoiceClickListener, OnCancelListener {

    private List<String> items;
    private boolean[] selected;
    private String defaultText;
    private MultiSpinnerListener listener;

    public MultiSpinner(Context context) {
        super(context);
    }

    public MultiSpinner(Context arg0, AttributeSet arg1) {
        super(arg0, arg1);
    }

    public MultiSpinner(Context arg0, AttributeSet arg1, int arg2) {
        super(arg0, arg1, arg2);
    }

    @Override
    public void onClick(DialogInterface dialog, int which, boolean isChecked) {
        if (isChecked)
            selected[which] = true;
        else
            selected[which] = false;
    }

    @Override
    public void onCancel(DialogInterface dialog) {
        // refresh text on spinner
        StringBuffer spinnerBuffer = new StringBuffer();
        boolean someSelected = false;
        for (int i = 0; i < items.size(); i++) {
            if (selected[i] == true) {
                spinnerBuffer.append(items.get(i));
                spinnerBuffer.append(", ");
                someSelected = true;
            }
        }
        String spinnerText;
        if (someSelected) {
            spinnerText = spinnerBuffer.toString();
            if (spinnerText.length() > 2)
                spinnerText = spinnerText.substring(0, spinnerText.length() - 2);
        } else {
            spinnerText = defaultText;
        }
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(getContext(),
                android.R.layout.simple_spinner_item,
                new String[] { spinnerText });
        setAdapter(adapter);
        listener.onItemsSelected(selected);
    }

    @Override
    public boolean performClick() {
        AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
        builder.setMultiChoiceItems(
                items.toArray(new CharSequence[items.size()]), selected, this);
        builder.setPositiveButton(android.R.string.ok,
                new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.cancel();
                    }
                });
        builder.setOnCancelListener(this);
        builder.show();
        return true;
    }

    public void setItems(List<String> items, String allText,
            MultiSpinnerListener listener) {
        this.items = items;
        this.defaultText = allText;
        this.listener = listener;

        // all selected by default
        selected = new boolean[items.size()];
        for (int i = 0; i < selected.length; i++)
            selected[i] = true;

        // all text on the spinner
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(getContext(),
                android.R.layout.simple_spinner_item, new String[] { allText });
        setAdapter(adapter);
    }

    public interface MultiSpinnerListener {
        public void onItemsSelected(boolean[] selected);
    }
}

You use it in XML like this:

<cz.destil.settleup.gui.MultiSpinner android:id="@+id/multi_spinner" />

And you pass data to it in Java like this:

MultiSpinner multiSpinner = (MultiSpinner) findViewById(R.id.multi_spinner);
multiSpinner.setItems(items, getString(R.string.for_all), this);

Also you need to implement the listener,which will return the same length array , with true or false to show selected to unselected..

public void onItemsSelected(boolean[] selected);


问:
Cancel previous release azure pipeline yaml
When creating a release pipeline via the UI (Release) in Azure Devops you have the option cancel previous release.

How can i create this with YAML in my release pipeline, now as you can see al the previous releases are still waiting

答:
Cancel previous release azure pipeline yaml

For this issue ,I am afraid it is currently not supported in yaml.

From this document , we can know that: Queuing policies are not yet supported in YAML pipelines.

Subsequent releases setting is also part of the Deployment queue settings. So Deploy latest and cancel the others should also not be supported at present, and can only be implemented in classic pipeline.

Apart from the negative answer, I think what you want is a good idea! So I post a feature request here in DC forum. Anyone interested in this can vote for it and track it. You could also vote that suggestion ticket and share your comment there.The product team would provide the updates if they view it. Hope this helps.


问:
Take a list in input remove all duplicates and count how many they are
I have tried to make this function but sometimes I get a problem on runtime. I need to take in input a list like 1-2-3-2-4-6-1-2 and the list should be modified as 1-2-3-4-6 so once for every node and I should save how many times is a node repeated so for example 1 is repeated 2 times the 2 is repeated 3 times etc.
But sometimes it doesn't work I cannot understand why.
If you run it following what I wrote just after you'll see the problem:
How many nodes: 5 than write 1, 1, 2, 4, 2 and the output should be 1, 2 -> 2, 2 -> 4 (that means 1 is repeated two times, 2 is repeated two times and 4 is repeated 1 time). If I give in input 1, 2, 3, 2, 1 I get the "right output" plus a garbage value. More are the numbers higher is the probability that it doesn't work :(</p>

```<code>#include <stdio.h>
#include <stdlib.h>

typedef struct Node{
   int val;
   int rip;
   struct Node *next;
} node;

node *modify(node *head);

void print(node *head2);

int main(){

   int m, i;

   printf("How many nodes: \n");
   scanf("%d", &m);

   node *head = NULL;
   head = (node *)malloc(sizeof(node));
   node *temp = head;
   node *head2 = NULL;
  for(i=0; i < m; i++){
       temp->next = (node *)malloc(sizeof(node));
       printf("Write the value in position %d: \n", i);
       scanf("%d", &temp->val);
       temp = temp->next;
       temp->next = NULL;
   }

   head2 = modify(head);

   print(head2);

   return 0;
}

node *modify(node *head){

   int counter, pass, m;

   node *curr = head;
   node *track = head;

while (track->next != NULL){
       counter = 0;
       pass = 0;
       m = track->val;
       while((curr)->next != NULL){
           if(m == (curr)->val){
               pass++;
               counter++;
               if(pass > 1){
                   node *removed = curr;
                   curr = (curr)->next;
                   free(removed);
               }
               if(pass == 1)
                   curr = curr->next;
           }
           else{
               curr = (curr)->next;
           }
       }
       track->rip = counter;
       track = track->next;
       curr = track;
   }

return head;
}

void print(node *head2){

   while(head2->next != NULL){
       printf("%d, %d -> ", head2->val, head2->rip);
       head2 = head2->next;
   }
   printf("\n");
}
</code>```

答:
I corrected your program :

```<code>#include <stdio.h>
#include <stdlib.h>

typedef struct Node{
    int val;
    int rip;
    struct Node *next;
} node;

node *modify(node *head);

void print(node *head2);

int main(){

    int m, i;

    printf("How many nodes: \n");
    scanf("%d", &m);

    node *head = NULL;
    head = (node *)malloc(sizeof(node));
    node *temp = head;
    node *head2 = NULL;

    printf("Write the value in HEAD position : \n");
    scanf("%d", &temp->val);
    temp->rip=0;
    temp->next = NULL;

    for(i=0; i < m-1; i++)
    {
        temp->next = (node *)malloc(sizeof(node));
        printf("Write the value in position %d: \n", i);
        temp = temp->next;
        scanf("%d", &temp->val);
        temp->rip=0;
        temp->next = NULL;
    }

    head2 = modify(head);

    print(head2);

    return 0;
}

node *modify(node *head){

    int counter, pass, m;

    node *curr = head;
    node *track = head;
    node *precNode;

    while (track != NULL){
        counter = 0;
        pass = 0;
        m = track->val;
        while( curr != NULL){
            if(m == (curr)->val){
                pass++;
                counter++;
                if(pass > 1){
                    node *removed = curr;

                    precNode->next = (curr)->next;

                    curr = (curr)->next;
                    free(removed);

                }
                if(pass == 1)
                {
                    precNode = curr;
                    curr = curr->next;
                }
            }
            else{
                precNode = curr;
                curr = (curr)->next;
            }
        }
        track->rip = counter;
        track = track->next;
        curr = track;
    }

    return head;
}

void print(node *head2){

    while(head2 != NULL){
        printf("[%d, %d]  ->   ", head2->val, head2->rip);
        head2 = head2->next;
    }
    printf("\n");
}
</code>```

Result:

Body:
I have tried to make this function but sometimes I get a problem on runtime. I need to take in input a list like 1-2-3-2-4-6-1-2 and the list should be modified as 1-2-3-4-6 so once for every node and I should save how many times is a node repeated so for example 1 is repeated 2 times the 2 is repeated 3 times etc.
But sometimes it doesn't work I cannot understand why.
If you run it following what I wrote just after you'll see the problem:
How many nodes: 5 than write 1, 1, 2, 4, 2 and the output should be 1, 2 -> 2, 2 -> 4 (that means 1 is repeated two times, 2 is repeated two times and 4 is repeated 1 time). If I give in input 1, 2, 3, 2, 1 I get the "right output" plus a garbage value. More are the numbers higher is the probability that it doesn't work :(

#include <stdio.h>
#include <stdlib.h>

typedef struct Node{
   int val;
   int rip;
   struct Node *next;
} node;

node *modify(node *head);

void print(node *head2);

int main(){

   int m, i;

   printf("How many nodes: \n");
   scanf("%d", &m);

   node *head = NULL;
   head = (node *)malloc(sizeof(node));
   node *temp = head;
   node *head2 = NULL;
  for(i=0; i < m; i++){
       temp->next = (node *)malloc(sizeof(node));
       printf("Write the value in position %d: \n", i);
       scanf("%d", &temp->val);
       temp = temp->next;
       temp->next = NULL;
   }

   head2 = modify(head);

   print(head2);

   return 0;
}

node *modify(node *head){

   int counter, pass, m;

   node *curr = head;
   node *track = head;

while (track->next != NULL){
       counter = 0;
       pass = 0;
       m = track->val;
       while((curr)->next != NULL){
           if(m == (curr)->val){
               pass++;
               counter++;
               if(pass > 1){
                   node *removed = curr;
                   curr = (curr)->next;
                   free(removed);
               }
               if(pass == 1)
                   curr = curr->next;
           }
           else{
               curr = (curr)->next;
           }
       }
       track->rip = counter;
       track = track->next;
       curr = track;
   }

return head;
}

void print(node *head2){

   while(head2->next != NULL){
       printf("%d, %d -> ", head2->val, head2->rip);
       head2 = head2->next;
   }
   printf("\n");
}

Body:
I corrected your program :

#include <stdio.h>
#include <stdlib.h>

typedef struct Node{
    int val;
    int rip;
    struct Node *next;
} node;

node *modify(node *head);

void print(node *head2);

int main(){

    int m, i;

    printf("How many nodes: \n");
    scanf("%d", &m);

    node *head = NULL;
    head = (node *)malloc(sizeof(node));
    node *temp = head;
    node *head2 = NULL;

    printf("Write the value in HEAD position : \n");
    scanf("%d", &temp->val);
    temp->rip=0;
    temp->next = NULL;

    for(i=0; i < m-1; i++)
    {
        temp->next = (node *)malloc(sizeof(node));
        printf("Write the value in position %d: \n", i);
        temp = temp->next;
        scanf("%d", &temp->val);
        temp->rip=0;
        temp->next = NULL;
    }

    head2 = modify(head);

    print(head2);

    return 0;
}

node *modify(node *head){

    int counter, pass, m;

    node *curr = head;
    node *track = head;
    node *precNode;

    while (track != NULL){
        counter = 0;
        pass = 0;
        m = track->val;
        while( curr != NULL){
            if(m == (curr)->val){
                pass++;
                counter++;
                if(pass > 1){
                    node *removed = curr;

                    precNode->next = (curr)->next;

                    curr = (curr)->next;
                    free(removed);

                }
                if(pass == 1)
                {
                    precNode = curr;
                    curr = curr->next;
                }
            }
            else{
                precNode = curr;
                curr = (curr)->next;
            }
        }
        track->rip = counter;
        track = track->next;
        curr = track;
    }

    return head;
}

void print(node *head2){

    while(head2 != NULL){
        printf("[%d, %d]  ->   ", head2->val, head2->rip);
        head2 = head2->next;
    }
    printf("\n");
}

Result:


问:
Does history.push supposed to render the component associated with the route?
So I'm creating a loader component that requests data to a server, then based on the response - then the loader page redirects/reroutes them to other pages.

But for some reason history.push changes the route but does not render the component and remains with the <LoaderPage> component. Not sure what am I missing. So kindly help.

I have wrapped all pages with the <LoaderPage> component as my goal is when every time a user visits any route the <LoaderPage> component renders first then it does its job then redirects/reroutes users to other pages.

loader.tsx

```<code>import React from 'react';
import { useHistory } from 'react-router-dom'
import { AnimatedLodingScreen } from './loaders/AnimatedLodingScreen'

type loaderProps = {
 children: React.ReactNode;
};

export const LoaderPage = ({ children }:loaderProps) => {
  const history = useHistory();
  React.useEffect(() => {
    const session = http.get('/some-route');
    session.then((result) => {
      if(result.authenticated) {
        history.push('home'); // when user is logged
      }
      history.push('/login'); // not authenticated
    }
  }, [])

  return (
    <AnimatedLodingScreen/>
  );
}
</code>```

app.tsx

```<code>import React from 'react';
import { BrowserRouter, Route, Switch } from 'react-router-dom';
import { observer } from 'mobx-react';
import { LoaderPage } from 'pages/loaders/LoaderPage';
import { SomeComponent1, SomeComponent2 } from 'pages/index'

export const App: React.FC = observer(() => {
  return (
    <BrowserRouter>
      <LoaderPage>
        <Route path='/home' exact component={SomeComponent1}/>
        <Route path='/login' exact component={SomeComponent2}/>
        // and so on... I have alot of routes in fact these routes are looped via .map and
        // type-checked i just put it like this for simplicity
      </LoaderPage>
    </BrowserRouter>
  );
});
</code>```

index.tsx

```<code>import React from 'react';
import ReactDOM from 'react-dom';
import { App } from 'app/app';

ReactDOM.render(<App/>, document.getElementById('root'));

</code>```

答:
The children props taken by your LoaderPage component isn't used for render anywhere within it, and thus nothing is rendered.

```<code>export const LoaderPage = ({ children }:loaderProps) => {
  const history = useHistory();
  React.useEffect(() => {
    const session = http.get('/some-route');
    session.then((result) => {
      if(result.authenticated) {
        history.push('home'); // when user is logged
      }
      history.push('/login'); // not authenticated
    }
  }, [])

  return (
    {children || <AnimatedLodingScreen/>}
  );
}
</code>```

Body:
So I'm creating a loader component that requests data to a server, then based on the response - then the loader page redirects/reroutes them to other pages.

But for some reason history.push changes the route but does not render the component and remains with the <LoaderPage> component. Not sure what am I missing. So kindly help.

I have wrapped all pages with the <LoaderPage> component as my goal is when every time a user visits any route the <LoaderPage> component renders first then it does its job then redirects/reroutes users to other pages.

loader.tsx

import React from 'react';
import { useHistory } from 'react-router-dom'
import { AnimatedLodingScreen } from './loaders/AnimatedLodingScreen'

type loaderProps = {
 children: React.ReactNode;
};

export const LoaderPage = ({ children }:loaderProps) => {
  const history = useHistory();
  React.useEffect(() => {
    const session = http.get('/some-route');
    session.then((result) => {
      if(result.authenticated) {
        history.push('home'); // when user is logged
      }
      history.push('/login'); // not authenticated
    }
  }, [])

  return (
    <AnimatedLodingScreen/>
  );
}

app.tsx

import React from 'react';
import { BrowserRouter, Route, Switch } from 'react-router-dom';
import { observer } from 'mobx-react';
import { LoaderPage } from 'pages/loaders/LoaderPage';
import { SomeComponent1, SomeComponent2 } from 'pages/index'

export const App: React.FC = observer(() => {
  return (
    <BrowserRouter>
      <LoaderPage>
        <Route path='/home' exact component={SomeComponent1}/>
        <Route path='/login' exact component={SomeComponent2}/>
        // and so on... I have alot of routes in fact these routes are looped via .map and
        // type-checked i just put it like this for simplicity
      </LoaderPage>
    </BrowserRouter>
  );
});

index.tsx

import React from 'react';
import ReactDOM from 'react-dom';
import { App } from 'app/app';

ReactDOM.render(<App/>, document.getElementById('root'));

Body:
The children props taken by your LoaderPage component isn't used for render anywhere within it, and thus nothing is rendered.

export const LoaderPage = ({ children }:loaderProps) => {
  const history = useHistory();
  React.useEffect(() => {
    const session = http.get('/some-route');
    session.then((result) => {
      if(result.authenticated) {
        history.push('home'); // when user is logged
      }
      history.push('/login'); // not authenticated
    }
  }, [])

  return (
    {children || <AnimatedLodingScreen/>}
  );
}


答:
You can use a state to save whether the data loading is completed or not and render children based on that</p>

```<code>export const LoaderPage = ({ children }:loaderProps) => {
      const history = useHistory();
      const [isLoaded, setLoaded] = React.useState(false)
      const [redirectPath, setRedirectPath] = React.useState('')
      React.useEffect(() => {
        const session = http.get('/some-route');
        session.then((result) => {
          if(result.authenticated) {

            return setRedirectPath('/home') // when user is logged
          }
          setRedirectPath('/login')   // not authenticated

        }
      }, [])

  function redirectToPath() {
  setLoaded(true);
  history.push(redirectPath)
  }

  if(isLoaded) { return <>{children}</> }
  return <AnimatedLodingScreen onAnimationEnd={redirectToPath} /> // onAnimationEnd is the function passed as prop to the component that should be invoked on animation ends

}
</code>```

Title: Does history.push supposed to render the component associated with the route?

Body:
You can use a state to save whether the data loading is completed or not and render children based on that

export const LoaderPage = ({ children }:loaderProps) => {
      const history = useHistory();
      const [isLoaded, setLoaded] = React.useState(false)
      const [redirectPath, setRedirectPath] = React.useState('')
      React.useEffect(() => {
        const session = http.get('/some-route');
        session.then((result) => {
          if(result.authenticated) {

            return setRedirectPath('/home') // when user is logged
          }
          setRedirectPath('/login')   // not authenticated

        }
      }, [])

  function redirectToPath() {
  setLoaded(true);
  history.push(redirectPath)
  }

  if(isLoaded) { return <>{children}</> }
  return <AnimatedLodingScreen onAnimationEnd={redirectToPath} /> // onAnimationEnd is the function passed as prop to the component that should be invoked on animation ends

}


问:
Access sql Query problem
I'm not getting proper result from this query.

```<code>SELECT Qty as op,
       0 as secunit
  FROM tbl_master
 WHERE tb_sno = 1
UNION
SELECT main_qty as op,
       main_unit as secunit
  FROM purchase
 WHERE tb_sno = 1
   AND TRN_DATE < #2011/05/14#
   AND trn_sno2 <> 0
</code>```

This show less one record from actual. is there any way to get actual result

答: It looks like both of your queries set the exact same criteria on the tb_sno field (WHERE tb_sno = 1).  Because of that, if op and sec_unit have the same resulting values in each query, a UNION will eliminate one of the duplicate rows.  A UNION ALL will keep all duplicates, as fortheworld mentioned.

Title: Access sql Query problem

Body:
I'm not getting proper result from this query.

SELECT Qty as op,
       0 as secunit
  FROM tbl_master
 WHERE tb_sno = 1
UNION
SELECT main_qty as op,
       main_unit as secunit
  FROM purchase
 WHERE tb_sno = 1
   AND TRN_DATE < #2011/05/14#
   AND trn_sno2 <> 0

This show less one record from actual. is there any way to get actual result


问:
Gradle cannot resolve symbol while it does
I've the following build.gradle file:

```<code>import org.jetbrains.kotlin.gradle.tasks.FatFrameworkTask

apply plugin: 'kotlin-multiplatform'
apply plugin: 'com.android.library'

android {
    compileSdkVersion 28
    defaultConfig {
        minSdkVersion 19
    }
    lintOptions {
        abortOnError false
    }
}

dependencies {
    testImplementation 'junit:junit:4.12'
    testImplementation 'org.jetbrains.kotlin:kotlin-test'
    testImplementation 'org.jetbrains.kotlin:kotlin-test-junit'
    testImplementation 'com.google.truth:truth:0.42'

    androidTestImplementation 'junit:junit:4.12'
    androidTestImplementation 'org.jetbrains.kotlin:kotlin-test'
    androidTestImplementation 'org.jetbrains.kotlin:kotlin-test-junit'
    androidTestImplementation 'com.google.truth:truth:0.42'
}

kotlin {
    targets {
        jvm("jvm")
        android("android")
        iosArm32("ios32")
        iosArm64("ios64")
        iosX64("emulator")

        configure([ios32, ios64, emulator]) {
            binaries.framework('HyModule')
        }
    }

    sourceSets {
        commonMain.dependencies {
            api 'org.jetbrains.kotlin:kotlin-stdlib-common'
        }
        jvmMain.dependencies {
            api 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
        }
        androidMain.dependencies {
            implementation 'org.jetbrains.kotlin:kotlin-stdlib'
        }
        androidMain.dependsOn jvmMain
    }

    task fatFramework(type: FatFrameworkTask) {
        // the fat framework must have the same base name as the initial frameworks
        baseName = "HyModule"

        final File frameworkDir = new File(buildDir, "xcode-frameworks")
        destinationDir = frameworkDir

        // specify the frameworks to be merged
        from(
                targets.ios32.binaries.getFramework('HyModule', 'RELEASE'),
                targets.ios64.binaries.getFramework('HyModule', 'RELEASE'),
                targets.emulator.binaries.getFramework('HyModule', 'RELEASE')
        )

        doLast {
            new File(frameworkDir, 'gradlew').with {
                text = "#!/bin/bash\nexport 'JAVA_HOME=${System.getProperty("java.home")}'\ncd '${rootProject.rootDir}'\n./gradlew \$@\n"
                setExecutable(true)
            }
        }
    }
}

// workaround for https://youtrack.jetbrains.com/issue/KT-27170
configurations {
    compileClasspath
}

tasks.build.dependsOn fatFramework
</code>```

import org.jetbrains.kotlin.gradle.tasks.FatFrameworkTask is marked in red with an error

Cannot resolve symbol 'FatFrameworkTask'

Even though everything works just fine, I don't like having error in my project.

答:
Try

```<code>import org.jetbrains.kotlin.gradle.tasks.*
</code>```

I was facing same problem,
Don't know why this works

Body:
I've the following build.gradle file:

import org.jetbrains.kotlin.gradle.tasks.FatFrameworkTask

apply plugin: 'kotlin-multiplatform'
apply plugin: 'com.android.library'

android {
    compileSdkVersion 28
    defaultConfig {
        minSdkVersion 19
    }
    lintOptions {
        abortOnError false
    }
}

dependencies {
    testImplementation 'junit:junit:4.12'
    testImplementation 'org.jetbrains.kotlin:kotlin-test'
    testImplementation 'org.jetbrains.kotlin:kotlin-test-junit'
    testImplementation 'com.google.truth:truth:0.42'

    androidTestImplementation 'junit:junit:4.12'
    androidTestImplementation 'org.jetbrains.kotlin:kotlin-test'
    androidTestImplementation 'org.jetbrains.kotlin:kotlin-test-junit'
    androidTestImplementation 'com.google.truth:truth:0.42'
}

kotlin {
    targets {
        jvm("jvm")
        android("android")
        iosArm32("ios32")
        iosArm64("ios64")
        iosX64("emulator")

        configure([ios32, ios64, emulator]) {
            binaries.framework('HyModule')
        }
    }

    sourceSets {
        commonMain.dependencies {
            api 'org.jetbrains.kotlin:kotlin-stdlib-common'
        }
        jvmMain.dependencies {
            api 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
        }
        androidMain.dependencies {
            implementation 'org.jetbrains.kotlin:kotlin-stdlib'
        }
        androidMain.dependsOn jvmMain
    }

    task fatFramework(type: FatFrameworkTask) {
        // the fat framework must have the same base name as the initial frameworks
        baseName = "HyModule"

        final File frameworkDir = new File(buildDir, "xcode-frameworks")
        destinationDir = frameworkDir

        // specify the frameworks to be merged
        from(
                targets.ios32.binaries.getFramework('HyModule', 'RELEASE'),
                targets.ios64.binaries.getFramework('HyModule', 'RELEASE'),
                targets.emulator.binaries.getFramework('HyModule', 'RELEASE')
        )

        doLast {
            new File(frameworkDir, 'gradlew').with {
                text = "#!/bin/bash\nexport 'JAVA_HOME=${System.getProperty("java.home")}'\ncd '${rootProject.rootDir}'\n./gradlew \$@\n"
                setExecutable(true)
            }
        }
    }
}

// workaround for https://youtrack.jetbrains.com/issue/KT-27170
configurations {
    compileClasspath
}

tasks.build.dependsOn fatFramework

import org.jetbrains.kotlin.gradle.tasks.FatFrameworkTask is marked in red with an error

Cannot resolve symbol 'FatFrameworkTask'

Even though everything works just fine, I don't like having error in my project.

Body:
Try

import org.jetbrains.kotlin.gradle.tasks.*

I was facing same problem,
Don't know why this works


问:
Ionic 4 Image Picker Crashing android app
I'm using ionic image picker to select multiple image and upload to firestore storage. But the plugin cordova image picker is crashing my android app. I saw a tutorial and done a poc. Plugin is wokring fine in poc . but when i implement it in my app it is crashing. Im stuck for more then one week. Please anyone help me with working solution.</p>

```<code>alert('hello')
this.images = [];

var options = {
  maximumImagesCount: 3,
  outputType: 1
}
    this.imagePicker.getPictures(options).then(async (results) => {
    alert('Image URI: ');

    for (var i = 0; i < results.length; i++) {
      this.base64Image = 'data:image/jpg;base64,' + results[i];

    }
     (err) => {
    //   // Handle error
    }
  }).catch(err => {
    alert('hello'+err)
  })
</code>```

答:
Install plugin:

```<code>ionic cordova plugin add cordova-plugin-telerik-imagepicker --variable PHOTO_LIBRARY_USAGE_DESCRIPTION="App wants to access your gallery"
</code>```

Install Dependency:

```<code>npm install --save @ionic-native/image-picker
</code>```

Use Below Mentioned Function to get images.

```<code>getPictures() {
      this.imagePicker.getPictures({
        maximumImagesCount: 5,
        outputType: 1
      }).then(selectedImg => {
        selectedImg.forEach(i => this.images.push("data:image/jpeg;base64," + i));
      })
    }
</code>```

Body:
I'm using ionic image picker to select multiple image and upload to firestore storage. But the plugin cordova image picker is crashing my android app. I saw a tutorial and done a poc. Plugin is wokring fine in poc . but when i implement it in my app it is crashing. Im stuck for more then one week. Please anyone help me with working solution.

alert('hello')
this.images = [];

var options = {
  maximumImagesCount: 3,
  outputType: 1
}
    this.imagePicker.getPictures(options).then(async (results) => {
    alert('Image URI: ');

    for (var i = 0; i < results.length; i++) {
      this.base64Image = 'data:image/jpg;base64,' + results[i];

    }
     (err) => {
    //   // Handle error
    }
  }).catch(err => {
    alert('hello'+err)
  })

Body:
Install plugin:

ionic cordova plugin add cordova-plugin-telerik-imagepicker --variable PHOTO_LIBRARY_USAGE_DESCRIPTION="App wants to access your gallery"

Install Dependency:

npm install --save @ionic-native/image-picker

Use Below Mentioned Function to get images.

getPictures() {
      this.imagePicker.getPictures({
        maximumImagesCount: 5,
        outputType: 1
      }).then(selectedImg => {
        selectedImg.forEach(i => this.images.push("data:image/jpeg;base64," + i));
      })
    }


问:
How to calculate/display number as "Top 5", "Top 10", "Top 15" and so on?
How would you create a function (in PHP) to return a value for the appropriate rounded ranking group (e.g. "Top 5", "Top 10", "Top 15", ... "Top 1 million", "Top 5 million", "Top 10 million", "Top 15 million").

Note that it should round up to the nearest 1, 5 or 10 - e.g. "Top 15 million" rather than "Top 12 million".

Example:

Rank = Output

1-5 = 5 (Top 5 ranking)

6-10 = 10 (Top 10 ranking)

11-15 = 15 (Top 15 ranking)

This should work all the way up to trillions.

My current function works (sort of) however it would return a value for a ranking group of top 15 as top 20 instead.

```<code>   private function format_number_iollions($amount,$style=null) {
        $amount = (0 + str_replace(',', '', $amount));
        if (!is_numeric($amount)){
            return false;
        }

        $plusString = '';
        switch ($style){
            case 'plus':
                $plusString = '+';
            break;
        }

        if ($style==='rank' && $amount<=10){
            return 10;
        }

        // filter and format it
        if ($amount>1000000000000){

            if ($style==='rank'){
                $v = ceil(($amount/1000000000000));
            } else {
                $v = floor(($amount/1000000000000));
            }

            $v .= $plusString.' trillion';
        } else if ($amount>1000000000){
            if ($style==='rank'){
                $v = ceil(($amount/1000000000));
            } else {
                $v = floor(($amount/1000000000));
            }

            $v .= $plusString.' billion';
        } else if ($amount>1000000){
            if ($style==='rank'){
                $v = ceil(($amount/1000000));
            } else {
                $v = floor(($amount/1000000));
            }

            $v .= $plusString.' million';
        } else if ($amount>100000){
            if ($style==='rank'){
                $v = ceil(($amount/100000));
            } else {
                $v = floor(($amount/100000));
            }

            $v .= '00,000'.$plusString;
        } else if ($amount>10000){
            if ($style==='rank'){
                $v = ceil(($amount/10000));
            } else {
                $v = floor(($amount/10000));
            }

            $v .= '0,000'.$plusString;
        } else if ($amount>1000){
            if ($style==='rank'){
                $v = ceil(($amount/1000));
            } else {
                $v = floor(($amount/1000));
            }

            $v .= ',000'.$plusString;
        } else if ($amount>100){
            if ($style==='rank'){
                $v = ceil(($amount/100));
            } else {
                $v = floor(($amount/100));
            }

            $v .= '00'.$plusString;
        } else if ($amount>10){
            if ($style==='rank'){
                $v = ceil(($amount/10));
            } else {
                $v = floor(($amount/10));
            }

            $v .= '0'.$plusString;
        } else {
            return number_format($amount);
        }

        return $v;
    }
</code>```

UPDATE - the final solution is this function (if anyone needs it):

```<code>private function get_rank_group($rawrank) {
    // Divide by 1000 and count how many divisions were done
    $rank_scale = 0;
    while ($rawrank >= 1000) {
        $rawrank /= 1000;
        $rank_scale++;
    }
    // Determine which Top X can be
    if ($rawrank >= 100) {
        $lim_name = (floor(($rawrank-1) / 50) + 1) * 50;
    } else {
        $lim_name = (floor(($rawrank-1) / 5) + 1) * 5;
    }
    // if its in the next higher level
    if ($lim_name >= 1000) {
        $lim_name = '1';
        $rank_scale++;
    }
    static $rank_scale_names = array('', ',000', ' Million', ' Billion', ' Trillion',  ' Quadrillion', ' Quintillion', ' Sextillion', ' Septillion');
    if (!isset($rank_scale_names[$rank_scale])){
        return null; //too much - add higher word-numbers to $rank_scale_names
    } else {
        return "$lim_name{$rank_scale_names[$rank_scale]}";
    }
}
</code>```

答:
```<code><?php
  function get_rank_group($rawrank) {
     // Divide by 1000 and count how many divisions were done
     $rank_scale = 0;
     while ($rawrank >= 1000) {
       $rawrank /= 1000;
       $rank_scale++;
     }
     // Determine which Top X can be
     static $rank_split = array(3, 5, 10, 15, 20, 30, 50, 100, 150, 200, 300, 500);
     $lim_name = false;
     // Look for a group, which is not less than the number
     foreach ($rank_split as $lim) {
       if ($rawrank <= $lim) {
         $lim_name = $lim;
         break;
       }
     }
     // If nothing was found then it is a Top 1 of (next scaler) eg. 501 is Top 1 Thousand
     if ($lim_name === false) {
       $lim_name = '1';
       $rank_scale++;
     }
     static $rank_scale_names = array('', ' Thousand', ' Million', ' Billion', ' Trillion',  ' Quadrillion', ' Quintillion', ' Sextillion', ' Septillion'); // etc
     if (!isset($rank_scale_names[$rank_scale])) return 'too much!'; // just check
     return "Top $lim_name{$rank_scale_names[$rank_scale]}";
  }

  // Tests
  $tests = array(1, 2, 3, 4, 16, 49, 50, 51, 299, 300, 301, 12345, 654321, 234567890, 1234567890123456789);
  foreach ($tests as $test) {
    print ("$test -> " . get_rank_group($test) . PHP_EOL);
  }
</code>```

The output:

```<code>1 -> Top 3
2 -> Top 3
3 -> Top 3
4 -> Top 5
16 -> Top 20
49 -> Top 50
50 -> Top 50
51 -> Top 100
299 -> Top 300
300 -> Top 300
301 -> Top 500
12345 -> Top 15 Thousand
654321 -> Top 1 Million
234567890 -> Top 300 Million
1234567890123456789 -> Top 3 Quintillion

</code>```

Body:
How would you create a function (in PHP) to return a value for the appropriate rounded ranking group (e.g. "Top 5", "Top 10", "Top 15", ... "Top 1 million", "Top 5 million", "Top 10 million", "Top 15 million").

Note that it should round up to the nearest 1, 5 or 10 - e.g. "Top 15 million" rather than "Top 12 million".

Example:

Rank = Output

1-5 = 5 (Top 5 ranking)

6-10 = 10 (Top 10 ranking)

11-15 = 15 (Top 15 ranking)

This should work all the way up to trillions.

My current function works (sort of) however it would return a value for a ranking group of top 15 as top 20 instead.

   private function format_number_iollions($amount,$style=null) {
        $amount = (0 + str_replace(',', '', $amount));
        if (!is_numeric($amount)){
            return false;
        }

        $plusString = '';
        switch ($style){
            case 'plus':
                $plusString = '+';
            break;
        }

        if ($style==='rank' && $amount<=10){
            return 10;
        }

        // filter and format it
        if ($amount>1000000000000){

            if ($style==='rank'){
                $v = ceil(($amount/1000000000000));
            } else {
                $v = floor(($amount/1000000000000));
            }

            $v .= $plusString.' trillion';
        } else if ($amount>1000000000){
            if ($style==='rank'){
                $v = ceil(($amount/1000000000));
            } else {
                $v = floor(($amount/1000000000));
            }

            $v .= $plusString.' billion';
        } else if ($amount>1000000){
            if ($style==='rank'){
                $v = ceil(($amount/1000000));
            } else {
                $v = floor(($amount/1000000));
            }

            $v .= $plusString.' million';
        } else if ($amount>100000){
            if ($style==='rank'){
                $v = ceil(($amount/100000));
            } else {
                $v = floor(($amount/100000));
            }

            $v .= '00,000'.$plusString;
        } else if ($amount>10000){
            if ($style==='rank'){
                $v = ceil(($amount/10000));
            } else {
                $v = floor(($amount/10000));
            }

            $v .= '0,000'.$plusString;
        } else if ($amount>1000){
            if ($style==='rank'){
                $v = ceil(($amount/1000));
            } else {
                $v = floor(($amount/1000));
            }

            $v .= ',000'.$plusString;
        } else if ($amount>100){
            if ($style==='rank'){
                $v = ceil(($amount/100));
            } else {
                $v = floor(($amount/100));
            }

            $v .= '00'.$plusString;
        } else if ($amount>10){
            if ($style==='rank'){
                $v = ceil(($amount/10));
            } else {
                $v = floor(($amount/10));
            }

            $v .= '0'.$plusString;
        } else {
            return number_format($amount);
        }

        return $v;
    }

UPDATE - the final solution is this function (if anyone needs it):

private function get_rank_group($rawrank) {
    // Divide by 1000 and count how many divisions were done
    $rank_scale = 0;
    while ($rawrank >= 1000) {
        $rawrank /= 1000;
        $rank_scale++;
    }
    // Determine which Top X can be
    if ($rawrank >= 100) {
        $lim_name = (floor(($rawrank-1) / 50) + 1) * 50;
    } else {
        $lim_name = (floor(($rawrank-1) / 5) + 1) * 5;
    }
    // if its in the next higher level
    if ($lim_name >= 1000) {
        $lim_name = '1';
        $rank_scale++;
    }
    static $rank_scale_names = array('', ',000', ' Million', ' Billion', ' Trillion',  ' Quadrillion', ' Quintillion', ' Sextillion', ' Septillion');
    if (!isset($rank_scale_names[$rank_scale])){
        return null; //too much - add higher word-numbers to $rank_scale_names
    } else {
        return "$lim_name{$rank_scale_names[$rank_scale]}";
    }
}

Body:
<?php
  function get_rank_group($rawrank) {
     // Divide by 1000 and count how many divisions were done
     $rank_scale = 0;
     while ($rawrank >= 1000) {
       $rawrank /= 1000;
       $rank_scale++;
     }
     // Determine which Top X can be
     static $rank_split = array(3, 5, 10, 15, 20, 30, 50, 100, 150, 200, 300, 500);
     $lim_name = false;
     // Look for a group, which is not less than the number
     foreach ($rank_split as $lim) {
       if ($rawrank <= $lim) {
         $lim_name = $lim;
         break;
       }
     }
     // If nothing was found then it is a Top 1 of (next scaler) eg. 501 is Top 1 Thousand
     if ($lim_name === false) {
       $lim_name = '1';
       $rank_scale++;
     }
     static $rank_scale_names = array('', ' Thousand', ' Million', ' Billion', ' Trillion',  ' Quadrillion', ' Quintillion', ' Sextillion', ' Septillion'); // etc
     if (!isset($rank_scale_names[$rank_scale])) return 'too much!'; // just check
     return "Top $lim_name{$rank_scale_names[$rank_scale]}";
  }

  // Tests
  $tests = array(1, 2, 3, 4, 16, 49, 50, 51, 299, 300, 301, 12345, 654321, 234567890, 1234567890123456789);
  foreach ($tests as $test) {
    print ("$test -> " . get_rank_group($test) . PHP_EOL);
  }

The output:

1 -> Top 3
2 -> Top 3
3 -> Top 3
4 -> Top 5
16 -> Top 20
49 -> Top 50
50 -> Top 50
51 -> Top 100
299 -> Top 300
300 -> Top 300
301 -> Top 500
12345 -> Top 15 Thousand
654321 -> Top 1 Million
234567890 -> Top 300 Million
1234567890123456789 -> Top 3 Quintillion


问:
what's the largest number float type can hold?
I'm new to programming and have recently come up with this simple question .
float type has 32 bits in which 8 bits are for the whole number part (the mantissa).
so my question is can float type hold numbers bigger than 255.9999 ?

and I would also appreciate if someone told me why this code is behaving unexpectedly. Is it a related issue?

```<code>int main(){
float a=123456789.1;
printf("%lf",a);
return 0;
}
</code>```

for which the output is :

```<code>123456792.000000
</code>```

答:
The most common 32-bit floating-point format, IEEE-754 binary32, does not have eight bits for the whole number part. It has one bit for a sign, eight bits for an exponent field, and 23 bits for a significand field (a fraction part).

The sign bit determines whether the number is positive (0) or negative (1).

The exponent field, e, has several uses. If it is 11111111 (in binary), and the significand field, f, is zero, the floating-point value represents infinity. If e is 11111111, and the significand field is not zero, it represents a special Not-a-Number “value”.

If the exponent is not 11111111 and is not zero, floating-point value represents 2e−127•(1+f/223), with the sign added. Note that the fraction portion is formed by adding 1 to the contents of the significand field. That is often called an implicit 1, so the mathematical significand is 24 bits—1 bit from the leading 1, 23 bits from the significand field.

If the exponent is zero, floating-point value represents 21−127•(0+f/223) or the negative of that if the sign bit is 1. Note that the leading bit is 0. These are called subnormal numbers. They are included in the format to make some mathematical properties work in floating-point arithmetic.

The largest finite value represented is when the exponent is 11111110 (254) and the significand field is all ones (f is 223−1), so the number represented is 2254−127•(1+ (223−1)/223) = 2127•(2−2−23) = 2128−2104 = 340282346638528859811704183484516925440.

In float a=123456789.1;, the float type does not have enough precision to represent 123456789.1. (In fact, a decimal fraction .1 can never be represented with a binary floating-point format.) When we have only 24 bits for the significand, the closest numbers to 123456789.1 that we can represent are 123456792 and 123456800.

Body:
I'm new to programming and have recently come up with this simple question .
float type has 32 bits in which 8 bits are for the whole number part (the mantissa).
so my question is can float type hold numbers bigger than 255.9999 ?

and I would also appreciate if someone told me why this code is behaving unexpectedly. Is it a related issue?

int main(){
float a=123456789.1;
printf("%lf",a);
return 0;
}

for which the output is :

123456792.000000


问:
Laravel 6 - How to get the value from controller's compact array in view/blade?
I am passing an array using compact from my Controller to a blade and I want to access them one by one in my view / blade template but I am always receiving this error:

Here's the content of my compact array:

Here's my snippet source code from the Controller:

```<code>//dd($flight_book_details);
    $flight_book_details = $request->all();
    return view('auth.register', compact('flight_book_details'));
</code>```

And here's my snippet source code in the view / blade template:

```<code><h2>
@foreach($flight_book_details as $flight_book_detail)
    {{$flight_book_detail->seat_quantity}}  //Trying to access the 'seat_quantity'
@endforeach
</h2>
</code>```

Question: Is there any other way to access the values from the compact in view?

答:
you are getting all data.use array. $flight_book_details->seat_quantity used when data get an object </p>

```<code>{{$flight_book_details['seat_quantity']}}
</code>```

Body:
I am passing an array using compact from my Controller to a blade and I want to access them one by one in my view / blade template but I am always receiving this error:

Here's the content of my compact array:

Here's my snippet source code from the Controller:

//dd($flight_book_details);
    $flight_book_details = $request->all();
    return view('auth.register', compact('flight_book_details'));

And here's my snippet source code in the view / blade template:

@foreach($flight_book_details as $flight_book_detail)
    {{$flight_book_detail->seat_quantity}}  //Trying to access the 'seat_quantity'
@endforeach

Question: Is there any other way to access the values from the compact in view?

Body:
you are getting all data.use array. $flight_book_details->seat_quantity used when data get an object

{{$flight_book_details['seat_quantity']}}