问:
Open modal dialog on event bus event
I've created a backend and am now trying to build a frontend, using it. I'm very new to Vue.js and am having a hard time telling it to do what I want; probably because of missing some basic concepts. Hopefully someone can point me in the right direction.

The App.vue groups following components: Header, main section (routed), footer and a modal login dialog.

The issue I'm trying to solve is to display the modal login dialog when clicking the Login button (which lives in the header component); currently, nothing besides the messages being logged happens.

For this I've created an event bus and am firing an event:

```<code>export default {
  name: 'SppdTeamTunerHeader',
  methods: {
    emitShowLoginDialogEvent () {
      EventBus.$emit('ShowLoginDialog', true)
    }
  }
}
</code>```

Emitting the event works as I can see in the Vue DevTools for Chrome.

Here's the complete code of App.vue:

```<code><template>
  <div id="app">
    <SppdTeamTunerHeader/>
    <router-view></router-view>
    <SppdTeamTunerFooter/>

    <LoginDialogModal
      v-show="isLoginDialogVisible"
    />
  </div>
</template>

<script>
import SppdTeamTunerHeader from '@/components/TheHeader'
import SppdTeamTunerFooter from '@/components/TheFooter'
import LoginDialogModal from '@/components/LoginDialogModal'
import { EventBus } from '@/common/EventBus'

export default {
  name: 'App',
  components: {
    SppdTeamTunerHeader,
    SppdTeamTunerFooter,
    LoginDialogModal
  },
  data: function () {
    return {
      isLoginDialogVisible: false
    }
  },
  mounted () {
    EventBus.$on('ShowLoginDialog', function (isVisible) {
      console.log('Setting ShowLoginDialog isVisible=' + isVisible + '. isLoginDialogVisible=' + this.isLoginDialogVisible)
      if (isVisible) {
        this.isLoginDialogVisible = true
      } else {
        this.isLoginDialogVisible = false
      }
      console.log('Finished setting isLoginDialogVisible=' + this.isLoginDialogVisible)
    })
  },
  destroyed () {
    EventBus.$off('ShowLoginDialog')
  }
}
</script>
</code>```

When checking the console, following is being printed when clicking the login button:

```<code>Setting ShowLoginDialog isVisible=true. isLoginDialogVisible=undefined
Finished setting isLoginDialogVisible=true
</code>```

The value logged for isLoginDialogVisible can't come from the variable defined in the data function as it prints undefined, whereas it has been defined as false (I guess that's my main problem).

I've read quite a few articles about the subject, e.g:

https://codingexplained.com/coding/front-end/vue-js/why-components-data-properties-must-be-functions

https://v2.vuejs.org/v2/guide/instance.html#Data-and-Methods

The modal dialog example I've based the implementation comes from here: https://alligator.io/vuejs/vue-modal-component/

答:
This is happening because you are not using an Arrow function. Instead of a plain function, use arrow function like this:

```<code>mounted () {
    // Note the use of arrow function.
    EventBus.$on('ShowLoginDialog', (isVisible) => {
      // .. All your code
    })
}
</code>```

If you use plain function function () {}, then this pointer is not accessible within inner function. Arrow function will lexically bind this pointer to mounted() function's this context. So use an arrow function i.e. () => {};

Note: If you insist on using plain old function syntax then use closure variable to keep track of this pointer:

```<code>mounted () {

    // Assign this pointer to some closure variable
    const vm = this;

    EventBus.$on('ShowLoginDialog', function (isVisible) {
      console.log('Setting ShowLoginDialog isVisible=' + isVisible + '. isLoginDialogVisible=' + vm.isLoginDialogVisible)
      if (isVisible) {
        vm.isLoginDialogVisible = true
      } else {
        vm.isLoginDialogVisible = false
      }
      console.log('Finished setting isLoginDialogVisible=' + vm.isLoginDialogVisible)
    })
}
</code>```

This has nothing to do with Vue.js. It is a typical JavaScript behavior.

Title: Open modal dialog on event bus event

Body:
I've created a backend and am now trying to build a frontend, using it. I'm very new to Vue.js and am having a hard time telling it to do what I want; probably because of missing some basic concepts. Hopefully someone can point me in the right direction.

The App.vue groups following components: Header, main section (routed), footer and a modal login dialog.

The issue I'm trying to solve is to display the modal login dialog when clicking the Login button (which lives in the header component); currently, nothing besides the messages being logged happens.

For this I've created an event bus and am firing an event:

export default {
  name: 'SppdTeamTunerHeader',
  methods: {
    emitShowLoginDialogEvent () {
      EventBus.$emit('ShowLoginDialog', true)
    }
  }
}

Emitting the event works as I can see in the Vue DevTools for Chrome.

Here's the complete code of App.vue:

<template>

    <SppdTeamTunerHeader/>
    <router-view></router-view>
    <SppdTeamTunerFooter/>

    <LoginDialogModal
      v-show="isLoginDialogVisible"
    />

</template>

When checking the console, following is being printed when clicking the login button:

Setting ShowLoginDialog isVisible=true. isLoginDialogVisible=undefined
Finished setting isLoginDialogVisible=true

The value logged for isLoginDialogVisible can't come from the variable defined in the data function as it prints undefined, whereas it has been defined as false (I guess that's my main problem).

I've read quite a few articles about the subject, e.g:

https://codingexplained.com/coding/front-end/vue-js/why-components-data-properties-must-be-functions

https://v2.vuejs.org/v2/guide/instance.html#Data-and-Methods

The modal dialog example I've based the implementation comes from here: https://alligator.io/vuejs/vue-modal-component/

Body:
This is happening because you are not using an Arrow function. Instead of a plain function, use arrow function like this:

mounted () {
    // Note the use of arrow function.
    EventBus.$on('ShowLoginDialog', (isVisible) => {
      // .. All your code
    })
}

If you use plain function function () {}, then this pointer is not accessible within inner function. Arrow function will lexically bind this pointer to mounted() function's this context. So use an arrow function i.e. () => {};

Note: If you insist on using plain old function syntax then use closure variable to keep track of this pointer:

mounted () {

    // Assign this pointer to some closure variable
    const vm = this;

    EventBus.$on('ShowLoginDialog', function (isVisible) {
      console.log('Setting ShowLoginDialog isVisible=' + isVisible + '. isLoginDialogVisible=' + vm.isLoginDialogVisible)
      if (isVisible) {
        vm.isLoginDialogVisible = true
      } else {
        vm.isLoginDialogVisible = false
      }
      console.log('Finished setting isLoginDialogVisible=' + vm.isLoginDialogVisible)
    })
}

This has nothing to do with Vue.js. It is a typical JavaScript behavior.


来源: stackexchange

问:
Google Sign In error 12500
I am trying to integrate Google Sign In into my app. I don't have a back-end server, I am just getting the details of the logged on Google Account to my app.

I first tried it by using Google Sign In Example but I got an error (No code changes made except for printing the stacktrace below). I just used the example SignInActivity as I don't have a back-end server.

```<code> Exception com.google.android.gms.common.api.ApiException: 12500:
 at com.google.android.gms.common.internal.zzb.zzz(Unknown Source)
 at com.google.android.gms.auth.api.signin.GoogleSignIn.getSignedInAccountFromIntent(Unknown Source)
 at com.ewise.android.api.MainActivity.onActivityResult(SignInActivity.java:89)     at android.app.Activity.dispatchActivityResult(Activity.java:7010)
 at android.app.ActivityThread.deliverResults(ActivityThread.java:4187)
 at android.app.ActivityThread.handleSendResult(ActivityThread.java:4234)
 at android.app.ActivityThread.-wrap20(ActivityThread.java)
 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1584)
 at android.os.Handler.dispatchMessage(Handler.java:102)
 at android.os.Looper.loop(Looper.java:154)
 at android.app.ActivityThread.main(ActivityThread.java:6316)
 at java.lang.reflect.Method.invoke(Native Method)
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)
</code>```

Code

```<code> public class SignInActivity extends AppCompatActivity implements
         View.OnClickListener {

     private static final String TAG = "SignInActivity";
     private static final int RC_SIGN_IN = 9001;

     private GoogleSignInClient mGoogleSignInClient;
     private TextView mStatusTextView;

     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_main);

         // Views
         mStatusTextView = findViewById(R.id.status);

         // Button listeners
         findViewById(R.id.sign_in_button).setOnClickListener(this);
         findViewById(R.id.sign_out_button).setOnClickListener(this);
         findViewById(R.id.disconnect_button).setOnClickListener(this);

         // [START configure_signin]
         // Configure sign-in to request the user's ID, email address, and basic
         // profile. ID and basic profile are included in DEFAULT_SIGN_IN.
         GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                 .requestEmail()
                 .build();
         // [END configure_signin]

         // [START build_client]
         // Build a GoogleSignInClient with the options specified by gso.
         mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
         // [END build_client]

         // [START customize_button]
         // Set the dimensions of the sign-in button.
         SignInButton signInButton = findViewById(R.id.sign_in_button);
         signInButton.setSize(SignInButton.SIZE_STANDARD);
         signInButton.setColorScheme(SignInButton.COLOR_LIGHT);
         // [END customize_button]
     }

     @Override
     public void onStart() {
         super.onStart();

         // [START on_start_sign_in]
         // Check for existing Google Sign In account, if the user is already signed in
         // the GoogleSignInAccount will be non-null.
         GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(this);
         updateUI(account);
         // [END on_start_sign_in]
     }

     // [START onActivityResult]
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);

         // Result returned from launching the Intent from GoogleSignInClient.getSignInIntent(...);
         if (requestCode == RC_SIGN_IN) {
             // The Task returned from this call is always completed, no need to attach
             // a listener.
             Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
             handleSignInResult(task);
         }
     }
     // [END onActivityResult]

     // [START handleSignInResult]
     private void handleSignInResult(Task<GoogleSignInAccount> completedTask) {
         try {
             GoogleSignInAccount account = completedTask.getResult(ApiException.class);

             // Signed in successfully, show authenticated UI.
             updateUI(account);
         } catch (ApiException e) {
             // The ApiException status code indicates the detailed failure reason.
             // Please refer to the GoogleSignInStatusCodes class reference for more information.
             Log.w(TAG, "signInResult:failed code=" + e.getStatusCode());
             e.printStackTrace();
             updateUI(null);
         }
     }
     // [END handleSignInResult]

     // [START signIn]
     private void signIn() {
         Intent signInIntent = mGoogleSignInClient.getSignInIntent();
         startActivityForResult(signInIntent, RC_SIGN_IN);
     }
     // [END signIn]

     // [START signOut]
     private void signOut() {
         mGoogleSignInClient.signOut()
                 .addOnCompleteListener(this, new OnCompleteListener<Void>() {
                     @Override
                     public void onComplete(@NonNull Task<Void> task) {
                         // [START_EXCLUDE]
                         updateUI(null);
                         // [END_EXCLUDE]
                     }
                 });
     }
     // [END signOut]

     // [START revokeAccess]
     private void revokeAccess() {
         mGoogleSignInClient.revokeAccess()
                 .addOnCompleteListener(this, new OnCompleteListener<Void>() {
                     @Override
                     public void onComplete(@NonNull Task<Void> task) {
                         // [START_EXCLUDE]
                         updateUI(null);
                         // [END_EXCLUDE]
                     }
                 });
     }
     // [END revokeAccess]

     private void updateUI(@Nullable GoogleSignInAccount account) {
         if (account != null) {
             mStatusTextView.setText(getString(R.string.signed_in_fmt, account.getDisplayName()));

             findViewById(R.id.sign_in_button).setVisibility(View.GONE);
             findViewById(R.id.sign_out_and_disconnect).setVisibility(View.VISIBLE);
         } else {
             mStatusTextView.setText(R.string.signed_out);

             findViewById(R.id.sign_in_button).setVisibility(View.VISIBLE);
             findViewById(R.id.sign_out_and_disconnect).setVisibility(View.GONE);
         }
     }

     @Override
     public void onClick(View v) {
         switch (v.getId()) {
             case R.id.sign_in_button:
                 signIn();
                 break;
             case R.id.sign_out_button:
                 signOut();
                 break;
             case R.id.disconnect_button:
                 revokeAccess();
                 break;
         }
     }
  }
</code>```

