text:
Q: Insert large record into mongodb using mongo shell I'm trying to insert large polygon array into my collection. I'm using following command to insert the data...
db.geoPolygonData.insert({"polygonName":"location1", "polygons":{"type":"Polygon", coordinates:[[[ 17.60083012593064, 78.18557739257812], [ 17.16834652544664, 78.19381713867188], [ 17.17490690610013, 78.739013671875], [ 17.613919673106714, 78.73489379882812],[ 17.60083012593064, 78.18557739257812]]]}});
WriteResult({ "nInserted" : 1 })

*

*Problem: when the polygon array size is too large then not able paste that in the insert command.

db.geoPolygonData.insert({"polygonName":"location1", "polygons":{"type":"Polygon", coordinates:[[27.24391676007466, 77.99706560813125], [27.24663657232702, 77.99603771498144], [27.247562169041, 77.99579619785604], [27.24812715892217, 77.9953496989439], [27.24815137812172, 77.99495972468578], [27.24786408813674, 77.9942950687252], [27.24728295413829, 77.99401316495602], [27.24691626810016, 77.99409211782215], [27.24630787932104, 77.99434214769431], [27.24578183050557, 77.99445233957894], [27.24506545801119, 77.99455743098659], [27.24436725351516, 77.99441937620895], [27.24428512657685, 77.99339215109099], [27.24416758939267, 77.99335786813789], [27.24388134647987, 77.99340468780039], [27.24364577274164, 77.99335946000515], [27.24338072207595, 77.99339127980087], [27.24307924134828, 77.99349996041506], [27.24289895965795, 77.99347178104993], [27.24242531545428, 77.99349801394814], [27.24226589308678, 77.9934703935053], [27.24224091007617, 77.99333740322909], [27.24262872921169, 77.9924448883617], [27.24346377039268, 77.99080931883213], [27.24277480621489, 77.99016819114682], [27.24236626279172, 77.98975251327597], [27.24184037267633, 77.98896787149644], [27.24208060195639, 77.98879527249848], [27.24264732258803, 77.98832005673326], [27.2427620622403, 77.98815966761026], [27.24277061841023, 77.98775903791018], [27.24286204153501, 77.9872244087011], [27.24289782642137, 77.9868517488547], [27.24293484509637, 77.98658420129162], [27.24290480133503, 77.98652502094515], [27.24277087525858, 77.98644360578182], [27.24250037654928, 77.98624178714861], [27.24216696692127, 77.98605385611691], [27.24201267904537, 77.98594854734944], [27.24187751713501, 77.9857620219303], [27.24159072245221, 77.98534572280121], [27.24138041126056, 77.98493146821534], [27.24194752676157, 77.98460024188113], [27.24212161328115, 77.98442975868801], [27.24185542511326, 77.98402568725903], [27.24169750036504, 77.98376461240707], [27.24140970399648, 77.9833949934572], [27.24088707995773, 77.98278171147012], [27.24062363684074, 77.98240866091682], [27.24088987367768, 77.9822027094119], [27.24115026007457, 77.9818989504684], [27.24134493499909, 77.98169996525266], [27.24181036156287, 77.98182778642682], [27.24182434241625, 77.98154408370043], [27.24177771643389, 77.981125603911], [27.24179981514432, 77.98083324019257], [27.24173090014172, 77.98071599666811], [27.24177489872516, 77.98051299053564], [27.24188309507776, 77.98027618643594], [27.24195427841228, 77.98028696177776], [27.24196900495651, 77.98034061874148], [27.2420479295497, 77.98036047793835], [27.24213932024148, 77.98016761203432], [27.24228905710167, 77.97984314018316], [27.24258173204895, 77.97914074792912], [27.24321086306847, 77.9794060864327], [27.24350938865228, 77.97880149586724], [27.24358755785651, 77.97885684431792], [27.24378053236036, 77.97836484552957], [27.24366157829446, 77.97836167565461], [27.24377996811734, 77.97801860652774], [27.24384208985404, 77.9777095477021], [27.24369254765399, 77.97765229839226], [27.24382547432796, 77.9769989014064], [27.24388211764866, 77.97657428762763], [27.24390892597918, 77.97606010329555], [27.24428920227233, 77.9760879843636], [27.24419894168467, 77.97548190529714], [27.24408432732331, 77.97527466974142], [27.24337190002105, 77.97407499443753], [27.24333922665217, 77.97374565668366], [27.24261983184003, 77.97361998718297], [27.24235020142166, 77.97361281395445], [27.24166139609085, 77.97354122514088], [27.24163740551786, 77.97317661395424], [27.24070275998563, 77.97309849000847], [27.24016878354814, 77.97302214698475], [27.24015063440687, 77.97238250053793], [27.24006658996276, 77.97185650683522], [27.24004089870061, 77.97157175117869], [27.24000424469154, 77.97105589519276], [27.23973197596943, 77.97117294032903], [27.23962643244647, 77.9712855392159], [27.23934303014902, 77.97155320020754], [27.23919046971809, 77.97163791691194], [27.23890483621163, 77.97183472028493], [27.23793384110247, 77.9714278759281], [27.23791915121764, 77.97134668732562], [27.23796719530922, 77.97113935224066], [27.23804486949654, 77.97065761379115], [27.23804420052079, 77.97050224647363], [27.2380522150586, 77.97031160139083], [27.23770525776551, 77.9702091736292], [27.23712180256475, 77.97003388585033], [27.23645177225287, 77.96982523100517], [27.23605855024003, 77.96965943908992], [27.23608137700895, 77.96933159768798], [27.2360918246972, 77.96883920343133], [27.23603734752186, 77.96878893355198], [27.2358053785725, 77.96868956611098], [27.23565177194435, 77.96863666440206], [27.23556642021527, 77.96854562890074], [27.23537476146519, 77.96841626348875], [27.23522284841485, 77.96828351524798], [27.23511455216204, 77.96815192526456], [27.23500219649088, 77.9680246662129], [27.23489352361323, 77.96791082050332], [27.2347719202275, 77.96784545457116], [27.23466570711387, 77.96780268945206], [27.23471252266857, 77.96765302538556], [27.2340761691697, 77.96716566460886], [27.23389234509042, 77.96704094974878], [27.23364087509413, 77.96748699283201], [27.23331259700067, 77.96725192352372], [27.2334079345315, 77.96705916465518], [27.23281850210135, 77.96660412688988], [27.23273344656863, 77.96668619913619], [27.23243282901324, 77.96645630639951], [27.23213580006381, 77.96624426347921], [27.23129135296767, 77.96565376169849], [27.23045417510392, 77.96509452994871], [27.22967337141958, 77.96468326330394], [27.22948926242537, 77.96457186518343], [27.22914047490189, 77.96418093282234], [27.22888091296686, 77.96388556984002], [27.22858540191636, 77.96378897455655], [27.22831058224185, 77.96383938830616], [27.22804388081856, 77.96388114065904], [27.22775120771441, 77.9638378795061], [27.22740367930377, 77.96376209800862], [27.22675648634716, 77.9635984905796], [27.2261006112913, 77.96347016019317], [27.22559285694918, 77.9632791845895], [27.22513165169155, 77.96313826268813], [27.22485718621491, 77.9629845364143], [27.22455515187099, 77.9628212046522], [27.22420307170152, 77.96258553997579], [27.22406691814265, 77.96245766949579], [27.22390981196892, 77.96238250064044], [27.22375988517349, 77.96234302621373], [27.2234206610684, 77.96224972120102], [27.22310785618344, 77.96203285287488], [27.22292799082263, 77.96190826504457], [27.22230453809463, 77.96212253181022], [27.2224107774854, 77.96160166599452], [27.22159352090845, 77.96122499693422], [27.22171930137752, 77.96071796420925], [27.22168908067144, 77.96064615753836], [27.22167877979222, 77.96057044012998], [27.22151618066637, 77.96037974443419], [27.22126946759449, 77.96022676491796], [27.22096942447697, 77.96015669527112], [27.22025899461001, 77.96016896361162], [27.22014484750736, 77.96012600267605], [27.21990255214584, 77.96051456170167], [27.21985206171045, 77.96065079925681], [27.2197348443701, 77.96094059571483], [27.21928675017983, 77.96074234826042], [27.21895526695234, 77.96065813362198], [27.2187265039849, 77.96059438879095], [27.21870169683053, 77.96007894618809], [27.21851302794826, 77.95980768654744], [27.21823400232318, 77.95949409770859], [27.21828296399789, 77.95924243826661], [27.21833011616025, 77.95888866130005], [27.21846909508166, 77.95831985944943], [27.2185447803676, 77.95811772123702], [27.21881595020102, 77.9576766703609], [27.21870273910345, 77.95758935918295], [27.21872047406592, 77.95750107158179], [27.21852842682649, 77.95738948784111], [27.21870630270251, 77.95685721314206], [27.21854635139379, 77.95672872738318], [27.21834134627352, 77.95647923072106], [27.21822259534839, 77.95633665279307], [27.21817714830512, 77.95636394713932], [27.21793996833566, 77.95651078428196], [27.21769910404083, 77.95664421013346], [27.21747410056894, 77.95677805456684], [27.21718285909136, 77.95685467612577], [27.21698974929357, 77.9568872941336], [27.21691757893229, 77.95692310789576], [27.21616501315811, 77.95677008997329], [27.21586029938408, 77.95673319347618], [27.21570490571156, 77.95704638324507], [27.21548236703363, 77.95753308641565], [27.21533249791063, 77.95786638953417], [27.21522331114027, 77.95815195267147], [27.21510431895429, 77.95852600945611], [27.21496474985562, 77.95893502265513], [27.21480791252444, 77.95941014299767], [27.21454350393353, 77.96028180499641], [27.21453718099778, 77.96029938832348], [27.21393904923445, 77.95997293271769], [27.21402717455296, 77.96162162244295], [27.21402140620174, 77.96226936260713], [27.21404592542554, 77.96279808861533], [27.21410080075447, 77.9637669430382], [27.21409368653921, 77.96429039379774], [27.2140830539672, 77.96460518308498], [27.2141266185798, 77.96498353481704], [27.21412400877715, 77.96529409897698], [27.21413167723125, 77.96549399499717], [27.21392368226408, 77.96538641838274], [27.21280186582671, 77.96496618798521], [27.21242742567541, 77.96484976696418], [27.21213447029789, 77.96481981861358], [27.21196595963191, 77.96490854290111], [27.21170610236684, 77.96537647394946], [27.21142981925112, 77.9658705925539], [27.21088553390126, 77.96571860754503], [27.21053885073018, 77.96560292213167], [27.21021124198086, 77.96552324259734], [27.20999511525522, 77.96548916774981], [27.20990676685457, 77.96547523866558], [27.20956188828616, 77.96546166415936], [27.20944601809946, 77.96606208501102], [27.20943514158481, 77.96605612438955], [27.20943563421359, 77.9660840001905], [27.20926297016088, 77.96711778150592], [27.20886621281779, 77.96861598144132], [27.20853150733383, 77.96943245883226], [27.2083181600282, 77.97023218010102], [27.20722643588747, 77.97344246234586], [27.20606686389735, 77.97685498779262], [27.20566603930921, 77.97816663089377], [27.20508432004915, 77.97977518083036], [27.20433113649352, 77.98198260471948], [27.20347388901654, 77.98385887385953], [27.20238360330877, 77.98624360251489], [27.20079531086978, 77.98980280080488], [27.20070863244568, 77.98999702970562], [27.19953496978029, 77.99256575907215], [27.19921827036782, 77.99327608312015], [27.19862739042537, 77.99419204525896], [27.19804238413151, 77.99483306632364], [27.19793116302506, 77.99493214076203], [27.19792835390957, 77.99493158025571], [27.19792778621711, 77.99495090728823], [27.19793294665098, 77.99503423897268], [27.19829217947011, 77.9953965815679], [27.19814720784494, 77.99549696957438], [27.1976902548515, 77.99571546513178], [27.1973337383552, 77.99606087852536], [27.19675741396101, 77.99666661988743], [27.1965602583714, 77.99698079732647], [27.19641971125107, 77.99761594099729], [27.19647001167216, 77.9986022655353], [27.19654057916646, 77.99901234424416], [27.19672810375937, 78.00025968261251], [27.19668474355631, 78.00117251025878], [27.19668635033792, 78.00183807920907], [27.19662715928937, 78.0018231821443], [27.19616901593137, 78.00172660274932], [27.19494525792143, 78.00144090819816], [27.19420701841765, 78.00127027567977], [27.19330017993058, 78.00100639441423], [27.1925896814804, 78.0008568952528], [27.19261336580441, 78.00102792324468], [27.1928186888865, 78.00181428099327], [27.19311308584775, 78.00288697756035], [27.19424320038513, 78.00605848444471], [27.19271211245174, 78.00715318056528], [27.19239807865275, 78.00740362669076], [27.19294609999842, 78.00787321275676], [27.19295838369142, 78.00787853388606], [27.19305589146632, 78.00795657590562], [27.19316979649053, 78.00819477902972], [27.19324868220437, 78.00840098522298], [27.19347414427054, 78.00880190672376], [27.19354652763711, 78.00894138874327], [27.19353387048671, 78.00897654229037], [27.19357218749836, 78.00903968541331], [27.19365269122929, 78.00917051246111], [27.19371996599832, 78.00936309809202], [27.19377769079253, 78.00963085132561], [27.19386301643829, 78.00972187821192], [27.19402916741084, 78.00974408977997], [27.19414680655658, 78.01017761261784], [27.19422816672792, 78.0102685336467], [27.19429381974986, 78.01053650155765], [27.19439001066891, 78.0110448738458], [27.19442723954208, 78.01134313536367], [27.19436080462836, 78.01166522994305], [27.19428878304653, 78.01206259807842], [27.19411172169513, 78.01273221650678], [27.19389815476791, 78.01325443932943], [27.19370006457805, 78.01379482325157], [27.19344426732303, 78.01443569575433], [27.19311227281256, 78.01511444403447], [27.19276412881544, 78.01580606326293], [27.19252953004621, 78.01619904441438], [27.19235450116551, 78.01658919151583], [27.19214001205044, 78.01696940127546], [27.19201494920693, 78.01724997627316], [27.19199660590194, 78.01736483416869], [27.19192375622727, 78.01761575865827], [27.19183891554986, 78.01787079633924], [27.19177853328781, 78.01809543638203], [27.19177261000917, 78.01837034623654], [27.19175913835457, 78.01862730619285], [27.19175359626724, 78.01888447976], [27.191740601502, 78.01911926939088], [27.19177236837291, 78.01930202627338], [27.19182472467829, 78.01944984543302], [27.19222839158944, 78.01949621972656], [27.19292374898787, 78.01963031750947], [27.19304986474796, 78.01966921066577], [27.1933328603993, 78.01979219332732], [27.19366573670981, 78.01907355307247], [27.19382691520415, 78.0193263518824], [27.1943653841285, 78.02011285410013], [27.19493929013911, 78.02109553549504], [27.19507199631934, 78.02119672318948], [27.19471589288477, 78.02188811794144], [27.19445437233568, 78.02260868084464], [27.19416170256957, 78.02330177921094], [27.19422265419252, 78.02341877840179], [27.19450526276897, 78.02355950826873], [27.1949026092643, 78.02389855200583], [27.1954338071806, 78.02428557997797], [27.19632786795053, 78.024771147305], [27.19679772969668, 78.02505891869667], [27.19703183511416, 78.02450620588449], [27.19717534090439, 78.02447458716378], [27.19732830867871, 78.02437223496095], [27.19754463704749, 78.02390777438637], [27.1978248968908, 78.02305459672226], [27.19795522228246, 78.02289838871127], [27.19812692010631, 78.02266343385763], [27.19816226251501, 78.02263284673576], [27.19849869865996, 78.02234167658406], [27.19889097527965, 78.02255538823334], [27.19974654017136, 78.02298667784025], [27.20004673140548, 78.02304802515958], [27.20052605789732, 78.02326506528135], [27.20090869224813, 78.02355048778385], [27.20145804705544, 78.02383154088642], [27.20165304129033, 78.02398766442867], [27.20231303155933, 78.02428945829824], [27.20353317603095, 78.0247395005097], [27.20410059037587, 78.02491900239205], [27.20428649397797, 78.02500962431186], [27.20446452734626, 78.02460049086724], [27.20477716762556, 78.02408535888529], [27.20508034425109, 78.02364096228851], [27.20562754627147, 78.0229191760799], [27.20579074095631, 78.02271059962428], [27.20600572677554, 78.02230818586273], [27.20623331767811, 78.02205697456102], [27.20648488958961, 78.0217975352315], [27.20656047010335, 78.02160433936726], [27.20666910995794, 78.02134991488052], [27.20687911720588, 78.02117809514438], [27.2071068977458, 78.02091801030322], [27.2071345144938, 78.0207412672428], [27.20718745158633, 78.02049421193554], [27.20736803357932, 78.02021510260539], [27.20755110171973, 78.01982069151158], [27.20781223246168, 78.01911777799943], [27.20801431699518, 78.01820915529491], [27.2080829187487, 78.01797139339193], [27.20862926668913, 78.01793066171997], [27.20863591744945, 78.0180839233854], [27.20855057755293, 78.01946605056622], [27.2084680943173, 78.02071513384519], [27.20817098924697, 78.0225360712049], [27.20814805379635, 78.02267663474683], [27.20768828539918, 78.02555103134681], [27.20768022136127, 78.02560144294227], [27.20741174853267, 78.02700965523609], [27.2072518835516, 78.0285317279018], [27.20687149951069, 78.0299768310675], [27.20678770054831, 78.03022985514747], [27.20569171295186, 78.03353894212586], [27.2072627013746, 78.03389658195074], [27.20969242670459, 78.03454816009753], [27.2110378180948, 78.03470888265862], [27.2123735009829, 78.03458535493058], [27.21354750995567, 78.03459943976709], [27.21466423155667, 78.03432797421576], [27.2157144380108, 78.03419670140018], [27.21661296664191, 78.03374181033814], [27.2178820352888, 78.0330307014938], [27.21938323400994, 78.03259212920248], [27.22011778116002, 78.03238127967582], [27.22049548245858, 78.03216075614249], [27.22079061818152, 78.03208887623616], [27.22151512156164, 78.0319753800159], [27.22218175729402, 78.0316029231399], [27.2225685403382, 78.0313293860447], [27.22276154752585, 78.03121035762453], [27.22303308537854, 78.03112895925932], [27.22356106951116, 78.03093024989845], [27.22423025526267, 78.03080637052405], [27.22475516597244, 78.03074958714402], [27.22525258261855, 78.03049679063653], [27.22582545689592, 78.03042355355224], [27.22627830693191, 78.03041835932332], [27.22637939822247, 78.03049181751697], [27.22656594318347, 78.03048799605264], [27.22870202390565, 78.03077665493444], [27.22883043923698, 78.03070912625756], [27.22900547347382, 78.03068724133362], [27.2292605751705, 78.03063202165902], [27.22952360676366, 78.03057701668526], [27.22976808912851, 78.03064577525254], [27.23012570327217, 78.03061996198839], [27.23075427891809, 78.030539358199], [27.23121555812569, 78.03048972522578], [27.23143990068949, 78.03038928940437], [27.23172499306933, 78.03041476810502], [27.23200138708015, 78.03047551667753], [27.23234972650702, 78.03051158637116], [27.23254816620002, 78.03050808813641], [27.23265726365515, 78.03059980895866], [27.2334226214684, 78.03079808230991], [27.23412006832814, 78.03083474062036], [27.23475068740454, 78.03084295855741], [27.23514533109671, 78.03079361531215], [27.23530099476503, 78.02741374784027], [27.23577167449148, 78.02472798460923], [27.23614407920141, 78.0221815660897], [27.23517856079782, 78.02169831977125], [27.23461287124243, 78.02143892489497], [27.23416139935826, 78.02121812540022], [27.23392928480861, 78.02112752627612], [27.23383933507575, 78.02106739833258], [27.23337520132796, 78.02088176609456], [27.23297044624056, 78.02070217792479], [27.23251152132139, 78.02045899284201], [27.2320714634233, 78.02026070153794], [27.23162558100275, 78.01996461457453], [27.23147759145601, 78.01983634884273], [27.23111826773005, 78.01957366977976], [27.23005356930287, 78.01890583091986], [27.22926483297745, 78.01850286293163], [27.22889642798219, 78.01829320580805], [27.2274120560796, 78.01740104583057], [27.22693348922222, 78.01714848250697], [27.22673963718334, 78.01693910525711], [27.22405537843054, 78.01668031370892], [27.22135238994785, 78.01655416973723], [27.22110355014751, 78.01650308224704], [27.22044601822852, 78.016454722549], [27.22045262177788, 78.0161482622511], [27.22026363910624, 78.01608103898712], [27.22044875315399, 78.01503872021787], [27.22043709400727, 78.01447481143323], [27.22033538304079, 78.0138552236527], [27.21983028039209, 78.01280762539469], [27.21985478268253, 78.01259083623826], [27.21994682892811, 78.01218504282124], [27.22000987833954, 78.01183615871982], [27.219366441512, 78.01168570586593], [27.21833151595688, 78.01147590336807], [27.21806389748549, 78.01137550939198], [27.21765334699458, 78.01128014456796], [27.21747276815586, 78.01119096950168], [27.21711580725416, 78.01081747753793], [27.21680489960309, 78.0105162289342], [27.21695601763933, 78.00976146090736], [27.21711378371353, 78.00925093916776], [27.21725869972498, 78.0087844467447], [27.21754166601001, 78.00817078445093], [27.21771568383716, 78.00784416163899], [27.21898831840402, 78.00851825135908], [27.21975706020936, 78.00722377016045], [27.21984425602154, 78.007051019381], [27.21995147549836, 78.00691771640876], [27.22025561489147, 78.00636169498371], [27.22047869734048, 78.00634045253888], [27.22066495774837, 78.00625207325635], [27.22089519129137, 78.00605981752364], [27.22114149271854, 78.00625320538332], [27.22170636979913, 78.00570418167304], [27.22177075377924, 78.00578373270311], [27.22195481200734, 78.00595988493512], [27.22208252495177, 78.0060061183742], [27.22218682081596, 78.00600892088114], [27.22231536885935, 78.00601626615533], [27.22244664180072, 78.0060587044352], [27.22271233007343, 78.00615923012705], [27.22280486001887, 78.00622397418417], [27.22280905683417, 78.00635249307554], [27.22281756532491, 78.00644221691765], [27.22289643958467, 78.00649492096328], [27.22303010294016, 78.00658800864326], [27.22321335644781, 78.00663962725584], [27.22351481179987, 78.00669442314425], [27.22352365418302, 78.00676859207246], [27.2236309252516, 78.00679482216694], [27.22368663319429, 78.00679242844315], [27.22372056305084, 78.00683225172138], [27.22386854989248, 78.00690626995332], [27.22393157720886, 78.00672508095536], [27.22417673973057, 78.00680949360573], [27.22422407441107, 78.00687302425331], [27.22434160791063, 78.00690731285012], [27.2245935562065, 78.00699969101295], [27.22474560425178, 78.00704658122179], [27.22502355907415, 78.00706183589207], [27.22551672414181, 78.00709844119642], [27.22568326306432, 78.0071184832885], [27.22594186265082, 78.00706317650338], [27.22644926795797, 78.00708460050777], [27.22668617286167, 78.00706762245709], [27.2267846524362, 78.00717922461617], [27.22757529406595, 78.00729387292628], [27.22804312032075, 78.00737649520039], [27.22886149003792, 78.00749578406841], [27.22955198039594, 78.00757661419995], [27.23022689284195, 78.00773485380117], [27.23063879377074, 78.00766810492914], [27.2309635805258, 78.00777023331432], [27.23175539085207, 78.00783044489589], [27.23213035325684, 78.00786387930094], [27.23234038316607, 78.00650753008267], [27.23242495188152, 78.00580934642166], [27.2325220870109, 78.00517376214376], [27.23257004692742, 78.00456020385977], [27.23264548249957, 78.0039629487347], [27.23272291880556, 78.00327235164103], [27.23280975158724, 78.00279214400356], [27.2329216138809, 78.00211803474582], [27.23308798697958, 78.00214585038871], [27.23326519934334, 78.00069519873205], [27.23333177999546, 78.00051019475653], [27.23363009535508, 78.0005493318198], [27.23370167898252, 78.00013097217062], [27.23365005652785, 77.99994279574975], [27.23548298640669, 77.9991436169689], [27.23733917655239, 77.99888208169753], [27.23927668491421, 77.998397004347], [27.24012996270293, 77.9981863888125], [27.2405613876413, 77.99818239345637], [27.24391676007466, 77.99706560813125]]}});

