问:
Non-static variable cannot be referenced from a static context?
i'm a n00b in Android Coding, today I wanna try to use the location service.

I set up a simple class and a simple main, just to have longitude and latitude.

But when I try to call the construction for retrive the long and latitude Android Studio pop out the error:

"Error:(33, 16) error: non-static variable latitude cannot be referenced from a static context"

This is my location Class

```<code>public class AppLocationManager implements LocationListener {

    private LocationManager locationManager;
    private String latitude;
    private String longitude;
    private Criteria criteria;
    private String provider;

    public AppLocationManager(Context context) {
        locationManager = (LocationManager) context
                .getSystemService(Context.LOCATION_SERVICE);
        criteria = new Criteria();
        criteria.setAccuracy(Criteria.ACCURACY_FINE);
        provider = locationManager.getBestProvider(criteria, true);
        locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,1,0,this);
        setMostRecentLocation(locationManager.getLastKnownLocation(provider));
    }

    private void setMostRecentLocation(Location lastKnownLocation) {

    }

    public String getLatitude() {
        return latitude;
    }

    public String getLongitude() {
        return longitude;
    }

    /*
     * (non-Javadoc)
     *
     * @see
     * android.location.LocationListener#onLocationChanged(android.location.
     * Location)
     */
    @Override
    public void onLocationChanged(Location location) {
        double lon = (double) (location.getLongitude());/// * 1E6);
        double lat = (double) (location.getLatitude());// * 1E6);

//      int lontitue = (int) lon;
//      int latitute = (int) lat;
        latitude = lat + "";
        longitude = lon + "";

    }

    /*
     * (non-Javadoc)
     *
     * @see
     * android.location.LocationListener#onProviderDisabled(java.lang.String)
     */
    @Override
    public void onProviderDisabled(String arg0) {
        // TODO Auto-generated method stub

    }

    /*
     * (non-Javadoc)
     *
     * @see
     * android.location.LocationListener#onProviderEnabled(java.lang.String)
     */
    @Override
    public void onProviderEnabled(String arg0) {
        // TODO Auto-generated method stub

    }

    /*
     * (non-Javadoc)
     *
     * @see android.location.LocationListener#onStatusChanged(java.lang.String,
     * int, android.os.Bundle)
     */
    @Override
    public void onStatusChanged(String arg0, int arg1, Bundle arg2) {
        // TODO Auto-generated method stub

    }

}
</code>```

答:
Declare your variable as static as below : </p>

```<code> private static String latitude;
 private static  String longitude;
</code>```

Body:
i'm a n00b in Android Coding, today I wanna try to use the location service.

I set up a simple class and a simple main, just to have longitude and latitude.

But when I try to call the construction for retrive the long and latitude Android Studio pop out the error:

"Error:(33, 16) error: non-static variable latitude cannot be referenced from a static context"

This is my location Class

public class AppLocationManager implements LocationListener {

    private LocationManager locationManager;
    private String latitude;
    private String longitude;
    private Criteria criteria;
    private String provider;

    public AppLocationManager(Context context) {
        locationManager = (LocationManager) context
                .getSystemService(Context.LOCATION_SERVICE);
        criteria = new Criteria();
        criteria.setAccuracy(Criteria.ACCURACY_FINE);
        provider = locationManager.getBestProvider(criteria, true);
        locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,1,0,this);
        setMostRecentLocation(locationManager.getLastKnownLocation(provider));
    }

    private void setMostRecentLocation(Location lastKnownLocation) {

    }

    public String getLatitude() {
        return latitude;
    }

    public String getLongitude() {
        return longitude;
    }

    /*
     * (non-Javadoc)
     *
     * @see
     * android.location.LocationListener#onLocationChanged(android.location.
     * Location)
     */
    @Override
    public void onLocationChanged(Location location) {
        double lon = (double) (location.getLongitude());/// * 1E6);
        double lat = (double) (location.getLatitude());// * 1E6);

//      int lontitue = (int) lon;
//      int latitute = (int) lat;
        latitude = lat + "";
        longitude = lon + "";

    }

    /*
     * (non-Javadoc)
     *
     * @see
     * android.location.LocationListener#onProviderDisabled(java.lang.String)
     */
    @Override
    public void onProviderDisabled(String arg0) {
        // TODO Auto-generated method stub

    }

    /*
     * (non-Javadoc)
     *
     * @see
     * android.location.LocationListener#onProviderEnabled(java.lang.String)
     */
    @Override
    public void onProviderEnabled(String arg0) {
        // TODO Auto-generated method stub

    }

    /*
     * (non-Javadoc)
     *
     * @see android.location.LocationListener#onStatusChanged(java.lang.String,
     * int, android.os.Bundle)
     */
    @Override
    public void onStatusChanged(String arg0, int arg1, Bundle arg2) {
        // TODO Auto-generated method stub

    }

}

Body:
Declare your variable as static as below :

 private static String latitude;
 private static  String longitude;


来源: stackexchange

问:
Nothing is being detected in Tensorflow Object detection API
I'm trying to implement Tensorflow object detection API sample. I am following sentdex videos for getting started. The sample code runs perfectly, it also shows the images which are used for testing the results, but no boundaries around detected objects are shown. Just the plane image is displayed without any errors.

I'm using this code: This Github link.

This is my result after running the sample code.

another image without any detection.

What I'm missing here? The code is included in above link and there is no error logs.

Results of box, score, classes, num in that order.

```<code>  [[[ 0.74907303  0.14624023  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.20880508  1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.20934391  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.20880508  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]]]
[[ 0.03587547  0.02224986  0.0186467   0.01096812  0.01003207  0.00654409
   0.00633549  0.00534311  0.0049596   0.00410213  0.00362371  0.00339186
   0.00308251  0.00303347  0.00293389  0.00277099  0.00269575  0.00266825
   0.00263925  0.00263331  0.00258657  0.00240822  0.0022581   0.00186967
   0.00184311  0.00180467  0.00177475  0.00173655  0.00172811  0.00171935
   0.00171891  0.00170288  0.00163755  0.00162967  0.00160273  0.00156545
   0.00153615  0.00140941  0.00132407  0.00131524  0.0013105   0.00129431
   0.0012582   0.0012553   0.00122365  0.00119186  0.00115651  0.00115186
   0.00112369  0.00107097  0.00105805  0.00104338  0.00102719  0.00102337
   0.00100349  0.00097762  0.00096851  0.00092741  0.00088506  0.00087696
   0.0008734   0.00084826  0.00084135  0.00083513  0.00083398  0.00082068
   0.00080583  0.00078979  0.00078059  0.00077476  0.00075448  0.00074426
   0.00074421  0.00070195  0.00068741  0.00068138  0.00067262  0.00067125
   0.00067033  0.00066035  0.00064729  0.00064205  0.00061964  0.00061794
   0.00060835  0.00060465  0.00059548  0.00059479  0.00059461  0.00059436
   0.00059426  0.00059411  0.00059406  0.00059392  0.00059365  0.00059351
   0.00059191  0.00058798  0.00058682  0.00058148]]
[[  1.   1.  18.  32.  62.  60.  63.  67.  61.  49.  31.  84.  50.  54.
   15.  44.  44.  49.  31.  56.  88.  28.  88.  52.  17.  32.  38.  75.
    3.  33.  48.  59.  35.  57.  47.  51.  19.  27.  72.   4.  84.   6.
   55.  20.  58.  65.  61.  82.  42.  34.  40.  21.  43.  64.  39.  62.
   36.  22.  79.  46.  16.  40.  41.  77.  16.  48.  78.  77.  89.  86.
   27.   8.  87.   5.  25.  70.  80.  76.  75.  67.  65.  37.   2.   9.
   73.  63.  29.  30.  69.  66.  68.  26.  71.  12.  45.  83.  13.  85.
   74.  23.]]
[ 100.]
[[[ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.68494415  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.68494415  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.00784111  0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.68494415  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.68494415  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.68494415  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.68494415  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.68494415  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.68494415  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.68494415  1.          1.        ]
  [ 0.          0.68494415  1.          1.        ]]]
[[ 0.01044297  0.0098214   0.00942165  0.00846471  0.00613666  0.00398615
   0.00357754  0.0030054   0.00255861  0.00236574  0.00232631  0.00220291
   0.00185227  0.0016354   0.0015979   0.00145072  0.00143661  0.00141369
   0.00122685  0.00118978  0.00108457  0.00104251  0.00099215  0.00096401
   0.0008708   0.00084773  0.00080484  0.00078507  0.00078378  0.00076876
   0.00072774  0.00071732  0.00071348  0.00070812  0.00069253  0.0006762
   0.00067269  0.00059905  0.00059367  0.000588    0.00056114  0.0005504
   0.00051472  0.00051057  0.00050973  0.00048486  0.00047297  0.00046204
   0.00044787  0.00043259  0.00042987  0.00042673  0.00041978  0.00040494
   0.00040087  0.00039576  0.00039059  0.00037274  0.00036831  0.00036417
   0.00036119  0.00034645  0.00034479  0.00034078  0.00033771  0.00033605
   0.0003333   0.0003304   0.0003294   0.00032326  0.00031787  0.00031773
   0.00031748  0.00031741  0.00031732  0.00031729  0.00031724  0.00031722
   0.00031717  0.00031708  0.00031702  0.00031579  0.00030416  0.00030222
   0.00029739  0.00029726  0.00028289  0.0002653   0.00026325  0.00024584
   0.00024221  0.00024156  0.00023911  0.00023335  0.00021619  0.0002001
   0.00019127  0.00018342  0.00017273  0.00015509]]
[[ 38.   1.   1.  16.  25.  38.  64.  24.  49.  56.  20.   3.  28.   2.
   48.  19.  21.  62.  50.   6.   8.   7.  67.  18.  35.  53.  39.  55.
   15.  57.  72.  52.  10.   5.  42.  43.  76.  22.  82.   4.  61.  23.
   17.  16.  87.  62.  51.  60.  36.  58.  59.  33.  31.  54.  70.  11.
   40.  79.  31.   9.  41.  77.  80.  34.  90.  89.  73.  13.  84.  32.
   63.  29.  30.  69.  66.  68.  26.  71.  12.  45.  83.  14.  44.  78.
   85.  46.  47.  19.  65.  74.  37.  27.  63.  88.  28.  81.  86.  75.
   27.  18.]]
[ 100.]
</code>```

