问:
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>```

答:
I was stuck of this for a while.

Make sure these step are performed-

Correct SHA key is saved on Firebase Console.

Download the latest google-service.json

And Last and most important   Save OAuth consent under credentials in google api,
OAuth Screen This took a long to figure out.
And it worked fine after this.

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


来源: stackexchange

问:
Can Path.Data creation be simplified in code?
I have a Canvas in UWP, and need to draw Path on it in code-behind.  I have it working, but it seems needlessly verbose, especially considering that I need to have four instances of it in a switch-case statement.  I'm wondering if there's a way to simplify the code, or at least to consolidate it into a single line:

C#

```<code>Rect door = new Rect(left, top, width, height);
RectangleGeometry doorGeometry = new RectangleGeometry();
doorGeometry.Rect = door;
doorGroup.Children.Add(doorGeometry);
path.Data = doorGroup;
</code>```

I tried putting it into a single line as below, but received several "No constructor with 1 elements" errors in IntelliSense.  Is there a way to do this that simplifies/lessens the amount of code used?

```<code>GeometryGroup doorGroup = new GeometryGroup(new RectangleGeometry(new Rect(left, top, width, height);
</code>```

答:
You cannot write it in a simpler manner using just the built-in API. What you could do however is to write your own "builder" pattern-based class that could feature a Fluent API that would allow you to build up the path data "as a single statement".

See this blog post as an example of a fluent builder.

ContentLicense: CC BY-SA 4.0

Body:
I have a Canvas in UWP, and need to draw Path on it in code-behind.  I have it working, but it seems needlessly verbose, especially considering that I need to have four instances of it in a switch-case statement.  I'm wondering if there's a way to simplify the code, or at least to consolidate it into a single line:

C#

Rect door = new Rect(left, top, width, height);
RectangleGeometry doorGeometry = new RectangleGeometry();
doorGeometry.Rect = door;
doorGroup.Children.Add(doorGeometry);
path.Data = doorGroup;

I tried putting it into a single line as below, but received several "No constructor with 1 elements" errors in IntelliSense.  Is there a way to do this that simplifies/lessens the amount of code used?

GeometryGroup doorGroup = new GeometryGroup(new RectangleGeometry(new Rect(left, top, width, height);


问:
How to limit number of the many in a one-to-many relationships between two tables?
I have a MySQL database with two MySql tables. First is with The first table (table A) has a column with unique values(from values (from 1 to n). In the second table 2 (table B), I have two columns: in the first I have a name and in the second i have values from 1 to n(if i ad an value in the . The second it's updated column in table B is a reference to the first and vice versa. That's done)column in table A.

My Question: Can I limit the number of aparation of times the values from the second in table A appear in table B, specifically to a maximum of 10 times?
An example is this: (with limitation for column val to 3) (the third table would send an error)

```<code>First table:      Second table:        Third table(imaginary)
+---+             +----+-----+          +----+-----+
|val|             |name| val |          |name| val |
+---+             +----+-----+          +----+-----+
| 1 |             |  a |  1  |          |  a |  1  |
| 2 |             |  b |  2  |          |  b |  2  |
+---+             |  c |  1  |          |  c |  1  |
                  |  d |  1  |          |  d |  1  |
                  +----+-----+          |  e |  1  |
                                        +----+-----+
</code>```

PS: Sorry for my english.

答: You need to add a constraint to the table definition of the second table.  This way, the database will check the value for you upon insert and update.</p>

ContentLicense: CC BY-SA 3.0

Body:
I have a MySQL database with two MySql tables. First is with The first table (table A) has a column with unique values(from values (from 1 to n). In the second table 2 (table B), I have two columns: in the first I have a name and in the second i have values from 1 to n(if i ad an value in the . The second it's updated column in table B is a reference to the first and vice versa. That's done)column in table A.

My Question: Can I limit the number of aparation of times the values from the second in table A appear in table B, specifically to a maximum of 10 times?
An example is this: (with limitation for column val to 3) (the third table would send an error)

First table:      Second table:        Third table(imaginary)
+---+             +----+-----+          +----+-----+
|val|             |name| val |          |name| val |
+---+             +----+-----+          +----+-----+
| 1 |             |  a |  1  |          |  a |  1  |
| 2 |             |  b |  2  |          |  b |  2  |
+---+             |  c |  1  |          |  c |  1  |
                  |  d |  1  |          |  d |  1  |
                  +----+-----+          |  e |  1  |
                                        +----+-----+

PS: Sorry for my english.


问:
Google Sign-in is not working
I tried to use Google Sign-in for my website, however, it keeps giving me 400 error.

I referenced this article: https://developers.google.com/identity/sign-in/web/sign-in, and my code is really simple:

```<code><html>
<head>
  <title>Test Google Login</title>
  <script src="https://apis.google.com/js/platform.js" async defer></script>
  <meta name="google-signin-client_id" content="<CHANGE IT>">
  <script>
  function onSignIn(googleUser) {
    var profile = googleUser.getBasicProfile();
    console.log('ID: ' + profile.getId());
    console.log('Name: ' + profile.getName());
    console.log('Image URL: ' + profile.getImageUrl());
    console.log('Email: ' + profile.getEmail());
  }
  </script>
</head>
<body>
  <div class="g-signin2" data-onsuccess="onSignIn"></div>
</body>
</html>
</code>```

When I click Sign-in button, it popups a window, and after logged in, it gave me 400 error as below:

```<code>400. That’s an error.

The requested URL was not found on this server. That’s all we know.
</code>```

I guess it's redirect issue, but I don't know how to configure it. So I checked url it returned to me:

```<code>https://accounts.google.com/o/oauth2/auth?fetch_basic_profile=true&scope=email+profile+openid&response_type=permission&e=3100087&redirect_uri=storagerelay://http/127.0.0.1:8000?id%3Dauth867179&ss_domain=http://127.0.0.1:8000&client_id=378468243311-9dt7m9ufa9mee305j1b12815put5betb.apps.googleusercontent.com&openid.realm&hl=en&from_login=1&as=1b5f0a407ea58e11&pli=1&authuser=0
</code>```

Why is redirect_uri "storagerelay://http/127.0.0.1:8000?id%3Dauth867179"?

答: Replace everywherehttp://127.0.0.1:8000/ to HTTP://localhost:8000/even in your browser too. The Problem comes when you use http://127.0.0.1:8000/ either in the developer console or a browser.

Title: Google Sign-in is not working

Body:
I tried to use Google Sign-in for my website, however, it keeps giving me 400 error.

I referenced this article: https://developers.google.com/identity/sign-in/web/sign-in, and my code is really simple:

  <title>Test Google Login</title>

  <meta name="google-signin-client_id" content="<CHANGE IT>">

When I click Sign-in button, it popups a window, and after logged in, it gave me 400 error as below:

400. That’s an error.

The requested URL was not found on this server. That’s all we know.

I guess it's redirect issue, but I don't know how to configure it. So I checked url it returned to me:

https://accounts.google.com/o/oauth2/auth?fetch_basic_profile=true&scope=email+profile+openid&response_type=permission&e=3100087&redirect_uri=storagerelay://http/127.0.0.1:8000?id%3Dauth867179&ss_domain=http://127.0.0.1:8000&client_id=378468243311-9dt7m9ufa9mee305j1b12815put5betb.apps.googleusercontent.com&openid.realm&hl=en&from_login=1&as=1b5f0a407ea58e11&pli=1&authuser=0

Why is redirect_uri "storagerelay://http/127.0.0.1:8000?id%3Dauth867179"?


问:
Styling different width columns in same row Bootstrap
I've just got back in to learning bootstrap, html and css. So far I have three cards in a row of different widths using the bootstrap grid the horizontal card template. My problem is that I want my layout to be the same in each card, The title and paragraph should be the same distance away in each and the fav / info button the same distance from the title. Also, I managed to get the first two columns close but somehow there is weird extra large spacing between the image and title of the last and largest column. How can I do this?

I've tried to manually adjust the positions of the elements in each card but it's hard to get them consistent, it also made my code a mess with extra ids for very similar things. As for the odd spacing I've tried to find the issue using developer tools on chrome to change the width, padding etc but not sure what is causing this. The columns I have are col-md-3, col-md-4 and col-md-5.

these are my cards

```<code><div class="row">
<div class="col-md-3">

 <div class="card mb-3">
  <div class="row no-gutters">
    <div class="col-md-4">
     <div class="img-container"><img src="https://cdn.myanimelist.net/images/anime/1517/100633l.jpg" class="card-img-top" class="card-img" alt="..."></div>
    </div>
    <div class="col-md-8">
      <div class="card-body">
        <h5 class="card-title">Attack on Titan</h5>
        <p class="card-text">Airs Sunday :: 10 eps</p>"
 <div class="col-md-4">

        <div class="card mb-3">
  <div class="row no-gutters">
    <div class="col-md-3">
     <div class="img-container"><img src="https://cdn.myanimelist.net/images/anime/1068/97169l.jpg" class="card-img-top" class="card-img" alt="..."></div>
    </div>
    <div class="col-md-8">
      <div class="card-body">
        <h5 class="card-title">The Rising of the Shield Hero</h5>
        <p class="card-text">Airs Wednesday :: 26 eps</p>

                <div class="status"></div>
      </div>
    </div>
  </div>
</div>
  </div>

 <div class="col-md-5">

        <div class="card mb-3">
  <div class="row no-gutters">
    <div class="col-md-3">
     <div class="img-container"><img src="https://cdn.myanimelist.net/images/anime/1130/99458l.jpg" class="card-img-top" class="card-img-top" class="card-img" alt="..."></div>
    </div>
    <div class="col-md-8">
      <div class="card-body">
        <h5 class="card-title">Hitori Bocchi no Maru Maru Seikatsu</h5>
        <p class="card-text">Airs Saturday :: 12 eps</p>
                <div class="status"></div>

      </div>
    </div>
  </div>
</code>```

I also added it to my codepen to better see also https://codepen.io/Shiro01/pen/YbRQmQ

I'm trying to get them similar to the cards on this site https://anichart.net/airing

I want to have the column fit the content and don't want the title breaking on to another line. I want the distance of the elements to be as equally spaced as possible so the whole design looks consistent. Thank you.

答:
```<code><div class="row outer_row">
<div class="col-md-4">
  <div class="row inside_row">
    <div class="col-sm-4">
      <div class="img-container">
        <img src="https://cdn.myanimelist.net/images/anime/1517/100633l.jpg" class="card-img-top" alt="..."></div>
</div>
    <div class="col-sm-6">
      <div class="card-data">
        <h5 class="card-title">Attack on Titan</h5>
        <p class="card-text">Airs Sunday :: 10 eps</p>
      </div>
    </div>
    <div class="col-sm-2">
      <div class="status"></div>
    </div>
  </div>
</div>
<div class="col-md-4">
  <div class="row inside_row">
    <div class="col-sm-4">
      <div class="img-container">
        <img src="https://cdn.myanimelist.net/images/anime/1517/100633l.jpg" class="card-img-top" class="card-img" alt="..."></div>
</div>
    <div class="col-sm-6">
      <div class="card-data">
        <h5 class="card-title">Attack on Titan</h5>
        <p class="card-text">Airs Sunday :: 10 eps</p>
      </div>
    </div>
    <div class="col-sm-2">
      <div class="status"></div>
    </div>
  </div>
</div>
<div class="col-md-4">
  <div class="row inside_row">
    <div class="col-sm-4">
      <div class="img-container">
        <img src="https://cdn.myanimelist.net/images/anime/1517/100633l.jpg" class="card-img-top" class="card-img" alt="..."></div>
</div>
    <div class="col-sm-6">
      <div class="card-data">
        <h5 class="card-title">Attack on Titan</h5>
        <p class="card-text">Airs Sunday :: 10 eps</p>
      </div>
    </div>
    <div class="col-sm-2">
      <div class="status"></div>
    </div>
  </div>
</div>
</code>```

here is css for HTML code :

```<code>body {
  padding: 70px;
}
.card-img-top {
   width: 100%;
  margin-left: -15px;
  height: 80px;
}
.status {
  background-color: #662481;
  height: 80px;
  width: 10px;
}

.card-data{
  margin-left:-30px;
  margin-top:6px;
}
.inside_row{
  width: 100%;
  border:1px solid lightgray;
  height:80px;
}
.outer_row{
  width: 100%;
}
</code>```

here is my solution for your question in a codepen https://codepen.io/nick4434/pen/joQGVM?editors=1100

Body:
I've just got back in to learning bootstrap, html and css. So far I have three cards in a row of different widths using the bootstrap grid the horizontal card template. My problem is that I want my layout to be the same in each card, The title and paragraph should be the same distance away in each and the fav / info button the same distance from the title. Also, I managed to get the first two columns close but somehow there is weird extra large spacing between the image and title of the last and largest column. How can I do this?

I've tried to manually adjust the positions of the elements in each card but it's hard to get them consistent, it also made my code a mess with extra ids for very similar things. As for the odd spacing I've tried to find the issue using developer tools on chrome to change the width, padding etc but not sure what is causing this. The columns I have are col-md-3, col-md-4 and col-md-5.

these are my cards

Attack on Titan

Airs Sunday :: 10 eps
"

The Rising of the Shield Hero

Airs Wednesday :: 26 eps

Hitori Bocchi no Maru Maru Seikatsu

Airs Saturday :: 12 eps

I also added it to my codepen to better see also https://codepen.io/Shiro01/pen/YbRQmQ

I'm trying to get them similar to the cards on this site https://anichart.net/airing

I want to have the column fit the content and don't want the title breaking on to another line. I want the distance of the elements to be as equally spaced as possible so the whole design looks consistent. Thank you.

Body:
<div class="row outer_row">
<div class="col-md-4">
  <div class="row inside_row">
    <div class="col-sm-4">
      <div class="img-container">
        <img src="https://cdn.myanimelist.net/images/anime/1517/100633l.jpg" class="card-img-top" alt="..."></div>
</div>
    <div class="col-sm-6">
      <div class="card-data">
        <h5 class="card-title">Attack on Titan</h5>
        <p class="card-text">Airs Sunday :: 10 eps</p>
      </div>
    </div>
    <div class="col-sm-2">
      <div class="status"></div>
    </div>
  </div>
</div>
<div class="col-md-4">
  <div class="row inside_row">
    <div class="col-sm-4">
      <div class="img-container">
        <img src="https://cdn.myanimelist.net/images/anime/1517/100633l.jpg" class="card-img-top" class="card-img" alt="..."></div>
</div>
    <div class="col-sm-6">
      <div class="card-data">
        <h5 class="card-title">Attack on Titan</h5>
        <p class="card-text">Airs Sunday :: 10 eps</p>
      </div>
    </div>
    <div class="col-sm-2">
      <div class="status"></div>
    </div>
  </div>
</div>
<div class="col-md-4">
  <div class="row inside_row">
    <div class="col-sm-4">
      <div class="img-container">
        <img src="https://cdn.myanimelist.net/images/anime/1517/100633l.jpg" class="card-img-top" class="card-img" alt="..."></div>
</div>
    <div class="col-sm-6">
      <div class="card-data">
        <h5 class="card-title">Attack on Titan</h5>
        <p class="card-text">Airs Sunday :: 10 eps</p>
      </div>
    </div>
    <div class="col-sm-2">
      <div class="status"></div>
    </div>
  </div>
</div>

here is css for HTML code :

body {
  padding: 70px;
}
.card-img-top {
   width: 100%;
  margin-left: -15px;
  height: 80px;
}
.status {
  background-color: #662481;
  height: 80px;
  width: 10px;
}

.card-data{
  margin-left:-30px;
  margin-top:6px;
}
.inside_row{
  width: 100%;
  border:1px solid lightgray;
  height:80px;
}
.outer_row{
  width: 100%;
}

here is my solution for your question in a codepen https://codepen.io/nick4434/pen/joQGVM?editors=1100


问:
use systemjs in a basic vanilla js page
I'm trying to use a chart component from Syncfusion in a simple application I'm developing.

It's pure JS, no Angular, no React, no TypeScript. I've not even used NPM

My problem is that I'm not able to import the necessary files to make the chart component works!

Following the documentation founded here
https://ej2.syncfusion.com/javascript/documentation/chart/es5-getting-started/

I've added a systemjs.config.js in my folder /_assets/systemjs.config.js and I've configured this way:

```<code>System.config({
    paths: {
        'syncfusion:': './_assets/vendors/Syncfusion/@syncfusion',
    },
    map: {
        app: 'app',

        //Syncfusion packages mapping
        "@syncfusion/ej2-base": "syncfusion:ej2-base/dist/ej2-base.umd.min.js",
        "@syncfusion/ej2-data": "syncfusion:ej2-data/dist/ej2-data.umd.min.js",
        "@syncfusion/ej2-charts": "syncfusion:ej2-charts/dist/ej2-charts.umd.min.js",
        "@syncfusion/ej2-popups": "syncfusion:ej2-popups/dist/ej2-popups.umd.min.js",
        "@syncfusion/ej2-buttons": "syncfusion:ej2-buttons/dist/ej2-buttons.umd.min.js",
        "@syncfusion/ej2-pdf-export": "syncfusion:ej2-pdf-export/dist/ej2-pdf-export.umd.min.js",
        "@syncfusion/ej2-file-utils": "syncfusion:ej2-file-utils/dist/ej2-file-utils.umd.min.js",
        "@syncfusion/ej2-compression": "syncfusion:ej2-compression/dist/ej2-compression.umd.min.js",
        "@syncfusion/ej2-navigations": "syncfusion:ej2-navigations/dist/ej2-navigations.umd.min.js",
        "@syncfusion/ej2-calendars": "syncfusion:ej2-calendars/dist/ej2-calendars.umd.min.js",
        "@syncfusion/ej2-lists": "syncfusion:ej2-lists/dist/ej2-lists.umd.min.js",
        "@syncfusion/ej2-inputs": "syncfusion:ej2-inputs/dist/ej2-inputs.umd.min.js",
        "@syncfusion/ej2-svg-base": "syncfusion:ej2-svg-base/dist/ej2-svg-base.umd.min.js",
        "@syncfusion/ej2-splitbuttons": "syncfusion:ej2-splitbuttons/dist/ej2-splitbuttons.umd.min.js"
        ,
    },
    packages: {
        'app': { main: 'app', defaultExtension: 'js' }
    }
});
</code>```

It talks about "app" but I don't have an app variable... I'm not using Angular neither React.

In the folder /_assets/vendors/Syncfusion/ I've inserted all the scripts files of Syncfusion:

Then in my HTML page I've added:

```<code><script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="/_assets/js/systemjs.config.js"></script>
</code>```

but when I run the page from the local dev web server I get:

Test:94 Uncaught ReferenceError: ej is not defined

答:
We have analyzed your query. If you want to load only chart scripts instead of loading entire scripts. You can refer the charts and its dependency scripts alone.

Please find the below code snippet to achieve this requirement,

```<code><head>
    <script src="http://cdn.syncfusion.com/ej2/ej2-base/dist/global/ej2-base.min.js"></script>
    <script src="http://cdn.syncfusion.com/ej2/ej2-data/dist/global/ej2-data.min.js"></script>
    <script src="http://cdn.syncfusion.com/ej2/ej2-svg-base/dist/global/ej2-svg-base.min.js"></script>
    <script src="http://cdn.syncfusion.com/ej2/ej2-charts/dist/global/ej2-charts.min.js"></script>
</head>

<body>
  <div id="container"></div>
  <script>
var chart = new ej.charts.Chart({
  // Other customization
});
chart.appendTo('#container');
</script>
</body>
</code>```

Sample for your reference can be found from below link,
chart sample

Kindly revert us, if you have any concerns.

Regards,
Baby.

Title: use systemjs in a basic vanilla js page

Body:
I'm trying to use a chart component from Syncfusion in a simple application I'm developing.

It's pure JS, no Angular, no React, no TypeScript. I've not even used NPM

My problem is that I'm not able to import the necessary files to make the chart component works!

Following the documentation founded here
https://ej2.syncfusion.com/javascript/documentation/chart/es5-getting-started/

I've added a systemjs.config.js in my folder /_assets/systemjs.config.js and I've configured this way:

System.config({
    paths: {
        'syncfusion:': './_assets/vendors/Syncfusion/@syncfusion',
    },
    map: {
        app: 'app',

        //Syncfusion packages mapping
        "@syncfusion/ej2-base": "syncfusion:ej2-base/dist/ej2-base.umd.min.js",
        "@syncfusion/ej2-data": "syncfusion:ej2-data/dist/ej2-data.umd.min.js",
        "@syncfusion/ej2-charts": "syncfusion:ej2-charts/dist/ej2-charts.umd.min.js",
        "@syncfusion/ej2-popups": "syncfusion:ej2-popups/dist/ej2-popups.umd.min.js",
        "@syncfusion/ej2-buttons": "syncfusion:ej2-buttons/dist/ej2-buttons.umd.min.js",
        "@syncfusion/ej2-pdf-export": "syncfusion:ej2-pdf-export/dist/ej2-pdf-export.umd.min.js",
        "@syncfusion/ej2-file-utils": "syncfusion:ej2-file-utils/dist/ej2-file-utils.umd.min.js",
        "@syncfusion/ej2-compression": "syncfusion:ej2-compression/dist/ej2-compression.umd.min.js",
        "@syncfusion/ej2-navigations": "syncfusion:ej2-navigations/dist/ej2-navigations.umd.min.js",
        "@syncfusion/ej2-calendars": "syncfusion:ej2-calendars/dist/ej2-calendars.umd.min.js",
        "@syncfusion/ej2-lists": "syncfusion:ej2-lists/dist/ej2-lists.umd.min.js",
        "@syncfusion/ej2-inputs": "syncfusion:ej2-inputs/dist/ej2-inputs.umd.min.js",
        "@syncfusion/ej2-svg-base": "syncfusion:ej2-svg-base/dist/ej2-svg-base.umd.min.js",
        "@syncfusion/ej2-splitbuttons": "syncfusion:ej2-splitbuttons/dist/ej2-splitbuttons.umd.min.js"
        ,
    },
    packages: {
        'app': { main: 'app', defaultExtension: 'js' }
    }
});

It talks about "app" but I don't have an app variable... I'm not using Angular neither React.

In the folder /_assets/vendors/Syncfusion/ I've inserted all the scripts files of Syncfusion:

Then in my HTML page I've added:

but when I run the page from the local dev web server I get:

Test:94 Uncaught ReferenceError: ej is not defined

Body:
We have analyzed your query. If you want to load only chart scripts instead of loading entire scripts. You can refer the charts and its dependency scripts alone.

Please find the below code snippet to achieve this requirement,

<head>
    <script src="http://cdn.syncfusion.com/ej2/ej2-base/dist/global/ej2-base.min.js"></script>
    <script src="http://cdn.syncfusion.com/ej2/ej2-data/dist/global/ej2-data.min.js"></script>
    <script src="http://cdn.syncfusion.com/ej2/ej2-svg-base/dist/global/ej2-svg-base.min.js"></script>
    <script src="http://cdn.syncfusion.com/ej2/ej2-charts/dist/global/ej2-charts.min.js"></script>
</head>

<body>
  <div id="container"></div>
  <script>
var chart = new ej.charts.Chart({
  // Other customization
});
chart.appendTo('#container');
</script>
</body>

Sample for your reference can be found from below link,
chart sample

Kindly revert us, if you have any concerns.

Regards,
Baby.


问:
The origin server did not find a current representation for the target resource or is not willing to disclose that one exists

web.xml

```<code>    <?xml version="1.0" encoding="UTF-8"?>
     <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
  <display-name>springsecuritydemo</display-name>
<!--   <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list> -->
  <servlet>
    <description></description>
    <display-name>offers</display-name>
    <servlet-name>offers</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
   <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>offers</servlet-name>
    <url-pattern>/DispatcherServlet</url-pattern>
  </servlet-mapping>
</web-app>
</code>```

offers-sevlet.xml

```<code>    <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns = "http://www.springframework.org/schema/beans"
   xmlns:context = "http://www.springframework.org/schema/context"
   xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
   xmlns:mvc="http://www.springframework.org/schema/mvc"
   xsi:schemaLocation = "http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
   http://www.springframework.org/schema/context
   http://www.springframework.org/schema/context/spring-context-4.3.xsd
   http://www.springframework.org/schema/mvc
   http://www.springframework.org/schema/mvc/spring-mvc.xsd">

   <context:component-scan base-package="com.spring.security.web"></context:component-scan>
   <mvc:annotation-driven></mvc:annotation-driven>

   <bean name="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/WEB-INF/jsps/"></property>
    <property name="suffix" value=".jsp"></property>
   </bean>

</beans>
</code>```

what is wrong here? i cannot access home.jsp.
i am actually watching a tutorial in spring 3.0 and i have done exactly shown in video. can anyone point my mistake here?

答:
There is one more way to solve this problem.
1)Go to Project Explorer. Go to the target folder of your project, right-click and delete the target folder.
2)Right-click on your project, select run as Maven Build.
3)After you get Build Success on the console; right click on the project folder and select refresh.
After performing the above steps, try to run your project.Your problem should be solved now.</p>

Body:
web.xml

    <?xml version="1.0" encoding="UTF-8"?>
     <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
  <display-name>springsecuritydemo</display-name>

  <servlet>
    <description></description>
    <display-name>offers</display-name>
    <servlet-name>offers</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
   <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>offers</servlet-name>
    <url-pattern>/DispatcherServlet</url-pattern>
  </servlet-mapping>
</web-app>

offers-sevlet.xml

    <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns = "http://www.springframework.org/schema/beans"
   xmlns:context = "http://www.springframework.org/schema/context"
   xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
   xmlns:mvc="http://www.springframework.org/schema/mvc"
   xsi:schemaLocation = "http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
   http://www.springframework.org/schema/context
   http://www.springframework.org/schema/context/spring-context-4.3.xsd
   http://www.springframework.org/schema/mvc
   http://www.springframework.org/schema/mvc/spring-mvc.xsd">

   <context:component-scan base-package="com.spring.security.web"></context:component-scan>
   <mvc:annotation-driven></mvc:annotation-driven>

   <bean name="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/WEB-INF/jsps/"></property>
    <property name="suffix" value=".jsp"></property>
   </bean>

</beans>

what is wrong here? i cannot access home.jsp.
i am actually watching a tutorial in spring 3.0 and i have done exactly shown in video. can anyone point my mistake here?


问:
Swagger Param Documentation
Current State:

I have two methods in my controller to get data based on what parameters are passed.  The code:

```<code>@RestController
@RequestMapping("/samples")
public class SampleController {

    @RequestMapping(value = "/{id}", params = {"cost"}, method = RequestMethod.GET)
    public String getSamplesByIdAndCost(@PathVariable String id, @RequestParam(value = "cost") String cost) {
        return "result";
    }

    @RequestMapping(value = "/{id}", params = {"cost", "size"}, method = RequestMethod.GET)
    public String getSamplesByIdCostAndSize(@PathVariable String id, @RequestParam(value = "cost") String cost,
                                        @RequestParam(value = "size") String size) {
    return "ID : " + id + " / COST : " + cost + " / SIZE : " + size;
    }
}
</code>```

Everything works fine, but the swagger documentation is not what I expected.

Question

Is there a way to remove {?size,cost} from the Request URL?

Here is my Docket info:

```<code>@Bean
    public Docket myApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.any())
                .build()
                .pathMapping("/")
                .directModelSubstitute(LocalDate.class,
                        String.class)
                .genericModelSubstitutes(ResponseEntity.class)
                .alternateTypeRules(
                        newRule(typeResolver.resolve(DeferredResult.class,
                                typeResolver.resolve(ResponseEntity.class, WildcardType.class)),
                                typeResolver.resolve(WildcardType.class)))
                .useDefaultResponseMessages(false)
                .globalResponseMessage(RequestMethod.GET,
                        newArrayList(new ResponseMessageBuilder()
                                .code(500)
                                .message("500 message")
                                .responseModel(new ModelRef("Error"))
                                .build()))
                .enableUrlTemplating(true);

    }

    @Autowired
    TypeResolver typeResolver;

    @Bean
    UiConfiguration uiConfig() {
        return new UiConfiguration(
                "validatorUrl",// url
                "none",       // docExpansion          => none | list
                "alpha",      // apiSorter             => alpha
                "schema",     // defaultModelRendering => schema
                UiConfiguration.Constants.DEFAULT_SUBMIT_METHODS,
                false,        // enableJsonEditor      => true | false
                true);        // showRequestHeaders    => true | false
    }