From what I read, the issue could be caused by SHA1 Generation.

I followed the complete guide but apparently it's not working.

I copied the SHA1 from gradle signingReport

```<code>Variant: debug
Config: debug
Store: /Users/user/.android/debug.keystore
Alias: AndroidDebugKey
MD5: A3:16:3F:43:75:FE:07:62:6D:8D:CC:DD:21:9F:FA:1A
SHA1: 7B:21:26:7F:D8:18:BB:0E:36:1C:82:DD:B7:28:5F:C1:2F:5C:E4:EA
Valid until: Saturday, August 31, 2047
----------
Variant: release
Config: none
----------
Variant: debugAndroidTest
Config: debug
Store: /Users/user/.android/debug.keystore
Alias: AndroidDebugKey
MD5: A3:16:3F:43:75:FE:07:62:6D:8D:CC:DD:21:9F:FA:1A
SHA1: 7B:21:26:7F:D8:18:BB:0E:36:1C:82:DD:B7:28:5F:C1:2F:5C:E4:EA
Valid until: Saturday, August 31, 2047
----------
Variant: debugUnitTest
Config: debug
Store: /Users/user/.android/debug.keystore
Alias: AndroidDebugKey
MD5: A3:16:3F:43:75:FE:07:62:6D:8D:CC:DD:21:9F:FA:1A
SHA1: 7B:21:26:7F:D8:18:BB:0E:36:1C:82:DD:B7:28:5F:C1:2F:5C:E4:EA
Valid until: Saturday, August 31, 2047
</code>```

what could be the possible cause of this?

Thanks

P.S. Could this be a possible cause?

```<code>Google Play services out of date.  Requires 11720000 but found 10932470
</code>```

答: When your app authenticates with a backend server or accesses Google APIs from your backend server, then you must pass the OAuth 2.0 client ID that was created for your server to the requestIdToken method when you construct the GoogleSignInOptions object, for accessing the user's basic profile information. Also, don't forget to submit the support email in the OAuth consent screen found in the Credentials page in the API Console.</p>

ContentLicense: CC BY-SA 3.0

Title: Google Sign In error 12500

Body:
I am trying to integrate Google Sign In into my app. I don't have a back-end server, I am just getting the details of the logged on Google Account to my app.

I first tried it by using Google Sign In Example but I got an error (No code changes made except for printing the stacktrace below). I just used the example SignInActivity as I don't have a back-end server.

 Exception com.google.android.gms.common.api.ApiException: 12500:
 at com.google.android.gms.common.internal.zzb.zzz(Unknown Source)
 at com.google.android.gms.auth.api.signin.GoogleSignIn.getSignedInAccountFromIntent(Unknown Source)
 at com.ewise.android.api.MainActivity.onActivityResult(SignInActivity.java:89)     at android.app.Activity.dispatchActivityResult(Activity.java:7010)
 at android.app.ActivityThread.deliverResults(ActivityThread.java:4187)
 at android.app.ActivityThread.handleSendResult(ActivityThread.java:4234)
 at android.app.ActivityThread.-wrap20(ActivityThread.java)
 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1584)
 at android.os.Handler.dispatchMessage(Handler.java:102)
 at android.os.Looper.loop(Looper.java:154)
 at android.app.ActivityThread.main(ActivityThread.java:6316)
 at java.lang.reflect.Method.invoke(Native Method)
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)

Code

 public class SignInActivity extends AppCompatActivity implements
         View.OnClickListener {

     private static final String TAG = "SignInActivity";
     private static final int RC_SIGN_IN = 9001;

     private GoogleSignInClient mGoogleSignInClient;
     private TextView mStatusTextView;

     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_main);

         // Views
         mStatusTextView = findViewById(R.id.status);

         // Button listeners
         findViewById(R.id.sign_in_button).setOnClickListener(this);
         findViewById(R.id.sign_out_button).setOnClickListener(this);
         findViewById(R.id.disconnect_button).setOnClickListener(this);

         // [START configure_signin]
         // Configure sign-in to request the user's ID, email address, and basic
         // profile. ID and basic profile are included in DEFAULT_SIGN_IN.
         GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                 .requestEmail()
                 .build();
         // [END configure_signin]

         // [START build_client]
         // Build a GoogleSignInClient with the options specified by gso.
         mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
         // [END build_client]

         // [START customize_button]
         // Set the dimensions of the sign-in button.
         SignInButton signInButton = findViewById(R.id.sign_in_button);
         signInButton.setSize(SignInButton.SIZE_STANDARD);
         signInButton.setColorScheme(SignInButton.COLOR_LIGHT);
         // [END customize_button]
     }

     @Override
     public void onStart() {
         super.onStart();

         // [START on_start_sign_in]
         // Check for existing Google Sign In account, if the user is already signed in
         // the GoogleSignInAccount will be non-null.
         GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(this);
         updateUI(account);
         // [END on_start_sign_in]
     }

     // [START onActivityResult]
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);

         // Result returned from launching the Intent from GoogleSignInClient.getSignInIntent(...);
         if (requestCode == RC_SIGN_IN) {
             // The Task returned from this call is always completed, no need to attach
             // a listener.
             Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
             handleSignInResult(task);
         }
     }
     // [END onActivityResult]

     // [START handleSignInResult]
     private void handleSignInResult(Task<GoogleSignInAccount> completedTask) {
         try {
             GoogleSignInAccount account = completedTask.getResult(ApiException.class);

             // Signed in successfully, show authenticated UI.
             updateUI(account);
         } catch (ApiException e) {
             // The ApiException status code indicates the detailed failure reason.
             // Please refer to the GoogleSignInStatusCodes class reference for more information.
             Log.w(TAG, "signInResult:failed code=" + e.getStatusCode());
             e.printStackTrace();
             updateUI(null);
         }
     }
     // [END handleSignInResult]

     // [START signIn]
     private void signIn() {
         Intent signInIntent = mGoogleSignInClient.getSignInIntent();
         startActivityForResult(signInIntent, RC_SIGN_IN);
     }
     // [END signIn]

     // [START signOut]
     private void signOut() {
         mGoogleSignInClient.signOut()
                 .addOnCompleteListener(this, new OnCompleteListener<Void>() {
                     @Override
                     public void onComplete(@NonNull Task<Void> task) {
                         // [START_EXCLUDE]
                         updateUI(null);
                         // [END_EXCLUDE]
                     }
                 });
     }
     // [END signOut]

     // [START revokeAccess]
     private void revokeAccess() {
         mGoogleSignInClient.revokeAccess()
                 .addOnCompleteListener(this, new OnCompleteListener<Void>() {
                     @Override
                     public void onComplete(@NonNull Task<Void> task) {
                         // [START_EXCLUDE]
                         updateUI(null);
                         // [END_EXCLUDE]
                     }
                 });
     }
     // [END revokeAccess]

     private void updateUI(@Nullable GoogleSignInAccount account) {
         if (account != null) {
             mStatusTextView.setText(getString(R.string.signed_in_fmt, account.getDisplayName()));

             findViewById(R.id.sign_in_button).setVisibility(View.GONE);
             findViewById(R.id.sign_out_and_disconnect).setVisibility(View.VISIBLE);
         } else {
             mStatusTextView.setText(R.string.signed_out);

             findViewById(R.id.sign_in_button).setVisibility(View.VISIBLE);
             findViewById(R.id.sign_out_and_disconnect).setVisibility(View.GONE);
         }
     }

     @Override
     public void onClick(View v) {
         switch (v.getId()) {
             case R.id.sign_in_button:
                 signIn();
                 break;
             case R.id.sign_out_button:
                 signOut();
                 break;
             case R.id.disconnect_button:
                 revokeAccess();
                 break;
         }
     }
  }

From what I read, the issue could be caused by SHA1 Generation.

I followed the complete guide but apparently it's not working.

I copied the SHA1 from gradle signingReport

Variant: debug
Config: debug
Store: /Users/user/.android/debug.keystore
Alias: AndroidDebugKey
MD5: A3:16:3F:43:75:FE:07:62:6D:8D:CC:DD:21:9F:FA:1A
SHA1: 7B:21:26:7F:D8:18:BB:0E:36:1C:82:DD:B7:28:5F:C1:2F:5C:E4:EA
Valid until: Saturday, August 31, 2047
----------
Variant: release
Config: none
----------
Variant: debugAndroidTest
Config: debug
Store: /Users/user/.android/debug.keystore
Alias: AndroidDebugKey
MD5: A3:16:3F:43:75:FE:07:62:6D:8D:CC:DD:21:9F:FA:1A
SHA1: 7B:21:26:7F:D8:18:BB:0E:36:1C:82:DD:B7:28:5F:C1:2F:5C:E4:EA
Valid until: Saturday, August 31, 2047
----------
Variant: debugUnitTest
Config: debug
Store: /Users/user/.android/debug.keystore
Alias: AndroidDebugKey
MD5: A3:16:3F:43:75:FE:07:62:6D:8D:CC:DD:21:9F:FA:1A
SHA1: 7B:21:26:7F:D8:18:BB:0E:36:1C:82:DD:B7:28:5F:C1:2F:5C:E4:EA
Valid until: Saturday, August 31, 2047

what could be the possible cause of this?

Thanks

P.S. Could this be a possible cause?

Google Play services out of date.  Requires 11720000 but found 10932470

ContentLicense: CC BY-SA 4.0


问:
C++ error unexplained: error: expected initializer before '&' token
i know there's a few other posts like this, but i've been on this single error for over an hour now and can't figure it out. here's the code that's giving trouble

```<code>istream& operator>>(istream& in, UndirectedGraph& g)
{
    int numVerticies;
    in >> numVerticies;
    g = UndirectedGraph(numVerticies);

    for(int i = 0; i < numVerticies; i++)
    {
        int temp;
        in >> temp;
        if(temp != i)
        {
            g.linkedAdjacencyList[i]->value = temp;
        }
    }

    int edges;
    in >> edges;
    g.edges = edges;
    for(int i = 0; i < edges; i++)
    {
        int first;
        int second;
        in >> first >> second;
        addEdge(first, second);
    }
    return in;
}

ostream& operator<<(ostream& out, UndirectedGraph& g)
{
    out << g.numVerticies << endl;

    for(int i = 0; i < g.numVerticies; i++)
    {
        out << g.linkedAdjacencyList[i] << " ";
    }
    out << endl;

    out << g.edges << endl;

    for(int i = 0; i < g.numVerticies; i++)
    {
        out << linkedAdjacencyList[i]->value;
        Node* whereto;
        whereto = linkedAdjacencyList[i]->adj;
        while(whereto->adj != NULL)
        {
            out << " " << whereto->value;
            whereto->adj = whereto->adj->adj;
        }
    }
    return out;
}

int main()
{

    ifstream inFile;
    inFile.open("hw8.in");

    UndirectedGraph graph;
    inFile >> graph;
</code>```

...

here, the errors are on lines 1 and 28, with the overloading of istream and ostream.

Thanks for your help!

答:
```<code>void UndirectedGraph::istream& operator>>(istream& in, UndirectedGraph g)
</code>```

There are two return types here: void and UndirectedGraph::istream&. One needs to go. Same goes for the other method.

Furthermore, I assume that you mean std::istream, not UndirectedGraph::istream, right?

And finally, for this code to work you need to pass the argument g by reference, otherwise you won’t be able to change it.

