问:
Deselecting an item in collection view and removing that from an array not working
I am trying to select a cell and add the content of that cell into an array and then to be able to deselect a cell and remove that same object from the array. I've been struggling for a few days and still can't seem to get it work. Select and deselect functionality works, it's adding objects to the array but upon deselection, I don't know how to remove that same object from the array. How can I deselect the cell and remove that from the array?

This is my code:

```<code>    struct Friends {
    var friendName : String!
}

struct SelectedMembers {
    var selectedFriend : String!
}

    var friends = [Friends]()
    var selectedFriends = [SelectedMembers]()

        //MARK: Select multiple cells
    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        let cell = collectionView.cellForItem(at: indexPath) as? FriendsCell
        selectedCell.append(indexPath)
        cell?.contentView.backgroundColor = .red
        print("Friends are: \(String(describing: cell?.nameSurname.text!))")

        if (cell?.isSelected)! {
            print("this is selected...")
            var selection = SelectedMembers()
            selection.selectedFriend = friends[indexPath.item].friendName
            selectedFriends.append(selection)

            print(selectedFriends)

        }

    }

    //MARK: Deselect Multiple cells
    func collectionView(_ collectionView: UICollectionView, didDeselectItemAt indexPath: IndexPath) {
        let deselectedCell = collectionView.cellForItem(at: indexPath) as? FriendsCell
        print(indexPath.row)
        if let index = selectedFriends.index(of: selectedFriends[indexPath.row]) {
            selectedFriends.remove(at: index)
        }

        if selectedCell.contains(indexPath) {
            selectedCell.remove(at: selectedCell.index(of: indexPath)!)
            deselectedCell?.contentView.backgroundColor = .white
            print(selectedCell)
        }

        print(selectedFriends)
    }
}
</code>```

答:
According to me, create a isSelected key in "SelectedMembers" object and change that key value for selected and unselected cell and after that reload the tableView.
And at last you will retrieve an array of selected cell by simple loop.

other wise use it

```<code> extension SelectRecipeViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    let product =  self.productList[indexPath.row]
    if arraySelectedProduct.contains(recipe) {
        let index = arraySelectedRecipes.index(of: recipe)
        arraySelectedProduct.remove(at: index!)
    } else {
        arraySelectedProduct.append(recipe)
    }
    tableView.reloadRows(at: [indexPath], with: .none)
}
}
</code>```

Body:
I am trying to select a cell and add the content of that cell into an array and then to be able to deselect a cell and remove that same object from the array. I've been struggling for a few days and still can't seem to get it work. Select and deselect functionality works, it's adding objects to the array but upon deselection, I don't know how to remove that same object from the array. How can I deselect the cell and remove that from the array?

This is my code:

    struct Friends {
    var friendName : String!
}

struct SelectedMembers {
    var selectedFriend : String!
}

    var friends = [Friends]()
    var selectedFriends = [SelectedMembers]()

        //MARK: Select multiple cells
    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        let cell = collectionView.cellForItem(at: indexPath) as? FriendsCell
        selectedCell.append(indexPath)
        cell?.contentView.backgroundColor = .red
        print("Friends are: \(String(describing: cell?.nameSurname.text!))")

        if (cell?.isSelected)! {
            print("this is selected...")
            var selection = SelectedMembers()
            selection.selectedFriend = friends[indexPath.item].friendName
            selectedFriends.append(selection)

            print(selectedFriends)

        }

    }

    //MARK: Deselect Multiple cells
    func collectionView(_ collectionView: UICollectionView, didDeselectItemAt indexPath: IndexPath) {
        let deselectedCell = collectionView.cellForItem(at: indexPath) as? FriendsCell
        print(indexPath.row)
        if let index = selectedFriends.index(of: selectedFriends[indexPath.row]) {
            selectedFriends.remove(at: index)
        }

        if selectedCell.contains(indexPath) {
            selectedCell.remove(at: selectedCell.index(of: indexPath)!)
            deselectedCell?.contentView.backgroundColor = .white
            print(selectedCell)
        }

        print(selectedFriends)
    }
}

Body:
According to me, create a isSelected key in "SelectedMembers" object and change that key value for selected and unselected cell and after that reload the tableView.
And at last you will retrieve an array of selected cell by simple loop.

other wise use it

 extension SelectRecipeViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    let product =  self.productList[indexPath.row]
    if arraySelectedProduct.contains(recipe) {
        let index = arraySelectedRecipes.index(of: recipe)
        arraySelectedProduct.remove(at: index!)
    } else {
        arraySelectedProduct.append(recipe)
    }
    tableView.reloadRows(at: [indexPath], with: .none)
}
}


来源: stackexchange

问:
Unable to launch Hive metastore with MySql empty password
My local MySql do not have password for login, so I set hive-site.xml config for:

```<code><property>
    <name>javax.jdo.option.ConnectionPassword</name>
    <value/>
<description>password to use against metastore database</description>
</code>```

But After launching metastore with
hive --service metastore

It always show there's password

```<code>Caused by: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:965) ~[mysql-connector-java-5.1.45-bin.jar:5.1.45]
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3973) ~[mysql-connector-java-5.1.45-bin.jar:5.1.45]
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3909) ~[mysql-connector-java-5.1.45-bin.jar:5.1.45]
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:873) ~[mysql-connector-java-5.1.45-bin.jar:5.1.45]
at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1710) ~[mysql-connector-java-5.1.45-bin.jar:5.1.45]
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1226) ~[mysql-connector-java-5.1.45-bin.jar:5.1.45]
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2188) ~[mysql-connector-java-5.1.45-bin.jar:5.1.45]
at com.mysql.jdbc.ConnectionImpl.connectOneTryO
</code>```

How to fix it?

答:
Sovled by add --hiveconf when start the server.</p>

```<code>hive --hiveconf javax.jdo.option.ConnectionPassword= --service metastore
</code>```

ContentLicense: CC BY-SA 3.0

Body:
My local MySql do not have password for login, so I set hive-site.xml config for:

<property>
    <name>javax.jdo.option.ConnectionPassword</name>
    <value/>
<description>password to use against metastore database</description>

But After launching metastore with
hive --service metastore

It always show there's password

Caused by: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:965) ~[mysql-connector-java-5.1.45-bin.jar:5.1.45]
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3973) ~[mysql-connector-java-5.1.45-bin.jar:5.1.45]
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3909) ~[mysql-connector-java-5.1.45-bin.jar:5.1.45]
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:873) ~[mysql-connector-java-5.1.45-bin.jar:5.1.45]
at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1710) ~[mysql-connector-java-5.1.45-bin.jar:5.1.45]
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1226) ~[mysql-connector-java-5.1.45-bin.jar:5.1.45]
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2188) ~[mysql-connector-java-5.1.45-bin.jar:5.1.45]
at com.mysql.jdbc.ConnectionImpl.connectOneTryO

How to fix it?

Body:
Sovled by add --hiveconf when start the server.

hive --hiveconf javax.jdo.option.ConnectionPassword= --service metastore


问:
Pass a string to for WHERE clause in stored procedure
I want to pass a string from a text box in my stored procedure for a WHERE clause, basically what I want to do is this.

SELECT *
FROM TABLE
WHERE "Textbox1.text" = '1234'
```

<p>(the textbox value will be the column name(ex. 'ID')</p>

<p>How can I do that in a stored procedure?</p>

<p>Here's what I done so far, it returns no value</p>

<pre class="lang-sql prettyprint-override"><code>ALTER PROCEDURE ORProc
    @SEARCH_PARAMETER VARCHAR(100) = NULL,
    @OR_NUMBER VARCHAR(20) = NULL,
    @CLIENT_NAME VARCHAR(100) = NULL,
    @OR_DATE VARCHAR(10) = NULL
AS
BEGIN
    SET NOCOUNT ON;

    SELECT *
    FROM OR_HEADER
    WHERE '%'+ @SEARCH_PARAMETER + '%' = @OR_NUMBER
       OR '%'+ @SEARCH_PARAMETER + '%' = @OR_DATE
       OR '%'+ @SEARCH_PARAMETER + '%' = @CLIENT_NAME
 END;

 EXEC ORProc @SEARCH_PARAMETER = 'OR_NUMBER',
             @OR_NUMBER = '23232'
</code>```

答:
Try the next query

```<code>SELECT *
FROM OR_HEADER
WHERE (@SEARCH_PARAMETER='OR_NUMBER' AND OR_NUMBER=@OR_NUMBER)
  OR (@SEARCH_PARAMETER='OR_DATE' AND OR_DATE=@OR_DATE)
  OR (@SEARCH_PARAMETER='CLIENT_NAME' AND CLIENT_NAME=@CLIENT_NAME)
</code>```

And I think you can replace @OR_DATE VARCHAR(10) = NULL to @OR_DATE DATE = NULL or @OR_DATE DATETIME = NULL.

I think you can replace three value parameters to one @SEARCH_VALUE

```<code>ALTER PROCEDURE ORProc
    @SEARCH_PARAMETER VARCHAR(100) = NULL,
    @SEARCH_VALUE VARCHAR(100) = NULL
AS
BEGIN
    SET NOCOUNT ON;

    IF(ISNULL(@SEARCH_PARAMETER,'') NOT IN('','ID','OR_NUMBER','OR_DATE','CLIENT_NAME'))
    BEGIN
      PRINT 'You sent the wrong parameter!'
      RETURN
    END

    SELECT *
    FROM OR_HEADER
    WHERE (@SEARCH_PARAMETER='OR_NUMBER' AND OR_NUMBER=@SEARCH_VALUE)
      OR (@SEARCH_PARAMETER='OR_DATE' AND OR_DATE=CAST(@SEARCH_VALUE AS date))
      OR (@SEARCH_PARAMETER='CLIENT_NAME' AND CLIENT_NAME=@SEARCH_VALUE)
      OR (@SEARCH_PARAMETER='ID' AND ID=CAST(@SEARCH_VALUE AS int))
      OR ISNULL(@SEARCH_PARAMETER,'')=''

END
</code>```

Body:
I want to pass a string from a text box in my stored procedure for a WHERE clause, basically what I want to do is this.

SELECT *
FROM TABLE
WHERE "Textbox1.text" = '1234'

