问:
JSONexception while fetching JSONArray JSONObject
Getting JSON Exception while fetching json response from server.I have tried many solutions given on stackoverflow but thats not working.Below is my code for sending parameters to the sever and fetching json.Please help me guys.Any help will be appreciated.
Thanks

JSON Response from server:

Note:"upload" is an JSONarray .

```<code>  {
        "code": 200,
        "upload": {
        "Booking": {
        "id": "17",
        "contributor_id": "16",
        "table_of_content_id": "1",
        "composition_id": "12",
        "completion": "2017-05-20",
        "approved": null,
        "cdn_id": null,
        "secret_token": null,
        "uploaded_on": null,
        "created": "2017-05-09 14:41:49",
        "modified": "2017-05-09 14:41:49"
        },
        "TableOfContent": {
        "id": "1",
        "name": "গোরা",
        "category_id": "1",
        "language_id": "1",
        "created": "2016-03-09 03:39:01",
        "modified": "2016-03-09 14:39:01"
        }
        }
        }
</code>```

This is how i am trying to do it.

```<code>public void forwardtoOurServer() {
        JSONObject jsonObject=null;
        String tag_string_req = "req_login";
        StringRequest postStringRequest = new StringRequest(Request.Method.POST, RECORD_COMPOSITION_API,
                new Response.Listener<String>() {

                    @Override
                    public void onResponse(String response) {
                        Log.d(TAG, "Audio Upload Response Check :" + response);

                        try {
                            JSONObject json = new JSONObject(response);
                            String code = json.getString("code");
                            JSONArray obj = json.getJSONArray("upload");
                            Log.d(TAG, "obj Response Check :" + obj);
                            for (int i = 0; i < obj.length(); i++) {

                                JSONObject jsonObject = obj.getJSONObject(i);
                                Log.d(TAG, "jsonObject Response Check :" + jsonObject);
                                JSONObject bookings = obj.getJSONObject(Integer.parseInt("Booking"));

//                                int id = jsonObject.getInt("id");
//
//                                String type = jsonObject.getString("type");

                                // retrieve the values like this so on..

                            }

                        } catch (JSONException e) {
                            e.printStackTrace();
                        }

                    }
                },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        Log.e(TAG, "Error Response Check :" + error);

                    }
                }) {

            @RequiresApi(api = Build.VERSION_CODES.N)
            @Override
            protected Map<String, String> getParams() {
                Map<String, String> params = new HashMap<String, String>();
                params.put("data[Booking][id]",bookingId);
                params.put("data[Booking][contributor_id]",contributor_id);
                params.put("data[Booking][table_of_content_id]",tocId);
                params.put("data[Booking][cdn_id]",vs_cdn_id);
                params.put("data[Booking][secret_token]",secret_token);
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
                sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
                Date now = new Date();
                String strDate = sdf.format(now);
                params.put("data[Booking][uploaded_on]",strDate);
                Log.d(TAG, "Params :" + params);
                return params;

            }

            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                Map<String, String> headers = new HashMap<String, String>();
                headers.put("Content-Type", "application/x-www-form-urlencoded");
                headers.put("UUID", device_uuid);
                headers.put("APPID", "2A192A0C22");
                headers.put("USERID", "1");
                headers.put("PLATFORM", "Andriod");
                headers.put("APP_REQUEST", "1");
                headers.put("PLATFORMVERSION",androidOS);
                return headers;
            }

        };

        AppController.getInstance().addToRequestQueue(postStringRequest, tag_string_req);

    }
</code>```

Log:

```<code>06-07 12:44:18.865 13701-13903/com.showhow2.www.thetagoreproject D/Null: Params :{data[Booking][cdn_id]=326929293, data[Booking][table_of_content_id]=1, data[Booking][id]=16, data[Booking][secret_token]=s-0DT7x, data[Booking][contributor_id]=16, data[Booking][uploaded_on]=2017-06-07T07:14:18Z}
06-07 12:44:20.629 13701-13701/com.showhow2.www.thetagoreproject D/Null: Audio Upload Response Check :{"code":200,"upload":{"Booking":{"id":"17","contributor_id":"16","table_of_content_id":"1","composition_id":"12","completion":"2017-05-20","approved":null,"cdn_id":null,"secret_token":null,"uploaded_on":null,"created":"2017-05-09 14:41:49","modified":"2017-05-09 14:41:49"},"TableOfContent":{"id":"1","name":"\u0997\u09cb\u09b0\u09be","category_id":"1","language_id":"1","created":"2016-03-09 03:39:01","modified":"2016-03-09 14:39:01"},"Composition":{"id":"12","content":"\u09ac\u09bf\u09a8\u09df \u0993 \u0997\u09cb\u09b0\u09be \u09aa\u09b0\u09c7\u09b6\u09c7\u09b0 \u09ac\u09be\u09dc\u09bf \u09b9\u0987\u09a4\u09c7 \u09b0\u09be\u09b8\u09cd\u09a4\u09be\u09df \u09ac\u09be\u09b9\u09bf\u09b0 \u09b9\u0987\u09b2\u09c7 \u09ac\u09bf\u09a8\u09df \u0995\u09b9\u09bf\u09b2, "\u0997\u09cb\u09b0\u09be, \u098f\u0995\u099f\u09c1 \u0986\u09b8\u09cd\u09a4\u09c7 \u0986\u09b8\u09cd\u09a4\u09c7 \u099a\u09b2\u09cb \u09ad\u09be\u0987-- \u09a4\u09cb\u09ae\u09be\u09b0 \u09aa\u09be \u09a6\u09c1\u099f\u09cb \u0986\u09ae\u09be\u09a6\u09c7\u09b0 \u099a\u09c7\u09df\u09c7 \u0985\u09a8\u09c7\u0995 \u09ac\u09dc\u09cb-- \u0993\u09b0 \u099a\u09be\u09b2\u099f\u09be \u098f\u0995\u099f\u09c1 \u0996\u09be\u099f\u09cb \u09a8\u09be \u0995\u09b0\u09b2\u09c7 \u09a4\u09cb\u09ae\u09be\u09b0 \u09b8\u0999\u09cd\u0997\u09c7 \u09af\u09c7\u09a4\u09c7 \u0986\u09ae\u09b0\u09be \u09b9\u09be\u0981\u09aa\u09bf\u09df\u09c7 \u09aa\u09dc\u09bf\u0964"\n \u0997\u09cb\u09b0\u09be \u0995\u09b9\u09bf\u09b2, "\u0986\u09ae\u09bf \u098f\u0995\u09b2\u09be\u0987 \u09af\u09c7\u09a4\u09c7 \u099a\u09be\u0987, \u0986\u09ae\u09be\u09b0 \u0986\u099c \u0985\u09a8\u09c7\u0995 \u0995\u09a5\u09be \u09ad\u09be\u09ac\u09ac\u09be\u09b0 \u0986\u099b\u09c7\u0964"\n \u09ac\u09b2\u09bf\u09df\u09be \u09a4\u09be\u09b9\u09be\u09b0 \u09b8\u09cd\u09ac\u09be\u09ad\u09be\u09ac\u09bf\u0995 \u09a6\u09cd\u09b0\u09c1\u09a4\u0997\u09a4\u09bf\u09a4\u09c7 \u09b8\u09c7 \u09ac\u09c7\u0997\u09c7 \u099a\u09b2\u09bf\u09df\u09be \u0997\u09c7\u09b2\u0964\n \u09ac\u09bf\u09a8\u09df\u09c7\u09b0 \u09ae\u09a8\u09c7 \u0986\u0998\u09be\u09a4 \u09b2\u09be\u0997\u09bf\u09b2\u0964 \u09b8\u09c7 \u0986\u099c \u0997\u09cb\u09b0\u09be\u09b0 \u09ac\u09bf\u09b0\u09c1\u09a6\u09cd\u09a7\u09c7 \u09ac\u09bf\u09a6\u09cd\u09b0\u09cb\u09b9 \u0995\u09b0\u09bf\u09df\u09be \u09a4\u09be\u09b9\u09be\u09b0 \u09a8\u09bf\u09df\u09ae \u09ad\u0999\u09cd\u0997 \u0995\u09b0\u09bf\u09df\u09be\u099b\u09c7\u0964 \u09b8\u09c7 \u09b8\u09ae\u09cd\u09ac\u09a8\u09cd\u09a7\u09c7 \u0997\u09cb\u09b0\u09be\u09b0 \u0995\u09be\u099b\u09c7 \u09a4\u09bf\u09b0\u09b8\u09cd\u0995\u09be\u09b0 \u09ad\u09cb\u0997 \u0995\u09b0\u09bf\u09b2\u09c7 \u09b8\u09c7 \u0996\u09c1\u09b6\u09bf \u09b9\u0987\u09a4\u0964 \u098f\u0995\u099f\u09be \u099d\u09dc \u09b9\u0987\u09df\u09be \u0997\u09c7\u09b2\u09c7\u0987 \u09a4\u09be\u09b9\u09be\u09a6\u09c7\u09b0 \u099a\u09bf\u09b0\u09a6\u09bf\u09a8\u09c7\u09b0 \u09ac\u09a8\u09cd\u09a7\u09c1\u09a4\u09cd\u09ac\u09c7\u09b0 \u0986\u0995\u09be\u09b6 \u09b9\u0987\u09a4\u09c7 \u0997\u09c1\u09ae\u099f \u0995\u09be\u099f\u09bf\u09df\u09be \u09af\u09be\u0987\u09a4 \u098f\u09ac\u0982 \u09b8\u09c7 \u09b9\u09be\u0981\u09aa \u099b\u09be\u09dc\u09bf\u09df\u09be \u09ac\u09be\u0981\u099a\u09bf\u09a4\u0964\n \u09a4\u09be\u09b9\u09be \u099b\u09be\u09dc\u09be \u0986\u09b0-\u098f\u0995\u099f\u09be \u0995\u09a5\u09be \u09a4\u09be\u09b9\u09be\u0995\u09c7 \u09aa\u09c0\u09dc\u09be \u09a6\u09bf\u09a4\u09c7\u099b\u09bf\u09b2\u0964 \u0986\u099c \u09b9\u09a0\u09be\u09ce \u0997\u09cb\u09b0\u09be \u09aa\u09b0\u09c7\u09b6\u09c7\u09b0 \u09ac\u09be\u09dc\u09bf\u09a4\u09c7 \u09aa\u09cd\u09b0\u09a5\u09ae \u0986\u09b8\u09bf\u09df\u09be\u0987 \u09ac\u09bf\u09a8\u09df\u0995\u09c7 \u09b8\u09c7\u0996\u09be\u09a8\u09c7 \u09ac\u09a8\u09cd\u09a7\u09c1\u09ad\u09be\u09ac\u09c7 \u09ac\u09b8\u09bf\u09df\u09be \u09a5\u09be\u0995\u09bf\u09a4\u09c7 \u09a6\u09c7\u0996\u09bf\u09df\u09be \u09a8\u09bf\u09b6\u09cd\u099a\u09df\u0987 \u09ae\u09a8\u09c7 \u0995\u09b0\u09bf\u09df\u09be\u099b\u09c7 \u09ac\u09bf\u09a8\u09df \u098f \u09ac\u09be\u
06-07 12:44:20.663 13701-13701/com.showhow2.www.thetagoreproject W/System.err: org.json.JSONException: Value {"Booking":{"id":"17","contributor_id":"16","table_of_content_id":"1","composition_id":"12","completion":"2017-05-20","approved":null,"cdn_id":null,"secret_token":null,"uploaded_on":null,"created":"2017-05-09 14:41:49","modified":"2017-05-09 14:41:49"},"TableOfContent":{"id":"1","name":"গোরা","category_id":"1","language_id":"1","created":"2016-03-09 03:39:01","modified":"2016-03-09 14:39:01"},"Composition":{"id":"12","content":"বিনয় ও গোরা পরেশের বাড়ি হইতে রাস্তায় বাহির হইলে বিনয় কহিল, "গোরা, একটু আস্তে আস্তে চলো ভাই-- তোমার পা দুটো আমাদের চেয়ে অনেক বড়ো-- ওর চালটা একটু খাটো না করলে তোমার সঙ্গে যেতে আমরা হাঁপিয়ে পড়ি।"\n গোরা কহিল, "আমি একলাই যেতে চাই, আমার আজ অনেক কথা ভাববার আছে।"\n বলিয়া তাহার স্বাভাবিক দ্রুতগতিতে সে বেগে চলিয়া গেল।\n বিনয়ের মনে আঘাত লাগিল। সে আজ গোরার বিরুদ্ধে বিদ্রোহ করিয়া তাহার নিয়ম ভঙ্গ করিয়াছে। সে সম্বন্ধে গোরার কাছে তিরস্কার ভোগ করিলে সে খুশি হইত। একটা ঝড় হইয়া গেলেই তাহাদের চিরদিনের বন্ধুত্বের আকাশ হইতে গুমট কাটিয়া যাইত এবং সে হাঁপ ছাড়িয়া বাঁচিত।\n তাহা ছাড়া আর-একটা কথা তাহাকে পীড়া দিতেছিল। আজ হঠাৎ গোরা পরেশের বাড়িতে প্রথম আসিয়াই বিনয়কে সেখানে বন্ধুভাবে বসিয়া থাকিতে দেখিয়া নিশ্চয়ই মনে করিয়াছে বিনয় এ বাড়িতে সর্বদাই যাতায়াত করে। অবশ্য, যাতায়াত করিলে যে কোনো অপরাধ আছে তাহা নয়; গোরা যাহাই বলুক পরেশবাবুর সুশিক্ষিত পরিবারের সঙ্গে অন্তরঙ্গভাবে পরিচিত হইবার সুযোগ পাওয়া বিনয় একটা বিশেষ লাভ বলিয়া গণ্য করিতেছে; ইঁহাদের সঙ্গে মেশামেশি করাতে গোরা যদি কোনো দোষ দেখে তবে সেটা তাহার নিতান্ত গোঁড়ামি; কিন্তু পূর্বের কথাবার্তায় গোরা নাকি জানিয়াছে যে বিনয় পরেশবাবুর বাড়িতে যাওয়া-আসা করে না, আজ সহসা তাহার মনে হইতে পারে যে সে কথাটা সত্য নয়। বিশেষত বরদাসুন্দরী তাহাকে বিশেষ করিয়া ঘরে ডাকিয়া লইয়া গেলেন, সেখানে তাঁহার মেয়েদের সঙ্গে তাহার আলাপ হইতে লাগিল-- গোরার তীক্ষ্ণ লক্ষ হইতে ইহা এড়াইয়া যায় নাই। মেয়েদের সঙ্গে এইরূপ মেলামেশায় ও বরদাসুন্দরীর আত্মীয়তায় মনে মনে বিনয় ভার�
06-07 12:44:20.663 13701-13701/com.showhow2.www.thetagoreproject W/System.err:     at org.json.JSON.typeMismatch(JSON.java:100)
06-07 12:44:20.663 13701-13701/com.showhow2.www.thetagoreproject W/System.err:     at org.json.JSONObject.getJSONArray(JSONObject.java:588)
06-07 12:44:20.663 13701-13701/com.showhow2.www.thetagoreproject W/System.err:     at com.showhow2.www.thetagoreproject.RecordComposition$16.onResponse(RecordComposition.java:704)
06-07 12:44:20.663 13701-13701/com.showhow2.www.thetagoreproject W/System.err:     at com.showhow2.www.thetagoreproject.RecordComposition$16.onResponse(RecordComposition.java:694)
06-07 12:44:20.663 13701-13701/com.showhow2.www.thetagoreproject W/System.err:     at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:60)
06-07 12:44:20.663 13701-13701/com.showhow2.www.thetagoreproject W/System.err:     at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:30)
06-07 12:44:20.663 13701-13701/com.showhow2.www.thetagoreproject W/System.err:     at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:99)
06-07 12:44:20.663 13701-13701/com.showhow2.www.thetagoreproject W/System.err:     at android.os.Handler.handleCallback(Handler.java:739)
06-07 12:44:20.663 13701-13701/com.showhow2.www.thetagoreproject W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:95)
06-07 12:44:20.663 13701-13701/com.showhow2.www.thetagoreproject W/System.err:     at android.os.Looper.loop(Looper.java:148)
06-07 12:44:20.663 13701-13701/com.showhow2.www.thetagoreproject W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:5417)
06-07 12:44:20.663 13701-13701/com.showhow2.www.thetagoreproject W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
06-07 12:44:20.664 13701-13701/com.showhow2.www.thetagoreproject W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
06-07 12:44:20.664 13701-13701/com.showhow2.www.thetagoreproject W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
</code>```