Which leaves us with:

```<code>std::istream& operator>>(std::istream& in, UndirectedGraph& g)
</code>```

Body:
i know there's a few other posts like this, but i've been on this single error for over an hour now and can't figure it out. here's the code that's giving trouble

istream& operator>>(istream& in, UndirectedGraph& g)
{
    int numVerticies;
    in >> numVerticies;
    g = UndirectedGraph(numVerticies);

    for(int i = 0; i < numVerticies; i++)
    {
        int temp;
        in >> temp;
        if(temp != i)
        {
            g.linkedAdjacencyList[i]->value = temp;
        }
    }

    int edges;
    in >> edges;
    g.edges = edges;
    for(int i = 0; i < edges; i++)
    {
        int first;
        int second;
        in >> first >> second;
        addEdge(first, second);
    }
    return in;
}

ostream& operator<<(ostream& out, UndirectedGraph& g)
{
    out << g.numVerticies << endl;

    for(int i = 0; i < g.numVerticies; i++)
    {
        out << g.linkedAdjacencyList[i] << " ";
    }
    out << endl;

    out << g.edges << endl;

    for(int i = 0; i < g.numVerticies; i++)
    {
        out << linkedAdjacencyList[i]->value;
        Node* whereto;
        whereto = linkedAdjacencyList[i]->adj;
        while(whereto->adj != NULL)
        {
            out << " " << whereto->value;
            whereto->adj = whereto->adj->adj;
        }
    }
    return out;
}

int main()
{

    ifstream inFile;
    inFile.open("hw8.in");

    UndirectedGraph graph;
    inFile >> graph;

...

here, the errors are on lines 1 and 28, with the overloading of istream and ostream.

Thanks for your help!

Body:
void UndirectedGraph::istream& operator>>(istream& in, UndirectedGraph g)

There are two return types here: void and UndirectedGraph::istream&. One needs to go. Same goes for the other method.

Furthermore, I assume that you mean std::istream, not UndirectedGraph::istream, right?

And finally, for this code to work you need to pass the argument g by reference, otherwise you won’t be able to change it.

Which leaves us with:

std::istream& operator>>(std::istream& in, UndirectedGraph& g)


问:
Cell Hyperlink in PHP using HTML
I searched for some answers, but nothing worked. I have an HTML table in my index.php and everything works fine. I now want to add a new  and want it to be a clickable link.
This is the table now without the link:

```<code><?php
    $file1 = "c:/tablename.txt";
    $file2 = "c:/tablestatus.txt";
    $file3 = "c:/tablelocation.txt";
    $file4 = "c:/userlist.csv";
    if(file_exists($file1) && file_exists($file2))
    {
        $line1= file($file1, FILE_IGNORE_NEW_LINES);
         $line2 = file($file2, FILE_IGNORE_NEW_LINES);
         $line3raw = file($file3, FILE_IGNORE_NEW_LINES);
         $line3 = array_map("utf8_encode", $line3raw );
         $line4 = file($file4, FILE_IGNORE_NEW_LINES);

         $html = '<table align="center">';
             $html .= '<tr><th width="460px"></th><th width="140px"></th><th width="340px"></th></tr>';
                for($i=0;$i<count($line1);$i++){
                    $html .= '<tr class="'.$line2[$i].'">';
                        $html .= '<td font-size:"90pt">'.$line1[$i].'</td>';
                        $html .= '<td font-size:"90pt">'.$line2[$i].'</td>';
                        $html .= '<td font-size:"90pt">'.$line3[$i].'</td>';
                        $html .= '</tr>';
                    }
                    $html .= '</table>';
                    echo $html;
                }else
                {
                    echo "Files missing.";
                }
?>
</code>```

I found out how to make a cell as a link like this:

```<code><td><a href="https://mypage.com" target="_blank">title</a>;</td>
</code>```

That didn't work.
This works:

```<code>$html .= '<a href="https://mypage.com\" target="_blank">'.$line1[$i].'</a>';
</code>```

But obviously, it's not part of the table anymore. How can I put this hyperlink into the table?

If you need more information or I missed something, just tell. I hope we can solve this issue.

答:
Here, it is:</p>

```<code> <?php
        $file1 = "c:/tablename.txt";
        $file2 = "c:/tablestatus.txt";
        $file3 = "c:/tablelocation.txt";
        $file4 = "c:/userlist.csv";
        if(file_exists($file1) && file_exists($file2))
        {
            $line1= file($file1, FILE_IGNORE_NEW_LINES);
             $line2 = file($file2, FILE_IGNORE_NEW_LINES);
             $line3raw = file($file3, FILE_IGNORE_NEW_LINES);
             $line3 = array_map("utf8_encode", $line3raw );
             $line4 = file($file4, FILE_IGNORE_NEW_LINES);

             $html = '<table align="center">';
                 $html .= '<tr><th width="460px"></th><th width="140px"></th><th width="340px"></th></tr>';
                    for($i=0;$i<count($line1);$i++){
                        $html .= '<tr class="'.$line2[$i].'">';
                            $html .= '<td font-size:"90pt"><a href="https://mypage.com\" target="_blank">'.$line1[$i].'</a></td>';
                            $html .= '<td font-size:"90pt">'.$line2[$i].'</td>';
                            $html .= '<td font-size:"90pt">'.$line3[$i].'</td>';
                            $html .= '</tr>';
                        }
                        $html .= '</table>';
                        echo $html;
                    }else
                    {
                        echo "Files missing.";
                    }
    ?>
</code>```

Title: Cell Hyperlink in PHP using HTML

Body:
I searched for some answers, but nothing worked. I have an HTML table in my index.php and everything works fine. I now want to add a new  and want it to be a clickable link.
This is the table now without the link:

<?php
    $file1 = "c:/tablename.txt";
    $file2 = "c:/tablestatus.txt";
    $file3 = "c:/tablelocation.txt";
    $file4 = "c:/userlist.csv";
    if(file_exists($file1) && file_exists($file2))
    {
        $line1= file($file1, FILE_IGNORE_NEW_LINES);
         $line2 = file($file2, FILE_IGNORE_NEW_LINES);
         $line3raw = file($file3, FILE_IGNORE_NEW_LINES);
         $line3 = array_map("utf8_encode", $line3raw );
         $line4 = file($file4, FILE_IGNORE_NEW_LINES);

         $html = '
';
             $html .= '

';
                for($i=0;$i<count($line1);$i++){
                    $html .= '
';
                        $html .= ''.$line1[$i].'	';
                        $html .= ''.$line2[$i].'	';
                        $html .= ''.$line3[$i].'	';
                        $html .= '
';
                    }
                    $html .= '
';
                    echo $html;
                }else
                {
                    echo "Files missing.";
                }
?>

I found out how to make a cell as a link like this:

title;

That didn't work.
This works:

$html .= ''.$line1[$i].'';

But obviously, it's not part of the table anymore. How can I put this hyperlink into the table?

If you need more information or I missed something, just tell. I hope we can solve this issue.

Body:
Here, it is:

 <?php
        $file1 = "c:/tablename.txt";
        $file2 = "c:/tablestatus.txt";
        $file3 = "c:/tablelocation.txt";
        $file4 = "c:/userlist.csv";
        if(file_exists($file1) && file_exists($file2))
        {
            $line1= file($file1, FILE_IGNORE_NEW_LINES);
             $line2 = file($file2, FILE_IGNORE_NEW_LINES);
             $line3raw = file($file3, FILE_IGNORE_NEW_LINES);
             $line3 = array_map("utf8_encode", $line3raw );
             $line4 = file($file4, FILE_IGNORE_NEW_LINES);

             $html = '<table align="center">';
                 $html .= '<tr><th width="460px"></th><th width="140px"></th><th width="340px"></th></tr>';
                    for($i=0;$i<count($line1);$i++){
                        $html .= '<tr class="'.$line2[$i].'">';
                            $html .= '<td font-size:"90pt"><a href="https://mypage.com\" target="_blank">'.$line1[$i].'</a></td>';
                            $html .= '<td font-size:"90pt">'.$line2[$i].'</td>';
                            $html .= '<td font-size:"90pt">'.$line3[$i].'</td>';
                            $html .= '</tr>';
                        }
                        $html .= '</table>';
                        echo $html;
                    }else
                    {
                        echo "Files missing.";
                    }
    ?>


问:
Cross-Origin request warning for google fonts
I am using Google Webfonts on my website. In the console on Chrome I get the following warning:

Blink is considering rejecting non spec-compliant cross-origin web
  font requests:
  http://fonts.gstatic.com/s/raleway/v8/0dTEPzkLWceF7z0koJaX1A.woff2.
  Please use Access-Control-Allow-Origin to make these requests
  spec-compliant.

Upon inspecting the request headers there appears to not be any Access-Control headers present:

```<code>Remote Address:109.231.231.219:80
Request URL:http://fonts.gstatic.com/s/raleway/v8/0dTEPzkLWceF7z0koJaX1A.woff2
Request Method:GET
Status Code:304 Not Modified
Request Headersview source
Accept:*/*
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8,en-GB;q=0.6
Cache-Control:max-age=0
Connection:keep-alive
DNT:1
Host:fonts.gstatic.com
If-Modified-Since:Mon, 04 Aug 2014 17:04:46 GMT
Origin:http://samarkanddesign.com
Referer:http://samarkanddesign.com/
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36
Response Headersview source
Age:369865
Date:Fri, 08 Aug 2014 02:01:39 GMT
Expires:Sat, 08 Aug 2015 02:01:39 GMT
Server:GFE/2.0
</code>```

What can I do to solve this? Can anyone explain what's going on as I don't fully understand CORS. The page when viewed in firefox and IE seems to block the font request.

One thing to note is that I'm viewing the site on my company network. It might have a strange setting or proxy that strips out Access-Control headers. Can anyone one a normal connection verify the headers are usually present? The page is at http://samarkanddesign.com

答:
If you have this issue just in one browser:

I had a Chrome Browser Extension running which caused this problem. In my case it was "Alexa page rank" - but test out all your extensions by disabling one after the other.

Body:
I am using Google Webfonts on my website. In the console on Chrome I get the following warning:

Blink is considering rejecting non spec-compliant cross-origin web
  font requests:
  http://fonts.gstatic.com/s/raleway/v8/0dTEPzkLWceF7z0koJaX1A.woff2.
  Please use Access-Control-Allow-Origin to make these requests
  spec-compliant.

Upon inspecting the request headers there appears to not be any Access-Control headers present:

Remote Address:109.231.231.219:80
Request URL:http://fonts.gstatic.com/s/raleway/v8/0dTEPzkLWceF7z0koJaX1A.woff2
Request Method:GET
Status Code:304 Not Modified
Request Headersview source
Accept:*/*
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8,en-GB;q=0.6
Cache-Control:max-age=0
Connection:keep-alive
DNT:1
Host:fonts.gstatic.com
If-Modified-Since:Mon, 04 Aug 2014 17:04:46 GMT
Origin:http://samarkanddesign.com
Referer:http://samarkanddesign.com/
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36
Response Headersview source
Age:369865
Date:Fri, 08 Aug 2014 02:01:39 GMT
Expires:Sat, 08 Aug 2015 02:01:39 GMT
Server:GFE/2.0

What can I do to solve this? Can anyone explain what's going on as I don't fully understand CORS. The page when viewed in firefox and IE seems to block the font request.

One thing to note is that I'm viewing the site on my company network. It might have a strange setting or proxy that strips out Access-Control headers. Can anyone one a normal connection verify the headers are usually present? The page is at http://samarkanddesign.com


问:
parse parenthesized numbers to negative numbers
How can i Parse parenthesized numbers in a list of strings  to negative numbers (or strings with negative sign).

example

```<code>input
list1= ['abcd','(1,234)','Level-2 (2):','(31)%', 'others','(3,102.2)%']

output
['abcd',-1234,'Level-2 (2):','-31%', 'others','-3102.2%']
</code>```

strings only with numbers inside parenthesis or numbers with comma/dot inside parenthesis followed by a percentage(%) sign, should be parsed . other strings such as 'Level-2 (2):' should not be parsed.

I have tried

```<code>translator = str.maketrans(dict.fromkeys('(),'))
['-'+(x.translate(translator)) for x in list1]
</code>```

but the output is (every element has a - appended)

```<code>['-abcd', '-1234', '-Level-2 2:', '-31%', '-others', '-3102.2%']
</code>```

Body:
How can i Parse parenthesized numbers in a list of strings  to negative numbers (or strings with negative sign).

example

input
list1= ['abcd','(1,234)','Level-2 (2):','(31)%', 'others','(3,102.2)%']

output
['abcd',-1234,'Level-2 (2):','-31%', 'others','-3102.2%']

strings only with numbers inside parenthesis or numbers with comma/dot inside parenthesis followed by a percentage(%) sign, should be parsed . other strings such as 'Level-2 (2):' should not be parsed.

I have tried

translator = str.maketrans(dict.fromkeys('(),'))
['-'+(x.translate(translator)) for x in list1]

but the output is (every element has a - appended)

['-abcd', '-1234', '-Level-2 2:', '-31%', '-others', '-3102.2%']

Body:
You can try using re.sub, eg:

import re

list1 = ['abcd','(1,234)','Level-2 (2):','(31)%', 'others','(3,102.2)%']
res = [re.sub(r'^\(([\d+.,]+)\)(%?)$', r'-\1\2', el) for el in list1]
# ['abcd', '-1,234', 'Level-2 (2):', '-31%', 'others', '-3,102.2%']


问:
R: Converting cartesian coordinates to polar coordinates, and then calculating distance from origin
I've been looking for a solution to convert cartesian coordinates (lat, long) that I have to polar coordinates in order to facilitate a simulation that I want to run, but I haven't found any questions or answers here for doing this in R. There are a number of options, including the built in function cart2pol in Matlab, but all of my data are in R and I'd like to continue getting comfortable working in this framework.

Question:

I have lat/long coordinates from tagging data, and I want to convert these to polar coordinates (meaning jump size and angle: http://en.wikipedia.org/wiki/Polar_coordinate_system) so that I can then shuffle or bootstrap them (haven't decided which) about 1,000 times, and calculate the straight-line distance of each simulated track from the starting point. I have a true track, and I'm interested in determining if this animal is exhibiting site affinity by simulating 1,000 random tracks with the same jump sizes and turning angles, but in completely different orders and combinations. So I need 1,000 straight-line distances from the origin to create a distribution of distances and then compare this to my true data set's straight-line distance.

I'm comfortable doing the bootstrapping, but I'm stuck at the very first step, which is converting my cartesian lat/long coordinates to polar coordinates (jump size and turning angle). I know there are built in functions to do this in other programs such as Matlab, but I can't find any way to do it in R. I could do it manually by hand in a for-loop, but if there's a package out there or any easier way to do it, I'd much prefer that.

Ideally I'd like to convert the data to polar coordinates, run the simulation, and then for each random track output an end point as cartesian coordinates, lat/long, so I can then calculate the straight-line distance traveled.

I didn't post any sample data, as it would just be a two-column data frame of lat and long coordinates.

Thanks for any help you can provide!  If there's an easy explanation somewhere on this site or others that I missed, please point me in that direction! I couldn't find anything.

Cheers

答:
I think this code I wrote converts to polar coordinates:</p>

```<code># example data
x<-runif(30)
y<-runif(30)
# center example around 0
x<-x-mean(x)
y<-y-mean(y)

# function to convert to polar coordinates
topolar<-function(x,y){

    # calculate angles
    alphas<-atan(y/x)

    # correct angles per quadrant
    quad2<-which(x<0&y>0)
    quad3<-which(x<0&y<0)
    quad4<-which(x>0&y<0)
    alphas[quad2]<-alphas[quad2]+pi
    alphas[quad3]<-alphas[quad3]+pi
    alphas[quad4]<-alphas[quad4]+2*pi

    # calculate distances to 0,0
    r<-sqrt(x^2+y^2)

    # create output
    polar<-data.frame(alphas=alphas,r=r)

}

# call function
polar_out<-topolar(x,y)
# get out angles
the_angles<-polar_out$alphas
</code>```

Body:
I think this code I wrote converts to polar coordinates:

# example data
x<-runif(30)
y<-runif(30)
# center example around 0
x<-x-mean(x)
y<-y-mean(y)

# function to convert to polar coordinates
topolar<-function(x,y){

    # calculate angles
    alphas<-atan(y/x)

    # correct angles per quadrant
    quad2<-which(x<0&y>0)
    quad3<-which(x<0&y<0)
    quad4<-which(x>0&y<0)
    alphas[quad2]<-alphas[quad2]+pi
    alphas[quad3]<-alphas[quad3]+pi
    alphas[quad4]<-alphas[quad4]+2*pi

    # calculate distances to 0,0
    r<-sqrt(x^2+y^2)

    # create output
    polar<-data.frame(alphas=alphas,r=r)

}

# call function
polar_out<-topolar(x,y)
# get out angles
the_angles<-polar_out$alphas


问:
How to render value of a radio button in React Native?
I am pretty new in React Native and mobile app development as a whole.
I am trying to render the value I have assigned to different radio buttons under a radio button group, however, I seem to be getting something wrong. Here is the code below:

RadioButtons.js

```<code>    import React from 'react';
    import { FontAwesome, Ionicons, MaterialCommunityIcons,
    MaterialIcons, Feather } from '@expo/vector-icons';

    export const DeliveryModes = [{
      label: <Ionicons name='ios-walk' size={20} />,
      value: '30'
    }, {
      label: <MaterialCommunityIcons name='bike' size={20} />,
      value: '50'
    }, {
      label: <MaterialCommunityIcons name='motorbike' size={20} />,
      value: '190'
    }, {
      label: <MaterialCommunityIcons name='car-sports' size={20} />,
      value: '50'
    }, {
      label: <MaterialCommunityIcons name='car-pickup' size={20} />,
      value: '50'
    }, {
      label: <MaterialCommunityIcons name='car-estate' size={20} />,
      value: '50'
    }, {
      label: <MaterialCommunityIcons name='bus-side' size={20} />,
      value: '50'
    }, {
      label: <Feather name='truck' size={20} />,
      value: '50'
    },
    ];
</code>```

Index.js

```<code>    import React, { Component } from 'react';
    import { View, StyleSheet, Text, TouchableHighlight, } from 'react-native';
    import RadioGroup from 'react-native-custom-radio-group';
    import Tabs from './tabs';
    import { DeliveryModes } from './deliveryMode.js';

    class Details extends Component {
      constructor(props) {
        super(props);
        // Initialize State
        this.state = {
          // First tab is active by default
          activeTab: 0,
        };
      }

      render({ children } = this.props) {
        const {
         onBook
       } = this.props;
        return (
          <View style={styles.Container}>
          <Tabs>
            {/* First tab */}
            <View title="Delivery Mode" style={styles.content}>
            {/* Showtimes */}
             <View>
               {/* Day */}
               <Text style={styles.sectionHeader}>Kindly select desired mode of delivery.</Text>
               <RadioGroup
               radioGroupList={DeliveryModes}
               containerStyle={{ flexWrap: 'wrap', padding: 5, }}
               buttonContainerStyle={{ borderWidth: 0, margin: 5, borderRadius: 40, width: 90, }}
               onChange={(value) => this.deliveryMode(value)}
               ref={e => this.RadioGroup = e}
               />
               </View>
            </View>
            {/* Second tab */}
            <View title="Number & Weight" style={styles.content}>
              <Text style={styles.header}>
                Truly Native
              </Text>
              <Text style={styles.text}>
                Components you define will end up rendering as native platform widgets
              </Text>
            </View>
            {/* Third tab */}
            <View title="Parcel Category" style={styles.content}>
              <Text style={styles.header}>
                Ease of Learning
              </Text>
              <Text style={styles.text}>
                It’s much easier to read and write comparing to native platform’s code
              </Text>
            </View>

            </Tabs>
            {/* Footer */}
            <View style={styles.footer}>
              <TouchableHighlight
                underlayColor="#9575CD"
                style={styles.buttonContainer}
                onPress={onBook}
              >
                <Text style={styles.button}>Next</Text>
              </TouchableHighlight>
              <Text>{value}</Text>
            </View>
          </View>
        );
      }
    }

    const styles = StyleSheet.create({
      Container: {
        backgroundColor: '#FFF',
        height: 250,
        width: '100%',
        position: 'absolute',
        bottom: 0,
        shadowColor: '#000',
        shadowOffset: { x: 0, y: 0 },
        shadowOpacity: 0.2,
        elevation: 2,
        zIndex: 9999,
        flex: 1,
      },
      // Tab content container
    content: {
      flex: 1,
      justifyContent: 'center',
      alignItems: 'center',
      backgroundColor: '#F8F8F8',
    },
    // Content header
    header: {
      margin: 10,                         // Add margin
      color: '#34495E',                   // White color
      fontFamily: 'Avenir',               // Change font family
      fontSize: 26,                       // Bigger font size
    },
    // Content text
    text: {
      marginHorizontal: 20,               // Add horizontal margin
      color: '#34495E',                    // Semi-transparent text
      textAlign: 'center',
      fontFamily: 'Avenir',
      fontSize: 18,
    },
    sectionHeader: {
      paddingTop: 10,
      paddingLeft: 10,
      color: '#34495E',
      fontFamily: 'Avenir',
      fontSize: 15,
    },
      footer: {
        paddingHorizontal: 110,
        paddingVertical: 10,
        backgroundColor: '#FFF'
      },
      buttonContainer: {
        backgroundColor: '#2FCC71',
        borderRadius: 100,
        paddingVertical: 15,
        paddingHorizontal: 15,
        alignItems: 'center',
      },
      button: {
        color: '#FFFFFF',
        fontSize: 16,
        fontFamily: 'Avenir',
        fontWeight: 'bold',
      },
    });

    export default Details;
