问:
Open application after clicking on Notification
I have a notification in my app with the following code:

```<code>//Notification Start

   notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

   int icon = R.drawable.n1;
   CharSequence tickerText = "Call Blocker";
   long when = System.currentTimeMillis(); //now
   Notification notification = new Notification(icon, tickerText, when);
   Intent notificationIntent = new Intent(context, Main.class);
   PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);

   Context context = getApplicationContext();
   CharSequence title = "Call Blocker";
   text = "Calls will be blocked while driving";

   notification.setLatestEventInfo(context, title, text, contentIntent);

   notification.flags |= Notification.FLAG_ONGOING_EVENT;
   notification.flags |= Notification.FLAG_SHOW_LIGHTS;
   notificationManager.notify(1, notification);

}
</code>```

My notifications fires very well, but my problem is that, when I click on notification in Notification Center, it does not start my app.

Basically, after clicking on my notification nothing happens!
What should I do, in order to start my Main activity after clicking on my notification.
Thanks.

答:
This is the way that I have approached.</p>

```<code>public class AppFCMService extends FirebaseMessagingService {

    private final static String TAG = "FCM Message";
    String notify, requstId, Notification;
    PendingIntent pendingIntent;

    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        Log.d(TAG, "From: " + remoteMessage.getFrom());
        Log.d(TAG, "Notification Message Body: " + remoteMessage.getNotification().getBody());
        //split string and getting order id from notification
        String Str = remoteMessage.getNotification().getBody();
        String[] tmp;
        tmp = Str.split(" ");
        String temp1 = tmp[0];
        String temp2 = tmp[1];
        String id = tmp[2];
        notify = temp1 + " " + temp2;
        requstId = id;
        showNotification(remoteMessage.getNotification().getBody());
    }

    private void showNotification(String messageBody) {
        // check whether session has been initiated or not
        if (new SessionHelper(getApplicationContext()).isLoggedIn()) {

            if (notify.equalsIgnoreCase("Travel request")) {

                Intent intent = new Intent(this, ViewTravelDetailsActivity.class);
                intent.putExtra("TravelRequestID", requstId);
                intent.putExtra("BackPress", "Notify");
                pendingIntent = PendingIntent.getActivity(this, 0, intent,
                        PendingIntent.FLAG_ONE_SHOT);

            } else if (notify.equalsIgnoreCase("Timesheet replied")) {

                Intent intent = new Intent(this, ViewReplyActivity.class);
                intent.putExtra("timesheetActivityID", requstId);
                intent.putExtra("BackPress", "Notify");
                intent.putExtra("RealmData", "DeleteRealm");
                intent.putExtra("isToday", "true");
                pendingIntent = PendingIntent.getActivity(this, 0, intent,
                        PendingIntent.FLAG_ONE_SHOT);
            } else {

                Intent intent = new Intent(this, Dashboard.class);
                intent.putExtra("timesheetActivityID", requstId);
                pendingIntent = PendingIntent.getActivity(this, 0, intent,
                        PendingIntent.FLAG_ONE_SHOT);
            }
        } else {

            Intent intent = new Intent(this, LoginActivity.class);
            intent.putExtra("timesheetActivityID", requstId);
            pendingIntent = PendingIntent.getActivity(this, 0, intent,
                    PendingIntent.FLAG_ONE_SHOT);
        }

        Bitmap notifyImage = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
        Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
                .setSmallIcon(R.mipmap.ic_launcher)
                .setLargeIcon(notifyImage)
                .setColor(Color.parseColor("#FFE74C3C"))
                .setContentTitle("TEST")
                .setContentText(messageBody)
                .setAutoCancel(true)
                .setSound(defaultSoundUri)
                .setContentIntent(pendingIntent);
        NotificationManager notificationManager =
                (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.notify(0, notificationBuilder.build());
    }
}
</code>```

Body:
I have a notification in my app with the following code:

//Notification Start

   notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

   int icon = R.drawable.n1;
   CharSequence tickerText = "Call Blocker";
   long when = System.currentTimeMillis(); //now
   Notification notification = new Notification(icon, tickerText, when);
   Intent notificationIntent = new Intent(context, Main.class);
   PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);

   Context context = getApplicationContext();
   CharSequence title = "Call Blocker";
   text = "Calls will be blocked while driving";

   notification.setLatestEventInfo(context, title, text, contentIntent);

   notification.flags |= Notification.FLAG_ONGOING_EVENT;
   notification.flags |= Notification.FLAG_SHOW_LIGHTS;
   notificationManager.notify(1, notification);

}

My notifications fires very well, but my problem is that, when I click on notification in Notification Center, it does not start my app.

Basically, after clicking on my notification nothing happens!
What should I do, in order to start my Main activity after clicking on my notification.
Thanks.

Body:
This is the way that I have approached.

public class AppFCMService extends FirebaseMessagingService {

    private final static String TAG = "FCM Message";
    String notify, requstId, Notification;
    PendingIntent pendingIntent;

    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        Log.d(TAG, "From: " + remoteMessage.getFrom());
        Log.d(TAG, "Notification Message Body: " + remoteMessage.getNotification().getBody());
        //split string and getting order id from notification
        String Str = remoteMessage.getNotification().getBody();
        String[] tmp;
        tmp = Str.split(" ");
        String temp1 = tmp[0];
        String temp2 = tmp[1];
        String id = tmp[2];
        notify = temp1 + " " + temp2;
        requstId = id;
        showNotification(remoteMessage.getNotification().getBody());
    }

    private void showNotification(String messageBody) {
        // check whether session has been initiated or not
        if (new SessionHelper(getApplicationContext()).isLoggedIn()) {

            if (notify.equalsIgnoreCase("Travel request")) {

                Intent intent = new Intent(this, ViewTravelDetailsActivity.class);
                intent.putExtra("TravelRequestID", requstId);
                intent.putExtra("BackPress", "Notify");
                pendingIntent = PendingIntent.getActivity(this, 0, intent,
                        PendingIntent.FLAG_ONE_SHOT);

            } else if (notify.equalsIgnoreCase("Timesheet replied")) {

                Intent intent = new Intent(this, ViewReplyActivity.class);
                intent.putExtra("timesheetActivityID", requstId);
                intent.putExtra("BackPress", "Notify");
                intent.putExtra("RealmData", "DeleteRealm");
                intent.putExtra("isToday", "true");
                pendingIntent = PendingIntent.getActivity(this, 0, intent,
                        PendingIntent.FLAG_ONE_SHOT);
            } else {

                Intent intent = new Intent(this, Dashboard.class);
                intent.putExtra("timesheetActivityID", requstId);
                pendingIntent = PendingIntent.getActivity(this, 0, intent,
                        PendingIntent.FLAG_ONE_SHOT);
            }
        } else {

            Intent intent = new Intent(this, LoginActivity.class);
            intent.putExtra("timesheetActivityID", requstId);
            pendingIntent = PendingIntent.getActivity(this, 0, intent,
                    PendingIntent.FLAG_ONE_SHOT);
        }

        Bitmap notifyImage = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
        Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
                .setSmallIcon(R.mipmap.ic_launcher)
                .setLargeIcon(notifyImage)
                .setColor(Color.parseColor("#FFE74C3C"))
                .setContentTitle("TEST")
                .setContentText(messageBody)
                .setAutoCancel(true)
                .setSound(defaultSoundUri)
                .setContentIntent(pendingIntent);
        NotificationManager notificationManager =
                (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.notify(0, notificationBuilder.build());
    }
}


来源: stackexchange

问:
Run stored procedure in SQL Developer
I have procedure with params:

```<code>procedure GetReceipt(iPaymentID    in number
                    ,oReceipt      out sys_refcursor
                    ,oReceiptItems out sys_refcursor);
</code>```

I try to run this my anonymous block:

```<code>SET serveroutput on;
DECLARE
  oReceipt sys_refcursor;
  oReceiptItems sys_refcursor;
BEGIN
  API.MOD.GetReceipt(4209735, oReceipt, oReceiptItems);
  dbms_output.put_line('oReceipt: ' || oReceipt);
  dbms_output.put_line('oReceiptItems: ' || oReceiptItems);
END;
</code>```

I get this error:

```<code>Error report:
ORA-06550: Строка 6, столбец 24:
PLS-00306: wrong number or types of arguments in call to '||'
ORA-06550: Строка 6, столбец 3:
PL/SQL: Statement ignored
ORA-06550: Строка 7, столбец 24:
PLS-00306: wrong number or types of arguments in call to '||'
ORA-06550: Строка 7, столбец 3:
PL/SQL: Statement ignored
06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.
*Action:
</code>```

How call this procedure? Where my mistake?

答:
sys_refcursor returns record set, may not be just a column.

So, you can not message it as a classical string with dbms_output.put_line. There should exists some columns(sub-components) of this argument in your routine like oReceiptItems.col_a or oReceiptItems.col_b so that you could message by these columns as strings with dbms_output.put_line.

ContentLicense: CC BY-SA 3.0

Title: Run stored procedure in SQL Developer

Body:
I have procedure with params:

procedure GetReceipt(iPaymentID    in number
                    ,oReceipt      out sys_refcursor
                    ,oReceiptItems out sys_refcursor);

I try to run this my anonymous block:

SET serveroutput on;
DECLARE
  oReceipt sys_refcursor;
  oReceiptItems sys_refcursor;
BEGIN
  API.MOD.GetReceipt(4209735, oReceipt, oReceiptItems);
  dbms_output.put_line('oReceipt: ' || oReceipt);
  dbms_output.put_line('oReceiptItems: ' || oReceiptItems);
END;

I get this error:

Error report:
ORA-06550: Строка 6, столбец 24:
PLS-00306: wrong number or types of arguments in call to '||'
ORA-06550: Строка 6, столбец 3:
PL/SQL: Statement ignored
ORA-06550: Строка 7, столбец 24:
PLS-00306: wrong number or types of arguments in call to '||'
ORA-06550: Строка 7, столбец 3:
PL/SQL: Statement ignored
06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.
*Action:

How call this procedure? Where my mistake?


问:
Android 3.0 build gradle errors
please see this errors in this picture

this is the app.build iv'e just installed android studio 3.0
and this is the errors in the picture
dont know what to do anymore please help me

Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve junit:junit:4.12.