(the textbox value will be the column name(ex. 'ID')

How can I do that in a stored procedure?

Here's what I done so far, it returns no value

ALTER PROCEDURE ORProc
    @SEARCH_PARAMETER VARCHAR(100) = NULL,
    @OR_NUMBER VARCHAR(20) = NULL,
    @CLIENT_NAME VARCHAR(100) = NULL,
    @OR_DATE VARCHAR(10) = NULL
AS
BEGIN
    SET NOCOUNT ON;

    SELECT *
    FROM OR_HEADER
    WHERE '%'+ @SEARCH_PARAMETER + '%' = @OR_NUMBER
       OR '%'+ @SEARCH_PARAMETER + '%' = @OR_DATE
       OR '%'+ @SEARCH_PARAMETER + '%' = @CLIENT_NAME
 END;

 EXEC ORProc @SEARCH_PARAMETER = 'OR_NUMBER',
             @OR_NUMBER = '23232'

Body:
Try the next query

SELECT *
FROM OR_HEADER
WHERE (@SEARCH_PARAMETER='OR_NUMBER' AND OR_NUMBER=@OR_NUMBER)
  OR (@SEARCH_PARAMETER='OR_DATE' AND OR_DATE=@OR_DATE)
  OR (@SEARCH_PARAMETER='CLIENT_NAME' AND CLIENT_NAME=@CLIENT_NAME)

And I think you can replace @OR_DATE VARCHAR(10) = NULL to @OR_DATE DATE = NULL or @OR_DATE DATETIME = NULL.

I think you can replace three value parameters to one @SEARCH_VALUE

ALTER PROCEDURE ORProc
    @SEARCH_PARAMETER VARCHAR(100) = NULL,
    @SEARCH_VALUE VARCHAR(100) = NULL
AS
BEGIN
    SET NOCOUNT ON;

    IF(ISNULL(@SEARCH_PARAMETER,'') NOT IN('','ID','OR_NUMBER','OR_DATE','CLIENT_NAME'))
    BEGIN
      PRINT 'You sent the wrong parameter!'
      RETURN
    END

    SELECT *
    FROM OR_HEADER
    WHERE (@SEARCH_PARAMETER='OR_NUMBER' AND OR_NUMBER=@SEARCH_VALUE)
      OR (@SEARCH_PARAMETER='OR_DATE' AND OR_DATE=CAST(@SEARCH_VALUE AS date))
      OR (@SEARCH_PARAMETER='CLIENT_NAME' AND CLIENT_NAME=@SEARCH_VALUE)
      OR (@SEARCH_PARAMETER='ID' AND ID=CAST(@SEARCH_VALUE AS int))
      OR ISNULL(@SEARCH_PARAMETER,'')=''

END


问:
django 2.0 path aren't added
i use path instead of url in django 2.0
but there is a problem

Following is my code

```<code>oauth2_endpoint_views = ([
path('authorize/', oauth2_views.AuthorizationView.as_view(), name='authorize'),
path('token/', oauth2_views.TokenView.as_view(), name='token'),
path('revoke-token/', oauth2_views.RevokeTokenView.as_view, name='revoke-token'),
], 'oauth2')

    if settings.DEBUG:
oauth2_endpoint_views += ([
        path('application/', oauth2_views.ApplicationList.as_view(), name='list'),
        path('application/register', oauth2_views.ApplicationRegistration.as_view(), name='register'),
        path('application/<int:pk>/', oauth2_views.ApplicationDetail.as_view(), name='detail'),
        path('application/<int:pk>/delete/', oauth2_views.ApplicationDetail.as_view(), name='delete'),
        path('application/<int:pk>/update/', oauth2_views.ApplicationUpdate.as_view(), name='update'),
        path('authorized-tokens/', oauth2_views.AuthorizedTokensListView.as_view(), name='authorized-token-list'),
        path('authorized-tokens/<int:pk>/delete/', oauth2_views.AuthorizedTokenDeleteView.as_view(), name='authorized-token-delete'),
    ], 'oauth2')
</code>```

I added path, but i can't found path application, application/register ...

how can i solve the problem?

答:
Try replacing this:

```<code>path('application/register',oauth2_views.ApplicationRegistration.as_view(), name='register'),
</code>```

with

```<code>path('application/register/', oauth2_views.ApplicationRegistration.as_view(), name='register'),
</code>```

Title: django 2.0 path aren't added

Body:
i use path instead of url in django 2.0
but there is a problem

Following is my code

oauth2_endpoint_views = ([
path('authorize/', oauth2_views.AuthorizationView.as_view(), name='authorize'),
path('token/', oauth2_views.TokenView.as_view(), name='token'),
path('revoke-token/', oauth2_views.RevokeTokenView.as_view, name='revoke-token'),
], 'oauth2')

    if settings.DEBUG:
oauth2_endpoint_views += ([
        path('application/', oauth2_views.ApplicationList.as_view(), name='list'),
        path('application/register', oauth2_views.ApplicationRegistration.as_view(), name='register'),
        path('application/<int:pk>/', oauth2_views.ApplicationDetail.as_view(), name='detail'),
        path('application/<int:pk>/delete/', oauth2_views.ApplicationDetail.as_view(), name='delete'),
        path('application/<int:pk>/update/', oauth2_views.ApplicationUpdate.as_view(), name='update'),
        path('authorized-tokens/', oauth2_views.AuthorizedTokensListView.as_view(), name='authorized-token-list'),
        path('authorized-tokens/<int:pk>/delete/', oauth2_views.AuthorizedTokenDeleteView.as_view(), name='authorized-token-delete'),
    ], 'oauth2')

I added path, but i can't found path application, application/register ...

how can i solve the problem?

Body:
Try replacing this:

path('application/register',oauth2_views.ApplicationRegistration.as_view(), name='register'),

with

path('application/register/', oauth2_views.ApplicationRegistration.as_view(), name='register'),


问:
assign only particular column values to a temp table from select query
I am having below query that will return 6 columns and i want only assign particular column (converted_skus) results to temporary table and i need to do further processing on that column only ..

I am not sure how can i assign only particular column values to temporary table where as other columns are not needed for further processing

here is my query

```<code> SELEct distinct
 clpAct.pk_cert,CCM.leg_sku_des,CCM.converted_sku_des,CCM.converted_skus,
 esitrans.pk_cert,esitrans.part_id from Clp_Active clpAct
 inner join transfertable esitrans
 ON clpact.pk_cert = esitrans.pk_cert
 INNER JOIN pass_conversion CCM
 ON esitrans.part_id = CCM.part_number
 where clpAct.subscription_key = @subKey
</code>```

Would any one please help on this query that would be very grateful to me.
Many thanks in advance

I am using sql server as DB

答:
if you don't need the other columns, then just select your required column only and insert it into the temp table. like this

```<code>create table #temp
(
converted_skus varchar(50)
)

insert into #temp
(
converted_skus
)
SELEct distinct
CCM.converted_skus
from Clp_Active clpAct
 inner join transfertable esitrans
 ON clpact.pk_cert = esitrans.pk_cert
 INNER JOIN pass_conversion CCM
 ON esitrans.part_id = CCM.part_number
 where clpAct.subscription_key = @subKey
</code>```

now you have only the required column and values in the temp table #temp

Body:
I am having below query that will return 6 columns and i want only assign particular column (converted_skus) results to temporary table and i need to do further processing on that column only ..

I am not sure how can i assign only particular column values to temporary table where as other columns are not needed for further processing

here is my query

 SELEct distinct
 clpAct.pk_cert,CCM.leg_sku_des,CCM.converted_sku_des,CCM.converted_skus,
 esitrans.pk_cert,esitrans.part_id from Clp_Active clpAct
 inner join transfertable esitrans
 ON clpact.pk_cert = esitrans.pk_cert
 INNER JOIN pass_conversion CCM
 ON esitrans.part_id = CCM.part_number
 where clpAct.subscription_key = @subKey

Would any one please help on this query that would be very grateful to me.
Many thanks in advance

I am using sql server as DB

Body:
if you don't need the other columns, then just select your required column only and insert it into the temp table. like this

create table #temp
(
converted_skus varchar(50)
)

insert into #temp
(
converted_skus
)
SELEct distinct
CCM.converted_skus
from Clp_Active clpAct
 inner join transfertable esitrans
 ON clpact.pk_cert = esitrans.pk_cert
 INNER JOIN pass_conversion CCM
 ON esitrans.part_id = CCM.part_number
 where clpAct.subscription_key = @subKey

now you have only the required column and values in the temp table #temp


问:
How do I set the "success" function for multiple ajax requests?
How can I set ajax success for all requests done?

```<code>$.ajax({
  success: function(){ clicked = false;}
});

$('.button').click(function(){
   $.post('file.php',{},function(){});
   $.post('file.php',{},function(){});
   $.post('file.php',{},function(){});
});
</code>```

答:
Do you mean execute a single method once all requests have completed?

```<code>var counter = 0;
var nRequests = 3;

function multiSuccess() {
    // do something
}

$('.button').click(function(){
   $.post('file.php',{},function(){
       counter++;
       if(counter == nRequests) {
           multiSuccess();
       }
   });
   $.post(...
   $.post(...
});
</code>```

Also, you might want to look into ajaxStop:

Whenever an Ajax request completes,
  jQuery checks whether there are any
  other outstanding Ajax requests. If
  none remain, jQuery triggers the
  ajaxStop event. Any and all handlers
  that have been registered with the
  .ajaxStop() method are executed at
  this time.

ContentLicense: CC BY-SA 2.5

Body:
How can I set ajax success for all requests done?

$.ajax({
  success: function(){ clicked = false;}
});

$('.button').click(function(){
   $.post('file.php',{},function(){});
   $.post('file.php',{},function(){});
   $.post('file.php',{},function(){});
});

Body:
Do you mean execute a single method once all requests have completed?

var counter = 0;
var nRequests = 3;

function multiSuccess() {
    // do something
}

$('.button').click(function(){
   $.post('file.php',{},function(){
       counter++;
       if(counter == nRequests) {
           multiSuccess();
       }
   });
   $.post(...
   $.post(...
});

Also, you might want to look into ajaxStop:

Whenever an Ajax request completes,
  jQuery checks whether there are any
  other outstanding Ajax requests. If
  none remain, jQuery triggers the
  ajaxStop event. Any and all handlers
  that have been registered with the
  .ajaxStop() method are executed at
  this time.


问:
No resource found that matches the given name: attr 'android:keyboardNavigationCluster'. when updating to Support Library 26.0.0
I've got this issue while updating to the latest Support Library version 26.0.0 (https://developer.android.com/topic/libraries/support-library/revisions.html#26-0-0):

Error:(18, 21) No resource found that matches the given name: attr
  'android:keyboardNavigationCluster'.

```<code>/.../app/build/intermediates/res/merged/beta/debug/values-v26/values-v26.xml
Error:(15, 21) No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.
Error:(18, 21) No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.
Error:(15, 21) No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.
Error:(18, 21) No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.
Error:Execution failed for task ':app:processBetaDebugResources'.
</code>```

com.android.ide.common.process.ProcessException: Failed to execute aapt

The file is from the support library:

```<code><style name="Base.V26.Widget.AppCompat.Toolbar" parent="Base.V7.Widget.AppCompat.Toolbar">
    <item name="android:touchscreenBlocksFocus">true</item>
    <item name="android:keyboardNavigationCluster">true</item>
</style>
</code>```

We're using the following versions:

```<code>ext.COMPILE_SDK_VERSION = 26
ext.BUILD_TOOLS_VERSION = "26.0.1"

ext.MIN_SDK_VERSION = 17
ext.TARGET_SDK_VERSION = 26
ext.ANDROID_SUPPORT_LIBRARY_VERSION = "26.0.0"
ext.GOOGLE_PLAY_SERVICES_LIBRARY_VERSION = "11.0.2"
</code>```

```<code>compile 'com.android.support:appcompat-v7:' + ANDROID_SUPPORT_LIBRARY_VERSION
compile 'com.android.support:design:' + ANDROID_SUPPORT_LIBRARY_VERSION
compile 'com.android.support:recyclerview-v7:' + ANDROID_SUPPORT_LIBRARY_VERSION
</code>```

Any ideas?

答:
```<code>//Adding this to the root build.gradle solved my problem, thanks @Yalamber
subprojects {
        afterEvaluate { project ->
            if (project.hasProperty("android")) {
                android {
                    compileSdkVersion 26
                    buildToolsVersion '26.0.2'
                }
            }
        }
    }
</code>```

Body:
I've got this issue while updating to the latest Support Library version 26.0.0 (https://developer.android.com/topic/libraries/support-library/revisions.html#26-0-0):

Error:(18, 21) No resource found that matches the given name: attr
  'android:keyboardNavigationCluster'.

/.../app/build/intermediates/res/merged/beta/debug/values-v26/values-v26.xml
Error:(15, 21) No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.
Error:(18, 21) No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.
Error:(15, 21) No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.
Error:(18, 21) No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.
Error:Execution failed for task ':app:processBetaDebugResources'.

com.android.ide.common.process.ProcessException: Failed to execute aapt

The file is from the support library:

We're using the following versions:

ext.COMPILE_SDK_VERSION = 26
ext.BUILD_TOOLS_VERSION = "26.0.1"

ext.MIN_SDK_VERSION = 17
ext.TARGET_SDK_VERSION = 26
ext.ANDROID_SUPPORT_LIBRARY_VERSION = "26.0.0"
ext.GOOGLE_PLAY_SERVICES_LIBRARY_VERSION = "11.0.2"

compile 'com.android.support:appcompat-v7:' + ANDROID_SUPPORT_LIBRARY_VERSION
compile 'com.android.support:design:' + ANDROID_SUPPORT_LIBRARY_VERSION
compile 'com.android.support:recyclerview-v7:' + ANDROID_SUPPORT_LIBRARY_VERSION

Any ideas?


问:
How to secure Data IonicV1 services
Hi I have implemented an app in Ionic v1 with Symfony2 as server side.

the communication between app and server is being made by post ajax request.

I want to make secure the request services data in network which is posted from app to Symfony2.

```<code>//Login services request

{role: "ROLE PARENT", user: "8557988004", password: "12872"}

//response

MessageId: 1, email: "sunilrawat@indivar.com", name: "SATNAM SINGH HANSRA", roleName: "ROLE PARENT"}
</code>```

I have some other pages in my app where I need to process payment as well.So can you please guide me how can I make each service data  secure so that no one can tamper it.Because by default ionic convert each services in ajax using $http.post.

Thanks advance

答:
For React-native I had made simple encryption plugin I used

https://github.com/BhavanPatel/react-native-simple-encryption for front end

side and my backend is on nodejs so I used

https://github.com/BhavanPatel/react-native-node-enc-dec/tree/master/Node
this. Please check it..

if you want me to make it for ionic v1 than I will.

Title: How to secure Data IonicV1 services

Body:
Hi I have implemented an app in Ionic v1 with Symfony2 as server side.

the communication between app and server is being made by post ajax request.

I want to make secure the request services data in network which is posted from app to Symfony2.

//Login services request

{role: "ROLE PARENT", user: "8557988004", password: "12872"}

//response

MessageId: 1, email: "sunilrawat@indivar.com", name: "SATNAM SINGH HANSRA", roleName: "ROLE PARENT"}

I have some other pages in my app where I need to process payment as well.So can you please guide me how can I make each service data  secure so that no one can tamper it.Because by default ionic convert each services in ajax using $http.post.

Thanks advance


问:
How to update each dependency in package.json to the latest version?
I copied package.json from another project and now want to bump all of the dependencies to their latest versions since this is a fresh project and I don't mind fixing something if it breaks.

What's the easiest way to do this?

The best way I know is to run npm info express version then update each dependency in package.json manually. There must be a better way.

```<code>{
  "name": "myproject",
  "description": "my node project",
  "version": "1.0.0",
  "dependencies": {
    "express": "^3.0.3", // how do I get these bumped to latest?
    "mongodb": "^1.2.5",
    "underscore": "^1.4.2"
  }
}
</code>```

For Yarn specific solutions refer to this Stack Overflow thread.

答:
To see which packages have newer versions available, then use the following command:

```<code>npm outdated
</code>```

to update just one dependency just use the following command:

```<code>npm install yourPackage@latest
</code>```

For example:

My package.json file has dependency:

```<code>"@progress/kendo-angular-dateinputs": "^1.3.1",
</code>```

then I should write:

```<code>npm install @progress/kendo-angular-dateinputs@latest
</code>```

What does --save-dev mean?

```<code>npm install @progress/kendo-angular-dateinputs@latest --save-dev
</code>```

As npm install docs says:

-D, --save-dev: Package will appear in your devDependencies.

ContentLicense: CC BY-SA 4.0

Body:
I copied package.json from another project and now want to bump all of the dependencies to their latest versions since this is a fresh project and I don't mind fixing something if it breaks.

What's the easiest way to do this?

The best way I know is to run npm info express version then update each dependency in package.json manually. There must be a better way.

{
  "name": "myproject",
  "description": "my node project",
  "version": "1.0.0",
  "dependencies": {
    "express": "^3.0.3", // how do I get these bumped to latest?
    "mongodb": "^1.2.5",
    "underscore": "^1.4.2"
  }
}

For Yarn specific solutions refer to this Stack Overflow thread.

Body:
To see which packages have newer versions available, then use the following command:

npm outdated

to update just one dependency just use the following command:

npm install yourPackage@latest

For example:

My package.json file has dependency:

"@progress/kendo-angular-dateinputs": "^1.3.1",

then I should write:

npm install @progress/kendo-angular-dateinputs@latest

What does --save-dev mean?

npm install @progress/kendo-angular-dateinputs@latest --save-dev

As npm install docs says:

-D, --save-dev: Package will appear in your devDependencies.


问:
How can I normalize a sparse matrix in R by both rows and columns?
I have created a sparse matrix using the R package "Matrix". The matrix is not square, and its dimensions are 4561 by 68825.

I'm looking to standardize this matrix so that each value x is equal to x / row sum + column sum. I've found a solution on stack which I could alter to solve this problem here. However, in the solution seen in the linked question, the problem uses a square matrix, so Diaganal can be used.In my case, my matrix is not square so I can't make this solution work.

How can I normalize a sparse matrix in R by both rows and columns?

Body:
If you simply want to divide each cell by sum of row sum and col sum, here is a simple way to do so:

test = matrix(1:20, 4, 5)
test
     [,1] [,2] [,3] [,4] [,5]
[1,]    1    5    9   13   17
[2,]    2    6   10   14   18
[3,]    3    7   11   15   19
[4,]    4    8   12   16   20

rs = rowSums(test)
cs = colSums(test)

for(j in 1:ncol(test)){
  for(i in 1:nrow(test)){
    test[i,j] = test[i,j]/(rs[i] + cs[j])
  }
}

test
           [,1]       [,2]      [,3]      [,4]      [,5]
[1,] 0.01818182 0.07042254 0.1034483 0.1262136 0.1428571
[2,] 0.03333333 0.07894737 0.1086957 0.1296296 0.1451613
[3,] 0.04615385 0.08641975 0.1134021 0.1327434 0.1472868
[4,] 0.05714286 0.09302326 0.1176471 0.1355932 0.1492537


问:
using sort and set() on list values in dictionary
I have a dictionary which has single value as key and a list as the value. I am trying to go through the dictionary values and remove duplicates and sort the lists. Im using the below code to try this.

```<code>def activity_time_from_dict(adict):
    for v in adict.values():
        v = list(set(v))
        v.sort()
</code>```

From printing within the loop it seems to do it correctly, but if I look at the dictionary outside of the loop it has just been sorted and the duplicates remain. I want to replace the original list in the dictionary with the seted and sorted list. What am I doing wrong ?

Body:
I have a dictionary which has single value as key and a list as the value. I am trying to go through the dictionary values and remove duplicates and sort the lists. Im using the below code to try this.

def activity_time_from_dict(adict):
    for v in adict.values():
        v = list(set(v))
        v.sort()

From printing within the loop it seems to do it correctly, but if I look at the dictionary outside of the loop it has just been sorted and the duplicates remain. I want to replace the original list in the dictionary with the seted and sorted list. What am I doing wrong ?

Body:
In [1]: dd = {'a':[1, 3, -5, 2, 3, 1]}

In [2]: for i in dd:sorted(list(set(dd['a'])))

In [3]: for i in dd:
    ...:     dd[i] = sorted(list(set(dd[i])))
    ...:

In [4]: dd
Out[4]: {'a': [-5, 1, 2, ]}


问:
What is the right way to avoid using raw type Comparable in a sort algorithm?

I am writing a merge sort algorithms, so I want all the methods take arguments that implements Comparable interface, i.e. having a method called compareTo.

I have been told many times to avoid using raw type in new code. But I can't find a right way to replace them.

```<code>public class Merge{
    private static Comparable[] aux;
    private Merge() {}

    private static boolean less(Comparable v,Comparable w){
        int sign=v.compareTo(w);
        if (sign==0) throw new IllegalArgumentException("Repeated points");
        return sign<0;
    }

    private static void exch(Comparable[] a,int i,int j){
        Comparable swap =a[i];
        a[i]=a[j];
        a[j]=swap;
    }

    private static void insertSort(Comparable[] a,int lo,int hi){

        for(int i=lo;i<hi+1;++i){
            for(int j=i;j>lo;--j){
                if(less(a[j],a[j-1]))
                    exch(a,j,j-1);
                else
                    break;
            }
        }
    }

    private static void merge(Comparable[] a,Comparable[] aux,int lo,int mid,int hi){
        for(int k=lo;k!=hi+1;++k){
            aux[k]=a[k];
        }

        int i=lo,j=mid+1;
        for(int k=lo;k!=hi+1;++k){
            if(i>mid){
                a[k]=aux[j++];
            }
            else if(j>hi){
                a[k]=aux[i++];
            }
            else if(less(aux[j],aux[i])){
                a[k]=aux[j++];
            }
            else{
                a[k]=aux[i++];
            }
        }
    }

    private static void sort(Comparable[] a, Comparable[] aux,int lo,int hi){
        if(hi<=lo+6){
            insertSort(a,lo,hi);
            return;
        }
        int mid=lo+ (hi-lo)/2;
        sort(a,aux,lo,mid);
        sort(a,aux,mid+1,hi);
        if(!less(a[mid+1],a[mid])) return;
        merge(a,aux,lo,mid,hi);
    }

    private static void sort(Comparable[] a){
        aux=new Comparable[a.length];
        sort(a,aux,0,a.length-1);
    }

}
</code>```

The question What is a raw type and why shouldn't we use it? is different from mine. Actually, I have read the question before. Still, I don't know how toa avoid using Comparable here.

答:
Whereever you have Comparable, use T. And declare T as <T extends Comparable<? super T>>.

You will face a problem with array creation, though. There are two ways how to bypass that. You could clone the original array and clear it in case you need it to be initialized with null, or you could use Reflection to create the array.

```<code>public class Merge {
    private Merge() {
    }

    private static <T extends Comparable<? super T>> boolean less(T v, T w) {
        int sign = v.compareTo(w);
        if (sign == 0) throw new IllegalArgumentException("Repeated points");
        return sign < 0;
    }

    private static <T extends Comparable<? super T>> void exch(T[] a, int i, int j) {
        T swap = a[i];
        a[i] = a[j];
        a[j] = swap;
    }

    private static <T extends Comparable<? super T>> void insertSort(T[] a, int lo, int hi) {

        for (int i = lo; i < hi + 1; ++i) {
            for (int j = i; j > lo; --j) {
                if (less(a[j], a[j - 1]))
                    exch(a, j, j - 1);
                else
                    break;
            }
        }
    }

    private static <T extends Comparable<? super T>> void merge(T[] a, T[] aux, int lo, int mid, int hi) {
        for (int k = lo; k != hi + 1; ++k) {
            aux[k] = a[k];
        }

        int i = lo, j = mid + 1;
        for (int k = lo; k != hi + 1; ++k) {
            if (i > mid) {
                a[k] = aux[j++];
            } else if (j > hi) {
                a[k] = aux[i++];
            } else if (less(aux[j], aux[i])) {
                a[k] = aux[j++];
            } else {
                a[k] = aux[i++];
            }
        }
    }

    private static <T extends Comparable<? super T>> void sort(T[] a, T[] aux, int lo, int hi) {
        if (hi <= lo + 6) {
            insertSort(a, lo, hi);
            return;
        }
        int mid = lo + (hi - lo) / 2;
        sort(a, aux, lo, mid);
        sort(a, aux, mid + 1, hi);
        if (!less(a[mid + 1], a[mid])) return;
        merge(a, aux, lo, mid, hi);
    }

    private static <T extends Comparable<? super T>> void sort(T[] a) {
        T[] aux = a.clone();
        sort(a, aux, 0, a.length - 1);
    }

}
</code>```

You can do away with the repetition of the type parameter <T extends Comparable<? super T>> and also the repetition of a and aux if you use a method object.

```<code>public enum Merge {
    ;

    private static class Merger<T extends Comparable<? super T>> {
        private final T[] a;
        private final T[] aux;

        private Merger(T[] a) {
            this.a = a;
            aux = a.clone();
        }
        private boolean less(T v, T w) {
            int sign = v.compareTo(w);
            if (sign == 0) throw new IllegalArgumentException("Repeated points");
            return sign < 0;
        }

        private void exch(int i, int j) {
            T swap = a[i];
            a[i] = a[j];
            a[j] = swap;
        }

        private void insertSort(int lo, int hi) {

            for (int i = lo; i < hi + 1; ++i) {
                for (int j = i; j > lo; --j) {
                    if (less(a[j], a[j - 1]))
                        exch(j, j - 1);
                    else
                        break;
                }
            }
        }

        private void merge(int lo, int mid, int hi) {
            for (int k = lo; k != hi + 1; ++k) {
                aux[k] = a[k];
            }

            int i = lo, j = mid + 1;
            for (int k = lo; k != hi + 1; ++k) {
                if (i > mid) {
                    a[k] = aux[j++];
                } else if (j > hi) {
                    a[k] = aux[i++];
                } else if (less(aux[j], aux[i])) {
                    a[k] = aux[j++];
                } else {
                    a[k] = aux[i++];
                }
            }
        }

        private void sort(int lo, int hi) {
            if (hi <= lo + 6) {
                insertSort(lo, hi);
                return;
            }
            int mid = lo + (hi - lo) / 2;
            sort(lo, mid);
            sort(mid + 1, hi);
            if (!less(a[mid + 1], a[mid])) return;
                merge(lo, mid, hi);
        }
        private void sort() {
            sort(0, a.length - 1);
        }
    }
    public static <T extends Comparable<? super T>> void sort(T[] a) {
        new Merger<>(a).sort();
    }

}
</code>```

Body:
I am writing a merge sort algorithms, so I want all the methods take arguments that implements Comparable interface, i.e. having a method called compareTo.

I have been told many times to avoid using raw type in new code. But I can't find a right way to replace them.

public class Merge{
    private static Comparable[] aux;
    private Merge() {}

    private static boolean less(Comparable v,Comparable w){
        int sign=v.compareTo(w);
        if (sign==0) throw new IllegalArgumentException("Repeated points");
        return sign<0;
    }

    private static void exch(Comparable[] a,int i,int j){
        Comparable swap =a[i];
        a[i]=a[j];
        a[j]=swap;
    }

    private static void insertSort(Comparable[] a,int lo,int hi){

        for(int i=lo;i<hi+1;++i){
            for(int j=i;j>lo;--j){
                if(less(a[j],a[j-1]))
                    exch(a,j,j-1);
                else
                    break;
            }
        }
    }

    private static void merge(Comparable[] a,Comparable[] aux,int lo,int mid,int hi){
        for(int k=lo;k!=hi+1;++k){
            aux[k]=a[k];
        }

        int i=lo,j=mid+1;
        for(int k=lo;k!=hi+1;++k){
            if(i>mid){
                a[k]=aux[j++];
            }
            else if(j>hi){
                a[k]=aux[i++];
            }
            else if(less(aux[j],aux[i])){
                a[k]=aux[j++];
            }
            else{
                a[k]=aux[i++];
            }
        }
    }

    private static void sort(Comparable[] a, Comparable[] aux,int lo,int hi){
        if(hi<=lo+6){
            insertSort(a,lo,hi);
            return;
        }
        int mid=lo+ (hi-lo)/2;
        sort(a,aux,lo,mid);
        sort(a,aux,mid+1,hi);
        if(!less(a[mid+1],a[mid])) return;
        merge(a,aux,lo,mid,hi);
    }

    private static void sort(Comparable[] a){
        aux=new Comparable[a.length];
        sort(a,aux,0,a.length-1);
    }

}

The question What is a raw type and why shouldn't we use it? is different from mine. Actually, I have read the question before. Still, I don't know how toa avoid using Comparable here.

Body:
Whereever you have Comparable, use T. And declare T as <T extends Comparable<? super T>>.

You will face a problem with array creation, though. There are two ways how to bypass that. You could clone the original array and clear it in case you need it to be initialized with null, or you could use Reflection to create the array.

public class Merge {
    private Merge() {
    }

    private static <T extends Comparable<? super T>> boolean less(T v, T w) {
        int sign = v.compareTo(w);
        if (sign == 0) throw new IllegalArgumentException("Repeated points");
        return sign < 0;
    }

    private static <T extends Comparable<? super T>> void exch(T[] a, int i, int j) {
        T swap = a[i];
        a[i] = a[j];
        a[j] = swap;
    }

    private static <T extends Comparable<? super T>> void insertSort(T[] a, int lo, int hi) {

        for (int i = lo; i < hi + 1; ++i) {
            for (int j = i; j > lo; --j) {
                if (less(a[j], a[j - 1]))
                    exch(a, j, j - 1);
                else
                    break;
            }
        }
    }

    private static <T extends Comparable<? super T>> void merge(T[] a, T[] aux, int lo, int mid, int hi) {
        for (int k = lo; k != hi + 1; ++k) {
            aux[k] = a[k];
        }

        int i = lo, j = mid + 1;
        for (int k = lo; k != hi + 1; ++k) {
            if (i > mid) {
                a[k] = aux[j++];
            } else if (j > hi) {
                a[k] = aux[i++];
            } else if (less(aux[j], aux[i])) {
                a[k] = aux[j++];
            } else {
                a[k] = aux[i++];
            }
        }
    }

    private static <T extends Comparable<? super T>> void sort(T[] a, T[] aux, int lo, int hi) {
        if (hi <= lo + 6) {
            insertSort(a, lo, hi);
            return;
        }
        int mid = lo + (hi - lo) / 2;
        sort(a, aux, lo, mid);
        sort(a, aux, mid + 1, hi);
        if (!less(a[mid + 1], a[mid])) return;
        merge(a, aux, lo, mid, hi);
    }

    private static <T extends Comparable<? super T>> void sort(T[] a) {
        T[] aux = a.clone();
        sort(a, aux, 0, a.length - 1);
    }

}

You can do away with the repetition of the type parameter <T extends Comparable<? super T>> and also the repetition of a and aux if you use a method object.

public enum Merge {
    ;

    private static class Merger<T extends Comparable<? super T>> {
        private final T[] a;
        private final T[] aux;

        private Merger(T[] a) {
            this.a = a;
            aux = a.clone();
        }
        private boolean less(T v, T w) {
            int sign = v.compareTo(w);
            if (sign == 0) throw new IllegalArgumentException("Repeated points");
            return sign < 0;
        }

        private void exch(int i, int j) {
            T swap = a[i];
            a[i] = a[j];
            a[j] = swap;
        }

        private void insertSort(int lo, int hi) {

            for (int i = lo; i < hi + 1; ++i) {
                for (int j = i; j > lo; --j) {
                    if (less(a[j], a[j - 1]))
                        exch(j, j - 1);
                    else
                        break;
                }
            }
        }

        private void merge(int lo, int mid, int hi) {
            for (int k = lo; k != hi + 1; ++k) {
                aux[k] = a[k];
            }

            int i = lo, j = mid + 1;
            for (int k = lo; k != hi + 1; ++k) {
                if (i > mid) {
                    a[k] = aux[j++];
                } else if (j > hi) {
                    a[k] = aux[i++];
                } else if (less(aux[j], aux[i])) {
                    a[k] = aux[j++];
                } else {
                    a[k] = aux[i++];
                }
            }
        }

        private void sort(int lo, int hi) {
            if (hi <= lo + 6) {
                insertSort(lo, hi);
                return;
            }
            int mid = lo + (hi - lo) / 2;
            sort(lo, mid);
            sort(mid + 1, hi);
            if (!less(a[mid + 1], a[mid])) return;
                merge(lo, mid, hi);
        }
        private void sort() {
            sort(0, a.length - 1);
        }
    }
    public static <T extends Comparable<? super T>> void sort(T[] a) {
        new Merger<>(a).sort();
    }

}


问:
I want to invite the member to team on tfs but getting error 'No identities found'
I am getting error "No identities found" when inserting member to my team. I've verified the email address is correct. Why am I seeing this text? How can i fix this?
why cannot found?</p>

答:
According to your screenshot, you are working on VSTS, you could double confirm this-- sever url should like https://xxx.visualstudio.com.

And you want to login VSTS with an non Microsoft email, you should pay attention to below:

Sign up for Visual Studio Team Services with a work or school account

Control access to Visual Studio Team Services the same way you do with
  Microsoft services like Office 365 and Azure. When you sign up with a
  work or school account, your Visual Studio Team Services account is
  connected to your organization's directory (tenant) in Azure Active
  Directory (Azure AD). You can then use the same username and password
  as other Microsoft services, like @fabrikam.com. Azure AD helps you
  enforce policies around accessing your team's critical resources and
  key assets.

More details, please refer link from MSDN: Sign up for Visual Studio Team Services: Git & Agile for DevOps, continuous integration, & continuous delivery

Finally, just follow the details steps in this tutorial to add users to a team project.


问:
css-grids, max-height on Chrome not working?
I want to build a Website Applikation with a fixed Size.

Only a content div should be scrollable.

On FireFox my App worked correctly, but on Chrome i get a strange behaviour and i cannot figure out why?

I extract the problem in a small example as follows.

```<code><!DOCTYPE html>
<html>
<head>
    <title>App</title>
    <style>
        html, body
        {
            left: 0;
            top: 0;
            margin: 0;
            width: 100vw;
            height: 100vh;
        }

        .app
        {
            height : 100vh;
            width : 100vw;
            /*overflow: hidden;*/
            display: grid;
            grid-template-rows: 100px auto;
        }

        .content
        {
            display: grid;
            grid-template-columns: 500px auto;
            height: 100%;
            max-height: 100%;
        }

        .scrollable
        {
            overflow: auto;
            max-height: 100%;
        }

        .red
        {
            background-color: red;
        }

        .yellow
        {
            background-color: yellow;
        }

        .blue
        {
          background-color: blue;
        }
    </style>
</head>

<body>
  <div class="app">
    <div class="yellow"></div>
    <div class="content">
      <div class="red scrollable">
        some content <br />
        some content <br />
        .
        .
        .
        some content <br />
        some content <br />
      </div>

      <div class="blue scrollable"></div>
    </div>
  </div>
</body>

</html>
</code>```

in firefox just the red div got a scrollbar, but in chrome the whole page get one. Why they behave differently and how can i fix this in chrome?

答:
Use HTML5 features.

.app {
    height : 100vh;
    width : 100vw;
    overflow: hidden;
}
```

Body:
I want to build a Website Applikation with a fixed Size.

Only a content div should be scrollable.

On FireFox my App worked correctly, but on Chrome i get a strange behaviour and i cannot figure out why?

I extract the problem in a small example as follows.

<!DOCTYPE html>

    <title>App</title>

        some content

        some content

        .
        .
        .
        some content

        some content

in firefox just the red div got a scrollbar, but in chrome the whole page get one. Why they behave differently and how can i fix this in chrome?


问:
How to fix overlapping objects
I have recently started understanding on how to code in Android Studio and want to set up basic coding. I created 2 number objects and 1 button, 1 plain text object.
Without writing any piece of code, when I click on Run App button on Android Studio and select any Emulator, all the objects stack up on each other. Is there a simple way to fix this?

Following is the text in activity_main.xml:

```<code><?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.myapplication70.MainActivity">

    <EditText
        android:id="@+id/editText3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10"
        android:hint="Result"
        android:inputType="numberDecimal"
        tools:layout_editor_absoluteX="67dp"
        tools:layout_editor_absoluteY="223dp" />

    <EditText
        android:id="@+id/editText1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="number"
        tools:layout_editor_absoluteX="67dp"
        tools:layout_editor_absoluteY="60dp" />

    <EditText
        android:id="@+id/editText2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="numberSigned"
        tools:layout_editor_absoluteX="67dp"
        tools:layout_editor_absoluteY="134dp" />

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button"
        tools:layout_editor_absoluteX="100dp"
        tools:layout_editor_absoluteY="319dp" />

</android.support.constraint.ConstraintLayout>
</code>```

答:
Remove all your tools:layout_editor_absoluteX & tools:layout_editor_absoluteY attributes.

As per Documentation

When you build your app, the build tools remove these attributes so
  there is no effect on your APK size or runtime behavior

If you want to align all your attributes according to your displayed preview and using ConstraintLayout, I suggest learn more about ConstraintLayout and how to Build a Responsive UI with ConstraintLayout

Also, to fix your current layout, you can make changes like:

```<code><?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.myapplication70.MainActivity">

    <EditText
        android:id="@+id/editText1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="32dp"
        android:ems="10"
        android:inputType="number"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <EditText
        android:id="@+id/editText2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="32dp"
        android:ems="10"
        android:inputType="numberSigned"
        app:layout_constraintEnd_toEndOf="@+id/editText1"
        app:layout_constraintStart_toStartOf="@+id/editText1"
        app:layout_constraintTop_toBottomOf="@+id/editText1" />

    <EditText
        android:id="@+id/editText3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="32dp"
        android:ems="10"
        android:hint="Result"
        android:inputType="numberDecimal"
        app:layout_constraintEnd_toEndOf="@+id/editText2"
        app:layout_constraintStart_toStartOf="@+id/editText2"
        app:layout_constraintTop_toBottomOf="@+id/editText2" />

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="32dp"
        android:text="Button"
        app:layout_constraintEnd_toEndOf="@+id/editText3"
        app:layout_constraintStart_toStartOf="@+id/editText3"
        app:layout_constraintTop_toBottomOf="@+id/editText3" />

</android.support.constraint.ConstraintLayout>
</code>```

Title: How to fix overlapping objects

Body:
I have recently started understanding on how to code in Android Studio and want to set up basic coding. I created 2 number objects and 1 button, 1 plain text object.
Without writing any piece of code, when I click on Run App button on Android Studio and select any Emulator, all the objects stack up on each other. Is there a simple way to fix this?

Following is the text in activity_main.xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.myapplication70.MainActivity">

    <EditText
        android:id="@+id/editText3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10"
        android:hint="Result"
        android:inputType="numberDecimal"
        tools:layout_editor_absoluteX="67dp"
        tools:layout_editor_absoluteY="223dp" />

    <EditText
        android:id="@+id/editText1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="number"
        tools:layout_editor_absoluteX="67dp"
        tools:layout_editor_absoluteY="60dp" />

    <EditText
        android:id="@+id/editText2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="numberSigned"
        tools:layout_editor_absoluteX="67dp"
        tools:layout_editor_absoluteY="134dp" />

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button"
        tools:layout_editor_absoluteX="100dp"
        tools:layout_editor_absoluteY="319dp" />

</android.support.constraint.ConstraintLayout>

Body:
Remove all your tools:layout_editor_absoluteX & tools:layout_editor_absoluteY attributes.

As per Documentation

When you build your app, the build tools remove these attributes so
  there is no effect on your APK size or runtime behavior

If you want to align all your attributes according to your displayed preview and using ConstraintLayout, I suggest learn more about ConstraintLayout and how to Build a Responsive UI with ConstraintLayout

Also, to fix your current layout, you can make changes like:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.myapplication70.MainActivity">

    <EditText
        android:id="@+id/editText1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="32dp"
        android:ems="10"
        android:inputType="number"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <EditText
        android:id="@+id/editText2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="32dp"
        android:ems="10"
        android:inputType="numberSigned"
        app:layout_constraintEnd_toEndOf="@+id/editText1"
        app:layout_constraintStart_toStartOf="@+id/editText1"
        app:layout_constraintTop_toBottomOf="@+id/editText1" />

    <EditText
        android:id="@+id/editText3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="32dp"
        android:ems="10"
        android:hint="Result"
        android:inputType="numberDecimal"
        app:layout_constraintEnd_toEndOf="@+id/editText2"
        app:layout_constraintStart_toStartOf="@+id/editText2"
        app:layout_constraintTop_toBottomOf="@+id/editText2" />

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="32dp"
        android:text="Button"
        app:layout_constraintEnd_toEndOf="@+id/editText3"
        app:layout_constraintStart_toStartOf="@+id/editText3"
        app:layout_constraintTop_toBottomOf="@+id/editText3" />

</android.support.constraint.ConstraintLayout>


问:
get the windows installation drive using python
How to detect the windows installation path or drive using python code ?</p>

答:
You can use GetWindowsDirectory via the ctypes library to get the location of the Windows folder, and then you can use os.path.splitdrive to get the drive letter.  For example:

```<code>import ctypes
import os

kernel32 = ctypes.windll.kernel32
windows_directory = ctypes.create_unicode_buffer(1024)
if kernel32.GetWindowsDirectoryW(windows_directory, 1024) == 0:
    # Handle error
else:
    windows_drive = os.path.splitdrive(windows_directory)[0]
</code>```

Body:
You can use GetWindowsDirectory via the ctypes library to get the location of the Windows folder, and then you can use os.path.splitdrive to get the drive letter.  For example:

import ctypes
import os

kernel32 = ctypes.windll.kernel32
windows_directory = ctypes.create_unicode_buffer(1024)
if kernel32.GetWindowsDirectoryW(windows_directory, 1024) == 0:
    # Handle error
else:
    windows_drive = os.path.splitdrive(windows_directory)[0]


问:
asp.net mvc How to add placeholder for html.dropdownlist
I'm using asp.net mvc 3.

I have this dropdownlist of countries and I want to add a placeholder for it. Here's my code:

```<code>@Html.DropDownList("country",
     new SelectList(ViewBag.countries as System.Collections.IEnumerable,
     "name", "name"), new { @class="chzn-select", @placeholder="-select-",
     @style="width:160px;" } )
</code>```

But the placeholder doesn't work, while the style works.

How do I set a placeholder for this?

PS. I just want to use @Html.DropDownList, not @Html.DropDownListFor

答:
Best way</p>

```<code>@Html.DropDownListFor(m => m.SelectedProductIDs,
                      Model.AvaliableProducts.ToSelectList("ID","Name"),
                      "Please select a product",
                      new { @class = "chzn-select"})
</code>```

Body:
I'm using asp.net mvc 3.

I have this dropdownlist of countries and I want to add a placeholder for it. Here's my code:

@Html.DropDownList("country",
     new SelectList(ViewBag.countries as System.Collections.IEnumerable,
     "name", "name"), new { @class="chzn-select", @placeholder="-select-",
     @style="width:160px;" } )

But the placeholder doesn't work, while the style works.

How do I set a placeholder for this?

PS. I just want to use @Html.DropDownList, not @Html.DropDownListFor

Body:
Best way

@Html.DropDownListFor(m => m.SelectedProductIDs,
                      Model.AvaliableProducts.ToSelectList("ID","Name"),
                      "Please select a product",
                      new { @class = "chzn-select"})


问:
Multitenancy issue with AAD
We have a multitenant multitier scenario in Azure AAD  where a client app calls multiple Web APIs. These WebAPIs in turn calls other WebAPIs.
Every time we add a take new API dependency , we see that users from other than the app tenancy is unable to logon. We see the below error

AADSTS65005: The app needs access to a service……

My question is what is the best practice or guidance around multitenancy. Do we need to provide the admin consent every time we add a new dependency

答:
The problem is that you are adding a new permission requirement to the Application object. The permission grants are not created on the service principals automatically, it always requires consent. You can quite easily grant this in a single-tenant scenario, but multi-tenant is harder.

Since it would make no sense that I could just add permissions to read all users' mailboxes when it could not before, the only option is to run admin consent for each tenant again.

The v2 endpoint allows you to handle this in an easier way as it allows dynamic/incremental consent, where you can specify a new scope from the client. Though even then you would have to provide some notification to the users that they can't use the new functionality until their admin grants consent.

Title: Multitenancy issue with AAD


问:
List<string> to Alertcontroller
Noob question....i am new into developing apps, i hope this question isn't too stupid.

I have a TableView with companys from my database. When I Swipe, I want to have 3 options.

1. Show Information about the selected Company in an AlertController

 2. Manage some Information about the selected Company

 3. Delete the selected Company

My Question is for Case 1.

The swipe function works and the AlertController appears. But I have the following error message for the Information from my database:
System.Collection.Generic.List'1[Systen.String]

picture

If you need the hole Code, I can upload it. I hope these two parts are enough.

My code:

```<code>public partial class ListViewController : UITableViewController
{
    public ListViewController(IntPtr handle) : base(handle)
    {
    }

    List<string> words = new List<string>();
    List<string> adresse = new List<string>();

  .....

 public UIContextualAction ContextualFlagAction(int row)
    {
        var action = UIContextualAction.FromContextualActionStyle(UIContextualActionStyle.Normal,
                                                                  "Flag",
                                                                  (FlagAction, view, success) => {
            var alertController = UIAlertController.Create($"Information über {words[row]}", $"Straße: {adresse}", UIAlertControllerStyle.Alert);

                                                                       //kuddelmuddel beginnt

                                                                      using (MySqlConnection connection2 = new MySqlConnection("Connection String"))
                                                                      {
                                                                            string query = $"SELECT Strasse FROM Kunden WHERE Firma LIKE '{words[row]}'";
                                                                            MySqlCommand command = new MySqlCommand(query, connection2);

                                                                          connection2.Open();

                                                                            using (MySqlDataReader reader = command.ExecuteReader())
                                                                            {
                                                                            while (reader.Read())
                                                                            {
                                                                            adresse.Add(reader.GetString(0));
                                                                            }

                                                                          }
                                                                      }

                                                                        //kuddelmuddel endet
                                                                      alertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Cancel, null));

                                                                     PresentViewController(alertController, true, null);

                                                                     success(true);
                                                                  });

        action.Image = UIImage.FromFile("feedback.png");
        action.BackgroundColor = UIColor.Blue;

        return action;
    }
</code>```

答:
@Jason said, the error comes with treating the list as a string.And make the alert show after the db operation.

Modify

```<code>using (MySqlConnection connection2 = new MySqlConnection("Connection String"))
{
    string query = $"SELECT Strasse FROM Kunden WHERE Firma LIKE '{words[row]}'";
    MySqlCommand command = new MySqlCommand(query, connection2);
    connection2.Open();
    using (MySqlDataReader reader = command.ExecuteReader())
    {
        while (reader.Read())
        {
           adresse.Add(reader.GetString(0));
        }
    }
}

var alertController = UIAlertController.Create($"Information über {words[row]}", $"Straße: {adresse[0]}", UIAlertControllerStyle.Alert);
alertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Cancel, null));
PresentViewController(alertController, true, null);
</code>```

Title: List<string> to Alertcontroller

Body:
Noob question....i am new into developing apps, i hope this question isn't too stupid.

I have a TableView with companys from my database. When I Swipe, I want to have 3 options.

1. Show Information about the selected Company in an AlertController

 2. Manage some Information about the selected Company

 3. Delete the selected Company

My Question is for Case 1.

The swipe function works and the AlertController appears. But I have the following error message for the Information from my database:
System.Collection.Generic.List'1[Systen.String]

picture

If you need the hole Code, I can upload it. I hope these two parts are enough.

My code:

public partial class ListViewController : UITableViewController
{
    public ListViewController(IntPtr handle) : base(handle)
    {
    }

    List<string> words = new List<string>();
    List<string> adresse = new List<string>();

  .....

 public UIContextualAction ContextualFlagAction(int row)
    {
        var action = UIContextualAction.FromContextualActionStyle(UIContextualActionStyle.Normal,
                                                                  "Flag",
                                                                  (FlagAction, view, success) => {
            var alertController = UIAlertController.Create($"Information über {words[row]}", $"Straße: {adresse}", UIAlertControllerStyle.Alert);

                                                                       //kuddelmuddel beginnt

                                                                      using (MySqlConnection connection2 = new MySqlConnection("Connection String"))
                                                                      {
                                                                            string query = $"SELECT Strasse FROM Kunden WHERE Firma LIKE '{words[row]}'";
                                                                            MySqlCommand command = new MySqlCommand(query, connection2);

                                                                          connection2.Open();

                                                                            using (MySqlDataReader reader = command.ExecuteReader())
                                                                            {
                                                                            while (reader.Read())
                                                                            {
                                                                            adresse.Add(reader.GetString(0));
                                                                            }

                                                                          }
                                                                      }

                                                                        //kuddelmuddel endet
                                                                      alertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Cancel, null));

                                                                     PresentViewController(alertController, true, null);

                                                                     success(true);
                                                                  });

        action.Image = UIImage.FromFile("feedback.png");
        action.BackgroundColor = UIColor.Blue;

        return action;
    }

Body:
@Jason said, the error comes with treating the list as a string.And make the alert show after the db operation.

Modify

using (MySqlConnection connection2 = new MySqlConnection("Connection String"))
{
    string query = $"SELECT Strasse FROM Kunden WHERE Firma LIKE '{words[row]}'";
    MySqlCommand command = new MySqlCommand(query, connection2);
    connection2.Open();
    using (MySqlDataReader reader = command.ExecuteReader())
    {
        while (reader.Read())
        {
           adresse.Add(reader.GetString(0));
        }
    }
}

var alertController = UIAlertController.Create($"Information über {words[row]}", $"Straße: {adresse[0]}", UIAlertControllerStyle.Alert);
alertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Cancel, null));
PresentViewController(alertController, true, null);


问:
jQuery combine data source urls on alpaca library
in this below code i have to use unique urls to get necessary data form server to use alpaca library , how can i combine this urls to get data from server with one url for example:

```<code>http://127.0.0.1:8000/content_categories
</code>```

my alpaca library implementation is:

```<code>$("#content_categories").alpaca({
    "data": [],
    "schema": "http://127.0.0.1:8000/schema",
    "options": "http://127.0.0.1:8000/options",
    "postRender": function (control) {
        $("#multiselect").parent().find("input[type=checkbox]").uniform();
    }
});
</code>```

and server implementation to send result:

```<code>Route::get('/schema', function () {
    echo json_encode(
        ["type" => 'array',
            "items" =>
                ["type" => "string",
                    "enum" => ["salam", "ma"],
                    "minItems" => 1,
                    "maxItems" => 20
                ]
        ]);

});