</code>```

I want to be able to pass the value of each radio button into a Text tag below the next button. I have kept the code plain and clean for a better usage of the onChange property.

答:
You have not added your "value" in setState
First add value in setState

```<code>this.state = {
      // First tab is active by default
      activeTab: 0,
      value:''
    };
</code>```

change value to this.state.value

```<code><Text>{this.state.value}</Text>
</code>```

Call setState method on onChange

```<code>onChange={(value) => this.setState({value:value})}
</code>```

Hope, this will help you cheers!

Body:
I am pretty new in React Native and mobile app development as a whole.
I am trying to render the value I have assigned to different radio buttons under a radio button group, however, I seem to be getting something wrong. Here is the code below:

RadioButtons.js

    import React from 'react';
    import { FontAwesome, Ionicons, MaterialCommunityIcons,
    MaterialIcons, Feather } from '@expo/vector-icons';

    export const DeliveryModes = [{
      label: <Ionicons name='ios-walk' size={20} />,
      value: '30'
    }, {
      label: <MaterialCommunityIcons name='bike' size={20} />,
      value: '50'
    }, {
      label: <MaterialCommunityIcons name='motorbike' size={20} />,
      value: '190'
    }, {
      label: <MaterialCommunityIcons name='car-sports' size={20} />,
      value: '50'
    }, {
      label: <MaterialCommunityIcons name='car-pickup' size={20} />,
      value: '50'
    }, {
      label: <MaterialCommunityIcons name='car-estate' size={20} />,
      value: '50'
    }, {
      label: <MaterialCommunityIcons name='bus-side' size={20} />,
      value: '50'
    }, {
      label: <Feather name='truck' size={20} />,
      value: '50'
    },
    ];

Index.js

    import React, { Component } from 'react';
    import { View, StyleSheet, Text, TouchableHighlight, } from 'react-native';
    import RadioGroup from 'react-native-custom-radio-group';
    import Tabs from './tabs';
    import { DeliveryModes } from './deliveryMode.js';

    class Details extends Component {
      constructor(props) {
        super(props);
        // Initialize State
        this.state = {
          // First tab is active by default
          activeTab: 0,
        };
      }

      render({ children } = this.props) {
        const {
         onBook
       } = this.props;
        return (
          <View style={styles.Container}>
          <Tabs>
            {/* First tab */}
            <View title="Delivery Mode" style={styles.content}>
            {/* Showtimes */}
             <View>
               {/* Day */}
               <Text style={styles.sectionHeader}>Kindly select desired mode of delivery.</Text>
               <RadioGroup
               radioGroupList={DeliveryModes}
               containerStyle={{ flexWrap: 'wrap', padding: 5, }}
               buttonContainerStyle={{ borderWidth: 0, margin: 5, borderRadius: 40, width: 90, }}
               onChange={(value) => this.deliveryMode(value)}
               ref={e => this.RadioGroup = e}
               />
               </View>
            </View>
            {/* Second tab */}
            <View title="Number & Weight" style={styles.content}>
              <Text style={styles.header}>
                Truly Native
              </Text>
              <Text style={styles.text}>
                Components you define will end up rendering as native platform widgets
              </Text>
            </View>
            {/* Third tab */}
            <View title="Parcel Category" style={styles.content}>
              <Text style={styles.header}>
                Ease of Learning
              </Text>
              <Text style={styles.text}>
                It’s much easier to read and write comparing to native platform’s code
              </Text>
            </View>

            </Tabs>
            {/* Footer */}
            <View style={styles.footer}>
              <TouchableHighlight
                underlayColor="#9575CD"
                style={styles.buttonContainer}
                onPress={onBook}
              >
                <Text style={styles.button}>Next</Text>
              </TouchableHighlight>
              <Text>{value}</Text>
            </View>
          </View>
        );
      }
    }

    const styles = StyleSheet.create({
      Container: {
        backgroundColor: '#FFF',
        height: 250,
        width: '100%',
        position: 'absolute',
        bottom: 0,
        shadowColor: '#000',
        shadowOffset: { x: 0, y: 0 },
        shadowOpacity: 0.2,
        elevation: 2,
        zIndex: 9999,
        flex: 1,
      },
      // Tab content container
    content: {
      flex: 1,
      justifyContent: 'center',
      alignItems: 'center',
      backgroundColor: '#F8F8F8',
    },
    // Content header
    header: {
      margin: 10,                         // Add margin
      color: '#34495E',                   // White color
      fontFamily: 'Avenir',               // Change font family
      fontSize: 26,                       // Bigger font size
    },
    // Content text
    text: {
      marginHorizontal: 20,               // Add horizontal margin
      color: '#34495E',                    // Semi-transparent text
      textAlign: 'center',
      fontFamily: 'Avenir',
      fontSize: 18,
    },
    sectionHeader: {
      paddingTop: 10,
      paddingLeft: 10,
      color: '#34495E',
      fontFamily: 'Avenir',
      fontSize: 15,
    },
      footer: {
        paddingHorizontal: 110,
        paddingVertical: 10,
        backgroundColor: '#FFF'
      },
      buttonContainer: {
        backgroundColor: '#2FCC71',
        borderRadius: 100,
        paddingVertical: 15,
        paddingHorizontal: 15,
        alignItems: 'center',
      },
      button: {
        color: '#FFFFFF',
        fontSize: 16,
        fontFamily: 'Avenir',
        fontWeight: 'bold',
      },
    });

    export default Details;

I want to be able to pass the value of each radio button into a Text tag below the next button. I have kept the code plain and clean for a better usage of the onChange property.

Body:
You have not added your "value" in setState
First add value in setState

this.state = {
      // First tab is active by default
      activeTab: 0,
      value:''
    };

change value to this.state.value

<Text>{this.state.value}</Text>

Call setState method on onChange

onChange={(value) => this.setState({value:value})}

Hope, this will help you cheers!


答:
This:

```<code>void UndirectedGraph::istream& operator>>(istream& in, UndirectedGraph g)
</code>```

doesn't make sense!  You probably want:

```<code>istream& operator>>(istream& in, UndirectedGraph g)
</code>```

Having said that, you don't seem to be returning anything in your function definition.

Title: C++ error unexplained: error: expected initializer before '&' token

Body:
This:

void UndirectedGraph::istream& operator>>(istream& in, UndirectedGraph g)

doesn't make sense!  You probably want:

istream& operator>>(istream& in, UndirectedGraph g)

Having said that, you don't seem to be returning anything in your function definition.


问:
How to fix: Attribute xmlns:gco redefined
I'm using XSLT to update some old XML metadata and I realized that the target output has the following namespace:

```<code>xmlns:gco="http://standards.iso.org/iso/19115/-3/gco/1.0"
</code>```

the old metadata has the following namespace:

```<code>xmlns:gco="http://www.isotc211.org/2005/gco
</code>```

If I put both in the header of the XSLT I got the error
Attribute xmlns:gco redefined

I tried to delete one of them but the XSLT is not able to extract the correct value and I got empty string:

```<code>xsltApplySequenceConstructor: copy node identificationInfo
xsltApplySequenceConstructor: copy node MD_DataIdentification
xsltApplySequenceConstructor: copy node citation
xsltApplySequenceConstructor: copy node CI_Citation
xsltApplySequenceConstructor: copy node title
xsltApplySequenceConstructor: copy node CharacterString
xsltValueOf: select //gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:title/gco:CharacterString
xsltValueOf: result ''
</code>```

This is a part of  the XML input file

```<code><?xml version="1.0" encoding="UTF-8"?>
<gmi:MI_Metadata xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:safe="http://www.esa.int/safe/sentinel-1.0" xmlns:gss="http://www.isotc211.org/2005/gss" xmlns:s1="http://www.esa.int/safe/sentinel-1.0/sentinel-1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:s1sar="http://www.esa.int/safe/sentinel-1.0/sentinel-1/sar" xmlns:gmi="http://sdi.eurac.edu/metadata/iso19139-2/schema/gmi" xmlns:s1sarl1="http://www.esa.int/safe/sentinel-1.0/sentinel-1/sar/level-1" xmlns:gco="http://www.isotc211.org/2005/gco" xmlns:gml="http://www.opengis.net/gml" xmlns:s1sarl2="http://www.esa.int/safe/sentinel-1.0/sentinel-1/sar/level-2" xmlns:gx="http://www.google.com/kml/ext/2.2" gco:isoType="gmd:MD_Metadata" xsi:schemaLocation="http://sdi.eurac.edu/metadata/iso19139-2/schema/gmi http://sdi.eurac.edu/metadata/iso19139-2/schema/gmi/gmi.xsd">
<gmd:identificationInfo>
        <gmd:MD_DataIdentification>
            <gmd:citation>
                <gmd:CI_Citation>
                    <gmd:title xsi:type="gmd:PT_FreeText_PropertyType">
                        <gco:CharacterString>TITLE_1</gco:CharacterString>
                    </gmd:title>
                    <gmd:alternateTitle>
                        <gco:CharacterString>TITLE_2</gco:CharacterString>
                    </gmd:alternateTitle>
                </gmd:CI_Citation>
            </gmd:citation>
        </gmd:MD_DataIdentification>
