问:
How to deserialize a variable property in JSON like this?
I need to display this JSON to a datagridview but the properties are variables, how do I do it? This is the JSON string:</p>

```<code>{
                    "result":{"count":"57"},

                    "content_1":{
                    "message_id":"5526",
                    "originator":"09366628607",
                    "message":"Received SMS TEST",
                    "timestamp":"2017-06-11 22:49:08"
                    } ,
                    "content_2":{
                    "message_id":"5527",
                    "originator":"09366628607",
                    "message":"Received SMS TEST",
                    "timestamp":"2017-06-11 22:49:10"
                    } ,
                    "content_3":{
                    "message_id":"5528",
                    "originator":"09399139785",
                    "message":"monday 6.12.2017",
                    "timestamp":"2017-06-12 05:48:32"
                    } ,
                    "content_4":{
                    "message_id":"5529",
                    "originator":"09399139785",
                    "message":"tuesday 6.13.2017",
                    "timestamp":"2017-06-13 12:51:11"
                    } ,
                    "content_5":{
                    "message_id":"5530",
                    "originator":"09399139785",
                    "message":"TAC",
                    "timestamp":"2017-06-13 16:06:56"
                    } ,
                    "content_6":{
                    "message_id":"5531",
                    "originator":"09399139785",
                    "message":"TAC",
                    "timestamp":"2017-06-13 16:06:58"
                    } ,
                    "content_7":{
                    "message_id":"5532",
                    "originator":"09399139785",
                    "message":"TAC aprv 12345667",
                    "timestamp":"2017-06-13 16:23:16"
                    } ,
                    "content_8":{
                    "message_id":"5533",
                    "originator":"09399139785",
                    "message":"TAC inq 1242353",
                    "timestamp":"2017-06-13 16:30:54"
                    } ,
                    "content_9":{
                    "message_id":"5534",
                    "originator":"09399139785",
                    "message":"TAC caol me please asap",
                    "timestamp":"2017-06-13 18:57:39"
                    } ,
                    "content_10":{
                    "message_id":"5535",
                    "originator":"09097675705",
                    "message":"Wakoy labot nimo",
                    "timestamp":"2017-06-13 20:42:51"
                    } ,
                    "content_11":{
                    "message_id":"5536",
                    "originator":"09399139785",
                    "message":"TAC Naku, Ka-TM, temporarily suspended ang TM Easy Plan mo. Pwedeng mag-load muna at gumamit ng prepaid offers. Para maibalik ang plan, magbayad ng bill ngayong araw. Para maibalik ang plan sa susunod na billing cycle, magbayad sa pinakamalapit na 1st or 16th day of the month. I-dial ang *143# > TM Easy Plan > P150 Plan Payment or text TMPlan150 to 8080.",
                    "timestamp":"2017-06-14 06:04:06"
                    } ,
                    "content_12":{
                    "message_id":"5537",
                    "originator":"09269787659",
                    "message":"Magandang umaga dumating naba c rey pls txt b,hnd ks ako poydng 2mawag,tm at globe lang poyd",
                    "timestamp":"2017-06-14 07:54:35"
                    } ,
                    "content_13":{
                    "message_id":"5538",
                    "originator":"09399139785",
                    "message":"TAC Sir maya nlng remote kpag nandito na si sir vincent lumakad pa sila kasi ni sir dindo.",
                    "timestamp":"2017-06-14 09:32:35"
                    } ,
                    "content_14":{
                    "message_id":"5539",
                    "originator":"09399139785",
                    "message":"TAC 192.168.65.36",
                    "timestamp":"2017-06-14 09:38:02"
                    } ,
                    "content_15":{
                    "message_id":"5540",
                    "originator":"09399139785",
                    "message":"TAC Mag-BREAK na tayo! Win P15,000 travel credits this week with promo code GRABTRAVELOKA. Valid for ALL Grab rides til July 7. Learn more: grb.to/GrabTraveloka",
                    "timestamp":"2017-06-14 10:22:21"
                    } ,
                    "content_16":{
                    "message_id":"5541",
                    "originator":"09399139785",
                    "message":"TAC Your One-Time Password (OTP) is 496900, please enter within 5 minutes. Call BDO Customer Contact Center if you did not login to your account. Ref.No.352061",
                    "timestamp":"2017-06-14 15:11:56"
                    } ,
                    "content_17":{
                    "message_id":"5542",
                    "originator":"09399139785",
                    "message":"TAC can u send an email to this address asking for their menu alo_catering@yahoo.com then print it para maka choose ko",
                    "timestamp":"2017-06-14 18:14:12"
                    } ,
                    "content_18":{
                    "message_id":"5543",
                    "originator":"09399139785",
                    "message":"TAC asa naman ka oi!!!",
                    "timestamp":"2017-06-14 19:19:57"
                    } ,
                    "content_19":{
                    "message_id":"5544",
                    "originator":"09399139785",
                    "message":"CDO Roy sori dugay ko naka reply. Duna ko ka istorya sa celfon. Ug walay plan  115 thousand na ang st. Gregory",
                    "timestamp":"2017-06-14 19:50:49"
                    } ,
                    "content_20":{
                    "message_id":"5545",
                    "originator":"09399139785",
                    "message":"CDO Welcome dong",
                    "timestamp":"2017-06-14 19:51:47"
                    } ,
                    "content_21":{
                    "message_id":"5546",
                    "originator":"09756631198",
                    "message":"Magandang gabe po mam.sir wala pa po ba yung plaka ko.Friday kupa nabayaran yon",
                    "timestamp":"2017-06-14 20:48:25"
                    } ,
                    "content_22":{
                    "message_id":"5547",
                    "originator":"09399139785",
                    "message":"TAC Ayos! Pwede ka nang mag-FB up to 50MB valid hanggang 2017-06-16 10:23:39.  Pumunta sa m.facebook.com o buksan ang FB app para magsimula. For more inf",
                    "timestamp":"2017-06-15 08:48:57"
                    } ,
                    "content_23":{
                    "message_id":"5548",
                    "originator":"09399139785",
                    "message":"TAC May free access ka sa JOFOM basta't registered sa TM promo. I-download ang app o pumunta sa www.jofom.com. For info, text JOFOM INFO to 8080 for free.",
                    "timestamp":"2017-06-15 08:49:06"
                    } ,
                    "content_24":{
                    "message_id":"5549",
                    "originator":"09399139785",
                    "message":"o, i-text ang FB5 INFO sa 8080. Enjoy!",
                    "timestamp":"2017-06-15 08:49:19"
                    } ,
                    "content_25":{
                    "message_id":"5550",
                    "originator":"09399139785",
                    "message":"TAC Ayos! Pwede ka nang mag-FB up to 50MB valid hanggang 2017-06-16 10:23:39.  Pumunta sa m.facebook.com o buksan ang FB app para magsimula. For more inf",
                    "timestamp":"2017-06-16 08:46:42"
                    } ,
                    "content_26":{
                    "message_id":"5551",
                    "originator":"09399139785",
                    "message":"TAC May free access ka sa JOFOM basta't registered sa TM promo. I-download ang app o pumunta sa www.jofom.com. For info, text JOFOM INFO to 8080 for free.",
                    "timestamp":"2017-06-16 08:46:44"
                    } ,
                    "content_27":{
                    "message_id":"5552",
                    "originator":"09399139785",
                    "message":"o, i-text ang FB5 INFO sa 8080. Enjoy!",
                    "timestamp":"2017-06-16 08:46:45"
                    } ,
                    "content_28":{
                    "message_id":"5553",
                    "originator":"09399139785",
                    "message":"TAC May free access ka sa JOFOM basta't registered sa TM promo. I-download ang app o pumunta sa www.jofom.com. For info, text JOFOM INFO to 8080 for free.",
                    "timestamp":"2017-06-16 10:23:06"
                    } ,
                    "content_29":{
                    "message_id":"5556",
                    "originator":"09396483334",
                    "message":"Nakaawid nkun",
                    "timestamp":"2017-06-17 14:59:06"
                    } ,
                    "content_30":{
                    "message_id":"5557",
                    "originator":"09108651938",
                    "message":"Tumawag ako ng 21:20

Di ko kinaya ang mister ko! Dalawa ang jowa nya! Sino ba uunahin kong ligpitin? Este, awayin?
Text KABIT to 5677 now!",
                    "timestamp":"2017-06-19 21:41:14"
                    } ,
                    "content_31":{
                    "message_id":"5558",
                    "originator":"09287963825",
                    "message":"Sir leyte req for overide FDCLeyte. 1/1 SO: D000238275 PRINCEGATE BAYBAY CL: 5.00M OrderVal: 1.63M Expos: 9.14M AvailCr: -4.14M LPay: 06/06/17 HBal: 8.93M OCL: 4.14M OCTDays: 17 Amt: 8,068,994.85 .PDC Details not available or not yet maintained.Dev: CTU/83%/HNU*WBC",
                    "timestamp":"2017-06-20 09:41:31"
                    } ,
                    "content_32":{
                    "message_id":"5559",
                    "originator":"09268370555",
                    "message":"inq D00014419",
                    "timestamp":"2017-06-22 10:31:48"
                    } ,
                    "content_33":{
                    "message_id":"5560",
                    "originator":"09177174147",
                    "message":"Tawag ko later Bos, paabot pako tawag/tex APV",
                    "timestamp":"2017-06-22 14:33:43"
                    } ,
                    "content_34":{
                    "message_id":"5561",
                    "originator":"09088731986",
                    "message":"Aprv D000524568",
                    "timestamp":"2017-06-22 15:16:28"
                    } ,
                    "content_35":{
                    "message_id":"5562",
                    "originator":"09753904045",
                    "message":"Payck-23217-t000225333-18,752.86-PB-1961-7-2-17",
                    "timestamp":"2017-06-22 17:36:48"
                    } ,
                    "content_36":{
                    "message_id":"5566",
                    "originator":"09175669795",
                    "message":"Good am sir. Respectfully im endorsing for your approval. This will be collected tom. This will be delivered once payment is available. Thanks a lot. FDCGenSan. 1/1 SO: D000531595 ADOFELS S CL: 1.71M OrderVal: 0.66M Expos: 1.66M AvailCr: 0.06M LPay: 06/23/17 HBal: 2.02M OCL: -0.06M OCTDays: 10 Amt: 1,033,331.04 .PDC Details not available or not yet maintaine",
                    "timestamp":"2017-06-23 11:04:10"
                    } ,
                    "content_37":{
                    "message_id":"5568",
                    "originator":"09268605971",
                    "message":"PAYCK X 35883 T000488044 104971.54 PB-02362961 6/08/17 B.O 2118.20",
                    "timestamp":"2017-06-23 11:41:36"
                    } ,
                    "content_38":{
                    "message_id":"5569",
                    "originator":"09753904045",
                    "message":"Paych-23223-t000236553
                           t000236874
338,381.41",
                    "timestamp":"2017-06-23 17:06:25"
                    } ,
                    "content_39":{
                    "message_id":"5570",
                    "originator":"09985935310",
                    "message":"aprv D000111390",
                    "timestamp":"2017-06-24 10:20:13"
                    } ,
                    "content_40":{
                    "message_id":"5571",
                    "originator":"09177206294",
                    "message":"aprv D000111390",
                    "timestamp":"2017-06-24 11:33:28"
                    } ,
                    "content_41":{
                    "message_id":"5572",
                    "originator":"09985935310",
                    "message":"Aprv D000144122",
                    "timestamp":"2017-06-24 15:23:10"
                    } ,
                    "content_42":{
                    "message_id":"5573",
                    "originator":"09177206294",
                    "message":"Aprv D000144122",
                    "timestamp":"2017-06-24 16:22:39"
                    } ,
                    "content_43":{
                    "message_id":"5574",
                    "originator":"09985935310",
                    "message":"aprv D000112090",
                    "timestamp":"2017-06-24 17:54:52"
                    } ,
                    "content_44":{
                    "message_id":"5575",
                    "originator":"09399139785",
                    "message":"mo reply napud samar sir, wla2x man gud signal.ani bohol ug samar.. ma.resolve rani sa migration namo sa receiver sir.. probably within nxt week ma implement na guro namo..",
                    "timestamp":"2017-06-24 18:42:39"
                    } ,
                    "content_45":{
                    "message_id":"5576",
                    "originator":"09177206294",
                    "message":"aprv D000112729",
                    "timestamp":"2017-06-27 11:05:32"
                    } ,
                    "content_46":{
                    "message_id":"5577",
                    "originator":"09268370555",
                    "message":"inq D000147307",
                    "timestamp":"2017-06-27 14:45:41"
                    } ,
                    "content_47":{
                    "message_id":"5578",
                    "originator":"09177206294",
                    "message":"aprv D000112729",
                    "timestamp":"2017-06-28 10:04:14"
                    } ,
                    "content_48":{
                    "message_id":"5579",
                    "originator":"09177206294",
                    "message":"Aprv D000113015",
                    "timestamp":"2017-06-28 10:55:35"
                    } ,
                    "content_49":{
                    "message_id":"5580",
                    "originator":"09177206294",
                    "message":"Aprv D000112729",
                    "timestamp":"2017-06-28 17:26:03"
                    } ,
                    "content_50":{
                    "message_id":"5581",
                    "originator":"09177206294",
                    "message":"Aprv D000114821",
                    "timestamp":"2017-06-29 10:41:23"
                    } ,
                    "content_51":{
                    "message_id":"5582",
                    "originator":"09104082749",
                    "message":"PAYCH X 32718 T000486877 153601.46 T11126 1630.91",
                    "timestamp":"2017-06-29 15:16:28"
                    } ,
                    "content_52":{
                    "message_id":"5583",
                    "originator":"09104082749",
                    "message":"PAYCH X 32718 T000486878 0 T11661 1235.73",
                    "timestamp":"2017-06-29 15:17:57"
                    } ,
                    "content_53":{
                    "message_id":"5584",
                    "originator":"09063911933",
                    "message":"Gud evening! How about the missing proximity card?",
                    "timestamp":"2017-06-29 20:51:07"
                    } ,
                    "content_54":{
                    "message_id":"5587",
                    "originator":"09104082749",
                    "message":"PAYCH X T000486878 200.50",
                    "timestamp":"2017-06-30 12:01:25"
                    } ,
                    "content_55":{
                    "message_id":"5588",
                    "originator":"09451174941",
                    "message":"Fgg",
                    "timestamp":"2017-06-30 21:21:53"
                    } ,
                    "content_56":{
                    "message_id":"5589",
                    "originator":"09355571913",
                    "message":"Me magagawa b di umuwi kna c kim dimkauwi andon p s mao wl msakyan wl n pera ikaw 2mwag ka mama mo ito?",
                    "timestamp":"2017-07-01 00:11:51"
                    } ,
                    "content_57":{
                    "message_id":"5590",
                    "originator":"09504242133",
                    "message":"WORD Today
07/01/17
Gn 18:1-15
Mt 8:5-17
God said, Let there be light. And the universe was born!
The messenger from God said to Abraham, Sarah shall have a son, (1st Reading). And his 90-year old, barren wife gave birth to Isaac!
The angel of God said to the Virgin Mary, You will conceive and give birth to a son. And the Word became Flesh!
God's Word ",
                    "timestamp":"2017-07-01 07:30:50"
                    }
}
</code>```