EDIT: As per suggested answers, it is working when we use faster_rcnn_resnet101_coco_2017_11_08 model. But it is more accurate and that's why slower. I want this application with high speed because I'm going to use it in real time (on webcam) object detection. So I need to use faster model (ssd_mobilenet_v1_coco_2017_11_08)

答: You can use older 'ssd_mobilenet_v1 ... ' and run your program completely with boxes (I run it just now and it is correct). This is a link to this older version. Hope they correct newer version soon!</p>

ContentLicense: CC BY-SA 3.0

Body:
I'm trying to implement Tensorflow object detection API sample. I am following sentdex videos for getting started. The sample code runs perfectly, it also shows the images which are used for testing the results, but no boundaries around detected objects are shown. Just the plane image is displayed without any errors.

I'm using this code: This Github link.

This is my result after running the sample code.

another image without any detection.

What I'm missing here? The code is included in above link and there is no error logs.

Results of box, score, classes, num in that order.

  [[[ 0.74907303  0.14624023  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.20880508  1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.20934391  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.20880508  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.74907303  0.14624023  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]]]
[[ 0.03587547  0.02224986  0.0186467   0.01096812  0.01003207  0.00654409
   0.00633549  0.00534311  0.0049596   0.00410213  0.00362371  0.00339186
   0.00308251  0.00303347  0.00293389  0.00277099  0.00269575  0.00266825
   0.00263925  0.00263331  0.00258657  0.00240822  0.0022581   0.00186967
   0.00184311  0.00180467  0.00177475  0.00173655  0.00172811  0.00171935
   0.00171891  0.00170288  0.00163755  0.00162967  0.00160273  0.00156545
   0.00153615  0.00140941  0.00132407  0.00131524  0.0013105   0.00129431
   0.0012582   0.0012553   0.00122365  0.00119186  0.00115651  0.00115186
   0.00112369  0.00107097  0.00105805  0.00104338  0.00102719  0.00102337
   0.00100349  0.00097762  0.00096851  0.00092741  0.00088506  0.00087696
   0.0008734   0.00084826  0.00084135  0.00083513  0.00083398  0.00082068
   0.00080583  0.00078979  0.00078059  0.00077476  0.00075448  0.00074426
   0.00074421  0.00070195  0.00068741  0.00068138  0.00067262  0.00067125
   0.00067033  0.00066035  0.00064729  0.00064205  0.00061964  0.00061794
   0.00060835  0.00060465  0.00059548  0.00059479  0.00059461  0.00059436
   0.00059426  0.00059411  0.00059406  0.00059392  0.00059365  0.00059351
   0.00059191  0.00058798  0.00058682  0.00058148]]
[[  1.   1.  18.  32.  62.  60.  63.  67.  61.  49.  31.  84.  50.  54.
   15.  44.  44.  49.  31.  56.  88.  28.  88.  52.  17.  32.  38.  75.
    3.  33.  48.  59.  35.  57.  47.  51.  19.  27.  72.   4.  84.   6.
   55.  20.  58.  65.  61.  82.  42.  34.  40.  21.  43.  64.  39.  62.
   36.  22.  79.  46.  16.  40.  41.  77.  16.  48.  78.  77.  89.  86.
   27.   8.  87.   5.  25.  70.  80.  76.  75.  67.  65.  37.   2.   9.
   73.  63.  29.  30.  69.  66.  68.  26.  71.  12.  45.  83.  13.  85.
   74.  23.]]
[ 100.]
[[[ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.68494415  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.68494415  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.00784111  0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.68494415  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.68494415  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.68494415  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.68494415  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.68494415  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.68494415  1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.          1.          1.        ]
  [ 0.          0.68494415  1.          1.        ]
  [ 0.          0.68494415  1.          1.        ]]]
[[ 0.01044297  0.0098214   0.00942165  0.00846471  0.00613666  0.00398615
   0.00357754  0.0030054   0.00255861  0.00236574  0.00232631  0.00220291
   0.00185227  0.0016354   0.0015979   0.00145072  0.00143661  0.00141369
   0.00122685  0.00118978  0.00108457  0.00104251  0.00099215  0.00096401
   0.0008708   0.00084773  0.00080484  0.00078507  0.00078378  0.00076876
   0.00072774  0.00071732  0.00071348  0.00070812  0.00069253  0.0006762
   0.00067269  0.00059905  0.00059367  0.000588    0.00056114  0.0005504
   0.00051472  0.00051057  0.00050973  0.00048486  0.00047297  0.00046204
   0.00044787  0.00043259  0.00042987  0.00042673  0.00041978  0.00040494
   0.00040087  0.00039576  0.00039059  0.00037274  0.00036831  0.00036417
   0.00036119  0.00034645  0.00034479  0.00034078  0.00033771  0.00033605
   0.0003333   0.0003304   0.0003294   0.00032326  0.00031787  0.00031773
   0.00031748  0.00031741  0.00031732  0.00031729  0.00031724  0.00031722
   0.00031717  0.00031708  0.00031702  0.00031579  0.00030416  0.00030222
   0.00029739  0.00029726  0.00028289  0.0002653   0.00026325  0.00024584
   0.00024221  0.00024156  0.00023911  0.00023335  0.00021619  0.0002001
   0.00019127  0.00018342  0.00017273  0.00015509]]
[[ 38.   1.   1.  16.  25.  38.  64.  24.  49.  56.  20.   3.  28.   2.
   48.  19.  21.  62.  50.   6.   8.   7.  67.  18.  35.  53.  39.  55.
   15.  57.  72.  52.  10.   5.  42.  43.  76.  22.  82.   4.  61.  23.
   17.  16.  87.  62.  51.  60.  36.  58.  59.  33.  31.  54.  70.  11.
   40.  79.  31.   9.  41.  77.  80.  34.  90.  89.  73.  13.  84.  32.
   63.  29.  30.  69.  66.  68.  26.  71.  12.  45.  83.  14.  44.  78.
   85.  46.  47.  19.  65.  74.  37.  27.  63.  88.  28.  81.  86.  75.
   27.  18.]]
[ 100.]

EDIT: As per suggested answers, it is working when we use faster_rcnn_resnet101_coco_2017_11_08 model. But it is more accurate and that's why slower. I want this application with high speed because I'm going to use it in real time (on webcam) object detection. So I need to use faster model (ssd_mobilenet_v1_coco_2017_11_08)


问:
How can I do a dictionary format with f-string in Python 3 .6?
How can I do this format with a Python 3.6 F-String?</p>
```<code>person = {'name': 'Jenne', 'age': 23}

print('My name {0[name]} and my age {1[age]}'.format(person, person))
print('My name {0} and my age {1}'.format(person['name'], person['age']))
</code>```

答:
Depending on the number of contributions your dictionary makes to a given string, you might consider using .format(**dict) instead to make it more readable, even though it doesn't have the terse elegance of an f-string.

>>> person = {'name': 'Jenne', 'age': 23}
>>> print('My name is {name} and my age is {age}.'.format(**person))
```

Output:

My name is Jenne and my age is 23.

While this option is situational, you might like avoiding a snarl up of quotes and double quotes.

ContentLicense: CC BY-SA 4.0

Body:
How can I do this format with a Python 3.6 F-String?

person = {'name': 'Jenne', 'age': 23}

print('My name {0[name]} and my age {1[age]}'.format(person, person))
print('My name {0} and my age {1}'.format(person['name'], person['age']))

Body:
Depending on the number of contributions your dictionary makes to a given string, you might consider using .format(**dict) instead to make it more readable, even though it doesn't have the terse elegance of an f-string.

>>> person = {'name': 'Jenne', 'age': 23}
>>> print('My name is {name} and my age is {age}.'.format(**person))

Output:

My name is Jenne and my age is 23.

While this option is situational, you might like avoiding a snarl up of quotes and double quotes.


问:
Xamarin forms - Load pages best practices
I want to create a "loader" which displayed when my ContentView will be loaded.

Like this in YouTube application:

As you can see, when I click on tab button, a loader appears.

But in Xamarin.Forms, I don't know how to do that, because ContentView have not OnAppearing to hide my loader. (And because my loader will be displayed at the same time of my ContentView).
When I click on my button, my app "froze" during 200ms approximately... Not good for user experience...

This is why I come here, what is the best practice to display my content?

Thanks

答:
You can add a loading image and a grid (or whatever you need) within an absolute layout in your XAML, like so:

```<code><AbsoluteLayout>
    <Grid ... IsVisible="{Binding IsBusy, Converter={StaticResource InvertBooleanConverter}}"> ... </Grid>
    <Image ... IsVisible="{Binding IsBusy}" />