Could not resolve junit:junit:4.12.
Required by:
    project :app

Could not resolve junit:junit:4.12.
  Could not get resource 'https://dl.google.com/dl/android/maven2/junit/junit/4.12/junit-4.12.pom'.
  Could not GET 'https://dl.google.com/dl/android/maven2/junit/junit/4.12/junit-4.12.pom'.
  Connect to dl.google.com:443 [dl.google.com/172.217.24.14] failed: Connection timed out: connect
  Connection timed out: connect

```<code>    apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.mahilum.meebot"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
</code>```

答:
Please add below line in app build gradle file.</p>

```<code> android {
        compileSdkVersion 26
        flavorDimensions "default"
    }
</code>```

Title: Android 3.0 build gradle errors

Body:
please see this errors in this picture

this is the app.build iv'e just installed android studio 3.0
and this is the errors in the picture
dont know what to do anymore please help me

Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve junit:junit:4.12.

Could not resolve junit:junit:4.12.
Required by:
    project :app

Could not resolve junit:junit:4.12.
  Could not get resource 'https://dl.google.com/dl/android/maven2/junit/junit/4.12/junit-4.12.pom'.
  Could not GET 'https://dl.google.com/dl/android/maven2/junit/junit/4.12/junit-4.12.pom'.
  Connect to dl.google.com:443 [dl.google.com/172.217.24.14] failed: Connection timed out: connect
  Connection timed out: connect

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.mahilum.meebot"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}

Body:
Please add below line in app build gradle file.

 android {
        compileSdkVersion 26
        flavorDimensions "default"
    }


问:
WP plugin commit issue:- svn: E175013: Access to ‘/!svn/me’ forbidden
I did svn checkout plugin code from https://plugins.svn.wordpress.org/my-plugin, made changes in a file and then when I give svn ci -m ‘changes description’ it asks for user name and password. When I give the username and password, I get the following error message:

```<code>svn: E175013: Commit failed (details follow):
svn: E175013: Access to ‘/!svn/me’ forbidden
</code>```

I have checked the URL, username and password and all are correct.

What can I try to resolve this?

答:
Turns out I was not added as a committer.

I was added as a contributor, but not committer. Only committer has access to commit code to their SVN.

To add as committer go to the plugins 'Advanced View' which is there at the right hand sidebar of the plugin owner.

ContentLicense: CC BY-SA 4.0

Body:
I did svn checkout plugin code from https://plugins.svn.wordpress.org/my-plugin, made changes in a file and then when I give svn ci -m ‘changes description’ it asks for user name and password. When I give the username and password, I get the following error message:

svn: E175013: Commit failed (details follow):
svn: E175013: Access to ‘/!svn/me’ forbidden

I have checked the URL, username and password and all are correct.

What can I try to resolve this?


问:
Understanding the delegates in UITableView and UITableViewController
I am learning how to use the UITableView and UITableViewController in the iOS and I think I may have confused myself. I have created a simple TableView and I have 2 sections.  Nothing complicated.

I have the following defined and it builds fine:

```<code>-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView
 numberOfRowsInSection:(NSInteger)section
{
    // Section is going to be either 0 or 1, high or low
    if (section == 0) {
        return 1;
    }
    else {
        return 2;
    }
}
</code>```

However what I don't understand is the definitions of the methods.  Both methods have to return an integer so I understand the starting (NSInteger).  The numberOfRowsInSection starts with tableView:(UITableView *)tableView and I don't understand why?

I'm am new to programming the iOS so be gentle :-)  All help greatly appreciated.

Mike

答:
The method name is "tableView:numberOfRowsInSection:". The first argument is the instance if UITableView which is asking the data source for the number of rows in a particular section. This is a useful convention as you might have a single object act as the data source for many table views or want to update the table view in some way when a delegate method is called. By passing the calling object to the delegate you avoid needing to have the delegate maintain an additional reference to that object. </p>

<p>Take a look at the NSURLConnection delegate methods dealing with authentication for an example of where this is really necessary. </p>

ContentLicense: CC BY-SA 2.5

Body:
I am learning how to use the UITableView and UITableViewController in the iOS and I think I may have confused myself. I have created a simple TableView and I have 2 sections.  Nothing complicated.

I have the following defined and it builds fine:

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView
 numberOfRowsInSection:(NSInteger)section
{
    // Section is going to be either 0 or 1, high or low
    if (section == 0) {
        return 1;
    }
    else {
        return 2;
    }
}

However what I don't understand is the definitions of the methods.  Both methods have to return an integer so I understand the starting (NSInteger).  The numberOfRowsInSection starts with tableView:(UITableView *)tableView and I don't understand why?

I'm am new to programming the iOS so be gentle :-)  All help greatly appreciated.

Mike

Body:
The method name is "tableView:numberOfRowsInSection:". The first argument is the instance if UITableView which is asking the data source for the number of rows in a particular section. This is a useful convention as you might have a single object act as the data source for many table views or want to update the table view in some way when a delegate method is called. By passing the calling object to the delegate you avoid needing to have the delegate maintain an additional reference to that object.

Take a look at the NSURLConnection delegate methods dealing with authentication for an example of where this is really necessary.


问:
Section background on iPhone are not sizing correctly
I have been trying for many hours to properly size the background on iPhones for a section using either a fixed or scroll attachment to the section tag, but I have not been able to get any of the common fixes to work. No matter what I've tried the background images for iPhones continue to be blown out of proportion.

I have tried to include 'user-scalable=no' in the meta tag.
I tried including the section in a div whose height and width were 100%.
I tried to force the sizing using jQuery.
I tried add a media query for iPhones to set background-attachment to "initial".

I  still do not understand how the fixes I attempted to implemented should have worked in theory, but it seems that the problem may be with my css or html instead to me now that so many supposed fixes are not working.

This is a definite setback as far as my desire to become a web designer goes.
Thanks.

```<code>   <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="x-ua-compatible" content="ie=edge">

     <section id="congress-section" class="py-4">
       <div class="container">
         <div class="row py-3">
           <div class="col-md-6 mb-3">
             <div class="card card-outline-secondary">
               <div class="card-block">
                 <h3 class="text-center">Wednesday Pre-Party (optional)</h3>
                 <p class="lead">Day 0</p>
                 <hr>
                 <p><i class="fa fa-check"></i>Early Check-In & Registration</p>
                 <p><i class="fa fa-camera-retro"></i>Tour Around Bologna</p>
                 <p><i class="fa fa-glass"></i>Party alla bolognese</p>
               </div>
             </div>
           </div>
           <div class="col-md-6 mb-3">
             <div class="card card-outline-secondary">
               <div class="card-block">
                 <h3 class="text-center">Thursday: 9 - 17</h3>
                 <p class="lead">Day 1</p>
                 <hr>
                 <p><i class="fa fa-check"></i>Registration</p>
                 <p><i class="fa fa-quote-left"></i>Keynote</p>
                 <p><i class="fa fa-cutlery"></i>Lunch & Coffee Time Gratis</p>
                 <div class="col-11 offset-1 subicon">
                   <p><i class="fa fa-leaf"></i>Vegan Options</p>
                 </div>
                 <p><i class="fa fa-users"></i>Share Experience & Give Feedback in Alternative Groups</p>
                 <p><i class="fa fa-beer"></i>A Pizza in Piazza Party (Night)</p>
               </div>
             </div>
           </div>
         </div>
       </div>
     </div>
   </section>

  #congress-section {
      background: url(../img/police2_2.jpg);
      background-position: bottom;
      background-size: cover;
      background-repeat: no-repeat;
      background-attachment: fixed;
      color: $color3;
    }

    @media (max-width: 767px) {
      #congress-section {
        background-attachment: initial;
      }
    }
</code>```

答:
Here is the working solution for your question

<meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="x-ua-compatible" content="ie=edge">

Wednesday Pre-Party (optional)

Day 0

Early Check-In & Registration

Tour Around Bologna

Party alla bolognese

Thursday: 9 - 17

Day 1

Registration

Keynote

Lunch & Coffee Time Gratis

Vegan Options

Share Experience & Give Feedback in Alternative Groups