答:
Using Json.NET, I think you will need to use a 2-step conversion process, since the "result" and "content_*" items are not the same type.  So, perhaps something like this:

```<code>Imports Newtonsoft.Json
Imports Newtonsoft.Json.Linq

' Class for "content_*" items
Class ContentItem
    Public Property message_id As String
    Public Property originator As String
    Public Property message As String
    Public Property timestamp As String
End Class

' Step 1 - parse JSON to a `Dictionary(Of String, JObject)`:
Dim dict = JsonConvert.DeserializeObject(Of Dictionary(Of String, JObject))(json)

' Step 2 - convert "content_*" items to ContentItem instances using LINQ query
Dim contentItems = (
    From key In dict.Keys
    Where key.StartsWith("content_")
    Select dict(key).ToObject(Of ContentItem)()
).ToList()
</code>```

You can then bind contentItems to your grid.  Perhaps there is a way to do this without the intermediate JObjects, but this isn't too ugly.

Body:
I need to display this JSON to a datagridview but the properties are variables, how do I do it? This is the JSON string:

{
                    "result":{"count":"57"},

                    "content_1":{
                    "message_id":"5526",
                    "originator":"09366628607",
                    "message":"Received SMS TEST",
                    "timestamp":"2017-06-11 22:49:08"
                    } ,
                    "content_2":{
                    "message_id":"5527",
                    "originator":"09366628607",
                    "message":"Received SMS TEST",
                    "timestamp":"2017-06-11 22:49:10"
                    } ,
                    "content_3":{
                    "message_id":"5528",
                    "originator":"09399139785",
                    "message":"monday 6.12.2017",
                    "timestamp":"2017-06-12 05:48:32"
                    } ,
                    "content_4":{
                    "message_id":"5529",
                    "originator":"09399139785",
                    "message":"tuesday 6.13.2017",
                    "timestamp":"2017-06-13 12:51:11"
                    } ,
                    "content_5":{
                    "message_id":"5530",
                    "originator":"09399139785",
                    "message":"TAC",
                    "timestamp":"2017-06-13 16:06:56"
                    } ,
                    "content_6":{
                    "message_id":"5531",
                    "originator":"09399139785",
                    "message":"TAC",
                    "timestamp":"2017-06-13 16:06:58"
                    } ,
                    "content_7":{
                    "message_id":"5532",
                    "originator":"09399139785",
                    "message":"TAC aprv 12345667",
                    "timestamp":"2017-06-13 16:23:16"
                    } ,
                    "content_8":{
                    "message_id":"5533",
                    "originator":"09399139785",
                    "message":"TAC inq 1242353",
                    "timestamp":"2017-06-13 16:30:54"
                    } ,
                    "content_9":{
                    "message_id":"5534",
                    "originator":"09399139785",
                    "message":"TAC caol me please asap",
                    "timestamp":"2017-06-13 18:57:39"
                    } ,
                    "content_10":{
                    "message_id":"5535",
                    "originator":"09097675705",
                    "message":"Wakoy labot nimo",
                    "timestamp":"2017-06-13 20:42:51"
                    } ,
                    "content_11":{
                    "message_id":"5536",
                    "originator":"09399139785",
                    "message":"TAC Naku, Ka-TM, temporarily suspended ang TM Easy Plan mo. Pwedeng mag-load muna at gumamit ng prepaid offers. Para maibalik ang plan, magbayad ng bill ngayong araw. Para maibalik ang plan sa susunod na billing cycle, magbayad sa pinakamalapit na 1st or 16th day of the month. I-dial ang *143# > TM Easy Plan > P150 Plan Payment or text TMPlan150 to 8080.",
                    "timestamp":"2017-06-14 06:04:06"
                    } ,
                    "content_12":{
                    "message_id":"5537",
                    "originator":"09269787659",
                    "message":"Magandang umaga dumating naba c rey pls txt b,hnd ks ako poydng 2mawag,tm at globe lang poyd",
                    "timestamp":"2017-06-14 07:54:35"
                    } ,
                    "content_13":{
                    "message_id":"5538",
                    "originator":"09399139785",
                    "message":"TAC Sir maya nlng remote kpag nandito na si sir vincent lumakad pa sila kasi ni sir dindo.",
                    "timestamp":"2017-06-14 09:32:35"
                    } ,
                    "content_14":{
                    "message_id":"5539",
                    "originator":"09399139785",
                    "message":"TAC 192.168.65.36",
                    "timestamp":"2017-06-14 09:38:02"
                    } ,
                    "content_15":{
                    "message_id":"5540",
                    "originator":"09399139785",
                    "message":"TAC Mag-BREAK na tayo! Win P15,000 travel credits this week with promo code GRABTRAVELOKA. Valid for ALL Grab rides til July 7. Learn more: grb.to/GrabTraveloka",
                    "timestamp":"2017-06-14 10:22:21"
                    } ,
                    "content_16":{
                    "message_id":"5541",
                    "originator":"09399139785",
                    "message":"TAC Your One-Time Password (OTP) is 496900, please enter within 5 minutes. Call BDO Customer Contact Center if you did not login to your account. Ref.No.352061",
                    "timestamp":"2017-06-14 15:11:56"
                    } ,
                    "content_17":{
                    "message_id":"5542",
                    "originator":"09399139785",
                    "message":"TAC can u send an email to this address asking for their menu alo_catering@yahoo.com then print it para maka choose ko",
                    "timestamp":"2017-06-14 18:14:12"
                    } ,
                    "content_18":{
                    "message_id":"5543",
                    "originator":"09399139785",
                    "message":"TAC asa naman ka oi!!!",
                    "timestamp":"2017-06-14 19:19:57"
                    } ,
                    "content_19":{
                    "message_id":"5544",
                    "originator":"09399139785",
                    "message":"CDO Roy sori dugay ko naka reply. Duna ko ka istorya sa celfon. Ug walay plan  115 thousand na ang st. Gregory",
                    "timestamp":"2017-06-14 19:50:49"
                    } ,
                    "content_20":{
                    "message_id":"5545",
                    "originator":"09399139785",
                    "message":"CDO Welcome dong",
                    "timestamp":"2017-06-14 19:51:47"
                    } ,
                    "content_21":{
                    "message_id":"5546",
                    "originator":"09756631198",
                    "message":"Magandang gabe po mam.sir wala pa po ba yung plaka ko.Friday kupa nabayaran yon",
                    "timestamp":"2017-06-14 20:48:25"
                    } ,
                    "content_22":{
                    "message_id":"5547",
                    "originator":"09399139785",
                    "message":"TAC Ayos! Pwede ka nang mag-FB up to 50MB valid hanggang 2017-06-16 10:23:39.  Pumunta sa m.facebook.com o buksan ang FB app para magsimula. For more inf",
                    "timestamp":"2017-06-15 08:48:57"
                    } ,
                    "content_23":{
                    "message_id":"5548",
                    "originator":"09399139785",
                    "message":"TAC May free access ka sa JOFOM basta't registered sa TM promo. I-download ang app o pumunta sa www.jofom.com. For info, text JOFOM INFO to 8080 for free.",
                    "timestamp":"2017-06-15 08:49:06"
                    } ,
                    "content_24":{
                    "message_id":"5549",
                    "originator":"09399139785",
                    "message":"o, i-text ang FB5 INFO sa 8080. Enjoy!",
                    "timestamp":"2017-06-15 08:49:19"
                    } ,
                    "content_25":{
                    "message_id":"5550",
                    "originator":"09399139785",
                    "message":"TAC Ayos! Pwede ka nang mag-FB up to 50MB valid hanggang 2017-06-16 10:23:39.  Pumunta sa m.facebook.com o buksan ang FB app para magsimula. For more inf",
                    "timestamp":"2017-06-16 08:46:42"
                    } ,
                    "content_26":{
                    "message_id":"5551",
                    "originator":"09399139785",
                    "message":"TAC May free access ka sa JOFOM basta't registered sa TM promo. I-download ang app o pumunta sa www.jofom.com. For info, text JOFOM INFO to 8080 for free.",
                    "timestamp":"2017-06-16 08:46:44"
                    } ,
                    "content_27":{
                    "message_id":"5552",
                    "originator":"09399139785",
                    "message":"o, i-text ang FB5 INFO sa 8080. Enjoy!",
                    "timestamp":"2017-06-16 08:46:45"
                    } ,
                    "content_28":{
                    "message_id":"5553",
                    "originator":"09399139785",
                    "message":"TAC May free access ka sa JOFOM basta't registered sa TM promo. I-download ang app o pumunta sa www.jofom.com. For info, text JOFOM INFO to 8080 for free.",
                    "timestamp":"2017-06-16 10:23:06"
                    } ,
                    "content_29":{
                    "message_id":"5556",
                    "originator":"09396483334",
                    "message":"Nakaawid nkun",
                    "timestamp":"2017-06-17 14:59:06"
                    } ,
                    "content_30":{
                    "message_id":"5557",
                    "originator":"09108651938",
                    "message":"Tumawag ako ng 21:20

Di ko kinaya ang mister ko! Dalawa ang jowa nya! Sino ba uunahin kong ligpitin? Este, awayin?
Text KABIT to 5677 now!",
                    "timestamp":"2017-06-19 21:41:14"
                    } ,
                    "content_31":{
                    "message_id":"5558",
                    "originator":"09287963825",
                    "message":"Sir leyte req for overide FDCLeyte. 1/1 SO: D000238275 PRINCEGATE BAYBAY CL: 5.00M OrderVal: 1.63M Expos: 9.14M AvailCr: -4.14M LPay: 06/06/17 HBal: 8.93M OCL: 4.14M OCTDays: 17 Amt: 8,068,994.85 .PDC Details not available or not yet maintained.Dev: CTU/83%/HNU*WBC",
                    "timestamp":"2017-06-20 09:41:31"
                    } ,
                    "content_32":{
                    "message_id":"5559",
                    "originator":"09268370555",
                    "message":"inq D00014419",
                    "timestamp":"2017-06-22 10:31:48"
                    } ,
                    "content_33":{
                    "message_id":"5560",
                    "originator":"09177174147",
                    "message":"Tawag ko later Bos, paabot pako tawag/tex APV",
                    "timestamp":"2017-06-22 14:33:43"
                    } ,
                    "content_34":{
                    "message_id":"5561",
                    "originator":"09088731986",
                    "message":"Aprv D000524568",
                    "timestamp":"2017-06-22 15:16:28"
                    } ,
                    "content_35":{
                    "message_id":"5562",
                    "originator":"09753904045",
                    "message":"Payck-23217-t000225333-18,752.86-PB-1961-7-2-17",
                    "timestamp":"2017-06-22 17:36:48"
                    } ,
                    "content_36":{
                    "message_id":"5566",
                    "originator":"09175669795",
                    "message":"Good am sir. Respectfully im endorsing for your approval. This will be collected tom. This will be delivered once payment is available. Thanks a lot. FDCGenSan. 1/1 SO: D000531595 ADOFELS S CL: 1.71M OrderVal: 0.66M Expos: 1.66M AvailCr: 0.06M LPay: 06/23/17 HBal: 2.02M OCL: -0.06M OCTDays: 10 Amt: 1,033,331.04 .PDC Details not available or not yet maintaine",
                    "timestamp":"2017-06-23 11:04:10"
                    } ,
                    "content_37":{
                    "message_id":"5568",
                    "originator":"09268605971",
                    "message":"PAYCK X 35883 T000488044 104971.54 PB-02362961 6/08/17 B.O 2118.20",
                    "timestamp":"2017-06-23 11:41:36"
                    } ,
                    "content_38":{
                    "message_id":"5569",
                    "originator":"09753904045",
                    "message":"Paych-23223-t000236553
                           t000236874
338,381.41",
                    "timestamp":"2017-06-23 17:06:25"
                    } ,
                    "content_39":{
                    "message_id":"5570",
                    "originator":"09985935310",
                    "message":"aprv D000111390",
                    "timestamp":"2017-06-24 10:20:13"
                    } ,
                    "content_40":{
                    "message_id":"5571",
                    "originator":"09177206294",
                    "message":"aprv D000111390",
                    "timestamp":"2017-06-24 11:33:28"
                    } ,
                    "content_41":{
                    "message_id":"5572",
                    "originator":"09985935310",
                    "message":"Aprv D000144122",
                    "timestamp":"2017-06-24 15:23:10"
                    } ,
                    "content_42":{
                    "message_id":"5573",
                    "originator":"09177206294",
                    "message":"Aprv D000144122",
                    "timestamp":"2017-06-24 16:22:39"
                    } ,
                    "content_43":{
                    "message_id":"5574",
                    "originator":"09985935310",
                    "message":"aprv D000112090",
                    "timestamp":"2017-06-24 17:54:52"
                    } ,
                    "content_44":{
                    "message_id":"5575",
                    "originator":"09399139785",
                    "message":"mo reply napud samar sir, wla2x man gud signal.ani bohol ug samar.. ma.resolve rani sa migration namo sa receiver sir.. probably within nxt week ma implement na guro namo..",
                    "timestamp":"2017-06-24 18:42:39"
                    } ,
                    "content_45":{
                    "message_id":"5576",
                    "originator":"09177206294",
                    "message":"aprv D000112729",
                    "timestamp":"2017-06-27 11:05:32"
                    } ,
                    "content_46":{
                    "message_id":"5577",
                    "originator":"09268370555",
                    "message":"inq D000147307",
                    "timestamp":"2017-06-27 14:45:41"
                    } ,
                    "content_47":{
                    "message_id":"5578",
                    "originator":"09177206294",
                    "message":"aprv D000112729",
                    "timestamp":"2017-06-28 10:04:14"
                    } ,
                    "content_48":{
                    "message_id":"5579",
                    "originator":"09177206294",
                    "message":"Aprv D000113015",
                    "timestamp":"2017-06-28 10:55:35"
                    } ,
                    "content_49":{
                    "message_id":"5580",
                    "originator":"09177206294",
                    "message":"Aprv D000112729",
                    "timestamp":"2017-06-28 17:26:03"
                    } ,
                    "content_50":{
                    "message_id":"5581",
                    "originator":"09177206294",
                    "message":"Aprv D000114821",
                    "timestamp":"2017-06-29 10:41:23"
                    } ,
                    "content_51":{
                    "message_id":"5582",
                    "originator":"09104082749",
                    "message":"PAYCH X 32718 T000486877 153601.46 T11126 1630.91",
                    "timestamp":"2017-06-29 15:16:28"
                    } ,
                    "content_52":{
                    "message_id":"5583",
                    "originator":"09104082749",
                    "message":"PAYCH X 32718 T000486878 0 T11661 1235.73",
                    "timestamp":"2017-06-29 15:17:57"
                    } ,
                    "content_53":{
                    "message_id":"5584",
                    "originator":"09063911933",
                    "message":"Gud evening! How about the missing proximity card?",
                    "timestamp":"2017-06-29 20:51:07"
                    } ,
                    "content_54":{
                    "message_id":"5587",
                    "originator":"09104082749",
                    "message":"PAYCH X T000486878 200.50",
                    "timestamp":"2017-06-30 12:01:25"
                    } ,
                    "content_55":{
                    "message_id":"5588",
                    "originator":"09451174941",
                    "message":"Fgg",
                    "timestamp":"2017-06-30 21:21:53"
                    } ,
                    "content_56":{
                    "message_id":"5589",
                    "originator":"09355571913",
                    "message":"Me magagawa b di umuwi kna c kim dimkauwi andon p s mao wl msakyan wl n pera ikaw 2mwag ka mama mo ito?",
                    "timestamp":"2017-07-01 00:11:51"
                    } ,
                    "content_57":{
                    "message_id":"5590",
                    "originator":"09504242133",
                    "message":"WORD Today
07/01/17
Gn 18:1-15
Mt 8:5-17
God said, Let there be light. And the universe was born!
The messenger from God said to Abraham, Sarah shall have a son, (1st Reading). And his 90-year old, barren wife gave birth to Isaac!
The angel of God said to the Virgin Mary, You will conceive and give birth to a son. And the Word became Flesh!
God's Word ",
                    "timestamp":"2017-07-01 07:30:50"
                    }
}