</AbsoluteLayout>
</code>```

Create a property called IsBusy in your ViewModel, like so:

```<code>bool _isBusy = true;
public bool IsBusy
{
    get
    {
        return _isBusy;
    }
    set
    {
        _isBusy = value;
        OnPropertyChanged(nameof(IsBusy));
    }
}
</code>```

Then set IsBusy to false in your ViewModel when your data has fully loaded. This results in the Image being displayed until the data loads, when it is replaced by your grid full of data.

You'll need to create the InvertBooleanConverter converter like so:

```<code>public class InvertBooleanConverter : IValueConverter
    {
        public object Convert (object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return !(bool)value;
        }
        public object ConvertBack (object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return !(bool)value;
        }
    }
</code>```

Body:
You can add a loading image and a grid (or whatever you need) within an absolute layout in your XAML, like so:

<AbsoluteLayout>
    <Grid ... IsVisible="{Binding IsBusy, Converter={StaticResource InvertBooleanConverter}}"> ... </Grid>
    <Image ... IsVisible="{Binding IsBusy}" />
</AbsoluteLayout>

Create a property called IsBusy in your ViewModel, like so:

bool _isBusy = true;
public bool IsBusy
{
    get
    {
        return _isBusy;
    }
    set
    {
        _isBusy = value;
        OnPropertyChanged(nameof(IsBusy));
    }
}

Then set IsBusy to false in your ViewModel when your data has fully loaded. This results in the Image being displayed until the data loads, when it is replaced by your grid full of data.

You'll need to create the InvertBooleanConverter converter like so:

public class InvertBooleanConverter : IValueConverter
    {
        public object Convert (object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return !(bool)value;
        }
        public object ConvertBack (object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return !(bool)value;
        }
    }


问:
React Native Android location request timed out
In IOS there isn't a problem while looking for gps coords. It works fine.

On Android side its not stable as IOS. This problem both in real device and emulator. Sometimes it can find location, but sometimes not. Looking for 3days but there wasn't find a solution.

When my app cannot find my location, I tried via Google Maps app, it works like charm.

Here is my code for both IOS and Android;

```<code>getCurrentPosition() {
    navigator.geolocation.getCurrentPosition(
        (position) => {
            this.setState({ initialPosition: position });
            alert(JSON.stringify(position))
            var coords = new Coords();
            coords.Latitude = position.coords.latitude;
            coords.Longitude = position.coords.longitude;
            this.getPharmaciesByCoordinates(coords);
        },
        (error) => alert(error.message),
        { enableHighAccuracy: true, timeout: 20000, maximumAge: 1000 }
    );
    this.watchID = navigator.geolocation.watchPosition((position) => {
        this.setState({ initialPosition: position });
    },
        (error) => alert(error.message),
        { enableHighAccuracy: true, timeout: 20000, maximumAge: 1000 }
    );
}
</code>```

Any kind of solution is welcome.

Thanks

答:
the tricks is, if you set

```<code>{ enableHighAccuracy: true, timeout: 25000, maximumAge: 3600000 }
</code>```

then it will work. full code below.

```<code>import React, { Component } from 'react';
import { View, Text } from 'react-native';

class GeolocationExample extends Component {
constructor(props) {
super(props);

this.state = {
  latitude: null,
  longitude: null,
  error: null,
};
}

componentDidMount() {
navigator.geolocation.getCurrentPosition(
  (position) => {
    this.setState({
      latitude: position.coords.latitude,
      longitude: position.coords.longitude,
      error: null,
       });
       },
  (error) => this.setState({ error: error.message }),
  { enableHighAccuracy: true, timeout: 25000, maximumAge: 3600000 },
);}

 render() {
return (
  <View style={{ flexGrow: 1, alignItems: 'center', justifyContent: 'center' }}>
    <Text>Latitude: {this.state.latitude}</Text>
    <Text>Longitude: {this.state.longitude}</Text>
    {this.state.error ? <Text>Error: {this.state.error}</Text> : null}
  </View>
  );
 }
}

export default GeolocationExample;
</code>```

Body:
In IOS there isn't a problem while looking for gps coords. It works fine.

On Android side its not stable as IOS. This problem both in real device and emulator. Sometimes it can find location, but sometimes not. Looking for 3days but there wasn't find a solution.

When my app cannot find my location, I tried via Google Maps app, it works like charm.

Here is my code for both IOS and Android;

getCurrentPosition() {
    navigator.geolocation.getCurrentPosition(
        (position) => {
            this.setState({ initialPosition: position });
            alert(JSON.stringify(position))
            var coords = new Coords();
            coords.Latitude = position.coords.latitude;
            coords.Longitude = position.coords.longitude;
            this.getPharmaciesByCoordinates(coords);
        },
        (error) => alert(error.message),
        { enableHighAccuracy: true, timeout: 20000, maximumAge: 1000 }
    );
    this.watchID = navigator.geolocation.watchPosition((position) => {
        this.setState({ initialPosition: position });
    },
        (error) => alert(error.message),
        { enableHighAccuracy: true, timeout: 20000, maximumAge: 1000 }
    );
}

Any kind of solution is welcome.

Thanks

Body:
the tricks is, if you set

{ enableHighAccuracy: true, timeout: 25000, maximumAge: 3600000 }

then it will work. full code below.

import React, { Component } from 'react';
import { View, Text } from 'react-native';

class GeolocationExample extends Component {
constructor(props) {
super(props);

this.state = {
  latitude: null,
  longitude: null,
  error: null,
};
}

componentDidMount() {
navigator.geolocation.getCurrentPosition(
  (position) => {
    this.setState({
      latitude: position.coords.latitude,
      longitude: position.coords.longitude,
      error: null,
       });
       },
  (error) => this.setState({ error: error.message }),
  { enableHighAccuracy: true, timeout: 25000, maximumAge: 3600000 },
);}

 render() {
return (
  <View style={{ flexGrow: 1, alignItems: 'center', justifyContent: 'center' }}>
    <Text>Latitude: {this.state.latitude}</Text>
    <Text>Longitude: {this.state.longitude}</Text>
    {this.state.error ? <Text>Error: {this.state.error}</Text> : null}
  </View>
  );
 }
}

export default GeolocationExample;


问:
Will TestFlight remove my previous builds if I upload a new version of an app?
I have a version of my app, let's say 1.0.2, which has 3 builds currently testing in TestFlight (builds 18, 19 and 20). Now we are planning for a newer version of app and hence the new version will be version 1.0.3 with the build number 1, will Apple remove or expire my previous TestFlight builds of previous version 1.0.2?

Apple says:

We’ve made some changes to help you do more with TestFlight in iTunes Connect. With multiple build support, enhanced groups, and improved tester management, we’re making it even easier to test your apps.

It says multiple builds, does this mean multiple builds only or multiple versions + multiple builds? It's confusing.

答: No, your previous builds will stay testable, even if a new minor (or major) version is introduced.


问:
remove white space before after of data in text area
I input string to textarea such as below:

```<code>         email1@gmail.com
   email@gmail.com
 email3@gmail.com
      email4@gmail.com
</code>```

How to format they to:

```<code>email1@gmail.com
email@gmail.com
email3@gmail.com
email4@gmail.com
</code>```

One email in one line in textarea. I want use PHP to make it.
Please help me about solution, thanks you.

答:
Use the trim function to do this.</p>

```<code>return(trim($str));
</code>```

Body:
I input string to textarea such as below:

         email1@gmail.com
   email@gmail.com
 email3@gmail.com
      email4@gmail.com

How to format they to:

email1@gmail.com
email@gmail.com
email3@gmail.com
email4@gmail.com

One email in one line in textarea. I want use PHP to make it.
Please help me about solution, thanks you.

Body:
Use the trim function to do this.

return(trim($str));


问:
when I click on Browse &;80(http) i got this screen

when I clicked on Browse *;80(http) I got this screen in IIS..what could wrong? please give me solution.

答:
The issue you are running into is a common problem for developers since they start developing on their Desktop or their Documents folder without realizing that only they have access to them. In other words those folders only have ACL's for you. This works ok when you use Visual Studio since they run the process as your identity which makes it all work, however when you use a real server, such as IIS that runs as a service it will no longer run the process as your identity but some service account which will NOT have access to your directory.

You will need to add ACLs for IIS to be able to read the files (IIS_IUSRS or the AppPool Identity like IIS APPPOOL\DefaultAppPool, depending on the settings of your apppool), or move it to a folder that has enough access such as \inetpub\wwwroot\

ContentLicense: CC BY-SA 2.5


问:
Remove NaN from input while calculation
I have a javascript function in which I need to remove the NaN from textbox after calculation ?

```<code>function calculateInterest() {

    var repay_period = parseInt(document.getElementById("emp_loan_repayment_method_id").value);
    var loan_amount = parseInt(document.getElementById("maximum_loan_amount").value);
    var rate_of_interest = parseInt(document.getElementById("rate_of_interest").value);
    var no_of_months = parseInt(document.getElementById("repayment_periods").value);
    var repay_month_amount = parseInt(document.getElementById("repayment_amount").value);
    var no_of_periods = no_of_months / 12;

    {
        var payable_interest = (loan_amount * no_of_periods * rate_of_interest) / 100;

        var pay_interest = payable_interest.toFixed(2);

        document.getElementById("total_payable_interest").value = pay_interest;

        var repay_amount = (loan_amount / no_of_months).toFixed(2);

        document.getElementById("repayment_amount").value = repay_amount;

        var total_payable_amount = (payable_interest + loan_amount).toFixed(2);

        document.getElementById("total_payable_amount").value = total_payable_amount;

    }
}
</code>```

答:
Using isNan() will help you :

see below snippet :

function calculateInterest() {

    var repay_period = parseInt(document.getElementById("emp_loan_repayment_method_id").value) ;
    var loan_amount = parseInt(document.getElementById("maximum_loan_amount").value);
    var rate_of_interest = parseInt(document.getElementById("rate_of_interest").value);
    var no_of_months = parseInt(document.getElementById("repayment_periods").value);
    var repay_month_amount = parseInt(document.getElementById("repayment_amount").value);
    var no_of_periods = no_of_months / 12;

    {
        var payable_interest = (loan_amount * no_of_periods * rate_of_interest) / 100;

        var pay_interest = payable_interest.toFixed(2);
        pay_interest = isNaN(pay_interest) ? 0 : pay_interest;
        document.getElementById("total_payable_interest").value = pay_interest;

        var repay_amount = (loan_amount / no_of_months).toFixed(2);
        repay_amount = isNaN(repay_amount) ? 0 : repay_amount;
        document.getElementById("repayment_amount").value = repay_amount;

        var total_payable_amount = (payable_interest + loan_amount).toFixed(2);
        total_payable_amount = isNaN(total_payable_amount) ? 0 : total_payable_amount;
        document.getElementById("total_payable_amount").value = total_payable_amount;

    }
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code>emp_loan_repayment_method : <input id="emp_loan_repayment_method_id" value="100" />
<br>
maximum_loan_amount : <input id="maximum_loan_amount" value ="50" />
<br>
rate_of_interest : <input id="rate_of_interest" value="2" />
<br>
repayment_periods : <input id="repayment_periods" value="3" />
<br>
repayment_amount : <input id="repayment_amount" value="200"  />

<br><br><br>

total_payable_interest : <input id="total_payable_interest" />
<br><br>
total_payable_amount : <input id="total_payable_amount" />
<br><br>

<button onclick="calculateInterest()" >Calculate</button></code>```