A Pizza in Piazza Party (Night)

  #congress-section {
      display: inline-block;
      width:100%;
      background: url(../img/police2_2.jpg);
      background-position: bottom;
      background-size: cover;
      background-repeat: no-repeat;
      background-attachment: fixed;
      color: $color3;
    }

    @media (max-width: 767px) {
      #congress-section {
        background-size: cover;
      }
    }```

Let me know if you need further help.

Body:
I have been trying for many hours to properly size the background on iPhones for a section using either a fixed or scroll attachment to the section tag, but I have not been able to get any of the common fixes to work. No matter what I've tried the background images for iPhones continue to be blown out of proportion.

I have tried to include 'user-scalable=no' in the meta tag.
I tried including the section in a div whose height and width were 100%.
I tried to force the sizing using jQuery.
I tried add a media query for iPhones to set background-attachment to "initial".

I  still do not understand how the fixes I attempted to implemented should have worked in theory, but it seems that the problem may be with my css or html instead to me now that so many supposed fixes are not working.

This is a definite setback as far as my desire to become a web designer goes.
Thanks.

   <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="x-ua-compatible" content="ie=edge">

Wednesday Pre-Party (optional)

Day 0

Early Check-In & Registration

Tour Around Bologna

Party alla bolognese

Thursday: 9 - 17

Day 1

Registration

Keynote

Lunch & Coffee Time Gratis

Vegan Options

Share Experience & Give Feedback in Alternative Groups

A Pizza in Piazza Party (Night)

  #congress-section {
      background: url(../img/police2_2.jpg);
      background-position: bottom;
      background-size: cover;
      background-repeat: no-repeat;
      background-attachment: fixed;
      color: $color3;
    }

    @media (max-width: 767px) {
      #congress-section {
        background-attachment: initial;
      }
    }

Body:
Here is the working solution for your question

<meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="x-ua-compatible" content="ie=edge">

     <section id="congress-section" class="py-4">
       <div class="container">
         <div class="row py-3">
           <div class="col-md-6 mb-3">
             <div class="card card-outline-secondary">
               <div class="card-block">
                 <h3 class="text-center">Wednesday Pre-Party (optional)</h3>
                 <p class="lead">Day 0</p>
                 <hr>
                 <p><i class="fa fa-check"></i>Early Check-In & Registration</p>
                 <p><i class="fa fa-camera-retro"></i>Tour Around Bologna</p>
                 <p><i class="fa fa-glass"></i>Party alla bolognese</p>
               </div>
             </div>
           </div>
           <div class="col-md-6 mb-3">
             <div class="card card-outline-secondary">
               <div class="card-block">
                 <h3 class="text-center">Thursday: 9 - 17</h3>
                 <p class="lead">Day 1</p>
                 <hr>
                 <p><i class="fa fa-check"></i>Registration</p>
                 <p><i class="fa fa-quote-left"></i>Keynote</p>
                 <p><i class="fa fa-cutlery"></i>Lunch & Coffee Time Gratis</p>
                 <div class="col-11 offset-1 subicon">
                   <p><i class="fa fa-leaf"></i>Vegan Options</p>
                 </div>
                 <p><i class="fa fa-users"></i>Share Experience & Give Feedback in Alternative Groups</p>
                 <p><i class="fa fa-beer"></i>A Pizza in Piazza Party (Night)</p>
               </div>
             </div>
           </div>
         </div>
       </div>
     </div>
   </section>

  #congress-section {
      display: inline-block;
      width:100%;
      background: url(../img/police2_2.jpg);
      background-position: bottom;
      background-size: cover;
      background-repeat: no-repeat;
      background-attachment: fixed;
      color: $color3;
    }

    @media (max-width: 767px) {
      #congress-section {
        background-size: cover;
      }
    }

Let me know if you need further help.


问:
how to split a textbox into multple subtextboxes for each character
I am designing a PHP form that contains some input fields as displayed in below image.

How can I split an input type(textbox) into single character sub-textboxes OR a textbox into multi-column textboxes for each character separately for given string.

And how to insert the data in it e.g. |JOHN DOE| into |J|O|H|N| |D|O|E| this manner

答:
You may visit this URL http://jsfiddle.net/w564j/ for sample

HTML

```<code><input type="text" maxlength="9" id="text"/>
</code>```

CSS

```<code>#text{
    background-image: url("http://3.bp.blogspot.com/-4oAWWCcNNz4/Tjr3nKNyVUI/AAAAAAAAPLU/Pouua-pNsEY/s1600/sq.gif");
    width: 195px;
    height: 18px;
    background-size: 20px;
    border: none;
    font-family: monospace;
    font-size: 13px;
    padding-left: 5px;
    letter-spacing: 12px;
}
</code>```

Body:
You may visit this URL http://jsfiddle.net/w564j/ for sample

HTML

<input type="text" maxlength="9" id="text"/>

CSS

#text{
    background-image: url("http://3.bp.blogspot.com/-4oAWWCcNNz4/Tjr3nKNyVUI/AAAAAAAAPLU/Pouua-pNsEY/s1600/sq.gif");
    width: 195px;
    height: 18px;
    background-size: 20px;
    border: none;
    font-family: monospace;
    font-size: 13px;
    padding-left: 5px;
    letter-spacing: 12px;
}


问:
The Parent doensn't retrieve the childs hibertnate JPA
I have a Controller from rest service that I call a Hibernate method to get the result, but I really don't know why the children components didn't come. When I call this method using Junit, It works.
This is the Code:  </p>

```<code>{

@Entity
public class Product implements Serializable {
    private static final long serialVersionUID = -6131311050358241535L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    @Column(nullable = false)
    private String name;

    private String description;

    @OneToMany(mappedBy = "product")
    private List<Image> images = new ArrayList<Image>();
}

{

@Entity
public class Image implements Serializable {

    private static final long serialVersionUID = 2128787860415180858L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    @JoinColumn(name = "product_id")
    @ManyToOne
    private Product product;

    private ImageType type;
}
{

@PersistenceContext
private EntityManager entityManager;

public List<Product> findAllWithParentProductsAndImage() {
String hpql = "select distinct p from Product p left join fetch p.images";
List<Product> resultList = entityManager.createQuery(hpql,
        Product.class).getResultList();
return resultList;
}
}
</code>```

答:
You can definitely use

```<code>@OneToMany(mappedBy = "product", fetch=FetchType.Eager)
</code>```

However this has a downside. You will always be fetching children even if you only want the Parent and its few properties.

Use JOIN FETCH within your @Query if you are using JpaRepositories.

Check out the following related questions

How to properly express JPQL "join fetch" with "where" clause as JPA 2 CriteriaQuery?

http://www.objectdb.com/java/jpa/query/jpql/from#LEFT_OUTER_INNER_JOIN_FETCH_

https://stackoverflow.com/a/29667050/3094731

Body:
I have a Controller from rest service that I call a Hibernate method to get the result, but I really don't know why the children components didn't come. When I call this method using Junit, It works.
This is the Code:

{

@Entity
public class Product implements Serializable {
    private static final long serialVersionUID = -6131311050358241535L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    @Column(nullable = false)
    private String name;

    private String description;

    @OneToMany(mappedBy = "product")
    private List<Image> images = new ArrayList<Image>();
}

{

@Entity
public class Image implements Serializable {

    private static final long serialVersionUID = 2128787860415180858L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    @JoinColumn(name = "product_id")
    @ManyToOne
    private Product product;

    private ImageType type;
}
{

@PersistenceContext
private EntityManager entityManager;

public List<Product> findAllWithParentProductsAndImage() {
String hpql = "select distinct p from Product p left join fetch p.images";
List<Product> resultList = entityManager.createQuery(hpql,
        Product.class).getResultList();
return resultList;
}
}

Body:
You can definitely use

@OneToMany(mappedBy = "product", fetch=FetchType.Eager)

However this has a downside. You will always be fetching children even if you only want the Parent and its few properties.

Use JOIN FETCH within your @Query if you are using JpaRepositories.

Check out the following related questions

How to properly express JPQL "join fetch" with "where" clause as JPA 2 CriteriaQuery?

http://www.objectdb.com/java/jpa/query/jpql/from#LEFT_OUTER_INNER_JOIN_FETCH_

https://stackoverflow.com/a/29667050/3094731


问:
change time format to 24 hours in javascript
I have a time format like: 12/16/2011 3:49:37 PM and I got this format by:

```<code>var newDate = new Date(timeFromat);
timeFormat = newDate.toLocaleString();
</code>```

My actual format was GMT and I converted it to my bowers time by using the code above.

and I want to change it to 24h time format so I want this date to be changed like: 12/16/2011 15:49:37 and I want to do it in javascript.

Thats what I did

```<code>var firstPartOftimeFormat = timeFormat.substring(0,9);
var secondPartOftimeFormat = timeFormat.substring(10,20);
</code>```

but it does not work when the date format is like: 3/16/2011. but the following part works.

```<code>var time = $("#starttime").val();
var hours = Number(secondPartOftimeFormat.match(/^(\d+)/)[1]);
var minutes = Number(secondPartOftimeFormat.match(/:(\d+)/)[1]);
var AMPM = secondPartOftimeFormat.match(/\s(.*)$/)[1];
if(AMPM == "PM" && hours<12) hours = hours+12;
if(AMPM == "AM" && hours==12) hours = hours-12;
var sHours = hours.toString();
var sMinutes = minutes.toString();
if(hours<10) sHours = "0" + sHours;
if(minutes<10) sMinutes = "0" + sMinutes;
alert(sHours + ":" + sMinutes);
</code>```

Can you suggest other approach?

thanks

答:
try this:

```<code>// British English uses day-month-year order and 24-hour time without AM/PM
console.log(date.toLocaleString('en-GB'));
// → "20/12/2012 03:00:00"
</code>```

reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString

Body:
I have a time format like: 12/16/2011 3:49:37 PM and I got this format by:

var newDate = new Date(timeFromat);
timeFormat = newDate.toLocaleString();

My actual format was GMT and I converted it to my bowers time by using the code above.

and I want to change it to 24h time format so I want this date to be changed like: 12/16/2011 15:49:37 and I want to do it in javascript.

Thats what I did

var firstPartOftimeFormat = timeFormat.substring(0,9);
var secondPartOftimeFormat = timeFormat.substring(10,20);

but it does not work when the date format is like: 3/16/2011. but the following part works.

var time = $("#starttime").val();
var hours = Number(secondPartOftimeFormat.match(/^(\d+)/)[1]);
var minutes = Number(secondPartOftimeFormat.match(/:(\d+)/)[1]);
var AMPM = secondPartOftimeFormat.match(/\s(.*)$/)[1];
if(AMPM == "PM" && hours<12) hours = hours+12;
if(AMPM == "AM" && hours==12) hours = hours-12;
var sHours = hours.toString();
var sMinutes = minutes.toString();
if(hours<10) sHours = "0" + sHours;
if(minutes<10) sMinutes = "0" + sMinutes;
alert(sHours + ":" + sMinutes);

Can you suggest other approach?

thanks

Body:
try this:

// British English uses day-month-year order and 24-hour time without AM/PM
console.log(date.toLocaleString('en-GB'));
// → "20/12/2012 03:00:00"

reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString


问:
ng-repeate not displaying object properties
here i'm using  Array for avoiding duplicate data for that i wrote this code       if (EmployeeList.indexOf(EmpDetails) == -1)  Here im Getting Error as EmployeeList of Array is not defind

```<code>     $scope.EmployeeList = [];
        $scope.SaveDb = function (Isvalid) {
            var EmpDetails = [{
                'EmpName': $scope.EmpName,
                'Email': $scope.Email

            }]

            $scope.EmployeeList.push(EmpDetails);
            console.log($scope.EmployeeList);
        }
        }
    })
</code>```

答:
you are pushing array into array try to push</p>

```<code>$scope.SaveDb = function (Isvalid) {
        var EmpDetails = {
            'EmpName': $scope.EmpName,
            'Email': $scope.Email

        };
        $scope.EmployeeList .push(EmpDetails);
    }