Route::get('/options', function () {
    echo json_encode(
        ["helper" => "یک یا چند مورد انتخاب کنید",
            "type" => "select",
            "id" => "multiselect",
            "focus" => false,
            "size" => 1]
    );
});
</code>```

for example:

```<code>Route::get('/content_categories', function () {
    echo json_encode([
            "schema" => ["type" => 'array',
                "items" =>
                    ["type" => "string",
                        "enum" => ["salam", "ma"],
                        "minItems" => 1,
                        "maxItems" => 20
                    ]
            ],
            "options" => ["helper" => "یک یا چند مورد انتخاب کنید",
                "type" => "select",
                "id" => "multiselect",
                "focus" => false,
                "size" => 1
            ]
        ]
    );
});
</code>```

答:
Yes you can do that with only one webservice which you should call it before alpaca initialization using ajax for example...and you should also devide the response to schema and options objects like this :

```<code>"schema": response.schema,
"options": response.options
</code>```

here's a fiddle for this.

Body:
in this below code i have to use unique urls to get necessary data form server to use alpaca library , how can i combine this urls to get data from server with one url for example:

http://127.0.0.1:8000/content_categories

my alpaca library implementation is:

$("#content_categories").alpaca({
    "data": [],
    "schema": "http://127.0.0.1:8000/schema",
    "options": "http://127.0.0.1:8000/options",
    "postRender": function (control) {
        $("#multiselect").parent().find("input[type=checkbox]").uniform();
    }
});

and server implementation to send result:

Route::get('/schema', function () {
    echo json_encode(
        ["type" => 'array',
            "items" =>
                ["type" => "string",
                    "enum" => ["salam", "ma"],
                    "minItems" => 1,
                    "maxItems" => 20
                ]
        ]);

});

Route::get('/options', function () {
    echo json_encode(
        ["helper" => "یک یا چند مورد انتخاب کنید",
            "type" => "select",
            "id" => "multiselect",
            "focus" => false,
            "size" => 1]
    );
});

for example:

Route::get('/content_categories', function () {
    echo json_encode([
            "schema" => ["type" => 'array',
                "items" =>
                    ["type" => "string",
                        "enum" => ["salam", "ma"],
                        "minItems" => 1,
                        "maxItems" => 20
                    ]
            ],
            "options" => ["helper" => "یک یا چند مورد انتخاب کنید",
                "type" => "select",
                "id" => "multiselect",
                "focus" => false,
                "size" => 1
            ]
        ]
    );
});

Body:
Yes you can do that with only one webservice which you should call it before alpaca initialization using ajax for example...and you should also devide the response to schema and options objects like this :

"schema": response.schema,
"options": response.options

here's a fiddle for this.


问:
Ember.js computed property to return model ID array?
Updated: 11:36PST 07 Dec 2017

All I'm trying to do is create an array containing a list of current ID's in the model to use in a child component, but somehow seem to be missing something obvious. If it is relevant, I am using Ember 2.17.0 with Ember Data 2.17.0 as well.

The route returns an array of models very similar to a findAll, but modified to work with a REST endpoint I do not have any control over. I need an array of the id's from the model to use in a component embedded in the route. Based on feedback, I have attempted to implement this in both the route and the controller.

In the controller, I'm trying it this way.

```<code>searchIdArrayC: computed('model', () => {
  return this.get('model').map((record) => record.get('reachId'));
})
</code>```

..and in the route I'm trying it this way.

```<code>searchIdArrayR: computed('model', () => {
  return this.modelFor('reaches').map((record) => record.get('reachId'));
});
</code>```

When I look at it in the Chrome Ember Inspector, for both the route and controller it is telling me Error while computing: searchIdArrayR or Error while computing: searchIdArrayC.

Just to try and do some testing, I sent both the route and the controller to the console. With both the route and controller, the aforementioned methods are working, so I am really confused.

Thank you in advance for any help or guidance you may be able to offer.

答:
In route file, model is a function, but you are treating it like model property which is available in the corresponding controller.

If you can move searchIdArray computed property to corresponding controller then that should work.

Body:
Updated: 11:36PST 07 Dec 2017

All I'm trying to do is create an array containing a list of current ID's in the model to use in a child component, but somehow seem to be missing something obvious. If it is relevant, I am using Ember 2.17.0 with Ember Data 2.17.0 as well.

The route returns an array of models very similar to a findAll, but modified to work with a REST endpoint I do not have any control over. I need an array of the id's from the model to use in a component embedded in the route. Based on feedback, I have attempted to implement this in both the route and the controller.

In the controller, I'm trying it this way.

searchIdArrayC: computed('model', () => {
  return this.get('model').map((record) => record.get('reachId'));
})

..and in the route I'm trying it this way.

searchIdArrayR: computed('model', () => {
  return this.modelFor('reaches').map((record) => record.get('reachId'));
});

When I look at it in the Chrome Ember Inspector, for both the route and controller it is telling me Error while computing: searchIdArrayR or Error while computing: searchIdArrayC.

Just to try and do some testing, I sent both the route and the controller to the console. With both the route and controller, the aforementioned methods are working, so I am really confused.

Thank you in advance for any help or guidance you may be able to offer.


问:
GDB and asm 32 bytes
for my school i'm doing a security project. The first steep is from the binary, find the c code source.

I have one problem here, this is the asm code from the school binary with GDB:
Main:

```<code>   0x0804853f <+0>: push   ebp
   0x08048540 <+1>: mov    ebp,esp
   0x08048542 <+3>: and    esp,0xfffffff0
   0x08048545 <+6>: call   0x80484d4 <p>
   0x0804854a <+11>:    leave
   0x0804854b <+12>:    ret