Title: Remove NaN from input while calculation

Body:
I have a javascript function in which I need to remove the NaN from textbox after calculation ?

function calculateInterest() {

    var repay_period = parseInt(document.getElementById("emp_loan_repayment_method_id").value);
    var loan_amount = parseInt(document.getElementById("maximum_loan_amount").value);
    var rate_of_interest = parseInt(document.getElementById("rate_of_interest").value);
    var no_of_months = parseInt(document.getElementById("repayment_periods").value);
    var repay_month_amount = parseInt(document.getElementById("repayment_amount").value);
    var no_of_periods = no_of_months / 12;

    {
        var payable_interest = (loan_amount * no_of_periods * rate_of_interest) / 100;

        var pay_interest = payable_interest.toFixed(2);

        document.getElementById("total_payable_interest").value = pay_interest;

        var repay_amount = (loan_amount / no_of_months).toFixed(2);

        document.getElementById("repayment_amount").value = repay_amount;

        var total_payable_amount = (payable_interest + loan_amount).toFixed(2);

        document.getElementById("total_payable_amount").value = total_payable_amount;

    }
}

Body:
Using isNan() will help you :

see below snippet :

function calculateInterest() {

    var repay_period = parseInt(document.getElementById("emp_loan_repayment_method_id").value) ;
    var loan_amount = parseInt(document.getElementById("maximum_loan_amount").value);
    var rate_of_interest = parseInt(document.getElementById("rate_of_interest").value);
    var no_of_months = parseInt(document.getElementById("repayment_periods").value);
    var repay_month_amount = parseInt(document.getElementById("repayment_amount").value);
    var no_of_periods = no_of_months / 12;

    {
        var payable_interest = (loan_amount * no_of_periods * rate_of_interest) / 100;

        var pay_interest = payable_interest.toFixed(2);
        pay_interest = isNaN(pay_interest) ? 0 : pay_interest;
        document.getElementById("total_payable_interest").value = pay_interest;

        var repay_amount = (loan_amount / no_of_months).toFixed(2);
        repay_amount = isNaN(repay_amount) ? 0 : repay_amount;
        document.getElementById("repayment_amount").value = repay_amount;

        var total_payable_amount = (payable_interest + loan_amount).toFixed(2);
        total_payable_amount = isNaN(total_payable_amount) ? 0 : total_payable_amount;
        document.getElementById("total_payable_amount").value = total_payable_amount;

    }
}

emp_loan_repayment_method : <input id="emp_loan_repayment_method_id" value="100" />
<br>
maximum_loan_amount : <input id="maximum_loan_amount" value ="50" />
<br>
rate_of_interest : <input id="rate_of_interest" value="2" />
<br>
repayment_periods : <input id="repayment_periods" value="3" />
<br>
repayment_amount : <input id="repayment_amount" value="200"  />

<br><br><br>

total_payable_interest : <input id="total_payable_interest" />
<br><br>
total_payable_amount : <input id="total_payable_amount" />
<br><br>

<button onclick="calculateInterest()" >Calculate</button>


问:
Can't set shadow on UICollectionViewCell and have rounded corners. Can only make one work at a time
I have a UICollectionViewCell subclass and I need to round its corners and add a shadow as well.  The cell looks like a square card, and the cells have a good amount of space in-between them.

So "underneath" every cell, I would like to add some shadow. I can successfully do this, but then my cell only has rounded corners on the bottom. The top just has normal corners. I need rounded corners for all four corners.

I have found solutions on here for UIViews that recommend adding a separate UIView as a subview, but I would prefer to avoid this for performance reasons.

I did find one solution which was to use this method which you will find in my code below:

[UIBezierPath bezierPathWithRoundedRect: cornerRadius:]

But that didn't work for me either. Is it possible that it's not working for me because of how I'm trying to only add the shadow "underneath" / at the bottom of the cell? It seems like most of these answers are provided for questions where the developer wants to add a shadow around the entire cell.

I guess I would be willing to add a special subview to my UICollectionViewCell subclass, but I would like to use that as a last resort.

I am targeting iOS 7+ and using Xcode 6.1.1.

Here is the code I am using inside my UICollectionViewCell subclass to try and achieve both the shadow and the rounded corners:

```<code>- (void)load:(CustomUserObject *)customObject
{
    self.customObject = customObject;

    // Round cell corners
    self.layer.cornerRadius = 12;

    // Add shadow
    self.layer.masksToBounds = NO;
    self.layer.shadowOpacity = 0.75f;
    self.layer.shadowRadius = 10.0f;
    self.layer.shouldRasterize = NO;
    self.layer.shadowPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(self.frame.size.width/2 - (self.frame.size.width - 50)/2, self.frame.size.height, self.frame.size.width - 50, 10) cornerRadius:self.layer.cornerRadius].CGPath;

}
</code>```

EDIT: If I set self.layer.masksToBounds to NO, the shadow works but the top corners do not round. If I set self.layer.masksToBounds to YES, the shadow does not work, but all four corners are now rounded. I just can't figure out how to round all four corners and get the shadow to work.

答:
```<code>func dropShadow() {
    self.layer.masksToBounds = false
    self.layer.shadowColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.25).cgColor
    self.layer.shadowOpacity = 0.5
    self.layer.shadowOffset = CGSize(width: 0.0, height: 2.0)
    self.layer.shadowRadius = 4.0
    self.layer.cornerRadius = 5.0
}
</code>```

<p>//To drop shadow use </p>

<p>cell.dropShadow()    </p>

Body:
I have a UICollectionViewCell subclass and I need to round its corners and add a shadow as well.  The cell looks like a square card, and the cells have a good amount of space in-between them.

So "underneath" every cell, I would like to add some shadow. I can successfully do this, but then my cell only has rounded corners on the bottom. The top just has normal corners. I need rounded corners for all four corners.

I have found solutions on here for UIViews that recommend adding a separate UIView as a subview, but I would prefer to avoid this for performance reasons.

I did find one solution which was to use this method which you will find in my code below:

[UIBezierPath bezierPathWithRoundedRect: cornerRadius:]

But that didn't work for me either. Is it possible that it's not working for me because of how I'm trying to only add the shadow "underneath" / at the bottom of the cell? It seems like most of these answers are provided for questions where the developer wants to add a shadow around the entire cell.

I guess I would be willing to add a special subview to my UICollectionViewCell subclass, but I would like to use that as a last resort.

I am targeting iOS 7+ and using Xcode 6.1.1.

Here is the code I am using inside my UICollectionViewCell subclass to try and achieve both the shadow and the rounded corners:

- (void)load:(CustomUserObject *)customObject
{
    self.customObject = customObject;

    // Round cell corners
    self.layer.cornerRadius = 12;

    // Add shadow
    self.layer.masksToBounds = NO;
    self.layer.shadowOpacity = 0.75f;
    self.layer.shadowRadius = 10.0f;
    self.layer.shouldRasterize = NO;
    self.layer.shadowPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(self.frame.size.width/2 - (self.frame.size.width - 50)/2, self.frame.size.height, self.frame.size.width - 50, 10) cornerRadius:self.layer.cornerRadius].CGPath;

}

EDIT: If I set self.layer.masksToBounds to NO, the shadow works but the top corners do not round. If I set self.layer.masksToBounds to YES, the shadow does not work, but all four corners are now rounded. I just can't figure out how to round all four corners and get the shadow to work.

Body:
func dropShadow() {
    self.layer.masksToBounds = false
    self.layer.shadowColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.25).cgColor
    self.layer.shadowOpacity = 0.5
    self.layer.shadowOffset = CGSize(width: 0.0, height: 2.0)
    self.layer.shadowRadius = 4.0
    self.layer.cornerRadius = 5.0
}