</code>```

答:
you can change maven pom

```<code><dependency>
    <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger2</artifactId>
        <version>2.9.2</version>
    </dependency>
 <dependency>
    <groupId>io.springfox.ui</groupId>
        <artifactId>springfox-swagger-ui-rfc6570</artifactId>
        <version>1.0.0</version>
</dependency>
</code>```

use springfox-swagger-ui-rfc6570 instead of springfox-swagger-ui

Click here to see more.

Title: Swagger Param Documentation

Body:
Current State:

I have two methods in my controller to get data based on what parameters are passed.  The code:

@RestController
@RequestMapping("/samples")
public class SampleController {

    @RequestMapping(value = "/{id}", params = {"cost"}, method = RequestMethod.GET)
    public String getSamplesByIdAndCost(@PathVariable String id, @RequestParam(value = "cost") String cost) {
        return "result";
    }

    @RequestMapping(value = "/{id}", params = {"cost", "size"}, method = RequestMethod.GET)
    public String getSamplesByIdCostAndSize(@PathVariable String id, @RequestParam(value = "cost") String cost,
                                        @RequestParam(value = "size") String size) {
    return "ID : " + id + " / COST : " + cost + " / SIZE : " + size;
    }
}

Everything works fine, but the swagger documentation is not what I expected.

Question

Is there a way to remove {?size,cost} from the Request URL?

Here is my Docket info:

@Bean
    public Docket myApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.any())
                .build()
                .pathMapping("/")
                .directModelSubstitute(LocalDate.class,
                        String.class)
                .genericModelSubstitutes(ResponseEntity.class)
                .alternateTypeRules(
                        newRule(typeResolver.resolve(DeferredResult.class,
                                typeResolver.resolve(ResponseEntity.class, WildcardType.class)),
                                typeResolver.resolve(WildcardType.class)))
                .useDefaultResponseMessages(false)
                .globalResponseMessage(RequestMethod.GET,
                        newArrayList(new ResponseMessageBuilder()
                                .code(500)
                                .message("500 message")
                                .responseModel(new ModelRef("Error"))
                                .build()))
                .enableUrlTemplating(true);

    }

    @Autowired
    TypeResolver typeResolver;

    @Bean
    UiConfiguration uiConfig() {
        return new UiConfiguration(
                "validatorUrl",// url
                "none",       // docExpansion          => none | list
                "alpha",      // apiSorter             => alpha
                "schema",     // defaultModelRendering => schema
                UiConfiguration.Constants.DEFAULT_SUBMIT_METHODS,
                false,        // enableJsonEditor      => true | false
                true);        // showRequestHeaders    => true | false
    }

Body:
you can change maven pom

<dependency>
    <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger2</artifactId>
        <version>2.9.2</version>
    </dependency>
 <dependency>
    <groupId>io.springfox.ui</groupId>
        <artifactId>springfox-swagger-ui-rfc6570</artifactId>
        <version>1.0.0</version>
</dependency>

use springfox-swagger-ui-rfc6570 instead of springfox-swagger-ui

Click here to see more.


问:
NSString stringWithContentsOfURL is deprecated. What should I do?
I've written some code that uses stringWithContentsOfURL, but it turns out that it is now deprecated. Can you help me replace it? Here's my code:

```<code>NSString *locationString = [NSString stringWithContentsOfURL:[NSURL URLWithString:urlString]];
NSArray *listItems = [locationString componentsSeparatedByString:@","];
</code>```

Additionally, can someone have some sample code to show how it works? What encoding was the original code done in (in my 2 lines above)?

I want to maintain compatibility so what should I choose for the encoding? What does error mean and what is it used for?

答:
The NSString reference says this:

Use stringWithContentsOfURL:encoding:error: or stringWithContentsOfURL:usedEncoding:error: instead.

Body:
I've written some code that uses stringWithContentsOfURL, but it turns out that it is now deprecated. Can you help me replace it? Here's my code:

NSString *locationString = [NSString stringWithContentsOfURL:[NSURL URLWithString:urlString]];
NSArray *listItems = [locationString componentsSeparatedByString:@","];

Additionally, can someone have some sample code to show how it works? What encoding was the original code done in (in my 2 lines above)?

I want to maintain compatibility so what should I choose for the encoding? What does error mean and what is it used for?


问:
CellValuePropertyFactory in TableColumn cannot be applied
So i'm trying to populate a TableView, but the problem is that I can't set the CellValueFactoryProperty, it says it cannot be applied, I've tried to look it up but i'm probably messing up in some point, because I don't seem to find the answer, or even the same error.

PD: I'm using JPA and Hibernate, don't think that matters tho.

This is the problem:

```<code>private void fillTable() {

colID.cellValueFactoryProperty(new PropertyValueFactory<Alumnos, Integer>
("ID"));

}
</code>```

Here are my columns:

```<code>@FXML
private TableColumn<Alumnos, Integer> colID;

