问:
.NET MVC razor -- iteration, and then iteration again?
I'm in C# .NET MVC.  I am able to use a list for my model, and iterate through that list.  However, I must not only iterate through the model, but each item in the list in the model will actually have lists also, so I need to iterate yet again, but obviously I cannot use the same technique, since I'm already using my model for one iteration..

```<code>@model List<MVC_MONGODB.Models.PATIENT.Encounter>

<div style="background-color: #00BCD4; width:100%; padding:10px ">
@{
    ViewData["Title"] = "Encounters";
}

<h2>Encounters </h2><hr />

@foreach (var item in Model)
{
    <label>@item.Date</label><br /><br />
    <br /><strong>Chief Complaints/HPI</strong>
    <label>@item.ChiefComplaints</label><br /><br />
    <hr />
}
</div>
</code>```

From the above, I have a List, and for each Encounter, I must display a List which is a Encounter.ChiefComplaints

答:
Just add one more cycle:</p>

```<code>@model List<MVC_MONGODB.Models.PATIENT.Encounter>

<div style="background-color: #00BCD4; width:100%; padding:10px ">

@{
    ViewData["Title"] = "Encounters";
}

<h2>Encounters </h2><hr />

@foreach (var item in Model)
{
    <label>@item.Date</label><br /><br />
    <br /><strong>Chief Complaints/HPI</strong>
    <label>@item.ChiefComplaints</label><br /><br />

    @foreach(var chief in item.ChiefComplaints)
    {
        //do smth with chief
    }
}

</div>
</code>```

Body:
I'm in C# .NET MVC.  I am able to use a list for my model, and iterate through that list.  However, I must not only iterate through the model, but each item in the list in the model will actually have lists also, so I need to iterate yet again, but obviously I cannot use the same technique, since I'm already using my model for one iteration..

@model List<MVC_MONGODB.Models.PATIENT.Encounter>

@{
    ViewData["Title"] = "Encounters";
}

Encounters

@foreach (var item in Model)
{
    @item.Date

Chief Complaints/HPI
    @item.ChiefComplaints

}

From the above, I have a List, and for each Encounter, I must display a List which is a Encounter.ChiefComplaints

Body:
Just add one more cycle:

@model List<MVC_MONGODB.Models.PATIENT.Encounter>

<div style="background-color: #00BCD4; width:100%; padding:10px ">

@{
    ViewData["Title"] = "Encounters";
}

<h2>Encounters </h2><hr />

@foreach (var item in Model)
{
    <label>@item.Date</label><br /><br />
    <br /><strong>Chief Complaints/HPI</strong>
    <label>@item.ChiefComplaints</label><br /><br />

    @foreach(var chief in item.ChiefComplaints)
    {
        //do smth with chief
    }
}

</div>


来源: stackexchange

问:
What are some uses for linked lists?
Do linked lists have any practical uses at all. Many computer science books compare them to arrays and say the main advantage is that they are mutable. However, most languages provide mutable versions of arrays. So do linked lists have any actual uses in the real world, or are they just part of computer science theory?</p>

答:
So do linked lists have any actual uses in the real world,

A Use/Example of Linked List (Doubly) can be Lift in the Building.

- A person have to go through all the floor to reach top (tail in terms of linked list).

- A person can never go to some random floor directly (have to go through intermediate floors/Nodes).

- A person can never go beyond the top floor (next to the tail node is assigned null).

- A person can never go beyond the ground/last floor (previous to the head node is assigned null in linked list).

ContentLicense: CC BY-SA 2.5

Title: What are some uses for linked lists?

ContentLicense: CC BY-SA 4.0


问:
Is there a way to set HttpExpires on a sub-directory of a virtual directory programmatically on IIS 6?
I have a web application:

W3SVC/1/ROOT/MyApp

I can set the HttpExpires value via adsutil:

cscript C:\InetPub\AdminScripts\adsutil.vbs set W3SVC/1/ROOT/MyApp/HttpExpires "D,86400"

However, I don't want caching for the whole application, just my images which is a subdirectory:

W3SVC/1/ROOT/MyApp/images

Keep in mind that images isn't it's a web directory, just a sub-directory.

When I try thru adsutil I get this:

The path requested could not be found.
ErrNumber: -2147024893 (0x80070003)
Error Trying To Get the Object: W3SVC/1/ROOT/MyApp/images

答:
I was under the impression that creating a web directory would create a virtual directory,but when I look at the metabase it is set as a web directory;so,</p>

```<code>Set vDir = GetObject("IIS://LocalHost/w3svc/1/root/myapp")
If err.number <> 0 Then
    Set objRoot = GetObject("IIS://LocalHost/w3svc/1/root/myapp")
    Set vDir = objRoot.Create("IIsWebDirectory", "images")
End If
vDir.Put "HTTPEXPIRES",  "D,2419200"
vDir.SetInfo
</code>```

Body:
I was under the impression that creating a web directory would create a virtual directory,but when I look at the metabase it is set as a web directory;so,

Set vDir = GetObject("IIS://LocalHost/w3svc/1/root/myapp")
If err.number <> 0 Then
    Set objRoot = GetObject("IIS://LocalHost/w3svc/1/root/myapp")
    Set vDir = objRoot.Create("IIsWebDirectory", "images")
End If
vDir.Put "HTTPEXPIRES",  "D,2419200"
vDir.SetInfo

ContentLicense: CC BY-SA 3.0


问:
How to get user profile information from Facebook API Android
I'm trying to get user profile information Facebook. Begins loading, I click to confirm permission to send my profile, again, continue loading but eventually get empty fields.

What am I doing wrong? Help please.

```<code>public class SettingsApps extends Activity {
public final String API_KEY = "492429660800628";
Facebook facebook = new Facebook(API_KEY);

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

mPrefs=getPreferences(MODE_PRIVATE);
String acces_token=mPrefs.getString("acces_token",null);
long expires=mPrefs.getLong("acces_expires", 0);

if (Session.getActiveSession() == null || Session.getActiveSession().isClosed()) {
    Session.openActiveSession(this, true, new StatusCallback() {
        public void call(Session session, SessionState state, Exception exception) {
            System.out.println("State= " + state);

            if (session.isOpened()) {
                System.out.println("Token=" + session.getAccessToken());
                Request request =  Request.newMeRequest(session, new GraphUserCallback() {
                            public void onCompleted(GraphUser user, Response response) {

                                if (user != null) {
                                    TextView idText = (TextView)findViewById(R.id.id);
                                    TextView first_nameText = (TextView)findViewById(R.id.first_name);
                                    TextView last_nameText = (TextView)findViewById(R.id.last_name);
                                    idText.setText(user.getId());
                                    first_nameText.setText(user.getFirstName());
                                    last_nameText.setText(user.getLastName());
                                }
                                if (response != null) {
                                    System.out.println("Response="  + response);
                                    Toast.makeText(SettingsApps.this, response.toString(),
                                            Toast.LENGTH_LONG).show();
                                }
                            }
                        });
                Request.executeBatchAsync(request);
            }
            if (exception != null) {
                System.out.println("Some thing bad happened!");
                exception.printStackTrace();
            }
        }
    });
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
  super.onActivityResult(requestCode, resultCode, data);
  facebook.authorizeCallback(requestCode, resultCode, data);
  }
}
</code>```

LogCat

```<code>669: INFO/ActivityManager(72): Starting: Intent { cmp=com.fitness_sport_betta/.SettingsApps } from pid 847
899: INFO/ActivityManager(72): Starting: Intent { act=SSO_WITH_FALLBACK cmp=com.fitness_sport_betta/com.facebook.LoginActivity (has extras) } from pid 847
949: INFO/System.out(847): State= OPENING
539: INFO/ActivityManager(72): Displayed com.fitness_sport_betta/com.facebook.LoginActivity: +621ms (total +851ms)
669: DEBUG/dalvikvm(389): GC_CONCURRENT freed 1685K, 41% free 6996K/11783K, external 716K/1038K, paused 16ms+11ms
420: WARN/fb4a:fb:OrcaServiceQueue(389): Exception during service
420: WARN/fb4a:fb:OrcaServiceQueue(389): com.facebook.orca.protocol.base.ApiException: remote_app_id does not match stored id
420: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.orca.protocol.base.ApiResponseChecker.b(ApiResponseChecker.java:74)
420: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.orca.protocol.base.ApiResponseChecker.a(ApiResponseChecker.java:103)
420: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.orca.protocol.base.ApiResponse.g(ApiResponse.java:184)
420: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.katana.server.protocol.AuthorizeAppMethod.a(AuthorizeAppMethod.java:267)
420: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.katana.server.protocol.AuthorizeAppMethod.a(AuthorizeAppMethod.java:28)
420: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.orca.protocol.base.SingleMethodRunner.a(SingleMethodRunner.java:125)
420: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.katana.server.handler.PlatformOperationHandler.c(PlatformOperationHandler.java:274)
420: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.katana.server.handler.PlatformOperationHandler.a(PlatformOperationHandler.java:175)
420: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.orca.server.OrcaServiceQueue.d(OrcaServiceQueue.java:214)
420: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.orca.server.OrcaServiceQueue.d(OrcaServiceQueue.java:37)
420: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.orca.server.OrcaServiceQueue$3.run(OrcaServiceQueue.java:168)
420: WARN/fb4a:fb:OrcaServiceQueue(389):     at android.os.Handler.handleCallback(Handler.java:587)
420: WARN/fb4a:fb:OrcaServiceQueue(389):     at android.os.Handler.dispatchMessage(Handler.java:92)
420: WARN/fb4a:fb:OrcaServiceQueue(389):     at android.os.Looper.loop(Looper.java:123)
420: WARN/fb4a:fb:OrcaServiceQueue(389):     at android.os.HandlerThread.run(HandlerThread.java:60)
459: INFO/ActivityManager(72): Starting: Intent { act=com.facebook.platform.PLATFORM_ACTIVITY cat=[android.intent.category.DEFAULT] cmp=com.facebook.katana/.platform.PlatformActivity (has extras) } from pid 847
639: INFO/ActivityManager(72): Starting: Intent { cmp=com.facebook.katana/.platform.PlatformWrapperActivity (has extras) } from pid 389
670: INFO/ActivityManager(72): Displayed com.facebook.katana/.platform.PlatformActivity: +1s87ms
779: INFO/ActivityManager(72): Displayed com.facebook.katana/.platform.PlatformWrapperActivity: +1s106ms
449: WARN/fb4a:fb:OrcaServiceQueue(389): Exception during service
449: WARN/fb4a:fb:OrcaServiceQueue(389): com.facebook.orca.protocol.base.ApiException: remote_app_id does not match stored id
449: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.orca.protocol.base.ApiResponseChecker.b(ApiResponseChecker.java:74)
449: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.orca.protocol.base.ApiResponseChecker.a(ApiResponseChecker.java:103)
449: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.orca.protocol.base.ApiResponse.g(ApiResponse.java:184)
449: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.katana.server.protocol.AuthorizeAppMethod.a(AuthorizeAppMethod.java:267)
449: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.katana.server.protocol.AuthorizeAppMethod.a(AuthorizeAppMethod.java:28)
449: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.orca.protocol.base.SingleMethodRunner.a(SingleMethodRunner.java:125)
449: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.katana.server.handler.PlatformOperationHandler.c(PlatformOperationHandler.java:274)
449: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.katana.server.handler.PlatformOperationHandler.a(PlatformOperationHandler.java:175)
449: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.orca.server.OrcaServiceQueue.d(OrcaServiceQueue.java:214)
449: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.orca.server.OrcaServiceQueue.d(OrcaServiceQueue.java:37)
449: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.orca.server.OrcaServiceQueue$3.run(OrcaServiceQueue.java:168)
449: WARN/fb4a:fb:OrcaServiceQueue(389):     at android.os.Handler.handleCallback(Handler.java:587)
449: WARN/fb4a:fb:OrcaServiceQueue(389):     at android.os.Handler.dispatchMessage(Handler.java:92)
449: WARN/fb4a:fb:OrcaServiceQueue(389):     at android.os.Looper.loop(Looper.java:123)
449: WARN/fb4a:fb:OrcaServiceQueue(389):     at android.os.HandlerThread.run(HandlerThread.java:60)
469: WARN/fb4a:fb:GDPDialog(389): Failed to send
469: WARN/fb4a:fb:GDPDialog(389): com.facebook.orca.ops.ServiceException: API_ERROR: API_ERROR
469: WARN/fb4a:fb:GDPDialog(389):     at com.facebook.orca.ops.OrcaServiceOperation.c(OrcaServiceOperation.java:597)
469: WARN/fb4a:fb:GDPDialog(389):     at com.facebook.orca.ops.OrcaServiceOperation.c(OrcaServiceOperation.java:38)
469: WARN/fb4a:fb:GDPDialog(389):     at com.facebook.orca.ops.OrcaServiceOperation$2.run(OrcaServiceOperation.java:562)
469: WARN/fb4a:fb:GDPDialog(389):     at android.os.Handler.handleCallback(Handler.java:587)
469: WARN/fb4a:fb:GDPDialog(389):     at android.os.Handler.dispatchMessage(Handler.java:92)
469: WARN/fb4a:fb:GDPDialog(389):     at android.os.Looper.loop(Looper.java:123)
469: WARN/fb4a:fb:GDPDialog(389):     at android.app.ActivityThread.main(ActivityThread.java:3683)
469: WARN/fb4a:fb:GDPDialog(389):     at java.lang.reflect.Method.invokeNative(Native Method)
469: WARN/fb4a:fb:GDPDialog(389):     at java.lang.reflect.Method.invoke(Method.java:507)
469: WARN/fb4a:fb:GDPDialog(389):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
469: WARN/fb4a:fb:GDPDialog(389):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
469: WARN/fb4a:fb:GDPDialog(389):     at dalvik.system.NativeStart.main(Native Method)
009: WARN/InputManagerService(72): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@40677138 (uid=10030 pid=847)
009: WARN/InputManagerService(72): Client not active, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@40556e88
529: INFO/ActivityManager(72): Displayed com.fitness_sport_betta/.SettingsApps: +10s839ms
</code>```