//To drop shadow use

cell.dropShadow()


问:
Call the dialog from Intent
Is it possible to call a dialog from Intent. I have two Activity RegisterActivity and AuthenticActivity and I implemented custom dialog on RegisterActivity but I also need same dialog on AuthenticActivity. So how can we get that dialog on AuthenticActivity. Can we get that from Intent, Please suggest me? I don't want to write code on both Activity.</p>

答:
short awnser: use a BroadcastReceiver.

```<code>@Override
public void onReceive(Context context, Intent intent) {

  if (intent.getAction().equals(ACTION_EXECUTE_EXAMPLE_TEST)) {
      //Do whatever you want
  }
}
</code>```

Check it out for yourself here. Add it on manifest and then you can receive the intent in your activities ;)

Title: Call the dialog from Intent

Body:
short awnser: use a BroadcastReceiver.

@Override
public void onReceive(Context context, Intent intent) {

  if (intent.getAction().equals(ACTION_EXECUTE_EXAMPLE_TEST)) {
      //Do whatever you want
  }
}

Check it out for yourself here. Add it on manifest and then you can receive the intent in your activities ;)


问:
Looks for patterns across different lines
I have a file like this (test.txt):

```<code>abc
12
34
def
56
abc
ghi
78
def
90
</code>```

And I would like to search the 78 which is enclosed by "abc\nghi" and "def". Currently, I know I can do this by:

```<code>cat test.txt | awk '/abc/,/def/' | awk '/ghi/,'/def/'
</code>```

Is there any better way?

答:
One way is to use flags

```<code>$ awk '/ghi/ && p~/abc/{f=1} f; /def/{f=0} {p=$0}' test.txt
ghi
78
def
</code>```

{p=$0} this will save input line for future use

/ghi/ && p~/abc/{f=1} set flag if current line contains ghi and previous line contains abc

f; print input record as long as flag is set

/def/{f=0} clear the flag if line contains def

If you only want the lines between these two boundaries

```<code>$ awk '/ghi/ && p~/abc/{f=1; next} /def/{f=0} f; {p=$0}' ip.txt
78
$ awk '/12/ && p~/abc/{f=1; next} /def/{f=0} f; {p=$0}' ip.txt
34
</code>```

See also How to select lines between two patterns?

Body:
I have a file like this (test.txt):

abc
12
34
def
56
abc
ghi
78
def
90

And I would like to search the 78 which is enclosed by "abc\nghi" and "def". Currently, I know I can do this by:

cat test.txt | awk '/abc/,/def/' | awk '/ghi/,'/def/'

Is there any better way?

Body:
One way is to use flags

$ awk '/ghi/ && p~/abc/{f=1} f; /def/{f=0} {p=$0}' test.txt
ghi
78
def

{p=$0} this will save input line for future use

/ghi/ && p~/abc/{f=1} set flag if current line contains ghi and previous line contains abc

f; print input record as long as flag is set

/def/{f=0} clear the flag if line contains def

If you only want the lines between these two boundaries

$ awk '/ghi/ && p~/abc/{f=1; next} /def/{f=0} f; {p=$0}' ip.txt
78
$ awk '/12/ && p~/abc/{f=1; next} /def/{f=0} f; {p=$0}' ip.txt
34

See also How to select lines between two patterns?


问:
Microsoft Bot Framework Special Characters
A coworker of mine developed a bot using MS Bot Framework. It's working as expected, but there are responses wherein special characters are shown in place of apostrophe's. Please let me know if you guys experienced this and have any fix. Thanks. :)

答:
You can use regex class for a best practice to avoid other special characters in future. Below is the sample you can use</p>

```<code>using System;
using System.Text.RegularExpressions;

class Program
{
    static void Main()
    {

        string inputString = "Manoj# Bhard@waj";
        //  . indicates any character to be removed. You can also write characters as well to remove some selected characters
        string outputString = Regex.Replace(input, ".", " ");

        // Write the output.
        Console.WriteLine(inputString);
        Console.WriteLine(outputString);
    }
}
</code>```

Body:
You can use regex class for a best practice to avoid other special characters in future. Below is the sample you can use

using System;
using System.Text.RegularExpressions;

class Program
{
    static void Main()
    {

        string inputString = "Manoj# Bhard@waj";
        //  . indicates any character to be removed. You can also write characters as well to remove some selected characters
        string outputString = Regex.Replace(input, ".", " ");

        // Write the output.
        Console.WriteLine(inputString);
        Console.WriteLine(outputString);
    }
}


问:
extracting a variable from the redux store
I need to extract the props from the store in the calculate component and pass the calculation results in the app. I just started using redux.

app.js

```<code>    import React, { Component } from 'react';
    import { connect } from 'react-redux';
    import principalChanged from './src/actions';
    import { Input, Card } from './src/components/common';
    import  { principal2, principal3 } from './src/components/calculate';

      class App extends Component {
        onPrincipalChange(text) {
          this.props.principalChanged(text);
        }
      render() {
        return (
            <Card>
               <Input
                 placeholder="Placeholder"
                 label="Label"
                 onChangeText={this.onPrincipalChange.bind(this)}
                 value={this.props.principal}
                />
              `Current state of the variable: ${this.props.principal}`{/n}
              `New variable: ${principal2}`
              `New variable: ${principal3}`
            </Card>
        );
       }
       }
const mapStateToProps = state => {
   return {
      principal: state.form.principal
   };
};
export default connect(mapStateToProps, {
    principalChanged
})(App);
</code>```

calculate.js

```<code>// call the { principal } variable from the store
// somehow
// maybe I should use mergeProps
export const principal2 = (principal) => {
     return ( { principal * 2 } ); // calculating
};

export const principal3 = () => {
     return ( { principal2 / 4 } ); // calculating
};
</code>```

I don't know how to connect state.principal.props to calculate.js. Maybe I should use mergeProps?

答:
You can't connect Redux (resp. react-redux) store to a function. You have to always connect it to a component via connect. Which you correctly used in App component.

What you're looking for is called a selector, or a selector-like logic. Just call the transform functions in the connect and thus inject the values you need in your component. No need to use mergeProps.

Here is how you may do it, code should be exacutable:

App.js

```<code>import React, { Component } from 'react';
import { connect } from 'react-redux';
import principalChanged from './src/actions';
import { Input, Card } from './src/components/common';
import { principal2 as principal2Selector, principal3 as principal3Selector } from './src/components/calculate';

class App extends Component {

  onPrincipalChange(text) {
    this.props.principalChanged(text);
  }

  render() {
    const { principal, principal2, principal3 } = this.props

    return (
      <Card>
        <Input
          placeholder="Placeholder"
          label="Label"
          onChangeText={this.onPrincipalChange.bind(this)}
          value={principal}
        />
        Current state of the variable: {principal}
        New variable: {principal2}
        New variable: {principal3}
      </Card>
    );
  }
}

const mapStateToProps = state => {
  const principal = state.form.principal

  return {
    principal,
    principal2: principal2Selector(principal),
    principal3: principal3Selector(principal),
  }
};

export default connect(mapStateToProps, {
    principalChanged
})(App);
</code>```

Just mind I renamed your principal2 and principal3 imports, not to confuse the variables with functions/selectors.

```<code>import { principal2 as principal2Selector, principal3 as principal3Selector } from './src/components/calculate';
</code>```

calculate.js

```<code>export const principal2 = (principal) => {
     return (principal * 2); // calculating
};

export const principal3 = (principal) => {
     return (principal2(principal) / 4); // calculating
};
</code>```

Body:
I need to extract the props from the store in the calculate component and pass the calculation results in the app. I just started using redux.

app.js

    import React, { Component } from 'react';
    import { connect } from 'react-redux';
    import principalChanged from './src/actions';
    import { Input, Card } from './src/components/common';
    import  { principal2, principal3 } from './src/components/calculate';

      class App extends Component {
        onPrincipalChange(text) {
          this.props.principalChanged(text);
        }
      render() {
        return (
            <Card>
               <Input
                 placeholder="Placeholder"
                 label="Label"
                 onChangeText={this.onPrincipalChange.bind(this)}
                 value={this.props.principal}
                />
              `Current state of the variable: ${this.props.principal}`{/n}
              `New variable: ${principal2}`
              `New variable: ${principal3}`
            </Card>
        );
       }
       }
const mapStateToProps = state => {
   return {
      principal: state.form.principal
   };
};
export default connect(mapStateToProps, {
    principalChanged
})(App);

calculate.js

// call the { principal } variable from the store
// somehow
// maybe I should use mergeProps
export const principal2 = (principal) => {
     return ( { principal * 2 } ); // calculating
};

export const principal3 = () => {
     return ( { principal2 / 4 } ); // calculating
};

I don't know how to connect state.principal.props to calculate.js. Maybe I should use mergeProps?

Body:
You can't connect Redux (resp. react-redux) store to a function. You have to always connect it to a component via connect. Which you correctly used in App component.

What you're looking for is called a selector, or a selector-like logic. Just call the transform functions in the connect and thus inject the values you need in your component. No need to use mergeProps.

Here is how you may do it, code should be exacutable:

App.js

import React, { Component } from 'react';
import { connect } from 'react-redux';
import principalChanged from './src/actions';
import { Input, Card } from './src/components/common';
import { principal2 as principal2Selector, principal3 as principal3Selector } from './src/components/calculate';

class App extends Component {

  onPrincipalChange(text) {
    this.props.principalChanged(text);
  }