</code>```

Body:
here i'm using  Array for avoiding duplicate data for that i wrote this code       if (EmployeeList.indexOf(EmpDetails) == -1)  Here im Getting Error as EmployeeList of Array is not defind

     $scope.EmployeeList = [];
        $scope.SaveDb = function (Isvalid) {
            var EmpDetails = [{
                'EmpName': $scope.EmpName,
                'Email': $scope.Email

            }]

            $scope.EmployeeList.push(EmpDetails);
            console.log($scope.EmployeeList);
        }
        }
    })

Body:
you are pushing array into array try to push

$scope.SaveDb = function (Isvalid) {
        var EmpDetails = {
            'EmpName': $scope.EmpName,
            'Email': $scope.Email

        };
        $scope.EmployeeList .push(EmpDetails);
    }


答:
You are pushing array in array and in ng-repeat you're trying to get the properties of object on array. that's the problem. Try pushing object in array and that should do the trick

```<code> $scope.EmployeeList = [];
 $scope.SaveDb = function (Isvalid) {
    var EmpDetails = {
        'EmpName': $scope.EmpName,
        'Email': $scope.Email

    }
    $scope.EmployeeList .push(EmpDetails);
}
})
</code>```

Title: ng-repeate not displaying object properties

Body:
You are pushing array in array and in ng-repeat you're trying to get the properties of object on array. that's the problem. Try pushing object in array and that should do the trick

 $scope.EmployeeList = [];
 $scope.SaveDb = function (Isvalid) {
    var EmpDetails = {
        'EmpName': $scope.EmpName,
        'Email': $scope.Email

    }
    $scope.EmployeeList .push(EmpDetails);
}
})


问:
Adding a table column using jquery and the new column should be the first column
Thanks for all yor help. My requrirement is to prepend the column to a row with image. But my image is moving all the columns to the right. How to add image to only matching rows but not moving other columns to right. Iam attaching my screenshot here. Please help me.

Thanks,

```<code><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script src="http://dlglobal.dl.com/Admin/IT/operations/Documents/jquery.SPServices-0.5.8.min.js" type="text/javascript"></script>

<script type="text/javascript">
$(document).ready(function()
{
//alert("alert test");
/*$Textsql = $("td.ms-vb2:contains('Budakov')");
$Textsql.css("background-color", "#461B7E"); */

$().SPServices({
  operation: "GetListItems",
  async: false,
  listName: "OnCallList",

  completefunc: function (xData, Status) {
    //alert(xData.responseXML.xml);
$("#ctl00_m_g_87fe292c_7976_4ad4_bf5c_3c1ecf08b2d8_AdvancedDataGrid tr:first").append("<th></th>");

    $(xData.responseXML).find("[nodeName=z:row]").each(function() {

     var TextList=$(this).attr("ows_Title");
     $Textsql = $("td.ms-vb2:contains('" + TextList.toString() + "')");

     $Textsql.parent().prepend("<td class='ms-vb2'><img src='http://dlglobal.dl.com/Admin/IT/operations/PublishingImages/OnCall.png' /></td>");  });
}
});
});
</script>
</code>```

答: Set a fixed with on the TD and add it to every row.  Then only populate that TD with the image for the selected rows.  This way that column will always be the width of the image whether or not it is present.</p>


问:
Guidance on Managing Azure Website Deployments/Backups/Logs
Tasked with creating an automated Azure deploy and swap 'tool,' I would like use C# and Azure Resource Manager and add it to a WebAPI Server.
However, documentation seems limited.

For example, the following is the link for ARMs BeginSwapSlotWithProduction()

Googling that method returns only 7 results!

I see Azure PowerShell cmdlets very well documented.

https://learn.microsoft.com/en-us/azure/app-service/web-sites-staged-publishing#azure-powershell-cmdlets-for-deployment-slots

http://ruslany.net/2016/10/using-powershell-to-manage-azure-web-app-deployment-slots/

And so is Azure Resource Manager with Templates.  <- Not type safe.

I have considered using Powershell inline in C# such as documented here.
But seems I am fighting the system.

Attempting to keep this question from being Opinion Based.  Are there other alternatives I have not mentioned here.

Azure Resource Manager (Fluent Based)

Azure Resource Manager

Azure PowerShell

Azure Resource Manager REST with (Weakly typed)Resource Manager templates.

Looking for a well documented, strongly typed way to interact with Azure basically.

答:
If you want to swap or deploy WebApp, you could use the Microsoft.Azure.Management.Fluent and Microsoft.Azure.Management.ResourceManager.Fluent. We also could get more demo code from the github Azure SDK. About how to get the credential file you could refer to Authentication in Azure Management Libraries for .NET.

The following is the demo code.

```<code>var credentials = SdkContext.AzureCredentialsFactory.FromFile(@"Credential file path");
var azure = Azure
            .Configure()
            .WithLogLevel(HttpLoggingDelegatingHandler.Level.Basic)
            .Authenticate(credentials)
            .WithDefaultSubscription();

//create WebApp
var webApp = azure.WebApps.Define(appName)
.WithRegion(Region.USWest)
.WithNewResourceGroup(rgName)
.WithNewFreeAppServicePlan()
.Create();

//Deploy WebApp
 webApp .Deploy().WithPackageUri("packageUri");

//get WebApp
var webApp = azure.WebApps.GetByResourceGroup("rgName", "appName");

//swap WebApp
webApp.Swap("slotName");
</code>```

Body:
If you want to swap or deploy WebApp, you could use the Microsoft.Azure.Management.Fluent and Microsoft.Azure.Management.ResourceManager.Fluent. We also could get more demo code from the github Azure SDK. About how to get the credential file you could refer to Authentication in Azure Management Libraries for .NET.

The following is the demo code.

var credentials = SdkContext.AzureCredentialsFactory.FromFile(@"Credential file path");
var azure = Azure
            .Configure()
            .WithLogLevel(HttpLoggingDelegatingHandler.Level.Basic)
            .Authenticate(credentials)
            .WithDefaultSubscription();

//create WebApp
var webApp = azure.WebApps.Define(appName)
.WithRegion(Region.USWest)
.WithNewResourceGroup(rgName)
.WithNewFreeAppServicePlan()
.Create();

//Deploy WebApp
 webApp .Deploy().WithPackageUri("packageUri");

//get WebApp
var webApp = azure.WebApps.GetByResourceGroup("rgName", "appName");

//swap WebApp
webApp.Swap("slotName");


问:
Explain how xml is processed by xsl
I have this *.xml file

```<code><?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="xq340.xsl"?>

<wine grape="Cabernet">
    <winery>Duckpond</winery>
    <product>Merit Selection</product>
    <year>1996</year>
    <price>11.99</price>
</wine>
</code>```

and this *.xsl file

```<code><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" omit-xml-declaration="yes"/>

<xsl:template match="winery">
    <b><font size="10pt"><xsl:apply-templates/>
    <xsl:text> </xsl:text>
    <xsl:value-of select="../@grape"/></font></b><br/>
</xsl:template>

<xsl:template match="product">
    <i><font size="10pt"><xsl:apply-templates/></font></i><br/>
</xsl:template>

<xsl:template match="year | price">
    <font size="10pt"><xsl:apply-templates/></font><br/>
</xsl:template>
</xsl:stylesheet>
</code>```

and somehow this is the output

Duckpond Cabernet

  Merit Selection

  1996

  11.99

This is probably a lot, but I don't understand how the xsl steps through the xml to produce the html.

I would think it goes this way; the first template matches "winery", then it writes the bold and font tags. Here's where I get lost, the next instruction is "apply-templates" and this would activate the product template, write the italic tag and then "apply-templates" and write the font tags for year and price. In my "book" I should get something like this:

```<code><b>
    <font size="10pt">
        <i>
            <font size="10pt">
                <font size="10pt">
                    <font size="10pt"></font>
                    <br/>
                </font>
            </font>
        </i>
        <br/>
    </font>
</b>
<br/>
</code>```

There also the "select="../@grape" which I assume is the one it's getting the actual xml nodes values; however, this is the name of and entire xml node, so I don't really know what it's getting.

Here're my questions:

How does the first "apply-templates" returns "Duckpond"?

When the first "apply-templates" in winery is called is it also
trying to match itself again or does it try to match ALL OTHER
templates or only templates showing after?

When the first template end tag </xsl:template> is hit, are the
other two templates "product" and "year | price" called again?

Thanks. I guess I'm having problems trying to understand the flow of it all.

答:
A potentially overlooked detail of XSLT is that there are built-in templates. One built-in template is defined in the standard somewhere but basically says (among other things) to always copy text nodes directly to the output. So this is where you've stumbled: the first xsl:apply-templates triggers this standard template, and this is what produces the word "Duckpond" in the output. Check it out by removing the xsl:apply-templates there. "Duckpond" disappears. (It's informative, I think, to look at the no-op XSL transform.)

You actually have what xsl:apply-templates does kind of backwards. It doesn't tell XSLT to go run a bunch of templates. xsl:call-template does that. Instead, it basically says "from where we are right now, run whatever templates you know that seem to match." Where you are at that first moment is inside the winery tag. What's under there? Nothing but a text node containing Duckpond.

Regarding your third question, what the other two templates are really doing is replacing the built-in template for those element types. XSLT is going to encounter them as it does its normal traversal (see the default template). When it finds them normally, it would just dump out their text (try it—comment out those templates). These templates cause it to instead set up some formatting first around them.

XSLT is, by default, already going to walk through the entire document. So you don't have to tell it how to do that procedurally. This is why they call it a declarative language. You can instead sort of tell it what to do when it finds something you are concerned about, and not worry as much about how it gets there.

If you want more control, you can basically override the standard template, and make your first template match /.

Title: Explain how xml is processed by xsl

Body:
I have this *.xml file

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="xq340.xsl"?>

<wine grape="Cabernet">
    <winery>Duckpond</winery>
    <product>Merit Selection</product>
    <year>1996</year>
    <price>11.99</price>
</wine>

and this *.xsl file

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" omit-xml-declaration="yes"/>

<xsl:template match="winery">
    <xsl:apply-templates/>
    <xsl:text> </xsl:text>
    <xsl:value-of select="../@grape"/>

</xsl:template>

<xsl:template match="product">
    <xsl:apply-templates/>

</xsl:template>

<xsl:template match="year | price">
    <xsl:apply-templates/>

</xsl:template>
</xsl:stylesheet>

and somehow this is the output

Duckpond Cabernet

  Merit Selection

  1996

  11.99

This is probably a lot, but I don't understand how the xsl steps through the xml to produce the html.

I would think it goes this way; the first template matches "winery", then it writes the bold and font tags. Here's where I get lost, the next instruction is "apply-templates" and this would activate the product template, write the italic tag and then "apply-templates" and write the font tags for year and price. In my "book" I should get something like this:

There also the "select="../@grape" which I assume is the one it's getting the actual xml nodes values; however, this is the name of and entire xml node, so I don't really know what it's getting.

Here're my questions:

How does the first "apply-templates" returns "Duckpond"?

When the first "apply-templates" in winery is called is it also
trying to match itself again or does it try to match ALL OTHER
templates or only templates showing after?

When the first template end tag </xsl:template> is hit, are the
other two templates "product" and "year | price" called again?

Thanks. I guess I'm having problems trying to understand the flow of it all.


问:
Replacing components in a Webpack bundle
We have a Webpack bundle exposing React components. The exposed components contain nested components from the same bundle.
We want to allow users to replace components with their own specific version.

For example, the following component structure;

```<code>class A extends React.Component {
    render() {
        return (
            <B/>
        );
    }
}