I'm not able to execute above full command in the mongo shell. Also I've tried to use mongo-shell variable in following way...
var file = cat('/home/vivek/locationCoordinates.json');
db.geoPolygonData.insert({"polygonName":"location6", "polygons":{"type":"Polygon", coordinates:[file]}});

But it storing coordinates in a string not an array.

Please let me know, Is there any limitation to execute such large query? or if there is any other way around to execute such commands.

A: cat just reads the file, it doesn't parse the file as json.
Try:
var file = JSON.parse(cat('/home/vivek/locationCoordinates.json'));
db.geoPolygonData.insert({"polygonName":"location6", "polygons":{"type":"Polygon", coordinates:[file]}});

A: Create a JavaScript file called as insert_large_array_doc.js, with the following contents:
let doc = { "polygonName": "location1",  "polygons": {"type": "Polygon", coordinates: [ [27.24391676007466, 77.99706560813125], [27.24663657232702, 77.99603771498144], ...
..., [27.24391676007466, 77.99706560813125] ] } }

db.collection.insertOne(doc);

From the mongo shell (specify the entire file path of the JS file):
mongo > load("insert_large_array_doc.js");

The document will be inserted into the collection. Query the document:
mongo > db.collection.find()

A: There is a limit for a document, but it might not be your case.