Body:
Using Json.NET, I think you will need to use a 2-step conversion process, since the "result" and "content_*" items are not the same type.  So, perhaps something like this:

Imports Newtonsoft.Json
Imports Newtonsoft.Json.Linq

' Class for "content_*" items
Class ContentItem
    Public Property message_id As String
    Public Property originator As String
    Public Property message As String
    Public Property timestamp As String
End Class

' Step 1 - parse JSON to a `Dictionary(Of String, JObject)`:
Dim dict = JsonConvert.DeserializeObject(Of Dictionary(Of String, JObject))(json)

' Step 2 - convert "content_*" items to ContentItem instances using LINQ query
Dim contentItems = (
    From key In dict.Keys
    Where key.StartsWith("content_")
    Select dict(key).ToObject(Of ContentItem)()
).ToList()

You can then bind contentItems to your grid.  Perhaps there is a way to do this without the intermediate JObjects, but this isn't too ugly.


来源: stackexchange

问:
Spring Integration DSL: how to make single-threaded caching channel?
I have the following flow config:

```<code>@Bean
public IntegrationFlow setupDatabaseFlow() {
    return IntegrationFlows.from(pubSubDatabaseRabbitOutput)
          // WHAT CHANNEL
            .handle((p, h) -> databaseActivator.recordToDatabase(p, h))
            .get();
}
</code>```

and I am willing to insert in "WHAT CHANNEL" place some channel, that is

caching

single-threaded

running in separate thread

What would be the best channel specification to use here?

答:
Not sure what is the use-case, but that can be achieved with the QueueChannel and PollingConsumer with the fixedDelay policy.

QueueChannel uses queue buffer (persistent or in-memory) to keep messages until they are consumed. A-la cache in your terms.

The PollingConsumer does the poll from the queue using TaskScheduler, therefore separate thread.

Using fixedDelay policy you ensure that the next polling task won't start until the previous has been finished. Therefore single-threaded model.

If you don't like to sleep in between polling task, and end up with the event-driven model, you can use fixedDelay(-1), this way the next polling task won't sleep after the previous. The current polling task does block the thread until the value in the queue.

UPDATE

Some code on the matter:

```<code>.channel(c -> c.queue())
.<Object>handle((p, h) -> databaseActivator.recordToDatabase(p, h),
            e -> e.poller(p -> p.fixedDelay(0).maxMessagesPerPoll(1)))
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I have the following flow config:

@Bean
public IntegrationFlow setupDatabaseFlow() {
    return IntegrationFlows.from(pubSubDatabaseRabbitOutput)
          // WHAT CHANNEL
            .handle((p, h) -> databaseActivator.recordToDatabase(p, h))
            .get();
}

and I am willing to insert in "WHAT CHANNEL" place some channel, that is

caching

single-threaded

running in separate thread

What would be the best channel specification to use here?

Body:
Not sure what is the use-case, but that can be achieved with the QueueChannel and PollingConsumer with the fixedDelay policy.

QueueChannel uses queue buffer (persistent or in-memory) to keep messages until they are consumed. A-la cache in your terms.

The PollingConsumer does the poll from the queue using TaskScheduler, therefore separate thread.

Using fixedDelay policy you ensure that the next polling task won't start until the previous has been finished. Therefore single-threaded model.

If you don't like to sleep in between polling task, and end up with the event-driven model, you can use fixedDelay(-1), this way the next polling task won't sleep after the previous. The current polling task does block the thread until the value in the queue.

UPDATE

Some code on the matter:

.channel(c -> c.queue())
.<Object>handle((p, h) -> databaseActivator.recordToDatabase(p, h),
            e -> e.poller(p -> p.fixedDelay(0).maxMessagesPerPoll(1)))


问:
Cron job every three days
Is it possible to run a cronjob every three days? Or maybe 10 times/month.</p>

答:
I am not a cron specialist, but how about:

```<code>0 */72 * * *
</code>```

It will run every 72 hours non-interrupted.

https://crontab.guru/#0_/72___

Title: Cron job every three days

Body:
I am not a cron specialist, but how about:

0 */72 * * *

It will run every 72 hours non-interrupted.

https://crontab.guru/#0_/72___


问:
Update using ajax in asp.net mvc
Hi can someone tell me the problem with this please, and how to fix it.

I'm trying to update part of the page using ajax, I'm using the basic code that comes with a new mvc project.

The logon page has this:

```<code> <span id="error"/>
@using (Ajax.BeginForm("LogOn", "Account", new AjaxOptions { UpdateTargetId="error"})) {
    <div>
        <fieldset>
            <legend>Account Information</legend>

            <div class="editor-label">
                @Html.LabelFor(m => m.UserName)
            </div>
            <div class="editor-field">
                @Html.TextBoxFor(m => m.UserName)
                @Html.ValidationMessageFor(m => m.UserName)
            </div>

            <div class="editor-label">
                @Html.LabelFor(m => m.Password)
            </div>
            <div class="editor-field">
                @Html.PasswordFor(m => m.Password)
                @Html.ValidationMessageFor(m => m.Password)
            </div>

            <div class="editor-label">
                @Html.CheckBoxFor(m => m.RememberMe)
                @Html.LabelFor(m => m.RememberMe)
            </div>

            <p>
                    <input type="submit" value="Log On" />
            </p>
        </fieldset>
    </div>
}
</code>```

and the controller like so:

```<code>        [HttpPost]
        public string LogOn(LogOnModel model, string returnUrl)
        {

            if (ModelState.IsValid)
            {
                if (MembershipService.ValidateUser(model.UserName, model.Password))
                {
                    FormsService.SignIn(model.UserName, model.RememberMe);
                    if (Url.IsLocalUrl(returnUrl))
                    {
                         Redirect(returnUrl);
                    }
                    else
                    {
                         RedirectToAction("Index", "Home");
                    }
                }
                else
                {
                    ModelState.AddModelError("", "The user name or password provided is incorrect.");
                }
            }

            return "The user name or password provided is incorrect.";
        }
</code>```

Basically what I have done is embeded the login form into a modal popup.
if the entered user credentials fail I want the error to be displayed inside the modal popup, not go off to another page.

The above code is just creating a blank page with the text "The user name or password provided is incorrect."...I need it to be displayed in the modal dialog (jQuery).

答:
This post helped me:

http://weblogs.asp.net/owscott/archive/2010/11/17/mvc-3-ajax-redirecting-instead-of-updating-div.aspx

ContentLicense: CC BY-SA 2.5

Title: Update using ajax in asp.net mvc

Body:
Hi can someone tell me the problem with this please, and how to fix it.

I'm trying to update part of the page using ajax, I'm using the basic code that comes with a new mvc project.

The logon page has this:

@using (Ajax.BeginForm("LogOn", "Account", new AjaxOptions { UpdateTargetId="error"})) {

        <fieldset>
            <legend>Account Information</legend>

                @Html.LabelFor(m => m.UserName)

                @Html.TextBoxFor(m => m.UserName)
                @Html.ValidationMessageFor(m => m.UserName)

                @Html.LabelFor(m => m.Password)

                @Html.PasswordFor(m => m.Password)
                @Html.ValidationMessageFor(m => m.Password)

                @Html.CheckBoxFor(m => m.RememberMe)
                @Html.LabelFor(m => m.RememberMe)

                    <input type="submit" value="Log On" />

        </fieldset>

}

and the controller like so:

        [HttpPost]
        public string LogOn(LogOnModel model, string returnUrl)
        {

            if (ModelState.IsValid)
            {
                if (MembershipService.ValidateUser(model.UserName, model.Password))
                {
                    FormsService.SignIn(model.UserName, model.RememberMe);
                    if (Url.IsLocalUrl(returnUrl))
                    {
                         Redirect(returnUrl);
                    }
                    else
                    {
                         RedirectToAction("Index", "Home");
                    }
                }
                else
                {
                    ModelState.AddModelError("", "The user name or password provided is incorrect.");
                }
            }

            return "The user name or password provided is incorrect.";
        }

Basically what I have done is embeded the login form into a modal popup.
if the entered user credentials fail I want the error to be displayed inside the modal popup, not go off to another page.

The above code is just creating a blank page with the text "The user name or password provided is incorrect."...I need it to be displayed in the modal dialog (jQuery).


问:
Using Hibernate 2nd Level Cache and Multitenancy
I'm presently using Hibernate with MultiTenancy options (schema per tenant in MySQL... so DB per tenant).  We have an implementation of the connection provider and tenant identifier which properly switches DB schemas for us.   Great.

Now, we want to begin exploring using 2nd Level Cache in our application.  Going through the docs, it not clear if this works properly or not.

For a given tenant database, there will be rows with given DB ids... 1,2,3 etc as primary key.  When I have two tenant DBs in play, are those entities stored separately?  Will Hibernate correctly create caches per tenant (effectively)?

答:
In section 19.4.3 "Caching", which was section 16.3.3 in some earlier versions, the Hibernate 5.2 documentation says:

Multitenancy support in Hibernate works seamlessly with the Hibernate second level cache. The key used to cache data encodes the tenant identifier.

The above quote seems definitive but in the same section an informational note adds:

Currently, schema export will not really work with multitenancy. That may not change.
  The JPA expert group is in the process of defining multitenancy
  support for an upcoming version of the specification.

The note directly addresses schema export but it's implications for the second level cache and multitenancy aren't clear. It seems to suggest that native Hibernate fully supports multitenacy but it's JPA implementation may not although I could be over reading that section.


问:
How to format the result from using Delt function in quantmod package in r
I have got a great result from using Delt function from quantmod package in R.
However, the format of the result it not quiet how I want. It is something like -0.046984753. I want the number something as -4.7% if it makes sense!

help experts!!

Thank you!

答:
Using scales

```<code> library('scales')
 result=-0.046984753
 percent(result)
 [1] "-4.7%"
</code>```

Body:
Using scales

 library('scales')
 result=-0.046984753
 percent(result)
 [1] "-4.7%"


问:
How to propogate an assumption when pattern matching in Lean
I'm trying to prove in Lean that if an item is less than the head of a sorted list, it's not a member of the list.

```<code>theorem not_in_greater {α: Type} [d: decidable_linear_order α] {x h: α} (t: list α) (Hs: is_sorted (h::t)) (Hlt: x < h) : x ∉ (h::t) :=
match t with
    | [] := not_eq_not_in (ne_of_lt Hlt)
    | (y::ys) :=
    have x_neq_h: x ≠ h, from ne_of_lt Hlt,
    have sorted_tail: is_sorted (y::ys), from _
</code>```

After matching on t, the tail of the list, as (y::ys), I expected the assumption Hs: is_sorted (h::t) to be propagated, adding is_sorted (y::ys) as an assumption (and I've found Idris does exactly this), but this seems not to be the case in Lean. Moreover the equality t = (y::ys) isn't propagated, so I'm not sure how to prove that is_sorted (y::ys).

Is there something extra I need to do when pattern matching to propagate this assumption?

I've defined is_sorted as:

```<code>inductive is_sorted {α: Type} [d: decidable_linear_order α] : list α -> Type
    | is_sorted_zero : is_sorted []
    | is_sorted_one : Π (x: α), is_sorted [x]
    | is_sorted_many : Π (x y: α) (ys: list α), x < y -> is_sorted (y::ys) -> is_sorted (x::y::ys)
</code>```

The assumptions in the context as the _ placeholder are:

```<code>α : Type,
d : decidable_linear_order α,
x h : α,
t : list α,
Hs : is_sorted (h :: t),
Hlt : x < h,
_match : ∀ (_a : list α), x ∉ h :: _a,
y : α,
ys : list α,
x_neq_h : x ≠ h
</code>```

For reference, the Idris definition of is_sorted, which produces the desired behaviour in Idris:

```<code>data IsSorted : {a: Type} -> (ltRel: (a -> a -> Type)) -> List a -> Type where
  IsSortedZero : IsSorted {a=a} ltRel Nil
  IsSortedOne : (x: a) -> IsSorted ltRel [x]
  IsSortedMany : (x: a) -> (y: a) -> .IsSorted rel (y::ys) -> .(rel x y) -> IsSorted rel (x::y::ys)
</code>```

And the Idris proof:

```<code>notInGreater : .{so: SensibleOrdering a eqRel ltRel} -> (x: a) -> (h: a) -> (t: List a) ->
               .IsSorted ltRel (h::t) -> ltRel x h -> Not (Elem x (h::t))
notInGreater {so} x h [] _ xLtH = let xNeqH = (ltNe so) xLtH in notEqNotIn x h (xNeqH)
notInGreater {so} x h (y::ys) (IsSortedMany h y yYsSorted hLtY) xLtH = elemAbsurd
  where
  xNeqH : Not (x = h)
  xNeqH = (ltNe so) xLtH

  elemAbsurd : Elem x (h::y::ys) -> a
  elemAbsurd  xElemAll = case xElemAll of
    Here {x=y} => absurd $ ((ltNe so) xLtH) Refl
    There inRest => let notInRest = notInGreater {so} x y ys yYsSorted ((ltTrans so) xLtH hLtY)
      in absurd (notInRest inRest)
</code>```

I've also tried defining the Lean one closer to the Idris definition, moving the : left to allow pattern matching:

```<code> theorem not_in_greater2 {α: Type} [d: decidable_linear_order α] : Π (x h: α) (t: list α), is_sorted (h::t) -> x < h -> ¬ list.mem x (h::t)
     | x h [] _ x_lt_h := not_eq_not_in (ne_of_lt x_lt_h)
     | x h (y::ys) (is_sorted.is_sorted_many x h (y::ys) h_lt_y rest_sorted) x_lt_h := _
</code>```

But in this case Lean complains that invalid pattern, 'x' already appeared in this pattern (also for h, y and ys). And if I e.g. rename h to h1, then it complains that given argument 'h1', expected argument 'h'. I've found it actually seems possible to work around this by making the x, y and ys arguments to is_sorted_many implicit, so they don't have to be matched upon, but that seems a bit hacky.

答:
In Lean, you need to be explicit about inaccessible terms:

```<code>theorem not_in_greater2 {α: Type} [d: decidable_linear_order α] : Π (x h: α) (t: list α), is_sorted (h::t) → x < h → ¬ list.mem x (h::t)
| x h [] _ x_lt_h := _
| x h (y::ys) (is_sorted.is_sorted_many ._ ._ ._ h_lt_y rest_sorted) x_lt_h := _
</code>```

For more information about inaccessible terms, see chapter 8.5 of https://leanprover.github.io/theorem_proving_in_lean/theorem_proving_in_lean.pdf.

Note that Lean uses inaccessible terms automatically for implicit arguments:

```<code>inductive is_sorted {α : Type} [decidable_linear_order α] : list α → Type
| zero : is_sorted []
| one (x : α) : is_sorted [x]
| many {x y : α} {ys : list α} : x < y → is_sorted (y::ys) → is_sorted (x::y::ys)