const C = require('./C');

class B extends React.Component {
    render() {
        return (
            <C/>
        );
    }
}
</code>```

from which the top-level component A is exposed in the Webpack bundle:

```<code>const A = bundle.components.A;
</code>```

Our server-side web framework relies on the exposed bundle interface to invoke the React components.

From this structure, an example use-case would be to replace the nested component C from component A.

Current options that we see for this are;

add a method to the class B (and A) to replace component C

create a registration mechanism, e.g. by using the filename or logical name of C, and a generic method to the bundle to replace a component. For example: bundle.component.replace('./C', './custom-C');

...

What would be the best way, i.e. common practice, to replace a (nested) React component in a Webpack bundle?

答:
Joost, I've got the same problem and the way that I'm been handling this is creating an Block component which decides what component should take place.

This is a working project importing webpack bundles and deciding which one should take place. If they are defined in the template scope I switch the render method.

https://github.com/wallynm/react-template-system

Body:
We have a Webpack bundle exposing React components. The exposed components contain nested components from the same bundle.
We want to allow users to replace components with their own specific version.

For example, the following component structure;

class A extends React.Component {
    render() {
        return (

        );
    }
}

const C = require('./C');

class B extends React.Component {
    render() {
        return (
            <C/>
        );
    }
}

from which the top-level component A is exposed in the Webpack bundle:

const A = bundle.components.A;

Our server-side web framework relies on the exposed bundle interface to invoke the React components.

From this structure, an example use-case would be to replace the nested component C from component A.

Current options that we see for this are;

add a method to the class B (and A) to replace component C

create a registration mechanism, e.g. by using the filename or logical name of C, and a generic method to the bundle to replace a component. For example: bundle.component.replace('./C', './custom-C');

...

What would be the best way, i.e. common practice, to replace a (nested) React component in a Webpack bundle?


问:
Pivoting the data
This is my SQL statement

```<code>select  id , name, type,  value  from table1 a
INNER JOIN table2 b on a.id = b.id
where  b.type in ('display','contact','ship')
</code>```

which produces below result

```<code>ID  name     type           value
5   test     display        display1
5   test     contact        contact1
5   test     ship           ship1
6   test2    display        display2
6   test2    contact        contact2
6   test2    ship           ship2
</code>```

I need to get result in kind of pivoted format like this

```<code>id  name   display   contact   ship
5   test   display1  contact1 ship1
6   test2  display2  contact2 ship2
</code>```

I tried this solution : https://stackoverflow.com/a/6849706/2645738 ,but its giving me the same result (3 rows for each data). It's like i need to group by id and name,but don't know how to make display,contact,ship as columns.

Would you please help me for the same.

答:
This query should give you the results you want:</p>

```<code>select  a.id , a.name,
        max(case when b.type = 'display' then value end) as display,
        max(case when b.type = 'contact' then value end) as contact,
        max(case when b.type = 'ship' then value end) as ship
from table1 a
INNER JOIN table2 b on a.id = b.id
where  b.type in ('display','contact','ship')
group by a.id, a.name
</code>```

Title: Pivoting the data

Body:
This is my SQL statement

select  id , name, type,  value  from table1 a
INNER JOIN table2 b on a.id = b.id
where  b.type in ('display','contact','ship')

which produces below result

ID  name     type           value
5   test     display        display1
5   test     contact        contact1
5   test     ship           ship1
6   test2    display        display2
6   test2    contact        contact2
6   test2    ship           ship2

I need to get result in kind of pivoted format like this

id  name   display   contact   ship
5   test   display1  contact1 ship1
6   test2  display2  contact2 ship2

I tried this solution : https://stackoverflow.com/a/6849706/2645738 ,but its giving me the same result (3 rows for each data). It's like i need to group by id and name,but don't know how to make display,contact,ship as columns.

Would you please help me for the same.

Body:
This query should give you the results you want:

select  a.id , a.name,
        max(case when b.type = 'display' then value end) as display,
        max(case when b.type = 'contact' then value end) as contact,
        max(case when b.type = 'ship' then value end) as ship
from table1 a
INNER JOIN table2 b on a.id = b.id
where  b.type in ('display','contact','ship')
group by a.id, a.name


问:
Receiver Type Mismatch with Anko Layouts
I am trying to create layouts with Anko DSL in my support v4 Fragment but the IDE shows receiver type mismatch. DSL works ok from the v7 AppCompatActivity. In trying to get this to work I have updated to Android Studio 3.0. I have also updated the dependencies in build.gradle's as some other threads suggested.

Here are the dependencies in my app's build.gradle

```<code>dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')

    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.4.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:design:25.4.0'
    compile 'com.android.support:support-v4:25.4.0'
    compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
    compile "org.jetbrains.anko:anko:$anko_version"
    compile "org.jetbrains.anko:anko-appcompat-v7-commons:$anko_version"
    compile "org.jetbrains.anko:anko-appcompat-v7:$anko_version"
    compile "org.jetbrains.anko:anko-support-v4-commons:$anko_version"
    compile "org.jetbrains.anko:anko-support-v4:$anko_version"
}
</code>```

and the dependencies in project's build.gradle

```<code>dependencies {
    classpath 'com.android.tools.build:gradle:3.0.0'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
}
</code>```

I have also seen this Question 'receiver type mismatch' with Fragment and Anko toast

But I am still stuck.

答:
DSL works ok from the v7 AppCompatActivity

And in the list of candidates in the screenshot you can see it's defined as an extension function on Activity, and an AppCompatActivity is an Activity.

Your receiver (this) is the HomeAdapter, which doesn't extend Activity, Context or ViewManager.

If you call context.verticalLayout it will compile, but I don't know whether the result is what you want.

Body:
I am trying to create layouts with Anko DSL in my support v4 Fragment but the IDE shows receiver type mismatch. DSL works ok from the v7 AppCompatActivity. In trying to get this to work I have updated to Android Studio 3.0. I have also updated the dependencies in build.gradle's as some other threads suggested.

Here are the dependencies in my app's build.gradle

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')

    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.4.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:design:25.4.0'
    compile 'com.android.support:support-v4:25.4.0'
    compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
    compile "org.jetbrains.anko:anko:$anko_version"
    compile "org.jetbrains.anko:anko-appcompat-v7-commons:$anko_version"
    compile "org.jetbrains.anko:anko-appcompat-v7:$anko_version"
    compile "org.jetbrains.anko:anko-support-v4-commons:$anko_version"
    compile "org.jetbrains.anko:anko-support-v4:$anko_version"
}

and the dependencies in project's build.gradle

dependencies {
    classpath 'com.android.tools.build:gradle:3.0.0'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
}

I have also seen this Question 'receiver type mismatch' with Fragment and Anko toast

But I am still stuck.


问:
How to use the proxy file in scrapy?
I got the proxy list with proxybroker.

```<code>sudo pip install proxybroker
proxybroker grab --countries US --limit 100 --outfile proxies.txt
</code>```

To change from the format <Proxy US 0.00s [] 104.131.6.78:80> into 104.131.6.78:80 with grep.

```<code> grep -oP  \([0-9]+.\){3}[0-9]+:[0-9]+   proxies.txt   > proxy.csv
</code>```

All the proxy in proxy.csv in the following format.

```<code>cat proxy.csv
104.131.6.78:80
104.197.16.8:3128
104.131.94.221:8080
63.110.242.67:3128
</code>```

I wrote my scrawler according to  the webpage.

Multiple Proxies

Here is my frame structure--test.py.

```<code>import scrapy,urllib.request
import os,csv

class TestSpider(scrapy.Spider):
    name = "quotes"
    allowed_domains = ["xxxx.com"]

    def __init__(self, *args, **kw):
        self.timeout = 10
        csvfile = open('proxy.csv')
        reader = csv.reader(csvfile)
        ippool = [row[0] for row in reader]
        self.proxy_pool =  ippool

    def start_requests(self):
        yield scrapy.Request(url , callback=self.parse)

    def get_request(self, url):
        req = Request(url=url)
        if self.proxy_pool:
            req.meta['proxy'] = random.choice(self.proxy_pool)
        return req

    def parse(self, response):
        do something
</code>```

The error info occurs when to run the spider with scrapy  runspider  test.py

Connection was refused by other side: 111: Connection refused.

With the same proxy got from proxybroker ,i use my own way to download the url set instead of scrapy.

To make it simple,all broken proxy ip remain instead of being removed.

The codes snippet following is to test whether proxy ip can be used instead of downloading url set perfectly.

The program structure are as following.

```<code>import time
import csv,os,urllib.request
data_dir = "/tmp/"

urls = set #omit how to get it.

csvfile = open(data_dir + 'proxy.csv')
reader = csv.reader(csvfile)
ippool = [row[0] for row in reader]
ip_len = len(ippool)
ipth = 0