The maximum BSON document size is 16 megabytes.

The maximum document size helps ensure that a single document cannot use excessive amount of RAM or, during transmission, excessive amount of bandwidth. To store documents larger than the maximum size, MongoDB provides the GridFS API.
Another point is related to Shell:

The mongo shell prompt has a limit of 4095 codepoints for each line. If you enter a line with more than 4095 codepoints, the shell will truncate it.

MongoDB Limits and Thresholds might be a good option to check.
There are some workarounds of how you can deal with long commands. Here you can also find some good advices.

A: Here is a variation on prasad's solution because his didn't work for me.
Define the javascript file where you define 'doc' (or whatever json) but don't add the insertOne at the end.
let doc = {...my JSON...}

Load up mongo and use
load(".../MyPath/my_file.js")

Now, the "doc" variable is set within the mongo shell.
db.myCollection.insertOne(doc)

And it's inserted as normal.


text:
Q: Swift executing firebase calls out of order My code makes calls to my firebase database, but the order in which it receives the data is incorrect in terms of the function call. It calls the data from ref3 then ref2 then ref4 and I would like for it to retrieve the data in order of ref2, ref3, ref4 of course. No matter what it will always do it in this order.
     var ref2: DatabaseReference?
     var ref3: DatabaseReference?
     var ref4: DatabaseReference?

     ref2 = Database.database().reference().child("User data").
     ref3 = Database.database().reference().child("User Info").child("Name")
     ref4 = Database.database().reference().child("User Info").child("Address")

    ref2?.observe(DataEventType.value, with:{(DataSnapshot) in
        if DataSnapshot.childrenCount > 0{
            for data in DataSnapshot.children.allObjects as![DataSnapshot]{
                let proObj = data.value as? [String: AnyObject]
                let p: String = proObj?["Username"] as! String
                let n: String = proObj?["User login"] as! String

            }

        }
    })

    ref3?.observe(DataEventType.value, with:{(DataSnapshot) in
        if DataSnapshot.childrenCount > 0{
            for data in DataSnapshot.children.allObjects as![DataSnapshot]{
                let proObj = data.value as? [String: AnyObject]
                let p: String = proObj?["User first name"] as! String
                let n: String = proObj?["User last name"] as! String

            }

        }
    })

    ref4?.observe(DataEventType.value, with:{(DataSnapshot) in
        if DataSnapshot.childrenCount > 0{
            for data in DataSnapshot.children.allObjects as![DataSnapshot]{
                let proObj = data.value as? [String: AnyObject]
                let p: String = proObj?["User email"] as! String

            }

        }
    })

A: When querying data from your firebase database, you are performing an asynchronous call. To put things in simple terms, your code is executed on a different thread and, subsequently, performs parallel operations. This is exactly what is happening in your case.
You are observing data from three different references, and even though you have defined their sequence programmatically, nothing guarantees that the code within the completion handler blocks of your observers will run in that exact same sequence.
If you want to run them sequentially, then you have to nest your observers so that the next database query is executed only after the previous one has finished.
The below should hypothetically work
ref2?.observe(DataEventType.value, with: { (DataSnapshot) in

    if DataSnapshot.childrenCount > 0 {
        for data in DataSnapshot.children.allObjects as! [DataSnapshot] {
            let proObj = data.value as? [String: AnyObject]
            let p: String = proObj?["Username"] as! String
            let n: String = proObj?["User login"] as! String
        }
    }

    ref3?.observe(DataEventType.value, with: { (DataSnapshot) in

        if DataSnapshot.childrenCount > 0 {
            for data in DataSnapshot.children.allObjects as! [DataSnapshot] {
                let proObj = data.value as? [String: AnyObject]
                let p: String = proObj?["User first name"] as! String
                let n: String = proObj?["User last name"] as! String
            }
        }

        ref4?.observe(DataEventType.value, with: { (DataSnapshot) in

            if DataSnapshot.childrenCount > 0 {
                for data in DataSnapshot.children.allObjects as![DataSnapshot] {
                    let proObj = data.value as? [String: AnyObject]
                    let p: String = proObj?["User email"] as! String
                }
            }

        }) // ref4 observer

    }) // ref3 observer

}) // ref2 observer

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to access a shared library file with mkmf in Ruby? I am trying to work with libcsv here. The header file csv.h is in /usr/include directory, and the shared library file libcsv.so in /usr/lib64 (Fedora 35).
For now, I was able to make the gem file work using the shell command:
gcc -c -fPIC rcsv.c -o rcsv.o
gcc -shared -lcsv rcsv.o -o rcsv.so

I have to manually move the .so file to lib/rcsv/, which is quite inconvenient, and is not favourable for installing gems.
I would like to write the same in code in Ruby format inside extconf.rb. How should I go about this?
extconf.rb
require 'mkmf'

have_header("csv.h")
have_library('libcsv.so')

create_makefile('rcsv/rcsv')

rake log
(in /home/<username>/Desktop/rcsv)
mkdir -p tmp/x86_64-linux/rcsv/3.0.3
cd tmp/x86_64-linux/rcsv/3.0.3
/home/<username>/.asdf/installs/ruby/3.0.3/bin/ruby -I. -r.rake-compiler-siteconf.rb ../../../../ext/rcsv/extconf.rb
checking for csv.h... yes
checking for -llibcsv.so... no
creating Makefile
cd -
cd tmp/x86_64-linux/rcsv/3.0.3
/usr/bin/gmake
compiling ../../../../ext/rcsv/rcsv.c
linking shared-object rcsv/rcsv.so
cd -
mkdir -p tmp/x86_64-linux/stage/lib/rcsv
/usr/bin/gmake install target_prefix=
/usr/bin/install -c -m 0755 rcsv.so /home/<username>/Desktop/rcsv/lib/rcsv
cp tmp/x86_64-linux/rcsv/3.0.3/rcsv.so tmp/x86_64-linux/stage/lib/rcsv/rcsv.so
Loaded suite /home/<username>/.asdf/installs/ruby/3.0.3/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/rake_test_loader
Started
/home/<username>/.asdf/installs/ruby/3.0.3/bin/ruby: symbol lookup error: /home/<username>/Desktop/rcsv/lib/rcsv/rcsv.so: undefined symbol: csv_init
rake aborted!
Command failed with status (127)

Tasks: TOP => default => test
(See full trace by running task with --trace)

A: The above code in extconf.rb was proper, but not the string value inside the have_library('libcsv.so'), which should have been 'csv' instead of 'libcsv.so'.
So, overall, the extconf.rb file should look like:
require 'mkmf'

have_header("csv.h")
have_library('csv')

create_makefile('rcsv/rcsv')


text:
Q: Does Android support Full Disk Encryption for mico SD Cards? Note: My Android is on Android 6.0.1 and is NOT ROOTED!
Androids default sd card encryption is file-based
The default encryption for micro sd cards on Android appears to use file-based encryption. I put my micro sd card into my PC and all the file names were viewable. All file names, folders, etc. were viewable. It was just the content that wasn't viewable. This doesn't help in situations where the content of a file can be figured out by its name. Eg. MP3 files. You can also find out what apps are installed on the phone.
My Question
I would like to know whether or not Android has an option to encrypt the entire sd card (file system). So instead of file contents being scrambled, everything is scrambled including the files and folders?
Known Solution
The only solution I have found is to use ADB Tools to force your Android device to use your micro sd card as adoptable storage. This results in your micro sd card's file system being encrypted with 128 bit AES encryption. Take it out of your phone and put it in your PC and the file system is scrambled.
Why this solution isn't appropriate
However this has the drawback of making your phone a lot slower (slower read-writes) and results in you no longer being able to view your phones internal storage. I copy files to and from my adopted-storage micro sd card via the adb tool commands: adb pull / adb push. If you try and copy your phones internal storage, you will only be able to copy the contents of your adoptable storage - as your adoptable storage becomes internal and access to internal becomes restricted/denied.
Updates
I do not want to root my device.
No Third Party Apps
I do not want to create an encrypted file (via an app) within which to place files. That still wouldn't solve my problem and would likely cause more problems than adoptable storage; I'd suspect I would be using unstable and untested software. A solution would need to work on-the-fly (with no "go here, enter your password, mount, save file, unmount", etc.) with all software such as Music and Camera apps - with no problems whatsoever.
If you do have such a solution, feel free to add it but know that it doesn't properly solve the problem.
Opinion
Android advertises itself as supporting encryption. The fact that file names are viewable can be regarded as a security vulnerability.


text:
Q: Android character by character display text animation Anyone knows any efficient method of perform an animation that what is has to do is to display a text, character by character? Like:

T Th Thi This This i This is ...

And so on.
Thanks!