@FXML
private TableColumn<Alumnos, String> colNombre;
</code>```

And this is basically my Alumnos class:

```<code>@Entity
public class Alumnos {
    private int aluId;
    private String aluNom;
</code>```

I only expect to be able to set the CellValueFactoryProperty right.

答:
The answer is the first comment, I'll post it here to help fellow coders.

You're trying to pass the value to the property getter method. This method does not take parameters though. Either do colID.cellValueFactoryProperty().set(new PropertyValueFactory<>("ID")); or better colID.setCellValueFactoryProperty(new PropertyValueFactory<>("ID"));

So just substitute

```<code>colID.cellValueFactoryProperty(new PropertyValueFactory<Alumnos, Integer>("ID"));
</code>```

to:

```<code>colID.setCellValueFactoryProperty(new PropertyValueFactory<Alumnos, Integer>("ID"));
</code>```

Credits to @fabian.
Thank you.

Body:
So i'm trying to populate a TableView, but the problem is that I can't set the CellValueFactoryProperty, it says it cannot be applied, I've tried to look it up but i'm probably messing up in some point, because I don't seem to find the answer, or even the same error.

PD: I'm using JPA and Hibernate, don't think that matters tho.

This is the problem:

private void fillTable() {

colID.cellValueFactoryProperty(new PropertyValueFactory<Alumnos, Integer>
("ID"));

}

Here are my columns:

@FXML
private TableColumn<Alumnos, Integer> colID;

@FXML
private TableColumn<Alumnos, String> colNombre;

And this is basically my Alumnos class:

@Entity
public class Alumnos {
    private int aluId;
    private String aluNom;

I only expect to be able to set the CellValueFactoryProperty right.

Body:
The answer is the first comment, I'll post it here to help fellow coders.

You're trying to pass the value to the property getter method. This method does not take parameters though. Either do colID.cellValueFactoryProperty().set(new PropertyValueFactory<>("ID")); or better colID.setCellValueFactoryProperty(new PropertyValueFactory<>("ID"));

So just substitute

colID.cellValueFactoryProperty(new PropertyValueFactory<Alumnos, Integer>("ID"));

to:

colID.setCellValueFactoryProperty(new PropertyValueFactory<Alumnos, Integer>("ID"));

Credits to @fabian.
Thank you.


问:
Popup notifiers in C/C++
I've been working on a project that will need a notifier in the system tray (sorry, "System Notification Area"). It will be a simple app that just generates popup notifications when it receives a message via a Zeromq socket.

I am not having any luck finding anything other than .NET resources and examples. Does anyone have a sample in C/C++?

答:
I would start with this section of MSDN: Notifications and the Notification Area.

Then I'd check the NotificationIcon Sample in the Windows SDK.

Title: Popup notifiers in C/C++


问:
How to set an initial/default value for the array used by <FieldArray/>?
I have been creating a form with react-final form. This form has some conditional fields, that only display when a user clicks a checkbox. If the checkbox is checked, then a  component is rendered.

It is very similar to the example they provide in the documentation, which you can see here. https://codesandbox.io/s/kx8qv67nk5

I am basing myself off that example, and i can add to the field array with a button that calls the push method, exactly as in the example.

What i would like to do is not have to push a button in order to push that object into the array, but rather have the array default already include one object inside.

in other words,

In the example provided, the array starts empty and you push() into the array,the fields that are defined within

How can i have it default to already having one object by default instead of manually pushing it?

Im not sure where that array is getting defined or initialized.

答:
You can use "initialValues"

Example :

```<code>import { Form } from "react-final-form";
...
myInitData = {
    firstName: "hello",
    lastName: "world"
}
...
render() {
    return
        <Form
            initialValues={myInitData}
            onSubmit={this.handleSubmit}
            validate={this.validate}
          >...
</code>```

Body:
You can use "initialValues"

Example :

import { Form } from "react-final-form";
...
myInitData = {
    firstName: "hello",
    lastName: "world"
}
...
render() {
    return
        <Form
            initialValues={myInitData}
            onSubmit={this.handleSubmit}
            validate={this.validate}
          >...


问:
Angular Material Snackbar Change Color
I'm using Angular 7 with Material Snackbar. I want to changes the color of Snackbar to green.

In app.component.ts, I have:

```<code>this.snackBarRef = this.snackBar.open(result.localized_message, 'X', {
    duration: 4000,
    verticalPosition: 'top',
    panelClass: 'notif-success'
});

this.snackBarRef.onAction().subscribe(() => {
    this.snackBarRef.dismiss();
});
</code>```

In app.component.scss, I have:

```<code>.notif-success {
    color: #155724 !important; // green
    background-color: #d4edda !important;
    border-color: #c3e6cb !important;
    .mat-simple-snackbar-action {
        color: #155724 !important;
    }
}
</code>```

But the Snackbar is still shown in its default colors.

I can see that the notif-success class has been applied to the snackbar

```<code><snack-bar-container class="mat-snack-bar-container ng-tns-c18-84 ng-trigger ng-trigger-state notif-success mat-snack-bar-center mat-snack-bar-top ng-star-inserted" role="status" style="transform: scale(1); opacity: 1;">
</code>```

Why is the custom css not working?

答:
You should write that .notif-success CSS class on your main styles.scss, instead of the app.component.scss.

If you are wondering, it is the one which is on the same directory level as your index.html, package.json, etc.

Title: Angular Material Snackbar Change Color

Body:
I'm using Angular 7 with Material Snackbar. I want to changes the color of Snackbar to green.

In app.component.ts, I have:

this.snackBarRef = this.snackBar.open(result.localized_message, 'X', {
    duration: 4000,
    verticalPosition: 'top',
    panelClass: 'notif-success'
});

this.snackBarRef.onAction().subscribe(() => {
    this.snackBarRef.dismiss();
});

In app.component.scss, I have:

.notif-success {
    color: #155724 !important; // green
    background-color: #d4edda !important;
    border-color: #c3e6cb !important;
    .mat-simple-snackbar-action {
        color: #155724 !important;
    }
}

But the Snackbar is still shown in its default colors.

I can see that the notif-success class has been applied to the snackbar

<snack-bar-container class="mat-snack-bar-container ng-tns-c18-84 ng-trigger ng-trigger-state notif-success mat-snack-bar-center mat-snack-bar-top ng-star-inserted" role="status" style="transform: scale(1); opacity: 1;">

Why is the custom css not working?


问:
Netbeans 6.9 support for HAML and SASS?
It doesn't seem to be any HAML and SASS support in Netbeans 6.9.

Is there a way to add this support?

Thanks

答:
There's an haml plugin that needs some teaks in order to change the default colors:
How to change color of HAML tags in NetBeans?</p>

ContentLicense: CC BY-SA 2.5

Title: Netbeans 6.9 support for HAML and SASS?


问:
How to upload a picture in python selennium with a complicated HTML situation
I'm setting up a automatisation of a upload process of a website and I am struggeling right now with uploading a picture.

Normally you would use

uploadBtn.send_keys(Path)
```

<p>, but the image would just not upload. I have also been trying to implement some Javascript, so I added an attribute "type=file"</p>

<p>My Python code:</p>

<pre class="lang-py prettyprint-override"><code>uploadInput = driver.find_element_by_xpath("//a[contains(.,\"Browse\")]")#
jsSetAttributeFileInput = "arguments[0].setAttribute(\"type\",\"file\")"
driver.execute_script(jsSetAttributeFileInput, uploadInput)
uploadInput.send_keys(design["DesignPath"])
</code>```

The HTML of the Website:

```<code><a href="javascript:void(0)"> Browse </a>
</code>```

I expect the result to upload my picture, but it just does not upload it. I don't get any errors, but it's just not uploading. I think it has something to do with the HTML, because it is an 'a'-tag instead of an 'input'-tag

答:
Try this:

```<code>uploadInput = driver.find_element_by_xpath("//a[contains(.,\"Browse\")]")
uploadInput.send_keys(os.getcwd()+"/image.png")
</code>```

and find your submit button and click it.

Where os.getcwd() returns the current working directory. image.png is located right next to the running script in the same directory

Body:
I'm setting up a automatisation of a upload process of a website and I am struggeling right now with uploading a picture.

Normally you would use

uploadBtn.send_keys(Path)

, but the image would just not upload. I have also been trying to implement some Javascript, so I added an attribute "type=file"

My Python code:

uploadInput = driver.find_element_by_xpath("//a[contains(.,\"Browse\")]")#
jsSetAttributeFileInput = "arguments[0].setAttribute(\"type\",\"file\")"
driver.execute_script(jsSetAttributeFileInput, uploadInput)
uploadInput.send_keys(design["DesignPath"])

The HTML of the Website:

 Browse

I expect the result to upload my picture, but it just does not upload it. I don't get any errors, but it's just not uploading. I think it has something to do with the HTML, because it is an 'a'-tag instead of an 'input'-tag

Body:
Try this:

uploadInput = driver.find_element_by_xpath("//a[contains(.,\"Browse\")]")
uploadInput.send_keys(os.getcwd()+"/image.png")

and find your submit button and click it.

Where os.getcwd() returns the current working directory. image.png is located right next to the running script in the same directory


问:
How to print prime numbers in specific format
I have to ask the user to input a number, and print out the prime factors.

However, this is DIFFERENT from other prime-factor codes as I need to print it in a specific format.

If the user inputs 27, I have to print out

3^3

if the use inputs 28, I have to print out

2^2*7

I know how to print out just the prime factors, so that if the user inputs 27, it would print out

3 3 3

However, I have a hard time trying to figure out how to put in the ^ sign in and the * sign. I figured I would have to count the numbers that are the same and make an if loop(possibly), but I have no clue as to how to do that.

```<code>import java.util.*;

public class Prime{
   public static void main(String[] args) {
      Scanner input= new Scanner (System.in);

      System.out.println("Enter a number");
      int num= input.nextInt();
      String prim = "";

      for (int i = 2; i <= num ; i++) {
         while (num % i == 0) {
            prim += i + " ";
            num /= i;
         }
      }

      System.out.println("Prime factors are: " + prim);

   }

}
</code>```

The code above just prints out the factors, and what I have to do right now is change the format using ^ and *.

Can anyone help me out?

Any help is appreciated.

答:
Use a HashSet to find the unique members in your list, and Collections.frequency() to count how often an element occurs in the list you already have. Then you're basically there.

```<code>import java.util.*;

public class Prime{
   public static void main(String[] args) {
      Scanner input= new Scanner (System.in);

      System.out.println("Enter a number");
      int num= input.nextInt();
      String prim = "";
      ArrayList<Integer> l = new ArrayList<Integer>();

      for (int i = 2; i <= num ; i++) {
         while (num % i == 0) {
            l.add(i);
            num /= i;
         }
      }

      Set<Integer> s = new HashSet<>(l);
      for (int i : s){
          if (prim.length() > 0){
              prim += " * ";
          }
          int power = Collections.frequency(l, i);
          prim += i;
          if (power > 1){
              prim += "^" + power;
          }
      }

      System.out.println("Prime factors as list: " + l);
      System.out.println("Prime factors as formula: " + prim);
   }

}
</code>```

Output for 28:

```<code>Prime factors as list: [2, 2, 7]
Prime factors as formula: 2^2 * 7
</code>```

Body:
I have to ask the user to input a number, and print out the prime factors.

However, this is DIFFERENT from other prime-factor codes as I need to print it in a specific format.

If the user inputs 27, I have to print out

3^3

if the use inputs 28, I have to print out

2^2*7

I know how to print out just the prime factors, so that if the user inputs 27, it would print out

3 3 3

However, I have a hard time trying to figure out how to put in the ^ sign in and the * sign. I figured I would have to count the numbers that are the same and make an if loop(possibly), but I have no clue as to how to do that.

import java.util.*;

public class Prime{
   public static void main(String[] args) {
      Scanner input= new Scanner (System.in);

      System.out.println("Enter a number");
      int num= input.nextInt();
      String prim = "";

      for (int i = 2; i <= num ; i++) {
         while (num % i == 0) {
            prim += i + " ";
            num /= i;
         }
      }

      System.out.println("Prime factors are: " + prim);

   }

}

The code above just prints out the factors, and what I have to do right now is change the format using ^ and *.

Can anyone help me out?

Any help is appreciated.

Body:
Use a HashSet to find the unique members in your list, and Collections.frequency() to count how often an element occurs in the list you already have. Then you're basically there.

import java.util.*;

public class Prime{
   public static void main(String[] args) {
      Scanner input= new Scanner (System.in);

      System.out.println("Enter a number");
      int num= input.nextInt();
      String prim = "";
      ArrayList<Integer> l = new ArrayList<Integer>();

      for (int i = 2; i <= num ; i++) {
         while (num % i == 0) {
            l.add(i);
            num /= i;
         }
      }

      Set<Integer> s = new HashSet<>(l);
      for (int i : s){
          if (prim.length() > 0){
              prim += " * ";
          }
          int power = Collections.frequency(l, i);
          prim += i;
          if (power > 1){
              prim += "^" + power;
          }
      }

      System.out.println("Prime factors as list: " + l);
      System.out.println("Prime factors as formula: " + prim);
   }

}

Output for 28:

Prime factors as list: [2, 2, 7]
Prime factors as formula: 2^2 * 7


问:
IIS URL Rewrite Rule Excluding Multiple Files
I have an IIS URL Rewrite rule that forces HTTPS unless that page is a healthcheck.html (which is over port 80). This works like a charm as I use the match URL logic as follows:

```<code><match url="healthcheck.html" negate="true" />
</code>```

However, I need to exclude not just this page but a second file named OtherCheck.aspx in a directory named Dir1

I have not found any instances where others have excluded two files, especially one that is not in the root. Is it possible to have two filename exclusions? I tried this but it did not work:

```<code><match url="healthcheck.html&/Dir1/OtherCheck.aspx" negate="true" />
</code>```

答:
File and folder structure:
    s1(root folder):

healthcheck.html(file)

s2(subfolder):

page1.html(file)

You could use below url rewrite rule to exclude multiple files:

```<code> <rule name="Redirect to HTTPS multiple file" enabled="true" stopProcessing="true">
     <match url="(.*)" />
     <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                    <add input="{HTTPS}" pattern="off" />
                    <add input="{REQUEST_URI}" pattern="^/healthcheck.html" negate="true" />
                    <add input="{REQUEST_URI}" pattern="^/s2/page1.html" negate="true" />
     </conditions>
     <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Found" />
   </rule>
</code>```

https redirect:

exclude file:

Note:
You could set file and folder name as per your requirement.

Regards,
Jalpa

Body:
I have an IIS URL Rewrite rule that forces HTTPS unless that page is a healthcheck.html (which is over port 80). This works like a charm as I use the match URL logic as follows:

<match url="healthcheck.html" negate="true" />

However, I need to exclude not just this page but a second file named OtherCheck.aspx in a directory named Dir1

I have not found any instances where others have excluded two files, especially one that is not in the root. Is it possible to have two filename exclusions? I tried this but it did not work:

<match url="healthcheck.html&/Dir1/OtherCheck.aspx" negate="true" />

Body:
File and folder structure:
    s1(root folder):

healthcheck.html(file)

s2(subfolder):

page1.html(file)

You could use below url rewrite rule to exclude multiple files:

 <rule name="Redirect to HTTPS multiple file" enabled="true" stopProcessing="true">
     <match url="(.*)" />
     <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                    <add input="{HTTPS}" pattern="off" />
                    <add input="{REQUEST_URI}" pattern="^/healthcheck.html" negate="true" />
                    <add input="{REQUEST_URI}" pattern="^/s2/page1.html" negate="true" />
     </conditions>
     <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Found" />
   </rule>

https redirect:

exclude file:

Note:
You could set file and folder name as per your requirement.

Regards,
Jalpa


问:
cassandra vs elastic search vs any other design suggestions
We have a need to run analytics queries on the data stored in rds. And that's becoming very very slow because of group by queries and ever increasing size of the tables.
For example we have following 3 tables in RDS :

```<code>alm(id,name,cli, group_id, con_id ...)
group(id, type,timestamp ...)
con(id,ip,port ...)
</code>```

each of the tables have very high amount of data and are being updated several times a minute as the new data comes in.

Now we want to run aggregation queries like :

```<code>select name from alm, group, con where alm.group_id=group.id and alm.con_id=con.id group by name, group.type, con.ip
</code>```

We also want users to run custom aggregation queries in the future as opposed to the fix query provided by us in future.

So far the options we are considering are moving to either Cassandra, Elasticsearch or Dynamo db so that aggregation would be faster. Can someone guide as to how to go about this problem ? Or any crumbs of experience ? Anybody know any technologies have severe advantage over others ?

答:
Cassandra and DynamoDB are quite different from ElasticSearch. And all three are very different from relational database offerings.

For ad-hoc analytics, relational databases, with a well designed schema, can be pretty good up to the point where you need to split your data across multiple servers (then replication issues start to dominate the benefits). And that's really the primary motivation for non-relational databases. But the catch is that in order to solve the horizontal scaling problem, they generally trade some features such as joining and aggregating.

Elastic search is really great at answering search queries, but not particularly good at aggregations (other than very basic counts, sums and their estimates). It's amazing at indexing copious amounts of data but it can't answer queries that require complex cross index operations. It is also not as robust (rebuilding indexes may be needed from time to time)

If you have high volumes of data and you need aggregation, you pretty much have two options:

if you can get away with offline analytics, then distributed data processing frameworks such as Spark can get you the answers you need very efficiently

if you need online analytics, the most common approach is to pre-compute the aggregations and update as you get more data, so that answers to queries can be very fast without having to process a lot of data for each query

Don't be afraid to mix and match though. Relational databases have their purpose as do non-relationals. There is no silver bullet though.

Body:
We have a need to run analytics queries on the data stored in rds. And that's becoming very very slow because of group by queries and ever increasing size of the tables.
For example we have following 3 tables in RDS :

alm(id,name,cli, group_id, con_id ...)
group(id, type,timestamp ...)
con(id,ip,port ...)

each of the tables have very high amount of data and are being updated several times a minute as the new data comes in.

Now we want to run aggregation queries like :

select name from alm, group, con where alm.group_id=group.id and alm.con_id=con.id group by name, group.type, con.ip

We also want users to run custom aggregation queries in the future as opposed to the fix query provided by us in future.

So far the options we are considering are moving to either Cassandra, Elasticsearch or Dynamo db so that aggregation would be faster. Can someone guide as to how to go about this problem ? Or any crumbs of experience ? Anybody know any technologies have severe advantage over others ?


问:
Dart: Get POST parameters on server side
I send some data from client side using POST request

```<code>var value = new Map<String, String>();
value["param1"] = 'value1';
value["param2"] = 'value2';
value["param3"] = 'value3';

HttpRequest.postFormData('http://localhost:8080/', value);
</code>```

and try to get this data on the server side:

```<code>HttpServer.bind(InternetAddress.ANY_IP_V6, 8080).then((server) {
    server.listen((HttpRequest request) {
        //TODO: process POST request
    });
});
</code>```

But how can I get POST values from the request as Map< string, string>?

upd 1

But as I see result of

```<code>var jsonString = await request.transform(UTF8.decoder).join();
</code>```

depends on type of post message. If I change it result will be

multipart/form-data

```<code>------WebKitFormBoundaryoQQD7N0iA5zS8qmg
Content-Disposition: form-data; name="param1"

value 1
------WebKitFormBoundaryoQQD7N0iA5zS8qmg
Content-Disposition: form-data; name="param2"

value 2
------WebKitFormBoundaryoQQD7N0iA5zS8qmg
Content-Disposition: form-data; name="param3"

value 3
------WebKitFormBoundaryoQQD7N0iA5zS8qmg--
</code>```

text/plain

```<code>param1=value 1
param2=value 2
param3=value 3
</code>```

application/x-www-form-urlencoded

```<code>param1=value+1&param2=value+2&param3=value+3
</code>```

As I have already asked how can I convert it to Map< string, string>?

答:
I have the same question, and I didn't find any solution until now. I need to pass a map from client to server, and server to use that map to interrogate a mongodb database. Client send that map, but server receive a string. Any conversion to json return also string, not a map.
On the client side I send a map named query:

```<code>await HttpRequest.postFormData('http://localhost:8085/$_coll',query).then((HttpRequest response)
</code>```

On the server side :

```<code>if (request.method == 'POST') {

   query = await request.transform(utf8.decoder).join();
}
</code>```

I've tried to encode/decode to json, but with no success.

Body:
I send some data from client side using POST request

var value = new Map<String, String>();
value["param1"] = 'value1';
value["param2"] = 'value2';
value["param3"] = 'value3';

HttpRequest.postFormData('http://localhost:8080/', value);

and try to get this data on the server side:

HttpServer.bind(InternetAddress.ANY_IP_V6, 8080).then((server) {
    server.listen((HttpRequest request) {
        //TODO: process POST request
    });
});

But how can I get POST values from the request as Map< string, string>?

upd 1

But as I see result of

var jsonString = await request.transform(UTF8.decoder).join();

depends on type of post message. If I change it result will be

multipart/form-data

------WebKitFormBoundaryoQQD7N0iA5zS8qmg
Content-Disposition: form-data; name="param1"

value 1
------WebKitFormBoundaryoQQD7N0iA5zS8qmg
Content-Disposition: form-data; name="param2"

value 2
------WebKitFormBoundaryoQQD7N0iA5zS8qmg
Content-Disposition: form-data; name="param3"

value 3
------WebKitFormBoundaryoQQD7N0iA5zS8qmg--

text/plain

param1=value 1
param2=value 2
param3=value 3

application/x-www-form-urlencoded

param1=value+1&param2=value+2&param3=value+3

As I have already asked how can I convert it to Map< string, string>?

Body:
I have the same question, and I didn't find any solution until now. I need to pass a map from client to server, and server to use that map to interrogate a mongodb database. Client send that map, but server receive a string. Any conversion to json return also string, not a map.
On the client side I send a map named query:

await HttpRequest.postFormData('http://localhost:8085/$_coll',query).then((HttpRequest response)

On the server side :

if (request.method == 'POST') {

   query = await request.transform(utf8.decoder).join();
}

I've tried to encode/decode to json, but with no success.


问:
Check if git status is clean inside a Powershell script
I'm developing a Powershell script for create a program release.
In order to do it I want to check if the git working tree is clean and there are no uncommitted changes.

I've read this post but it's related to bash.

How can I check from inside a powershell script if the git working tree is clean and there's anything to commit? I don't care about untracked files.

I've tried something like

```<code>  $gitOutput = (git status -z) | Out-String
  if ($gitOutput) {
    "output"
  } else {
    "no Output"
  }
</code>```

The problem is that I print output also when everything is committed but there are some untracked files, that's something that I'd like to avoid. I want to ignore untracked files and check only if all tracked files are committed.

答:
I found one another solution using git status --porcelain.

```<code>$ChangedFiles = $(git status --porcelain | Measure-Object | Select-Object -expand Count)
if ($ChangedFiles -gt 0)
{
    Write-Output "Found $ChangedFiles changed files"
}
</code>```

Body:
I'm developing a Powershell script for create a program release.
In order to do it I want to check if the git working tree is clean and there are no uncommitted changes.

I've read this post but it's related to bash.

How can I check from inside a powershell script if the git working tree is clean and there's anything to commit? I don't care about untracked files.

I've tried something like

  $gitOutput = (git status -z) | Out-String
  if ($gitOutput) {
    "output"
  } else {
    "no Output"
  }

The problem is that I print output also when everything is committed but there are some untracked files, that's something that I'd like to avoid. I want to ignore untracked files and check only if all tracked files are committed.

Body:
I found one another solution using git status --porcelain.

$ChangedFiles = $(git status --porcelain | Measure-Object | Select-Object -expand Count)
if ($ChangedFiles -gt 0)
{
    Write-Output "Found $ChangedFiles changed files"
}


问:
Spring Data - How to reuse repository in repository fragment?
Update: the following is using Spring Boot 2.1.0

I have a Spring Data repository and I am trying to provide some custom functionality to it, following the fragments example from the documentation.

So I've added an extra interface to the repository:

```<code>public interface UserRepository extends JpaRepository<User, Long>, UserExtraLogic {
    User findByFirstNameAndLastName(String firstName, String lastName);
}
</code>```

with this custom interface:

```<code>interface UserExtraLogic {
    void ensureHasAccess();
}
</code>```

and its implementation:

```<code>class UserExtraLogicImpl implements UserExtraLogic {
    public void ensureHasAccess() {
    }
}
</code>```

The problem is that I would like to be able to use my repositories inside UserExtraLogicImpl, so that I can reuse query methods like findByFirstNameAndLastName without having to write them by myself with EntityManager. So I tried this:

```<code>class UserExrtaLogicImpl implements UserExtraLogic {
    @Autowired
    private UserRepository userRepository;
}
</code>```

But then the application does not start. I get a NullPointerException, but I think it's just Spring getting into a cycle trying to resolve these dependencies.

Is what I'm trying to do possible? Is there another way to do this?

答:
You can lazily load your repository with ObjectFactory<T> (Spring concept) or Provider<T> (standard java api).

```<code>class UserExrtaLogicImpl implements UserExtraLogic {
    @Autowired
    private ObjectFactory<UserRepository> userRepository;

    public void soSomething() {
         userRepository().getObject().findById(xxx);
    }
}
</code>```

Body:
Update: the following is using Spring Boot 2.1.0

I have a Spring Data repository and I am trying to provide some custom functionality to it, following the fragments example from the documentation.

So I've added an extra interface to the repository:

public interface UserRepository extends JpaRepository<User, Long>, UserExtraLogic {
    User findByFirstNameAndLastName(String firstName, String lastName);
}

with this custom interface:

interface UserExtraLogic {
    void ensureHasAccess();
}

and its implementation:

class UserExtraLogicImpl implements UserExtraLogic {
    public void ensureHasAccess() {
    }
}

The problem is that I would like to be able to use my repositories inside UserExtraLogicImpl, so that I can reuse query methods like findByFirstNameAndLastName without having to write them by myself with EntityManager. So I tried this:

class UserExrtaLogicImpl implements UserExtraLogic {
    @Autowired
    private UserRepository userRepository;
}

But then the application does not start. I get a NullPointerException, but I think it's just Spring getting into a cycle trying to resolve these dependencies.

Is what I'm trying to do possible? Is there another way to do this?

Body:
You can lazily load your repository with ObjectFactory<T> (Spring concept) or Provider<T> (standard java api).

class UserExrtaLogicImpl implements UserExtraLogic {
    @Autowired
    private ObjectFactory<UserRepository> userRepository;

    public void soSomething() {
         userRepository().getObject().findById(xxx);
    }
}


问:
single paging page size in operating system
In our exam the question was asked, and I couldn't answer it. However, I wonder its answer.

If there exist 2^N bit virtual addressing, 2^M bit physical
  addressing and 2^L kb page size. In single paging, what is the page
  size?

答:
This is unanswerable unless you make random/unfounded assumptions.

For a silly example, you could assume that there are only 2 physical pages and only one virtual page (M == N-1), and that the page table is the same size as a page (and only has one page table entry) and therefore a page table entry consumes 2^L bits where one of these bits are used to select the physical page and all of the other bits are used for other purposes (access permissions, tracking accessed/dirty, spare bits for the OS to use however it likes, ...).


问:
Control no longer gaining focus after putting it in a splitcontainer
I have a forms app and when it starts up I would like it to give focus to a particular text box. While I was initially developing I just whacked all the controls straight on the form and the focus command worked fine.

The app is near ready and I put some splitcontainers on the form just to hold the controls in neatly defined areas using their Dock properties. Now a completely different read only control gets focus on startup and the app seems to ignore my command that the focus should go to this one textbox. Does any one know why this might be?

答:
You can try this :

```<code>splitContainer1.Focus();
splitContainer1.ActiveControl = textBox1;
</code>```

If it doesn't works please post your focus code here.
Sorry because i didn't write a comment but i don't have the privilege yet.

Body:
You can try this :

splitContainer1.Focus();
splitContainer1.ActiveControl = textBox1;

If it doesn't works please post your focus code here.
Sorry because i didn't write a comment but i don't have the privilege yet.


问:
inserting nested objects not saving all data
I am trying to insert a record with nested objects.
My intent is to store an event that can have many link posts or image posts under the main event.
When I try to save, the top level data is saved but the nested objects only show, "link:[], image:[]" when they should each have three values stored.

```<code>var eventSystem = require ("mongoose");
eventSystem.connect('mongodb://localhost/historydb', { useNewUrlParser: true });
var linkPostSchema= new eventSystem.Schema({
    linkurl: String,
    title: String,
    story: String
});
var linkPost = eventSystem.model("linkPost", linkPostSchema);
var imagePostSchema= new eventSystem.Schema({
    src: String,
    title: String,
    story: String
});
var imagePost = eventSystem.model("imagePost", imagePostSchema);
var postSchema= new eventSystem.Schema({
    link: [linkPostSchema],
    image: [imagePostSchema]
});
var Post = eventSystem.model("Post", postSchema);
var eventSchema = new eventSystem.Schema({
    name: String,
    date: Date,
    story: String,
    posts: [postSchema]
});

var Event = eventSystem.model("Event", eventSchema);
var newEvent = new Event({
    name: "MAIN EVENT",
    date: Date.now(),
    story: "main event story"
});

newEvent.posts.push(
     {
         imagePost: {
             src: "first.jpg",
             title: "image post title",
             story: "image post story"
        },
        linkPost: {
            linkurl: "https://youtube.com",
            title: "link post title",
            story: "link post story"
        }
    });

</code>```

ACTUAL results:

```<code>{ _id: 5cf0aea863a51b129a61288f,
  name: 'MAIN EVENT',
  date: 2019-05-31T04:33:44.117Z,
  story: 'main event story',
  posts: [ { _id: 5cf0aea863a51b129a612890, link: [], image: [] } ],
  __v: 0
 }
</code>```

EXPECTED results:

```<code>{ _id: 5cf0aea863a51b129a61288f,
  name: 'MAIN EVENT',
  date: 2019-05-31T04:33:44.117Z,
  story: 'main event story',
  posts: [ {
      _id: 5cf0aea863a51b129a612890,
       link: [linkPost: {
        linkurl: "https://youtube.com",
        title: "link post title",
        story: "link post story"
    }], image: [imagePost: {
         src: "first.jpg",
         title: "image post title",
         story: "image post story"
    }] } ],
  __v: 0
}
</code>```

答:
I got it!
the correct syntax should have been:</p>

```<code>newEvent.posts.push({
          image: [{
             src: "first.jpg",
             title: "image post title",
             story: "image post story"
         }],
        link: [{
            linkurl: "https://youtube.com",
            title: "link post title",
            story: "link post story"
        }]
});
</code>```

Body:
I am trying to insert a record with nested objects.
My intent is to store an event that can have many link posts or image posts under the main event.
When I try to save, the top level data is saved but the nested objects only show, "link:[], image:[]" when they should each have three values stored.

var eventSystem = require ("mongoose");
eventSystem.connect('mongodb://localhost/historydb', { useNewUrlParser: true });
var linkPostSchema= new eventSystem.Schema({
    linkurl: String,
    title: String,
    story: String
});
var linkPost = eventSystem.model("linkPost", linkPostSchema);
var imagePostSchema= new eventSystem.Schema({
    src: String,
    title: String,
    story: String
});
var imagePost = eventSystem.model("imagePost", imagePostSchema);
var postSchema= new eventSystem.Schema({
    link: [linkPostSchema],
    image: [imagePostSchema]
});
var Post = eventSystem.model("Post", postSchema);
var eventSchema = new eventSystem.Schema({
    name: String,
    date: Date,
    story: String,
    posts: [postSchema]
});

var Event = eventSystem.model("Event", eventSchema);
var newEvent = new Event({
    name: "MAIN EVENT",
    date: Date.now(),
    story: "main event story"
});

newEvent.posts.push(
     {
         imagePost: {
             src: "first.jpg",
             title: "image post title",
             story: "image post story"
        },
        linkPost: {
            linkurl: "https://youtube.com",
            title: "link post title",
            story: "link post story"
        }
    });

ACTUAL results:

{ _id: 5cf0aea863a51b129a61288f,
  name: 'MAIN EVENT',
  date: 2019-05-31T04:33:44.117Z,
  story: 'main event story',
  posts: [ { _id: 5cf0aea863a51b129a612890, link: [], image: [] } ],
  __v: 0
 }

EXPECTED results:

{ _id: 5cf0aea863a51b129a61288f,
  name: 'MAIN EVENT',
  date: 2019-05-31T04:33:44.117Z,
  story: 'main event story',
  posts: [ {
      _id: 5cf0aea863a51b129a612890,
       link: [linkPost: {
        linkurl: "https://youtube.com",
        title: "link post title",
        story: "link post story"
    }], image: [imagePost: {
         src: "first.jpg",
         title: "image post title",
         story: "image post story"
    }] } ],
  __v: 0
}

Body:
I got it!
the correct syntax should have been:

newEvent.posts.push({
          image: [{
             src: "first.jpg",
             title: "image post title",
             story: "image post story"
         }],
        link: [{
            linkurl: "https://youtube.com",
            title: "link post title",
            story: "link post story"
        }]
});


问:
How should "ought" be interpreted as when encountered within rfc7230?
RFC 7230 (HTTP/1.1 message Syntax and Routing) specifies that "must", "shall", "should", and "may" are to be interpreted as described in RFC 2119.  However in addition to those requirement specifiers, RFC 7230 also seems to use "ought" as requirement specifiers in 23 separate locations within the document.

I originally assumed that "ought" is equivalent to "should" but there are some instances where interpreting it as "shall" might make more sense. The word definitions I've found support both usages.

So my question is as follows: How should "ought" be interpreted as when encountered within rfc7230 (and its siblings)?

答:
From HTTP persistent connection:

According to RFC 7230, section 6.4, "a client ought to limit the number of simultaneous open connections that it maintains to a given server". The previous version of the HTTP/1.1 specification stated specific maximum values but in the words of RFC 7230 "this was found to be impractical for many applications... instead... be conservative when opening multiple connections".

Here "ought" has a bit of both meanings: formerly "shall," relaxed to "should." That is, definitely not "shall."

And in this answer someone also has the strong opinion that "ought" is not "shall,"

Note the weak "ought to" here which is far from MUST. But at least net/http is fully correct in that this kind of response is wrong and can be handled as error. But it is not required to be treated as error.

And in all the examples in What's difference between HTTP 301 and 308 status codes? I think it's clear "ought" means "should," not "shall."

Finally, from simply a usage of words standpoint, "ought" isn't a common or natural choice of word—no one uses it willy nilly—the word is only used when the author can't commit to "shall."

So at this point, I'd say if you're definitely sure an "ought" should have been a "shall," then it was more likely an error in the document, or something closer to my first example where it was historically a "shall."

In any case it's probably best to ask specifically about the clauses you care about, to experts.


问:
InstanceProfile is required for creating cluster
I was trying to run Elastic MapReduce from Eclipse but couldn't do so.

My code is as below:

```<code>public class RunEMR {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
         AWSCredentials credentials = new BasicAWSCredentials("xxxx","xxxx");
            AmazonElasticMapReduceClient emr = new AmazonElasticMapReduceClient(credentials);

            StepFactory stepFactory = new StepFactory();

            StepConfig enableDebugging = new StepConfig()
                .withName("Enable Debugging")
                .withActionOnFailure("TERMINATE_JOB_FLOW")
                .withHadoopJarStep(stepFactory.newEnableDebuggingStep());

            StepConfig installHive = new StepConfig()
                .withName("Install Hive")
                .withActionOnFailure("TERMINATE_JOB_FLOW")
                .withHadoopJarStep(stepFactory.newInstallHiveStep());

            StepConfig hiveScript = new StepConfig().withName("Hive Script")
                .withActionOnFailure("TERMINATE_JOB_FLOW")
                .withHadoopJarStep(stepFactory.newRunHiveScriptStep("s3://mywordcountbuckett/binary/WordCount.jar"));

            RunJobFlowRequest request = new RunJobFlowRequest()
                .withName("Hive Interactive")
                .withSteps(enableDebugging, installHive)
                .withLogUri("s3://mywordcountbuckett/")
                .withInstances(new JobFlowInstancesConfig()
                    .withEc2KeyName("xxxx")
                    .withHadoopVersion("0.20")
                    .withInstanceCount(3)
                    .withKeepJobFlowAliveWhenNoSteps(true)
                    .withMasterInstanceType("m1.small")
                    .withSlaveInstanceType("m1.small"));

            RunJobFlowResult result = emr.runJobFlow(request);

    }

}
</code>```

The error that I got was :

```<code>Exception in thread "main" com.amazonaws.AmazonServiceException: InstanceProfile is required for creating cluster. (Service: AmazonElasticMapReduce; Status Code: 400; Error Code: ValidationException; Request ID: 7a96ee32-9744-11e5-947d-65ca8f7db0a5
</code>```

I have tried for couple of hours but unable to fix it. Does anyone knows how ?

答:
For an ec2 role (here jobflowrole), an instance profile with the same nameis created internally. Hence it uses these names interchangeably.
If you creating an emr cluster from scratch using boto3, you should also create emr service role, one ec2jobflow role , one instance profile linked to ec2jobflow role.
AWS doc
<img src="https://i.stack.imgur.com/qT5mH.png" alt="referencing AWs documentation"> </p>

Body:
I was trying to run Elastic MapReduce from Eclipse but couldn't do so.

My code is as below:

public class RunEMR {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
         AWSCredentials credentials = new BasicAWSCredentials("xxxx","xxxx");
            AmazonElasticMapReduceClient emr = new AmazonElasticMapReduceClient(credentials);

            StepFactory stepFactory = new StepFactory();

            StepConfig enableDebugging = new StepConfig()
                .withName("Enable Debugging")
                .withActionOnFailure("TERMINATE_JOB_FLOW")
                .withHadoopJarStep(stepFactory.newEnableDebuggingStep());

            StepConfig installHive = new StepConfig()
                .withName("Install Hive")
                .withActionOnFailure("TERMINATE_JOB_FLOW")
                .withHadoopJarStep(stepFactory.newInstallHiveStep());

            StepConfig hiveScript = new StepConfig().withName("Hive Script")
                .withActionOnFailure("TERMINATE_JOB_FLOW")
                .withHadoopJarStep(stepFactory.newRunHiveScriptStep("s3://mywordcountbuckett/binary/WordCount.jar"));

            RunJobFlowRequest request = new RunJobFlowRequest()
                .withName("Hive Interactive")
                .withSteps(enableDebugging, installHive)
                .withLogUri("s3://mywordcountbuckett/")
                .withInstances(new JobFlowInstancesConfig()
                    .withEc2KeyName("xxxx")
                    .withHadoopVersion("0.20")
                    .withInstanceCount(3)
                    .withKeepJobFlowAliveWhenNoSteps(true)
                    .withMasterInstanceType("m1.small")
                    .withSlaveInstanceType("m1.small"));

            RunJobFlowResult result = emr.runJobFlow(request);

    }

}

The error that I got was :

Exception in thread "main" com.amazonaws.AmazonServiceException: InstanceProfile is required for creating cluster. (Service: AmazonElasticMapReduce; Status Code: 400; Error Code: ValidationException; Request ID: 7a96ee32-9744-11e5-947d-65ca8f7db0a5

I have tried for couple of hours but unable to fix it. Does anyone knows how ?