for ith,item in enumerate(urls):
    time.sleep(2)
    flag = 1
    if ipth >= ip_len : ipth =0
    while(ipth <ip_len and flag == 1):
        try :
            handler = urllib.request.ProxyHandler({'http':ippool[ipth]})
            opener = urllib.request.build_opener(handler)
            urllib.request.install_opener(opener)
            response = urllib.request.urlopen(urls[ith]).read().decode("utf8")
            fh = open(data_dir + str(ith),"w")
            fh.write(response)
            fh.close()
            ipth = ipth + 1
            flag = 0
            print(urls[ith] + "downloaded")
        except :
            print("can not downloaded" + urls[ith])
</code>```

Many urls can be downloaded with proxy grabbed by proxybroker.

It is clear that :

many proxy ip grabbed by proxybroker can be used,many of them are free and stable.

some bug in my scrapy codes.

How to fix bugs in my scrapy?

答:
try using the scrapy-proxies

In your Settings.py you can make changes something like this:

```<code># Retry many times since proxies often fail
RETRY_TIMES = 10
# Retry on most error codes since proxies fail for different reasons
RETRY_HTTP_CODES = [500, 503, 504, 400, 403, 404, 408]

DOWNLOADER_MIDDLEWARES = {
    'scrapy.downloadermiddlewares.retry.RetryMiddleware': 90,
    'scrapy_proxies.RandomProxy': 100,
    'scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware': 110,
}

# Proxy list containing entries like
# http://host1:port
# http://username:password@host2:port
# http://host3:port
# ...
PROXY_LIST = '/path/to/proxy/list.txt'

# Proxy mode
# 0 = Every requests have different proxy
# 1 = Take only one proxy from the list and assign it to every requests
# 2 = Put a custom proxy to use in the settings
PROXY_MODE = 0

# If proxy mode is 2 uncomment this sentence :
#CUSTOM_PROXY = "http://host1:port"
</code>```

Hopefully this will help you, as this solved my problem too.

Title: How to use the proxy file in scrapy?

Body:
I got the proxy list with proxybroker.

sudo pip install proxybroker
proxybroker grab --countries US --limit 100 --outfile proxies.txt

To change from the format <Proxy US 0.00s [] 104.131.6.78:80> into 104.131.6.78:80 with grep.

 grep -oP  \([0-9]+.\){3}[0-9]+:[0-9]+   proxies.txt   > proxy.csv

All the proxy in proxy.csv in the following format.

cat proxy.csv
104.131.6.78:80
104.197.16.8:3128
104.131.94.221:8080
63.110.242.67:3128

I wrote my scrawler according to  the webpage.

Multiple Proxies

Here is my frame structure--test.py.

import scrapy,urllib.request
import os,csv

class TestSpider(scrapy.Spider):
    name = "quotes"
    allowed_domains = ["xxxx.com"]

    def __init__(self, *args, **kw):
        self.timeout = 10
        csvfile = open('proxy.csv')
        reader = csv.reader(csvfile)
        ippool = [row[0] for row in reader]
        self.proxy_pool =  ippool

    def start_requests(self):
        yield scrapy.Request(url , callback=self.parse)

    def get_request(self, url):
        req = Request(url=url)
        if self.proxy_pool:
            req.meta['proxy'] = random.choice(self.proxy_pool)
        return req

    def parse(self, response):
        do something

The error info occurs when to run the spider with scrapy  runspider  test.py

Connection was refused by other side: 111: Connection refused.

With the same proxy got from proxybroker ,i use my own way to download the url set instead of scrapy.

To make it simple,all broken proxy ip remain instead of being removed.

The codes snippet following is to test whether proxy ip can be used instead of downloading url set perfectly.

The program structure are as following.

import time
import csv,os,urllib.request
data_dir = "/tmp/"

urls = set #omit how to get it.

csvfile = open(data_dir + 'proxy.csv')
reader = csv.reader(csvfile)
ippool = [row[0] for row in reader]
ip_len = len(ippool)
ipth = 0

for ith,item in enumerate(urls):
    time.sleep(2)
    flag = 1
    if ipth >= ip_len : ipth =0
    while(ipth <ip_len and flag == 1):
        try :
            handler = urllib.request.ProxyHandler({'http':ippool[ipth]})
            opener = urllib.request.build_opener(handler)
            urllib.request.install_opener(opener)
            response = urllib.request.urlopen(urls[ith]).read().decode("utf8")
            fh = open(data_dir + str(ith),"w")
            fh.write(response)
            fh.close()
            ipth = ipth + 1
            flag = 0
            print(urls[ith] + "downloaded")
        except :
            print("can not downloaded" + urls[ith])

Many urls can be downloaded with proxy grabbed by proxybroker.

It is clear that :

many proxy ip grabbed by proxybroker can be used,many of them are free and stable.

some bug in my scrapy codes.

How to fix bugs in my scrapy?

Body:
try using the scrapy-proxies

In your Settings.py you can make changes something like this:

# Retry many times since proxies often fail
RETRY_TIMES = 10
# Retry on most error codes since proxies fail for different reasons
RETRY_HTTP_CODES = [500, 503, 504, 400, 403, 404, 408]

DOWNLOADER_MIDDLEWARES = {
    'scrapy.downloadermiddlewares.retry.RetryMiddleware': 90,
    'scrapy_proxies.RandomProxy': 100,
    'scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware': 110,
}

# Proxy list containing entries like
# http://host1:port
# http://username:password@host2:port
# http://host3:port
# ...
PROXY_LIST = '/path/to/proxy/list.txt'

# Proxy mode
# 0 = Every requests have different proxy
# 1 = Take only one proxy from the list and assign it to every requests
# 2 = Put a custom proxy to use in the settings
PROXY_MODE = 0

# If proxy mode is 2 uncomment this sentence :
#CUSTOM_PROXY = "http://host1:port"

Hopefully this will help you, as this solved my problem too.


问:
Select Distinct Field on Join
I am joining two large tables in MySQL based on a unique identifier they both share. Because there are a large number of fields, I do not want to list out all fields after SELECT. Instead I want to select all fields, but I do not want recurring fields (the shared unique identifier in this case) to be repeated.

With this example query:

```<code>SELECT *
FROM Gr3_PracMath_Jan11_D1 as a, student_list_011811 as b
WHERE a.StudentID = b.StudentID
</code>```

The field StudentID is repeated. Is there a way to prevent this?

答:
I believe that if you do an explicit join with the USING keyword, you won't get a duplicate.</p>

```<code>SELECT *
FROM Gr3_PracMath_Jan11_D1
LEFT JOIN student_list_011811
USING (StudentID)
</code>```

Title: Select Distinct Field on Join

Body:
I am joining two large tables in MySQL based on a unique identifier they both share. Because there are a large number of fields, I do not want to list out all fields after SELECT. Instead I want to select all fields, but I do not want recurring fields (the shared unique identifier in this case) to be repeated.

With this example query:

SELECT *
FROM Gr3_PracMath_Jan11_D1 as a, student_list_011811 as b
WHERE a.StudentID = b.StudentID

The field StudentID is repeated. Is there a way to prevent this?

Body:
I believe that if you do an explicit join with the USING keyword, you won't get a duplicate.

SELECT *
FROM Gr3_PracMath_Jan11_D1
LEFT JOIN student_list_011811
USING (StudentID)


问:
Unexpected non-void return value in void function when returns an array
I would like to get help cuz I'm really confused. It says "Unexpected non-void return value in void function" when it returns an array. I think that my problem is brackets, but I don't know how to fix it.</p>

```<code>func getWords() -> Array<Any>{

           ref = Database.database().reference()
            ref.child("addedWords").observe(.value, with: { (DataSnapshot) in
                var tempWords = DataSnapshot.value as! [String:AnyObject]
                var words = Array(tempWords.keys)
                print(words)

                return words
                })}