</gmd:identificationInfo>
</gmi:MI_Metadata>
</code>```

and the following is the XSL file I'm using:

```<code><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output method="xml" indent="yes"/>
        <xsl:template match="/">
<mdb:MD_Metadata xmlns:mri="http://standards.iso.org/iso/19115/-3/mri/1.0"
                 xmlns:mrl="http://standards.iso.org/iso/19115/-3/mrl/2.0"
                 xmlns:mas="http://standards.iso.org/iso/19115/-3/mas/1.0"
                 xmlns:mrs="http://standards.iso.org/iso/19115/-3/mrs/1.0"
                 xmlns:mda="http://standards.iso.org/iso/19115/-3/mda/1.0"
                 xmlns:mrd="http://standards.iso.org/iso/19115/-3/mrd/1.0"
                 xmlns:mdt="http://standards.iso.org/iso/19115/-3/mdt/2.0"
                 xmlns:mco="http://standards.iso.org/iso/19115/-3/mco/1.0"
                 xmlns:mex="http://standards.iso.org/iso/19115/-3/mex/1.0"
                 xmlns:msr="http://standards.iso.org/iso/19115/-3/msr/2.0"
                 xmlns:mds="http://standards.iso.org/iso/19115/-3/mds/2.0"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xmlns:gfc="http://standards.iso.org/iso/19110/gfc/1.1"
                 xmlns:mmi="http://standards.iso.org/iso/19115/-3/mmi/1.0"
                 xmlns:srv="http://standards.iso.org/iso/19115/-3/srv/2.1"
                 xmlns:lan="http://standards.iso.org/iso/19115/-3/lan/1.0"
                 xmlns:mac="http://standards.iso.org/iso/19115/-3/mac/2.0"
                 xmlns:gcx="http://standards.iso.org/iso/19115/-3/gcx/1.0"
                 xmlns:xlink="http://www.w3.org/1999/xlink"
                 xmlns:mrc="http://standards.iso.org/iso/19115/-3/mrc/2.0"
                 xmlns:gex="http://standards.iso.org/iso/19115/-3/gex/1.0"
                 xmlns:gml="http://www.opengis.net/gml/3.2"
                 xmlns:mdb="http://standards.iso.org/iso/19115/-3/mdb/2.0"
                 xmlns:cit="http://standards.iso.org/iso/19115/-3/cit/2.0"
                 xmlns:cat="http://standards.iso.org/iso/19115/-3/cat/1.0"
                 xmlns:mcc="http://standards.iso.org/iso/19115/-3/mcc/1.0"
                 xmlns:mdq="http://standards.iso.org/iso/19157/-2/mdq/1.0"
                 xmlns:mpc="http://standards.iso.org/iso/19115/-3/mpc/1.0"
                 xmlns:gmd="http://www.isotc211.org/2005/gmd"
                 xmlns:gco="http://standards.iso.org/iso/19115/-3/gco/1.0"
                 xmlns:gco="http://www.isotc211.org/2005/gco"
                 >
    <mdb:identificationInfo>
      <mri:MD_DataIdentification>
         <mri:citation>
            <cit:CI_Citation>
               <cit:title>
                  <gco:CharacterString>
                        <xsl:value-of select="//gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:title/gco:CharacterString"/>
                  </gco:CharacterString>
               </cit:title>
               <cit:alternateTitle>
                  <gco:CharacterString>
                    <xsl:value-of select="//gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:alternatetitle/gco:CharacterString"/>
                  </gco:CharacterString>
               </cit:alternateTitle>
            </cit:CI_Citation>
        </mri:citation>
        </mri:MD_DataIdentification>
    </mdb:identificationInfo>