A: this new copy for  Devunwired with xml layout
    public class Typewriter extends TextView {

    private CharSequence mText;
    private int mIndex;
    private long mDelay = 500; //Default 500ms delay

    public Typewriter(Context context) {
        super(context);
    }

    public Typewriter(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    private Handler mHandler = new Handler();
    private Runnable characterAdder = new Runnable() {
        @Override
        public void run() {
            setText(mText.subSequence(0, mIndex++));
            if(mIndex <= mText.length()) {
                mHandler.postDelayed(characterAdder, mDelay);
            }
        }
    };

    public void animateText(CharSequence text) {
        mText = text;
        mIndex = 0;

        setText("");
        mHandler.removeCallbacks(characterAdder);
        mHandler.postDelayed(characterAdder, mDelay);
    }

    public void setCharacterDelay(long millis) {
        mDelay = millis;
    }
}

code use
        textView = (Typewriter)findViewById(R.id.textView1);
    //Add a character every 150ms
    textView.setCharacterDelay(150);
    textView.animateText("Sample String");

then define textView in classStart

A: I used a recursive method, also added a bit delay in between words to have more human feel.
Send the textView as view along with the text and send '1' as the length to type from start
  private fun typingAnimation(view: TextView, text: String, length: Int) {
    var delay = 100L
    if(Character.isWhitespace(text.elementAt(length-1))){
        delay = 600L
    }
    view.text = text.substring(0,length)
    when (length) {
        text.length -> return
        else -> Handler().postDelayed({
            typingAnimation(view, text, length+1 )
        }, delay)
    }
}

A: use Devunwired's Typewriter class
then, in the layout:
<com.example.fmm.Typewriter
    android:id="@+id/typewriter"
    android:layout_alignParentTop="true"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"/>

code in the activity:
Typewriter writer = (Typewriter)findViewById(R.id.typewriter);
        //Add a character every 150ms
        writer.setCharacterDelay(150);
        writer.animateText("Sample String");

A: I know its too late now but someone still may arrive here from Google.
Actually, I too needed something like this for my app, so made one myself.
Try out Fade-In TextView, it makes every character appear with a smooth alpha animation. Usage is also quite simple.
In the XML layout
    <believe.cht.fadeintextview.TextView
        android:id="@+id/textView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textSize="30sp"
        android:textColor="@android:color/black"

        app:letterDuration="250"/>

In the Activity/Fragment
believe.cht.fadeintextview.TextView textView = (believe.cht.fadeintextview.TextView) findViewById(R.id.textView);

textView.setLetterDuration(250); // sets letter duration programmatically
textView.isAnimating(); // returns current animation state (boolean)
textView.setText(); // sets the text with animation

Some more information
The Fade-In TextView library inherits its properties directly from the native TextView class, which means that all the native TextView methods are supported. There are practically no limitations including multiline support. The library also has some of its own methods and attributes which offer full control over the View.

A: No need to set an extra class Use this, here tv is a textview in your layout
just call
setCharacterDelay(150);
animateText("Sample String");
private Handler mHandler = new Handler();
private Runnable characterAdder = new Runnable() {
    @Override
    public void run() {
        tv.setText(mText.subSequence(0, mIndex++));
        if(mIndex <= mText.length()) {
            mHandler.postDelayed(characterAdder, mDelay);
        }
    }
};

public void animateText(CharSequence text) {
    mText = text;
    mIndex = 0;

    tv.setText("");
    mHandler.removeCallbacks(characterAdder);
    mHandler.postDelayed(characterAdder, mDelay);

}

public void setCharacterDelay(long millis) {
    mDelay = millis;
}

A: This may not be the most elegant solution, but the simplest is probably a quick subclass of TextView with a Handler that updates the text every so often until the complete sequence is displayed:
public class Typewriter extends TextView {

    private CharSequence mText;
    private int mIndex;
    private long mDelay = 500; //Default 500ms delay

    public Typewriter(Context context) {
        super(context);
    }

    public Typewriter(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    private Handler mHandler = new Handler();
    private Runnable characterAdder = new Runnable() {
        @Override
        public void run() {
            setText(mText.subSequence(0, mIndex++));
            if(mIndex <= mText.length()) {
                mHandler.postDelayed(characterAdder, mDelay);
            }
        }
    };

    public void animateText(CharSequence text) {
        mText = text;
        mIndex = 0;

        setText("");
        mHandler.removeCallbacks(characterAdder);
        mHandler.postDelayed(characterAdder, mDelay);
    }

    public void setCharacterDelay(long millis) {
        mDelay = millis;
    }
}

You can then use this in an Activity like so:
public class MyActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Typewriter writer = new Typewriter(this);
        setContentView(writer);

        //Add a character every 150ms
        writer.setCharacterDelay(150);
        writer.animateText("Sample String");
    }
}

If you want some animation effects with each letter added, perhaps look at subclassing TextSwitcher instead.

A: In theory it would be

string text = "hello"
string temp = "h"

iterate: temp += if (text.length > temp.length) text[temp.length]; wait

You will of course do the iterate in your runmethod.

A: Most of the solutions provided above throw various errors. I guess the solutions are old. I stumbled on this android studio plugin and it works like charm.
1.Installation of AutoTypeTextView is preety simple. Just add in build.gradle

compile 'com.krsticdragan:autotypetextview:1.1'

2.Add a new namespace which you will use for adding AutoTypeTextView and using its tags.

xmlns:attv="http://schemas.android.com/apk/res-auto"

Hence your root layout should look like this
<?xml version="1.0" encoding="utf-8"?>
      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      xmlns:attv="http://schemas.android.com/apk/res-auto"

*Add this to your xml file.
<com.dragankrstic.autotypetextview.AutoTypeTextView
     android:id="@+id/lblTextWithoutMistakes"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     attv:animateTextTypeWithoutMistakes="Hello World!" />
With just these three steps you are good to go. You can check out the documentation here for more details

A: Just to add to @Devunwired's answer when working with Kotlin code,
I changed (in animateText function):
mHandler.postDelayed(mRunnable,mDelay) to mRunnable.run()

so my final Kotlin class looks like this:
class TextViewAnimationComponent(context: Context,attributeSet: AttributeSet?) : TextView(context,attributeSet) {
    private var mHandler = Handler()
    private var mText:CharSequence = ""
    private var mIndex:Int = 0
    private var mDelay:Long = 500

    private val mRunnable = object: Runnable{
        override fun run() {
            text = mText.subSequence(0,mIndex++)
            if(mIndex <= mText.length){
                mHandler.postDelayed(this,mDelay)
            }
        }
    }

    fun animateText(mText:CharSequence){
        this.mText = mText
        mIndex = 0

        text = ""
        mHandler.removeCallbacks(mRunnable)
        mRunnable.run()
//        mHandler.postDelayed(mRunnable,mDelay)
    }

    fun setCharacterDelay(millis:Long){
        mDelay = millis
    }
}