</code>```

func P:

```<code>   0x080484d4 <+0>: push   ebp
   0x080484d5 <+1>: mov    ebp,esp
   0x080484d7 <+3>: sub    esp,0x68
   0x080484da <+6>: mov    eax,ds:0x8049860
   0x080484df <+11>:    mov    DWORD PTR [esp],eax
   0x080484e2 <+14>:    call   0x80483b0 <fflush@plt>
   0x080484e7 <+19>:    lea    eax,[ebp-0x4c]
   0x080484ea <+22>:    mov    DWORD PTR [esp],eax
   0x080484ed <+25>:    call   0x80483c0 <gets@plt>
   0x080484f2 <+30>:    mov    eax,DWORD PTR [ebp+0x4]
   0x080484f5 <+33>:    mov    DWORD PTR [ebp-0xc],eax
   0x080484f8 <+36>:    mov    eax,DWORD PTR [ebp-0xc]
   0x080484fb <+39>:    and    eax,0xb0000000
   0x08048500 <+44>:    cmp    eax,0xb0000000
   0x08048505 <+49>:    jne    0x8048527 <p+83>
   0x08048507 <+51>:    mov    eax,0x8048620
   0x0804850c <+56>:    mov    edx,DWORD PTR [ebp-0xc]
   0x0804850f <+59>:    mov    DWORD PTR [esp+0x4],edx
   0x08048513 <+63>:    mov    DWORD PTR [esp],eax
   0x08048516 <+66>:    call   0x80483a0 <printf@plt>
   0x0804851b <+71>:    mov    DWORD PTR [esp],0x1
   0x08048522 <+78>:    call   0x80483d0 <_exit@plt>
   0x08048527 <+83>:    lea    eax,[ebp-0x4c]
   0x0804852a <+86>:    mov    DWORD PTR [esp],eax
   0x0804852d <+89>:    call   0x80483f0 <puts@plt>
   0x08048532 <+94>:    lea    eax,[ebp-0x4c]
   0x08048535 <+97>:    mov    DWORD PTR [esp],eax
   0x08048538 <+100>:   call   0x80483e0 <strdup@plt>
   0x0804853d <+105>:   leave
   0x0804853e <+106>:   ret