</mdb:MD_Metadata>
</xsl:template>
</xsl:stylesheet>
</code>```

It has the two namespaces defined.

The desired output should be:

```<code><?xml version="1.0"?>
<mdb:MD_Metadata xmlns:mri="http://standards.iso.org/iso/19115/-3/mri/1.0"
                 xmlns:mrl="http://standards.iso.org/iso/19115/-3/mrl/2.0"
                 xmlns:mas="http://standards.iso.org/iso/19115/-3/mas/1.0"
                 xmlns:mrs="http://standards.iso.org/iso/19115/-3/mrs/1.0"
                 xmlns:mda="http://standards.iso.org/iso/19115/-3/mda/1.0"
                 xmlns:mrd="http://standards.iso.org/iso/19115/-3/mrd/1.0"
                 xmlns:mdt="http://standards.iso.org/iso/19115/-3/mdt/2.0"
                 xmlns:mco="http://standards.iso.org/iso/19115/-3/mco/1.0"
                 xmlns:mex="http://standards.iso.org/iso/19115/-3/mex/1.0"
                 xmlns:msr="http://standards.iso.org/iso/19115/-3/msr/2.0"
                 xmlns:mds="http://standards.iso.org/iso/19115/-3/mds/2.0"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xmlns:gfc="http://standards.iso.org/iso/19110/gfc/1.1"
                 xmlns:mmi="http://standards.iso.org/iso/19115/-3/mmi/1.0"
                 xmlns:srv="http://standards.iso.org/iso/19115/-3/srv/2.1"
                 xmlns:lan="http://standards.iso.org/iso/19115/-3/lan/1.0"
                 xmlns:mac="http://standards.iso.org/iso/19115/-3/mac/2.0"
                 xmlns:gcx="http://standards.iso.org/iso/19115/-3/gcx/1.0"
                 xmlns:xlink="http://www.w3.org/1999/xlink"
                 xmlns:mrc="http://standards.iso.org/iso/19115/-3/mrc/2.0"
                 xmlns:gex="http://standards.iso.org/iso/19115/-3/gex/1.0"
                 xmlns:gml="http://www.opengis.net/gml/3.2"
                 xmlns:mdb="http://standards.iso.org/iso/19115/-3/mdb/2.0"
                 xmlns:cit="http://standards.iso.org/iso/19115/-3/cit/2.0"
                 xmlns:cat="http://standards.iso.org/iso/19115/-3/cat/1.0"
                 xmlns:mcc="http://standards.iso.org/iso/19115/-3/mcc/1.0"
                 xmlns:mdq="http://standards.iso.org/iso/19157/-2/mdq/1.0"
                 xmlns:mpc="http://standards.iso.org/iso/19115/-3/mpc/1.0"
                 xmlns:gmd="http://www.isotc211.org/2005/gmd"
                 xmlns:gco="http://standards.iso.org/iso/19115/-3/gco/1.0">
    <mdb:identificationInfo>
        <mri:MD_DataIdentification>
            <mri:citation>
                <cit:CI_Citation>
                <cit:title>
                  <gco:CharacterString>TITLE_1</gco:CharacterString>
                </cit:title>
               <cit:alternateTitle>
                  <gco:CharacterString>TITLE_2</gco:CharacterString>
               </cit:alternateTitle>
                </cit:CI_Citation>
            </mri:citation>
        </mri:MD_DataIdentification>
    </mdb:identificationInfo>
</mdb:MD_Metadata>

</code>```

Is there a way to solve this conflict and use both of them? Or do you have any other suggestion?

答:
You can use another prefix for the "old" namespace. Consider the following example:

XML

```<code><gco:input xmlns:gco="http://www.isotc211.org/2005/gco">123</gco:input>
</code>```

XSLT 1.0

```<code><xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:old="http://www.isotc211.org/2005/gco"
xmlns:gco="http://standards.iso.org/iso/19115/-3/gco/1.0"
exclude-result-prefixes="old">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>

<xsl:template match="/">
    <gco:output>
        <xsl:value-of select="old:input"/>
    </gco:output>
</xsl:template>

</xsl:stylesheet>
</code>```

Result

```<code><?xml version="1.0" encoding="UTF-8"?>
<gco:output xmlns:gco="http://standards.iso.org/iso/19115/-3/gco/1.0">123</gco:output>
</code>```

Body:
I'm using XSLT to update some old XML metadata and I realized that the target output has the following namespace:

xmlns:gco="http://standards.iso.org/iso/19115/-3/gco/1.0"

the old metadata has the following namespace:

xmlns:gco="http://www.isotc211.org/2005/gco

If I put both in the header of the XSLT I got the error
Attribute xmlns:gco redefined

I tried to delete one of them but the XSLT is not able to extract the correct value and I got empty string:

xsltApplySequenceConstructor: copy node identificationInfo
xsltApplySequenceConstructor: copy node MD_DataIdentification
xsltApplySequenceConstructor: copy node citation
xsltApplySequenceConstructor: copy node CI_Citation
xsltApplySequenceConstructor: copy node title
xsltApplySequenceConstructor: copy node CharacterString
xsltValueOf: select //gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:title/gco:CharacterString
xsltValueOf: result ''

This is a part of  the XML input file

<?xml version="1.0" encoding="UTF-8"?>
<gmi:MI_Metadata xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:safe="http://www.esa.int/safe/sentinel-1.0" xmlns:gss="http://www.isotc211.org/2005/gss" xmlns:s1="http://www.esa.int/safe/sentinel-1.0/sentinel-1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:s1sar="http://www.esa.int/safe/sentinel-1.0/sentinel-1/sar" xmlns:gmi="http://sdi.eurac.edu/metadata/iso19139-2/schema/gmi" xmlns:s1sarl1="http://www.esa.int/safe/sentinel-1.0/sentinel-1/sar/level-1" xmlns:gco="http://www.isotc211.org/2005/gco" xmlns:gml="http://www.opengis.net/gml" xmlns:s1sarl2="http://www.esa.int/safe/sentinel-1.0/sentinel-1/sar/level-2" xmlns:gx="http://www.google.com/kml/ext/2.2" gco:isoType="gmd:MD_Metadata" xsi:schemaLocation="http://sdi.eurac.edu/metadata/iso19139-2/schema/gmi http://sdi.eurac.edu/metadata/iso19139-2/schema/gmi/gmi.xsd">
<gmd:identificationInfo>
        <gmd:MD_DataIdentification>
            <gmd:citation>
                <gmd:CI_Citation>
                    <gmd:title xsi:type="gmd:PT_FreeText_PropertyType">
                        <gco:CharacterString>TITLE_1</gco:CharacterString>
                    </gmd:title>
                    <gmd:alternateTitle>
                        <gco:CharacterString>TITLE_2</gco:CharacterString>
                    </gmd:alternateTitle>
                </gmd:CI_Citation>
            </gmd:citation>
        </gmd:MD_DataIdentification>
</gmd:identificationInfo>
</gmi:MI_Metadata>

and the following is the XSL file I'm using:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output method="xml" indent="yes"/>
        <xsl:template match="/">
<mdb:MD_Metadata xmlns:mri="http://standards.iso.org/iso/19115/-3/mri/1.0"
                 xmlns:mrl="http://standards.iso.org/iso/19115/-3/mrl/2.0"
                 xmlns:mas="http://standards.iso.org/iso/19115/-3/mas/1.0"
                 xmlns:mrs="http://standards.iso.org/iso/19115/-3/mrs/1.0"
                 xmlns:mda="http://standards.iso.org/iso/19115/-3/mda/1.0"
                 xmlns:mrd="http://standards.iso.org/iso/19115/-3/mrd/1.0"
                 xmlns:mdt="http://standards.iso.org/iso/19115/-3/mdt/2.0"
                 xmlns:mco="http://standards.iso.org/iso/19115/-3/mco/1.0"
                 xmlns:mex="http://standards.iso.org/iso/19115/-3/mex/1.0"
                 xmlns:msr="http://standards.iso.org/iso/19115/-3/msr/2.0"
                 xmlns:mds="http://standards.iso.org/iso/19115/-3/mds/2.0"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xmlns:gfc="http://standards.iso.org/iso/19110/gfc/1.1"
                 xmlns:mmi="http://standards.iso.org/iso/19115/-3/mmi/1.0"
                 xmlns:srv="http://standards.iso.org/iso/19115/-3/srv/2.1"
                 xmlns:lan="http://standards.iso.org/iso/19115/-3/lan/1.0"
                 xmlns:mac="http://standards.iso.org/iso/19115/-3/mac/2.0"
                 xmlns:gcx="http://standards.iso.org/iso/19115/-3/gcx/1.0"
                 xmlns:xlink="http://www.w3.org/1999/xlink"
                 xmlns:mrc="http://standards.iso.org/iso/19115/-3/mrc/2.0"
                 xmlns:gex="http://standards.iso.org/iso/19115/-3/gex/1.0"
                 xmlns:gml="http://www.opengis.net/gml/3.2"
                 xmlns:mdb="http://standards.iso.org/iso/19115/-3/mdb/2.0"
                 xmlns:cit="http://standards.iso.org/iso/19115/-3/cit/2.0"
                 xmlns:cat="http://standards.iso.org/iso/19115/-3/cat/1.0"
                 xmlns:mcc="http://standards.iso.org/iso/19115/-3/mcc/1.0"
                 xmlns:mdq="http://standards.iso.org/iso/19157/-2/mdq/1.0"
                 xmlns:mpc="http://standards.iso.org/iso/19115/-3/mpc/1.0"
                 xmlns:gmd="http://www.isotc211.org/2005/gmd"
                 xmlns:gco="http://standards.iso.org/iso/19115/-3/gco/1.0"
                 xmlns:gco="http://www.isotc211.org/2005/gco"
                 >
    <mdb:identificationInfo>
      <mri:MD_DataIdentification>
         <mri:citation>
            <cit:CI_Citation>
               <cit:title>
                  <gco:CharacterString>
                        <xsl:value-of select="//gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:title/gco:CharacterString"/>
                  </gco:CharacterString>
               </cit:title>
               <cit:alternateTitle>
                  <gco:CharacterString>
                    <xsl:value-of select="//gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:alternatetitle/gco:CharacterString"/>
                  </gco:CharacterString>
               </cit:alternateTitle>
            </cit:CI_Citation>
        </mri:citation>
        </mri:MD_DataIdentification>
    </mdb:identificationInfo>
</mdb:MD_Metadata>
</xsl:template>
</xsl:stylesheet>

It has the two namespaces defined.

The desired output should be:

<?xml version="1.0"?>
<mdb:MD_Metadata xmlns:mri="http://standards.iso.org/iso/19115/-3/mri/1.0"
                 xmlns:mrl="http://standards.iso.org/iso/19115/-3/mrl/2.0"
                 xmlns:mas="http://standards.iso.org/iso/19115/-3/mas/1.0"
                 xmlns:mrs="http://standards.iso.org/iso/19115/-3/mrs/1.0"
                 xmlns:mda="http://standards.iso.org/iso/19115/-3/mda/1.0"
                 xmlns:mrd="http://standards.iso.org/iso/19115/-3/mrd/1.0"
                 xmlns:mdt="http://standards.iso.org/iso/19115/-3/mdt/2.0"
                 xmlns:mco="http://standards.iso.org/iso/19115/-3/mco/1.0"
                 xmlns:mex="http://standards.iso.org/iso/19115/-3/mex/1.0"
                 xmlns:msr="http://standards.iso.org/iso/19115/-3/msr/2.0"
                 xmlns:mds="http://standards.iso.org/iso/19115/-3/mds/2.0"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xmlns:gfc="http://standards.iso.org/iso/19110/gfc/1.1"
                 xmlns:mmi="http://standards.iso.org/iso/19115/-3/mmi/1.0"
                 xmlns:srv="http://standards.iso.org/iso/19115/-3/srv/2.1"
                 xmlns:lan="http://standards.iso.org/iso/19115/-3/lan/1.0"
                 xmlns:mac="http://standards.iso.org/iso/19115/-3/mac/2.0"
                 xmlns:gcx="http://standards.iso.org/iso/19115/-3/gcx/1.0"
                 xmlns:xlink="http://www.w3.org/1999/xlink"
                 xmlns:mrc="http://standards.iso.org/iso/19115/-3/mrc/2.0"
                 xmlns:gex="http://standards.iso.org/iso/19115/-3/gex/1.0"
                 xmlns:gml="http://www.opengis.net/gml/3.2"
                 xmlns:mdb="http://standards.iso.org/iso/19115/-3/mdb/2.0"
                 xmlns:cit="http://standards.iso.org/iso/19115/-3/cit/2.0"
                 xmlns:cat="http://standards.iso.org/iso/19115/-3/cat/1.0"
                 xmlns:mcc="http://standards.iso.org/iso/19115/-3/mcc/1.0"
                 xmlns:mdq="http://standards.iso.org/iso/19157/-2/mdq/1.0"
                 xmlns:mpc="http://standards.iso.org/iso/19115/-3/mpc/1.0"
                 xmlns:gmd="http://www.isotc211.org/2005/gmd"
                 xmlns:gco="http://standards.iso.org/iso/19115/-3/gco/1.0">
    <mdb:identificationInfo>
        <mri:MD_DataIdentification>
            <mri:citation>
                <cit:CI_Citation>
                <cit:title>
                  <gco:CharacterString>TITLE_1</gco:CharacterString>
                </cit:title>
               <cit:alternateTitle>
                  <gco:CharacterString>TITLE_2</gco:CharacterString>
               </cit:alternateTitle>
                </cit:CI_Citation>
            </mri:citation>
        </mri:MD_DataIdentification>
    </mdb:identificationInfo>
</mdb:MD_Metadata>

Is there a way to solve this conflict and use both of them? Or do you have any other suggestion?

Body:
You can use another prefix for the "old" namespace. Consider the following example:

XML

<gco:input xmlns:gco="http://www.isotc211.org/2005/gco">123</gco:input>

XSLT 1.0

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:old="http://www.isotc211.org/2005/gco"
xmlns:gco="http://standards.iso.org/iso/19115/-3/gco/1.0"
exclude-result-prefixes="old">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>

<xsl:template match="/">
    <gco:output>
        <xsl:value-of select="old:input"/>
    </gco:output>
</xsl:template>

</xsl:stylesheet>

Result

<?xml version="1.0" encoding="UTF-8"?>
<gco:output xmlns:gco="http://standards.iso.org/iso/19115/-3/gco/1.0">123</gco:output>


问:
compression problems excell using Maatwebsite
the problem very easy the form that i try to compress a file is the next

```<code> $zipname = 'file.zip';
 $zip = new ZipArchive;
 $zip->open($zipname, ZipArchive::CREATE);
 $zip->addFile(Excel::download(new SheetsExports($page1, $page2), $filename . '.xls'));
  $zip->close()
 echo 'Archive created!'
 header('Content-disposition: attachment; filename=files.zip');
 header('Content-type: application/zip');
 <!-- end snippet -->
 $zip->close()
 echo 'Archive created!';
 header('Content-disposition: attachment; filename=files.zip');
 header('Content-type: application/zip');