  render() {
    const { principal, principal2, principal3 } = this.props

    return (
      <Card>
        <Input
          placeholder="Placeholder"
          label="Label"
          onChangeText={this.onPrincipalChange.bind(this)}
          value={principal}
        />
        Current state of the variable: {principal}
        New variable: {principal2}
        New variable: {principal3}
      </Card>
    );
  }
}

const mapStateToProps = state => {
  const principal = state.form.principal

  return {
    principal,
    principal2: principal2Selector(principal),
    principal3: principal3Selector(principal),
  }
};

export default connect(mapStateToProps, {
    principalChanged
})(App);

Just mind I renamed your principal2 and principal3 imports, not to confuse the variables with functions/selectors.

import { principal2 as principal2Selector, principal3 as principal3Selector } from './src/components/calculate';

calculate.js

export const principal2 = (principal) => {
     return (principal * 2); // calculating
};

export const principal3 = (principal) => {
     return (principal2(principal) / 4); // calculating
};


问:
Indexing uploaded documents - searchable only by the users that uploaded them
If someone could point me in the right direction that would be most helpful.

I have written a custom CMS where I want to be able to allow each individual user to upload documents (.doc .docx .pdf .rtf .txt etc) and then be able to search the contents of those files for keywords.

The CMS is written entirely in PHP and MySQL within a Linux environment.

Once uploaded the documents would be stored in the users  private folder on the server "as is". There will be hundreds if not thousands of documents stored by each user.

It is very important that the specific users files are searchable only by that user.

Could anyone point me in the right direction? I have had a look at Solr but these types of solutions seem so complicated. I have spent an entire week looking at different solutions and this is my last attempt at finding a solution.

Thank you in advance.

答:
As long as the user's files are all located in an isolated directory, or there is some way specify one user's documents, like adding the user id to the filename, you could use grep.

The disadvantages:

Each search would have to go through all the documents, so if you have a lot of documents or very large documents it would be slow.

Binary document formats, like Word or PDF, might not produce accurate results.

This is not an enterprise solution.

Revised answer: Try mnoGoSearch


问:
Ajax and DefaultController Symfony
I use Symfony 3 and I try to call my function in the Default Controller with Ajax like this:

```<code>$(document).ready(function() {
    $.ajax({
        dataType: "json",
        type: "POST",
        data: {
            action: 'active'
        },
        url: '{{ path ('
        show_chat ')}}',
        success: function(active) {
            if (active === true)
                $('.message-box').fadeIn();
        },
        error: function() {
            console.log('error');
            return false;
        }
    });
});
</code>```

In the Default Controller I want to return a twig template and a variable which is true so my window for the chat can appear:

```<code>return $this->render('ChatBundle:Default:chat.html.twig',$online);
</code>```

I use  $presence = $request->get('active');  Symfony\Component\HttpFoundation\Response;

My method is POST but when I dump $request the method is GET. I do not understand what I am doing wrong and why it doesn't work ... Any ideas, please

Routing:

```<code>show_chat:
path:     /chat
defaults: { _controller: slackChatBundle:Default:chat}
methods: [POST,GET]
</code>```

If I put only POST method ,I have a message "No route found,Method Not Allowed (Allow: POST)

this is the dump of request:

dump request

答: I advice that you use FOSJsRoutingBundle that allows you to expose Symfony Routes to JavaScript</p>

Title: Ajax and DefaultController Symfony

Body:
I use Symfony 3 and I try to call my function in the Default Controller with Ajax like this:

$(document).ready(function() {
    $.ajax({
        dataType: "json",
        type: "POST",
        data: {
            action: 'active'
        },
        url: '{{ path ('
        show_chat ')}}',
        success: function(active) {
            if (active === true)
                $('.message-box').fadeIn();
        },
        error: function() {
            console.log('error');
            return false;
        }
    });
});

In the Default Controller I want to return a twig template and a variable which is true so my window for the chat can appear:

return $this->render('ChatBundle:Default:chat.html.twig',$online);

I use  $presence = $request->get('active');  Symfony\Component\HttpFoundation\Response;

My method is POST but when I dump $request the method is GET. I do not understand what I am doing wrong and why it doesn't work ... Any ideas, please

Routing:

show_chat:
path:     /chat
defaults: { _controller: slackChatBundle:Default:chat}
methods: [POST,GET]

If I put only POST method ,I have a message "No route found,Method Not Allowed (Allow: POST)

this is the dump of request:

dump request


问:
How do I select a node within a template string in html?
Create an element and pass it an innerHTML string.

let mydiv = document.createElement('div');
mydiv.innerHTML = "

Intro

Hello Example

";
console.log(mydiv.getElementByID("greet"))```
</div>
</div>
</p>

<p>.. How do I get the element with id='greet'?</p>

```mydiv.getElementbyID('greet')   //doesn't work.
```

答:
Assuming u have jquery</p>

```<code>$(mydiv).find("#greet");
</code>```

Body:
Create an element and pass it an innerHTML string.

let mydiv = document.createElement('div');
mydiv.innerHTML = "

Intro

Hello Example

";
console.log(mydiv.getElementByID("greet"))

.. How do I get the element with id='greet'?

mydiv.getElementbyID('greet')   //doesn't work.

Body:
Assuming u have jquery

$(mydiv).find("#greet");


问:
How to get the single user profile from UPS using powershell?
I am new to Powershell world. I want to fetch the single user data from the UPS using Powershell instead of looping through each and every user in the UPS.
I followed  this also. Here they are comparing Email with UPS Email and then they are fetching the profile of matched Email in UPS.</p>

```<code>Add-PSSnapin "Microsoft.SharePoint.PowerShell"
$emailAddress = "EMAIL ADDRESS YOU WISH TO QUERY"
$site = Get-SpSite $mySitesURL;
$context = Get-SPServiceContext $site;
$profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)
$allProfiles = $profileManager.GetEnumerator()
foreach ($profile in $allProfiles) {
    if ($profile.GetProfileValueCollection("WorkEmail") -eq $emailAddress) {
        $profile
    }
}
</code>```

答:
I think this is what you are looking for. Try this:

```<code>Add-PSSnapin "Microsoft.SharePoint.PowerShell"
$emailAddress = "EMAIL ADDRESS YOU WISH TO QUERY"
$site = Get-SpSite $mySitesURL;
$context = Get-SPServiceContext $site;
$profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)
$userProfile  = $profileManager.GetEnumerator()| Where-Object {$_["WorkEmail"].value -like $emailAddress}
</code>```

It will fetch only single user data based on the $emailAddress. You don't need to loop through each and every user profile in UPS.

Body:
I am new to Powershell world. I want to fetch the single user data from the UPS using Powershell instead of looping through each and every user in the UPS.
I followed  this also. Here they are comparing Email with UPS Email and then they are fetching the profile of matched Email in UPS.

Add-PSSnapin "Microsoft.SharePoint.PowerShell"
$emailAddress = "EMAIL ADDRESS YOU WISH TO QUERY"
$site = Get-SpSite $mySitesURL;
$context = Get-SPServiceContext $site;
$profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)
$allProfiles = $profileManager.GetEnumerator()
foreach ($profile in $allProfiles) {
    if ($profile.GetProfileValueCollection("WorkEmail") -eq $emailAddress) {
        $profile
    }
}

Body:
I think this is what you are looking for. Try this:

Add-PSSnapin "Microsoft.SharePoint.PowerShell"
$emailAddress = "EMAIL ADDRESS YOU WISH TO QUERY"
$site = Get-SpSite $mySitesURL;
$context = Get-SPServiceContext $site;
$profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)
$userProfile  = $profileManager.GetEnumerator()| Where-Object {$_["WorkEmail"].value -like $emailAddress}

It will fetch only single user data based on the $emailAddress. You don't need to loop through each and every user profile in UPS.


问:
PowerShell script to add first domain user [permissions issue]
I have a SQL Server 2014 VM in Azure, created from the Azure store. I want to add a PowerShell CustomExtension to set up my database environment as soon as the new VM is available. I have an issue with permissions. If I run the PowerShell code below as local admin, I get a message that the Windows NT User or group cannot be found, as that local admin does not have domain admin permissions. If I run the below PowerShell as a domain admin, then that domain admin does not have permission to log on to SQL Server, which is actually the task I am trying to achieve.

```<code>cls
import-module sqlps –DisableNameChecking -Verbose:$false | Out-Null
$sql = "USE [MASTER]
GO
CREATE LOGIN [ABC.PROD\My Group Name] FROM WINDOWS WITH DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english]
GO"
Invoke-Sqlcmd -Query $sql
</code>```

If above run as domain admin I get this error

Invoke-Sqlcmd : Login failed for user 'ABC\myadminusername'.

If above run as local admin I get this error

Invoke-Sqlcmd : Windows NT user or group 'ABC.PROD\My Group Name' not
  found. Check the name again.

Is there an easy way out of this catch 22 using some handy PowerShell? If I do this manually, I would just log on to SQL Server as the local admin, add user, list locations, and supply domain admin credentials when asked. But I cannot see any way to supply those domain admin credentials to this SQL command.

Thank you,
David

答:
OK, I actually found the issue while I was writing this question. Given the question was already written, I figured I would go ahead and post it and give the answer in case this helps someone else.

The problem appears to have been that I should not provide a fully qualified domain name. The below code worked when run as the local admin. I just changed "ABC.PROD\My Group Name" to "ABC\My Group Name", and it worked.

```<code>cls
import-module sqlps –DisableNameChecking -Verbose:$false | Out-Null
$sql = "USE [MASTER]
GO
CREATE LOGIN [ABC\My Group Name] FROM WINDOWS WITH DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english]
GO"
Invoke-Sqlcmd -Query $sql
</code>```

Body:
I have a SQL Server 2014 VM in Azure, created from the Azure store. I want to add a PowerShell CustomExtension to set up my database environment as soon as the new VM is available. I have an issue with permissions. If I run the PowerShell code below as local admin, I get a message that the Windows NT User or group cannot be found, as that local admin does not have domain admin permissions. If I run the below PowerShell as a domain admin, then that domain admin does not have permission to log on to SQL Server, which is actually the task I am trying to achieve.

cls
import-module sqlps –DisableNameChecking -Verbose:$false | Out-Null
$sql = "USE [MASTER]
GO
CREATE LOGIN [ABC.PROD\My Group Name] FROM WINDOWS WITH DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english]
GO"
Invoke-Sqlcmd -Query $sql

If above run as domain admin I get this error

Invoke-Sqlcmd : Login failed for user 'ABC\myadminusername'.

If above run as local admin I get this error

Invoke-Sqlcmd : Windows NT user or group 'ABC.PROD\My Group Name' not
  found. Check the name again.

Is there an easy way out of this catch 22 using some handy PowerShell? If I do this manually, I would just log on to SQL Server as the local admin, add user, list locations, and supply domain admin credentials when asked. But I cannot see any way to supply those domain admin credentials to this SQL command.

Thank you,
David

Body:
OK, I actually found the issue while I was writing this question. Given the question was already written, I figured I would go ahead and post it and give the answer in case this helps someone else.

The problem appears to have been that I should not provide a fully qualified domain name. The below code worked when run as the local admin. I just changed "ABC.PROD\My Group Name" to "ABC\My Group Name", and it worked.

cls
import-module sqlps –DisableNameChecking -Verbose:$false | Out-Null
$sql = "USE [MASTER]
GO
CREATE LOGIN [ABC\My Group Name] FROM WINDOWS WITH DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english]
GO"
Invoke-Sqlcmd -Query $sql


问:
Creating a dynamic chart displaying sequences of activities with their count in R
If you run the R script below, the dataset "patients" is an eventlog of patients visiting a clinic and getting treatment. The trace explorer gets created as in the snapshot below with the tooltip displayed. Now in the "#Script for Frequency Percentage", you get the frequency percentage for each trace in the column "af_percent". My requirement is that, I just want to replace the "label = value" in the ggplot command below with corresponding frequency percentage of each trace. Please help.

```<code>library(splitstackshape)
library(scales)
library(ggplot2)
library(plotly)
tr <- data.frame(traces(patients, output_traces = T, output_cases = F))
tr.df <- cSplit(tr, "trace", ",")
tr.df$af_percent <-
percent(tr.df$absolute_frequency/sum(tr.df$absolute_frequency))
pos <- c(1,4:ncol(tr.df))
tr.df <- tr.df[,..pos]
tr.df <- melt(tr.df, id.vars = c("trace_id","af_percent"))
mp1 = ggplot(data = tr.df, aes(x = variable,y = trace_id, fill = value,
label = value)) +
geom_tile(colour = "white") +
geom_text(colour = "white", fontface = "bold", size = 2) +
scale_fill_discrete(na.value="transparent") +
theme(legend.position="none")
ggplotly(mp1)