Also, a quick and dirty code (still in Kotlin) without subclassing.
Inside Activity:
    private fun animateText(mText: CharSequence, delayMillis: Long, postFunction:() -> Unit){
        var mIndex = 0

        val runnable = object : Runnable {
            override fun run() {

                // RunRunnable is a boolean flag; used in case you want to interrupt the execution
                if(runRunnable) {
                    if (mIndex <= mText.length) {

                        // change textViewSwitchStateValue with your own TextView id
                        textViewSwitchStateValue.text = mText.subSequence(0, mIndex++)
                        Handler().postDelayed(this, delayMillis)
                    } else {

                        // After all the characters finished animating; Clear the TextView's text and then run the postFunction
                        textViewSwitchStateValue.text = ""
                        postFunction()
                    }
                }
            }
        }
        runOnUiThread(runnable)

A simple example for animating a loading dots:
animateText(". . .", 400){switchStateON()}

A: Yep,I know it's been a while but I hope to help others with a different approach using ValueAnimator
val text = "This is your sentence"
val textLength = text.length-1
val textView = findViewById<TextView>(R.id.sampleText)

ValueAnimator.ofInt(0, textLength).apply {
     var _Index = -1
     interpolator = LinearInterpolator()
     duration = 2000
     addUpdateListener { valueAnimator ->
         val currentCharIndex = valueAnimator.animatedValue as Int
         if (_Index != currentCharIndex) {
             val currentChar = text[currentCharIndex]
             textView.text = textView.text.toString().plus(currentChar.toString())
         }
        _Index = currentCharIndex
     }
}.start()

Update

I think is more appropriate, rather solution above, of course if you are using RxJava
 Observable.range(0, textLength)
        .concatMap { Observable.just(it).delay(75, TimeUnit.MILLISECONDS) }
        .map { text[it].toString() }
        .subscribeOn(Schedulers.computation())
        .observeOn(AndroidSchedulers.mainThread())
        .subscribe { char ->
            println("Item: $char")
            textView.text = textView.text.toString().plus(char)
        }

A: You can use this library for the same: TypeWriterView Android library
A glimpse into the library:
    //Create Object and refer to layout view
    TypeWriterView typeWriterView=(TypeWriterView)findViewById(R.id.typeWriterView);

    //Setting each character animation delay
    typeWriterView.setDelay(int);

    //Setting music effect On/Off
    typeWriterView.setWithMusic(boolean);

    //Animating Text
    typeWriterView.animateText(string);

    //Remove Animation. This is required to be called when you want to minimize the app while animation is going on. Call this in onPause() or onStop()
    typeWriterView.removeAnimation();


text:
Q: The simplification of $(1+a_1\cdot h) \cdot \ldots \cdot (1+a_n\cdot h)$ I would like to simplify the expression $(1+a_1\cdot h) \cdot \ldots \cdot (1+a_n\cdot h)$. One will later anyway truncate all terms with $h^2$ and greater by considering $h << 1$, but I would like to write down a formula before doing $h<<1$.
So far I have:
\begin{align}
(1+a_1\cdot h) \cdot \ldots \cdot (1+a_n\cdot h) = 1 + h \sum_{j=1}^n a_j + h^2 \sum_{j\ne k}^n a_ja_k + \ldots
\end{align}

A: Denoting with $[n]=\{1,2,\ldots,n\}$ we obtain
\begin{align*}
\color{blue}{\prod_{j=1}^n}\color{blue}{\left(1+a_jh\right)}
&=\sum_{k=0}^n\sum_{{S\subseteq [n]}\atop{|S|=k}}\left(\prod_{j\in S}a_j\right)h^k\\
&=\sum_{{S\subseteq [n]}\atop{|S|=0}}\left(\prod_{j\in S}a_j\right)h^0+\sum_{{S\subseteq [n]}\atop{|S|=1}}\left(\prod_{j\in S}a_j\right)h^1+\sum_{k=2}^n\sum_{{S\subseteq [n]}\atop{|S|=k}}\left(\prod_{j\in S}a_j\right)h^k\\
&\,\,\color{blue}{=1+\sum_{j=1}^na_jh
+\sum_{k=2}^n\sum_{{S\subseteq [n]}\atop{|S|=k}}\left(\prod_{j\in S}a_j\right)h^k}\\
\end{align*}

A: Hint:
$$\prod_{i=1}^n\left[1+a_i h \right]=\prod_{i=1}^na_i\left[h + \dfrac{1}{a_i} \right]=\prod_{i=1}^na_i\prod_{i=1}^n\left[h + \dfrac{1}{a_i} \right]$$
The last product can be interpreted as a polynomial in $h$ with degree $n$ in which $-1/a_i$ are the roots of the polynomial. The coefficients can be written down by Vieta's formulas.


text:
Q: How Convert UTC Date & time to local time using different timezone Nodatime i am using a function which is taking date time over the internet from external server.
here is the function which i am using to get date and time without depend on user pc date time settings.
using NodaTime;
using NodaTime.Text;
using System.IO;
using System.Globalization;

 public static DateTime GetFastestNISTDate()
        {
            var result = DateTime.MinValue;
            DateTime utcDateTime = DateTime.MinValue;

            // Initialize the list of NIST time servers
            // http://tf.nist.gov/tf-cgi/servers.cgi
            string[] servers = new string[] {
                "nist1-ny.ustiming.org",
                "nist1-nj.ustiming.org",
                "nist1-pa.ustiming.org",
                "time-a.nist.gov",
                "time-b.nist.gov",
                "nist1.aol-va.symmetricom.com",
                "nist1.columbiacountyga.gov",
                "nist1-chi.ustiming.org",
                "nist.expertsmi.com",
                "nist.netservicesgroup.com"
            };

            // Try 5 servers in random order to spread the load
            Random rnd = new Random();
            foreach (string server in servers.OrderBy(s => rnd.NextDouble()).Take(5))
            {
                try
                {
                    // Connect to the server (at port 13) and get the response
                    string serverResponse = string.Empty;
                    using (var reader = new StreamReader(new System.Net.Sockets.TcpClient(server, 13).GetStream()))
                    {
                        serverResponse = reader.ReadToEnd();
                    }

                    // If a response was received
                    if (!string.IsNullOrEmpty(serverResponse))
                    {
                        // Split the response string ("55596 11-02-14 13:54:11 00 0 0 478.1 UTC(NIST) *")
                        string[] tokens = serverResponse.Split(' ');

                        // Check the number of tokens
                        if (tokens.Length >= 6)
                        {
                            // Check the health status
                            string health = tokens[5];
                            if (health == "0")
                            {
                                // Get date and time parts from the server response
                                string[] dateParts = tokens[1].Split('-');
                                string[] timeParts = tokens[2].Split(':');

                                // Create a DateTime instance
                                utcDateTime = new DateTime(
                                    Convert.ToInt32(dateParts[0]) + 2000,
                                    Convert.ToInt32(dateParts[1]), Convert.ToInt32(dateParts[2]),
                                    Convert.ToInt32(timeParts[0]), Convert.ToInt32(timeParts[1]),
                                    Convert.ToInt32(timeParts[2]));

                                // Convert received (UTC) DateTime value to the local timezone
                                result = utcDateTime.ToLocalTime();

                                //return result;
                                return utcDateTime;
                                // Response successfully received; exit the loop

                            }
                        }

                    }

                }
                catch
                {
                    // Ignore exception and try the next server
                }
            }
            //return result;
            return utcDateTime;
        }

this variable result has local date time but i need to use Nodatime library where i will put my local date time variable result and also specify different timezone and Noda libraray will return local date and time of that timezone.
just guide me how to achieve it. i visit this url but still not clear how to incorporate Nodatime library and local time got from external server together to get another datetime based on different timezone.
looking for help with bit of sample code
thanks
EDIT
var wc = GetFastestNISTDate();

var pattern = InstantPattern.CreateWithInvariantCulture("dd/MM/yyyy HH:mm:ss");
var parseResult = pattern.Parse(wc.ToString("dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture));
if (!parseResult.Success)
    throw new InvalidDataException("...whatever...");
var instant = parseResult.Value;

var timeZone = DateTimeZoneProviders.Tzdb["Europe/London"];
var zonedDateTime = instant.InZone(timeZone);
var bclDateTime = zonedDateTime.ToDateTimeUnspecified();

timezone translation is not working. i got the right date from this function GetFastestNISTDate(); and next i try to get local date and time of different timezone based on my first utc time but code return wrong time for London. i guess i am making mistake the code. can anyone see & help. thanks
EDIT 2
the samething i want to achieve by Nodatime library.
    var wc = GetFastestNISTDate();

    TimeZoneInfo cstZone = TimeZoneInfo.FindSystemTimeZoneById("GMT Standard Time");
    DateTime cstTime = TimeZoneInfo.ConvertTimeFromUtc(wc, cstZone);

the above code is giving more or less right time. just tell me how to replace my last 2 line using nodatime library. thanks
Edit 3
var wc = GetFastestNISTDate();
Instant now = Instant.FromDateTimeUtc(wc);

var timeZone = DateTimeZoneProviders.Tzdb["Europe/London"];
var zonedDateTime = instant.InZone(timeZone);
var bclDateTime = zonedDateTime.ToDateTimeUnspecified();

@John just tell me the above code is ok because u said
Don't convert the UTC DateTime to a local version - it's pointless and confusing
Use Instant.FromDateTimeUtc to convert a UTC DateTime to an instant

GetFastestNISTDate() returning datetime instance and here we just create noda instance from utc datetime using like this code `Instant now = Instant.FromDateTimeUtc(wc);`

does it solve the issue.
EDIT 4
@Matt Johnson : thanks a lot for redirecting me to a good library.
i would definitely like to work with that library to achieve my task. before
use your library i have some question.

*

*Point 1
what was wrong you notice in this routine GetFastestNISTDate(); the routine was query few NIST time servers and get the utctime.
                   utcDateTime = new DateTime(
                        Convert.ToInt32(dateParts[0]) + 2000,
                        Convert.ToInt32(dateParts[1]), Convert.ToInt32(dateParts[2]),
                        Convert.ToInt32(timeParts[0]), Convert.ToInt32(timeParts[1]),
                        Convert.ToInt32(timeParts[2]));

this routine GetFastestNISTDate(); was returning  utcDateTime....was not a utc time ?

*Point 2
when i was calling GetFastestNISTDate(); routine i notice some time this routine was returning DateTime.MinValue which was not expected result. i could understand why it was happening because NIST time servers was busy or blocked or timeout occured at that time.

*Point 3
if i use your current code/library NodaTime.NetworkClock then i like to know which NTP server it will query by default?

if i use NodaTime.NetworkClock then is there any chance that some time i may get wrong date or null date due to NTP server is busy/block or timeout occur?
EDIT 5
    var instant = NetworkClock.Instance.Now;
    var timeZone = DateTimeZoneProviders.Tzdb["Europe/London"];
    var zonedDateTime = instant.InZone(timeZone);

    lbldate.Text = zonedDateTime.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);
    lbltime.Text = zonedDateTime.ToString("hh:mm:ss", CultureInfo.InvariantCulture);

A: Your GetFastestNISTDate function uses the daytime protocol - which is essentially deprecated and NOT meant for machine interaction because its results are in no specific format.  Even the docs from NIST strongly encourage users to use NTP instead of daytime.
You can find a simple C# implementation of an NTP client here.
To make things easier, I've implemented this client as a NodaTime.IClock.  The code is on GitHub here.  Simply install it from NuGet:
Install-Package NodaTime.NetworkClock

Then you can use it just like you would use the SystemClock:
var instant = NetworkClock.Instance.Now;
var timeZone = DateTimeZoneProviders.Tzdb["Europe/London"];
var zonedDateTime = instant.InZone(timeZone);

A: You shouldn't be converting the DateTime to a string and back - but your current problem is that you're converting the UTC value you get back from the server into a local DateTime for no obvious reason. Ideally, I'd suggest changing GetFastestNISTDate() to return an Instant, but assuming you can't do that:

*

*Don't do the parsing yourself. Take the appropriate substring from the response, then use DateTime.ParseExact, specifying CultureInfo.InvariantCulture and DateTimeStyles.AssumeUniversal

*Don't convert the UTC DateTime to a local version - it's pointless and confusing

*Use Instant.FromDateTimeUtc to convert a UTC DateTime to an instant

The final part of your code (the last three lines) is okay, but why do you need a DateTime at all? If you can make as much of your code as possible use Noda Time, you'll get the greatest benefits in terms of code clarity.


text:
Q: LDA analysis error: object not found I am trying to make a LDA analysis in R to some data. The code is below:
The data is defines as follows:
mydata=matrix(c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30), ncol=5, dimnames=list(c("ex1","ex2","ex3","ex4","ex5","ex6"),c("class","a","b","c","d")))

This is the result for "mydata":
class  a  b  c  d
ex1     1  7 13 19 25
ex2     2  8 14 20 26
ex3     3  9 15 21 27
ex4     4 10 16 22 28
ex5     5 11 17 23 29
ex6     6 12 18 24 30

Now, I try to make a LDA analysis using this code:
mydata.lda<-lda(class ~ mydata.a + mydata.b + mydata.c + mydata.d)

This is the error code I get:
Error in eval(expr, envir, enclos) : object 'mydata.a' not found
Calls: lda ... eval -> model.frame -> model.frame.default -> eval -> eval

Why it is not working? Should I change something?

A: You need to use mydata$a, not mydata.a. You could also just do (untested)
mydata.lda <- lda(class~a+b+c+d, data = mydata)


text:
Q: pandoc-citeproc as API: processCites' does not add references I have a small text file in markdown :
---
title: postWithReference
author: auf
date: 2010-07-29
keywords: homepage
abstract: |
    What are the objects of
    ontologists .

bibliography: "/home/frank/Workspace8/SSG/site/resources/BibTexLatex.bib"
csl: "/home/frank/Workspace8/SSG/site/resources/chicago-fullnote-bibliography-bb.csl"
---

An example post. With a reference to [@Frank2010a] and more[@navratil08].

## References

and process it in Haskell with processCites' which has a single argument, namely the Pandoc data resulting from readMarkdown. The bibliography and the csl style should be taken from the input file.
The process does not produce errors, but the result of processCites is the same text as the input; references are not treated at all. For the same input the references are resolved with the standalone pandoc (this excludes errors in the bibliography and the csl style)
pandoc -f markdown -t html  --filter=pandoc-citeproc -o p1.html postWithReference.md

The issue is therefore in the API. The code I have is:
markdownToHTML4 :: Text -> PandocIO Value
markdownToHTML4 t = do
  pandoc   <- readMarkdown markdownOptions  t
  let meta2 = flattenMeta (getMeta pandoc)

  -- test if biblio is present and apply
  let bib = Just $ ( meta2) ^? key "bibliography" . _String
  pandoc2 <- case bib of
    Nothing -> return pandoc
    _ -> do
                res <- liftIO $ processCites' pandoc --  :: Pandoc -> IO Pandoc
                when (res == pandoc) $
                    liftIO $ putStrLn "*** markdownToHTML3 result without references ***"
                return res

  htmltex <- writeHtml5String html5Options pandoc2

  let withContent = ( meta2) & _Object . at "contentHtml" ?~ String ( htmltex)
  return  withContent

getMeta :: Pandoc -> Meta
getMeta (Pandoc m _) = m

What do I misunderstand? are there any reader options necessary for citeproc? The bibliography is a BibLatex file.
I found in hakyll code a comment, which I cannot understand in light of the code there - perhaps somebody knows what the intention is.
-- We need to know the citation keys, add then *before* actually parsing the
-- actual page. If we don't do this, pandoc won't even consider them
-- citations!

A: I have a workaround (not an answer to the original question, I still hope that somebody can identify my error!). It is simple to call the standalone pandoc with System.readProess and pass the text and get the result back, not even reading and writing files:
processCites2x :: Maybe FilePath -> Maybe FilePath -> Text ->   ErrIO Text
-- porcess the cites in the text (not with the API)
-- using systemcall because the standalone pandoc works with
-- call: pandoc -f markdown -t html  --filter=pandoc-citeproc
-- with the input text on stdin and the result on stdout
-- the csl and bib file are used from text, not from what is in the arguments

processCites2x _ _  t  = do
        putIOwords ["processCite2" ] -- - filein\n", showT styleFn2, "\n", showT bibfn2]

        let cmd = "pandoc"
        let cmdargs = ["--from=markdown", "--to=html5", "--filter=pandoc-citeproc" ]

        let cmdinp = t2s t
        res :: String <- callIO $ System.readProcess cmd cmdargs cmdinp

        return . s2t $ res
        -- error are properly caught and reported in ErrIO

t2s and s2t are conversion utilities between string and text, ErrIO is ErrorT Text a IO and callIO is essentially liftIO with handling of errors.

A: The original problem was very simple:  I had not included the option Ext_citations in the markdownOptions. When it is included, the example works (thanks to help I received from the pandoc-citeproc issue page). The referenced code is updated...


text:
Q: CSS media queries for modern mobile browsers I'm having a problem with my media queries where I want to target phones, tablets or computers. the problem is that today some phones and tablets have a high screen resolution.
I can´t seem to find a proper combination to achieve this. Could you help me and post the queries that you guys use for your websites? I've been working on these for days, to no avail.
Should I use some JavaScript library for this?
UPDATE:
I found a very good jquery library that seems to be very reliable with today's devices. And even though it is not being developed anymore, I found that it successfully detected all the devices tested, regular phones and tablets, high ppi phones and tablets, and desktop or laptop computers.
Try it out, and see if it works for you too
Categorizr

A: There is no way to make everyone happy. For our upcoming responsive website we used a few breakpoints
768px
1024px
1280px
1920px - is our biggest, we cut off at this point
We have our server output classes on the body to detect classes (can be done with modernizr I think, never used it), for example, .iphone, android, .mobile, .phone, .tablet
So if you are using an iphone we would get
.iphone and .phone on the body tag
For some pages we also defined breakpoints at 320px and 480px
We use jquery for everything, just a warning, jquery runs fairly slow on Samsung tablets, man do we hate that device
Example of media query (we use LESS)
// normal styles

@media only screen and (max-width: @maxTabletWidth) {
   // less than 1024px styles, yes I know 1280px is also tablet
}

@media only screen and (max-width: @maxPhoneWidth) {
   // less than 768px styles
}

Good luck

A: Having built quite a few responsive websites, I find that instead of specifying 'x' width for a desktop monitor, 'y' width for a tablet, and 'z' width for a mobile; it's better to use breakpoints to ensure your site works across all browser sizes.
That said, a good site to look at if you're interested in various screen sizes is screensiz.es, where you can see popularity stats as well as their physical pixel widths.
Being device agnostic means that you won't have to readapt designs, and builds when Apple, or Samsung release their super thin, or super chunky devices.
A final suggestion to aid the functionality on the variety of devices would be to employ something like Modernizr to detect touch events.
Hope that helps.

A: I wonder if you are using the right tool for the job. Responsive design lets you stop trying to target specific devices or guess what the specifics of the next iPad / smartphone will be.
Set the break points to manage the layout of your design at different viewports and you are 90% done ;)