</code>```

I have no idee where the line p+30 from because ebp+4 mean the variable from before the stack of the func P but P have no parameter...

Have you got a idea where this variable from? and how can i get her ? Actualy this is my source.c It's wrong close to the gets thx :)

```<code>#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//gcc -fno-stack-protector -z execstack -Wl,-z,norelro -m32 source.c

void                p(void)
{
    char            str[0x40]
    void            *ptr;

    fflush(stdin);
    ptr = gets(str);;
    if (((unsigned int)ptr & 0xb0000000) == 0xb0000000)
    {
        printf("(%p)\n", ptr);
        exit(0x1);
    }
    puts(str);
    strdup(str);
}

int             main(int argc, char **argv)
{
    p();
}
</code>```

答:
After making a stack frame, [ebp+0x4] is the return address.  On function entry, args start at [esp+4], which becomes [esp+8] after you push ebp.  Thus, with a stack frame, the first arg would be at [ebp+8].

To get a compiler to emit something like that asm for p, you'd need to use something like the GNU C __builtin_return_address extension.

```<code>#include <stdint.h>

void foo(void) {
    uintptr_t ptr = (uintptr_t)__builtin_return_address(0);
    // 0 means current function's ret addr.
    // higher numbers backtrace up the call stack.
}
</code>```

There's also a __builtin_frame_address...

Title: GDB and asm 32 bytes

Body:
for my school i'm doing a security project. The first steep is from the binary, find the c code source.

I have one problem here, this is the asm code from the school binary with GDB:
Main:

   0x0804853f <+0>: push   ebp
   0x08048540 <+1>: mov    ebp,esp
   0x08048542 <+3>: and    esp,0xfffffff0
   0x08048545 <+6>: call   0x80484d4

   0x0804854a <+11>:    leave
   0x0804854b <+12>:    ret

func P:

   0x080484d4 <+0>: push   ebp
   0x080484d5 <+1>: mov    ebp,esp
   0x080484d7 <+3>: sub    esp,0x68
   0x080484da <+6>: mov    eax,ds:0x8049860
   0x080484df <+11>:    mov    DWORD PTR [esp],eax
   0x080484e2 <+14>:    call   0x80483b0 <fflush@plt>
   0x080484e7 <+19>:    lea    eax,[ebp-0x4c]
   0x080484ea <+22>:    mov    DWORD PTR [esp],eax
   0x080484ed <+25>:    call   0x80483c0 <gets@plt>
   0x080484f2 <+30>:    mov    eax,DWORD PTR [ebp+0x4]
   0x080484f5 <+33>:    mov    DWORD PTR [ebp-0xc],eax
   0x080484f8 <+36>:    mov    eax,DWORD PTR [ebp-0xc]
   0x080484fb <+39>:    and    eax,0xb0000000
   0x08048500 <+44>:    cmp    eax,0xb0000000
   0x08048505 <+49>:    jne    0x8048527

   0x08048507 <+51>:    mov    eax,0x8048620
   0x0804850c <+56>:    mov    edx,DWORD PTR [ebp-0xc]
   0x0804850f <+59>:    mov    DWORD PTR [esp+0x4],edx
   0x08048513 <+63>:    mov    DWORD PTR [esp],eax
   0x08048516 <+66>:    call   0x80483a0 <printf@plt>
   0x0804851b <+71>:    mov    DWORD PTR [esp],0x1
   0x08048522 <+78>:    call   0x80483d0 <_exit@plt>
   0x08048527 <+83>:    lea    eax,[ebp-0x4c]
   0x0804852a <+86>:    mov    DWORD PTR [esp],eax
   0x0804852d <+89>:    call   0x80483f0 <puts@plt>
   0x08048532 <+94>:    lea    eax,[ebp-0x4c]
   0x08048535 <+97>:    mov    DWORD PTR [esp],eax
   0x08048538 <+100>:   call   0x80483e0 <strdup@plt>
   0x0804853d <+105>:   leave
   0x0804853e <+106>:   ret

I have no idee where the line p+30 from because ebp+4 mean the variable from before the stack of the func P but P have no parameter...

Have you got a idea where this variable from? and how can i get her ? Actualy this is my source.c It's wrong close to the gets thx :)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//gcc -fno-stack-protector -z execstack -Wl,-z,norelro -m32 source.c

void                p(void)
{
    char            str[0x40]
    void            *ptr;

    fflush(stdin);
    ptr = gets(str);;
    if (((unsigned int)ptr & 0xb0000000) == 0xb0000000)
    {
        printf("(%p)\n", ptr);
        exit(0x1);
    }
    puts(str);
    strdup(str);
}

int             main(int argc, char **argv)
{
    p();
}

Body:
After making a stack frame, [ebp+0x4] is the return address.  On function entry, args start at [esp+4], which becomes [esp+8] after you push ebp.  Thus, with a stack frame, the first arg would be at [ebp+8].

To get a compiler to emit something like that asm for p, you'd need to use something like the GNU C __builtin_return_address extension.

#include <stdint.h>

void foo(void) {
    uintptr_t ptr = (uintptr_t)__builtin_return_address(0);
    // 0 means current function's ret addr.
    // higher numbers backtrace up the call stack.
}

There's also a __builtin_frame_address...


问:
Print scenario name when running each scenario
I want to print the name of each scenario as the test run. What can i call or do to get the name so that i can execute * print <scenario_name> ?

The answer for this post is exactly what i want to do: Print scenario name Is there a way to access the Scenario object?

答:
As of now this is not supported, but will be easy to add. But here's the question - is this just to help you make sense of the logs ? Because if you are not using the Cucumber HTML report yet, you should - and that's what most teams are using: https://twitter.com/KarateDSL/status/899671441221623809

Refer to this discussion for more: https://stackoverflow.com/a/47555173/143475

If you still really need this, kindly raise a feature request.

Edit: this will be available in the next version: https://github.com/intuit/karate/issues/257


问:
how to apply a custom mode to mapbox-gl-draw when writing a html which uses GL draw to draw a feature
On the github of the mapbox-gl-draw, I've seen that draw provides an interface for writing and hooking in custom modes, but how does the custom modes actually be used on the browser? For example, if I want to write a mode which can draw a curve line, how can I add this new mode to draw's original modes and be used in browser? I'm new to mapbox gl, and hope anyone can help me on this, thanks a lot!</p>

答: download the zip on the github, and edit the js file in src. At last, use the nodejs to execute "npm run build" and generate a new mapbox-gl-draw.js in the dist, which can be used in the html by writing </p>


问:
how to print project id number using project table in Laravel 5.2
I have collaboration model in My laravel app and consider following form

```<code><div class="container">
      @if($collaboration)
        <div class="row">
        @foreach ($collaboration as $proj)