#Script for Frequency Percentage
tr = traces(patients, output_traces = T,output_cases = F)
tr$af_percent = percent(te$absolute_frequency/sum(te$absolute_frequency))
</code>```

答:
```<code>library(bupaR)
library(plotly)

traces(patients, output_traces = T, output_cases = F)

p <- trace_explorer(patients,type = "frequent", coverage = 1) +
theme(axis.text.x=element_blank(),
      axis.ticks.x=element_blank(),
      axis.text.y=element_blank(),
      axis.ticks.y=element_blank())

gg <- ggplotly(p)

# Now manipulate the plotly object in the same way that
# we would manipulate any other plotly object
# See https://plotly-book.cpsievert.me/extending-ggplotly.html
layout(gg, margin=list(l=50, b=50), legend=list(x=1.05))
</code>```

Body:
If you run the R script below, the dataset "patients" is an eventlog of patients visiting a clinic and getting treatment. The trace explorer gets created as in the snapshot below with the tooltip displayed. Now in the "#Script for Frequency Percentage", you get the frequency percentage for each trace in the column "af_percent". My requirement is that, I just want to replace the "label = value" in the ggplot command below with corresponding frequency percentage of each trace. Please help.

library(splitstackshape)
library(scales)
library(ggplot2)
library(plotly)
tr <- data.frame(traces(patients, output_traces = T, output_cases = F))
tr.df <- cSplit(tr, "trace", ",")
tr.df$af_percent <-
percent(tr.df$absolute_frequency/sum(tr.df$absolute_frequency))
pos <- c(1,4:ncol(tr.df))
tr.df <- tr.df[,..pos]
tr.df <- melt(tr.df, id.vars = c("trace_id","af_percent"))
mp1 = ggplot(data = tr.df, aes(x = variable,y = trace_id, fill = value,
label = value)) +
geom_tile(colour = "white") +
geom_text(colour = "white", fontface = "bold", size = 2) +
scale_fill_discrete(na.value="transparent") +
theme(legend.position="none")
ggplotly(mp1)

#Script for Frequency Percentage
tr = traces(patients, output_traces = T,output_cases = F)
tr$af_percent = percent(te$absolute_frequency/sum(te$absolute_frequency))


问:
Migrating from SVN to TFS 2017
Recently we did POC to work java code with TFS by add on tool,now we are planing to migrate java code to TFS 2017.
is any way without third party tool we can migrate SVN to TFS 2017.</p>

答:
Seems you  need to migrate a SVN repository to TFS. If you mean you want to directly use some official SVN or TFS tool to do the migration. I'm afraid there is no such thing for now. You need to use some  other tools. There are two types of version control in TFS: TFVC and GIT.

For GIT, there are plenty of free tools such as git-svn tool and subgit that will help in migrating Subversion to a Git repository. Once you've created the Git repository locally you can then push it to remote GIT repo hosted by TFS.

For TFVC, one simple option would be to first migrate SVN to GIT, and go from GIT to TFVC using either git-tfs or git-tf.

For detail ways how to do this you could refer below tutorials:

Migrate Visual Studio Solution from SVN to TFS

Migrate an SVN repository to TFS

Besides you could also directly build the source code in SVN repro through TFS build system.

Title: Migrating from SVN to TFS 2017


问:
Keras deep learning model to android
I'm developing a real-time object classification app for android. First I created a deep learning model using "keras" and I already have trained model saved as "model.h5" file. I would like to know how can I use that model in android for image classification.  </p>

答:
You cant export Keras directly to Android but you have to save the model

Configure Tensorflow as your Keras backend.

Save model wights using model.save(filepath) (you already done this)

Then load it with one of the following solutions:

Solution 1: Import model in Tensflow

1- Build Tensorflow model

Build tensorflow model from keras model use this code (link updated)

2- Build Android app and call Tensorflow. check this tutorial and this official demo from google to learn how to do it.

Solution 2: Import model in java

1- deeplearning4j a java library allow to import keras model: tutorial link

2- Use deeplearning4j in Android: it is easy since you are in java world. check this tutorial

Title: Keras deep learning model to android


问:
How to find the MLE of a uniform distribution?
I am trying to find the maximum likelihood estimators a_hat and b_hat for a given uniform distribution X ~ UNIF(1,3) using R. Below is my code and its output:

```<code>##Example: Uniform Distribution
x<-runif(100,1,3)
n<-length(x)
ll<-function(a,b){

  -sum(1/(b-a)^n,log=TRUE)

}
m0<-mle2(ll,start=list(a=1,b=2))
summary(m0)

> summary(m0)
</code>```

Maximum likelihood estimation

```<code>Call:
mle2(minuslogl = ll, start = list(a = 1, b = 2))

Coefficients:
Estimate Std. Error z value Pr(z)
a   1.5159         NA      NA    NA
b   1.4841         NA      NA    NA

-2 log L: -1.542595e+150
Warning message:
In sqrt(diag(object@vcov)) : NaNs produced
</code>```

I am not able to reason why my coefficients are so off from the original values. I am pretty much sure I am using the correct likelihood function for uniform distribution, but I may be wrong for it as well syntax somewhere. I am using library(bbmle)

答:
The negative log-likelihood is -n*log(1/(b-a))=n*log(b-a) if a<min(x) and b>max(x). If these constraints are not satisfied then the likelihood is 0.

You can specifiy the constraints with method = "L-BFGS-B":

```<code>library(bbmle)
x <- runif(100,1,3)
n <- length(x)
ll <- function(a,b){
  n*log(b-a)
}

m0 <- mle2(ll, start=list(a=0, b=4),
           lower=c(a=-Inf, b=max(x)), upper=c(a=min(x), b=Inf),
           method="L-BFGS-B")