theorem not_in_greater2 {α : Type} [decidable_linear_order α] : Π (x h : α) (t : list α), is_sorted (h::t) → x < h → ¬ list.mem x (h::t)
| x h [] _ x_lt_h := not_eq_not_in (ne_of_lt x_lt_h)
| x h (y::ys) (is_sorted.many h_lt_y rest_sorted) x_lt_h := _
</code>```

Body:
I'm trying to prove in Lean that if an item is less than the head of a sorted list, it's not a member of the list.

theorem not_in_greater {α: Type} [d: decidable_linear_order α] {x h: α} (t: list α) (Hs: is_sorted (h::t)) (Hlt: x < h) : x ∉ (h::t) :=
match t with
    | [] := not_eq_not_in (ne_of_lt Hlt)
    | (y::ys) :=
    have x_neq_h: x ≠ h, from ne_of_lt Hlt,
    have sorted_tail: is_sorted (y::ys), from _

After matching on t, the tail of the list, as (y::ys), I expected the assumption Hs: is_sorted (h::t) to be propagated, adding is_sorted (y::ys) as an assumption (and I've found Idris does exactly this), but this seems not to be the case in Lean. Moreover the equality t = (y::ys) isn't propagated, so I'm not sure how to prove that is_sorted (y::ys).

Is there something extra I need to do when pattern matching to propagate this assumption?

I've defined is_sorted as:

inductive is_sorted {α: Type} [d: decidable_linear_order α] : list α -> Type
    | is_sorted_zero : is_sorted []
    | is_sorted_one : Π (x: α), is_sorted [x]
    | is_sorted_many : Π (x y: α) (ys: list α), x < y -> is_sorted (y::ys) -> is_sorted (x::y::ys)

The assumptions in the context as the _ placeholder are:

α : Type,
d : decidable_linear_order α,
x h : α,
t : list α,
Hs : is_sorted (h :: t),
Hlt : x < h,
_match : ∀ (_a : list α), x ∉ h :: _a,
y : α,
ys : list α,
x_neq_h : x ≠ h

For reference, the Idris definition of is_sorted, which produces the desired behaviour in Idris:

data IsSorted : {a: Type} -> (ltRel: (a -> a -> Type)) -> List a -> Type where
  IsSortedZero : IsSorted {a=a} ltRel Nil
  IsSortedOne : (x: a) -> IsSorted ltRel [x]
  IsSortedMany : (x: a) -> (y: a) -> .IsSorted rel (y::ys) -> .(rel x y) -> IsSorted rel (x::y::ys)

And the Idris proof:

notInGreater : .{so: SensibleOrdering a eqRel ltRel} -> (x: a) -> (h: a) -> (t: List a) ->
               .IsSorted ltRel (h::t) -> ltRel x h -> Not (Elem x (h::t))
notInGreater {so} x h [] _ xLtH = let xNeqH = (ltNe so) xLtH in notEqNotIn x h (xNeqH)
notInGreater {so} x h (y::ys) (IsSortedMany h y yYsSorted hLtY) xLtH = elemAbsurd
  where
  xNeqH : Not (x = h)
  xNeqH = (ltNe so) xLtH

  elemAbsurd : Elem x (h::y::ys) -> a
  elemAbsurd  xElemAll = case xElemAll of
    Here {x=y} => absurd $ ((ltNe so) xLtH) Refl
    There inRest => let notInRest = notInGreater {so} x y ys yYsSorted ((ltTrans so) xLtH hLtY)
      in absurd (notInRest inRest)

I've also tried defining the Lean one closer to the Idris definition, moving the : left to allow pattern matching:

 theorem not_in_greater2 {α: Type} [d: decidable_linear_order α] : Π (x h: α) (t: list α), is_sorted (h::t) -> x < h -> ¬ list.mem x (h::t)
     | x h [] _ x_lt_h := not_eq_not_in (ne_of_lt x_lt_h)
     | x h (y::ys) (is_sorted.is_sorted_many x h (y::ys) h_lt_y rest_sorted) x_lt_h := _

But in this case Lean complains that invalid pattern, 'x' already appeared in this pattern (also for h, y and ys). And if I e.g. rename h to h1, then it complains that given argument 'h1', expected argument 'h'. I've found it actually seems possible to work around this by making the x, y and ys arguments to is_sorted_many implicit, so they don't have to be matched upon, but that seems a bit hacky.

Body:
In Lean, you need to be explicit about inaccessible terms:

theorem not_in_greater2 {α: Type} [d: decidable_linear_order α] : Π (x h: α) (t: list α), is_sorted (h::t) → x < h → ¬ list.mem x (h::t)
| x h [] _ x_lt_h := _
| x h (y::ys) (is_sorted.is_sorted_many ._ ._ ._ h_lt_y rest_sorted) x_lt_h := _

For more information about inaccessible terms, see chapter 8.5 of https://leanprover.github.io/theorem_proving_in_lean/theorem_proving_in_lean.pdf.

Note that Lean uses inaccessible terms automatically for implicit arguments:

inductive is_sorted {α : Type} [decidable_linear_order α] : list α → Type
| zero : is_sorted []
| one (x : α) : is_sorted [x]
| many {x y : α} {ys : list α} : x < y → is_sorted (y::ys) → is_sorted (x::y::ys)

theorem not_in_greater2 {α : Type} [decidable_linear_order α] : Π (x h : α) (t : list α), is_sorted (h::t) → x < h → ¬ list.mem x (h::t)
| x h [] _ x_lt_h := not_eq_not_in (ne_of_lt x_lt_h)
| x h (y::ys) (is_sorted.many h_lt_y rest_sorted) x_lt_h := _


问:
Apache tomcat 8.5 user not working
I freshly installed Apache Tomcat via ansible on CentOS 7 VM but it seems that I can't access anything. I tried editing the tomcat-users.xml with

```<code><?xml version="1.0" encoding="UTF-8"?>

<tomcat-users>
    <role rolename="admin"/>
    <role rolename="admin-gui"/>
    <role rolename="manager"/>
    <role rolename="manager-gui"/>

    <user username="hultanu" password="hultanu" roles="admin,admin-gui,manager,manager-gui"/>
</tomcat-users>
</code>```

Still nothing, it keep giving me 403 when I try to access "Server Status, Manager App or Host Manager". Any ideas?

Thank you !

答:
I have just downloaded and installed a fresh/clean version of Apache 8.5.16, copied your tomcat-users.xml into my conf folder and able to browse to the server and login to the management/admin pages using the defined user (hultanu) perfectly fine. However this was done on my Windows 10 machine.

This plus the fact you are getting a 403 (Forbidden) rather than a 401 (Unauthorized) would make me think that your user settings are fine, but there is something more fundamentally wrong with your installation of Tomcat.

Are you able to browse to the tomcat instance when running and see the standard welcome screen (by default that would be localhost:8080)?

At what point do you get the 403 response (do you get asked for login details)?

Also - not sure if this is a duplicate of this question here

Title: Apache tomcat 8.5 user not working

Body:
I freshly installed Apache Tomcat via ansible on CentOS 7 VM but it seems that I can't access anything. I tried editing the tomcat-users.xml with

<?xml version="1.0" encoding="UTF-8"?>

<tomcat-users>
    <role rolename="admin"/>
    <role rolename="admin-gui"/>
    <role rolename="manager"/>
    <role rolename="manager-gui"/>

    <user username="hultanu" password="hultanu" roles="admin,admin-gui,manager,manager-gui"/>
</tomcat-users>

Still nothing, it keep giving me 403 when I try to access "Server Status, Manager App or Host Manager". Any ideas?

Thank you !


问:
Best way to convert list data to another with a desired format in c# using LINQ
How I need to insert a chart in my project and I use the C3 library to do so, which expect a specific format to work.

I retrieve my data from my database and I get it into this format

```<code>{"TotalbeAbsencesDepartmentByReason":[
[   {"Label":"DQUA","Reason":"AUT","AbsNumber":1,"AbsenceHours":3.75},
    {"Label":"DQUA","Reason":"NOAUT","AbsNumber":1,"AbsenceHours":3.75},
    {"Label":"DQUA","Reason":"CM","AbsNumber":4,"AbsenceHours":32}
],
[{"Label":"DPRO","Reason":"AUT","AbsNumber":10,"AbsenceHours":43.9},{"Label":"DPRO","Reason":"CM","AbsNumber":18,"AbsenceHours":144}],
[{"Label":"DMAI","Reason":"AUT","AbsNumber":2,"AbsenceHours":1.6999999999999993}],
[{"Label":"DENG","Reason":"CM","AbsNumber":2,"AbsenceHours":16}]
]}
</code>```

My expected format that I want to work on is :

```<code>"TotaleAbsDepartementByReason":
[
    {"Label":"DQUA","Aut":3.75,"NoAut":3.75,"CM":32},
    {"Label":"DPRO","Aut":43.9,"NoAut":0,"CM":144},
    {"Label":"DMAI","Aut":1.6999999999999993,"NoAut":0,"CM":0},
    {"Label":"DENG","Aut":0,"NoAut":0,"CM":16}
]
</code>```

This is my solution it works perfectly, But I think that there is another way to proceed for better performance :

```<code>var DeptNames = TotalbeAbsencesDepartmentByReason.Select(b => b.Label).Distinct();
var TotaleAbsDepartementByReason = new List<AbsByReason>();
foreach (var name in DeptNames)
{
    var auth = TotalbeAbsencesDepartmentByReason.Where(a => a.Label == name && a.Reason == "AUT").FirstOrDefault();
    var noauth = TotalbeAbsencesDepartmentByReason.Where(a => a.Label == name && a.Reason == "NOAUT").FirstOrDefault();
    var cm = TotalbeAbsencesDepartmentByReason.Where(a => a.Label == name && a.Reason == "CM").FirstOrDefault();
    TotaleAbsDepartementByReason.Add(new AbsByReason
    {
        Aut = auth != null ? auth.AbsenceHours.Value : 0 ,
        CM = cm != null ? cm.AbsenceHours.Value : 0,
        NoAut = noauth != null ? noauth.AbsenceHours.Value : 0,
        Label = name
    });
}
</code>```

答:
One problem I see is that you traverse the original list three times with different filter predicates. Here's a way how you can get the same result with only one list traversal:</p>

```<code>        var Depts = new Dictionary<string, AbsByReason>();
        foreach (var entry in TotalbeAbsencesDepartmentByReason)
        {
            AbsByReason abs;
            if (!Depts.TryGetValue(entry.Label, out abs))
                Depts[entry.Label] = abs = new AbsByReason() { Label = entry.Label };
            switch (entry.Reason)
            {
                case "AUT":
                    abs.Aut = entry.AbsenceHours.Value;
                    break;
                case "NOAUT":
                    abs.NoAut = entry.AbsenceHours.Value;
                    break;
                case "CM":
                    abs.CM = entry.AbsenceHours.Value;
                    break;
            }
        }
        var TotaleAbsDepartementByReason = Depts.Select(kvp => kvp.Value).ToList();