text:
Q: Angular send data from another component I woudlike to send data selected from my another component (variable in file .ts)
.html :

                <select class="form-control" name="Container" (change)="selectChangeHandler($event)">
                    <option disabled selected value> -- select an Container -- </option>
                    <option *ngFor="let v of values;let i = index" [value]="i">
                        {{v.Name}}
                    </option>
                </select>

{{selectedValue.Name}}

Matricule: {{selectedValue.Matricule}}

Material: {{selectedValue.Material}}

            <app-heat-local> </app-heat-local>

How can I get value for this component with using  to send my data in this component ?
another component .html (heat-local):

{{selectedValue.Name}}

my file .ts :
import {Component, OnDestroy, OnInit} from '@angular/core';
import {Cell} from 'app/data/cell';

@Component({
    selector: 'app-heat-global',
    templateUrl: './heat-global.component.html',
    styleUrls: ['./heat-global.component.css'],
    providers: [HeatService]
})

export class HeatGlobalComponent implements OnInit{

selectedValue = {
        Name: '',
        Matricule: '',
        Material:'',
        Quantity:'',
        Coordonates:'',
    }
    values = [{
        Name: "Container A",
        Matricule: "ABC",

A: From the question it seems that it could be possible to solve it this way.
You can set value of a selected option to property inside of selectChangeHandler()
selectChangeHandler(event) {
  this.currentValue = event.target.value;
}

To get it inside of app-heat-local

  <app-heat-local [value]="currentValue"> </app-heat-local>

To be able to set [value] attribute you need to define @Input() property inside of HeatLocalComponent
You could use @Input() to achieve this.
import {Component, Input} from '@angular/core';

@Component({
  selector: 'app-heat-local',
  templateUrl: './heat-local.component.html',
  styleUrls: ['./heat-local.component.scss']
})
export class HeatLocalComponent {
  @Input() value: number;
}

To display the value in heat-local.component.html you can you use interpolation

{{value}}

You can read more about component interaction
Update
To receive name instead of index just change value from i which is index to v.Name.

       {{v.Name}}

Or you can provide the whole object
<option *ngFor="let v of values;let i = index" [value]="v">
   {{v.Name}}
</option>

Becareful with type you specify in here. In previous part there is number type specified so it won't take anything else than number
import {Component, Input} from '@angular/core';

@Component({
  selector: 'app-heat-local',
  templateUrl: './heat-local.component.html',
  styleUrls: ['./heat-local.component.scss']
})
export class HeatLocalComponent {
  @Input() value: string // <== Here you can specify the type by TS type
}

string will be used just when value of an option is string, if you want to send whole object then change it to this @Input() value: any or define your own interface


text:
Q: PIL's image.paste operation degrades image / drawn text quality I am developing on a Windows 7 platform with Python 2.7.3 and PIL 1.1.7.
I am trying to write a python script to generate a set of images with text on them. Since I need to wrap text and fit it in an arbitrary bounding box, I wrote a method that draws text onto a white RGBA background image with the alpha transparency layer turned on. In order to simplify the problem, I wrote a small python script that illustrates the problem:
import Image,ImageDraw,ImageFont
import webbrowser

# sample text and font
text = "The text quality will degrade with the paste operation."
verdana_font = ImageFont.truetype("verdana.ttf", 20)

# get the line size
text_width, text_height = verdana_font.getsize(text)

# create a blank canvas with extra space between lines
blank_canvas = Image.new('RGB', (text_width + 10, text_height * 10 + 5 * 10), (255, 255, 255))

# create a blank RGBA canvas for the drawn text
text_canvas = Image.new('RGBA', (text_width, text_height), (255, 255, 255, 0))

draw = ImageDraw.Draw(text_canvas)

# draw the text onto the text canvas
draw.text((0,0), text, font = verdana_font, fill = "#000000")

# print 10 lines
for x in range(0,10):

    # calculate the coordinates for the paste operation and debug
    coordinates = (5, 5 + (x * (5 + text_height)))
    print "x = %d | coordinates = %r" % (x, coordinates)

    # paste the text onto the blank canvas
    blank_canvas.paste(text_canvas, coordinates, text_canvas)

    # create a temporary canvas
    temp_canvas = Image.new('RGBA', (text_width, text_height), (0, 0, 0, 0))

    # paste the text canvas onto the temp canvas using the png alpha layer for transparency
    temp_canvas.paste(text_canvas, (0,0), text_canvas)

    # swap the canvases
    text_canvas = temp_canvas

# save the blank canvas to a file
blank_canvas.save("paste-degradation.png", "PNG")

# open the image up to see the paste operation's image degradation
webbrowser.open("paste-degradation.png")

Each time the text gets pasted onto a new "temporary" canvas, the image quality of the drawn text gets worse and worse. The code above produces an image that looks like this:

Am I having an issue with my code? or is there a bug in PIL?

A: The issue is that draw.text() has a slightly unexpected behavior.
draw.text() draws the text by setting some pixels to fill (the ones definitely inside the text), and not touching other pixels (the ones definitely outside).  However, if a pixel is found to be, say, at 25% part of the text, then draw.text() will simply set the new pixel to be 25% of fill and 75% of the old value.  But such ratios are applied to all 4 components of RGBA independently.  In this example, your background is (255, 255, 255, 0) and fill is (0, 0, 0, 255): so the 25%-in-the-text pixel will be (192, 192, 192, 64).
But I would argue that this is not the intuitive result.  The intuitive result would have been (0, 0, 0, 64).  If you paste such a text on, say, a fully red image, then the pixel above would still end up contributing 25% of the light gray color (192, 192, 192).  In other words you will see gray borders, where you'd expect only black, red, and colors inbetween.
(In fact the explanation above is too simplified: setting the background to (0, 0, 0, 0) does not help.  I suspect it is because that color is in fact equivalent to (255, 255, 255, 0), i.e. fully transparent.  Moreover it seems that the same algorithm is used in a canvas.paste(img, (0,0), img) call.)
A way to fix it is to only use the alpha band of images drawn from text, i.e. replacing temp_canvas.paste(text_canvas, (0,0), text_canvas) with temp_canvas.paste("#000000", (0,0), text_canvas).


text:
Q: JBPM - No SQL Integration Can JBPM integrate with no-sql databases such as mongodb as its core db to store process states etc? Or does JBPM integrate better with relation databases such as MySQL as it seems to be using hibernate as ORM tool?

A: JBPM 7.x has some development to provision different type of data stores.
But this is just an experiments so far.
In versions prior to 7 it was though rather tight integration which resulted in dependencies to JPA being still needed. With version 7 persistence layer was refactored and enabled much cleaner integration with different (than default) persistence store.
Go here for more details


text:
Q: How do I access Google Cloud Datastore emulator using .Net Core? I have this simple console program in .Net Core v3.1:
static void Main(string[] args)
{
    var db = new DatastoreDbBuilder
    {
        ProjectId = "simple-proj",
        EmulatorDetection = EmulatorDetection.EmulatorOnly
    }.Build();

    var keyFactory = db.CreateKeyFactory("Simple");
    using (var transaction = db.BeginTransaction())
    {
        transaction.Insert(new Entity { Key = keyFactory.CreateIncompleteKey(), ["Message"] = "Hello" });
        transaction.Commit();
    }
}

I'm using the the Google.Cloud.Datastore.V1 v3.0.0 library to access the Datastore from my C# code. I started the emulator and set the environment variables using $(gcloud beta emulators datastore env-init) as the documentation says. I get an OK message back from the emulator endpoint (http://localhost:8081) when I access it via the browser. Everything seems to be in order.
This is the stack dump I get on my .Net console:
Unhandled exception. Grpc.Core.RpcException: Status(StatusCode=Unavailable, Detail="failed to connect to all addresses")
   at Grpc.Core.Internal.AsyncCall`2.UnaryCall(TRequest msg)
   at Grpc.Core.Calls.BlockingUnaryCall[TRequest,TResponse](CallInvocationDetails`2 call, TRequest req)
   at Grpc.Core.DefaultCallInvoker.BlockingUnaryCall[TRequest,TResponse](Method`2 method, String host, CallOptions options, TRequest request)
   at Grpc.Core.Interceptors.InterceptingCallInvoker.<BlockingUnaryCall>b__3_0[TRequest,TResponse](TRequest req, ClientInterceptorContext`2 ctx)
   at Grpc.Core.ClientBase.ClientBaseConfiguration.ClientBaseConfigurationInterceptor.BlockingUnaryCall[TRequest,TResponse](TRequest request, ClientInterceptorContext`2 context, BlockingUnaryCallContinuation`2 continuation)
   at Grpc.Core.Interceptors.InterceptingCallInvoker.BlockingUnaryCall[TRequest,TResponse](Method`2 method, String host, CallOptions options, TRequest request)
   at Google.Cloud.Datastore.V1.Datastore.DatastoreClient.BeginTransaction(BeginTransactionRequest request, CallOptions options)
   at Google.Api.Gax.Grpc.ApiCall.GrpcCallAdapter`2.CallSync(TRequest request, CallSettings callSettings)
   at Google.Api.Gax.Grpc.ApiCallRetryExtensions.<>c__DisplayClass1_0`2.<WithRetry>b__0(TRequest request, CallSettings callSettings)
   at Google.Api.Gax.Grpc.ApiCall`2.<>c__DisplayClass10_0.<WithCallSettingsOverlay>b__1(TRequest req, CallSettings cs)
   at Google.Api.Gax.Grpc.ApiCall`2.Sync(TRequest request, CallSettings perCallCallSettings)
   at Google.Cloud.Datastore.V1.DatastoreClientImpl.BeginTransaction(BeginTransactionRequest request, CallSettings callSettings)
   at Google.Cloud.Datastore.V1.DatastoreClient.BeginTransaction(String projectId, CallSettings callSettings)
   at Google.Cloud.Datastore.V1.DatastoreDbImpl.BeginTransaction(CallSettings callSettings)
   at simple.Simple.Main(String[] args) in /Users/wreid/git/leapsystems/research/console-reports/Simple.cs:line 20

And this is the corresponding Datastore emulator console message:
[datastore] Jul 24, 2020 5:48:42 PM io.gapi.emulators.grpc.GrpcServer$3 operationComplete
[datastore] INFO: Adding handler(s) to newly registered Channel.
[datastore] Jul 24, 2020 5:48:42 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
[datastore] INFO: Detected non-HTTP/2 connection.
[datastore] Jul 24, 2020 5:48:42 PM io.gapi.emulators.netty.NotFoundHandler handleRequest
[datastore] INFO: Unknown request URI: /bad-request

Am I missing something obvious somewhere either in my code or the setup of the emulator?


text:
Q: Get Org URL from Lightning component I am operating in an org: https://myorg.lightning.force.com.  If I call URL.getSalesforceBaseUrl() from an apex class I get the base org URL back.  If I then use the same command in a controller for a lightning component in a community I get the community's base URL: https://mycommunity.aa11.force.com.
Any ideas on how I can get the Org URL (https://myorg.lightning.force.com) in a lightning component dynamically?

A: Sorry for reviving an old post, but I was trying to find the same answer as OP and wanted to provide my solution for anyone else who might stumble upon this post:
   public static String getLexOriginUrl() {
        String prefix = URL.getSalesforceBaseURL().toExternalForm().replace('https://', '').split('\\.')[0];
        prefix = prefix.removeEnd('--c');
        return 'https://' + prefix.toLowerCase() + '.lightning.force.com';
    }

A: String Host = URL.getSalesforceBaseUrl().toExternalForm() + '/';
This will return https://yourinstance.salesforce.com/
then you can pass this to your controller.js file and use it.
Hope this answer your question

A: You can simply reference the apex class as your server side controller and fetch the value on the client side?
Server side controller:
public with sharing class theorgurl {

    @AuraEnabled
    public static String fetchit(){
        string urler = URL.getSalesforceBaseUrl().toString();
        return (urler);
    }
}

Client side controller:
"geturl" : function(cmp) {

        var action = cmp.get("c.fetchit");
        action.setParams({ urlname : cmp.get("v.urlname") });

        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
             ...Do something with response.getReturnValue()...
        }
}

If you are unsure on how to proceed, I would recommend you go through the Lightning Components Developer Guide since

the framework supports client-side and server-side controllers.

A: In case you want to get your org URL without APEX, use:
let hostname = window.location.hostname;


text:
Q: toggle nav on and off Here's in this JSfiddle, I am trying to toggle the nav on and off, but doesn't seem to be working. It's seems to close the nav bar once clicked, then do nothing else. I'm pretty new to working with jQuery. Can anyone tell me how I can correct this, and also I need the nav not to even show before the menu button is clicked. Thanks!
    $(function() {
      var showMenu = false;
      $('#menuButton').click(function() {
        if (showMenu) {
          $('#menu').css({'display':'none'});
          showMenu = false;
          return;
        }
        $('#menu').css({'display':'block'});
        showMenu = true;
      });
    });

A: here is the working fiddle
I have change selector to checkbox ie #spinner-form2 instead of #menuButton

A: As you said, you want to toggle, so do so:
$("#menuButton").click(function() {
    $("#menu").toggle();
}

http://api.jquery.com/toggle/


text:
Q: Aurelia component slotting in markup for components model I am building an autocomplete component. The plan is that I can slot in some markup for what I know the component is going to bind to.
The idea is this could be any object rather than a simple display value and identifier.
I have this working using templates but I am wondering if there is a better approach.
So far it looks like this (options is hard coded for now within the components model):
// Usage:
<autocomplete>
  <template replace-part="item">
    //this is the content for each option within the component
    ${option.lastName}, ${option.firstName}
  </template>
</autocomplete>

//autocomplete
<template>
  <input type="text" placeholder="Type 3 characters ...">

      <template replaceable part="item"></template>

</template>

I don't really like the templating boilerplate, slots are much nicer, is there any way to make slots work like this?
<autocomplete>

        ${option.lastName}, ${option.firstName}

</autocomplete>

//autocomplete
<template>
  <input type="text" placeholder="Type 3 characters ...">

    <slot></slot>

</template>

A: Slot in Aurelia is the emulation based on standard spec, which mean it doesn't work with repeat situation. repaceable was introduced to handle this scenario and I don't think we have any other options. Sometimes it feels weird but with a little documentation, probably you and your team will be fine. What you can do is for each replacement, what properties it can look for to get the item.


text:
Q: Why Proc Sql is faster than Proc Summary for sum-function? I have a column-based DB2-Blu table (DB2-Blu fixes indexing by itself) with 30.000 peer-groups and 50.000 values per peer group, total 1.5 billion rows.
I did a test to compare the run-time with two different processes: Proc Summary and Proc Sql like below:
proc summary data = table_blu  nodisplay nway missing chartype;
   /* Var1 and var2 are toghether peer-group  */
   class var1 var2 / groupinternal;
   var values;

   output out = stattable
   sum=sum
;
run;

Calculating only the sum-up through the peer-groups and it took around 14 min
Then I did the similar calculation with Proc SQL like below:
proc sql;
   create table stattable as
   select var1, var2, sum(values);
   from table_blu
   group by var1, var2;
quit;

This Proc SQL took only 1,26 min. It is definitely much less run_time comparing to the 14 min with Proc Summary process.
How can it be so big difference? Can it happen because the table is column-based? Maybe SAS is not optimal for column-based tables?

A: PROC SUMMARY will perform in-database processing if the database supports it and is supported by SAS, which will then be quite fast (and may well end up being identical to the PROC SQL, or may be faster).
However, this depends on both the DBMS and SAS.  You're also adding an added layer here - the database acceleration software itself.
SAS has supported DB2 for a long time, but it's only supported DB2-BLU since 9.4M3 (one maintenance release before the current one, so about a year and a half).  If you don't have 9.4M3 then you almost certainly don't have direct support, and thus probably aren't taking advantage of BLU and/or aren't taking advantage of in-database processing.
It's also possible that, since this is fairly new, that the in-database processing isn't as well implemented as you'd need; for example, I don't know if groupinternal is supported.  Anything that SAS doesn't know how to translate to the DBMS, whether because it's something the DBMS doesn't support or because SAS hasn't implemented support for it yet, will cause SAS to download the whole table.
So my suggestion is:

*

*Verify you have 9.4 TS1M3 or newer, and if not, get it.  There is not typically a charge for upgrading to newer versions of SAS, so this should be doable, if some work.

*If you do, try running a simpler summary (remove all options, just proc summary data=[yourdatabase.yourtable]; class [some class variable]; var [some variable]; output out=[something] sum=; run; or similar) and see if that is quicker.  That'll at least tell you something.

*Have your DBA or IT folks look at the database and/or network traffic and see if PROC SUMMARY is downloading the whole dataset; the DBA should be able to tell you what query SAS is running (if it's running a SQL summary or if it's just running SELECT and then is running the summary SAS-side) and/or IT should at least be able to tell you what's going over the network size-wise.  Even if SAS is running the summary in DB2, maybe it's not running an optimized query.

*Then, if you do have 9.4 TS1M3, open a SAS support track and give them the details from 2 and 3, plus your original question.  They should be able to tell you whether it's expected that this query run on the database or if it's always going to download the table first, and then if so, what you can do about it (if anything).

A: Assuming that the source table is within the work libname and not in a remote database, proc summary should perform faster than proc sql.
I tested below by creating a table with 190m observations and summarizing the data using both techniques:
332  data x;
333    set sashelp.class;
334    do i=1 to 10000000;
335      output;
336    end;
337  run;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: The data set WORK.X has 190000000 observations and 6 variables.
NOTE: Compressing data set WORK.X decreased size by 15.12 percent.
      Compressed is 118495 pages; un-compressed would require 139604 pages.
NOTE: DATA statement used (Total process time):
      real time           1:23.30
      cpu time            1:04.79

338
339
340  proc summary data=x noprint nway missing chartype;
341     class sex age / groupinternal;
342     var height;
343     output out=stattable sum=sum;
344  run;

NOTE: Multiple concurrent threads will be used to summarize data.
NOTE: There were 190000000 observations read from the data set WORK.X.
NOTE: The data set WORK.STATTABLE has 11 observations and 5 variables.
NOTE: Compressing data set WORK.STATTABLE increased size by 100.00 percent.
      Compressed is 2 pages; un-compressed would require 1 pages.
NOTE: PROCEDURE SUMMARY used (Total process time):
      real time           1:04.79
      cpu time            1:11.65

345
346
347  proc sql noprint;
348    create table xx as
349    select sex, age, sum(height)
350    from x
351    group by 1,2
352    ;
NOTE: SAS threaded sort was used.
NOTE: Compressing data set WORK.XX increased size by 100.00 percent.
      Compressed is 2 pages; un-compressed would require 1 pages.
NOTE: Table WORK.XX created, with 11 rows and 3 columns.

353  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           2:09.56
      cpu time            1:47.12

As you can see proc sql took almost twice the time.


text:
Q: Java/SpotBugs, What is a "named static inner class", if it's being declared in an interface? I inherited a codebase that uses MyBatis. SpotBugs is telling me that that SubjectRepositoryQueries could be refactored into a named _static_ inner class. I've never encountered this term, I was hoping someone could explain what exactly it's asking me to do better. It would seem that SubjectRepositoryQueries is in fact named (it's not anonymous), and it's already static. SubjectRepositoryQueries can't be declared private because it's inside an interface.
@Mapper
public interface SubjectRepositoryService {
  @SelectProvider(type = SubjectRepositoryQueries.class, method = "search")
  List<Subject> search(SubjectSearch subjectSearch);

  static final class SubjectRepositoryQueries {
    public String search(final SubjectSearch subjectSearch) {
      ... some string generation
    }
  }
}

Thanks!

A: When you declare an inner class
class Outer {
    class Inner {
    }
}

even when you haven't declared any fields in Inner, the java compiler will automatically insert a synthetic field that holds the outer class reference, typically called something like this$0. So if you run javap on the Inner class, you will see it.
The idea is, that in many cases, having that reference variable is a waste of space, and more importantly causes things like serialization to cause unexpected problems.
Imagine that the outer class had all kinds of fields in it, and was massive. Now imagine you wanted to only serialize the inner class, if you tried that you would be surprised to find that the entire inner and outer instance would be serialized making for a much slower and bigger experience.
By decorating the inner class with 'static' you are removing this synthetic field reference to the outer class, and stopping that from happening.
There are other things that having a normal inner class causes. For instance you can't create an instance of the inner class without creating the outer class, which causes really arcane syntax like
Outer.Inner i = new Outer().new Inner();

A: It's unclear what the specific warning means. If your only goal is to remove the warning then given that your inner class isn't implementing an interface, you can simply convert it to a static method.
@Mapper
public interface SubjectRepositoryService {
    //...

    static String search(final SubjectSearch subjectSearch) {
        //... some string generation
    }
}


text:
Q: Decrypt kerberos ticket using Spnego I'm using spnego ( http://spnego.sourceforge.net ) for kerberos authentication under JBoss.
I need to decrypt kerberos ticket to access the authorization-data which will containt PAC data. The PAC data is needed to decide which roles are to be granted to user.
How to access and decrypt kerberos ticket? I've searched net for examples, but without effort.

A: These guys have a full PAC decoding implementation:
http://jaaslounge.sourceforge.net/
You can use the token parser like this:
HttpServletRequest request = (HttpServletRequest) req;
String header = request.getHeader("Authorization");
byte[] base64Token = header.substring(10).getBytes("UTF-8");
byte[] spnegoHeader = Base64.decode(base64Token);

SpnegoInitToken spnegoToken = new SpnegoInitToken(spnegoHeader);

You're going to need to jump though some hoops if you want to decrypt the underlying Kerberos ticket.  Not sure if you need that.
Grant

A: I have successfully used the servlet filter from http://spnego.sourceforge.net in combination with the PAC parser from http://jaaslounge.sourceforge.net/ without the need to do something explicitly with DER/ASN.1 parsers :
/**
 * Retrieve LogonInfo (for example, Group SID) from the PAC Authorization Data
 * from a Kerberos Ticket that was issued by Active Directory.
 */
byte[] kerberosTokenData = gssapiData;
try {
    SpnegoToken token = SpnegoToken.parse(gssapiData);
    kerberosTokenData = token.getMechanismToken();
} catch (DecodingException dex) {
    // Chromium bug: sends a Kerberos response instead of an spnego response
    // with a Kerberos mechanism
} catch (Exception ex) {
    log.error("", ex);
}

try {
    Object[] keyObjs = IteratorUtils.toArray(loginContext.getSubject()
                         .getPrivateCredentials(KerberosKey.class).iterator());
    KerberosKey[] keys = new KerberosKey[keyObjs.length];
    System.arraycopy(keyObjs, 0, keys, 0, keyObjs.length);

    KerberosToken token = new KerberosToken(kerberosTokenData, keys);
    log.info("Authorizations: ");
    for (KerberosAuthData authData : token.getTicket().getEncData()
                                             .getUserAuthorizations()) {
        if (authData instanceof KerberosPacAuthData) {
            PacSid[] groupSIDs = ((KerberosPacAuthData) authData)
                                      .getPac().getLogonInfo().getGroupSids();
            log.info("GroupSids: " + Arrays.toString(groupSIDs));
            response.getWriter().println("Found group SIDs: " +
                Arrays.toString(groupSIDs));
        } else {
            log.info("AuthData without PAC: " + authData.toString());
        }
    }
} catch (Exception ex) {
    log.error("", ex);
}

I've also written a new HttpFilter (forked from spnego.sf.net): spnego-pac, that discloses the LogonInfo through the getUserPrincipal().
An example project demonstrating the above code in full can be found here:
https://github.com/EleotleCram/jetty-spnego-demo
The spnego-pac filter (used in the above example) can be found here:
https://github.com/EleotleCram/spnego.sf.net-fork
Hope this is helpful to anyone.
__
Marcel

A: If you get the mechanism token from the spnegoToken like this:
byte[] mechanismToken = spnegoToken.getMechanismToken();

The mechanism token is usually a KerberosApRequest.  There is a KerberosToken constructor which takes a KerberosApRequest.  Simply pass in the mechanismToken byte array along with the key to decrypt the contents.

A: I provide my own solution to the problem:
I've based my solution on BouncyCastle library (for parsing parts of token) and JaasLounge (for decrypting encrypted part of token). Unfortunatelly, the code for decoding whole spnego token from JaasLounge failed for my requirements. I had to write it myself.
I've decoded ticket part by part, firstly constructing DERObjects from byte[] array:
private DERObject[] readDERObjects(byte[] bytes) throws IOException {
    ASN1InputStream stream = new ASN1InputStream(new ByteArrayInputStream(
        bytes));
    List<DERObject> objects = new ArrayList<DERObject>();
    DERObject curObj;
    while ((curObj = stream.readObject()) != null) {
        objects.add(untag(curObj));
    }
    return objects.toArray(new DERObject[0]);
}

The untag() is my helper function, to remove DERTaggedObject wrapping
private DERObject untag(DERObject src) {
    if (src instanceof DERTaggedObject) {
        return ((DERTaggedObject) src).getObject();
    }
    return src;
}

For extracting sequence of DERObject from given DERObject I've written another helper function:
private DERObject[] readDERObjects(DERObject container) throws IOException {
// do operation varying from the type of container
if (container instanceof DERSequence) {
    // decode using enumerator
    List<DERObject> objects = new ArrayList<DERObject>();
    DERSequence seq = (DERSequence) container;
    Enumeration enumer = seq.getObjects();
    while (enumer.hasMoreElements()) {
    DERObject curObj = (DERObject) enumer.nextElement();
    objects.add(untag(curObj));
    }
    return objects.toArray(new DERObject[0]);
}
if (container instanceof DERApplicationSpecific) {
    DERApplicationSpecific aps = (DERApplicationSpecific) container;
    byte[] bytes = aps.getContents();
    return readDERObjects(bytes);
}
if (container instanceof DEROctetString) {
    DEROctetString octets = (DEROctetString) container;
    byte[] bytes = octets.getOctets();
    return readDERObjects(bytes);
}
throw new IllegalArgumentException("Unable to decode sequence from "+container);
}

At the end, when I've got DEROctetStream, that contained encrypted part, I've just used KerberosEncData:
KerberosEncData encData = new KerberosEncData(decrypted, matchingKey);

The byte sequence we receive from client browser will be parsed into single DERApplicationSpecific
which is ticket root - level 0.
The root contains:

*
* DERObjectIdentifier - SPNEGO OID

*DERSequence - level 1

Level 1 contains:

*
*SEQUENCE of DERObjectIdentifier - mech types

*DEROctetString - wrapped DERApplicationSepecific - level 2

Level 2 contains:

*
*DERObjectIndentifier - Kerberos OID

*KRB5_AP_REQ tag 0x01 0x00, parsed as boolean (false)

*DERApplicationSpecific - container of DERSequence - level 3

Level 3 contains:

*
*version number - should be 5

*message type - 14 (AP_REQ)

*AP options (DERBITString)

*DERApplicationSpecific - wrapped DERSequence with ticket part

*DERSeqeuence with additional ticket part - not processed

Ticket part - level 4 contains:

*

*Ticket version - should be 5

*Ticket realm - the name of the realm in which user is authenticated

*DERSequence of server names. Each server name is DERSequence of 2 strings:
server name and instance name

*DERSequence with encrypted part

Encrypted part sequence (level 5) contains:

*

*Used algorithm number

*

*1, 3 - DES

*16 - des3-cbc-sha1-kd

*17 - ETYPE-AES128-CTS-HMAC-SHA1-96

*18 - ETYPE-AES256-CTS-HMAC-SHA1-96

*23 - RC4-HMAC

*24 - RC4-HMAC-EXP

*Key version number

*Encrypted part (DEROctetStream)

The problem was with DERBoolean constructor, that throw ArrayIndexOutOfBoundException, when sequence 0x01 0x00 was found. I had to change that constructor:
public DERBoolean(
    byte[]       value)
{
// 2011-01-24 llech make it byte[0] proof, sequence 01 00 is KRB5_AP_REQ
if (value.length == 0)
    this.value = 0;
else
    this.value = value[0];
}

A: Wow been a while since I've used spnego (nearly a year) ... You're asking a very cool question.
I did a little digging and was going to try and run up some code I had from a while back that was working with MS-AD but just not feeling it today :-/
Anyway, I found this link through google:
http://www.google.com/url?sa=t&source=web&cd=1&sqi=2&ved=0CBMQFjAA&url=http%3A%2F%2Fbofriis.dk%2Ffiles%2Fms_kerberos_pac.pdf&rct=j&q=java%20kerberos%20privilege%20attribute%20certificate&ei=2FASTbaLGcP38Abk07iQDg&usg=AFQjCNHcIfQRUTxkQUvLRcgOaQksCALTHA&sig2=g8yn7ie1PbzSkE2Mfv41Bw&cad=rja
Hopefully that can give you some insight.


text:
Q: Entity Framework NullReferenceException calling ToList? I'm very new to WPF and the EF, and I'm trying to display some data from a table in a datagrid. I've got the entity model pulled from an existing database and simple operations seem to work (getting row counts, using 'first').
I'm running against Firebird 2.5.0 using the 2.0.5 DDEX provider and 2.5.2 ADO NETProvider.
When I try to get the data into the grid or simply into a list, I get a null reference exception.
Possibly I just don't understand how to use the entity framework, but the examples I see on the net make it look really easy.
public partial class Page1 : Page
{
    Entities context;

    public Page1()
    {
        context = new Entities();

        InitializeComponent();

        // This works to get a row into the grid
        var arep = context.SALESREPs.First();
        var alist = new List<SALESREP>();
        alist.Add( arep );
        gridUserList.ItemsSource = alist;

        // These both fail with null ref exception
        var allreps = context.SALESREPs.ToList();
        gridUserList.ItemsSource = context.SALESREPs;
    }
}

Here's the exception detail:
System.NullReferenceException was unhandled by user code
Message=Object reference not set to an instance of an object.
Source=System.Data.Entity
StackTrace:
   at System.Data.EntityKey.AddHashValue(Int32 hashCode, Object keyValue)
   at System.Data.EntityKey.GetHashCode()
   at System.Collections.Generic.GenericEqualityComparer`1.GetHashCode(T obj)
   at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
   at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)
   at System.Data.Objects.ObjectStateManager.TryGetEntityEntry(EntityKey key, EntityEntry& entry)
   at System.Data.Common.Internal.Materialization.Shaper.HandleEntityAppendOnly[TEntity](Func`2 constructEntityDelegate, EntityKey entityKey, EntitySet entitySet)
   at lambda_method(Closure , Shaper )
   at System.Data.Common.Internal.Materialization.Coordinator`1.ReadNextElement(Shaper shaper)
   at System.Data.Common.Internal.Materialization.Shaper`1.SimpleEnumerator.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at PSUserMaintenanceWebUI.Page1..ctor() in C:\Documents and Settings\d...\my documents\visual studio 2010\Projects\UserMaintenance\UserMaintenanceWebUI\Page1.xaml.cs:line 36
   at System.Xaml.Schema.XamlTypeInvoker.DefaultCtorXamlActivator.InvokeDelegate(Action`1 action, Object argument)
   at System.Xaml.Schema.XamlTypeInvoker.DefaultCtorXamlActivator.CallCtorDelegate(XamlTypeInvoker type)
   at System.Xaml.Schema.XamlTypeInvoker.DefaultCtorXamlActivator.CreateInstance(XamlTypeInvoker type)
   at System.Xaml.Schema.XamlTypeInvoker.CreateInstance(Object[] arguments)
   at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CreateInstanceWithCtor(XamlType xamlType, Object[] args)
   at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CreateInstance(XamlType xamlType, Object[] args)

InnerException:

A: My table has a multi-field primary key with some of the fields being nullable. The entity framework doesn't like nullable fields in the primary key. I removed those rows and it works fine. I'm already in the process of finding a different solution to the requirement that prompted us to allow nulls in some of the primary key fields.


text:
Q: erroneous react-controlled-components warning? This JSX code segment is generating a react-controlled-components warning:
          <input
            type="text"
            className="form-control endpoint-text"
            placeholder="fred.scuttle"
            value={ this.props.internals.username }
            onChange={ this.handleUserNameChange.bind(this) }
          />

Generates this warning in the console:

Warning: A component is changing an uncontrolled input of type text to be controlled. Input elements should not switch from uncontrolled to controlled (or vice versa). Decide between using a controlled or uncontrolled input element for the lifetime of the component. More info: https://reactjs.org/docs/forms.html#controlled-components

This is a large react/redux application with many, many controlled components and if you follow the link above, my code looks fine.
Anyone see my error? I can't figure it out. It is possible that the state value 'username' is undefined when this form is loaded, but this is not the warning/error I usually get for calling an undefined state datum.
Thanks in advance!
@Nandu Kalidindi:
  handleUserNameChange = (event) => {
    this.props.emitSetUserName(event.target.value);
  }

which simply sets/updates the username field in the redux state:
export function emitSetUserName(uname) {
  return {
    type: EMIT_SET_NAME_CHANGE,
    payload: uname
  }
}

The initial value for that state variable is loaded from a cookie in the same component:
 componentWillMount = () => {
   let username = cookies.get('uname');
   if ( username !== undefined ) {
     this.props.emitSetUserName(username);
   }
 }

Is this a race condition? I would expect an error for trying to access and undefined state value, not a "controlled input" warning...

A: It was indeed a race condition. I needed to process the cookied and set the state accordingly in the parent component. defaultValue works correctly now, too. Thanks for the feedback!