</code>```

You get:

```<code>Warning message:
In mle2(ll, start = list(a = 0, b = 4), lower = c(a = -Inf, b = max(x)),  :
  some parameters are on the boundary: variance-covariance calculations based on Hessian may be unreliable

> m0

Coefficients:
       a        b
1.003692 2.956433

Log-likelihood: -66.92
</code>```

The results are correct. The maximum likelihood estimates of a and b respectively are min(x) and max(x).

```<code>> min(x)
[1] 1.003692
> max(x)
[1] 2.956433
</code>```

Body:
I am trying to find the maximum likelihood estimators a_hat and b_hat for a given uniform distribution X ~ UNIF(1,3) using R. Below is my code and its output:

##Example: Uniform Distribution
x<-runif(100,1,3)
n<-length(x)
ll<-function(a,b){

  -sum(1/(b-a)^n,log=TRUE)

}
m0<-mle2(ll,start=list(a=1,b=2))
summary(m0)

> summary(m0)

Maximum likelihood estimation

Call:
mle2(minuslogl = ll, start = list(a = 1, b = 2))

Coefficients:
Estimate Std. Error z value Pr(z)
a   1.5159         NA      NA    NA
b   1.4841         NA      NA    NA

-2 log L: -1.542595e+150
Warning message:
In sqrt(diag(object@vcov)) : NaNs produced

I am not able to reason why my coefficients are so off from the original values. I am pretty much sure I am using the correct likelihood function for uniform distribution, but I may be wrong for it as well syntax somewhere. I am using library(bbmle)

Body:
The negative log-likelihood is -n*log(1/(b-a))=n*log(b-a) if a<min(x) and b>max(x). If these constraints are not satisfied then the likelihood is 0.

You can specifiy the constraints with method = "L-BFGS-B":

library(bbmle)
x <- runif(100,1,3)
n <- length(x)
ll <- function(a,b){
  n*log(b-a)
}

m0 <- mle2(ll, start=list(a=0, b=4),
           lower=c(a=-Inf, b=max(x)), upper=c(a=min(x), b=Inf),
           method="L-BFGS-B")

You get:

Warning message:
In mle2(ll, start = list(a = 0, b = 4), lower = c(a = -Inf, b = max(x)),  :
  some parameters are on the boundary: variance-covariance calculations based on Hessian may be unreliable

> m0

Coefficients:
       a        b
1.003692 2.956433

Log-likelihood: -66.92

The results are correct. The maximum likelihood estimates of a and b respectively are min(x) and max(x).

> min(x)
[1] 1.003692
> max(x)
[1] 2.956433


问:
PHP setlocale does not work for Korean language
I am currently using date function to print out today's date. While doing this, I realized that the setlocale function does not work for Korean unfortunately so I am now wondering is there any way to directly translate from English to Korean through one to one mapping.

so currently I have

```<code>setlocale(LC_CTYPE, 'ko_KR,eucKR');
$today = date("Y년 m월 d일 l", strtotime('today'));
</code>```

This prints 2014년 9월 12일 Monday and I would like to change Monday to 월.

So instead of relying on setlocale I want to know if it is possible to directly change this like:

```<code>Monday => 월 etc.
</code>```

答:
date('w') returns a number representing each day of the week from 0 (Sunday) to 6 (Saturday).

You can create an array:

```<code><?php
$kor_day = array( '일', '월', '화', '수', '목', '금', '토' );
echo $kor_day[date('w')];
?>
</code>```

It will output the day of the week in Korean.

Body:
I am currently using date function to print out today's date. While doing this, I realized that the setlocale function does not work for Korean unfortunately so I am now wondering is there any way to directly translate from English to Korean through one to one mapping.

so currently I have

setlocale(LC_CTYPE, 'ko_KR,eucKR');
$today = date("Y년 m월 d일 l", strtotime('today'));

This prints 2014년 9월 12일 Monday and I would like to change Monday to 월.

So instead of relying on setlocale I want to know if it is possible to directly change this like:

Monday => 월 etc.

Body:
date('w') returns a number representing each day of the week from 0 (Sunday) to 6 (Saturday).

You can create an array:

<?php
$kor_day = array( '일', '월', '화', '수', '목', '금', '토' );
echo $kor_day[date('w')];
?>

It will output the day of the week in Korean.


问:
Run large sql script
I have just reloaded my laptop and am now trying to setup my localhost again.

Currently I am trying to re-setup the database.

the issue is,

The script is 169,328 KB.

This keeps crashing whatever I use to run the query and I get the error: The mysql Server has gone away.

Seems everyone is suggesting splitting the script. Instead as this is only me setting my localhost back up, I have temporarily increased the max_packet_size.

答:
This would explain the error.

Perhaps you should open the script and see if you can chunk it into smaller, more manageable pieces.

I don't know what you're doing about transactions, but perhaps the rollback segment (or its MySQL equivalent) is getting too large.  If that's the case, break the script into several transactions that you can safely commit individually.

Title: Run large sql script


问:
contour approximation in opencv python is giving wrong result everytime
I am an absolute beginner in image processing.I want to detect a nested shape among various different edges.from my program I have successfully detected my expected contour through hierarchy relation.but my problem arises when I am going to detect the shape.for contour approximation, I am using cv2.approxpolyDP() method/function on my desired contour using its index number.but every time it is resulting in the same output, which is "1".I don't know where I am mistaking.please have a look and suggest me some.The code is given below and the images to be detected is also given in those links. please help me...

```<code>import cv2
import numpy as np
maxx=0
original_color=cv2.imread("tri.jpg",1)
original=cv2.cvtColor(original_color,cv2.COLOR_BGR2GRAY)
#cv2.imshow("original",original)
blur=cv2.GaussianBlur(original,(5,5),0)
ret,thresh=cv2.threshold(blur,50,255,cv2.THRESH_BINARY)
edges = cv2.Canny(thresh,100,200)
image,contours,hierarchy=cv2.findContours(edges.copy(),cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
print len(contours)
##for c in range(0,len(hierarchy)) :
##    a=zip(hierarchy[c],contours[c])

for i in range(0,len(hierarchy[0])):
    if hierarchy[0][i][2]>=maxx :
         if(hierarchy[0][i][3]==(hierarchy[0][i][2]-2)):
             maxx=hierarchy[0][i][2]
             index=i
cnt=contours[index]
for c in cnt :
    peri=cv2.arcLength(c,True)
    approx=cv2.approxPolyDP(c,0.04*peri,True)
print hierarchy
print maxx
print len(approx)

cv2.drawContours(original_color,contours,index,(0,255,0),3)
cv2.imshow("Show",original_color)
cv2.waitKey()
cv2.destroyAllWindows()
</code>```

Before Detection

Succesfully Detected

答:
The result of findContours is a list of list of points, this means that the problem is here:

```<code>cnt=contours[index]
for c in cnt :
    peri=cv2.arcLength(c,True)
    approx=cv2.approxPolyDP(c,0.04*peri,True)
</code>```

Here you select a contour(list of pointS) and then loop for each point and do the approxPolyDP with only 1 point. You should do it to the contour. So, if you want it to do it for the selected contour, you should do:

```<code>cnt=contours[index]
peri=cv2.arcLength(cnt,True)
approx=cv2.approxPolyDP(cnt,0.04*peri,True)
</code>```

If you want to do it for each contour then do like this (keeping the print inside the loop, if not it will show only the last one):

```<code>for c in contours:
    peri=cv2.arcLength(c,True)
    approx=cv2.approxPolyDP(c,0.04*peri,True)
    print len(approx)
</code>```

Body:
I am an absolute beginner in image processing.I want to detect a nested shape among various different edges.from my program I have successfully detected my expected contour through hierarchy relation.but my problem arises when I am going to detect the shape.for contour approximation, I am using cv2.approxpolyDP() method/function on my desired contour using its index number.but every time it is resulting in the same output, which is "1".I don't know where I am mistaking.please have a look and suggest me some.The code is given below and the images to be detected is also given in those links. please help me...

import cv2
import numpy as np
maxx=0
original_color=cv2.imread("tri.jpg",1)
original=cv2.cvtColor(original_color,cv2.COLOR_BGR2GRAY)
#cv2.imshow("original",original)
blur=cv2.GaussianBlur(original,(5,5),0)
ret,thresh=cv2.threshold(blur,50,255,cv2.THRESH_BINARY)
edges = cv2.Canny(thresh,100,200)
image,contours,hierarchy=cv2.findContours(edges.copy(),cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
print len(contours)
##for c in range(0,len(hierarchy)) :
##    a=zip(hierarchy[c],contours[c])

for i in range(0,len(hierarchy[0])):
    if hierarchy[0][i][2]>=maxx :
         if(hierarchy[0][i][3]==(hierarchy[0][i][2]-2)):
             maxx=hierarchy[0][i][2]
             index=i
cnt=contours[index]
for c in cnt :
    peri=cv2.arcLength(c,True)
    approx=cv2.approxPolyDP(c,0.04*peri,True)
print hierarchy
print maxx
print len(approx)

cv2.drawContours(original_color,contours,index,(0,255,0),3)
cv2.imshow("Show",original_color)
cv2.waitKey()
cv2.destroyAllWindows()

Before Detection

Succesfully Detected

Body:
The result of findContours is a list of list of points, this means that the problem is here:

cnt=contours[index]
for c in cnt :
    peri=cv2.arcLength(c,True)
    approx=cv2.approxPolyDP(c,0.04*peri,True)

Here you select a contour(list of pointS) and then loop for each point and do the approxPolyDP with only 1 point. You should do it to the contour. So, if you want it to do it for the selected contour, you should do:

cnt=contours[index]
peri=cv2.arcLength(cnt,True)
approx=cv2.approxPolyDP(cnt,0.04*peri,True)

If you want to do it for each contour then do like this (keeping the print inside the loop, if not it will show only the last one):

for c in contours:
    peri=cv2.arcLength(c,True)
    approx=cv2.approxPolyDP(c,0.04*peri,True)
    print len(approx)