</code>```

Body:
How I need to insert a chart in my project and I use the C3 library to do so, which expect a specific format to work.

I retrieve my data from my database and I get it into this format

{"TotalbeAbsencesDepartmentByReason":[
[   {"Label":"DQUA","Reason":"AUT","AbsNumber":1,"AbsenceHours":3.75},
    {"Label":"DQUA","Reason":"NOAUT","AbsNumber":1,"AbsenceHours":3.75},
    {"Label":"DQUA","Reason":"CM","AbsNumber":4,"AbsenceHours":32}
],
[{"Label":"DPRO","Reason":"AUT","AbsNumber":10,"AbsenceHours":43.9},{"Label":"DPRO","Reason":"CM","AbsNumber":18,"AbsenceHours":144}],
[{"Label":"DMAI","Reason":"AUT","AbsNumber":2,"AbsenceHours":1.6999999999999993}],
[{"Label":"DENG","Reason":"CM","AbsNumber":2,"AbsenceHours":16}]
]}

My expected format that I want to work on is :

"TotaleAbsDepartementByReason":
[
    {"Label":"DQUA","Aut":3.75,"NoAut":3.75,"CM":32},
    {"Label":"DPRO","Aut":43.9,"NoAut":0,"CM":144},
    {"Label":"DMAI","Aut":1.6999999999999993,"NoAut":0,"CM":0},
    {"Label":"DENG","Aut":0,"NoAut":0,"CM":16}
]

This is my solution it works perfectly, But I think that there is another way to proceed for better performance :

var DeptNames = TotalbeAbsencesDepartmentByReason.Select(b => b.Label).Distinct();
var TotaleAbsDepartementByReason = new List<AbsByReason>();
foreach (var name in DeptNames)
{
    var auth = TotalbeAbsencesDepartmentByReason.Where(a => a.Label == name && a.Reason == "AUT").FirstOrDefault();
    var noauth = TotalbeAbsencesDepartmentByReason.Where(a => a.Label == name && a.Reason == "NOAUT").FirstOrDefault();
    var cm = TotalbeAbsencesDepartmentByReason.Where(a => a.Label == name && a.Reason == "CM").FirstOrDefault();
    TotaleAbsDepartementByReason.Add(new AbsByReason
    {
        Aut = auth != null ? auth.AbsenceHours.Value : 0 ,
        CM = cm != null ? cm.AbsenceHours.Value : 0,
        NoAut = noauth != null ? noauth.AbsenceHours.Value : 0,
        Label = name
    });
}

Body:
One problem I see is that you traverse the original list three times with different filter predicates. Here's a way how you can get the same result with only one list traversal:

        var Depts = new Dictionary<string, AbsByReason>();
        foreach (var entry in TotalbeAbsencesDepartmentByReason)
        {
            AbsByReason abs;
            if (!Depts.TryGetValue(entry.Label, out abs))
                Depts[entry.Label] = abs = new AbsByReason() { Label = entry.Label };
            switch (entry.Reason)
            {
                case "AUT":
                    abs.Aut = entry.AbsenceHours.Value;
                    break;
                case "NOAUT":
                    abs.NoAut = entry.AbsenceHours.Value;
                    break;
                case "CM":
                    abs.CM = entry.AbsenceHours.Value;
                    break;
            }
        }
        var TotaleAbsDepartementByReason = Depts.Select(kvp => kvp.Value).ToList();


问:
Web GL Rendering issue in Chrome 58
We have been using Web GL for one of our products and till the last update the app was working fine.

Since the last update the webgl render is pushed down to the bottom left corner and the scene is getting clipped to be only be visible in a small portion of the screen. we have no idea why this is happening and its is important that we get this fixed.

It would be a real help if some one can help us fix this issue so that it renders properly again.

It is working properly on desktop both mac and windows, on iphone is working fine. It is only present in chrome android version 58(Latest Update)

Attached below are the images, first one is the right render, and second one is wrong one.

Correct image

Problem image

Please Help

PS: we have tested this on Nexus 6

答:
The issue was because of the buffer memory in webgl for mobile devices, the line

```<code>var renderer = new THREE.WebGLRenderer({
antialias: true,
});
</code>```

was the one causing the problem.

For mobile devices which can't handle the antialias, just use

```<code>var renderer = new THREE.WebGLRenderer();
</code>```

This will solve the problem.

Title: Web GL Rendering issue in Chrome 58

Body:
The issue was because of the buffer memory in webgl for mobile devices, the line

var renderer = new THREE.WebGLRenderer({
antialias: true,
});

was the one causing the problem.

For mobile devices which can't handle the antialias, just use

var renderer = new THREE.WebGLRenderer();

This will solve the problem.


问:
Test an Angular2 Pipe that has a constructor method in Jasmine
I am falling at the first hurdle testing an Angular Pipe that has a constructor.

My Pipe is as follows:

reverse.pipe.ts

```<code>import {
  IterableDiffer,
  IterableDiffers,
  Pipe,
  PipeTransform
} from '@angular/core';

@Pipe({
  name: 'reverse',
  pure: false
})
export class ReversePipe implements PipeTransform {

  private cached: Array<any>;
  private differ: IterableDiffer<Array<any>>;

  constructor(private differs: IterableDiffers) {
    this.differ = this.differs.find([]).create(null);
  }

  transform(array: Array<any>): Array<any> {
    // TODO: Throw an error if `array` isn't an Array
    if (Array.isArray(array) === false) return [];

    const changes = this.differ.diff(array);

    if (changes) this.cached = array.slice().reverse();

    return this.cached;
  }
}
</code>```

I believe through several tutorials that it is correct to use an IterableDiffer for efficiency. But that isn't the topic of this question.

The fact that a constructor is required, I believe is the root of this simple test failing:

reverse.pipe.spec.ts

```<code>import { ReversePipe } from './reverse.pipe';

describe('ReversePipe', () => {
  it('create an instance', () => {
    const pipe = new ReversePipe();
    expect(pipe).toBeTruthy();
  });
});
</code>```

The test fails with the error: TypeError: Cannot read property 'find' of undefined

This I (probably incorrectly) assume is because differs needs injecting in the test as the error message suggests that it is undefined.

Am I along the right lines and how should I write a simple test for the Pipe?

Update

I have tried to inject IterableDiffers into the Pipe being tested; while that has rectified the previous error I am not faced with a new one Error: Can't resolve all parameters for IterableDiffers: (?).

In the terminal, the error Cannot invoke an expression whose type lacks a call signature. Type 'IterableDiffers' has no compatible call signatures. is shown.

Both are describing the same problem just in different language.

My updated test is:

reverse.pipe.spec.ts

```<code>import { IterableDiffer, IterableDiffers } from '@angular/core';
import { TestBed, inject } from '@angular/core/testing';

import { ReversePipe } from './reverse.pipe';

describe('ReversePipe', () => {
  beforeEach(() => {
    TestBed.configureTestingModule({
      providers: [IterableDiffers]
    });
  });

  // it('create an instance', () => {
  //   const array = [ 1, 2, 3 ];
  //   const pipe = new ReversePipe(new IterableDiffers);
  //   expect(pipe).toBeTruthy();
  // });

  it('create an instance', inject([IterableDiffers], (iterableDiffers: IterableDiffers) => {
    const array = [ 1, 2, 3 ];
    const pipe = new ReversePipe(iterableDiffers);

    expect(pipe).toBeTruthy();
  }));
});
</code>```

Any and all help is very much appreciated.

答:
I was very nearly there with my updated test. You do not need to provide IterableDiffers:

reverse.pipe.spec.ts

```<code>import { IterableDiffers } from '@angular/core';
import { TestBed, inject } from '@angular/core/testing';

import { ReversePipe } from './reverse.pipe';

describe('ReversePipe', () => {
  it('should create an instance', inject([ IterableDiffers ], (iterableDiffers: IterableDiffers) => {
    const pipe = new ReversePipe(iterableDiffers);

    expect(pipe).toBeTruthy();
  }));

  it('should reverse the array of type Array<number>', inject([ IterableDiffers ], (iterableDiffers: IterableDiffers) => {
    const array = [ 1, 2, 3 ];
    const pipe = new ReversePipe(iterableDiffers);

    expect(pipe.transform(array)).toEqual([ 3, 2, 1 ]);
  }));

  it('should reverse the array of type Array<string>', inject([ IterableDiffers ], (iterableDiffers: IterableDiffers) => {
    const array = [ 'apple', 'banana', 'clementine' ];
    const pipe = new ReversePipe(iterableDiffers);

    expect(pipe.transform(array)).toEqual([ 'clementine', 'banana', 'apple' ]);
  }));
});
</code>```

I also noticed I had an unnecessary if statement in reverse.pipe.spec.ts:

```<code>// TODO: Throw an error if `array` isn't an Array
if (Array.isArray(array) === false) return [];
</code>```

The first argument of transform would always be an Array; of course, the TypeScript compiler would throw a TypeError if the argument was anything other than an Array.

For completeness my Pipe is:

reverse.pipe.ts

```<code>import {
  IterableDiffer,
  IterableDiffers,
  Pipe,
  PipeTransform
} from '@angular/core';

@Pipe({
  name: 'reverse',
  pure: false
})
export class ReversePipe implements PipeTransform {

  private cached: Array<any>;
  private differ: IterableDiffer<Array<any>>;

  constructor(private differs: IterableDiffers) {
    this.differ = this.differs.find([]).create(null);
  }