<div class="col-md-3" style="border:1px solid #ccc;margin-left:5px;">

         <h2><a href="/collaborators/{{ $proj->project_id }}/">{!! $proj->project_id !!}</a></h2>
               <p>Due : {!! date_format(new DateTime($proj->due_date), "D, m Y") !!}</p>
               <p>Status: {!! $proj->project_status !!}</p>
               <p>Tasks: 0</p>
               <p>Comments: 0</p>
               <p>Attachments: 0</p>
               </div>
                @endforeach
         </div>
      @endif
</code>```

my collaboration model as following.

```<code>id project_id collaborator_id
 1     1            1
 2     1            2
 3     2            1
</code>```

now I need print project_name instinct project_id

this is my project model

```<code>id  project_name
 1       kiu
 2       jhy
 3       juh
</code>```

how can I do this?

答:
It is very simple you need to use join in your controller function like this way :

```<code> $collaboration = DB::table('collaboration')
                ->join('project ','project.id','=','collaboration.project_id')
                ->select('collaboration.*','project.project_name')
                ->get();
dd($collaboration);
</code>```

Rest everything will work like same you have added in view file, Hope it helps!

Body:
I have collaboration model in My laravel app and consider following form

      @if($collaboration)

        @foreach ($collaboration as $proj)

project_id }}/">{!! $proj->project_id !!}

Due : {!! date_format(new DateTime($proj->due_date), "D, m Y") !!}

Status: {!! $proj->project_status !!}

Tasks: 0

Comments: 0

Attachments: 0

                @endforeach

      @endif

my collaboration model as following.

id project_id collaborator_id
 1     1            1
 2     1            2
 3     2            1

now I need print project_name instinct project_id

this is my project model

id  project_name
 1       kiu
 2       jhy
 3       juh

how can I do this?

Body:
It is very simple you need to use join in your controller function like this way :

 $collaboration = DB::table('collaboration')
                ->join('project ','project.id','=','collaboration.project_id')
                ->select('collaboration.*','project.project_name')
                ->get();
dd($collaboration);

Rest everything will work like same you have added in view file, Hope it helps!


问:
Second page does not fully cover previous page (Xamarin Forms)
I'm currently working on Xamarin Forms app.
My application works in full screen mode without toolbar. When I move from first to second page, the second page shows properly, but I still see small part of the first page on the top of application.

Screens from android application:

First page

Second page with part of first page on top

I added this annotation to MainActivity.cs

this.Window.AddFlags(WindowManagerFlags.Fullscreen);

App.xaml.cs:

```<code>    public App()
    {
        InitializeComponent();
        MainPage = new App3.MainPage();
    }