</code>```

答:
You can´t just return words in your closure. First of all it´s an async method second you need to return a value outside of the closure which will be called before the closure. You need to have a completionHandler instead of returning Array<Any>. In that case you can pass the value if and when it succeeds. Something like this:

```<code>func getWords(onCompletion: @escaping (Array<Any>) -> Void) {
    ref = Database.database().reference()
    ref.child("addedWords").observe(.value, with: { (DataSnapshot) in
        var tempWords = DataSnapshot.value as! [String:AnyObject]
        var words = Array(tempWords.keys)
        print(words)
        onCompletion(words)
    })
}
</code>```

To call it:

```<code>getWords(onCompletion: { (words) in
    print(words)
})
</code>```

Body:
I would like to get help cuz I'm really confused. It says "Unexpected non-void return value in void function" when it returns an array. I think that my problem is brackets, but I don't know how to fix it.

func getWords() -> Array<Any>{

           ref = Database.database().reference()
            ref.child("addedWords").observe(.value, with: { (DataSnapshot) in
                var tempWords = DataSnapshot.value as! [String:AnyObject]
                var words = Array(tempWords.keys)
                print(words)

                return words
                })}

Body:
You can´t just return words in your closure. First of all it´s an async method second you need to return a value outside of the closure which will be called before the closure. You need to have a completionHandler instead of returning Array<Any>. In that case you can pass the value if and when it succeeds. Something like this:

func getWords(onCompletion: @escaping (Array<Any>) -> Void) {
    ref = Database.database().reference()
    ref.child("addedWords").observe(.value, with: { (DataSnapshot) in
        var tempWords = DataSnapshot.value as! [String:AnyObject]
        var words = Array(tempWords.keys)
        print(words)
        onCompletion(words)
    })
}

To call it:

getWords(onCompletion: { (words) in
    print(words)
})


问:
Removing index.php from codeigniter-2
I am having problems removing index.php from codeigniter-2. I remember using the same code before too & it worked perfectly fine, but it is not working on codeigniter-2.

I have checked the documentation & this question too, still of no help.

My .htaccess code is as follows:

```<code>RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond $1 !^(index\.php|images|robots\.txt|css)
RewriteRule ^(.*)$ ./index.php/$1 [L]
</code>```

答:
you have to re-write the .htaccess file for this.

maximum server work with this

```<code>RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</code>```

in godaddy server i have to write this. sometimes it works with above code in godaddy server.

```<code>RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php?/$1
</code>```

Title: Removing index.php from codeigniter-2

Body:
I am having problems removing index.php from codeigniter-2. I remember using the same code before too & it worked perfectly fine, but it is not working on codeigniter-2.

I have checked the documentation & this question too, still of no help.

My .htaccess code is as follows:

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond $1 !^(index\.php|images|robots\.txt|css)
RewriteRule ^(.*)$ ./index.php/$1 [L]

Body:
you have to re-write the .htaccess file for this.

maximum server work with this

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

in godaddy server i have to write this. sometimes it works with above code in godaddy server.

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php?/$1


问:
NSWindow makeKey() in macOS not working
In my menu bar app, I have a menu item which opens a window. The window opens in the front with the window behind it remaining the key window.

I can't get window.makeKey() to work unless I run it after a breakpoint. I tried putting the line of code in different places in the window's life cycle and even put it in DispatchQueue.main.asyncAfter(deadline: execute:) and it didn't work.

I have also tried  using window.makeKeyAndOrderFront(sender:). The property window.canBecomeKey is true.

答:
Turns out I needed to put this line in the IBAction for the menu item that opens the window:

NSApplication.shared.activate(ignoringOtherApps: true)

That makes it the key window when it opens, so I don't have to call window.makeKey()

Title: NSWindow makeKey() in macOS not working


问:
Java: static abstract (again) - best practice how to work around
I theoretically understand the point why there is no abstract static in Java, as explained for instance in Why can't static methods be abstract in Java .

But how do I solve such a problem then?

My application uses files of a few types, which I want to assign static properties like a description of that file type (like "data file", the other being "config file", etc.).
Obviously, I would put that into a static String so that the description is accessible without instancing a file (useful for the GUI f.i.).
On the other hand, obviously all file types should have some common methods like getStatus(), which obviously I want to inherit from a common superclass MyFileType.

getDescription() would of course be abstract in the superclass.

Tried using a combination of a superclass and an interface, but similar problem: A static implementation of an abstract method is not allowed.

How would a Java guru solve this?
Is it really such a bad implementation that I want to create?

Many thanks,
Philipp

答:
This sounds like a great time to pull out the Fundamental Theorem of Software Engineering:

Any problem can be solved by adding another layer of indirection.

The problem you have right here is that a file carries around multiple pieces of information - what the type of the file is, a description of the file, the file contents, etc.  I'd suggest splitting this into two classes - one class representing a concrete file on disk and its contents, and a second that is an abstract description of some file type.  This would allow you to treat the file type class polymorphically.  For example:

```<code>public interface FileType {
     String getExtension();
     String getDescription();

     /* ... etc. ... */
}
</code>```

Now, you can make subclasses for each of the file types you use:

```<code>public class TextFileType implements FileType {
     public String getExtension() {
         return ".txt";
     }
     public String getDescription() {
         return "A plain ol' text file.";
     }
     /* ... */
}
</code>```

You can then have some large repository of these sorts of objects, which would allow you to query their properties without having an open file of that type.  You could also associate a type with each actual file you use by just having it store a FileType reference.

Body:
This sounds like a great time to pull out the Fundamental Theorem of Software Engineering:

Any problem can be solved by adding another layer of indirection.

The problem you have right here is that a file carries around multiple pieces of information - what the type of the file is, a description of the file, the file contents, etc.  I'd suggest splitting this into two classes - one class representing a concrete file on disk and its contents, and a second that is an abstract description of some file type.  This would allow you to treat the file type class polymorphically.  For example:

public interface FileType {
     String getExtension();
     String getDescription();

     /* ... etc. ... */
}

Now, you can make subclasses for each of the file types you use:

public class TextFileType implements FileType {
     public String getExtension() {
         return ".txt";
     }
     public String getDescription() {
         return "A plain ol' text file.";
     }
     /* ... */
}

You can then have some large repository of these sorts of objects, which would allow you to query their properties without having an open file of that type.  You could also associate a type with each actual file you use by just having it store a FileType reference.


问:
How to check two checkbox unchecked in android
Hello i beginner in android. i am using four checkbox in my project. I want want to call one method after checkbox no 3 and 4 is unchecked state. how to write that code please help me.

Thanks in advance.

```<code>class myCheckBoxChnageClicker implements CompoundButton.OnCheckedChangeListener {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

            // Is the view now checked?
            boolean checked = ((CheckBox) buttonView).isChecked();

            // Check which checkbox was clicked
            switch(buttonView.getId()) {

                case R.id.t3_check:

                    if (checked) {

                    } else {

                    }

                    break;

                case R.id.t4_check:

                    if (checked) {

                    } else {

                    }

                    break;

                case R.id.tsh_check:

                    if (checked) {

                    } else {

                    }

                    break;

                case R.id.weight_check:

                    if(checked) {

                    } else {

                    }

                    break;
                default:

            }

        }

        public void showTextNotification(String msgToDisplay) {

            if ((msgToDisplay.equals("Tsh_Check") && msgToDisplay.equals("Weight_Check"))) {

                Toast.makeText(getApplicationContext(), "match", Toast.LENGTH_SHORT).show();

            } else {

            }

        }
    }
</code>```

Hello this is my code i want to call showTextNotification() method when 3 and 4 checkbox is unchecked state.

答:
Try this.

```<code> final boolean Check_three = false;
 final boolean Check_foure  = false;

        class myCheckBoxChnageClicker implements CompoundButton.OnCheckedChangeListener {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

                // Is the view now checked?
                boolean checked = ((CheckBox) buttonView).isChecked();

                // Check which checkbox was clicked
                switch(buttonView.getId()) {

                    case R.id.t3_check:

                        if (checked) {
                            Check_three = true;

                            if (Check_three == true && Check_foure == true)
                            {
                                showTextNotification("printmeaage");
                            }

                        } else {
                            Check_three = false;

                        }

                        break;

                    case R.id.t4_check:

                        if (checked) {

                            Check_foure = true;
                            if (Check_three == true && Check_foure == true)
                            {
                                showTextNotification("printmeaage");
                            }

                        } else {

                            Check_foure = false;

                        }

                        break;

                    case R.id.tsh_check:

                        if (checked) {

                        } else {

                        }

                        break;

                    case R.id.weight_check:

                        if(checked) {

                        } else {

                        }

                        break;
                    default:

                }

            }
</code>```

Body:
Hello i beginner in android. i am using four checkbox in my project. I want want to call one method after checkbox no 3 and 4 is unchecked state. how to write that code please help me.

Thanks in advance.

class myCheckBoxChnageClicker implements CompoundButton.OnCheckedChangeListener {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

            // Is the view now checked?
            boolean checked = ((CheckBox) buttonView).isChecked();

            // Check which checkbox was clicked
            switch(buttonView.getId()) {

                case R.id.t3_check:

                    if (checked) {

                    } else {

                    }

                    break;

                case R.id.t4_check:

                    if (checked) {

                    } else {

                    }

                    break;

                case R.id.tsh_check:

                    if (checked) {

                    } else {

                    }

                    break;

                case R.id.weight_check:

                    if(checked) {

                    } else {

                    }

                    break;
                default:

            }

        }

        public void showTextNotification(String msgToDisplay) {

            if ((msgToDisplay.equals("Tsh_Check") && msgToDisplay.equals("Weight_Check"))) {

                Toast.makeText(getApplicationContext(), "match", Toast.LENGTH_SHORT).show();

            } else {

            }

        }
    }

Hello this is my code i want to call showTextNotification() method when 3 and 4 checkbox is unchecked state.

Body:
Try this.

 final boolean Check_three = false;
 final boolean Check_foure  = false;

        class myCheckBoxChnageClicker implements CompoundButton.OnCheckedChangeListener {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

                // Is the view now checked?
                boolean checked = ((CheckBox) buttonView).isChecked();

                // Check which checkbox was clicked
                switch(buttonView.getId()) {

                    case R.id.t3_check:

                        if (checked) {
                            Check_three = true;

                            if (Check_three == true && Check_foure == true)
                            {
                                showTextNotification("printmeaage");
                            }

                        } else {
                            Check_three = false;

                        }

                        break;

                    case R.id.t4_check:

                        if (checked) {

                            Check_foure = true;
                            if (Check_three == true && Check_foure == true)
                            {
                                showTextNotification("printmeaage");
                            }

                        } else {

                            Check_foure = false;

                        }

                        break;

                    case R.id.tsh_check:

                        if (checked) {

                        } else {

                        }

                        break;

                    case R.id.weight_check:

                        if(checked) {

                        } else {

                        }

                        break;
                    default:

                }

            }


问:
How does one get a code-behind file to recognize type of a user control?
I have a custom control in my mater page that represents a menu, let's call it CustomMenu. The control code files are located in a non special directory.

I want to give each page that uses that master page the ability to access the control and, using a public property, tell the control whether or not it should render itself.

I have a public property on the control to do that, and I know I can get the control by referencing Page.Master.FindControl('IdOfControlIwant');

The problem I'm having is that I can't seem to get the control Type recognized by the compiler, so when I do find the menu control, I can't actually work with it. The only way I can get the code behind to recognize the type is to register it in the ascx file, and then add at least one control to the page, which is undesirable.

Thoughts?

答:
Use the MasterType directive in your pages:

```<code><%@ MasterType VirtualPath="~/your.master"  %>
</code>```

That will strongly type your Master page reference, so you should be able to add properties that can be accessed by the pages.

Body:
Use the MasterType directive in your pages:

<%@ MasterType VirtualPath="~/your.master"  %>

That will strongly type your Master page reference, so you should be able to add properties that can be accessed by the pages.


问:
How to retrieve data from JSON file using Jquery and ajax?
A weird thing happened to me today: I was trying to retrieve some data from a JSON file using jquery and ajax, and display this data on a webpage. This example, which I found on the Internet, worked for me on the base OS. When I try run it from a virtual machine with Win10 OS it doesn't work, meaning that it throws me to: alert('There was a problem with the server.  Try again soon!');. Why?
Many thanks in advance!

This is in my data19.json file:

```<code> {
  "one": "Learned Optimism",
  "two": "Deliberate Practice",
  "three": "Getting Things Done"
}
</code>```

My script, script19.js, is:

```<code>$(function() {
  $('#clickme').click(function() {
       $.ajax({
       url: 'data19.json',
       dataType: 'json',
       success: function(data) {
          var items = [];

          $.each(data, function(key, val) {

            items.push('<li id="' + key + '">' + val + '</li>');

          });

          $('<ul/>', {
             'class': 'interest-list',
             html: items.join('')
          }).appendTo('body');

       },
      statusCode: {
         404: function() {
           alert('There was a problem with the server.  Try again soon!');
         }
       }
    });
  });
});
</code>```

My HTML file is:

```<code> <!DOCTYPE html>
<html>
<head>
  <title>19. Using jQuery to retrieve JSON via AJAX</title>
  <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.7.1.min.js"></script>
  <script type="text/javascript" src="script19.js"></script>