Last change:

```<code>public class SettingsApps extends Activity {

public final String API_KEY = "492429660800628";
Facebook facebook = new Facebook(API_KEY);
public final String[] permissions = {"publish_stream"};
String mUserId;
String mUserToken;
String mUserName;
String mUserEmail;

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

if (Session.getActiveSession() == null || Session.getActiveSession().isClosed()) {
    Session.openActiveSession(this, true, new StatusCallback() {
        public void call(final Session session, SessionState state, Exception exception) {
            System.out.println("State= " + state);
            authorizeAndPostMassage();
            if (exception != null) {
                System.out.println("Some thing bad happened!");
                exception.printStackTrace();
            }
        }
    });
}
}

public void authorizeAndPostMassage() {

    facebook.authorize(this, permissions, new DialogListener () {
        public void onComplete(Bundle values) {
                Toast.makeText(SettingsApps.this, "Authorization successful", Toast.LENGTH_SHORT).show();
                getProfileInformation();
        }
        public void onFacebookError(FacebookError e) {
            Toast.makeText(SettingsApps.this, "Facebook error, try again later", Toast.LENGTH_SHORT).show();
        }
        public void onError(DialogError e) {
            Toast.makeText(SettingsApps.this, "Error, try again later", Toast.LENGTH_SHORT).show();
        }
        public void onCancel() {
            //Этот коллбэк никогда не срабатывает, вероятно, ошибка в SDK
            Toast.makeText(SettingsApps.this, "Authorization canceled", Toast.LENGTH_SHORT).show();
        }});
}

public void getProfileInformation() {
    try {

        JSONObject profile = Util.parseJson(facebook.request("me"));
        Log.e("Profile", "" + profile);

        mUserId = profile.getString("id");
        mUserToken = facebook.getAccessToken();
        mUserName = profile.getString("name");
        mUserEmail = profile.getString("email");
        runOnUiThread(new Runnable() {
            public void run() {
                Log.v("FaceBook_Profile",""+mUserId+"\n"+mUserToken+"\n"+mUserName+"\n"+mUserEmail);
                Toast.makeText(getApplicationContext(),
                        "Name: " + mUserName + "\nEmail: " + mUserEmail,
                        Toast.LENGTH_LONG).show();
            }
        });

    } catch (FacebookError e) {
        e.printStackTrace();
    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (JSONException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
  super.onActivityResult(requestCode, resultCode, data);
  facebook.authorizeCallback(requestCode, resultCode, data);
  }
}
</code>```

答:
First: login

```<code>LoginManager loginManager = LoginManager.getInstance();
loginManager.registerCallback(callbackManager, new FacebookLoginCallback());
</code>```

Then: get profile infomation

```<code>// call this when login success
Profile profile = Profile.getCurrentProfile();
// getAvatar
String avatar = ImageRequest.getProfilePictureUri(profile.getId(), width, height).toString();
</code>```

Body:
I'm trying to get user profile information Facebook. Begins loading, I click to confirm permission to send my profile, again, continue loading but eventually get empty fields.

What am I doing wrong? Help please.

public class SettingsApps extends Activity {
public final String API_KEY = "492429660800628";
Facebook facebook = new Facebook(API_KEY);

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

mPrefs=getPreferences(MODE_PRIVATE);
String acces_token=mPrefs.getString("acces_token",null);
long expires=mPrefs.getLong("acces_expires", 0);

if (Session.getActiveSession() == null || Session.getActiveSession().isClosed()) {
    Session.openActiveSession(this, true, new StatusCallback() {
        public void call(Session session, SessionState state, Exception exception) {
            System.out.println("State= " + state);

            if (session.isOpened()) {
                System.out.println("Token=" + session.getAccessToken());
                Request request =  Request.newMeRequest(session, new GraphUserCallback() {
                            public void onCompleted(GraphUser user, Response response) {

                                if (user != null) {
                                    TextView idText = (TextView)findViewById(R.id.id);
                                    TextView first_nameText = (TextView)findViewById(R.id.first_name);
                                    TextView last_nameText = (TextView)findViewById(R.id.last_name);
                                    idText.setText(user.getId());
                                    first_nameText.setText(user.getFirstName());
                                    last_nameText.setText(user.getLastName());
                                }
                                if (response != null) {
                                    System.out.println("Response="  + response);
                                    Toast.makeText(SettingsApps.this, response.toString(),
                                            Toast.LENGTH_LONG).show();
                                }
                            }
                        });
                Request.executeBatchAsync(request);
            }
            if (exception != null) {
                System.out.println("Some thing bad happened!");
                exception.printStackTrace();
            }
        }
    });
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
  super.onActivityResult(requestCode, resultCode, data);
  facebook.authorizeCallback(requestCode, resultCode, data);
  }
}

LogCat

669: INFO/ActivityManager(72): Starting: Intent { cmp=com.fitness_sport_betta/.SettingsApps } from pid 847
899: INFO/ActivityManager(72): Starting: Intent { act=SSO_WITH_FALLBACK cmp=com.fitness_sport_betta/com.facebook.LoginActivity (has extras) } from pid 847
949: INFO/System.out(847): State= OPENING
539: INFO/ActivityManager(72): Displayed com.fitness_sport_betta/com.facebook.LoginActivity: +621ms (total +851ms)
669: DEBUG/dalvikvm(389): GC_CONCURRENT freed 1685K, 41% free 6996K/11783K, external 716K/1038K, paused 16ms+11ms
420: WARN/fb4a:fb:OrcaServiceQueue(389): Exception during service
420: WARN/fb4a:fb:OrcaServiceQueue(389): com.facebook.orca.protocol.base.ApiException: remote_app_id does not match stored id
420: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.orca.protocol.base.ApiResponseChecker.b(ApiResponseChecker.java:74)
420: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.orca.protocol.base.ApiResponseChecker.a(ApiResponseChecker.java:103)
420: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.orca.protocol.base.ApiResponse.g(ApiResponse.java:184)
420: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.katana.server.protocol.AuthorizeAppMethod.a(AuthorizeAppMethod.java:267)
420: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.katana.server.protocol.AuthorizeAppMethod.a(AuthorizeAppMethod.java:28)
420: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.orca.protocol.base.SingleMethodRunner.a(SingleMethodRunner.java:125)
420: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.katana.server.handler.PlatformOperationHandler.c(PlatformOperationHandler.java:274)
420: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.katana.server.handler.PlatformOperationHandler.a(PlatformOperationHandler.java:175)
420: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.orca.server.OrcaServiceQueue.d(OrcaServiceQueue.java:214)
420: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.orca.server.OrcaServiceQueue.d(OrcaServiceQueue.java:37)
420: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.orca.server.OrcaServiceQueue$3.run(OrcaServiceQueue.java:168)
420: WARN/fb4a:fb:OrcaServiceQueue(389):     at android.os.Handler.handleCallback(Handler.java:587)
420: WARN/fb4a:fb:OrcaServiceQueue(389):     at android.os.Handler.dispatchMessage(Handler.java:92)
420: WARN/fb4a:fb:OrcaServiceQueue(389):     at android.os.Looper.loop(Looper.java:123)
420: WARN/fb4a:fb:OrcaServiceQueue(389):     at android.os.HandlerThread.run(HandlerThread.java:60)
459: INFO/ActivityManager(72): Starting: Intent { act=com.facebook.platform.PLATFORM_ACTIVITY cat=[android.intent.category.DEFAULT] cmp=com.facebook.katana/.platform.PlatformActivity (has extras) } from pid 847
639: INFO/ActivityManager(72): Starting: Intent { cmp=com.facebook.katana/.platform.PlatformWrapperActivity (has extras) } from pid 389
670: INFO/ActivityManager(72): Displayed com.facebook.katana/.platform.PlatformActivity: +1s87ms
779: INFO/ActivityManager(72): Displayed com.facebook.katana/.platform.PlatformWrapperActivity: +1s106ms
449: WARN/fb4a:fb:OrcaServiceQueue(389): Exception during service
449: WARN/fb4a:fb:OrcaServiceQueue(389): com.facebook.orca.protocol.base.ApiException: remote_app_id does not match stored id
449: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.orca.protocol.base.ApiResponseChecker.b(ApiResponseChecker.java:74)
449: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.orca.protocol.base.ApiResponseChecker.a(ApiResponseChecker.java:103)
449: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.orca.protocol.base.ApiResponse.g(ApiResponse.java:184)
449: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.katana.server.protocol.AuthorizeAppMethod.a(AuthorizeAppMethod.java:267)
449: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.katana.server.protocol.AuthorizeAppMethod.a(AuthorizeAppMethod.java:28)
449: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.orca.protocol.base.SingleMethodRunner.a(SingleMethodRunner.java:125)
449: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.katana.server.handler.PlatformOperationHandler.c(PlatformOperationHandler.java:274)
449: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.katana.server.handler.PlatformOperationHandler.a(PlatformOperationHandler.java:175)
449: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.orca.server.OrcaServiceQueue.d(OrcaServiceQueue.java:214)
449: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.orca.server.OrcaServiceQueue.d(OrcaServiceQueue.java:37)
449: WARN/fb4a:fb:OrcaServiceQueue(389):     at com.facebook.orca.server.OrcaServiceQueue$3.run(OrcaServiceQueue.java:168)
449: WARN/fb4a:fb:OrcaServiceQueue(389):     at android.os.Handler.handleCallback(Handler.java:587)
449: WARN/fb4a:fb:OrcaServiceQueue(389):     at android.os.Handler.dispatchMessage(Handler.java:92)
449: WARN/fb4a:fb:OrcaServiceQueue(389):     at android.os.Looper.loop(Looper.java:123)
449: WARN/fb4a:fb:OrcaServiceQueue(389):     at android.os.HandlerThread.run(HandlerThread.java:60)
469: WARN/fb4a:fb:GDPDialog(389): Failed to send
469: WARN/fb4a:fb:GDPDialog(389): com.facebook.orca.ops.ServiceException: API_ERROR: API_ERROR
469: WARN/fb4a:fb:GDPDialog(389):     at com.facebook.orca.ops.OrcaServiceOperation.c(OrcaServiceOperation.java:597)
469: WARN/fb4a:fb:GDPDialog(389):     at com.facebook.orca.ops.OrcaServiceOperation.c(OrcaServiceOperation.java:38)
469: WARN/fb4a:fb:GDPDialog(389):     at com.facebook.orca.ops.OrcaServiceOperation$2.run(OrcaServiceOperation.java:562)
469: WARN/fb4a:fb:GDPDialog(389):     at android.os.Handler.handleCallback(Handler.java:587)
469: WARN/fb4a:fb:GDPDialog(389):     at android.os.Handler.dispatchMessage(Handler.java:92)
469: WARN/fb4a:fb:GDPDialog(389):     at android.os.Looper.loop(Looper.java:123)
469: WARN/fb4a:fb:GDPDialog(389):     at android.app.ActivityThread.main(ActivityThread.java:3683)
469: WARN/fb4a:fb:GDPDialog(389):     at java.lang.reflect.Method.invokeNative(Native Method)
469: WARN/fb4a:fb:GDPDialog(389):     at java.lang.reflect.Method.invoke(Method.java:507)
469: WARN/fb4a:fb:GDPDialog(389):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
469: WARN/fb4a:fb:GDPDialog(389):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
469: WARN/fb4a:fb:GDPDialog(389):     at dalvik.system.NativeStart.main(Native Method)
009: WARN/InputManagerService(72): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@40677138 (uid=10030 pid=847)
009: WARN/InputManagerService(72): Client not active, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@40556e88
529: INFO/ActivityManager(72): Displayed com.fitness_sport_betta/.SettingsApps: +10s839ms