答:
Try this code</p>

```<code>try {
                        JSONObject json = new JSONObject(response);
                        String code = json.getString("code");
                        JSONObject obj = json.getJSONObject("upload");
                        JSONObject objbooking = obj.getJSONObject("Booking");
                        JSONObject objtable = obj.getJSONObject("TableOfContent");

                       //you can get values like below

                       String idbooking = objbooking.getString("id");
                       String idtable = objtable.getString("id");

                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
</code>```

Body:
Getting JSON Exception while fetching json response from server.I have tried many solutions given on stackoverflow but thats not working.Below is my code for sending parameters to the sever and fetching json.Please help me guys.Any help will be appreciated.
Thanks

JSON Response from server:

Note:"upload" is an JSONarray .

  {
        "code": 200,
        "upload": {
        "Booking": {
        "id": "17",
        "contributor_id": "16",
        "table_of_content_id": "1",
        "composition_id": "12",
        "completion": "2017-05-20",
        "approved": null,
        "cdn_id": null,
        "secret_token": null,
        "uploaded_on": null,
        "created": "2017-05-09 14:41:49",
        "modified": "2017-05-09 14:41:49"
        },
        "TableOfContent": {
        "id": "1",
        "name": "গোরা",
        "category_id": "1",
        "language_id": "1",
        "created": "2016-03-09 03:39:01",
        "modified": "2016-03-09 14:39:01"
        }
        }
        }

This is how i am trying to do it.

public void forwardtoOurServer() {
        JSONObject jsonObject=null;
        String tag_string_req = "req_login";
        StringRequest postStringRequest = new StringRequest(Request.Method.POST, RECORD_COMPOSITION_API,
                new Response.Listener<String>() {

                    @Override
                    public void onResponse(String response) {
                        Log.d(TAG, "Audio Upload Response Check :" + response);

                        try {
                            JSONObject json = new JSONObject(response);
                            String code = json.getString("code");
                            JSONArray obj = json.getJSONArray("upload");
                            Log.d(TAG, "obj Response Check :" + obj);
                            for (int i = 0; i < obj.length(); i++) {

                                JSONObject jsonObject = obj.getJSONObject(i);
                                Log.d(TAG, "jsonObject Response Check :" + jsonObject);
                                JSONObject bookings = obj.getJSONObject(Integer.parseInt("Booking"));

//                                int id = jsonObject.getInt("id");
//
//                                String type = jsonObject.getString("type");

                                // retrieve the values like this so on..

                            }

                        } catch (JSONException e) {
                            e.printStackTrace();
                        }

                    }
                },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        Log.e(TAG, "Error Response Check :" + error);

                    }
                }) {

            @RequiresApi(api = Build.VERSION_CODES.N)
            @Override
            protected Map<String, String> getParams() {
                Map<String, String> params = new HashMap<String, String>();
                params.put("data[Booking][id]",bookingId);
                params.put("data[Booking][contributor_id]",contributor_id);
                params.put("data[Booking][table_of_content_id]",tocId);
                params.put("data[Booking][cdn_id]",vs_cdn_id);
                params.put("data[Booking][secret_token]",secret_token);
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
                sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
                Date now = new Date();
                String strDate = sdf.format(now);
                params.put("data[Booking][uploaded_on]",strDate);
                Log.d(TAG, "Params :" + params);
                return params;

            }

            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                Map<String, String> headers = new HashMap<String, String>();
                headers.put("Content-Type", "application/x-www-form-urlencoded");
                headers.put("UUID", device_uuid);
                headers.put("APPID", "2A192A0C22");
                headers.put("USERID", "1");
                headers.put("PLATFORM", "Andriod");
                headers.put("APP_REQUEST", "1");
                headers.put("PLATFORMVERSION",androidOS);
                return headers;
            }

        };

        AppController.getInstance().addToRequestQueue(postStringRequest, tag_string_req);

    }

Log:

06-07 12:44:18.865 13701-13903/com.showhow2.www.thetagoreproject D/Null: Params :{data[Booking][cdn_id]=326929293, data[Booking][table_of_content_id]=1, data[Booking][id]=16, data[Booking][secret_token]=s-0DT7x, data[Booking][contributor_id]=16, data[Booking][uploaded_on]=2017-06-07T07:14:18Z}
06-07 12:44:20.629 13701-13701/com.showhow2.www.thetagoreproject D/Null: Audio Upload Response Check :{"code":200,"upload":{"Booking":{"id":"17","contributor_id":"16","table_of_content_id":"1","composition_id":"12","completion":"2017-05-20","approved":null,"cdn_id":null,"secret_token":null,"uploaded_on":null,"created":"2017-05-09 14:41:49","modified":"2017-05-09 14:41:49"},"TableOfContent":{"id":"1","name":"\u0997\u09cb\u09b0\u09be","category_id":"1","language_id":"1","created":"2016-03-09 03:39:01","modified":"2016-03-09 14:39:01"},"Composition":{"id":"12","content":"\u09ac\u09bf\u09a8\u09df \u0993 \u0997\u09cb\u09b0\u09be \u09aa\u09b0\u09c7\u09b6\u09c7\u09b0 \u09ac\u09be\u09dc\u09bf \u09b9\u0987\u09a4\u09c7 \u09b0\u09be\u09b8\u09cd\u09a4\u09be\u09df \u09ac\u09be\u09b9\u09bf\u09b0 \u09b9\u0987\u09b2\u09c7 \u09ac\u09bf\u09a8\u09df \u0995\u09b9\u09bf\u09b2, "\u0997\u09cb\u09b0\u09be, \u098f\u0995\u099f\u09c1 \u0986\u09b8\u09cd\u09a4\u09c7 \u0986\u09b8\u09cd\u09a4\u09c7 \u099a\u09b2\u09cb \u09ad\u09be\u0987-- \u09a4\u09cb\u09ae\u09be\u09b0 \u09aa\u09be \u09a6\u09c1\u099f\u09cb \u0986\u09ae\u09be\u09a6\u09c7\u09b0 \u099a\u09c7\u09df\u09c7 \u0985\u09a8\u09c7\u0995 \u09ac\u09dc\u09cb-- \u0993\u09b0 \u099a\u09be\u09b2\u099f\u09be \u098f\u0995\u099f\u09c1 \u0996\u09be\u099f\u09cb \u09a8\u09be \u0995\u09b0\u09b2\u09c7 \u09a4\u09cb\u09ae\u09be\u09b0 \u09b8\u0999\u09cd\u0997\u09c7 \u09af\u09c7\u09a4\u09c7 \u0986\u09ae\u09b0\u09be \u09b9\u09be\u0981\u09aa\u09bf\u09df\u09c7 \u09aa\u09dc\u09bf\u0964"\n \u0997\u09cb\u09b0\u09be \u0995\u09b9\u09bf\u09b2, "\u0986\u09ae\u09bf \u098f\u0995\u09b2\u09be\u0987 \u09af\u09c7\u09a4\u09c7 \u099a\u09be\u0987, \u0986\u09ae\u09be\u09b0 \u0986\u099c \u0985\u09a8\u09c7\u0995 \u0995\u09a5\u09be \u09ad\u09be\u09ac\u09ac\u09be\u09b0 \u0986\u099b\u09c7\u0964"\n \u09ac\u09b2\u09bf\u09df\u09be \u09a4\u09be\u09b9\u09be\u09b0 \u09b8\u09cd\u09ac\u09be\u09ad\u09be\u09ac\u09bf\u0995 \u09a6\u09cd\u09b0\u09c1\u09a4\u0997\u09a4\u09bf\u09a4\u09c7 \u09b8\u09c7 \u09ac\u09c7\u0997\u09c7 \u099a\u09b2\u09bf\u09df\u09be \u0997\u09c7\u09b2\u0964\n \u09ac\u09bf\u09a8\u09df\u09c7\u09b0 \u09ae\u09a8\u09c7 \u0986\u0998\u09be\u09a4 \u09b2\u09be\u0997\u09bf\u09b2\u0964 \u09b8\u09c7 \u0986\u099c \u0997\u09cb\u09b0\u09be\u09b0 \u09ac\u09bf\u09b0\u09c1\u09a6\u09cd\u09a7\u09c7 \u09ac\u09bf\u09a6\u09cd\u09b0\u09cb\u09b9 \u0995\u09b0\u09bf\u09df\u09be \u09a4\u09be\u09b9\u09be\u09b0 \u09a8\u09bf\u09df\u09ae \u09ad\u0999\u09cd\u0997 \u0995\u09b0\u09bf\u09df\u09be\u099b\u09c7\u0964 \u09b8\u09c7 \u09b8\u09ae\u09cd\u09ac\u09a8\u09cd\u09a7\u09c7 \u0997\u09cb\u09b0\u09be\u09b0 \u0995\u09be\u099b\u09c7 \u09a4\u09bf\u09b0\u09b8\u09cd\u0995\u09be\u09b0 \u09ad\u09cb\u0997 \u0995\u09b0\u09bf\u09b2\u09c7 \u09b8\u09c7 \u0996\u09c1\u09b6\u09bf \u09b9\u0987\u09a4\u0964 \u098f\u0995\u099f\u09be \u099d\u09dc \u09b9\u0987\u09df\u09be \u0997\u09c7\u09b2\u09c7\u0987 \u09a4\u09be\u09b9\u09be\u09a6\u09c7\u09b0 \u099a\u09bf\u09b0\u09a6\u09bf\u09a8\u09c7\u09b0 \u09ac\u09a8\u09cd\u09a7\u09c1\u09a4\u09cd\u09ac\u09c7\u09b0 \u0986\u0995\u09be\u09b6 \u09b9\u0987\u09a4\u09c7 \u0997\u09c1\u09ae\u099f \u0995\u09be\u099f\u09bf\u09df\u09be \u09af\u09be\u0987\u09a4 \u098f\u09ac\u0982 \u09b8\u09c7 \u09b9\u09be\u0981\u09aa \u099b\u09be\u09dc\u09bf\u09df\u09be \u09ac\u09be\u0981\u099a\u09bf\u09a4\u0964\n \u09a4\u09be\u09b9\u09be \u099b\u09be\u09dc\u09be \u0986\u09b0-\u098f\u0995\u099f\u09be \u0995\u09a5\u09be \u09a4\u09be\u09b9\u09be\u0995\u09c7 \u09aa\u09c0\u09dc\u09be \u09a6\u09bf\u09a4\u09c7\u099b\u09bf\u09b2\u0964 \u0986\u099c \u09b9\u09a0\u09be\u09ce \u0997\u09cb\u09b0\u09be \u09aa\u09b0\u09c7\u09b6\u09c7\u09b0 \u09ac\u09be\u09dc\u09bf\u09a4\u09c7 \u09aa\u09cd\u09b0\u09a5\u09ae \u0986\u09b8\u09bf\u09df\u09be\u0987 \u09ac\u09bf\u09a8\u09df\u0995\u09c7 \u09b8\u09c7\u0996\u09be\u09a8\u09c7 \u09ac\u09a8\u09cd\u09a7\u09c1\u09ad\u09be\u09ac\u09c7 \u09ac\u09b8\u09bf\u09df\u09be \u09a5\u09be\u0995\u09bf\u09a4\u09c7 \u09a6\u09c7\u0996\u09bf\u09df\u09be \u09a8\u09bf\u09b6\u09cd\u099a\u09df\u0987 \u09ae\u09a8\u09c7 \u0995\u09b0\u09bf\u09df\u09be\u099b\u09c7 \u09ac\u09bf\u09a8\u09df \u098f \u09ac\u09be\u
06-07 12:44:20.663 13701-13701/com.showhow2.www.thetagoreproject W/System.err: org.json.JSONException: Value {"Booking":{"id":"17","contributor_id":"16","table_of_content_id":"1","composition_id":"12","completion":"2017-05-20","approved":null,"cdn_id":null,"secret_token":null,"uploaded_on":null,"created":"2017-05-09 14:41:49","modified":"2017-05-09 14:41:49"},"TableOfContent":{"id":"1","name":"গোরা","category_id":"1","language_id":"1","created":"2016-03-09 03:39:01","modified":"2016-03-09 14:39:01"},"Composition":{"id":"12","content":"বিনয় ও গোরা পরেশের বাড়ি হইতে রাস্তায় বাহির হইলে বিনয় কহিল, "গোরা, একটু আস্তে আস্তে চলো ভাই-- তোমার পা দুটো আমাদের চেয়ে অনেক বড়ো-- ওর চালটা একটু খাটো না করলে তোমার সঙ্গে যেতে আমরা হাঁপিয়ে পড়ি।"\n গোরা কহিল, "আমি একলাই যেতে চাই, আমার আজ অনেক কথা ভাববার আছে।"\n বলিয়া তাহার স্বাভাবিক দ্রুতগতিতে সে বেগে চলিয়া গেল।\n বিনয়ের মনে আঘাত লাগিল। সে আজ গোরার বিরুদ্ধে বিদ্রোহ করিয়া তাহার নিয়ম ভঙ্গ করিয়াছে। সে সম্বন্ধে গোরার কাছে তিরস্কার ভোগ করিলে সে খুশি হইত। একটা ঝড় হইয়া গেলেই তাহাদের চিরদিনের বন্ধুত্বের আকাশ হইতে গুমট কাটিয়া যাইত এবং সে হাঁপ ছাড়িয়া বাঁচিত।\n তাহা ছাড়া আর-একটা কথা তাহাকে পীড়া দিতেছিল। আজ হঠাৎ গোরা পরেশের বাড়িতে প্রথম আসিয়াই বিনয়কে সেখানে বন্ধুভাবে বসিয়া থাকিতে দেখিয়া নিশ্চয়ই মনে করিয়াছে বিনয় এ বাড়িতে সর্বদাই যাতায়াত করে। অবশ্য, যাতায়াত করিলে যে কোনো অপরাধ আছে তাহা নয়; গোরা যাহাই বলুক পরেশবাবুর সুশিক্ষিত পরিবারের সঙ্গে অন্তরঙ্গভাবে পরিচিত হইবার সুযোগ পাওয়া বিনয় একটা বিশেষ লাভ বলিয়া গণ্য করিতেছে; ইঁহাদের সঙ্গে মেশামেশি করাতে গোরা যদি কোনো দোষ দেখে তবে সেটা তাহার নিতান্ত গোঁড়ামি; কিন্তু পূর্বের কথাবার্তায় গোরা নাকি জানিয়াছে যে বিনয় পরেশবাবুর বাড়িতে যাওয়া-আসা করে না, আজ সহসা তাহার মনে হইতে পারে যে সে কথাটা সত্য নয়। বিশেষত বরদাসুন্দরী তাহাকে বিশেষ করিয়া ঘরে ডাকিয়া লইয়া গেলেন, সেখানে তাঁহার মেয়েদের সঙ্গে তাহার আলাপ হইতে লাগিল-- গোরার তীক্ষ্ণ লক্ষ হইতে ইহা এড়াইয়া যায় নাই। মেয়েদের সঙ্গে এইরূপ মেলামেশায় ও বরদাসুন্দরীর আত্মীয়তায় মনে মনে বিনয় ভার�
06-07 12:44:20.663 13701-13701/com.showhow2.www.thetagoreproject W/System.err:     at org.json.JSON.typeMismatch(JSON.java:100)
06-07 12:44:20.663 13701-13701/com.showhow2.www.thetagoreproject W/System.err:     at org.json.JSONObject.getJSONArray(JSONObject.java:588)
06-07 12:44:20.663 13701-13701/com.showhow2.www.thetagoreproject W/System.err:     at com.showhow2.www.thetagoreproject.RecordComposition$16.onResponse(RecordComposition.java:704)
06-07 12:44:20.663 13701-13701/com.showhow2.www.thetagoreproject W/System.err:     at com.showhow2.www.thetagoreproject.RecordComposition$16.onResponse(RecordComposition.java:694)
06-07 12:44:20.663 13701-13701/com.showhow2.www.thetagoreproject W/System.err:     at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:60)
06-07 12:44:20.663 13701-13701/com.showhow2.www.thetagoreproject W/System.err:     at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:30)
06-07 12:44:20.663 13701-13701/com.showhow2.www.thetagoreproject W/System.err:     at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:99)
06-07 12:44:20.663 13701-13701/com.showhow2.www.thetagoreproject W/System.err:     at android.os.Handler.handleCallback(Handler.java:739)
06-07 12:44:20.663 13701-13701/com.showhow2.www.thetagoreproject W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:95)
06-07 12:44:20.663 13701-13701/com.showhow2.www.thetagoreproject W/System.err:     at android.os.Looper.loop(Looper.java:148)
06-07 12:44:20.663 13701-13701/com.showhow2.www.thetagoreproject W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:5417)
06-07 12:44:20.663 13701-13701/com.showhow2.www.thetagoreproject W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
06-07 12:44:20.664 13701-13701/com.showhow2.www.thetagoreproject W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
06-07 12:44:20.664 13701-13701/com.showhow2.www.thetagoreproject W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

Body:
Try this code

try {
                        JSONObject json = new JSONObject(response);
                        String code = json.getString("code");
                        JSONObject obj = json.getJSONObject("upload");
                        JSONObject objbooking = obj.getJSONObject("Booking");
                        JSONObject objtable = obj.getJSONObject("TableOfContent");

                       //you can get values like below

                       String idbooking = objbooking.getString("id");
                       String idtable = objtable.getString("id");

                    } catch (JSONException e) {
                        e.printStackTrace();
                    }


来源: stackexchange

问:
Fast linq query with join and count
I have this SQL query witch is running fast if executed from TOAD in Oracle database where Jobs table contains more than 2 million records.

```<code>select * from Technicians  A
left join
  (select TechnicianCode,count(*)JobCount from Jobs
   where TxnCode in ('Jc','Jcd') group by TechnicianCode) B
on B.TechnicianCode =A.TechnicianCode
</code>```

Not able to translate it to linq in efficient way.
Can anybody help with it?

答:
It try Code:</p>

```<code>var result= (from  p in Technicians
             join q in Jobs.where(c=>c.TxnCode=="JC" || c.TxnCode==c."Jcd").GroupBy(c=>c.TechnicianCode)
             .Select(m => new { jobcount = m.Count(), TechnicianCode = m.FirstOrDefault().TechnicianCode,  TxnCode=m.FirstOrDefault().TxnCode}).ToList()
             on p.TechnicianCode equals q.TechnicianCode into jj from kk in jj.DefaultIfEmpty()
             select new {
                          jobcount=kk.jobcount,
                          TxnCode=kk.TxnCode,
                          TechnicianCode=p.TechnicianCode
                        }).ToList();
</code>```

ContentLicense: CC BY-SA 3.0

Title: Fast linq query with join and count

Body:
I have this SQL query witch is running fast if executed from TOAD in Oracle database where Jobs table contains more than 2 million records.

select * from Technicians  A
left join
  (select TechnicianCode,count(*)JobCount from Jobs
   where TxnCode in ('Jc','Jcd') group by TechnicianCode) B
on B.TechnicianCode =A.TechnicianCode

Not able to translate it to linq in efficient way.
Can anybody help with it?

Body:
It try Code:

var result= (from  p in Technicians
             join q in Jobs.where(c=>c.TxnCode=="JC" || c.TxnCode==c."Jcd").GroupBy(c=>c.TechnicianCode)
             .Select(m => new { jobcount = m.Count(), TechnicianCode = m.FirstOrDefault().TechnicianCode,  TxnCode=m.FirstOrDefault().TxnCode}).ToList()
             on p.TechnicianCode equals q.TechnicianCode into jj from kk in jj.DefaultIfEmpty()
             select new {
                          jobcount=kk.jobcount,
                          TxnCode=kk.TxnCode,
                          TechnicianCode=p.TechnicianCode
                        }).ToList();


问:
Git reset and than pull
In my scenario, I'm doing:

git reset <commit>

followed immediately by:

git pull --ff-only

From my understanding of git, this action should success, and just re-do (fast forward) the history that I reset.

However, I'm getting:
error: The following untracked working tree files would be overwritten by merge: on many of my files, and the operation fails.

Does anyone know why isn't it working as I could expect? Thanks!

答:
git reset only unstage files that were just added to the index..