</code>```

in a laravel controller , i use the external library Maatwebsite
then when i execute the brwoser apair the next error

Corrupted Content Error

The site at http://hall.test/indiceDeRotacion?_token=2Eh6WAl0W43l8ANzLz0e4GGW9reV04ESpURvEi1H&almacen=PRINCIPAL&fechaDesde=2018-05-01&fechaHasta=2019-04-30&proveedor=3000 familia=&type=xls&compresion=on&email=&asunto=&submit=informe

so i need a solution , or another external library or the correct way in my code for it works

答:
i fix the issue with this code </p>

```<code> $zip = new ZipArchive;
        if ($zip->open('yyyy.zip', ZipArchive::CREATE) === true) {
            $zip->addFile(Excel::download(new SheetsExports($page1, $page2),  $filename . '.xls')->getFile(),
                'xxxx.xls');
            $zip->close();
        }
        return response()->download("yyyy.zip");
</code>```

Body:
the problem very easy the form that i try to compress a file is the next

 $zipname = 'file.zip';
 $zip = new ZipArchive;
 $zip->open($zipname, ZipArchive::CREATE);
 $zip->addFile(Excel::download(new SheetsExports($page1, $page2), $filename . '.xls'));
  $zip->close()
 echo 'Archive created!'
 header('Content-disposition: attachment; filename=files.zip');
 header('Content-type: application/zip');

 $zip->close()
 echo 'Archive created!';
 header('Content-disposition: attachment; filename=files.zip');
 header('Content-type: application/zip');

in a laravel controller , i use the external library Maatwebsite
then when i execute the brwoser apair the next error

Corrupted Content Error

The site at http://hall.test/indiceDeRotacion?_token=2Eh6WAl0W43l8ANzLz0e4GGW9reV04ESpURvEi1H&almacen=PRINCIPAL&fechaDesde=2018-05-01&fechaHasta=2019-04-30&proveedor=3000 familia=&type=xls&compresion=on&email=&asunto=&submit=informe

so i need a solution , or another external library or the correct way in my code for it works

Body:
i fix the issue with this code

 $zip = new ZipArchive;
        if ($zip->open('yyyy.zip', ZipArchive::CREATE) === true) {
            $zip->addFile(Excel::download(new SheetsExports($page1, $page2),  $filename . '.xls')->getFile(),
                'xxxx.xls');
            $zip->close();
        }
        return response()->download("yyyy.zip");


问:
Wrong local date format saving to SQL Server with Laravel
Our code in Laravel receives a date in Y-M-D format and tries to save it to a SQL Server database.

The code receives these dates via APIs for many tables and we cannot change this functionality everywhere.

SQL Server language is italian and our code is OK with a Y-D-M date.

Is there a way to specify the date format once for all or the locale used in the database connection configuration?
Setting the language via statement doesn't work.

Our code is something like this:

```<code>DB::statement('SET LANGUAGE us_english');
DB::table('tablename')->insert($saveData);
</code>```

答:
You can convert date format to Italian using LARAVEL Carbon Date library.

Like below :

```<code>$date = carbon::now()->locale($yourLocale);
</code>```

Here is the Carbon library locale example : https://carbon.nesbot.com/docs/#api-localization

Body:
Our code in Laravel receives a date in Y-M-D format and tries to save it to a SQL Server database.

The code receives these dates via APIs for many tables and we cannot change this functionality everywhere.

SQL Server language is italian and our code is OK with a Y-D-M date.

Is there a way to specify the date format once for all or the locale used in the database connection configuration?
Setting the language via statement doesn't work.

Our code is something like this:

DB::statement('SET LANGUAGE us_english');
DB::table('tablename')->insert($saveData);

Body:
You can convert date format to Italian using LARAVEL Carbon Date library.

Like below :

$date = carbon::now()->locale($yourLocale);

Here is the Carbon library locale example : https://carbon.nesbot.com/docs/#api-localization


问:
Convert string array to array with ascii codes
I'm trying to convert every character of a string to its ASCII code. The string array comes from stdin.

I'm trying to loop through the string and convert every character to ASCII with atoi() and add this ASCII code to a new int array.

```<code>char s2[1024];
fgets(s2, 1024, stdin);
int arr[1024];
int i = 0;
while (i < strlen(s2))
  {
  char * start = s2;
  int j = 0;
    while(start != "\0")
    {
      arr[j++] = atoi(start);
    }
    i++;
  }
</code>```

I'm pretty new to C and I thought this could work, but I get an "segmentation fault (core dumped)" when I run the code. I know this error has to do something with the memory, but I don't know how to debug it.

答:
You don't need to convert anything because the characters in s2 are already ASCII values.

You probably want something like this:

```<code>char s2[1024];
fgets(s2, 1024, stdin);
int arr[1024];
int i = 0;
while (i < strlen(s2))
{
  arr[i] = s2[i];
  i++;
}
</code>```

If your input is say:

```<code>ABCD
</code>```

arr will contain following values: {65, 66, 67, 68, x, x, x}, where x stands for "indetermined value".

Better version of the loop:

```<code>for (int i = 0; i < strlen(s2); i++)
{
  arr[i] = s2[i];
}
</code>```

Overall better version:

```<code>#define MAXLINE 1024

char line[MAXLINE];
fgets(line, sizeof line, stdin);
int arr[MAXLINE];

for (int i = 0; i < strlen(s2); i++)
{
  arr[i] = s2[i];
}
</code>```

Body:
I'm trying to convert every character of a string to its ASCII code. The string array comes from stdin.

I'm trying to loop through the string and convert every character to ASCII with atoi() and add this ASCII code to a new int array.

char s2[1024];
fgets(s2, 1024, stdin);
int arr[1024];
int i = 0;
while (i < strlen(s2))
  {
  char * start = s2;
  int j = 0;
    while(start != "\0")
    {
      arr[j++] = atoi(start);
    }
    i++;
  }

I'm pretty new to C and I thought this could work, but I get an "segmentation fault (core dumped)" when I run the code. I know this error has to do something with the memory, but I don't know how to debug it.

Body:
You don't need to convert anything because the characters in s2 are already ASCII values.

You probably want something like this:

char s2[1024];
fgets(s2, 1024, stdin);
int arr[1024];
int i = 0;
while (i < strlen(s2))
{
  arr[i] = s2[i];
  i++;
}

If your input is say:

ABCD

arr will contain following values: {65, 66, 67, 68, x, x, x}, where x stands for "indetermined value".

Better version of the loop:

for (int i = 0; i < strlen(s2); i++)
{
  arr[i] = s2[i];
}

Overall better version:

#define MAXLINE 1024

char line[MAXLINE];
fgets(line, sizeof line, stdin);
int arr[MAXLINE];

for (int i = 0; i < strlen(s2); i++)
{
  arr[i] = s2[i];
}


问:
After DDOS attack i cant access my site anymore
Hello guys I would like to ask for a help.

I just want to test my website for denial of service attack .
But it seem that i cant access my site 24hrs have been passed. Still nothing changed ..

This is the DDOS attack that i was downloaded.

```<code>https://github.com/Leetcore/JS-LOIC
</code>```

Anyone can help me? Because i need to fix this.

答:
There's a couple of things that could be wrong with your site that I have identified. I'll include them below but I recommend you contact your web hosting provider (which is shown as GoDaddy) and discuss the issue with them as they will be able to assist you further, and actually have the permissions to action any faults.

DNS Updates

Your whois information was last updated 2019-05-29 @ 06:48:19, and it has not yet been a full 24 hours. DNS Propagation may be the problem.

SOA Record - last update

Your SOA record appears to have updated in the last 24 hours, some time on 2019-05-29. Because it's been less than 24 hours, your domain name may not be working as expected due to DNS propagation.

A Records (IP Addresses) - Hostname

Your domain name appears to be pointing to the following ip address / host:

✗ 50.62.22.174 - ip-50-62-22-174.ip.secureserver.net

Apache

Apache does not appear to be running.

TL;DR: Contact your web hosting provider.

Body:
Hello guys I would like to ask for a help.

I just want to test my website for denial of service attack .
But it seem that i cant access my site 24hrs have been passed. Still nothing changed ..

This is the DDOS attack that i was downloaded.

https://github.com/Leetcore/JS-LOIC

Anyone can help me? Because i need to fix this.


问:
Xamarin Android use SetSound for Notification Channel to play custom sound on notification
I have I have been wasting at least a day trying to make this work. I am trying to play an mp3 file that i placed in Resources/raw once a notification is received. I do not know exactly how to get the Uri. My questions please are:

1.To play a custom file do you have to place it in Resources/raw or  can it be also in Assets/Sounds under the Xamarin Android project.

2.How do i get the Uri correctly based on where the mp3 file resides.

This is my code:

```<code>private void createNotificationChannel()
        {
            var channelName = GetString(Resource.String.noti_chan_urgent);
            var channelDescription = GetString(Resource.String.noti_chan_urgent_description);

            // set the vibration patterm for the channel
            long[] vibrationPattern = { 100, 200, 300, 400, 500, 400, 300, 200, 400 };

            // Creating an Audio Attribute
            var alarmAttributes = new AudioAttributes.Builder().SetUsage(AudioUsageKind.Alarm).Build();

            // Create the uri for the alarm file
            var alarmUri = Android.Net.Uri.Parse("MyApp.Android/Resources/raw/alarm.mp3");   // this must be wrong because its not working

            // create chan1  which is the urgent notifications channel
            var chan1 = new NotificationChannel(PRIMARY_CHANNEL_ID, channelName, NotificationImportance.High)
            {
                Description = channelDescription
            };

            // set the channel properties
            chan1.EnableLights(true);
            chan1.LightColor = Color.Red;
            chan1.EnableVibration(true);
            chan1.SetVibrationPattern(vibrationPattern);
            chan1.SetSound(alarmUri, alarmAttributes);
            chan1.SetBypassDnd(true);
            chan1.LockscreenVisibility = NotificationVisibility.Public;

            var manager = (NotificationManager)GetSystemService(NotificationService);
            manager.CreateNotificationChannel(chan1);
        }

    }