</head>
<body>
  <h1 id="title">19. Using jQuery to retrieve JSON via AJAX</h1>

  <a href="#" id="clickme">Get JSON Data</a>
</body>
</html>
</code>```

Also when I click "Get JSON Data" this is what appears in Console:

答:
I think this will solution the problem. I tried it by myself.u can use it.

```<code><!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-html -->

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>How to retrieve data from JSON file using Jquery and ajax?</title>
    </head>
    <body>
    <div id="info"></div>
    </body>

----------

    <script type="text/javascript">
                    // script for Load 6 items at a time
                    var j=0; // index for start load in the object
                    var xdata; //A global variable for accessing it from inside the functions. it will load the file and do not want to read the file every time
                    //loading the JSON file to object by Ajax
                    var xreq = new XMLHttpRequest();
                    xreq.open('GET', 'file.json');
                    xreq.onload = function () {
                        //convert the file from text to object after opened it , on load the file
                        xdata = JSON.parse(xreq.responseText);
                        // call funcation to Build the page
                        addHtml(xdata, j);
                        // added 6 to the index for start loading from the next items
                        j = j + 6;
                    };
                    //send ajax
                    xreq.send();

                    // when the page is ready and already the scroll access to end page call the building function again
                    $(document).ready(function () {
                            $(window).scroll(function () {
                                // get the scroll Position
                                var scrollPosition = $(window).scrollTop();
                                // Multiplication operation in 1.2 in order to call the function before arrival the end of the page with 20%
                                if (scrollPosition >= $(document).height() - ($(window).height())*1.2 && j < xdata.length) {
                                    addHtml(xdata, j);
                                    j = j + 6;
                                    xreq.send();
                                }
                            });
                        });

                    //funcation to Build the page
                    function addHtml(data,i) {
                        var info = document.getElementById("info");
                        var HtmlText ="";
                        // insert the HTML items before end a page
                        info.insertAdjacentHTML('beforeend',HtmlText);
                    }
                    </script>

----------

    </html>

<!-- end snippet Alwahashi 2017 -->
</code>```

Body:
A weird thing happened to me today: I was trying to retrieve some data from a JSON file using jquery and ajax, and display this data on a webpage. This example, which I found on the Internet, worked for me on the base OS. When I try run it from a virtual machine with Win10 OS it doesn't work, meaning that it throws me to: alert('There was a problem with the server.  Try again soon!');. Why?
Many thanks in advance!

This is in my data19.json file:

 {
  "one": "Learned Optimism",
  "two": "Deliberate Practice",
  "three": "Getting Things Done"
}

My script, script19.js, is:

$(function() {
  $('#clickme').click(function() {
       $.ajax({
       url: 'data19.json',
       dataType: 'json',
       success: function(data) {
          var items = [];

          $.each(data, function(key, val) {

            items.push('
' + val + '
');

          });

          $('
', {
             'class': 'interest-list',
             html: items.join('')
          }).appendTo('body');

       },
      statusCode: {
         404: function() {
           alert('There was a problem with the server.  Try again soon!');
         }
       }
    });
  });
});

My HTML file is:

 <!DOCTYPE html>

  <title>19. Using jQuery to retrieve JSON via AJAX</title>

19. Using jQuery to retrieve JSON via AJAX

  Get JSON Data

Also when I click "Get JSON Data" this is what appears in Console:

Body:
I think this will solution the problem. I tried it by myself.u can use it.

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-html -->

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>How to retrieve data from JSON file using Jquery and ajax?</title>
    </head>
    <body>
    <div id="info"></div>
    </body>

----------

    <script type="text/javascript">
                    // script for Load 6 items at a time
                    var j=0; // index for start load in the object
                    var xdata; //A global variable for accessing it from inside the functions. it will load the file and do not want to read the file every time
                    //loading the JSON file to object by Ajax
                    var xreq = new XMLHttpRequest();
                    xreq.open('GET', 'file.json');
                    xreq.onload = function () {
                        //convert the file from text to object after opened it , on load the file
                        xdata = JSON.parse(xreq.responseText);
                        // call funcation to Build the page
                        addHtml(xdata, j);
                        // added 6 to the index for start loading from the next items
                        j = j + 6;
                    };
                    //send ajax
                    xreq.send();

                    // when the page is ready and already the scroll access to end page call the building function again
                    $(document).ready(function () {
                            $(window).scroll(function () {
                                // get the scroll Position
                                var scrollPosition = $(window).scrollTop();
                                // Multiplication operation in 1.2 in order to call the function before arrival the end of the page with 20%
                                if (scrollPosition >= $(document).height() - ($(window).height())*1.2 && j < xdata.length) {
                                    addHtml(xdata, j);
                                    j = j + 6;
                                    xreq.send();
                                }
                            });
                        });

                    //funcation to Build the page
                    function addHtml(data,i) {
                        var info = document.getElementById("info");
                        var HtmlText ="";
                        // insert the HTML items before end a page
                        info.insertAdjacentHTML('beforeend',HtmlText);
                    }
                    </script>

----------

    </html>

<!-- end snippet Alwahashi 2017 -->


问:
I am a beginner and I am trying to make a card flip game in netbeans
On clicking an image I want another image to be displayed pause for one second and the original image to be restored and displayed againdisplayed again When I try to do it it action handler such as code given below it sets the image after sleep .I want the image to be displayed pause and the original to be displayed again how can I achieve that</p>

```<code>private void jButton16ActionPerformed(java.awt.event.ActionEvent evt) {
    jButton16.setIcon(new javax.swing.ImageIcon("C:\\Users\\x\\Documents\\O.png"));
    try {           //sleep 1 seconds
        Thread.sleep(1000);
    }
    catch (InterruptedException e)
    {
    }

    jButton16.setIcon(new javax.swing.ImageIcon("C:\\Users\\x\\Documents\\118px-AMIGO.jpg"));     }
</code>```

答:
Swing is single threaded, you should never perform long running or blocking operations within the context of the Event Dispatching Thread

Swing is NOT thread safe, this means you should never update the UI (and anything the UI needs) outside of the context of the EDT

The simplest solution to your problem is to use a Swing Timer

```<code>private void jButton16ActionPerformed(java.awt.event.ActionEvent evt) {
    jButton16.setIcon(new javax.swing.ImageIcon("C:\\Users\\x\\Documents\\O.png"));
    Timer timer = new Timer(1000, new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            jButton16.setIcon(new javax.swing.ImageIcon("C:\\Users\\x\\Documents\\118px-AMIGO.jpg"));
        }
    });
    timer.setRepeats(false);
    timer.start();
}
</code>```

See Concurrency in Swing and How to use Swing Timers for more details

Body:
On clicking an image I want another image to be displayed pause for one second and the original image to be restored and displayed againdisplayed again When I try to do it it action handler such as code given below it sets the image after sleep .I want the image to be displayed pause and the original to be displayed again how can I achieve that

private void jButton16ActionPerformed(java.awt.event.ActionEvent evt) {
    jButton16.setIcon(new javax.swing.ImageIcon("C:\\Users\\x\\Documents\\O.png"));
    try {           //sleep 1 seconds
        Thread.sleep(1000);
    }
    catch (InterruptedException e)
    {
    }

    jButton16.setIcon(new javax.swing.ImageIcon("C:\\Users\\x\\Documents\\118px-AMIGO.jpg"));     }

Body:
Swing is single threaded, you should never perform long running or blocking operations within the context of the Event Dispatching Thread

Swing is NOT thread safe, this means you should never update the UI (and anything the UI needs) outside of the context of the EDT

The simplest solution to your problem is to use a Swing Timer

private void jButton16ActionPerformed(java.awt.event.ActionEvent evt) {
    jButton16.setIcon(new javax.swing.ImageIcon("C:\\Users\\x\\Documents\\O.png"));
    Timer timer = new Timer(1000, new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            jButton16.setIcon(new javax.swing.ImageIcon("C:\\Users\\x\\Documents\\118px-AMIGO.jpg"));
        }
    });
    timer.setRepeats(false);
    timer.start();
}

See Concurrency in Swing and How to use Swing Timers for more details


答:
This Worked for me

```<code>WITH T
AS
(
    SELECT
      id ,
      name,
      type,
      value
      FROM table1 a
        INNER JOIN table2 b
          ON a.id = b.id
        WHERE  b.type in ('display','contact','ship')
)
SELECT
  *
  FROM T
  PIVOT
  (
    MAX([Value])
    FOR
    [Type] IN
    (
        [display],[Contact],[Ship]
    )
  )PVT
</code>```

Check the SQLFiddle

Title: Pivoting the data

Body:
This is my SQL statement

select  id , name, type,  value  from table1 a
INNER JOIN table2 b on a.id = b.id
where  b.type in ('display','contact','ship')

which produces below result

ID  name     type           value
5   test     display        display1
5   test     contact        contact1
5   test     ship           ship1
6   test2    display        display2
6   test2    contact        contact2
6   test2    ship           ship2

I need to get result in kind of pivoted format like this

id  name   display   contact   ship
5   test   display1  contact1 ship1
6   test2  display2  contact2 ship2

I tried this solution : https://stackoverflow.com/a/6849706/2645738 ,but its giving me the same result (3 rows for each data). It's like i need to group by id and name,but don't know how to make display,contact,ship as columns.

Would you please help me for the same.

Body:
This Worked for me

WITH T
AS
(
    SELECT
      id ,
      name,
      type,
      value
      FROM table1 a
        INNER JOIN table2 b
          ON a.id = b.id
        WHERE  b.type in ('display','contact','ship')
)
SELECT
  *
  FROM T
  PIVOT
  (
    MAX([Value])
    FOR
    [Type] IN
    (
        [display],[Contact],[Ship]
    )
  )PVT

Check the SQLFiddle