You need at least a reset --hard (if you are sure you don't have any work in progress) before a pull can succeed.

re-do (fast forward) the history that I reset.

Not exactly: it will fetch and then (git pull --ff-only):

Refuse to merge and exit with a non-zero status unless the current HEAD is already up-to-date or the merge can be resolved as a fast-forward.

It does not "fast-forward the history that you reset": reset has nothing to do with it: if you previously did local commits of your own, the merge would not be a fast-forward anyway, reset or not (unless you reset hard to origin/master, losing your local commits).

Title: Git reset and than pull


问:
Fetch First 'Variable' Rows Only
It is possible to pass value into fetch first syntax?</p>

```<code>        SET inputtotalCount = inputcount - inputintSimilarityLevel;
        IF inputtotalCount > 0 THEN
            BEGIN
                DELETE FROM EUSYSUPW WHERE UPRECID IN (
                SELECT UPRECID FROM EUSYSUPW
                WHERE UPUSRID = inputSACUSRID
                ORDER BY UPMODDT ASC
                FETCH FIRST inputtotalCount ROWS ONLY);
            END;
        END IF;
</code>```

答:
Hi you can't use parameter on fetch first rows , however you can create rownumber and delete rows with row num <= parameter .I don't have your data so I added some random integers.

```<code>begin atomic
declare   inputtotalCount int;
declare          inputcount  int;
declare          inputintSimilarityLevel int;
declare          inputSACUSRID int;
set inputcount=9;
set inputintSimilarityLevel=2;
SET inputtotalCount = inputcount - inputintSimilarityLevel;
set inputSACUSRID=5;
    SET inputtotalCount = 7;

    IF inputtotalCount > 0 THEN

           DELETE  from (
            SELECT e.*,row_number() over (PARTITION BY UPUSRID order by UPMODDT  ) as rownum
            FROM work.EUSYSUPW e
            WHERE UPUSRID = inputSACUSRID) as a
            where rownum<=inputtotalCount;

    END IF;
end
</code>```

second option is to create dynamic sql

Title: Fetch First 'Variable' Rows Only

Body:
It is possible to pass value into fetch first syntax?

        SET inputtotalCount = inputcount - inputintSimilarityLevel;
        IF inputtotalCount > 0 THEN
            BEGIN
                DELETE FROM EUSYSUPW WHERE UPRECID IN (
                SELECT UPRECID FROM EUSYSUPW
                WHERE UPUSRID = inputSACUSRID
                ORDER BY UPMODDT ASC
                FETCH FIRST inputtotalCount ROWS ONLY);
            END;
        END IF;

Body:
Hi you can't use parameter on fetch first rows , however you can create rownumber and delete rows with row num <= parameter .I don't have your data so I added some random integers.

begin atomic
declare   inputtotalCount int;
declare          inputcount  int;
declare          inputintSimilarityLevel int;
declare          inputSACUSRID int;
set inputcount=9;
set inputintSimilarityLevel=2;
SET inputtotalCount = inputcount - inputintSimilarityLevel;
set inputSACUSRID=5;
    SET inputtotalCount = 7;

    IF inputtotalCount > 0 THEN

           DELETE  from (
            SELECT e.*,row_number() over (PARTITION BY UPUSRID order by UPMODDT  ) as rownum
            FROM work.EUSYSUPW e
            WHERE UPUSRID = inputSACUSRID) as a
            where rownum<=inputtotalCount;

    END IF;
end

second option is to create dynamic sql


问:
Meteor.js : best way to stop event propagation
Consider this template in Meteor.js.

```<code><template name="trial">
  <li id='{{ _id }}'">{{ name }}
    <span>X</span>
  </li>
</template>
</code>```

I want to add an event to the "li" and another one to the "span". How can I prevent the click on the span to fire the event attached to the li? I've found some posts talking about this, but they're years old.

Many thanks for your help!

答:
To prevent event from bubbling-up to parent elements, use stopPropagation() of the event object. Works on either native JS events, or React events:

```<code>spanClickHandler(event) {
    event.stopPropagation();

    // handle click
    ...
}
</code>```

Body:
Consider this template in Meteor.js.

<template name="trial">

{{ name }}
    X

</template>

I want to add an event to the "li" and another one to the "span". How can I prevent the click on the span to fire the event attached to the li? I've found some posts talking about this, but they're years old.

Many thanks for your help!

Body:
To prevent event from bubbling-up to parent elements, use stopPropagation() of the event object. Works on either native JS events, or React events:

spanClickHandler(event) {
    event.stopPropagation();

    // handle click
    ...
}


问:
Pandas pivot with specified (additional) columns
I have a two different list of tuples that are converted into a pandas dataframe:

```<code>ls1 = [(1,"A",2),(1,"B",1),(1,"C",3),(2,"A",4),(2,"B",4,),(2,"C",5)]
ls2 = [(1,"A",2),(1,"C",3),(1,"B",1),(1,"D",6),(2,"A",4),(2,"C",5),(2,"B",4,)]
df1 = pandas.DataFrame(ls1, columns=['ID', 'Class', 'count'])
df2 = pandas.DataFrame(ls2, columns=['ID', 'Class', 'count'])
</code>```

Now I'd like to make a pivot table from both dataframes with the column names for the classes "A", "B", "C", "D". So, all four column names (if possible also in a specified order) should exist in the resulting pivot table. If there are no counts for a ID-Class combination these should be filled with e.g. NaN.

```<code>dfpivot1 = df1.pivot(index='ID', columns='Class', values='count')
dfpivot2 = df2.pivot(index='ID', columns='Class', values='count')

>>> dfpivot1
Class  A  B  C
ID
1      2  1  3
2      4  4  5
>>>
</code>```

Using the .pivot from pandas provides a pivot table for df1, but with only three Class-columns ("A","B","C"). So, dfpivot1 needs to be modified to have the columns "A","B","C" AND "D" and thus, exactly match the columns of dfpivot2. As I am starting from a list of tuples also other approaches (without using pandas) might be interesting.

答:
I think you need add reindex_axis or reindex for fill NaNs for all missing columns:

```<code>cols = ['A','B','C','D']
dfpivot1 = df1.pivot(index='ID', columns='Class', values='count').reindex_axis(cols, axis=1)
print (dfpivot1)
Class  A  B  C   D
ID
1      2  1  3 NaN
2      4  4  5 NaN
</code>```

Also is possible specify fill_value parameter:

```<code>cols = ['A','B','C','D']
dfpivot1 = df1.pivot(index='ID', columns='Class', values='count')
              .reindex_axis(cols, fill_value=0, axis=1)
print (dfpivot1)
Class  A  B  C  D
ID
1      2  1  3  0
2      4  4  5  0
</code>```

```<code>cols = ['A','B','C','D']
dfpivot1 = df1.pivot(index='ID', columns='Class', values='count').reindex(columns=cols)
print (dfpivot1)
Class  A  B  C   D
ID
1      2  1  3 NaN
2      4  4  5 NaN
</code>```

Body:
I have a two different list of tuples that are converted into a pandas dataframe:

ls1 = [(1,"A",2),(1,"B",1),(1,"C",3),(2,"A",4),(2,"B",4,),(2,"C",5)]
ls2 = [(1,"A",2),(1,"C",3),(1,"B",1),(1,"D",6),(2,"A",4),(2,"C",5),(2,"B",4,)]
df1 = pandas.DataFrame(ls1, columns=['ID', 'Class', 'count'])
df2 = pandas.DataFrame(ls2, columns=['ID', 'Class', 'count'])

Now I'd like to make a pivot table from both dataframes with the column names for the classes "A", "B", "C", "D". So, all four column names (if possible also in a specified order) should exist in the resulting pivot table. If there are no counts for a ID-Class combination these should be filled with e.g. NaN.

dfpivot1 = df1.pivot(index='ID', columns='Class', values='count')
dfpivot2 = df2.pivot(index='ID', columns='Class', values='count')

>>> dfpivot1
Class  A  B  C
ID
1      2  1  3
2      4  4  5
>>>

Using the .pivot from pandas provides a pivot table for df1, but with only three Class-columns ("A","B","C"). So, dfpivot1 needs to be modified to have the columns "A","B","C" AND "D" and thus, exactly match the columns of dfpivot2. As I am starting from a list of tuples also other approaches (without using pandas) might be interesting.

Body:
I think you need add reindex_axis or reindex for fill NaNs for all missing columns:

cols = ['A','B','C','D']
dfpivot1 = df1.pivot(index='ID', columns='Class', values='count').reindex_axis(cols, axis=1)
print (dfpivot1)
Class  A  B  C   D
ID
1      2  1  3 NaN
2      4  4  5 NaN

Also is possible specify fill_value parameter:

cols = ['A','B','C','D']
dfpivot1 = df1.pivot(index='ID', columns='Class', values='count')
              .reindex_axis(cols, fill_value=0, axis=1)
print (dfpivot1)
Class  A  B  C  D
ID
1      2  1  3  0
2      4  4  5  0

cols = ['A','B','C','D']
dfpivot1 = df1.pivot(index='ID', columns='Class', values='count').reindex(columns=cols)
print (dfpivot1)
Class  A  B  C   D
ID
1      2  1  3 NaN
2      4  4  5 NaN


问:
Sending ASCII and protocol commands to server
I managed to setup a client and server connection using Java socket.  After checking the connection had been establish, I tried sending Protocol commands that are provided by the SDK from the server and I'm using a JButton to execute the commands.

Examples of the commands are play, stop and ping the server.

The code below shows how I setup the connection and send the protocol commands

```<code>public void socket1()
{
    Socket MyClient;
    try {
        MyClient = new Socket("192.168.10.61",9993);
        os = new DataOutputStream(MyClient.getOutputStream());
        is = new DataInputStream(MyClient.getInputStream());
        lblerror.setText("Connected");
        MyClient.getOutputStream().write("play".getBytes("US-ASCII"));
    } catch (UnknownHostException e) {
        // TODO Auto-generated catch block
         lblerror.setText("Don't know about host: hostname");

    } catch (IOException e) {
        // TODO Auto-generated catch block
        lblerror.setText("Couldn't get I/O for the connection to: hostname");

    }

}
</code>```

After pressing the button on the GUI, The server did not response to the command 'play' and there is no error.

答:
As Scarry Wombat wrote, use os.write()
But instead of .write() use .writeBytes(),
because you want to send a byte array(?). Alternatively you could send a String with UTF-encoding by using .writeUTF()

Body:
I managed to setup a client and server connection using Java socket.  After checking the connection had been establish, I tried sending Protocol commands that are provided by the SDK from the server and I'm using a JButton to execute the commands.

Examples of the commands are play, stop and ping the server.

The code below shows how I setup the connection and send the protocol commands

public void socket1()
{
    Socket MyClient;
    try {
        MyClient = new Socket("192.168.10.61",9993);
        os = new DataOutputStream(MyClient.getOutputStream());
        is = new DataInputStream(MyClient.getInputStream());
        lblerror.setText("Connected");
        MyClient.getOutputStream().write("play".getBytes("US-ASCII"));
    } catch (UnknownHostException e) {
        // TODO Auto-generated catch block
         lblerror.setText("Don't know about host: hostname");

    } catch (IOException e) {
        // TODO Auto-generated catch block
        lblerror.setText("Couldn't get I/O for the connection to: hostname");

    }

}

After pressing the button on the GUI, The server did not response to the command 'play' and there is no error.


问:
Converting XML to JSON
I'm trying to convert an XML file into an internal table of type String.
Is there a function module to convert XML data to JSON format?

答:
Using a ABAP simple transformation or an XSLT transformation is only one option. You could also fully implement a conversion in ABAP code, e.g. with:

Use CALL TRANSFORMATION id SOURCE XML <xml as string> RESULT <root node> = <itab>. Refer to the ABAP keyword documentation

Use class/method /ui2/cl_json=>deserialize and =>serialize

Use class cl_ixml: see Parsing an XML document DOM-based and Parsing an XML document event-based

Title: Converting XML to JSON


问:
Extract metadata from multiple videos
I am faced with a challenge that requires multiple aspects of bash. I work in Linux (precisely Debian Stretch). Here is the situation (for all points/problem I write along the solution I considered for now, but I'm open to other ideas) :

I have videos of various types (and various upper-lower case), such as .mp4, .mov, .MOV, .MP4, .avi,... located in a directory (and spread across an almost un-structured tree of directories). To find all I tried to use the find command

For each video, I need to extract some metadata (i.e. the name of the file, duration of video, size of file and date of creation/last modification). The package mediainfo yields (among a lot of other things) the required fields.
The output of mediainfo is a long list of fields with format : <Tag>\t : <value>. I need to extract values for fields Complete name, Duration, File size and Encoded date.

So with all this information, I must filter the required fields value and put them in a CSV file. I considered using sed.

My goal is to achieve all these tasks either in a script or a small amount of separate commands.

The idea code (this code is hideously wrong, but you can get an idea) :

find . -type f -name "*.[mp4|MP4|mov|MOV|avi|AVI]" -exec mediainfo {} | sed '/Complete name|Duration|File size|Encoded date/p' > myfile.csv \;

Would you have any idea how to perform this task ? I feel terribly lost in combining find, exec and sed and outputting to a csv...

Thanks in advance for your help !

答:
Try this. Due to less time,I was not able to complete. You just have to send output to CSV.</p>

```<code>for c in $(locate --basename .mp4 .mkv .wmv .flv .webm .mov .avi)

do

 Complete_name=$(mediainfo --Output=XML $c | xml_grep 'Complete_name' --text_only| awk 'BEGIN{FS="/"}{print $NF}')

    echo $Complete_name

 Duration=$(mediainfo --Output=XML $c | xml_grep 'Duration' --text_only --nb_result 1)

    echo $Duration

 File_size=$(mediainfo --Output=XML $c | xml_grep 'File_size' --text_only)

echo $File_size

Encoded_date=$(mediainfo --Output=XML $c | xml_grep 'Encoded_date' --text_only -nb_result 1 | awk '{print $2}')

echo $Encoded_date

done
</code>```

Title: Extract metadata from multiple videos

Body:
Try this. Due to less time,I was not able to complete. You just have to send output to CSV.

for c in $(locate --basename .mp4 .mkv .wmv .flv .webm .mov .avi)

do

 Complete_name=$(mediainfo --Output=XML $c | xml_grep 'Complete_name' --text_only| awk 'BEGIN{FS="/"}{print $NF}')

    echo $Complete_name

 Duration=$(mediainfo --Output=XML $c | xml_grep 'Duration' --text_only --nb_result 1)

    echo $Duration

 File_size=$(mediainfo --Output=XML $c | xml_grep 'File_size' --text_only)

echo $File_size

Encoded_date=$(mediainfo --Output=XML $c | xml_grep 'Encoded_date' --text_only -nb_result 1 | awk '{print $2}')

echo $Encoded_date

done


问:
pdf.js rendering as PDF with base64
I am stuck at last point of my application, i am supposed to display user form in PDF which works fine on desktop browsers as they has pdf viewer built in, but for Android / iOS its not working as pdf viewer is missing.

So i was trying to use PDF.js to display it, (to be honest, this is very widely used but documentation is lacking), only catch is i am getting data in base64 format. PDF.js has example on site which shows how to render the base64 data but its not PDF, for that displaying PDF as "PDF" i need to user their "viewer.html" but that does not take base64 data?

closest i have come to Pdf.js: rendering a pdf file using base64... on stack overflow, but i dont know how to use it after PDFJS.getDocument(pdfAsArray)?.

Other link that came across was other link

I dont want to rely on Google / Third party PDF viewer as i dont know how long they will support this.

答:
There are no end-to-end answers on this topic in community so here is my attempt to put something here. (maybe it will help others)

Okay, PDF.js is one way of showing PDF in browser, specially when you don't want to rely on PDF plugin to be installed. In my case, my application generates report in PDF and that can be viewed before downloading but on handheld devices it was not working because of missing PDF viewer plugin.

In my case PDF was sent to browse in base64 string, that I can use to display PDF with <object src="base64-data"...></object>. This works like charm on Chrome / FF but switch to mobile view and it stops working.

<object type="application/pdf" id="pdfbin" width="100%" height="100%" title="Report.pdf">

Looks like there is no PDF viewer plugin installed, try one of the below approach...

</object>
```

<p>In above code it will try to show the PDF or fall back to <code><p></code> and show error message. And I Was planning to add the PDF viewer at this point, PDF.js was the choice but was not able to display it. One example on PDF.js with Base64 data shows how to do this but that renders it as an Image not PDF, and I was not able to find solution for that and hence the question, here is what I did,</p>

<ol>
<li><p>First add the JavaScript code to convert base64 to array</p></li>
<li><p>convert to blob and use <code>viewer.html</code> file packaged with PDF.js to display it as PDF</p></li>
</ol>

<p><em>In case if you are wondering why base64 data, then answer is simple I can create the PDF, read it, send the data to client and delete the file, I don't have to run any cleaner service/cron job to delete generated PDF files</em></p>

<p><strong>Few Things To Note</strong></p>

<blockquote>
  <ol>
  <li>Below code is using Flask + Jinja2, change the way base64 is read in html if you are using something else</li>
  <li>viewer.html needs to be changed to have required js & css files in proper location (by default their location is relative; you need them to be referred from static folder)</li>
  <li><code>viewer.js</code> looks for <code>pdf.worker.js</code> in predefined location, change that in case its throwing error as above file not found.</li>
  <li><code>viewer.js</code> <em>might</em> throw <code>file origin does not match viewer</code> error in that case as a quick fix comment the code which throws this error and see if that solves the issue (look for that error in viewer.js)</li>
  <li>I am not the author of below code, I have just put it together from different places.</li>
  </ol>
</blockquote>

<p>Now to the code (so PDF will be displayed when user clicks on button with <code>id="open_id"</code>)</p>

<hr>

<p><strong>Jquery</strong></p>

<pre class="lang-js prettyprint-override"><code>var pdfDataX = '{{ base64Pdf }}';
var BASE64_MARKER = ';base64,';
PDFJS.workerSrc = "{{ url_for('static', filename='js/pdf.worker.js') }}";

$('#open_id').click(function() {
    PDFJS.disableWorker = true;
    var pdfAsDataUri = "data:application/pdf;base64," + pdfDataX ;
    PDFJS.workerSrc = "{{ url_for('static', filename='js/pdf.worker.js') }}";

    // Try to show in the viewer.html

    var blob = base64toBlob(pdfDataX, 'application/pdf');
    var url = URL.createObjectURL(blob);
    var viewerUrl = "{{ url_for('static', filename='viewer.html') }}" + '?file=' + encodeURIComponent(url);
    $('#pdfViewer').attr('src', viewerUrl);

    // Finish

    var mdObj = $('#pdfbin');

    mdObj.hide();
    mdObj.attr('data', pdfAsDataUri);
    mdObj.show();

    $('#myModal').modal();
});

var base64toBlob = function(b64Data, contentType, sliceSize) {
    contentType = contentType || '';
    sliceSize = sliceSize || 512;

    var byteCharacters = atob(b64Data);
    var byteArrays = [];

    for (var offset = 0; offset < byteCharacters.length; offset += sliceSize) {
        var slice = byteCharacters.slice(offset, offset + sliceSize);

        var byteNumbers = new Array(slice.length);
        for (var i=0; i<slice.length; i++) {
            byteNumbers[i] = slice.charCodeAt(i);
        }

        var byteArray = new Uint8Array(byteNumbers);

        byteArrays.push(byteArray);
    }
    var blob = new Blob(byteArrays, {type: contentType});
    return blob;
}

$('.save').click(function(e) {
    e.preventDefault();
    var blob = base64toBlob(pdfDataX, 'application/pdf');
    saveAs(blob, 'abcd.pdf');  // requires https://github.com/eligrey/FileSaver.js/
    return false;
});
</code>```

HTML

<object type="application/pdf" id="pdfbin" width="100%" height="100%" title="Resume.pdf">

Looks like there is no PDF viewer plugin installed, try one of the below approach...

</object>```

Hope this will be useful for others in future.

Title: pdf.js rendering as PDF with base64

Body:
There are no end-to-end answers on this topic in community so here is my attempt to put something here. (maybe it will help others)

Okay, PDF.js is one way of showing PDF in browser, specially when you don't want to rely on PDF plugin to be installed. In my case, my application generates report in PDF and that can be viewed before downloading but on handheld devices it was not working because of missing PDF viewer plugin.

In my case PDF was sent to browse in base64 string, that I can use to display PDF with <object src="base64-data"...></object>. This works like charm on Chrome / FF but switch to mobile view and it stops working.

<object type="application/pdf" id="pdfbin" width="100%" height="100%" title="Report.pdf">
   <p class="text-center">Looks like there is no PDF viewer plugin installed, try one of the below approach...</p>
</object>

In above code it will try to show the PDF or fall back to <p> and show error message. And I Was planning to add the PDF viewer at this point, PDF.js was the choice but was not able to display it. One example on PDF.js with Base64 data shows how to do this but that renders it as an Image not PDF, and I was not able to find solution for that and hence the question, here is what I did,

First add the JavaScript code to convert base64 to array

convert to blob and use viewer.html file packaged with PDF.js to display it as PDF

In case if you are wondering why base64 data, then answer is simple I can create the PDF, read it, send the data to client and delete the file, I don't have to run any cleaner service/cron job to delete generated PDF files

Few Things To Note

Below code is using Flask + Jinja2, change the way base64 is read in html if you are using something else

viewer.html needs to be changed to have required js & css files in proper location (by default their location is relative; you need them to be referred from static folder)

viewer.js looks for pdf.worker.js in predefined location, change that in case its throwing error as above file not found.

viewer.js might throw file origin does not match viewer error in that case as a quick fix comment the code which throws this error and see if that solves the issue (look for that error in viewer.js)

I am not the author of below code, I have just put it together from different places.

Now to the code (so PDF will be displayed when user clicks on button with id="open_id")

Jquery

var pdfDataX = '{{ base64Pdf }}';
var BASE64_MARKER = ';base64,';
PDFJS.workerSrc = "{{ url_for('static', filename='js/pdf.worker.js') }}";

$('#open_id').click(function() {
    PDFJS.disableWorker = true;
    var pdfAsDataUri = "data:application/pdf;base64," + pdfDataX ;
    PDFJS.workerSrc = "{{ url_for('static', filename='js/pdf.worker.js') }}";

    // Try to show in the viewer.html

    var blob = base64toBlob(pdfDataX, 'application/pdf');
    var url = URL.createObjectURL(blob);
    var viewerUrl = "{{ url_for('static', filename='viewer.html') }}" + '?file=' + encodeURIComponent(url);
    $('#pdfViewer').attr('src', viewerUrl);

    // Finish

    var mdObj = $('#pdfbin');

    mdObj.hide();
    mdObj.attr('data', pdfAsDataUri);
    mdObj.show();

    $('#myModal').modal();
});

var base64toBlob = function(b64Data, contentType, sliceSize) {
    contentType = contentType || '';
    sliceSize = sliceSize || 512;

    var byteCharacters = atob(b64Data);
    var byteArrays = [];

    for (var offset = 0; offset < byteCharacters.length; offset += sliceSize) {
        var slice = byteCharacters.slice(offset, offset + sliceSize);

        var byteNumbers = new Array(slice.length);
        for (var i=0; i<slice.length; i++) {
            byteNumbers[i] = slice.charCodeAt(i);
        }

        var byteArray = new Uint8Array(byteNumbers);

        byteArrays.push(byteArray);
    }
    var blob = new Blob(byteArrays, {type: contentType});
    return blob;
}

$('.save').click(function(e) {
    e.preventDefault();
    var blob = base64toBlob(pdfDataX, 'application/pdf');
    saveAs(blob, 'abcd.pdf');  // requires https://github.com/eligrey/FileSaver.js/
    return false;
});

HTML

<object type="application/pdf" id="pdfbin" width="100%" height="100%" title="Resume.pdf">
    <p class="text-center">Looks like there is no PDF viewer plugin installed, try one of the below approach...</p>
    <iframe id="pdfViewer" style="width: 100%; height: 100%;" allowfullscreen="" webkitallowfullscreen=""></iframe>
</object>

Hope this will be useful for others in future.


问:
Pod installed Alamofire 4.4, but class is not being autocomplete by Xcode 8.3
I have noticed this problem as closed before but I am getting the same problem.

P.S - I have imported Alamofire in the class mentioned in the screenshot

Here is my pod details

```<code>platform :ios, '10.0'

use_frameworks!
target 'PhotoTagger' do
     pod 'Alamofire'
end
</code>```

Also the only thing being auto completed is AlamofireVersionNumber and i cannot access anything when I am trying to use the auto complete feature. Now if i write Alamofire by hand then I can access some methods, but then again something is going wrong and code is not compiling, which i think boils down to the issue that the class isnt being fetched by auto complete.

I have tried -

In Project settings > Build settings

Always search user path To YES

Header search path to only include "$(inherited)" as non-recursive

All other pods are working fine, except Alamofire.
Also after writing class name by hand or copy pasting, some of the methods that are being auto completed does not have the same signature of the actual method of the Alamofire class

Please please please !! help me sort this out, so that someone out there when facing this can help themselves too. There isnt any solution to this as of now.

P.S

I had opened an issue on Alamofire's Github page, but they responded with

```<code>Sorry, we're not responsible for Xcode's autocomplete issues.
In the future, you should open questions like this on Stack Overflow
and tag alamofire.

Cheers.
</code>```

Please help, I am stuck with this for quite some time.

EDIT :

Here is my project settings details

Also, I have build the project and still the problem persists.

P.S - Writing the class manually by hand , and the methods even, it compiles but everytime, I have to go to the github page, to copy paste the method signature, The problem is that with Autocomplete, i can navigate all method signatures and know about the public available methods. But I am only restricted to the example methods available in github, as everytime I have to copy paste the methods and the overwrite the implementation. Again, this compiles and runs, but the auto complete is not working, not for the class, or for the functions.

答:
I had this exact problem a few days back. I think this is happening because Xcode is not able to find the Alamofire header libraries. What I did to resolve was :

1) Go to build settings and search for 'User Header Search Paths'

2) Enter its value as "${PODS_ROOT}/BuildHeaders" including the quotes

3) Click the thing again and in the right side , change the value of the selection to 'recursive'

Now Restart Xcode and build the project. Now the autocomplete works fine

Body:
I have noticed this problem as closed before but I am getting the same problem.

P.S - I have imported Alamofire in the class mentioned in the screenshot

Here is my pod details

platform :ios, '10.0'

use_frameworks!
target 'PhotoTagger' do
     pod 'Alamofire'
end

Also the only thing being auto completed is AlamofireVersionNumber and i cannot access anything when I am trying to use the auto complete feature. Now if i write Alamofire by hand then I can access some methods, but then again something is going wrong and code is not compiling, which i think boils down to the issue that the class isnt being fetched by auto complete.

I have tried -

In Project settings > Build settings

Always search user path To YES

Header search path to only include "$(inherited)" as non-recursive

All other pods are working fine, except Alamofire.
Also after writing class name by hand or copy pasting, some of the methods that are being auto completed does not have the same signature of the actual method of the Alamofire class

Please please please !! help me sort this out, so that someone out there when facing this can help themselves too. There isnt any solution to this as of now.

P.S

I had opened an issue on Alamofire's Github page, but they responded with

Sorry, we're not responsible for Xcode's autocomplete issues.
In the future, you should open questions like this on Stack Overflow
and tag alamofire.

Cheers.

Please help, I am stuck with this for quite some time.

EDIT :

Here is my project settings details

Also, I have build the project and still the problem persists.

P.S - Writing the class manually by hand , and the methods even, it compiles but everytime, I have to go to the github page, to copy paste the method signature, The problem is that with Autocomplete, i can navigate all method signatures and know about the public available methods. But I am only restricted to the example methods available in github, as everytime I have to copy paste the methods and the overwrite the implementation. Again, this compiles and runs, but the auto complete is not working, not for the class, or for the functions.


问:
Relative Paths in Javascript in an external file
So I'm running this javascript, and everything works fine, except the paths to the background image. It works on my local ASP.NET Dev environment, but it does NOT work when deployed to a server in a virtual directory.

This is in an external .js file, folder structure is

```<code>Site/Content/style.css
Site/Scripts/myjsfile.js
Site/Images/filters_expand.jpg
Site/Images/filters_colapse.jpg
</code>```

then this is where the js file is included from

```<code>Site/Views/ProductList/Index.aspx

$("#toggle").click(function() {
    if (left.width() > 0) {
        AnimateNav(left, right, 0);
        $(this).css("background", "url('../Images/filters_expand.jpg')");
    }
    else {
        AnimateNav(left, right, 170);
        $(this).css("background", "url('../Images/filters_collapse.jpg')");
    }
});
</code>```

I've tried using '/Images/filters_collapse.jpg' and that doesn't work either; however, it seems to work on the server if I use '../../Images/filters_collapse.jpg'.

Basically, I want have the same functionallity as the ASP.NET tilda -- ~.

update

Are paths in external .js files relative to the Page they are included in, or the actual location of the .js file?

答:
get the location of your javascript file during run time using jQuery by parsing the DOM for the 'src' attribute that referred it:

```<code>var jsFileLocation = $('script[src*=example]').attr('src');  // the js file path
jsFileLocation = jsFileLocation.replace('example.js', '');   // the js folder path
</code>```

(assuming your javascript file is named 'example.js')

ContentLicense: CC BY-SA 2.5

Body:
So I'm running this javascript, and everything works fine, except the paths to the background image. It works on my local ASP.NET Dev environment, but it does NOT work when deployed to a server in a virtual directory.

This is in an external .js file, folder structure is

Site/Content/style.css
Site/Scripts/myjsfile.js
Site/Images/filters_expand.jpg
Site/Images/filters_colapse.jpg

then this is where the js file is included from

Site/Views/ProductList/Index.aspx

$("#toggle").click(function() {
    if (left.width() > 0) {
        AnimateNav(left, right, 0);
        $(this).css("background", "url('../Images/filters_expand.jpg')");
    }
    else {
        AnimateNav(left, right, 170);
        $(this).css("background", "url('../Images/filters_collapse.jpg')");
    }
});

I've tried using '/Images/filters_collapse.jpg' and that doesn't work either; however, it seems to work on the server if I use '../../Images/filters_collapse.jpg'.

Basically, I want have the same functionallity as the ASP.NET tilda -- ~.

update

Are paths in external .js files relative to the Page they are included in, or the actual location of the .js file?

Body:
get the location of your javascript file during run time using jQuery by parsing the DOM for the 'src' attribute that referred it:

var jsFileLocation = $('script[src*=example]').attr('src');  // the js file path
jsFileLocation = jsFileLocation.replace('example.js', '');   // the js folder path

(assuming your javascript file is named 'example.js')


问:
what's `set ovs_ctl ${1-start}` command in linux shell mean?
I'm reading ovs' script, in start/stop script, there is :

```<code>start () {
    set ovs_ctl ${1-start}
    set "$@" --system-id=random
    ...
</code>```

what's set ovs_ctl ${1-start} means?

Thank you!

答: @spkeadoke explained it well, but maybe a little bit clearer documentation is in the bash manual 3.5.3 Shell Parameter Expansion</p>

Body:
I'm reading ovs' script, in start/stop script, there is :

start () {
    set ovs_ctl ${1-start}
    set "$@" --system-id=random
    ...

what's set ovs_ctl ${1-start} means?

Thank you!


问:
Android 4.4.4 can not connect to Nordic semi SDK 13 devices
I use the NRF-toolbox app's UART feature for connecting to Nordic-semiconductor based devices.
Android version is 4.4.4 and the device used is a Samsung device.
Everything was working fine when nordic device was using SDK 11, Softdevice S132 v3.
But after migration to SDK 13 and softdevice S132 v4.0.2, connection does not go through.
The connect request succeeds, but service discovery fails with GAT_INTERNAL_ERROR (0x81).
This is followed by a disconnection of the device (GATT_ERROR 0x85).
Same behaviour is seen through NRF-connect as well.

Is support for 4.4.4 android dropped from SDK 13, softdevice S132v4.0.2? I have searched nordic documentation but have not found anything related to my problem.

Update:
In SDK 13, a "GATT module" was introduced and is enabled by default. This was the reason for the problem. For more details - check the thread on https://devzone.nordicsemi.com/question/136600/can-not-connect-to-devices-with-sdk-13-from-android-444/

答: In SDK 13, a "GATT module" was introduced and is enabled by default. This was the reason for the problem. For more details - check the thread on https://devzone.nordicsemi.com/question/136600/can-not-connect-to-devices-with-sdk-13-from-android-444/</p>


问:
How to get an exact value from a website using php DOM and save it in a database?
I want to get the span id "CPH1_lblCurrent" from the url and save it in the database.
here is the code that i tried by seeing some examples.

```<code><?php
$file = $DOCUMENT_ROOT. "http://www.mypetrolprice.com/2/Petrol-price-in-Delhi";
$doc = new DOMDocument();
$doc->loadHTMLFile($file);

$xpath = new DOMXpath($doc);

$elements = $xpath->query('//span[@id="CPH1_lblCurrent"]');
if (!is_null($elements)) {
foreach ($elements as $element) {

$nodes = $element->childNodes;
foreach ($nodes as $node) {
echo $node->nodeValue. "\n";
}
}
}
?>
</code>```

This shows me the following.

```<code>Current Delhi Petrol Price = 67.12 Rs/Ltr
</code>```

but i want only the value 67.12.

Can somebody help me.

答:
try to use this simple regex for getting nubmer

```<code>.*= ([\d.]+) .*
</code>```

preg_match

Body:
I want to get the span id "CPH1_lblCurrent" from the url and save it in the database.
here is the code that i tried by seeing some examples.

<?php
$file = $DOCUMENT_ROOT. "http://www.mypetrolprice.com/2/Petrol-price-in-Delhi";
$doc = new DOMDocument();
$doc->loadHTMLFile($file);

$xpath = new DOMXpath($doc);

$elements = $xpath->query('//span[@id="CPH1_lblCurrent"]');
if (!is_null($elements)) {
foreach ($elements as $element) {

$nodes = $element->childNodes;
foreach ($nodes as $node) {
echo $node->nodeValue. "\n";
}
}
}
?>

This shows me the following.

Current Delhi Petrol Price = 67.12 Rs/Ltr

but i want only the value 67.12.

Can somebody help me.

Body:
try to use this simple regex for getting nubmer

.*= ([\d.]+) .*

preg_match


问:
Solr spatial search not returning any results in response element
I am using Solr version 6.2.1 and trying to return closest location for a given latitude and longitude.

I have manage to add data into Solr and indexed it.

My data file (.CSV) is in this format:

```<code>id,areaname,geo,country,state
1125257,"Mumbai","18.9750,72.8258","India","Maharashtra"
1125258,"Mumgaon","26.3833,93.4833","India","Assam"
1125259,"Mummasar","28.2167,74.2833","India","Rajasthan"
1125260,"Mummidivaram","16.6500,82.1167","India","Andhra Pradesh"
1125261,"Munaba","25.7500,70.2833","India","Rajasthan"
1125262,"Munabao","25.7500,70.2833","India","Rajasthan"
1125263,"Munabo","25.7500,70.2833","India","Rajasthan"
1125264,"Munagala","17.0500,79.8333","India","Andhra Pradesh"
</code>```

Under managed-schema file following fields are setup:

```<code><fieldType name="location" class="solr.LatLonType" subFieldSuffix="_coordinate"/>
</code>```

and field geo as:

```<code><field name="geo" type="location" indexed="true" stored="true" />
<field name="geo_0_coordinate" type="tdouble" indexed="true" stored="false" />
<field name="geo_1_coordinate" type="tdouble" indexed="true" stored="false" />
</code>```

Now when I am running my query to find closest location, it is returning nothing in response element.

```<code>{!geofilt sfield=geo}&pt=28.2167,74.2833&d=100
</code>```

No error in logs and data is indexed.

Please could someone explain me as to why this is not working.

Thanks.

答:
Solr Replace solr.LatLonType TO solr.LatLonPointSpatialField
I just used LatLonPointSpatialField to fix this problem.
Tow field _coordinate are no need.</p>

Body:
I am using Solr version 6.2.1 and trying to return closest location for a given latitude and longitude.

I have manage to add data into Solr and indexed it.

My data file (.CSV) is in this format:

id,areaname,geo,country,state
1125257,"Mumbai","18.9750,72.8258","India","Maharashtra"
1125258,"Mumgaon","26.3833,93.4833","India","Assam"
1125259,"Mummasar","28.2167,74.2833","India","Rajasthan"
1125260,"Mummidivaram","16.6500,82.1167","India","Andhra Pradesh"
1125261,"Munaba","25.7500,70.2833","India","Rajasthan"
1125262,"Munabao","25.7500,70.2833","India","Rajasthan"
1125263,"Munabo","25.7500,70.2833","India","Rajasthan"
1125264,"Munagala","17.0500,79.8333","India","Andhra Pradesh"

Under managed-schema file following fields are setup:

<fieldType name="location" class="solr.LatLonType" subFieldSuffix="_coordinate"/>

and field geo as:

<field name="geo" type="location" indexed="true" stored="true" />
<field name="geo_0_coordinate" type="tdouble" indexed="true" stored="false" />
<field name="geo_1_coordinate" type="tdouble" indexed="true" stored="false" />

Now when I am running my query to find closest location, it is returning nothing in response element.

{!geofilt sfield=geo}&pt=28.2167,74.2833&d=100

No error in logs and data is indexed.

Please could someone explain me as to why this is not working.

Thanks.


问:
String is not recognized as valid date time
Description:

In my application user is allowed to insert date in string format EX- "01/01/2000"and I'm parsing this string value using DateTime.Parse("01/01/00"); it is working fine. But in few case it is breaking.

Case 1:

Input : "01/01/00"

Code: DateTime.Parse("01/01/00");

Output: 01/01/2000

Case 2:

Input : "01/01/000"

Code: DateTime.Parse("01/01/000");

Output: Getting error "String is not recognized as valid date time."

Case 3:

Input : "01/01/0000"

Code: DateTime.Parse("01/01/0000");

Output: Getting error "String is not recognized as valid date time."

How to parse 000 or 0000 as correct year ?

答:
When you are validating date then you should keep in mind that the valid and invalid date format should be like this:

Valid Dates: "02/02/0002", "02/02/02"

Invalid Dates: "02/02/002", "02/02/00002"

Please find the code below for your reference. I think this is self-explanatory.

```<code>using System;
using System.Globalization;

class Program
{
    static void Main(string[] args)
    {
        //Valid Dates: "02/02/0002", "02/02/02"
        //Invalid Dates: "02/02/002", "02/02/00002"
        string date = "02/02/02";
        bool validDate = isDateTimeFormatValid(date);
        string status = validDate ? "valid" : "invalid";
        Console.WriteLine(date + " is " + status + " date");
        Console.ReadLine();
    }
    private static bool isDateTimeFormatValid(string date)
    {
        DateTime dateResult;
        bool chkYY = false;
        bool chkYYYY = false;
        if (date.Contains("/"))
        {
            chkYY = DateTime.TryParseExact(date, "MM/dd/yy", CultureInfo.InvariantCulture,
                             DateTimeStyles.None, out dateResult);
            chkYYYY = DateTime.TryParseExact(date, "MM/dd/yyyy", CultureInfo.InvariantCulture,
                             DateTimeStyles.None, out dateResult);
        }
        //Performing OR Operation
        bool result = chkYY | chkYYYY;
        return result;
    }
}
</code>```

Body:
When you are validating date then you should keep in mind that the valid and invalid date format should be like this:

Valid Dates: "02/02/0002", "02/02/02"

Invalid Dates: "02/02/002", "02/02/00002"

Please find the code below for your reference. I think this is self-explanatory.

using System;
using System.Globalization;

class Program
{
    static void Main(string[] args)
    {
        //Valid Dates: "02/02/0002", "02/02/02"
        //Invalid Dates: "02/02/002", "02/02/00002"
        string date = "02/02/02";
        bool validDate = isDateTimeFormatValid(date);
        string status = validDate ? "valid" : "invalid";
        Console.WriteLine(date + " is " + status + " date");
        Console.ReadLine();
    }
    private static bool isDateTimeFormatValid(string date)
    {
        DateTime dateResult;
        bool chkYY = false;
        bool chkYYYY = false;
        if (date.Contains("/"))
        {
            chkYY = DateTime.TryParseExact(date, "MM/dd/yy", CultureInfo.InvariantCulture,
                             DateTimeStyles.None, out dateResult);
            chkYYYY = DateTime.TryParseExact(date, "MM/dd/yyyy", CultureInfo.InvariantCulture,
                             DateTimeStyles.None, out dateResult);
        }
        //Performing OR Operation
        bool result = chkYY | chkYYYY;
        return result;
    }
}


问:
Difference between using [] and list() in Python when using with set() function
Could anyone tell me why this function work:

```<code>def findDisappearedNumbers(self, nums):
    return list(set(range(1,len(nums)+1)) - set(nums))
</code>```

but this function doesn't work:

```<code>def findDisappearedNums(self, nums):
    return [set(range(1, len(nums)+1)) - set(nums)]
</code>```

I would like to use [] instead of list() because [] has a better performance, but using [] with set() function would give me an error while list() with set() function works fine. Thanks.

```<code>>>> from timeit import timeit
>>> timeit("[]")
0.040084982867934334
>>> timeit("list()")
0.17704233359267718enter code here
</code>```

答:
Like what the other answers says. set(range(10)) is different from list(set(10)).

```<code>>>> set(range(10))
# Will create a set of unique numbers, obviously, from 1 to 9
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
</code>```

However,

```<code>>>> list(set(range(10))) # Or: [k for k in set(range(10))]
# Will create a list of one element, which is the set of the unique numbers
# between 1 and 9
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
</code>```

But, in your question, your benchmark isn't fully correct. You said that using list() to convert the set() to a list is slower than using [].

This kind of informations are not correct, even though your benchmark when creating an empty list is correct (creating an empty list using the constructor list() is slower than using []).

But, there is another benchmark using all form of 'tricks', that i know to convert a set into a list:

Empty lists:

```<code>>>> timeit("[]")
0.05085730400242028
>>> timeit("list()")
0.18752098699769704
</code>```

Converting a set() into a list:

```<code>>>> timeit("list(set(range(10)))")
1.9528166900017823
>>> timeit("set(range(10)).__reduce__()[1][0]")
2.8951575540013437
>>> timeit("[k for k in set(range(10))]")
2.771309465999366
</code>```

Well, as you can see, using list() is more faster than using [], also using list() is more faster than using set().__reduce__().

PS: I'm using a 32bit OS with 2GB of RAM.

Body:
Could anyone tell me why this function work:

def findDisappearedNumbers(self, nums):
    return list(set(range(1,len(nums)+1)) - set(nums))

but this function doesn't work:

def findDisappearedNums(self, nums):
    return [set(range(1, len(nums)+1)) - set(nums)]

I would like to use [] instead of list() because [] has a better performance, but using [] with set() function would give me an error while list() with set() function works fine. Thanks.

>>> from timeit import timeit
>>> timeit("[]")
0.040084982867934334
>>> timeit("list()")
0.17704233359267718enter code here

Body:
Like what the other answers says. set(range(10)) is different from list(set(10)).

>>> set(range(10))
# Will create a set of unique numbers, obviously, from 1 to 9
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}

However,

>>> list(set(range(10))) # Or: [k for k in set(range(10))]
# Will create a list of one element, which is the set of the unique numbers
# between 1 and 9
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

But, in your question, your benchmark isn't fully correct. You said that using list() to convert the set() to a list is slower than using [].

This kind of informations are not correct, even though your benchmark when creating an empty list is correct (creating an empty list using the constructor list() is slower than using []).

But, there is another benchmark using all form of 'tricks', that i know to convert a set into a list:

Empty lists:

>>> timeit("[]")
0.05085730400242028
>>> timeit("list()")
0.18752098699769704

Converting a set() into a list:

>>> timeit("list(set(range(10)))")
1.9528166900017823
>>> timeit("set(range(10)).__reduce__()[1][0]")
2.8951575540013437
>>> timeit("[k for k in set(range(10))]")
2.771309465999366

Well, as you can see, using list() is more faster than using [], also using list() is more faster than using set().__reduce__().

PS: I'm using a 32bit OS with 2GB of RAM.


问:
How secure is firebase with auth?
I am not sure where to begin but I recently saw 'Firebase' while searching for no server database, while it seems interesting to me, I was little worried about putting my api codes directly in the js files, which obviously can be seen through source but I have read that you can change the read/write rules and need authentication. so I no longer worried about API after reading through some pages

but the main question is:

I wanted to create an admin portal for my page, so example my admin page is located in localhost/admin/ <<< The page will simply have a login form which is to access the portal, so everything is set

```<code>var config = {
    apiKey: "",
    authDomain: "",
    databaseURL: "",
    projectId: "",
    storageBucket: "",
    messagingSenderId: ""
};

firebase.initializeApp(config);

firebase.auth().onAuthStateChanged(function(user) {

      if (user) {
      window.location = '/portal.html'
      }

      else {
      // Do nothing
      }
});

$("#loginbtn").click(function() {

var email = $('#login-name').val();
var password = $('#login-pass').val();

firebase.auth().signInWithEmailAndPassword(email, password)
    .catch(function(error) {
  // Handle Errors here.

});

});
</code>```

So when I log in successfully it will redirect me to that page but can someone just look through source code and then go that page manually and enter it?

Or even if I intend to build one page application and decide to change the page state after login, whatever functions i'm going to do after that, can someone still find out and inject the code ?

I'm not really expert on this but this what I was thinking before starting my project, so is there is any other way around?

答:
If you want to add admin capabilities and you are using Firebase real-time database, you need to set some custom Firebase rules to only allow admins to access restricted data. So if a non-admin user signs in, they are unable to modify/access admin only data.
One way to do this with Firebase rules is to have a /whitelist node with uid1: "bojeil@bla.com", uid2: "puf@bla.com" for storing all whitelisted admin UIDs and then a top-level security rule for restricted admin only nodes like ".write": "auth != null && root.child('whitelist').child(auth.uid).exists()". It's fairly simple, but goes a long way.

If you are not using real-time database and building a traditional web application, you need to protect restricted admin only resources. You will need to send the Firebase ID token to your backend. You can do that by setting a session cookie with its value and making sure to update that session cookie every hour or so when the Firebase ID token is refreshed. When the cookie is sent with your request, you check for it, decode it (you can use the Firebase Admin SDKs for that) and check that the user it belongs to is an admin. If so, you can allow access, otherwise you block access. On every page, you would add an onAuthStateChanged listener. If that triggers with null, you redirect to the sign-in page. If the session cookie contains an ID token for a non-admin, you can do a HTTP redirect on your server to the user non-admin section.

tldr; you need to enforce the check on your backend by sending the Firebase ID token with the request and double checking its user has adequate privileges.

Title: How secure is firebase with auth?

Body:
I am not sure where to begin but I recently saw 'Firebase' while searching for no server database, while it seems interesting to me, I was little worried about putting my api codes directly in the js files, which obviously can be seen through source but I have read that you can change the read/write rules and need authentication. so I no longer worried about API after reading through some pages

but the main question is:

I wanted to create an admin portal for my page, so example my admin page is located in localhost/admin/ <<< The page will simply have a login form which is to access the portal, so everything is set

var config = {
    apiKey: "",
    authDomain: "",
    databaseURL: "",
    projectId: "",
    storageBucket: "",
    messagingSenderId: ""
};

firebase.initializeApp(config);

firebase.auth().onAuthStateChanged(function(user) {

      if (user) {
      window.location = '/portal.html'
      }

      else {
      // Do nothing
      }
});

$("#loginbtn").click(function() {

var email = $('#login-name').val();
var password = $('#login-pass').val();

firebase.auth().signInWithEmailAndPassword(email, password)
    .catch(function(error) {
  // Handle Errors here.

});

});

So when I log in successfully it will redirect me to that page but can someone just look through source code and then go that page manually and enter it?

Or even if I intend to build one page application and decide to change the page state after login, whatever functions i'm going to do after that, can someone still find out and inject the code ?

I'm not really expert on this but this what I was thinking before starting my project, so is there is any other way around?

ContentLicense: CC BY-SA 4.0


问:
How can I check if the order email is being sent to a specific email
How can I check if the order email in magento 1.9 is being sent to a specific email and if it contains a specific text. If yes, I would like to add text to the email template. Is this possible?</p>

答:
Login Admin panel,

Go to system > Transactional Emails > Add new Template > Select New Order Template > Load Template.

After loading, you can get the template content. Also, you would be able to modify them and save.

Where to set : System > Configuration > Sales > Sales Emails > Order > New Order Confirmation Template > Here you can set you new template.

Also, insert your test email ID for testing in the field "Send Order Email Copy To".

Make an order and check the emails are getting sent or not.


问:
Facebook SDK 2.8 doesnot give email address
I am trying to implement FacbookSDK 2.8 for my website and below is the simplified version of the code.

```<code> <button onclick="logout()">Logout</button>
    <button onclick="login()">LogIn</button>
    <script>
        (function(d, s, id) {
            var js, fjs = d.getElementsByTagName(s)[0];
            if (d.getElementById(id)) return;
            js = d.createElement(s);
            js.id = id;
            js.src = "//connect.facebook.net/en_US/sdk.js";
            fjs.parentNode.insertBefore(js, fjs);
        }(document, 'script', 'facebook-jssdk'));
        setTimeout(() => {
            window.fbAsyncInit = () => {
                FB.init({
                    appId: 'xxxxxxx', //My app id here
                    cookie: true, // enable cookies to allow the server to access
                    // the session
                    xfbml: true, // parse social plugins on this page
                    version: 'v2.8' // use graph api version 2.8
                });
                checkFBLoginStatus();
            }
        })

        function checkFBLoginStatus() {
            FB.getLoginStatus((response) => {
                console.log(response)
            });
        }

        function logout() {
            FB.logout(function(response) {
                console.log(response)
            })
        }

        function login() {
            FB.login(function(response) {
                console.log(response)
                FB.api('/me?fields=id,email,name', function(response) {

                    console.log(JSON.stringify(response));
                });
            }, {
                scope: 'email'
            })
        }

        function onLoginSuccess() {
            FB.getLoginStatus(function(response) {
                console.log(response)
            })
        }
    </script>
</code>```

I am getting the response on logout and login

Here are my questions

On FB.api call i am getting only ID and Name whereas i need user email to set as an unique user identifier.

When is the condition i can achieve not_authorized. I am getting status 'connected' if i login and 'unknown' if i logout. I am not able to reproduce the condition un_authorized, so that i could code for it.

答:
You should use the ID of the user to identify him, not the email. Users do not have to have an email, they can also use their phone number to login. Make sure you get asked for the email permission in the login process/popup. Also, use this form instead:</p>

```<code>FB.api('/me', {fields: 'id,email,name'}, function(response) {
    console.log(JSON.stringify(response));
});
</code>```

Body:
I am trying to implement FacbookSDK 2.8 for my website and below is the simplified version of the code.

 <button onclick="logout()">Logout</button>
    <button onclick="login()">LogIn</button>

I am getting the response on logout and login

Here are my questions

On FB.api call i am getting only ID and Name whereas i need user email to set as an unique user identifier.

When is the condition i can achieve not_authorized. I am getting status 'connected' if i login and 'unknown' if i logout. I am not able to reproduce the condition un_authorized, so that i could code for it.

Body:
You should use the ID of the user to identify him, not the email. Users do not have to have an email, they can also use their phone number to login. Make sure you get asked for the email permission in the login process/popup. Also, use this form instead:

FB.api('/me', {fields: 'id,email,name'}, function(response) {
    console.log(JSON.stringify(response));
});


问:
Merging two multi-dimensional arrays using key and adding values
I want to merge two array's using key(product_id) and adding that values(usage).
Array 1

```
Array
(
    [0] => Array
        (
            [name] => Reschedule A Service
            [usage] => 1
            [product_id] => 8
        )

    [1] => Array
        (
            [name] => Adding An Image
            [usage] => 1
            [product_id] => 5
        )

    [2] => Array
        (
            [name] => Each Calendar Event
            [usage] => 1
            [product_id] => 14
        )

)
```

Array 2

```
Array
(
    [0] => Array
        (
            [name] => Adding An Image
            [usage] => 1
            [product_id] => 5
        )

    [1] => Array
        (
            [name] => Schedule A Service
            [usage] => 3
            [product_id] => 11
        )

    [2] => Array
        (
            [name] => Each Calendar Event
            [usage] => 2
            [product_id] => 14
        )

    [3] => Array
        (
            [name] => Sales Performance Dashboard
            [usage] => 2
            [product_id] => 30
        )

    [4] => Array
        (
            [name] => Quote
            [usage] => 1
            [product_id] => 32
        )

)
```

I need an out put like this merging and adding usage values.

```
Array
(
    [0] => Array
        (
            [name] => Adding An Image
            [usage] => 2
            [product_id] => 5
        )

    [1] => Array
        (
            [name] => Schedule A Service
            [usage] => 3
            [product_id] => 11
        )

    [2] => Array
        (
            [name] => Each Calendar Event
            [usage] => 3
            [product_id] => 14
        )

    [3] => Array
        (
            [name] => Sales Performance Dashboard
            [usage] => 2
            [product_id] => 30
        )

    [4] => Array
        (
            [name] => Quote
            [usage] => 1
            [product_id] => 32
        )

    [5] => Array
        (
            [name] => Reschedule A Service
            [usage] => 1
            [product_id] => 8
        )

)
```

This is my code for creating arrays

```

    foreach($query->rows as $product){

     $top_products[]=array(
        'name'=>$product['name'],
        'usage'=>$product['pusage'],
        'product_id'=>$product['product_id']
     );

    }

```

```

    foreach($query_2->rows as $product){

         $top_point_products[]=array(
           'name'=>$product['name'],
           'usage'=>$product['p_usage'],
           'product_id'=>$product['product_id']
         );

    }

```

答:
try this code

```<code><?php

$array1=array
(
    0 => array(
            'name' => "Reschedule A Service",
            'usage' => 1,
            'product_id' => 8
        ),

    1 => Array
        (
            'name' => "Adding An Image",
            'usage' => 1,
            'product_id' => 5
        ),

    2 => Array
        (
            'name' => "Each Calendar Event",
            'usage' => 2,
            'product_id' => 14
        )

);

$array2=array
(
    0 => Array
        (
            'name' => "Adding An Image",
            'usage' => 1,
            'product_id' => 5
        ),

    1 => Array
        (
            'name' => "Schedule A Service",
            'usage' => 3,
            'product_id' => 11
        ),

    2 => Array
        (
            'name' => "Each Calendar Event",
            'usage' => 5,
            'product_id' => 14
        ),

    3 => Array
        (
            'name' => "Sales Performance Dashboard",
            'usage' => 2,
            'product_id' => 30
        ),

    4 => Array
        (
            'name' => "Quote",
            'usage' => 1,
            'product_id' => 32
        )

);

$product_id1=array_column($array1, 'product_id');
$product_id2=array_column($array2, 'product_id');

$new=array_intersect($product_id1,$product_id2);

foreach ($new as $key => $value) {
    if(in_array($new[$key],$product_id2)){
        $array2[array_search($new[$key],$product_id2)]['usage']+=$array1[$key]['usage'];
      }
}
$new1=array_diff($product_id1,$product_id2);
foreach ($new1 as $key => $value) {
        $array2[]=$array1[$key];
 }

foreach ($array2 as $key => $value) {
    echo "[".$key."]=><br>";
    foreach ($value as $key1 => $value1) {
        echo "&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp";
        echo "[".$key1."]=>".$value1."<br>";

    }
    echo "<br>";
}
?>
</code>```

output

[0]=>
        [name]=>Adding An Image
        [usage]=>2
        [product_id]=>5

[1]=>
        [name]=>Schedule A Service
        [usage]=>3
        [product_id]=>11

[2]=>
        [name]=>Each Calendar Event
        [usage]=>7
        [product_id]=>14

[3]=>
        [name]=>Sales Performance Dashboard
        [usage]=>2
        [product_id]=>30

[4]=>
        [name]=>Quote
        [usage]=>1
        [product_id]=>32

[5]=>
        [name]=>Reschedule A Service
        [usage]=>1
        [product_id]=>8

Body:
I want to merge two array's using key(product_id) and adding that values(usage).
Array 1

Array
(
    [0] => Array
        (
            [name] => Reschedule A Service
            [usage] => 1
            [product_id] => 8
        )

    [1] => Array
        (
            [name] => Adding An Image
            [usage] => 1
            [product_id] => 5
        )

    [2] => Array
        (
            [name] => Each Calendar Event
            [usage] => 1
            [product_id] => 14
        )

)

Array 2

Array
(
    [0] => Array
        (
            [name] => Adding An Image
            [usage] => 1
            [product_id] => 5
        )

    [1] => Array
        (
            [name] => Schedule A Service
            [usage] => 3
            [product_id] => 11
        )

    [2] => Array
        (
            [name] => Each Calendar Event
            [usage] => 2
            [product_id] => 14
        )

    [3] => Array
        (
            [name] => Sales Performance Dashboard
            [usage] => 2
            [product_id] => 30
        )

    [4] => Array
        (
            [name] => Quote
            [usage] => 1
            [product_id] => 32
        )

)

I need an out put like this merging and adding usage values.

Array
(
    [0] => Array
        (
            [name] => Adding An Image
            [usage] => 2
            [product_id] => 5
        )

    [1] => Array
        (
            [name] => Schedule A Service
            [usage] => 3
            [product_id] => 11
        )

    [2] => Array
        (
            [name] => Each Calendar Event
            [usage] => 3
            [product_id] => 14
        )

    [3] => Array
        (
            [name] => Sales Performance Dashboard
            [usage] => 2
            [product_id] => 30
        )

    [4] => Array
        (
            [name] => Quote
            [usage] => 1
            [product_id] => 32
        )

    [5] => Array
        (
            [name] => Reschedule A Service
            [usage] => 1
            [product_id] => 8
        )

)

This is my code for creating arrays

    foreach($query->rows as $product){

     $top_products[]=array(
        'name'=>$product['name'],
        'usage'=>$product['pusage'],
        'product_id'=>$product['product_id']
     );

    }

    foreach($query_2->rows as $product){

         $top_point_products[]=array(
           'name'=>$product['name'],
           'usage'=>$product['p_usage'],
           'product_id'=>$product['product_id']
         );

    }

Body:
try this code

<?php

$array1=array
(
    0 => array(
            'name' => "Reschedule A Service",
            'usage' => 1,
            'product_id' => 8
        ),

    1 => Array
        (
            'name' => "Adding An Image",
            'usage' => 1,
            'product_id' => 5
        ),

    2 => Array
        (
            'name' => "Each Calendar Event",
            'usage' => 2,
            'product_id' => 14
        )

);

$array2=array
(
    0 => Array
        (
            'name' => "Adding An Image",
            'usage' => 1,
            'product_id' => 5
        ),

    1 => Array
        (
            'name' => "Schedule A Service",
            'usage' => 3,
            'product_id' => 11
        ),

    2 => Array
        (
            'name' => "Each Calendar Event",
            'usage' => 5,
            'product_id' => 14
        ),

    3 => Array
        (
            'name' => "Sales Performance Dashboard",
            'usage' => 2,
            'product_id' => 30
        ),

    4 => Array
        (
            'name' => "Quote",
            'usage' => 1,
            'product_id' => 32
        )

);

$product_id1=array_column($array1, 'product_id');
$product_id2=array_column($array2, 'product_id');

$new=array_intersect($product_id1,$product_id2);

foreach ($new as $key => $value) {
    if(in_array($new[$key],$product_id2)){
        $array2[array_search($new[$key],$product_id2)]['usage']+=$array1[$key]['usage'];
      }
}
$new1=array_diff($product_id1,$product_id2);
foreach ($new1 as $key => $value) {
        $array2[]=$array1[$key];
 }

foreach ($array2 as $key => $value) {
    echo "[".$key."]=><br>";
    foreach ($value as $key1 => $value1) {
        echo "&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp";
        echo "[".$key1."]=>".$value1."<br>";

    }
    echo "<br>";
}
?>

output

[0]=>
        [name]=>Adding An Image
        [usage]=>2
        [product_id]=>5

[1]=>
        [name]=>Schedule A Service
        [usage]=>3
        [product_id]=>11

[2]=>
        [name]=>Each Calendar Event
        [usage]=>7
        [product_id]=>14

[3]=>
        [name]=>Sales Performance Dashboard
        [usage]=>2
        [product_id]=>30

[4]=>
        [name]=>Quote
        [usage]=>1
        [product_id]=>32

[5]=>
        [name]=>Reschedule A Service
        [usage]=>1
        [product_id]=>8


问:
Create Queue and Download Agent means in TFS 2015 (on premise)
Trying to make my CI/CD work using TFS. Have to overcome some of this user role setup. Also not really getting my head around the terminology and the workflow (kinda different with how Jenkins works) and at the same time I have to figure the myriad of TFS versions(2010/2012/2013/2015/2017) and the online Visual Studio team services. I have to unlearn what I already know somehow, thus my basic questions:

What are agent queue? What are pools? (when i click create queue, it will ask me to create new pool)

What does "Download Agent" means? I thought this agent will be installed on the server side like a plugin that you install in Jenkins.

答:
The official tutorial  which involves a lot of aspects about Team Services and TFS. Most of the concepts is the same in /2013/2015/2017 and Team service. You just need pay attention to the support version under the topic such as below screenshot:

An agent queue provides access to an agent pool. When you create a
  build or release definition, you specify which queue it uses. Queues
  are scoped to your team project in TFS 2017 and in Team Services, so
  you can only use them across build and release definitions within a
  team project.

More details about agent queue and agent pool, you could refer this link: Agent pools and queues

each queue can use only one agent pool.

This is why when you click create queue, it will ask you to create new pool.

For TFS2015, you are using the private agent.

An agent that you set up and manage on your own to run build and
  deployment jobs is a private agent. You can use private agents in Team
  Services or Team Foundation Server (TFS). Private agents give you more
  control to install dependent software needed for your builds and
  deployments.

You could use the download agent to Deploy an agent on Windows. And one of the most commonly used scenes of the "Download Agent" is when you are  installing multiple private agents on the same machine.


问:
Record video in Simulator Xcode 9 Beta
Apple's Whats new in Xcode 9 states that we can record videos of Simulators. How to do that?</p>

答:
Taking a Screenshot or Recording a Video Using the Command Line:

Launch your app in Simulator.

Open terminal.

To take a screenshot, use the screenshot operation:

```<code>xcrun simctl io booted screenshot
</code>```

To record a video, use the recordVideo operation:

```<code>xcrun simctl io booted recordVideo <VideoFILENAME>.<extension>
</code>```

To stop recording, press Control-C in Terminal.

Note: It works only on Mac computers that support Metal
  . You can check your PC here.

Title: Record video in Simulator Xcode 9 Beta

Body:
Taking a Screenshot or Recording a Video Using the Command Line:

Launch your app in Simulator.

Open terminal.

To take a screenshot, use the screenshot operation:

xcrun simctl io booted screenshot

To record a video, use the recordVideo operation:

xcrun simctl io booted recordVideo <VideoFILENAME>.<extension>

To stop recording, press Control-C in Terminal.

Note: It works only on Mac computers that support Metal
  . You can check your PC here.