Last change:

public class SettingsApps extends Activity {

public final String API_KEY = "492429660800628";
Facebook facebook = new Facebook(API_KEY);
public final String[] permissions = {"publish_stream"};
String mUserId;
String mUserToken;
String mUserName;
String mUserEmail;

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

if (Session.getActiveSession() == null || Session.getActiveSession().isClosed()) {
    Session.openActiveSession(this, true, new StatusCallback() {
        public void call(final Session session, SessionState state, Exception exception) {
            System.out.println("State= " + state);
            authorizeAndPostMassage();
            if (exception != null) {
                System.out.println("Some thing bad happened!");
                exception.printStackTrace();
            }
        }
    });
}
}

public void authorizeAndPostMassage() {

    facebook.authorize(this, permissions, new DialogListener () {
        public void onComplete(Bundle values) {
                Toast.makeText(SettingsApps.this, "Authorization successful", Toast.LENGTH_SHORT).show();
                getProfileInformation();
        }
        public void onFacebookError(FacebookError e) {
            Toast.makeText(SettingsApps.this, "Facebook error, try again later", Toast.LENGTH_SHORT).show();
        }
        public void onError(DialogError e) {
            Toast.makeText(SettingsApps.this, "Error, try again later", Toast.LENGTH_SHORT).show();
        }
        public void onCancel() {
            //Этот коллбэк никогда не срабатывает, вероятно, ошибка в SDK
            Toast.makeText(SettingsApps.this, "Authorization canceled", Toast.LENGTH_SHORT).show();
        }});
}

public void getProfileInformation() {
    try {

        JSONObject profile = Util.parseJson(facebook.request("me"));
        Log.e("Profile", "" + profile);

        mUserId = profile.getString("id");
        mUserToken = facebook.getAccessToken();
        mUserName = profile.getString("name");
        mUserEmail = profile.getString("email");
        runOnUiThread(new Runnable() {
            public void run() {
                Log.v("FaceBook_Profile",""+mUserId+"\n"+mUserToken+"\n"+mUserName+"\n"+mUserEmail);
                Toast.makeText(getApplicationContext(),
                        "Name: " + mUserName + "\nEmail: " + mUserEmail,
                        Toast.LENGTH_LONG).show();
            }
        });

    } catch (FacebookError e) {
        e.printStackTrace();
    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (JSONException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
  super.onActivityResult(requestCode, resultCode, data);
  facebook.authorizeCallback(requestCode, resultCode, data);
  }
}

Body:
First: login

LoginManager loginManager = LoginManager.getInstance();
loginManager.registerCallback(callbackManager, new FacebookLoginCallback());

Then: get profile infomation

// call this when login success
Profile profile = Profile.getCurrentProfile();
// getAvatar
String avatar = ImageRequest.getProfilePictureUri(profile.getId(), width, height).toString();


问:
Unable to retreive unique dates from mysql column having date and time in mysql using php
Hi friend am trying to retreive the dates from mysql column named 'date' which has date and time. I want to retreive only dates not times. I want retreive only dates which are not duplicates..

Here is sample data of mysql with column date..

```<code>   03/07/2017 03:37:12pm
   03/07/2017 10:38:12pm
   04/07/2017 10:38:12pm
   04/07/2017 2:38:12pm
</code>```

wanted out put as

```<code>     03/07/2017
     04/07/2017
</code>```

Here is my php code

```<code><?php

$sql = "SELECT  DISTINCT date('d/m/Y,date) FROM video_data";
echo $sql;
$result = mysqli_query($connection, $sql);
echo $result;
while ($row = mysqli_fetch_assoc($result)) {
    $id   = $row['id'];
    $date = $row['date'];
    $date = date('Y-m-d', strtotime($date));
    echo "<tr>";
    echo "<td>$date</td>";
    echo "</tr>";

}

?>
</code>```

Am unable to print dates using php

答:
use Date_format get the date part from datetime column  then apply distinct for that column like this

```<code>SELECT id,DISTINCT date_format(date,'%d/%m/%Y') as new_date FROM video_data group by new_date
</code>```

PHP :

```<code><?php

$sql = "SELECT id,DISTINCT date_format(date,'%d/%m/%Y') as new_date FROM video_data group by new_date";

$result = mysqli_query($connection, $sql);

while ($row = mysqli_fetch_assoc($result)) {
    $id   = $row['id'];
    $date = $row['new_date'];
    echo "<tr>";
    echo "<td>$date</td>";
    echo "</tr>";

}

?>
</code>```

Body:
Hi friend am trying to retreive the dates from mysql column named 'date' which has date and time. I want to retreive only dates not times. I want retreive only dates which are not duplicates..

Here is sample data of mysql with column date..

   03/07/2017 03:37:12pm
   03/07/2017 10:38:12pm
   04/07/2017 10:38:12pm
   04/07/2017 2:38:12pm

wanted out put as

     03/07/2017
     04/07/2017

Here is my php code

<?php

$sql = "SELECT  DISTINCT date('d/m/Y,date) FROM video_data";
echo $sql;
$result = mysqli_query($connection, $sql);
echo $result;
while ($row = mysqli_fetch_assoc($result)) {
    $id   = $row['id'];
    $date = $row['date'];
    $date = date('Y-m-d', strtotime($date));
    echo "
";
    echo "$date	";
    echo "
";

}

?>

Am unable to print dates using php

Body:
use Date_format get the date part from datetime column  then apply distinct for that column like this

SELECT id,DISTINCT date_format(date,'%d/%m/%Y') as new_date FROM video_data group by new_date

PHP :

<?php

$sql = "SELECT id,DISTINCT date_format(date,'%d/%m/%Y') as new_date FROM video_data group by new_date";

$result = mysqli_query($connection, $sql);

while ($row = mysqli_fetch_assoc($result)) {
    $id   = $row['id'];
    $date = $row['new_date'];
    echo "<tr>";
    echo "<td>$date</td>";
    echo "</tr>";

}

?>


问:
How to delete trigger in SQL Server?
I need to delete a trigger in SQL Server. Seems like it should be simple enough, but because there is a thing called a "delete trigger", a trigger that is invoked upon deletion, it seems impossible to find resources on how to actually delete an already existing trigger.</p>

答:
I can Drop a Trigger with the Following Query

```<code>DROP TRIGGER [Trigger_Name]

          (OR)

DROP TRIGGER Trigger_Update
</code>```

Hope this Must helpfull...

Title: How to delete trigger in SQL Server?

Body:
I can Drop a Trigger with the Following Query

DROP TRIGGER [Trigger_Name]

          (OR)

DROP TRIGGER Trigger_Update

Hope this Must helpfull...


问:
Normalize PostgreSQL Table with more than 700 columns
I have a source (and I have no control on it) with a table like:

```<code>CREATE TABLE temp.badtable(
    Id       INTEGER
   ,Meta     TEXT
   ,Field001 FLOAT
   ,Field002 FLOAT
   ,...
   ,Field720 FLOAT
);
</code>```

Where fields names are predictable and types are homogeneous. I would like to normalize this table before processing its data. I would like to have a well-shaped table instead, it should look like:

```<code>CREATE TABLE temp.goodtable(
    Id         INTEGER
   --,Meta       TEXT -- For normalization sake
   ,FieldName  TEXT
   ,FieldValue FLOAT
);
</code>```

Is there a proper way to do so with PostgreSQL?

Update

I get a beggining of solution using JSON. This is not performent, but it achieves what I need:

```<code>WITH

A AS (
SELECT
    Id
   ,row_to_json(M) AS Data
FROM
    temp.badtable
),

B AS (
SELECT
    Id
   ,row_to_json(json_each(Data)) AS Pair
FROM
    A
)

SELECT
    Id
   ,Pair->>'key' AS FieldKey
   ,Pair->>'value' AS FieldValue
FROM B;
</code>```

答:
If that table is not normalized, that would mean that not all of these fields depend only on the primary key (id?).

If for example field004 and field005 depend on field003, like product name and product description depend on the product ID, you'd remove field004 and field005 from the table, create a new table that contains only these three fields with field003 as primary key and establish a foreign key relation ship from the main table to this new table.

That way you would end up with several tables, each describing certain entities, with relationships between them. You'd end up saving space and automatically guaranteed integrity because you avoid redundant data.

What you suggest above has nothing to do with normalization. It might be a possible solution if most of the fields in the table are NULL (a “sparse table”).

But in that case you might indeed be better off with a solution using JSON like Joey Pinto's answer suggests.

Body:
I have a source (and I have no control on it) with a table like:

CREATE TABLE temp.badtable(
    Id       INTEGER
   ,Meta     TEXT
   ,Field001 FLOAT
   ,Field002 FLOAT
   ,...
   ,Field720 FLOAT
);

Where fields names are predictable and types are homogeneous. I would like to normalize this table before processing its data. I would like to have a well-shaped table instead, it should look like:

CREATE TABLE temp.goodtable(
    Id         INTEGER
   --,Meta       TEXT -- For normalization sake
   ,FieldName  TEXT
   ,FieldValue FLOAT
);

Is there a proper way to do so with PostgreSQL?

Update

I get a beggining of solution using JSON. This is not performent, but it achieves what I need:

WITH

A AS (
SELECT
    Id
   ,row_to_json(M) AS Data
FROM
    temp.badtable
),

B AS (
SELECT
    Id
   ,row_to_json(json_each(Data)) AS Pair
FROM
    A
)

SELECT
    Id
   ,Pair->>'key' AS FieldKey
   ,Pair->>'value' AS FieldValue
FROM B;


问:
Ghost featured image and iframe issue
HTML

```<code><div class="blog-post">
  <div class="blog-image">
    <a href="#"><img src="img/featured-img.jpg"/></a>
  </div>
  <div class="blog-details">
    <h3>Post Title Here</h3>
    <ul class="blog-meta">
      <li>Date</li>
      <li>Author</li>
    </ul>
    <div class="blog-excerpt">
      <iframe width="560" height="315" src="https://www.youtube.com/embed/yH4zLmi_6n0" frameborder="0" allowfullscreen></iframe>
    </div>
  </div>
</code>```

and i used the following js

```<code>  function iframe_posts() {
    var video_url = $(".blog-details").find("iframe").attr("src");
    $(".blog-image").html('<iframe width="560" height="315" src="' + video_url + '" frameborder="0" allowfullscreen></iframe>');
  }
}

iframe_posts();
</code>```

By this code Image replacing with iframe but same iframe showing in every "blog-post". I want to show the parent video only for each  "blog-post". Suppose i have 2 blog-post with 2 different iframe. Now i want to show the iframe in

are

Anyone can help me please.

答:
```<code>$(".blog-post").each(function(){
var wrapper = $(this);
var video_url = wrapper.find("iframe").attr("src");
 var iframe_content = ('<iframe width="560" height="315" src="' + video_url + '" frameborder="0" allowfullscreen></iframe>');
 var video_div =  wrapper.find(".blog-image")
 video_div.each(function(){
          video_div.html(iframe_content);
 });
</code>```

});