</code>```

My question is, how can I show only second page on full screen?

答:
Here is an simple solution :

First, use NavigationPage to manages the navigation :

```<code>MainPage = new NavigationPage(new MainPage());
</code>```

Second, in your MainPage.xaml.cs, hide the  NavigationBar :

```<code>public partial class MainPage : ContentPage
{
    public MainPage()
    {
        NavigationPage.SetHasNavigationBar(this, false);
        InitializeComponent();
    }

    private async void Button_Clicked(object sender, EventArgs e)
    {
        await Navigation.PushAsync(new Page1());
    }
}
</code>```

In your second page do the same thing :

```<code>public partial class Page1 : ContentPage
{
    public Page1()
    {
        NavigationPage.SetHasNavigationBar(this, false);
        InitializeComponent();
    }
}
</code>```

Effect.

Body:
I'm currently working on Xamarin Forms app.
My application works in full screen mode without toolbar. When I move from first to second page, the second page shows properly, but I still see small part of the first page on the top of application.

Screens from android application:

First page

Second page with part of first page on top

I added this annotation to MainActivity.cs

this.Window.AddFlags(WindowManagerFlags.Fullscreen);

App.xaml.cs:

    public App()
    {
        InitializeComponent();
        MainPage = new App3.MainPage();
    }

My question is, how can I show only second page on full screen?

Body:
Here is an simple solution :

First, use NavigationPage to manages the navigation :

MainPage = new NavigationPage(new MainPage());

Second, in your MainPage.xaml.cs, hide the  NavigationBar :

public partial class MainPage : ContentPage
{
    public MainPage()
    {
        NavigationPage.SetHasNavigationBar(this, false);
        InitializeComponent();
    }

    private async void Button_Clicked(object sender, EventArgs e)
    {
        await Navigation.PushAsync(new Page1());
    }
}

In your second page do the same thing :

public partial class Page1 : ContentPage
{
    public Page1()
    {
        NavigationPage.SetHasNavigationBar(this, false);
        InitializeComponent();
    }
}

Effect.


问:
Show Console in Windows Application?
Is there a way to show the console in a Windows application?

I want to do something like this:

```<code>static class Program
{
    [STAThread]
    static void Main(string[] args) {
        bool consoleMode = Boolean.Parse(args[0]);

        if (consoleMode) {
            Console.WriteLine("consolemode started");
            // ...
        } else {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }
}
</code>```

答:
Check this source code out. All commented code – used to create a console in a Windows app. Uncommented – to hide the console in a console app. From here. (Previously <s>here</s>.) Project reg2run.

```<code>// Copyright (C) 2005-2015 Alexander Batishchev (abatishchev at gmail.com)

using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Reg2Run
{
    static class ManualConsole
    {
        #region DllImport
        /*
        [DllImport("kernel32.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall, SetLastError = true)]
        [return: MarshalAs(UnmanagedType.Bool)]
        private static extern bool AllocConsole();
        */

        [DllImport("kernel32.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall, SetLastError = true)]
        [return: MarshalAs(UnmanagedType.Bool)]
        private static extern bool CloseHandle(IntPtr handle);

        /*
        [DllImport("kernel32.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall, SetLastError = true)]
        private static extern IntPtr CreateFile([MarshalAs(UnmanagedType.LPStr)]string fileName, [MarshalAs(UnmanagedType.I4)]int desiredAccess, [MarshalAs(UnmanagedType.I4)]int shareMode, IntPtr securityAttributes, [MarshalAs(UnmanagedType.I4)]int creationDisposition, [MarshalAs(UnmanagedType.I4)]int flagsAndAttributes, IntPtr templateFile);
        */

        [DllImport("kernel32.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall, SetLastError = true)]
        [return: MarshalAs(UnmanagedType.Bool)]
        private static extern bool FreeConsole();

        [DllImport("kernel32.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall, SetLastError = true)]
        private static extern IntPtr GetStdHandle([MarshalAs(UnmanagedType.I4)]int nStdHandle);

        /*
        [DllImport("kernel32.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall, SetLastError = true)]
        [return: MarshalAs(UnmanagedType.Bool)]
        private static extern bool SetStdHandle(int nStdHandle, IntPtr handle);
        */
        #endregion

        #region Methods
        /*
        public static void Create()
        {
            var ptr = GetStdHandle(-11);
            if (!AllocConsole())
            {
                throw new Win32Exception("AllocConsole");
            }
            ptr = CreateFile("CONOUT$", 0x40000000, 2, IntPtr.Zero, 3, 0, IntPtr.Zero);
            if (!SetStdHandle(-11, ptr))
            {
                throw new Win32Exception("SetStdHandle");
            }
            var newOut = new StreamWriter(Console.OpenStandardOutput());
            newOut.AutoFlush = true;
            Console.SetOut(newOut);
            Console.SetError(newOut);
        }
        */

        public static void Hide()
        {
            var ptr = GetStdHandle(-11);
            if (!CloseHandle(ptr))
            {
                throw new Win32Exception();
            }
            ptr = IntPtr.Zero;
            if (!FreeConsole())
            {
                throw new Win32Exception();
            }
        }
        #endregion
    }
}
</code>```

OwnerDisplayName: Ase

Title: Show Console in Windows Application?

Body:
Is there a way to show the console in a Windows application?

I want to do something like this:

static class Program
{
    [STAThread]
    static void Main(string[] args) {
        bool consoleMode = Boolean.Parse(args[0]);

        if (consoleMode) {
            Console.WriteLine("consolemode started");
            // ...
        } else {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }
}

Body:
Check this source code out. All commented code – used to create a console in a Windows app. Uncommented – to hide the console in a console app. From here. (Previously <s>here</s>.) Project reg2run.

// Copyright (C) 2005-2015 Alexander Batishchev (abatishchev at gmail.com)

using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Reg2Run
{
    static class ManualConsole
    {
        #region DllImport
        /*
        [DllImport("kernel32.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall, SetLastError = true)]
        [return: MarshalAs(UnmanagedType.Bool)]
        private static extern bool AllocConsole();
        */

        [DllImport("kernel32.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall, SetLastError = true)]
        [return: MarshalAs(UnmanagedType.Bool)]
        private static extern bool CloseHandle(IntPtr handle);

        /*
        [DllImport("kernel32.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall, SetLastError = true)]
        private static extern IntPtr CreateFile([MarshalAs(UnmanagedType.LPStr)]string fileName, [MarshalAs(UnmanagedType.I4)]int desiredAccess, [MarshalAs(UnmanagedType.I4)]int shareMode, IntPtr securityAttributes, [MarshalAs(UnmanagedType.I4)]int creationDisposition, [MarshalAs(UnmanagedType.I4)]int flagsAndAttributes, IntPtr templateFile);
        */

        [DllImport("kernel32.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall, SetLastError = true)]
        [return: MarshalAs(UnmanagedType.Bool)]
        private static extern bool FreeConsole();

        [DllImport("kernel32.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall, SetLastError = true)]
        private static extern IntPtr GetStdHandle([MarshalAs(UnmanagedType.I4)]int nStdHandle);

        /*
        [DllImport("kernel32.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall, SetLastError = true)]
        [return: MarshalAs(UnmanagedType.Bool)]
        private static extern bool SetStdHandle(int nStdHandle, IntPtr handle);
        */
        #endregion

        #region Methods
        /*
        public static void Create()
        {
            var ptr = GetStdHandle(-11);
            if (!AllocConsole())
            {
                throw new Win32Exception("AllocConsole");
            }
            ptr = CreateFile("CONOUT$", 0x40000000, 2, IntPtr.Zero, 3, 0, IntPtr.Zero);
            if (!SetStdHandle(-11, ptr))
            {
                throw new Win32Exception("SetStdHandle");
            }
            var newOut = new StreamWriter(Console.OpenStandardOutput());
            newOut.AutoFlush = true;
            Console.SetOut(newOut);
            Console.SetError(newOut);
        }
        */

        public static void Hide()
        {
            var ptr = GetStdHandle(-11);
            if (!CloseHandle(ptr))
            {
                throw new Win32Exception();
            }
            ptr = IntPtr.Zero;
            if (!FreeConsole())
            {
                throw new Win32Exception();
            }
        }
        #endregion
    }
}

OwnerDisplayName: abatishchev