  public transform(array: Array<any>): Array<any> {
    const changes = this.differ.diff(array);

    if (changes) this.cached = array.slice().reverse();

    return this.cached;
  }
}
</code>```

Body:
I am falling at the first hurdle testing an Angular Pipe that has a constructor.

My Pipe is as follows:

reverse.pipe.ts

import {
  IterableDiffer,
  IterableDiffers,
  Pipe,
  PipeTransform
} from '@angular/core';

@Pipe({
  name: 'reverse',
  pure: false
})
export class ReversePipe implements PipeTransform {

  private cached: Array<any>;
  private differ: IterableDiffer<Array<any>>;

  constructor(private differs: IterableDiffers) {
    this.differ = this.differs.find([]).create(null);
  }

  transform(array: Array<any>): Array<any> {
    // TODO: Throw an error if `array` isn't an Array
    if (Array.isArray(array) === false) return [];

    const changes = this.differ.diff(array);

    if (changes) this.cached = array.slice().reverse();

    return this.cached;
  }
}

I believe through several tutorials that it is correct to use an IterableDiffer for efficiency. But that isn't the topic of this question.

The fact that a constructor is required, I believe is the root of this simple test failing:

reverse.pipe.spec.ts

import { ReversePipe } from './reverse.pipe';

describe('ReversePipe', () => {
  it('create an instance', () => {
    const pipe = new ReversePipe();
    expect(pipe).toBeTruthy();
  });
});

The test fails with the error: TypeError: Cannot read property 'find' of undefined

This I (probably incorrectly) assume is because differs needs injecting in the test as the error message suggests that it is undefined.

Am I along the right lines and how should I write a simple test for the Pipe?

Update

I have tried to inject IterableDiffers into the Pipe being tested; while that has rectified the previous error I am not faced with a new one Error: Can't resolve all parameters for IterableDiffers: (?).

In the terminal, the error Cannot invoke an expression whose type lacks a call signature. Type 'IterableDiffers' has no compatible call signatures. is shown.

Both are describing the same problem just in different language.

My updated test is:

reverse.pipe.spec.ts

import { IterableDiffer, IterableDiffers } from '@angular/core';
import { TestBed, inject } from '@angular/core/testing';

import { ReversePipe } from './reverse.pipe';

describe('ReversePipe', () => {
  beforeEach(() => {
    TestBed.configureTestingModule({
      providers: [IterableDiffers]
    });
  });

  // it('create an instance', () => {
  //   const array = [ 1, 2, 3 ];
  //   const pipe = new ReversePipe(new IterableDiffers);
  //   expect(pipe).toBeTruthy();
  // });

  it('create an instance', inject([IterableDiffers], (iterableDiffers: IterableDiffers) => {
    const array = [ 1, 2, 3 ];
    const pipe = new ReversePipe(iterableDiffers);

    expect(pipe).toBeTruthy();
  }));
});

Any and all help is very much appreciated.

Body:
I was very nearly there with my updated test. You do not need to provide IterableDiffers:

reverse.pipe.spec.ts

import { IterableDiffers } from '@angular/core';
import { TestBed, inject } from '@angular/core/testing';

import { ReversePipe } from './reverse.pipe';

describe('ReversePipe', () => {
  it('should create an instance', inject([ IterableDiffers ], (iterableDiffers: IterableDiffers) => {
    const pipe = new ReversePipe(iterableDiffers);

    expect(pipe).toBeTruthy();
  }));

  it('should reverse the array of type Array<number>', inject([ IterableDiffers ], (iterableDiffers: IterableDiffers) => {
    const array = [ 1, 2, 3 ];
    const pipe = new ReversePipe(iterableDiffers);

    expect(pipe.transform(array)).toEqual([ 3, 2, 1 ]);
  }));

  it('should reverse the array of type Array<string>', inject([ IterableDiffers ], (iterableDiffers: IterableDiffers) => {
    const array = [ 'apple', 'banana', 'clementine' ];
    const pipe = new ReversePipe(iterableDiffers);

    expect(pipe.transform(array)).toEqual([ 'clementine', 'banana', 'apple' ]);
  }));
});

I also noticed I had an unnecessary if statement in reverse.pipe.spec.ts:

// TODO: Throw an error if `array` isn't an Array
if (Array.isArray(array) === false) return [];

The first argument of transform would always be an Array; of course, the TypeScript compiler would throw a TypeError if the argument was anything other than an Array.

For completeness my Pipe is:

reverse.pipe.ts

import {
  IterableDiffer,
  IterableDiffers,
  Pipe,
  PipeTransform
} from '@angular/core';

@Pipe({
  name: 'reverse',
  pure: false
})
export class ReversePipe implements PipeTransform {

  private cached: Array<any>;
  private differ: IterableDiffer<Array<any>>;

  constructor(private differs: IterableDiffers) {
    this.differ = this.differs.find([]).create(null);
  }

  public transform(array: Array<any>): Array<any> {
    const changes = this.differ.diff(array);

    if (changes) this.cached = array.slice().reverse();

    return this.cached;
  }
}


问:
Trigger anonymous function inside setInterval immediately
So I have a timer that looks like this

```<code>my_timer = setInterval(function(){
    do_something_amazing();
    do_more.stuff_here();
    var etc_etc = "foo" + bar;
}, 1000);
</code>```

And I want it to run immediately, and every second after that. I tried appending () to the end of the function, but that caused it to run only once (because it is not returning the function itself to the setInterval?). I then tried to return this; so that it would possibly return the function itself, but that did no good either. That was a random guess.

Is there any way I can get this to work without creating a named function? Thanks!

答:
Use arguments.callee:</p>

```<code>my_timer = setInterval((function(){
    do_something_amazing();
    do_more.stuff_here();
    var etc_etc = "foo" + bar;
    return arguments.callee;
})(), 1000);
</code>```

Body:
So I have a timer that looks like this

my_timer = setInterval(function(){
    do_something_amazing();
    do_more.stuff_here();
    var etc_etc = "foo" + bar;
}, 1000);

And I want it to run immediately, and every second after that. I tried appending () to the end of the function, but that caused it to run only once (because it is not returning the function itself to the setInterval?). I then tried to return this; so that it would possibly return the function itself, but that did no good either. That was a random guess.

Is there any way I can get this to work without creating a named function? Thanks!

Body:
Use arguments.callee:

my_timer = setInterval((function(){
    do_something_amazing();
    do_more.stuff_here();
    var etc_etc = "foo" + bar;
    return arguments.callee;
})(), 1000);


问:
Index beyond bounds while setting up a cell in my table view
While setting up a cell in my table view, I had this issue:

Log:

* Terminating app due to uncaught exception 'NSRangeException', reason: '* -[__NSArrayM objectAtIndex:]: index 5 beyond bounds [0 .. 4]'
  *** First throw call stack:
  (0x18696afd8 0x1853cc538 0x1868491f0 0x100918a30 0x10091960c 0x18cddf114 0x18cddf32c 0x18cdcca30 0x18cde431c 0x18cb7c92c 0x18ca97158 0x189c87274 0x189c7bde8 0x189c7bca8 0x189bf7360 0x189c1e3c0 0x189c1ee8c 0x1869189a0 0x186916628 0x186846db4 0x1882b0074 0x18caff130 0x1006920bc 0x18585559c)
  libc++abi.dylib: terminating with uncaught exception of type NSException

```<code>internal func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    if (tableView == tableview) {
        let cell = tableView.dequeueReusableCell(withIdentifier: "table", for: indexPath as IndexPath) as! homeTableViewCell

        if (titlearray.count != 0) {
            let tit: NSString = self.titlearray[indexPath.row] as! NSString

            print("titlearraytitlearray\(titlearray)")

            appDelegate.trendseetitarray = titlearray

            print("appDelegatetrendseearray\(appDelegate.trendseetitarray)")

            cell.treadingtitle.text! = tit as String
        }

        if (pricearray.count != 0) {
            let tit: NSString = self.pricearray[indexPath.row] as! NSString

            appDelegate.trendseepricearray = pricearray

            cell.trendingprice.text! = tit as String
        }

        if (addressarraylist.count != 0) {
            let tit: NSString = self.addressarraylist[indexPath.row] as! NSString

            appDelegate.addressarraylist = addressarraylist
        }

        if (imagearray.count != 0 && imagearray.count != nil ) {
            print(imagearray)

            let roomurl=URL(string: "\(imagearray[indexPath.row])")
            //  print("Room URL:\(roomurl!)")
            appDelegate.trendseeimagearray = imagearray

            cell.Trendingimg.sd_setImage(
                with: roomurl,
                placeholderImage: UIImage(named:"no_image.png"),
                options: SDWebImageOptions.refreshCached,
                completed: { (image1: UIImage?, error1: Error?, cacheType1: SDImageCacheType, imageURL1: URL?) -> Void in
                }
            )

            cell.Trendingimg.clipsToBounds = true;
            cell.Trendingimg.sd_setImage(with: roomurl, completed: self.block1)
        }

        return cell
    }

    return UITableViewCell()
}
</code>```

Error in:

```<code>if (addressarraylist.count != 0) {
    let tit: NSString = self.addressarraylist[indexPath.row] as! NSString

    appDelegate.addressarraylist = addressarraylist
}
</code>```

Issue as image:

答:
You can try this:-</p>

```<code>if self.addressarraylist.count > indexPath.row {
    let tit: NSString = self.addressarraylist[indexPath.row] as! NSString
    appDelegate.addressarraylist = addressarraylist
 }