This code resolved my problem..

Title: Ghost featured image and iframe issue

Body:
HTML

Post Title Here

Date

Author

and i used the following js

  function iframe_posts() {
    var video_url = $(".blog-details").find("iframe").attr("src");
    $(".blog-image").html('');
  }
}

iframe_posts();

By this code Image replacing with iframe but same iframe showing in every "blog-post". I want to show the parent video only for each  "blog-post". Suppose i have 2 blog-post with 2 different iframe. Now i want to show the iframe in

are

Anyone can help me please.

Body:
$(".blog-post").each(function(){
var wrapper = $(this);
var video_url = wrapper.find("iframe").attr("src");
 var iframe_content = ('<iframe width="560" height="315" src="' + video_url + '" frameborder="0" allowfullscreen></iframe>');
 var video_div =  wrapper.find(".blog-image")
 video_div.each(function(){
          video_div.html(iframe_content);
 });

});

This code resolved my problem..


问:
I want to implement checkbox within a toolbar menu, and Check box shows but does not tick, any ideas?
I am making an app, where the toolbar has a menu, and within has 2-3 checkboxes.I have code put down for xml and java, and checkbox displays. But nothing gets ticked when i press. Code below

action_bar xml which gets included in main activity :

```<code><item
    android:id="@+id/eleaf"
    app:actionViewClass="android.widget.CheckBox"
    android:checkable="true"
    android:checked="false"
    android:orderInCategory="5"
    app:showAsAction="never"
    android:buttonTint="@color/colorAccent"
    android:title="E-Leaf"
    android:checkMark="?android:attr/listChoiceIndicatorMultiple"
    android:onClick="itemClicked"/>
</code>```

Java for onOptionsItemsSelected :

```<code>public boolean onOptionsItemSelected(MenuItem item)
{
    boolean checked = item.isChecked();

    switch (item.getItemId())
    {
        case R.id.eleaf:
            if(checked){
                Toast.makeText(this, "E-Leaf Map shown", Toast.LENGTH_SHORT).show();
                item.setChecked(false);
            }
            break;
        case R.id.biomass:
            if (checked){
                Toast.makeText(this, "Biomass Map shown", Toast.LENGTH_SHORT).show();
                item.setChecked(false);
            }
            break;
        default:
            return super.onOptionsItemSelected(item);
    }
    return true;
}
</code>```

I had this line in oncreate but not really using it :

```<code>    CheckBox checkEleaf = (CheckBox) findViewById(R.id.eleaf);
</code>```

Any suggestions on how to go about this. Thanks

答:
You have this code in your 1st case :

```<code> case R.id.eleaf:
            if(checked){
                Toast.makeText(this, "E-Leaf Map shown", Toast.LENGTH_SHORT).show();
                item.setChecked(false);
            }
            break;
</code>```

In this you are calling setChecked(false) only when its already check by if(checked) condition.. you should change this code to following code :

```<code> case R.id.eleaf:

                    if (checked) {
                        Toast.makeText(this, "E-Leaf Map shown", Toast.LENGTH_SHORT).show();
                    }
                    item.setChecked(!item.isChecked()); // this will make check,uncheck
                    break;
</code>```

Body:
I am making an app, where the toolbar has a menu, and within has 2-3 checkboxes.I have code put down for xml and java, and checkbox displays. But nothing gets ticked when i press. Code below

action_bar xml which gets included in main activity :

<item
    android:id="@+id/eleaf"
    app:actionViewClass="android.widget.CheckBox"
    android:checkable="true"
    android:checked="false"
    android:orderInCategory="5"
    app:showAsAction="never"
    android:buttonTint="@color/colorAccent"
    android:title="E-Leaf"
    android:checkMark="?android:attr/listChoiceIndicatorMultiple"
    android:onClick="itemClicked"/>

Java for onOptionsItemsSelected :

public boolean onOptionsItemSelected(MenuItem item)
{
    boolean checked = item.isChecked();

    switch (item.getItemId())
    {
        case R.id.eleaf:
            if(checked){
                Toast.makeText(this, "E-Leaf Map shown", Toast.LENGTH_SHORT).show();
                item.setChecked(false);
            }
            break;
        case R.id.biomass:
            if (checked){
                Toast.makeText(this, "Biomass Map shown", Toast.LENGTH_SHORT).show();
                item.setChecked(false);
            }
            break;
        default:
            return super.onOptionsItemSelected(item);
    }
    return true;
}

I had this line in oncreate but not really using it :

    CheckBox checkEleaf = (CheckBox) findViewById(R.id.eleaf);

Any suggestions on how to go about this. Thanks

Body:
You have this code in your 1st case :

 case R.id.eleaf:
            if(checked){
                Toast.makeText(this, "E-Leaf Map shown", Toast.LENGTH_SHORT).show();
                item.setChecked(false);
            }
            break;

In this you are calling setChecked(false) only when its already check by if(checked) condition.. you should change this code to following code :

 case R.id.eleaf:

                    if (checked) {
                        Toast.makeText(this, "E-Leaf Map shown", Toast.LENGTH_SHORT).show();
                    }
                    item.setChecked(!item.isChecked()); // this will make check,uncheck
                    break;


问:
GitLab only builds for specific tag names
Is there a way to instruct the pipeline to only do a step for certain tags that matches a regular expression?

I would like it to do a deploy when I push a tag on the format 1.2.3 (for example). Is there a way to do this?

答:
Yes, you can do this with the only option:

```<code>job:
  # Use regexp
  only:
    - /^issue-.*$/

job:
  # Use special keywords
  only:
    - tags
    - triggers
    - schedules
</code>```

See only/except (basic).

Body:
Yes, you can do this with the only option:

job:
  # Use regexp
  only:
    - /^issue-.*$/

job:
  # Use special keywords
  only:
    - tags
    - triggers
    - schedules

See only/except (basic).


问:
Spark: Stateful stream processing by key
I have stream of data such as JSON records with an ID.

I would like to process the data such that all records with the same key are processed by the same stateful worker.

How can I do that?

答: You can write custom Partition-er that will distribute data based on hash of Json id and same Id json will go to same partition and will be processed and each partition is going to get processed by same executor thread</p>


问:
VS Code terminal doesn't recognize PATH variables
I added a directory to my PATH but the terminal in my VS Code doesn't recognize a command(exe) that I'm trying to run from that directory.
The terminal uses cmd not power shell.
What am I missing?</p>

答: Restarted my computer and it worked :) Apparently VS Code didn't recognize the changes. </p>


问:
Catching thread exceptions from Java ExecutorService
I'm working on a software development framework for parallel computing JavaSeis.org. I need a robust mechanism for reporting thread exceptions. During development, knowing where exceptions came from has high value, so I would like to err on the side of over-reporting. I would also like to be able to handle Junit4 testing in threads as well. Is the approach below reasonable or is there a better way ?</p>

```<code>import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

public class TestThreadFailure {

  public static void main(String[] args) {
    int size = 1;
    ExecutorService exec = Executors.newFixedThreadPool(size);
    ThreadFailTask worker = new ThreadFailTask();
    Future<Integer> result = exec.submit(worker);
    try {
      Integer value = result.get();
      System.out.println("Result: " + value);
    } catch (Throwable t) {
      System.out.println("Caught failure: " + t.toString());
      exec.shutdownNow();
      System.out.println("Stack Trace:");
      t.printStackTrace();
      return;
    }
    throw new RuntimeException("Did not catch failure !!");
  }

  public static class ThreadFailTask implements Callable<Integer> {
    @Override
    public Integer call() {
      int nbuf = 65536;
      double[][] buf = new double[nbuf][nbuf];
      return new Integer((int) buf[0][0]);
    }
  }
}
</code>```

答:
Consider calling execute() instead of submit() on the ExecutorService. A Thread invoked with execute() will invoke the Thread.UncaughtExceptionHandler when it fails.

Simply make a ThreadFactory that installs a Thread.UncaughtExceptionHandler on all Threads and then invoke your work with execute() on the ExecutorService instead of submit().

Have a look at this related stack overflow question.

Body:
I'm working on a software development framework for parallel computing JavaSeis.org. I need a robust mechanism for reporting thread exceptions. During development, knowing where exceptions came from has high value, so I would like to err on the side of over-reporting. I would also like to be able to handle Junit4 testing in threads as well. Is the approach below reasonable or is there a better way ?

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