</code>```

答:
uri = Android.Net.Uri.Parse(
"android.resource://" + Application.Context.PackageName + "/raw/sound2");

only change I had to make.  to Fredsomofspeech answer.

android 9.
visualstudio 2019 xamarin.forms mobile ios android. sound2.mp3

was running a file android could not play, so make sure download a mp3 file for testing verified to work.

Body:
I have I have been wasting at least a day trying to make this work. I am trying to play an mp3 file that i placed in Resources/raw once a notification is received. I do not know exactly how to get the Uri. My questions please are:

1.To play a custom file do you have to place it in Resources/raw or  can it be also in Assets/Sounds under the Xamarin Android project.

2.How do i get the Uri correctly based on where the mp3 file resides.

This is my code:

private void createNotificationChannel()
        {
            var channelName = GetString(Resource.String.noti_chan_urgent);
            var channelDescription = GetString(Resource.String.noti_chan_urgent_description);

            // set the vibration patterm for the channel
            long[] vibrationPattern = { 100, 200, 300, 400, 500, 400, 300, 200, 400 };

            // Creating an Audio Attribute
            var alarmAttributes = new AudioAttributes.Builder().SetUsage(AudioUsageKind.Alarm).Build();

            // Create the uri for the alarm file
            var alarmUri = Android.Net.Uri.Parse("MyApp.Android/Resources/raw/alarm.mp3");   // this must be wrong because its not working

            // create chan1  which is the urgent notifications channel
            var chan1 = new NotificationChannel(PRIMARY_CHANNEL_ID, channelName, NotificationImportance.High)
            {
                Description = channelDescription
            };

            // set the channel properties
            chan1.EnableLights(true);
            chan1.LightColor = Color.Red;
            chan1.EnableVibration(true);
            chan1.SetVibrationPattern(vibrationPattern);
            chan1.SetSound(alarmUri, alarmAttributes);
            chan1.SetBypassDnd(true);
            chan1.LockscreenVisibility = NotificationVisibility.Public;

            var manager = (NotificationManager)GetSystemService(NotificationService);
            manager.CreateNotificationChannel(chan1);
        }

    }


问:
Change doesn't trigger when selection all checkboxes and records not getting added to the array
I have checkbox in each row of the table if I check any checkbox in the table individually then checkedForDeletion() methond runs and it adds the added record in the array and removes it if unchecked however if i select the checkbox at the top in the table th heading then (change) doesn't get triggerd and records are not added and removed from the array based on checked status.
I want that if user clicks on checkbox in the heading then all records should be push to the array and removed if used unchecks anyone row and so on.

              <input type="checkbox" (change)="selectAll();" [checked]="selectedAll">
              IP
              Domain
              Status
              Sender Email
              Action

              <input type="checkbox" [(ngModel)]="record.selected" (change)="checkedForDeletion(record,$event);">
              {{record.ip}}
              {{record.forDomain}}
              {{record.status}}
              {{record.senderEmail}}

```

<p>ts file</p>

<pre class="lang-js prettyprint-override"><code>    ipRecords: any;
    deletionList: any;
   selectedAll: any;

    checkedForDeletion(record: any, event: any) {
        const checked = event.target.checked;
        if (checked) {
          this.deletionList.push(record);
          console.log(this.deletionList);
        } else {
          const index = this.deletionList.findIndex(list => list.id === record.id );
          this.deletionList.splice(index, 1);
          console.log(this.deletionList);
        }

        selectAll() {
        this.selectedAll = !this.selectedAll;
        for (var i = 0; i < this.ipRecords.length; i++) {
          this.ipRecords[i].selected = this.selectedAll;
      }

      }
</code>```

答:
I think is a problem about the parameter. This is the wrong method

```<code><td><input type="checkbox" [(ngModel)]="record.selected" (change)="checkIfAllSelected(record); checkedForDeletion(record,$event);"></td>
</code>```

The correct method is:

```<code><td><input type="checkbox" [(ngModel)]="record.selected" (change)="checkIfAllSelected($event,record); checkedForDeletion($event,record);"></td>
</code>```

There is also a parentesis problem

```<code>checkedForDeletion(record: any, event: any) {
    const checked = event.target.checked;
    if (checked) {
      this.deletionList.push(record);
      console.log(this.deletionList);
    } else {
      const index = this.deletionList.findIndex(list => list.id === record.id );
      this.deletionList.splice(index, 1);
      console.log(this.deletionList);
    }
}//add here to end the method above
    selectAll() {
    this.selectedAll = !this.selectedAll;
    for (var i = 0; i < this.ipRecords.length; i++) {
      this.ipRecords[i].selected = this.selectedAll;
  }

  }
</code>```

Body:
I have checkbox in each row of the table if I check any checkbox in the table individually then checkedForDeletion() methond runs and it adds the added record in the array and removes it if unchecked however if i select the checkbox at the top in the table th heading then (change) doesn't get triggerd and records are not added and removed from the array based on checked status.
I want that if user clicks on checkbox in the heading then all records should be push to the array and removed if used unchecks anyone row and so on.

              <input type="checkbox" (change)="selectAll();" [checked]="selectedAll">
              IP
              Domain
              Status
              Sender Email
              Action

              <input type="checkbox" [(ngModel)]="record.selected" (change)="checkedForDeletion(record,$event);">
              {{record.ip}}
              {{record.forDomain}}
              {{record.status}}
              {{record.senderEmail}}

ts file

    ipRecords: any;
    deletionList: any;
   selectedAll: any;

    checkedForDeletion(record: any, event: any) {
        const checked = event.target.checked;
        if (checked) {
          this.deletionList.push(record);
          console.log(this.deletionList);
        } else {
          const index = this.deletionList.findIndex(list => list.id === record.id );
          this.deletionList.splice(index, 1);
          console.log(this.deletionList);
        }

        selectAll() {
        this.selectedAll = !this.selectedAll;
        for (var i = 0; i < this.ipRecords.length; i++) {
          this.ipRecords[i].selected = this.selectedAll;
      }

      }

Body:
I think is a problem about the parameter. This is the wrong method

<td><input type="checkbox" [(ngModel)]="record.selected" (change)="checkIfAllSelected(record); checkedForDeletion(record,$event);"></td>

The correct method is:

<td><input type="checkbox" [(ngModel)]="record.selected" (change)="checkIfAllSelected($event,record); checkedForDeletion($event,record);"></td>

There is also a parentesis problem

checkedForDeletion(record: any, event: any) {
    const checked = event.target.checked;
    if (checked) {
      this.deletionList.push(record);
      console.log(this.deletionList);
    } else {
      const index = this.deletionList.findIndex(list => list.id === record.id );
      this.deletionList.splice(index, 1);
      console.log(this.deletionList);
    }
}//add here to end the method above
    selectAll() {
    this.selectedAll = !this.selectedAll;
    for (var i = 0; i < this.ipRecords.length; i++) {
      this.ipRecords[i].selected = this.selectedAll;
  }

  }


问:
Error updating the details using rest api
Hi i try to update a product price using the following code . But for some reason it showing error . This is documentation . Please check this .

```<code>$storeId   = storeid;
$productId = myproductid;
$myToken   = mytoken;
$dataRAW   = json_encode( array( 'price' => 80 ), JSON_FORCE_OBJECT );
$dataToPut = $dataRAW;
$dataRAW   = http_build_query($dataRAW);
$context   = [
    'http' => [
        'method' => 'PUT',
        'header' => "Authorization: apikeystring\r\n" . "Content-Length: ".sizeof($dataToPut)."\r\n" . "Content-Type: application/json\r\n",
        'content' => $dataToPut
    ]
];

$context   = stream_context_create($context);
$url       = "https://app.ecwid.com/api/v3/".urlencode($storeId)."/products/".urlencode($productId)."?token=".$myToken;
$dataToPut = json_encode($dataToPut);

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Host: app.ecwid.com','Content-Type: application/json;charset=utf-8','Cache-Control: no-cache'));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $dataToPut);

// Make the REST call, returning the result
$response = curl_exec($curl);
echo $response;

if (!$response) {
    echo("Connection Failure: ".curl_error($curl));
    die();
}
curl_close($curl);
</code>```

I run this code in my localhost . http://localhost/ecwid/code.php

Warning: http_build_query(): Parameter 1 expected to be Array or Object. Incorrect value given in C:\xampp\htdocs\ecwid\code.php on line 7

Warning: sizeof(): Parameter must be an array or an object that implements Countable in C:\xampp\htdocs\ecwid\code.php on line 11

Connection Failure: error setting certificate verify locations: CAfile: C:\xampp\apache\bin\curl-ca-bundle.crt CApath: none

答:
You are passing JSON data in http_build_query so it happened, http_build_query take only array params and convert into the query string. You can take reference from the following the example.

```<code>$dataRAW   = ['price' => 80];
$dataRAW   = http_build_query($dataRAW);
</code>```

Body:
Hi i try to update a product price using the following code . But for some reason it showing error . This is documentation . Please check this .

$storeId   = storeid;
$productId = myproductid;
$myToken   = mytoken;
$dataRAW   = json_encode( array( 'price' => 80 ), JSON_FORCE_OBJECT );
$dataToPut = $dataRAW;
$dataRAW   = http_build_query($dataRAW);
$context   = [
    'http' => [
        'method' => 'PUT',
        'header' => "Authorization: apikeystring\r\n" . "Content-Length: ".sizeof($dataToPut)."\r\n" . "Content-Type: application/json\r\n",
        'content' => $dataToPut
    ]
];

$context   = stream_context_create($context);
$url       = "https://app.ecwid.com/api/v3/".urlencode($storeId)."/products/".urlencode($productId)."?token=".$myToken;
$dataToPut = json_encode($dataToPut);

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Host: app.ecwid.com','Content-Type: application/json;charset=utf-8','Cache-Control: no-cache'));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $dataToPut);

// Make the REST call, returning the result
$response = curl_exec($curl);
echo $response;

if (!$response) {
    echo("Connection Failure: ".curl_error($curl));
    die();
}
curl_close($curl);

I run this code in my localhost . http://localhost/ecwid/code.php

Warning: http_build_query(): Parameter 1 expected to be Array or Object. Incorrect value given in C:\xampp\htdocs\ecwid\code.php on line 7

Warning: sizeof(): Parameter must be an array or an object that implements Countable in C:\xampp\htdocs\ecwid\code.php on line 11

Connection Failure: error setting certificate verify locations: CAfile: C:\xampp\apache\bin\curl-ca-bundle.crt CApath: none

Body:
You are passing JSON data in http_build_query so it happened, http_build_query take only array params and convert into the query string. You can take reference from the following the example.

$dataRAW   = ['price' => 80];
$dataRAW   = http_build_query($dataRAW);