</code>```

Body:
While setting up a cell in my table view, I had this issue:

Log:

* Terminating app due to uncaught exception 'NSRangeException', reason: '* -[__NSArrayM objectAtIndex:]: index 5 beyond bounds [0 .. 4]'
  *** First throw call stack:
  (0x18696afd8 0x1853cc538 0x1868491f0 0x100918a30 0x10091960c 0x18cddf114 0x18cddf32c 0x18cdcca30 0x18cde431c 0x18cb7c92c 0x18ca97158 0x189c87274 0x189c7bde8 0x189c7bca8 0x189bf7360 0x189c1e3c0 0x189c1ee8c 0x1869189a0 0x186916628 0x186846db4 0x1882b0074 0x18caff130 0x1006920bc 0x18585559c)
  libc++abi.dylib: terminating with uncaught exception of type NSException

internal func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    if (tableView == tableview) {
        let cell = tableView.dequeueReusableCell(withIdentifier: "table", for: indexPath as IndexPath) as! homeTableViewCell

        if (titlearray.count != 0) {
            let tit: NSString = self.titlearray[indexPath.row] as! NSString

            print("titlearraytitlearray\(titlearray)")

            appDelegate.trendseetitarray = titlearray

            print("appDelegatetrendseearray\(appDelegate.trendseetitarray)")

            cell.treadingtitle.text! = tit as String
        }

        if (pricearray.count != 0) {
            let tit: NSString = self.pricearray[indexPath.row] as! NSString

            appDelegate.trendseepricearray = pricearray

            cell.trendingprice.text! = tit as String
        }

        if (addressarraylist.count != 0) {
            let tit: NSString = self.addressarraylist[indexPath.row] as! NSString

            appDelegate.addressarraylist = addressarraylist
        }

        if (imagearray.count != 0 && imagearray.count != nil ) {
            print(imagearray)

            let roomurl=URL(string: "\(imagearray[indexPath.row])")
            //  print("Room URL:\(roomurl!)")
            appDelegate.trendseeimagearray = imagearray

            cell.Trendingimg.sd_setImage(
                with: roomurl,
                placeholderImage: UIImage(named:"no_image.png"),
                options: SDWebImageOptions.refreshCached,
                completed: { (image1: UIImage?, error1: Error?, cacheType1: SDImageCacheType, imageURL1: URL?) -> Void in
                }
            )

            cell.Trendingimg.clipsToBounds = true;
            cell.Trendingimg.sd_setImage(with: roomurl, completed: self.block1)
        }

        return cell
    }

    return UITableViewCell()
}

Error in:

if (addressarraylist.count != 0) {
    let tit: NSString = self.addressarraylist[indexPath.row] as! NSString

    appDelegate.addressarraylist = addressarraylist
}

Issue as image:

Body:
You can try this:-

if self.addressarraylist.count > indexPath.row {
    let tit: NSString = self.addressarraylist[indexPath.row] as! NSString
    appDelegate.addressarraylist = addressarraylist
 }


问:
Hive Count Performance and Explain indication
I have 2 tables.

The first one has an ORC format, with partitions like this : {year,month,day,type} and ~60Millions lines.

The seconde one has TextInputFormat, with partitions like this : {date,type} and ~300Millions lines.

When I do a "SELECT COUNT(*)" on this both tables, the first one gives a result after minutes.

The explain plan being :

```<code>Plan not optimized by CBO.
Vertex dependency in root stage
Reducer 2 <- Map 1 (SIMPLE_EDGE)
Stage-0
Fetch Operator
limit:-1
Stage-1
Reducer 2 vectorized
File Output Operator [FS_107648]
compressed:true
Statistics:Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: NONE
table:{"serde:":"org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe","input format:":"org.apache.hadoop.mapred.TextInputFormat","output format:":"org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat"}
Group By Operator [OP_107647]
|  aggregations:["count(VALUE._col0)"]
|  outputColumnNames:["_col0"]
|  Statistics:Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: NONE
|<-Map 1 [SIMPLE_EDGE] vectorized
Reduce Output Operator [RS_107641]
sort order:
Statistics:Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: NONE
value expressions:_col0 (type: bigint)
Group By Operator [OP_107646]
aggregations:["count()"]
outputColumnNames:["_col0"]
Statistics:Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: NONE
Select Operator [OP_107645]
Statistics:Num rows: 64930697 Data size: 158452219904 Basic stats: PARTIAL Column stats: NONE
TableScan [TS_107638]
alias:mytable
Statistics:Num rows: 64930697 Data size: 158452219904 Basic stats: PARTIAL Column stats: NONE
</code>```

When I do the same query on the second one, it gives me a result after less 5 seconds...

The explain plan being :

```<code>Plan not optimized by CBO.
Stage-0
Fetch Operator
limit:1
</code>```

I guess either the partitionning or the format are involved...
Does anyone understand the situation and so, can explain :) it to me ?

答:
You are working with hive.compute.query.using.stats=true.

Your 2nd query does nothing but fetching the rows count from the metastore

hive.compute.query.using.stats

  Default Value: false

  Added In: Hive 0.13.0 with HIVE-5483

   When set to true Hive will answer a few
  queries like min, max, and count(1) purely using statistics stored in
  the metastore. For basic statistics collection, set the configuration
  property hive.stats.autogather to true. For more advanced statistics
  collection, run ANALYZE TABLE queries.

https://cwiki.apache.org/confluence/display/Hive/Configuration+Properties#ConfigurationProperties-Statistics

Body:
I have 2 tables.

The first one has an ORC format, with partitions like this : {year,month,day,type} and ~60Millions lines.

The seconde one has TextInputFormat, with partitions like this : {date,type} and ~300Millions lines.

When I do a "SELECT COUNT(*)" on this both tables, the first one gives a result after minutes.

The explain plan being :

Plan not optimized by CBO.
Vertex dependency in root stage
Reducer 2 <- Map 1 (SIMPLE_EDGE)
Stage-0
Fetch Operator
limit:-1
Stage-1
Reducer 2 vectorized
File Output Operator [FS_107648]
compressed:true
Statistics:Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: NONE
table:{"serde:":"org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe","input format:":"org.apache.hadoop.mapred.TextInputFormat","output format:":"org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat"}
Group By Operator [OP_107647]
|  aggregations:["count(VALUE._col0)"]
|  outputColumnNames:["_col0"]
|  Statistics:Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: NONE
|<-Map 1 [SIMPLE_EDGE] vectorized
Reduce Output Operator [RS_107641]
sort order:
Statistics:Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: NONE
value expressions:_col0 (type: bigint)
Group By Operator [OP_107646]
aggregations:["count()"]
outputColumnNames:["_col0"]
Statistics:Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: NONE
Select Operator [OP_107645]
Statistics:Num rows: 64930697 Data size: 158452219904 Basic stats: PARTIAL Column stats: NONE
TableScan [TS_107638]
alias:mytable
Statistics:Num rows: 64930697 Data size: 158452219904 Basic stats: PARTIAL Column stats: NONE

When I do the same query on the second one, it gives me a result after less 5 seconds...

The explain plan being :

Plan not optimized by CBO.
Stage-0
Fetch Operator
limit:1

I guess either the partitionning or the format are involved...
Does anyone understand the situation and so, can explain :) it to me ?


问:
Round off the area points in Highcharts Polar
Is there is a way to round off the area points and make them less pointed when used in the polar chart?

I have tried the 'areaspline', but with polar chart it's not quite right, as you can see here:

http://jsfiddle.net/qwbu6r3t/2/

```<code>Highcharts.chart('container', {

    chart: {
        polar: true
    },

    title: {
        text: 'Highcharts Polar Chart'
    },

    pane: {
        startAngle: 0,
        endAngle: 360
    },

    xAxis: {
        tickInterval: 45,
        min: 0,
        max: 360,
        labels: {
            formatter: function () {
                return this.value + '°';
            }
        }
    },

    yAxis: {
        min: 0
    },

    plotOptions: {
        series: {
            pointStart: 0,
            pointInterval: 45
        }
    },

    series: [{
        type: 'areaspline',
        name: 'Area spline',
        data: [1, 2, 3, 4, 5, 6, 7, 8]
    }, {
        type: 'area',
        name: 'Area',
        data: [1, 8, 2, 7, 3, 6, 4, 5]
    }]
});
</code>```

EDIT

What I need

答: just change area to areaspline would do what you want i think so

Body:
Is there is a way to round off the area points and make them less pointed when used in the polar chart?

I have tried the 'areaspline', but with polar chart it's not quite right, as you can see here:

http://jsfiddle.net/qwbu6r3t/2/

Highcharts.chart('container', {

    chart: {
        polar: true
    },

    title: {
        text: 'Highcharts Polar Chart'
    },

    pane: {
        startAngle: 0,
        endAngle: 360
    },

    xAxis: {
        tickInterval: 45,
        min: 0,
        max: 360,
        labels: {
            formatter: function () {
                return this.value + '°';
            }
        }
    },

    yAxis: {
        min: 0
    },

    plotOptions: {
        series: {
            pointStart: 0,
            pointInterval: 45
        }
    },

    series: [{
        type: 'areaspline',
        name: 'Area spline',
        data: [1, 2, 3, 4, 5, 6, 7, 8]
    }, {
        type: 'area',
        name: 'Area',
        data: [1, 8, 2, 7, 3, 6, 4, 5]
    }]
});

EDIT

What I need


问:
Receiving UDP packets at high frequency : packet loss?
I have a C++ application which uses a UDP Server (using Boost.Asio) that receives packets from a gigabit local network device at a high frequency (3500 packets per second). Some users report a few packet losses. So in the end I chose to run in parallel WireShark and my application to check if there are any packets that WireShark is able to receive but not my application.

What I found is that WireShark does not receive every packet, it seems that it misses some. My application misses also a few more frames that Wireshark received correctly.

My questions : Is it possible WireShark gets packets that my application does not ? I thought maybe WireShark has low-level access to the IP stack and packets are discarded by the OS even if they are shown in WireShark ?
Is it possible that the operation in (1) takes too much time such that the next async_receive_from is called too late?
I would like to have opinions on this subject. Thanks.

Here is the code I use (quite basic). udp_server.h :

```<code>#pragma once

#include <boost/asio.hpp>
#include <boost/bind.hpp>
#include <fstream>

const int MAX_BUFFER_SIZE = 65537;

using boost::asio::ip::udp;

class UDPServer
{
public:
    UDPServer(boost::asio::io_service& ios, udp::endpoint endpoint)
        :m_io_service(ios),
        m_udp_socket(m_io_service, endpoint)
    {
        // Resize the buffer to max size in the component property
        m_recv_buffer.resize(MAX_BUFFER_SIZE);

        m_output_file.open("out.bin", std::ios::out | std::ios::binary);

        StartReceive();
    }

public:
    void StartReceive()
    {
        m_udp_socket.async_receive_from(
            boost::asio::buffer(m_recv_buffer), m_remote_endpoint,
            boost::bind(&UDPServer::HandleReceive, this,
            boost::asio::placeholders::error,
            boost::asio::placeholders::bytes_transferred));
    }

private:
    void HandleReceive(const boost::system::error_code& error, std::size_t bytes_transferred)
    {
        if (!error || error == boost::asio::error::message_size)
        {
            // Write to output -- (1)
            m_output_file.sputn(&m_recv_buffer[0], bytes_transferred);

            // Start to receive again
            StartReceive();
        }
    }

    boost::asio::io_service&    m_io_service;
    udp::socket                 m_udp_socket;
    udp::endpoint               m_remote_endpoint;
    std::vector<char>           m_recv_buffer;
    std::filebuf                m_output_file;
};
</code>```

main.cpp:

```<code>include <boost/asio.hpp>
#include "udp_server.h"

const unsigned short PORT_NUMBER = 44444;

int main()
{
    boost::asio::io_service ios;
    boost::asio::ip::udp::endpoint endpoint(udp::endpoint(udp::v4(), PORT_NUMBER));
    UDPServer server(ios, endpoint);
    ios.run();

    return 0;
}
</code>```

答: How much bytes in a packet? You make a buffer as 64K, let the size be 32K. Then 3.5k * 32k means 112MB/s, I don't think a gigabit network afford it. And, you write packets to a file, the sputn may block you from receiving more packets, consequently the buffer of the driver overflowed, packets discarded.

Body:
I have a C++ application which uses a UDP Server (using Boost.Asio) that receives packets from a gigabit local network device at a high frequency (3500 packets per second). Some users report a few packet losses. So in the end I chose to run in parallel WireShark and my application to check if there are any packets that WireShark is able to receive but not my application.

What I found is that WireShark does not receive every packet, it seems that it misses some. My application misses also a few more frames that Wireshark received correctly.

My questions : Is it possible WireShark gets packets that my application does not ? I thought maybe WireShark has low-level access to the IP stack and packets are discarded by the OS even if they are shown in WireShark ?
Is it possible that the operation in (1) takes too much time such that the next async_receive_from is called too late?
I would like to have opinions on this subject. Thanks.

Here is the code I use (quite basic). udp_server.h :

#pragma once

#include <boost/asio.hpp>
#include <boost/bind.hpp>
#include <fstream>

const int MAX_BUFFER_SIZE = 65537;

using boost::asio::ip::udp;

class UDPServer
{
public:
    UDPServer(boost::asio::io_service& ios, udp::endpoint endpoint)
        :m_io_service(ios),
        m_udp_socket(m_io_service, endpoint)
    {
        // Resize the buffer to max size in the component property
        m_recv_buffer.resize(MAX_BUFFER_SIZE);

        m_output_file.open("out.bin", std::ios::out | std::ios::binary);

        StartReceive();
    }

public:
    void StartReceive()
    {
        m_udp_socket.async_receive_from(
            boost::asio::buffer(m_recv_buffer), m_remote_endpoint,
            boost::bind(&UDPServer::HandleReceive, this,
            boost::asio::placeholders::error,
            boost::asio::placeholders::bytes_transferred));
    }

private:
    void HandleReceive(const boost::system::error_code& error, std::size_t bytes_transferred)
    {
        if (!error || error == boost::asio::error::message_size)
        {
            // Write to output -- (1)
            m_output_file.sputn(&m_recv_buffer[0], bytes_transferred);

            // Start to receive again
            StartReceive();
        }
    }

    boost::asio::io_service&    m_io_service;
    udp::socket                 m_udp_socket;
    udp::endpoint               m_remote_endpoint;
    std::vector<char>           m_recv_buffer;
    std::filebuf                m_output_file;
};

main.cpp:

include <boost/asio.hpp>
#include "udp_server.h"

const unsigned short PORT_NUMBER = 44444;

int main()
{
    boost::asio::io_service ios;
    boost::asio::ip::udp::endpoint endpoint(udp::endpoint(udp::v4(), PORT_NUMBER));
    UDPServer server(ios, endpoint);
    ios.run();

    return 0;
}


问:
add 'tools:replace="Android:value"' to <meta-data> element at AndroidManifest
I'm following a tutorial in HeadFirst Android development and encountered issues after adding:
    private ActionBarDrawerToggle drawerToggle;

The control was deprecated so I followed instructions on Stack to resolve that issue by adding com.android.support:appcompat-v7:26.0.0-alpha1 to the app modules Dependencies

But now I'm getting the following build errors:

Error:Execution failed for task ':app:processDebugManifest'.

Manifest merger failed : Attribute meta-data#android.support.VERSION@value value=(25.3.1) from [com.android.support:recyclerview-v7:25.3.1] AndroidManifest.xml:24:9-31
      is also present at [com.android.support:appcompat-v7:26.0.0-alpha1] AndroidManifest.xml:27:9-38 value=(26.0.0-alpha1).
      Suggestion: add 'tools:replace="android:value"' to  element at AndroidManifest.xml:22:5-24:34 to override.

Here is the code:

答:
Changed all support library versions to 25.3.1 and worked like a charm:

```<code>compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
</code>```

You also need to change the following parameters to 25:

```<code>compileSdkVersion 25
targetSdkVersion 25
</code>```

Body:
Changed all support library versions to 25.3.1 and worked like a charm:

compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'

You also need to change the following parameters to 25:

compileSdkVersion 25
targetSdkVersion 25