public class TestThreadFailure {

  public static void main(String[] args) {
    int size = 1;
    ExecutorService exec = Executors.newFixedThreadPool(size);
    ThreadFailTask worker = new ThreadFailTask();
    Future<Integer> result = exec.submit(worker);
    try {
      Integer value = result.get();
      System.out.println("Result: " + value);
    } catch (Throwable t) {
      System.out.println("Caught failure: " + t.toString());
      exec.shutdownNow();
      System.out.println("Stack Trace:");
      t.printStackTrace();
      return;
    }
    throw new RuntimeException("Did not catch failure !!");
  }

  public static class ThreadFailTask implements Callable<Integer> {
    @Override
    public Integer call() {
      int nbuf = 65536;
      double[][] buf = new double[nbuf][nbuf];
      return new Integer((int) buf[0][0]);
    }
  }
}


问:
getting json values into php variable issue
i try to use some sms api and i have to get message-id. First of all here is the my api code.

```<code>$url = 'https://rest.nexmo.com/sms/json?' . http_build_query(
    [
      'api_key' =>  'xxx',
      'api_secret' => 'xxx',
      'to' => 'xxx',
      'from' => 'xxx',
      'text' => 'xxx'
    ]
);
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $response = curl_exec($ch);
</code>```

When i use this code it's working for sending sms and return response. And here is the json response.

```<code>{ "message-count": "1", "messages": [{ "to": "905075214049", "message-id": "0C000000440A086C", "status": "0", "remaining-balance": "1.52250000", "message-price": "0.01910000", "network": "28603" }] }
</code>```

And i use the print_r function to see the structrue of json data. And here it's.

```<code>stdClass Object
(
    [message-count] => 1
    [messages] => Array
        (
            [0] => stdClass Object
                (
                    [to] => xxx
                    [message-id] => 0C000000440A086C
                    [status] => 0
                    [remaining-balance] => 1.52250000
                    [message-price] => 0.01910000
                    [network] => 28603
                )

        )

)
</code>```

I use this code to get "message-id" into my php value.

```<code>$json_decode = json_decode($response);
$sonuc->messages[0]->message-id;
</code>```

My issue is; if i try to get network section from this json it works. But if i try to get "message-id" section it returns only 0 on the screen. I really don't know how can i get full message-id. Please help.

答:
- char is not allowed for using as property or variable name. If you want get this property, do it like this:

```<code>$sonuc->messages[0]->{"message-id"}
</code>```

Body:
i try to use some sms api and i have to get message-id. First of all here is the my api code.

$url = 'https://rest.nexmo.com/sms/json?' . http_build_query(
    [
      'api_key' =>  'xxx',
      'api_secret' => 'xxx',
      'to' => 'xxx',
      'from' => 'xxx',
      'text' => 'xxx'
    ]
);
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $response = curl_exec($ch);

When i use this code it's working for sending sms and return response. And here is the json response.

{ "message-count": "1", "messages": [{ "to": "905075214049", "message-id": "0C000000440A086C", "status": "0", "remaining-balance": "1.52250000", "message-price": "0.01910000", "network": "28603" }] }

And i use the print_r function to see the structrue of json data. And here it's.

stdClass Object
(
    [message-count] => 1
    [messages] => Array
        (
            [0] => stdClass Object
                (
                    [to] => xxx
                    [message-id] => 0C000000440A086C
                    [status] => 0
                    [remaining-balance] => 1.52250000
                    [message-price] => 0.01910000
                    [network] => 28603
                )

        )

)

I use this code to get "message-id" into my php value.

$json_decode = json_decode($response);
$sonuc->messages[0]->message-id;

My issue is; if i try to get network section from this json it works. But if i try to get "message-id" section it returns only 0 on the screen. I really don't know how can i get full message-id. Please help.

Body:
- char is not allowed for using as property or variable name. If you want get this property, do it like this:

$sonuc->messages[0]->{"message-id"}


问:
UI automation with excel
I am new to UI Automation. In my current organisation I was tasked with making an automated tool using GUI(Graphics User Interface) screen reading, but it is not working perfectly with other my colleague's machine because of a difference in screen resolution.

I watched this link on you-tube to try and understand UI Automation with excel, but I can't find much on this topic anywhere else.

Can anyone direct me toward resources on UI Automation? I Would like to know where I can learn it, read about it, and how to implement it with Excel.

Thanks in advance I really appreciate if anyone could help me.

答:
Seems like you are doing the automation using the coordinates, which changes when you switch to other resolution. If this is the case, please automate your application using ID, Class, Xpath, CSS etc. This link will help you in that: http://www.guru99.com/locators-in-selenium-ide.html

For automation using Excel, please look into the following link:
http://www.guru99.com/all-about-excel-in-selenium-poi-jxl.html

Title: UI automation with excel


问:
How to get the value of parameter in servlet?
```<code>public class Sender extends HttpServlet {

  @Override
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {

    Test t=new Test();
    StringBuilder a=player;

  }

  public void attackPlayer(StringBuilder player){
    System.out.println("code"+player);
  }
}
</code>```

i want to store the value of player in variable a. Is it possible to get the value of parameter

答:
If you are talking about request parameters, e.g.

```<code>http://yoururl.com?player=fred
</code>```

then you can retrieve them using

```<code>String player = request.getParameter("player");
</code>```

Body:
public class Sender extends HttpServlet {

  @Override
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {

    Test t=new Test();
    StringBuilder a=player;

  }

  public void attackPlayer(StringBuilder player){
    System.out.println("code"+player);
  }
}

i want to store the value of player in variable a. Is it possible to get the value of parameter

Body:
If you are talking about request parameters, e.g.

http://yoururl.com?player=fred

then you can retrieve them using

String player = request.getParameter("player");


问:
d3.js margin values echoed from PHP don't work
I echo margins for my graph from PHP(Laravel) into JavaScript like this:

```<code>margin = {
    top: {!! $margins !!}[ 0 ],
    bottom: {!! $margins !!}[ 1 ],
    left: {!! $margins !!}[ 2 ],
    right: {!! $margins !!}[ 3 ]
},
</code>```

$margins is an array which has many values. Console.log( {!! $margins !!}[ 0 ] ) returns a correct value for margin, which is 30. When I look at the source though, I see:

```<code>margin = {
    top: ["30","30","50","20","30","30","50","20"][ 0 ],
    bottom: ["30","30","50","20","30","30","50","20"][ 1 ],
    left: ["30","30","50","20","30","30","50","20"][ 2 ],
    right: ["30","30","50","20","30","30","50","20"][ 3 ]
},
</code>```

The problem is that d3 seems to sum up all the margin values in the array. I.e. instead of 30, it returns 30+30+50+20+30+30+50+20 = 260.

Does anyone know why it does it and how I can fix it?

EDIT: I had it a bit wrong. It doesn't sum up the array values, it edits SVG height instead when I set margins from JSON array.

答:
There might be a bug. As of d3.js 4.9.1, it is still there. Top and bottom margins must be forced into numeric data types, otherwise they take JSON string as an input. Left and right margins are automatically converted into integers. So this works:</p>

```<code>margin = {
    top: {!! $margins !!}[ 0 ] * 1,
    bottom: {!! $margins !!}[ 1 ] * 1,
    left: {!! $margins !!}[ 2 ],
    right: {!! $margins !!}[ 3 ]
},
</code>```

Body:
I echo margins for my graph from PHP(Laravel) into JavaScript like this:

margin = {
    top: {!! $margins !!}[ 0 ],
    bottom: {!! $margins !!}[ 1 ],
    left: {!! $margins !!}[ 2 ],
    right: {!! $margins !!}[ 3 ]
},

$margins is an array which has many values. Console.log( {!! $margins !!}[ 0 ] ) returns a correct value for margin, which is 30. When I look at the source though, I see:

margin = {
    top: ["30","30","50","20","30","30","50","20"][ 0 ],
    bottom: ["30","30","50","20","30","30","50","20"][ 1 ],
    left: ["30","30","50","20","30","30","50","20"][ 2 ],
    right: ["30","30","50","20","30","30","50","20"][ 3 ]
},

The problem is that d3 seems to sum up all the margin values in the array. I.e. instead of 30, it returns 30+30+50+20+30+30+50+20 = 260.

Does anyone know why it does it and how I can fix it?

EDIT: I had it a bit wrong. It doesn't sum up the array values, it edits SVG height instead when I set margins from JSON array.

Body:
There might be a bug. As of d3.js 4.9.1, it is still there. Top and bottom margins must be forced into numeric data types, otherwise they take JSON string as an input. Left and right margins are automatically converted into integers. So this works:

margin = {
    top: {!! $margins !!}[ 0 ] * 1,
    bottom: {!! $margins !!}[ 1 ] * 1,
    left: {!! $margins !!}[ 2 ],
    right: {!! $margins !!}[ 3 ]
},


问:
How do I activate a feature + popup when clicking outside of a map in Openlayers?
I'm re-parsing the KML that's already been loaded onto the map similar to the example here:
http://openlayers.org/dev/examples/sundials.html and turning it into a clickable list that will center the map on the point clicked, and display the popup window for it.

This was really easy to do in Google Maps, but I can't find any similar Openlayers examples. Is there any easier way to do this? Something built-in that I'm missing?

HTML:

```<code><ul id="locationTable">
</ul>
</code>```

JS:

```<code> htmlRows = "";
 for(var feat in features) {
     // Build details table
     featId = features[feat].id; // determine the feature ID
     title = jQuery(f).filter('[name=TITLE]').text();

     htmlRow = "<li><a href="javascript:selectFeature('"+featId+"');\">"+title+"</a></li>";
     htmlRows = htmlRows + htmlRow;
 }
 jQuery('#locationTable').append(htmlRows);
</code>```

And then for the selectFeature function:

```<code>function selectFeature(fid) {
    for(var i = 0; i<kml.features.length;++i) {
                     if (kml.features[i].id == fid)
                         {
                             selected = new OpenLayers.Control.SelectFeature(kml.features[i]);
                             selected.clickFeature(); // make call to simulate Click event of feature
                             break;
                         }
            }

        }
</code>```

答:
I think you should remove the "selected.clickFeature" call, and instead create an event listener for the "featureselected" event in your feature layer:

OpenLayers.Layer.Vector

If you display the popup in that event, you will only have to find it and select it with your existing code, and remove the line
selected.clickFeature();

Sidenote: Can your feature server deliver data in other formats? WFS for instance? Parsing KML data shouldn't be needed.

Body:
I'm re-parsing the KML that's already been loaded onto the map similar to the example here:
http://openlayers.org/dev/examples/sundials.html and turning it into a clickable list that will center the map on the point clicked, and display the popup window for it.

This was really easy to do in Google Maps, but I can't find any similar Openlayers examples. Is there any easier way to do this? Something built-in that I'm missing?

HTML:

JS:

 htmlRows = "";
 for(var feat in features) {
     // Build details table
     featId = features[feat].id; // determine the feature ID
     title = jQuery(f).filter('[name=TITLE]').text();

     htmlRow = "
"+title+"
";
     htmlRows = htmlRows + htmlRow;
 }
 jQuery('#locationTable').append(htmlRows);

And then for the selectFeature function:

function selectFeature(fid) {
    for(var i = 0; i<kml.features.length;++i) {
                     if (kml.features[i].id == fid)
                         {
                             selected = new OpenLayers.Control.SelectFeature(kml.features[i]);
                             selected.clickFeature(); // make call to simulate Click event of feature
                             break;
                         }
            }

        }


问:
Annotation in OWL API
I am learning how to use OWL API, I found this API is not the same as the API I used before. I am trying to figure out some simple concepts.I can't understand "Annotation". I get these from wiki:

The OWL abstract syntax presents an ontology as a sequence of
  annotations, axioms and facts. Annotations carry machine and human
  oriented meta-data.

If you are familiar with the owl, can you give me an example? What does "machine and human oriented meta-data" mean?
Thanks a lot.

Update:

Thanks for answering me. I also want to write a example:

```<code><http://data.doremus.org/performance/4db95574-8497-3f30-ad1e-f6f65ed6c896>
    a                      mus:M42_Performed_Expression_Creation ;
    ecrm:P3_has_note       "Créée par Teodoro Anzellotti, son commanditaire, en novembre 1995 à Rotterdam" ;
    ecrm:P4_has_time-span  <http://data.doremus.org/performance/4db95574-8497-3f30-ad1e-f6f65ed6c896/time> ;
    ecrm:P9_consists_of    [ a                        mus:M28_Individual_Performance ;
                             ecrm:P14_carried_out_by  "Teodoro Anzellotti"
                           ] ;
    ecrm:P9_consists_of    [ a                        mus:M28_Individual_Performance ;
                             ecrm:P14_carried_out_by  "à Rotterdam"
                           ] ;
    efrbroo:R17_created    <http://data.doremus.org/expression/2fdd40f3-f67c-30a0-bb03-f27e69b9f07f> ;
    efrbroo:R19_created_a_realisation_of
            <http://data.doremus.org/work/907de583-5247-346a-9c19-e184823c9fd6> ;
    efrbroo:R25_performed  <http://data.doremus.org/expression/b4bb1588-dd83-3915-ab55-b8b70b0131b5> .
</code>```

I think there is annotation in this example, the object of "ecrm:P9_consists_of" is not annotation. If I want to add annotation to ecrm:P3_has_not, how to do that?
Thanks a lot.

答:
the simplest example of owl-annotation is a annotation assertion, e.g:

```<code>_:x rdfs:comment "this is a comment"@en
</code>```

where predicate rdfs:comment - is a builtin annotation property, and there are 8 such builtin properties.
you can also provide your own annotation properties.
you can also make annotation of annotations and build a tree of annotations.
The example of сomplex nested annotations (turtle):

```<code>[ a                      owl:Annotation ;
  rdfs:comment           "indi-comment" ;
  owl:annotatedProperty  rdfs:comment ;
  owl:annotatedSource    [ a                      owl:Axiom ;
                           rdfs:comment           "INDI-ANN" ;
                           owl:annotatedProperty  rdf:type ;
                           owl:annotatedSource    :Indi ;
                           owl:annotatedTarget    :SomeClass1
                         ] ;
  owl:annotatedTarget    "INDI-ANN"
] .
</code>```

The same in functional syntax:

```<code>ClassAssertion(Annotation(Annotation(rdfs:comment "indi-comment"^^xsd:string) rdfs:comment "INDI-ANN"^^xsd:string) <#SomeClass1> <#Indi>)
</code>```

Here we have class-assertion axiom, which binds named-individual ':Indi' with class ':SomeClass1'; this axiom is annotated with rdfs:comment="INDI-ANN", which, in its turns, has annotation rdfs:comment(annotation-property)="indi-comment"(annotation-value).

I think functional-syntax representation can be considered as 'human-oriented meta-data', while turtle as 'machine-oriented' one.

In general, annotation is a way to provide additional (and optional) information about owl-statements (owl-axioms). It could be a version, a link, some custom annotation-property, etc.

Remark: it is about OWL2 specification rather then about OWL-API. Any API which meets specification must provide the similar way to handle owl-annotations.

Title: Annotation in OWL API

Body:
I am learning how to use OWL API, I found this API is not the same as the API I used before. I am trying to figure out some simple concepts.I can't understand "Annotation". I get these from wiki:

The OWL abstract syntax presents an ontology as a sequence of
  annotations, axioms and facts. Annotations carry machine and human
  oriented meta-data.

If you are familiar with the owl, can you give me an example? What does "machine and human oriented meta-data" mean?
Thanks a lot.

Update:

Thanks for answering me. I also want to write a example:

<http://data.doremus.org/performance/4db95574-8497-3f30-ad1e-f6f65ed6c896>
    a                      mus:M42_Performed_Expression_Creation ;
    ecrm:P3_has_note       "Créée par Teodoro Anzellotti, son commanditaire, en novembre 1995 à Rotterdam" ;
    ecrm:P4_has_time-span  <http://data.doremus.org/performance/4db95574-8497-3f30-ad1e-f6f65ed6c896/time> ;
    ecrm:P9_consists_of    [ a                        mus:M28_Individual_Performance ;
                             ecrm:P14_carried_out_by  "Teodoro Anzellotti"
                           ] ;
    ecrm:P9_consists_of    [ a                        mus:M28_Individual_Performance ;
                             ecrm:P14_carried_out_by  "à Rotterdam"
                           ] ;
    efrbroo:R17_created    <http://data.doremus.org/expression/2fdd40f3-f67c-30a0-bb03-f27e69b9f07f> ;
    efrbroo:R19_created_a_realisation_of
            <http://data.doremus.org/work/907de583-5247-346a-9c19-e184823c9fd6> ;
    efrbroo:R25_performed  <http://data.doremus.org/expression/b4bb1588-dd83-3915-ab55-b8b70b0131b5> .

I think there is annotation in this example, the object of "ecrm:P9_consists_of" is not annotation. If I want to add annotation to ecrm:P3_has_not, how to do that?
Thanks a lot.

Body:
the simplest example of owl-annotation is a annotation assertion, e.g:

_:x rdfs:comment "this is a comment"@en

where predicate rdfs:comment - is a builtin annotation property, and there are 8 such builtin properties.
you can also provide your own annotation properties.
you can also make annotation of annotations and build a tree of annotations.
The example of сomplex nested annotations (turtle):

[ a                      owl:Annotation ;
  rdfs:comment           "indi-comment" ;
  owl:annotatedProperty  rdfs:comment ;
  owl:annotatedSource    [ a                      owl:Axiom ;
                           rdfs:comment           "INDI-ANN" ;
                           owl:annotatedProperty  rdf:type ;
                           owl:annotatedSource    :Indi ;
                           owl:annotatedTarget    :SomeClass1
                         ] ;
  owl:annotatedTarget    "INDI-ANN"
] .

The same in functional syntax:

ClassAssertion(Annotation(Annotation(rdfs:comment "indi-comment"^^xsd:string) rdfs:comment "INDI-ANN"^^xsd:string) <#SomeClass1> <#Indi>)

Here we have class-assertion axiom, which binds named-individual ':Indi' with class ':SomeClass1'; this axiom is annotated with rdfs:comment="INDI-ANN", which, in its turns, has annotation rdfs:comment(annotation-property)="indi-comment"(annotation-value).

I think functional-syntax representation can be considered as 'human-oriented meta-data', while turtle as 'machine-oriented' one.

In general, annotation is a way to provide additional (and optional) information about owl-statements (owl-axioms). It could be a version, a link, some custom annotation-property, etc.

Remark: it is about OWL2 specification rather then about OWL-API. Any API which meets specification must provide the similar way to handle owl-annotations.


问:
excel vba finding with like or regex
I'm writing a VBA program.
I have a problem with finding this string [BLOCKED] in one column

```<code>For j = 0 To 4
    For i = 2 To lastrow
        If Cells(i, 12).Value = groupnames(j) And Cells(i, 8).Value Like "*" & "[BLOCKED]" & "*" Then
            groupsum(j) = groupsum(j) + 1
        End If
    Next i
Next j
</code>```

The problem is I have 96 cells for this string but the program found 500 how can I do this to going work?

Thanks for help

答:
The syntax of your Like  operation is incorrect.  Use:

```<code>... Like "*[[]BLOCKED]*"
</code>```

[...] is a Character class.  So, the way you have it written in your question, it will find any single character in the set of BLOCKED.  That is not what you want, apparently.

To match the [ character, you enclose it within a character class, as I have shown.  To match the ] character, it must be outside of a character class.

Title: excel vba finding with like or regex

Body:
I'm writing a VBA program.
I have a problem with finding this string [BLOCKED] in one column

For j = 0 To 4
    For i = 2 To lastrow
        If Cells(i, 12).Value = groupnames(j) And Cells(i, 8).Value Like "*" & "[BLOCKED]" & "*" Then
            groupsum(j) = groupsum(j) + 1
        End If
    Next i
Next j

The problem is I have 96 cells for this string but the program found 500 how can I do this to going work?

Thanks for help

Body:
The syntax of your Like  operation is incorrect.  Use:

... Like "*[[]BLOCKED]*"

[...] is a Character class.  So, the way you have it written in your question, it will find any single character in the set of BLOCKED.  That is not what you want, apparently.

To match the [ character, you enclose it within a character class, as I have shown.  To match the ] character, it must be outside of a character class.


问:
How do I pass parameters to a salt state file?
I want to create a group and user using salt state files, but I do not know the group, gid, user, uid, sshkey until I need to execute the salt state file which I would like to pass in as parameters.

I have read about Pillar to create the variable. How do I create pillars before execution?

/srv/salt/group.sls:

```<code>{{ name }}:
  group.present:
    - gid: {{ gid }}
    - system: True
</code>```

Command line:

```<code>salt 'SaltStack-01' state.sls group name=awesome gid=123456
</code>```

答:
if you do not want use Pillar

you can do as:

```<code># /srv/salt/params.yaml

name: awesome
gid: 123456
</code>```

and then:

```<code># /srv/salt/groups.sls

{% import_yaml "params.yaml" as params %}

{{ params['name'] }}:
  group.present:
    - gid: {{ params['gid'] }}
    - system: True
</code>```

more details:doc

Body:
I want to create a group and user using salt state files, but I do not know the group, gid, user, uid, sshkey until I need to execute the salt state file which I would like to pass in as parameters.

I have read about Pillar to create the variable. How do I create pillars before execution?

/srv/salt/group.sls:

{{ name }}:
  group.present:
    - gid: {{ gid }}
    - system: True

Command line:

salt 'SaltStack-01' state.sls group name=awesome gid=123456

Body:
if you do not want use Pillar

you can do as:

# /srv/salt/params.yaml

name: awesome
gid: 123456

and then:

# /srv/salt/groups.sls

{% import_yaml "params.yaml" as params %}

{{ params['name'] }}:
  group.present:
    - gid: {{ params['gid'] }}
    - system: True

more details:doc


问:
VS402375: Can't find the process associated with team project
I'm getting this error while trying to access Administration Page of my collection:
Administratio Page ERROR

I tried upload TFS.Configuration database, but no success so far.

This is the results of my sql selects:
SQL SELECT

答:
According the error info VS402375: Can't find the process associated with team project 'xxx'. Contact support to resolve this error.

It looks like the process template (which you used for the project) is missing in the team project collection database.

A solution is restoring your back-up database, which may do the trick for this issue. Daniel is right, it's highly not recommend to modify TFS databases yourself.

Another solution is manually changing the templateID  to match what your collection. More detail steps please take a look at bmonwai's answer in this similar question.


问:
Are there any good 3rd party GUI products for Python?
In .Net you have companies like DevEpxress, and Infragistics that offer a range of GUI widgets.  Is there any market like that for Python GUI widgets?  I'm thinking specifically about widgets like the DevExpress xtraGrid Suite.

Edit 01-16-09:  For Example:

http://www.devexpress.com/Downloads/NET/OnlineDemos.xml
http://demos.devexpress.com/ASPxGridViewDemos/

http://www.infragistics.com/products/default.aspx

答: The popular Python GUI toolkits are usually wrappers around external (usually C, C++) libraries. So whatever 3rd party products those external libraries have, Python code can benefit (by minimal manual wrapping even in case the 3rd party solution does not provide Python wrappers by default).</p>

OwnerDisplayName: mchean

LastEditorDisplayName: mchean

OwnerDisplayName: utku karatas

LastEditorDisplayName: utku karatas


问:
How to handle “CFNetwork SSLHandshake failed(-9807)” in iOS
I am getting CFNetwork SSL Handshake failed(-9807) in my ios application while logging into application.

I am using Xcode version 7.3 for my application.
I think this problem occurs due to expired ssl certificates, but I am not able to handle the problem and I don't able to figure out where to put this ssl certificates in the application.

Can U please suggest me some solution??

答:
Normally when I get CFNetwork SSLHandshake failed -(*) It's because of my wifi network or due to Security reason firewall block the connection.

Try it again on another network.


问:
Resize objects in view while opening sidebar/menu Swift
I am currently programming the app with side bar/menu and I would like to leave some functions from the view which is partially hidden when the side bar is opened. I was thinking about resizing/transitioning/disappearing of some objects from the main view while opening the side bar from right

For example, the main view/page is hidden I would like to resize some things so they still can be clickable and functional and when you drag it back the normal view appears again

I guess it mostly looks like a new view with animation, but I didn't find the way how to implement that and therefore I decided to do with sidebar. Could you tell me please, how to make the view changeable according to sidebar and make some objects appear instead of simply have partial information on that side?

Here is the actual application:

The main view is just with coverArts (first in the middle and second is in the bottom) and when dragging/opening the side bar the first cover resizes according to slide movement and second bottom cover just goes directly. Then it should look like on the second picture.

答:
========= ADD OBSERVER IN VIEW WILL APPEAR    =======

```<code>NotificationCenter.default.addObserver(self, selector: #selector(YourVC.showOverlayView), name: Notification.Name("showOverlayView"), object: nil)

NotificationCenter.default.addObserver(self, selector: #selector(YourVC.hideOverlayView), name: Notification.Name("hideOverlayView"), object: nil)
</code>```

========= You can Hide and Show From Here    =======

```<code>func showOverlayView() {
       UIView.animate(withDuration: 2.0, animations: {
            self.viewBlackOverLay     = UIView(frame: CGRect(x: 0, y: 0, width: screenSize.width, height: screenSize.height))
            self.viewBlackOverLay.backgroundColor = UIColor.black.withAlphaComponent(0.3)
            self.view.addSubview(self.viewBlackOverLay)
        })
    }

func hideOverlayView() {
    UIView.animate(withDuration: 1.0, animations: {
        self.viewBlackOverLay.removeFromSuperview()
    })
}
</code>```

========= POST OBSERVER   =======

When you want to Open side menu add below Line

NotificationCenter.default.post(name: NSNotification.Name(rawValue: "showOverlayView"), object: nil)

Where you close side menu add below Line

NotificationCenter.default.post(name: NSNotification.Name(rawValue: "hideOverlayView"), object: nil)

Body:
========= ADD OBSERVER IN VIEW WILL APPEAR    =======

NotificationCenter.default.addObserver(self, selector: #selector(YourVC.showOverlayView), name: Notification.Name("showOverlayView"), object: nil)

NotificationCenter.default.addObserver(self, selector: #selector(YourVC.hideOverlayView), name: Notification.Name("hideOverlayView"), object: nil)

========= You can Hide and Show From Here    =======

func showOverlayView() {
       UIView.animate(withDuration: 2.0, animations: {
            self.viewBlackOverLay     = UIView(frame: CGRect(x: 0, y: 0, width: screenSize.width, height: screenSize.height))
            self.viewBlackOverLay.backgroundColor = UIColor.black.withAlphaComponent(0.3)
            self.view.addSubview(self.viewBlackOverLay)
        })
    }

func hideOverlayView() {
    UIView.animate(withDuration: 1.0, animations: {
        self.viewBlackOverLay.removeFromSuperview()
    })
}

========= POST OBSERVER   =======

When you want to Open side menu add below Line

NotificationCenter.default.post(name: NSNotification.Name(rawValue: "showOverlayView"), object: nil)

Where you close side menu add below Line

NotificationCenter.default.post(name: NSNotification.Name(rawValue: "hideOverlayView"), object: nil)


问:
Pandas: converting strings representing numbers, with characters, into float/ int
From a daily report, I use:

```<code>pd.read_csv(filepath, sep = '\t')
</code>```

to open a dataframe looking like the below (in simplified format):

```<code>finalDf2 = pd.DataFrame(dict(
            Portfolio = pd.Series(['Book1', 'Book1', 'Book2', 'Book3', 'Book1','Book1']),
            Strike = pd.Series(['108','109.10', '111', '114', '108.3', '115.0']),
            Notional = pd.Series(['0', '-0.02', '35', '. 3K', '-0.05K', '0' ]))
     )
</code>```

By running the below on various entries under the "Notional" column:

```<code>type(finalDf2.iloc[ , ]
</code>```

I see the 0s are of type int already.

The nonzero values however are strings. I tried to convert strings to floats by using:

```<code>finalDf2['Notional'].astype(float)
</code>```

but before doing so, how could I convert all cells containing "K" values?
For instance,

. 3K should end up being float or int 30

 -0. 05K should end up being float or int -50

Spacings are actually in the file and thus dataframe unfortunately.

答:
First, replace spaces.

```<code>In [344]: s = finalDf2['Notional'].str.replace(' ', '0')
</code>```

Then, extract numerical part, and 'K' part, replacing K with 1000.

```<code>In [345]: (s.str.extract(r'(-?[\d\.]+)', expand=False).astype(float) *
           s.str.extract(r'([K]+)', expand=False).replace([np.nan, 'K'], [1, 1000]) )
Out[345]:
0     0.00
1    -0.02
2    35.00
3    30.00
4   -50.00
5     0.00
Name: Notional, dtype: float64
</code>```

Body:
From a daily report, I use:

pd.read_csv(filepath, sep = '\t')

to open a dataframe looking like the below (in simplified format):

finalDf2 = pd.DataFrame(dict(
            Portfolio = pd.Series(['Book1', 'Book1', 'Book2', 'Book3', 'Book1','Book1']),
            Strike = pd.Series(['108','109.10', '111', '114', '108.3', '115.0']),
            Notional = pd.Series(['0', '-0.02', '35', '. 3K', '-0.05K', '0' ]))
     )

By running the below on various entries under the "Notional" column:

type(finalDf2.iloc[ , ]

I see the 0s are of type int already.

The nonzero values however are strings. I tried to convert strings to floats by using:

finalDf2['Notional'].astype(float)

but before doing so, how could I convert all cells containing "K" values?
For instance,

. 3K should end up being float or int 30

 -0. 05K should end up being float or int -50

Spacings are actually in the file and thus dataframe unfortunately.

Body:
First, replace spaces.

In [344]: s = finalDf2['Notional'].str.replace(' ', '0')

Then, extract numerical part, and 'K' part, replacing K with 1000.

In [345]: (s.str.extract(r'(-?[\d\.]+)', expand=False).astype(float) *
           s.str.extract(r'([K]+)', expand=False).replace([np.nan, 'K'], [1, 1000]) )
Out[345]:
0     0.00
1    -0.02
2    35.00
3    30.00
4   -50.00
5     0.00
Name: Notional, dtype: float64


问:
Chrome scrollbar overlapping div border by 1 pixel
In Chrome 33.0.1750.146 m, when a div with a 1-pixel border and a scrollbar has fractional pixel width (where the fractional part is >= 0.5) inside another div with a percentage width (< 100%), the right side of the border is sometimes hidden, depending on rounding. This seems to happen because the scrollbar's position and the right side of the div are rounded in different directions, causing the scrollbar to overlap the right side of the div by one pixel.

Is this a known bug or is there a workaround? I'm experiencing this graphical glitch inside a PhpBB template page, where the content is centered and widths are automatically calculated which has resulted in a ---.5px width div, and I've traced it down to the following minimum reproducible sample:

HTML:

```<code><div id="wrapper">
    <div class="box">
        <p>Test content</p>
        <p>Test content</p>
        <p>Test content</p>
        <p>Test content</p>
    </div>
</div>
</code>```

CSS:

```<code>.box {
    height: 100px;
    overflow: auto;
    border: 1px solid;
}

#wrapper {
    max-width: 75%;
    margin: auto;
}
</code>```

Example JSFiddle — resize the window and observe the right border flicker/appear/disappear.

答:
I had similar issue. I had div with scrollbar and border-right set to 2px and when I was resizing the window I had the scrollbar or don't in result I had 1px border when scrollbar was on and 2px when not.

I've fixed it by adding 3px border and setting:

```<code>overflow-y: scroll;
</code>```

so the scrollbar is always visible and the border has always 2px visible width.

Body:
In Chrome 33.0.1750.146 m, when a div with a 1-pixel border and a scrollbar has fractional pixel width (where the fractional part is >= 0.5) inside another div with a percentage width (< 100%), the right side of the border is sometimes hidden, depending on rounding. This seems to happen because the scrollbar's position and the right side of the div are rounded in different directions, causing the scrollbar to overlap the right side of the div by one pixel.

Is this a known bug or is there a workaround? I'm experiencing this graphical glitch inside a PhpBB template page, where the content is centered and widths are automatically calculated which has resulted in a ---.5px width div, and I've traced it down to the following minimum reproducible sample:

HTML:

Test content

Test content

Test content

Test content

CSS:

.box {
    height: 100px;
    overflow: auto;
    border: 1px solid;
}

#wrapper {
    max-width: 75%;
    margin: auto;
}

Example JSFiddle — resize the window and observe the right border flicker/appear/disappear.

Body:
I had similar issue. I had div with scrollbar and border-right set to 2px and when I was resizing the window I had the scrollbar or don't in result I had 1px border when scrollbar was on and 2px when not.

I've fixed it by adding 3px border and setting:

overflow-y: scroll;

so the scrollbar is always visible and the border has always 2px visible width.


问:
Unable to retreive unique dates from mysql column having date and time in mysql using php
Hi friend am trying to retreive the dates from mysql column named 'date' which has date and time. I want to retreive only dates not times. I want retreive only dates which are not duplicates..

Here is sample data of mysql with column date..

```<code>   03/07/2017 03:37:12pm
   03/07/2017 10:38:12pm
   04/07/2017 10:38:12pm
   04/07/2017 2:38:12pm
</code>```

wanted out put as

```<code>     03/07/2017
     04/07/2017
</code>```

Here is my php code

```<code><?php

$sql = "SELECT  DISTINCT date('d/m/Y,date) FROM video_data";
echo $sql;
$result = mysqli_query($connection, $sql);
echo $result;
while ($row = mysqli_fetch_assoc($result)) {
    $id   = $row['id'];
    $date = $row['date'];
    $date = date('Y-m-d', strtotime($date));
    echo "<tr>";
    echo "<td>$date</td>";
    echo "</tr>";

}

?>
</code>```

Am unable to print dates using php

答:
select distinct value from db and convert them according to your need.</p>

```<code>$sql = "SELECT DISTINCT DATE_FORMAT(date, '%d/%m/%Y') FROM  video_data;"
$result = mysqli_query($connection, $sql);
while ($row = mysqli_fetch_assoc($result)) {
 $id   = $row['id'];
 $date = $row['date'];
 $date = date('d/m/Y', strtotime($date));
 echo "<tr>";
 echo "<td>".$date."</td>";
 echo "</tr>";
}
</code>```

Body:
Hi friend am trying to retreive the dates from mysql column named 'date' which has date and time. I want to retreive only dates not times. I want retreive only dates which are not duplicates..

Here is sample data of mysql with column date..

   03/07/2017 03:37:12pm
   03/07/2017 10:38:12pm
   04/07/2017 10:38:12pm
   04/07/2017 2:38:12pm

wanted out put as

     03/07/2017
     04/07/2017

Here is my php code

<?php

$sql = "SELECT  DISTINCT date('d/m/Y,date) FROM video_data";
echo $sql;
$result = mysqli_query($connection, $sql);
echo $result;
while ($row = mysqli_fetch_assoc($result)) {
    $id   = $row['id'];
    $date = $row['date'];
    $date = date('Y-m-d', strtotime($date));
    echo "
";
    echo "$date	";
    echo "
";

}

?>

Am unable to print dates using php

Body:
select distinct value from db and convert them according to your need.

$sql = "SELECT DISTINCT DATE_FORMAT(date, '%d/%m/%Y') FROM  video_data;"
$result = mysqli_query($connection, $sql);
while ($row = mysqli_fetch_assoc($result)) {
 $id   = $row['id'];
 $date = $row['date'];
 $date = date('d/m/Y', strtotime($date));
 echo "<tr>";
 echo "<td>".$date."</td>";
 echo "</tr>";
}


问: Modifying

答:
Something like this must do:

```<code>SetterBase sb = style.Setters[0];
Setter s = (Setter)sb;
s.TargetName = "abcd";
</code>```

(at least in WPF)

Edit:

In Silverlight there's no TargetName, but you can still access Property and Value. So, you say something like if (s.Property == Button.IsEnabled) s.Value = false;.

Edit:

Oh, you found a better solution yourself. :-) Didn't know that it's not allowed to change the Value.

Title: Modifying <Style> from code

Body:
I need to modify a Style in resources from code.  I already know I can access the Setters like that :

 Style st = (Style)this.Resources["myStyle"];
 set.Setters.Etc...

But I need to change the value of a specific Setter in that style.  Is there any way to do it?

Also, how can I retrieve the appropriate setter in the setters list based on the "Property"

thanks

Body:
Something like this must do:

SetterBase sb = style.Setters[0];
Setter s = (Setter)sb;
s.TargetName = "abcd";

(at least in WPF)

Edit:

In Silverlight there's no TargetName, but you can still access Property and Value. So, you say something like if (s.Property == Button.IsEnabled) s.Value = false;.

Edit:

Oh, you found a better solution yourself. :-) Didn't know that it's not allowed to change the Value.


问:
how to get the particular value from Json?
I am having the Json data as shown below in this I need to get the data that which key value pair for default is 1 then i need to get the remaining dictionaries data and need to be passed to the user to display can any one tell me how to implement this ?

And my code is as shown below

```<code>            if let addressArray = jsonObj!.value(forKey: "address") as? NSArray{
                    for array in addressArray {
                        if let addressDict = array as? NSDictionary{
                            if let Default = addressDict.value(forKey: "default"){

                            }
                        }
                    }
                }
 "address": [
    {
      "default": 0,
      "number": 9123456711,
      "name": "Ramesh",
      "address": "No:11/111 ,cross street,Nungambakkam,mylapore,chennai :600088"
    },
    {
      "default": 1,
      "number": 8123456722,
      "name": "Vignesh",
      "address": "No:22/222 ,cross street,Perambur,chennai :600012"
    },
    {
      "default": 0,
      "number": 7123456733,
      "name": "Rajesh",
      "address": "No:33/333 ,cross street,Villivakkam,chennai :600045"
    }
  ]
</code>```

答:
Step1: Prepare your model as shown in below code snippet.

```<code>class Addresses: NSObject {

var default = 0
var number = 0
var name = String()
var address = String()

init?(dictionary:[String:Any]) {

    guard let default = dictionary["default"],
        let number = dictionary["number"],
        let name = dictionary["name"],
        let address = dictionary["address"]
        else {
        return nil
    }
    self.default = default
    self.number = number
    self.name = name
    self.address = address
  }
 }
</code>```

Step2: Declare an array to store parsed addresses.

```<code>var addressesArray = [Addresses]()
</code>```

Step3:

```<code>if let addressArray = jsonObj!.value(forKey: "address") as? NSArray{
                for array in addressArray {
                    if let addressDict = array as? NSDictionary{
                        if let defaultValue = addressDict.value(forKey: "default") as? Int{
                            if defaultValue == 1 {
                             if let address = Addresses(dictionary: addressDict) {
                                addressesArray.append(address)
                           }
                          }

                        }
                    }
                }
            }
</code>```

Thats it, take care of datatypes, and you can use addressesArray to display data.

Body:
I am having the Json data as shown below in this I need to get the data that which key value pair for default is 1 then i need to get the remaining dictionaries data and need to be passed to the user to display can any one tell me how to implement this ?

And my code is as shown below

            if let addressArray = jsonObj!.value(forKey: "address") as? NSArray{
                    for array in addressArray {
                        if let addressDict = array as? NSDictionary{
                            if let Default = addressDict.value(forKey: "default"){

                            }
                        }
                    }
                }
 "address": [
    {
      "default": 0,
      "number": 9123456711,
      "name": "Ramesh",
      "address": "No:11/111 ,cross street,Nungambakkam,mylapore,chennai :600088"
    },
    {
      "default": 1,
      "number": 8123456722,
      "name": "Vignesh",
      "address": "No:22/222 ,cross street,Perambur,chennai :600012"
    },
    {
      "default": 0,
      "number": 7123456733,
      "name": "Rajesh",
      "address": "No:33/333 ,cross street,Villivakkam,chennai :600045"
    }
  ]

Body:
Step1: Prepare your model as shown in below code snippet.

class Addresses: NSObject {

var default = 0
var number = 0
var name = String()
var address = String()

init?(dictionary:[String:Any]) {

    guard let default = dictionary["default"],
        let number = dictionary["number"],
        let name = dictionary["name"],
        let address = dictionary["address"]
        else {
        return nil
    }
    self.default = default
    self.number = number
    self.name = name
    self.address = address
  }
 }

Step2: Declare an array to store parsed addresses.

var addressesArray = [Addresses]()

Step3:

if let addressArray = jsonObj!.value(forKey: "address") as? NSArray{
                for array in addressArray {
                    if let addressDict = array as? NSDictionary{
                        if let defaultValue = addressDict.value(forKey: "default") as? Int{
                            if defaultValue == 1 {
                             if let address = Addresses(dictionary: addressDict) {
                                addressesArray.append(address)
                           }
                          }

                        }
                    }
                }
            }

Thats it, take care of datatypes, and you can use addressesArray to display data.


问:
Angular js - Call function inside controller from view in ng-admin
I am working with the feature of multiple languages for ng-admin.
In the file header.html, I have added a dropdown with a list of languages. Clicking each option fires a function call.

The function itself is inside a controller in /js/main.js

Clicking in any of the languages results in ReferenceError: serve_language is not defined.

This is the content of both files:

header.html

```<code><ul class="nav navbar-top-links navbar-right hidden-xs">
    <li uib-dropdown ng-controller="languageCtrl">
        <a uib-dropdown-toggle href="#" aria-expanded="true">
            <i class="fa fa-user fa-lg"></i>  Language <i class="fa fa-caret-down"></i>
        </a>
        <ul class="dropdown-menu dropdown-user" role="menu">
            <li><a href="#" onclick="serve_language('en')"><i class="fa fa-sign-out fa-fw"></i> English</a></li>
            <li><a href="#" onclick="serve_language('ge')"><i class="fa fa-sign-out fa-fw"></i> German</a></li>
            <li><a href="#" onclick="serve_language('fr')"><i class="fa fa-sign-out fa-fw"></i> French</a></li>
            <li><a href="#" onclick="serve_language('sp')"><i class="fa fa-sign-out fa-fw"></i> Spanish</a></li>
        </ul>
    </li>
</ul>
</code>```

main.js

```<code>'use strict'
var myApp = angular.module('myApp', ['ng-admin','ng-admin.jwt-auth', 'nvd3']);
myApp.controller('languageCtrl', ['$translate', '$scope', function ($translate, $scope) {
    $scope.serve_language = function (langKey) {
       console.log("@langctrl");
    };
}]);
</code>```

I also tried calling the function as languageCtrl.serve_language(), but that resulted in ReferenceError: languageCtrl is not defined

答:
Don't use  href="#" and ng-click else it will redirect to your default routing(if routing is added).

Use ng-click in place of onclick.

Body:
I am working with the feature of multiple languages for ng-admin.
In the file header.html, I have added a dropdown with a list of languages. Clicking each option fires a function call.

The function itself is inside a controller in /js/main.js

Clicking in any of the languages results in ReferenceError: serve_language is not defined.

This is the content of both files:

header.html

              Language

 English

 German

 French

 Spanish

main.js

'use strict'
var myApp = angular.module('myApp', ['ng-admin','ng-admin.jwt-auth', 'nvd3']);
myApp.controller('languageCtrl', ['$translate', '$scope', function ($translate, $scope) {
    $scope.serve_language = function (langKey) {
       console.log("@langctrl");
    };
}]);

I also tried calling the function as languageCtrl.serve_language(), but that resulted in ReferenceError: languageCtrl is not defined


问:
eclipse for c++ developers MinGW error
I just installed the Eclipse for C++ Developers, but my problem is that it does not recognize MinGW (MinGW is in the System Environment Variables, if i open CMD where ever it runs gcc --version just fine)
in eclipse settings under C++ i have the environment variables set also..
but when i open new c++ project nothing gets recognized (libraries, syntax, etc..) and my only toolchain available is Cross GCC witch i do not have installed..
CodeBlocks works fine with C++
but i want to try eclipse..

答:
Solved it by putting mingw32-gcc.exe in the bin folder..
in other words.. eclipse needs the 32bit version of minwg..</p>

Title: eclipse for c++ developers MinGW error


问:
Row re-order angular js in datatable
I want to re-order row of data-table by drag and drop in angular.js.
Is there any way to do it?

I have tried ui-sortable, but it is not working with datatable.

答:
Use the following link:

Datatable Row reorder

Title: Row re-order angular js in datatable