\n'''"},"Answer":{"kind":"string","value":"The browser does excacly what you are telling him to do :)\nHowever I think you don't like the overflow it has.\nWhat happens is that your '#box' expands because of your border and padding. You can make these properties inset, so it does not expand your element. You can do this with 'box-sizing':\n'''\n#box {\nwidth: 100%;\nheight: 100%;\nborder: 5px solid red;\npadding: 15px;\n/*margin: 20px;*/\nbox-sizing: border-box;\n}\n'''\nHowever you can not do the same with the 'margin', because the element is pushing itself from the body: it does what it supposes to do.\nYou can make a workaround by doing the same thing as above:\n'''\nbody\n{\npadding: 20px;\nbox-sizing: border-box;\n}\n'''\n'#box'\n## jsFiddle\nTo prevent the double padding space, you should only apply it on the body element (or html, but i prefer the body as that is your visual element in the end)."},"Image":{"kind":"image","value":{"src":"https://datasets-server.huggingface.co/assets/mirzaei2114/stackoverflowVQA-filtered/--/f7f8542dcc90dcbfbd6754ed4e1db8f518357867/--/default/train/7/Image/image.jpg?Expires=1755824187&Signature=jCwn-WqTvAGmNhkC24gGFRPVM7dPrEVsV3-Lz7P51ox6Fy~X9kCOHN~tI77T--FdICdxAmr4rxJtJo0SVqF2BeoToob0AaT~exsUscm~4JkT2kJCxg1~P9TX1Ge8fZFPlSiBy9gfN-ydHcQqMMCNvIjpbn~SWgESR-M4rDmfqFPDqfEem-pNRs6n5IH5exU6j02VzaOcN989klbhYDjNMf8tqf2Sjt4TdddQPSUEKmUMUJH36si8OZL-liHbWPEugOSGDHct8xd3et88gnNiQ0icChcxiJU3zbazu2SxTGNnkOoWx8To6sjGnn1fyC2xA9sVGPzD5UUcU~clFLIG9A__&Key-Pair-Id=K3EI6M078Z3AC3","height":688,"width":1323},"inferredFromUrl":false}}},{"rowIdx":8,"cells":{"Id":{"kind":"number","value":12058624,"string":"12,058,624"},"PostTypeId":{"kind":"number","value":1,"string":"1"},"AcceptedAnswerId":{"kind":"number","value":12058836,"string":"12,058,836"},"Question":{"kind":"string","value":"I am loading 'http://www.google.com' url in the the WebView.\nBut, even though I am loading it from the device/simulator, the content of the webview is not getting adjusted based on the device dimensions.\n\nIf you see, Google page is not getting set properly according to the dimensions of the WebVie. But, if I open the same url in the simulator browser with same dimensions, then its loading properly with scaling etc.\nHow to make a webview load properly on a WebView in Android?\nHere is the XML of the WebView Layout\n''\nMainActivity.java file\n'WebView web_view =(WebView)findViewById(R.id.webView1); web_view.getSettings().setLoadWithOverviewMode(true); web_view.getSettings().setUseWideViewPort(true); web_view.loadUrl(\"google.com\";);'"},"Answer":{"kind":"string","value":"You need to change the user-agent to make it not load mobile sites.\n---\nTry this\n'''\n\n'''"},"Image":{"kind":"image","value":{"src":"https://datasets-server.huggingface.co/assets/mirzaei2114/stackoverflowVQA-filtered/--/f7f8542dcc90dcbfbd6754ed4e1db8f518357867/--/default/train/8/Image/image.png?Expires=1755824187&Signature=Jm9IZagKpMp-pMbPuBDobZSZPYKiiQdhRlWUoen-Kb36y~jdbqh7zp~1iThMlPFHqloQwJYz1bnTBWfL-tBnz6PTgSrTVi~quQ5I5toHLTT9JPH6RiDHlnkSUh148WIHRnIFNtEHInR5THhvce74Wm3pNsZu161YYKuEA6tc2RFYw3bXMpveqkYKGqlgdhsWV2UGVasGQpkR8dTboG-iQdNJGaDovJfr7zzN-6MTK2KKVPPNgYlPndb9GMf7bkXQL1CtClRvB5eQJRCmambp8tzgWRjrZewAO3ghtvA1OffL-q3tdx1TCknIE3GbhwYIe8p1BDvgZmm-phd2VrznXg__&Key-Pair-Id=K3EI6M078Z3AC3","height":1061,"width":706},"inferredFromUrl":false}}},{"rowIdx":9,"cells":{"Id":{"kind":"number","value":29038250,"string":"29,038,250"},"PostTypeId":{"kind":"number","value":1,"string":"1"},"AcceptedAnswerId":{"kind":"number","value":29043491,"string":"29,043,491"},"Question":{"kind":"string","value":"How would you go about having tags already being preselected in their selectbox at the time the page loads? Here's my code so far:\nHTML:\n'''\n\n'''\nJS:\n'''\n$(\".operatingSystems\").select2({tags: true, tokenSeparators: [',', ' ']});\n'''\nI'm basically trying to get it to look something like it does on the select2 documentation page where they have \"orange\" and \"purple\" preselected. From: "},"Answer":{"kind":"string","value":"You can select an existing option by setting the 'selected' property.\n'''\n\n'''\nWould pre-select the OSX option in the select box. This isn't specific to Select2, it's how you set a pre-selected option in general for select boxes (both single and multiple select).\nYou can do this using vanilla JavaScript by setting the 'selected' property on the element.\n'''\ntheOption.selected = true;\n'''\nOr using jQuery's '.val' method for setting the value.\n'''\n$(\"select\").val([\"OSX\"])\n'''\nIn order for Select2 and other plugins to pick up the change in value, you may need to trigger the 'change' event.\n'''\n$(\"select\").trigger(\"change\")\n'''"},"Image":{"kind":"image","value":{"src":"https://datasets-server.huggingface.co/assets/mirzaei2114/stackoverflowVQA-filtered/--/f7f8542dcc90dcbfbd6754ed4e1db8f518357867/--/default/train/9/Image/image.jpg?Expires=1755824187&Signature=u6i4I5N2filUONG4IY5nw30xlvDJa7uv1hJvX9fIVQvOyi7YJXiyFtT3q7FKokP0JPgylYXHBPiiNGIkSWY7F0EIj0SdbLs2yoqan~~SkgnJ~XjFbrRL6dDILRF1Xl2m4CqeT9fgv0pFt7z1mMeca-V7f9Bq8pH~JGyBiMBR19SGldZrdO8cE67RdR1jzTxkT0A7Mvt1FQCHhDKSOOHBR5KLS5Rd~8ziGXVCyCc25KOcdH5seiaj94vzAXUqPzIgiKcclOqEKVAuhsfec~Kh1GseWGGLFxy2bR0QuUFE1plgeT0iCYWX5nMC-gEmg3jaVp1HJhNFFurs4R9Qqj4hPg__&Key-Pair-Id=K3EI6M078Z3AC3","height":288,"width":1221},"inferredFromUrl":false}}},{"rowIdx":10,"cells":{"Id":{"kind":"number","value":15351422,"string":"15,351,422"},"PostTypeId":{"kind":"number","value":1,"string":"1"},"AcceptedAnswerId":{"kind":"number","value":15352141,"string":"15,352,141"},"Question":{"kind":"string","value":"This might explain my question a bit better:\nI need one child div positioned on top of the other so that the last-child is only showing around the edges, but the two child divs need to scroll together and keep the background of the first-child div static. This mesa that the viewport would be the first-child, but the content of the first and second child would have to scroll within the container so they can scroll together., with the first-child being the viewport.\n---\nI have the following HTML structure:\n'''\n
\n
\n
Row
\n
Row
\n
Row
\n
Row
\n
Row
\n
Row
\n
\n
\n\n\n\n\n\n\n
\n
\n'''\nThe 'bars' extend to the width of the page, and the 'text' div is overlaid on top of them, with a margin around it. I position each 'bars' div so that they match up at the same horizontal level with the visually corresponding 'row'.\nThe 'text' div is positioned to be 'x' pixels from each side, so that there is a margin around it. This way, you can see the ends of the 'bars' below it.\nThe markup is easy, but I can't figure out the CSS for this...\n'text' is positioned absolutely, so that it can extend to the bounds of the page with a margin. This is fine if the content inside it stays within the bounds, but it does not in this case.\n: I set 'container' to 'overflow:scroll' because I need the 'bars' to scroll with the 'rows'. Since 'text' has a background image, and is positioned so that you can just see the ends of the 'rows' beneath it, it has to be 'position:absolute'. This doesn't work, however, when the content exceeds the bounds of 'text. I can't add the background image to'container'because it would cover the ends of the'bars'.\nDoes that make sense? No? Here's a jsFiddle: \nDoes it still not make sense? Here's a picture:\n\nAny ideas? Ask me some questions so I can explain this better."},"Answer":{"kind":"string","value":"You don't need a lot of the css that's there -- for example the .container. If I understand correctly (and I'm not 100% sure I do) you'd like a image on the .text div which remains fixed while the rest of the page -- bars and text scroll.\nYou cannot put the image on the text div as it will scroll; rather, I suggest putting the image on each .row with a 'position: fixed' as well as using 'padding-bottom:20px' instead of the margin, so that there appears to be an image behind all of the rows and the effect is continuous. That will give you the effect I think you're after\n"},"Image":{"kind":"image","value":{"src":"https://datasets-server.huggingface.co/assets/mirzaei2114/stackoverflowVQA-filtered/--/f7f8542dcc90dcbfbd6754ed4e1db8f518357867/--/default/train/10/Image/image.jpg?Expires=1755824187&Signature=rC1c0gDLp99MJ3cdlxBTvvxpIDuFl59HbEU~s7C-Vy9V6Uw8qmRJ0-I4VDRpBEG6TI6BiTj-FjHkOdnjpnExd65jFoqa7hIiBIjVeyV139Agg0fPnyv8VROC-UodgZfBIyxOaqJn-ZqSEHZm8AV9LJNUkSmywn2TOetYSvFv94nIdLIjo9bkvO2DSsbrphtJ5vkejhNpamx8pxZBeF007hD4UBqYQEOJi4e5mFRLholWqbQD9l9GqfaqjqEXQP-xlGOgHPgf1z71muDZXm0Lb-XorGLHMXTvz2L-~5tUsFaTwblnH-vRPo3R3dRHDKN6ixUIvNE12lysdhfi3wqESg__&Key-Pair-Id=K3EI6M078Z3AC3","height":300,"width":800},"inferredFromUrl":false}}},{"rowIdx":11,"cells":{"Id":{"kind":"number","value":27097967,"string":"27,097,967"},"PostTypeId":{"kind":"number","value":1,"string":"1"},"AcceptedAnswerId":{"kind":"number","value":27524199,"string":"27,524,199"},"Question":{"kind":"string","value":"Today morning I build and run my xcode project. When simulator launched I saw this:\n\nThe screen is , I see only are .\nDid anybody faced with same problem? The issue happens in , also in .\nI tried to Clean project, switched to , , the same problem.\nAlso, this happens with my other iOS projects."},"Answer":{"kind":"string","value":"I why this bug appears at and not at :)\nBecause at work external display (), but at home (DELL, non-retina off course)\nIf you want this bug not to appear, just connect your macbook to external non-retina monitor. Then you may work fine, run simulator in macbook retina display, also in external monitor display, while Apple hard works to fix this bug in OS X.\nHere is the video proof: "},"Image":{"kind":"image","value":{"src":"https://datasets-server.huggingface.co/assets/mirzaei2114/stackoverflowVQA-filtered/--/f7f8542dcc90dcbfbd6754ed4e1db8f518357867/--/default/train/11/Image/image.png?Expires=1755824187&Signature=gNlHWwnrXR0cx2UiH2aUDZS8b6YTHWIpAM20an2vfrmY3nYmai~Ly4poJj-xlF0o7N6UNe5rQeHfcb21u1zZzrNIB5fkLsqzpZfHQxNxAWcyzbM1~kfho6a0JwWtpkWnGmd4Vx18gm1OYGz6mjHv2-FBYu6n3OvdM0N46kH7qMg0lnKr5DrOLPAIpN7nSRSFPubNaDPIUEV6zlqIVCLATazYHkkton7xSBDPxLswfb0fGxVPNAo-uJi2Gy5ta9C8HmIzVg8vzyhj~aqTaAzLUKwGqJoZWtb27jthGIjLyiVof1nnblpYjsEOuaU6loWnZJqbU9f3fQqei0aLvcCHow__&Key-Pair-Id=K3EI6M078Z3AC3","height":1378,"width":750},"inferredFromUrl":false}}},{"rowIdx":12,"cells":{"Id":{"kind":"number","value":64929913,"string":"64,929,913"},"PostTypeId":{"kind":"number","value":1,"string":"1"},"AcceptedAnswerId":{"kind":"number","value":64930167,"string":"64,930,167"},"Question":{"kind":"string","value":"The mentions the following in the \" Reactivity > Updating arrays and object \" chapter:\n\nThe documentation mentions updating references to 'obj.foo.bar' but the 'foo' variable is a separate copy of 'obj.foo'. So I can't see how doing 'obj=obj' would update reference to 'obj.foo.bar', as 'bar' is declared as an object property for 'foo', not for 'obj.foo'.\nCan someone translate what is meant here? There is probably a bug to file at least for clarifying things but I'd need to understand what's meant here first."},"Answer":{"kind":"string","value":"Take a look at this REPL that will help with understanding why the reassignment is necessary. "},"Image":{"kind":"image","value":{"src":"https://datasets-server.huggingface.co/assets/mirzaei2114/stackoverflowVQA-filtered/--/f7f8542dcc90dcbfbd6754ed4e1db8f518357867/--/default/train/12/Image/image.jpg?Expires=1755824187&Signature=aWrTf2Wf1ONzSXELHJiNxmq08VDL2c4bURM6lVVDrJp-yCV~n8iy3XTF-hQ44C4WJ7VjPyteLiKiZnBfVdqriEWK8xvgqu7mXkyI-ZE7qsXtg8--t0aCfXLDOHtGkbV-cr3LZ4-68FMGW0IN7GRZqB29h43Zlx9hRMOJQOSjFe44Aa~ploxVrMkxD-P7GkoozId6nZwJZC4NZuG7jAv-Q3f4gSHp7YtVCuDadq9C8KWphSumDahaeN5ArDP73LJplTkrC6ZGzPLJbYDsyuFQG5a20OYLpn3UXYI0Db9IDjRvTx-wn7LTEJHH5sfHLdqnBsVKAPKyjJZ2Qg1becqF~A__&Key-Pair-Id=K3EI6M078Z3AC3","height":226,"width":570},"inferredFromUrl":false}}},{"rowIdx":13,"cells":{"Id":{"kind":"number","value":19678978,"string":"19,678,978"},"PostTypeId":{"kind":"number","value":1,"string":"1"},"AcceptedAnswerId":{"kind":"number","value":19679090,"string":"19,679,090"},"Question":{"kind":"string","value":"The confusing question is best asked through an example. Say we have the following result set:\n\nWhat I want to do is count how many times one number appears from both columns.\nSo the returning data set might look like:\n'''\nID Counted\n0 4\n1 2\n9 1\n13 1\n'''\nMy original thought was to do some sort of addition between the counts on both IDs, but I'm not exactly sure how to 'GROUP' them in SQL in a way that is working."},"Answer":{"kind":"string","value":"You can do this with a subquery, 'GROUP BY', and a 'UNION ALL', like this:\n'''\nSELECT ID, COUNT(*)\nFROM(\nSELECT ID1 AS ID FROM MyTable\nUNION ALL\nSELECT ID2 AS ID FROM MyTable\n) source\nGROUP BY ID\nORDER BY ID ASC\n'''"},"Image":{"kind":"image","value":{"src":"https://datasets-server.huggingface.co/assets/mirzaei2114/stackoverflowVQA-filtered/--/f7f8542dcc90dcbfbd6754ed4e1db8f518357867/--/default/train/13/Image/image.jpg?Expires=1755824187&Signature=jjAuyZrbYOiKUOccIBidUixlMhrCiyv7fxixudSQQ6XnSNgRvEFZhYk4hqViPe6~K4ylDBqVu0UpeB9Ic7D2wwoNjfQwQqhzRvLsVHFWpPoi3zzd9HVvrvOqoEXyVG61NeTdOEcEgSc3mT5v8A2XNdJtI0PkxaYvHO9hNLX9beBYcUrChNkhOWLkPk9Wbaj9zU8r6T69dBwbTgeYxkrhnCk4oDE61YPOGjOOEAFDR7Zv6DUGiwAEXqvcWab93XG9gV4kLKeAfTFTSKj8-lJ6gXyuU9Dx~H6-BwLauBsOG7sOY0QSjfvp7kaD60diYPKrjx-UPyTnkh5zSWGL1RgPYA__&Key-Pair-Id=K3EI6M078Z3AC3","height":108,"width":113},"inferredFromUrl":false}}},{"rowIdx":14,"cells":{"Id":{"kind":"number","value":18850099,"string":"18,850,099"},"PostTypeId":{"kind":"number","value":1,"string":"1"},"AcceptedAnswerId":{"kind":"number","value":18852422,"string":"18,852,422"},"Question":{"kind":"string","value":"I need to make Bootstrap 3.0 Carousel to display a slide of thumbnails. How can I do this?\nThis is an image of what I'm looking for:\n\nThis is a working example for Bootstrap 2, but I need this for Bootstrap 3.0.: "},"Answer":{"kind":"string","value":"A multi-item carousel can be accomplished in several ways .\nThis can be done using the grid inside each carousel item.\n'''\n
\n
\n
\n
\n
..\n
\n
..\n
\n
..\n
\n
..\n
\n
\n\n
\n...add more item(s)\n
\n
\n'''\nDemo example thumbnail slider using the carousel: \nAnother example with carousel indicators as thumbnails:\n"},"Image":{"kind":"image","value":{"src":"https://datasets-server.huggingface.co/assets/mirzaei2114/stackoverflowVQA-filtered/--/f7f8542dcc90dcbfbd6754ed4e1db8f518357867/--/default/train/14/Image/image.jpg?Expires=1755824187&Signature=Q80gead4XC4Q0F8E-GcZKh8JjgGEa~J7Mh6URIuhzRajj~mVZwFrU3v4dZvmrHrkHpiMUFLC0d-6M-9CB~ZgejIpbLBCEEsE6N2ul8AnLNiVAIoPU6pn-15nPyRJPKmHsauM9SL1m3hoN3pO4~0jLIbxR65OAwJinI6gVqKzuvGUNc0427sAlF0Y7Ok4r2Oe7Em~DDm38h6bGTsdTqP8hc65y9XMqgaXPYY9B6oWXBKecOfClZwuUgBXWOeLm-bWmXk23ZvasD~H9TpaIydNOqbJ9L03I85LgWyfH0PHwxrTo453ZfPJ-f9ObmfZCl8T3wJylNgXcggvvosb3c6Uyw__&Key-Pair-Id=K3EI6M078Z3AC3","height":192,"width":811},"inferredFromUrl":false}}},{"rowIdx":15,"cells":{"Id":{"kind":"number","value":27028132,"string":"27,028,132"},"PostTypeId":{"kind":"number","value":1,"string":"1"},"AcceptedAnswerId":{"kind":"number","value":28186908,"string":"28,186,908"},"Question":{"kind":"string","value":"I saw a site that embedded an interactive Google trend chart on the page: \nWhen I inspected the element, the chart was embedded with the code:\n'''\n\n'''\nI checked the top of the html for google related script and I found these:\n'''\n\n\n'''\nBut when i created an html file as such:\n'''\n\n\n\n\n\n'''\nI did not have the Google trend chart but I didn't get the chart and had this:\n\nWhen you go to the Google trend site, e.g. , there are embedded scripts that one can copy and paste into the html but when i put it in my own html it didn't work too.\n ?"},"Answer":{"kind":"string","value":"Include the Google trend result in an iframe and you are done.\n'''\n\n'''\nSee "},"Image":{"kind":"image","value":{"src":"https://datasets-server.huggingface.co/assets/mirzaei2114/stackoverflowVQA-filtered/--/f7f8542dcc90dcbfbd6754ed4e1db8f518357867/--/default/train/15/Image/image.jpg?Expires=1755824187&Signature=hBN1wMli5f3soplsDRG9vrENnD0VMOh4rfFNuH6vQjFSjb8L~S0wUwBTy-frJBh4w48K1V7v6q1iioRcLdv3KSrq1NBY1eYz~mRts2TdiEevH7SvSACP2v6weakiRsVPPPi~DnPWpAqUOypSbTKnEcDpIkkHp1R3zKEyx5gaOMNf-URKtxqeKi31XZDVPSeo5rlNh8OTwml0A2VTulPvR54CG-5mN7eELEmREx7lLaStX0H06ghNtVZ54JMhDUj7qZgSM8lT3HGqfUVMseTH8X-nPjxOrrHNALywJvsoyom1xmqo9O6dYOjyMdems0ZtgIlVPdpMV0GWPiezRF6F7Q__&Key-Pair-Id=K3EI6M078Z3AC3","height":900,"width":1600},"inferredFromUrl":false}}},{"rowIdx":16,"cells":{"Id":{"kind":"number","value":6260067,"string":"6,260,067"},"PostTypeId":{"kind":"number","value":1,"string":"1"},"AcceptedAnswerId":{"kind":"number","value":13968433,"string":"13,968,433"},"Question":{"kind":"string","value":"I am trying to remove status bar from particular View Controller but still it shows blue line when i tried to Hide it so please give some suggestions for that."},"Answer":{"kind":"string","value":"'''\n[[UIApplication sharedApplication] setStatusBarHidden:YES];\n'''"},"Image":{"kind":"image","value":{"src":"https://datasets-server.huggingface.co/assets/mirzaei2114/stackoverflowVQA-filtered/--/f7f8542dcc90dcbfbd6754ed4e1db8f518357867/--/default/train/16/Image/image.jpg?Expires=1755824187&Signature=a1ARkx8XZdMtgky3bD453NUWtogwoffDvCPFbEDa2wSRz~i3KbvWkXlbnqZfLirq~uUJR2ZUxBDOnyz3z~yEh31sabe4UkB4iF~5WLxU1MwNX~RTiypw5jhVzkV9FB3~tpclhfqZ7GKMVoQ2kng2Sm3sV4Ph32WoVWekoUP5wSQTcKF-aP2fXMz5zxnq-zrT7vKu4esHhsROFzOTEQhHQD3MU9P7unrOK0VlkzfsEdZQDKpRI3X5J3Oq7ms38iFMYLUPn90GNhCD8mo5ctH-xM4kqZDS7c4o2xrKunhaS5q4ElLflmrvkInyzf8Hd10ebcxjXf-RPuP4Q9Ij7TKp4Q__&Key-Pair-Id=K3EI6M078Z3AC3","height":528,"width":337},"inferredFromUrl":false}}},{"rowIdx":17,"cells":{"Id":{"kind":"number","value":57074704,"string":"57,074,704"},"PostTypeId":{"kind":"number","value":1,"string":"1"},"AcceptedAnswerId":{"kind":"number","value":57074809,"string":"57,074,809"},"Question":{"kind":"string","value":"I am currently working with some telematics data where the trip id is missing. Trip id is unique. 1 trip id contains multiple of rows of data consisting i.e gps coordinate, temp, voltage, rpm, timestamp, engine status (on or off). The data pattern indicate time of engine status on and off, can be cluster as a unique trip id. Though, I have difficulty to translate the above logic in order to generate these tripId.\nTried to use few pandas loop methods but keep failing.\n'''\nimport pandas as pd\ninp = [{'Ignition_Status':'ON', 'tripID':''},{'Ignition_Status':'ON','tripID':''},\n{'Ignition_Status':'ON', 'tripID':''},{'Ignition_Status':'OFF','tripID':''},\n{'Ignition_Status':'ON', 'tripID':''},{'Ignition_Status':'ON','tripID':''},\n{'Ignition_Status':'ON', 'tripID':''},{'Ignition_Status':'ON', 'tripID':''},\n{'Ignition_Status':'ON', 'tripID':''},{'Ignition_Status':'OFF', 'tripID':''},\n{'Ignition_Status':'ON', 'tripID':''},{'Ignition_Status':'OFF', 'tripID':''}]\ntest = pd.DataFrame(inp)\nprint (test)\n'''\n'''\nn=1\nfor index, row in test.iterrows():\ntest['tripID']=np.where(test['Ignition_Status']=='ON',n,n)\nn=n+1\n'''\n"},"Answer":{"kind":"string","value":"Use :\n'''\ntest=test.assign(tripID=test.Ignition_Status.eq('OFF')\n.shift(fill_value=False).cumsum().add(1))\n'''\n---\n'''\nIgnition_Status tripID\n0 ON 1\n1 ON 1\n2 ON 1\n3 OFF 1\n4 ON 2\n5 ON 2\n6 ON 2\n7 ON 2\n8 ON 2\n9 OFF 2\n10 ON 3\n11 OFF 3\n'''"},"Image":{"kind":"image","value":{"src":"https://datasets-server.huggingface.co/assets/mirzaei2114/stackoverflowVQA-filtered/--/f7f8542dcc90dcbfbd6754ed4e1db8f518357867/--/default/train/17/Image/image.png?Expires=1755824187&Signature=ez7A4h~b01KraGn35QsQ5tfBM05KbITzgA0oxIaLWmZ12GGIiHDQRTWa2uy34mCV-Nd6fi9nxSRcFELjGCCnGWgJGloJNoENunn-BFl67JEg3SZWniPuE9ZHDwGyG7I6BM~YEXkGU8FwPvNJ8UvyExG49D3GA7hoyVjtDcBkrIPOHsq6TWc5H0~CEPnV-6jRjYvg-hz8Ei0JZbtKMxDY-Ges7-sNfHgl0GocV46zogoUpKVy50ZeYK1y3ZHJx~B3dlwxu8j1nTgYP7yyyrvwQa3KixCPUIxESyNQTRFmdGlnYTPoMTIQznTDaz8S~V9R17l8ecp4lEUaVPAJ7XgIBg__&Key-Pair-Id=K3EI6M078Z3AC3","height":274,"width":300},"inferredFromUrl":false}}},{"rowIdx":18,"cells":{"Id":{"kind":"number","value":7669754,"string":"7,669,754"},"PostTypeId":{"kind":"number","value":1,"string":"1"},"AcceptedAnswerId":{"kind":"number","value":7669784,"string":"7,669,784"},"Question":{"kind":"string","value":"I'm trying to implement dynamic array in C using realloc(). My understanding is that realloc() preserves old contents of the memory block the old pointer points to, but my following testing code suggests otherwise:\n'''\n#include \n#include \nint DARRAYSIZE=5;\ntypedef struct dynamicArray{\nint size;\nint *items;\n}DArray;\nint init(DArray *DAP){ //initialise the DArray\nDAP->items=(int *)malloc(sizeof(int)*DARRAYSIZE);\nif(DAP->items){\nDAP->size=0;\nreturn 0;\n}else{\nprintf(\"Malloc failed!\n\");\nreturn 1;\n}\n}\nvoid print(DArray *DAP){ //print all elements in the DArray\nint i=0;\nfor(;isize;i++)\nprintf(\"%d \",DAP->items[i]);\nprintf(\"\n\");\n}\nvoid add(DArray *DAP,int val){ //add the new val into the DArray\nif(!full(DAP)){\nDAP->items[DAP->size++]=val;\n}else{\nif(!grow(DAP)){\nDAP->items[DAP->size++]=val;\n}else\nexit(1);\n}\n}\nint full(DArray *DAP){ //returns 1 if the DAarray is full\nif(DAP->size==DARRAYSIZE)\nreturn 1;\nelse\nreturn 0;\n}\nint grow(DArray *DAP){ //grows the DArray to double its original size\nint *temp=(int *)realloc(DAP->items,DARRAYSIZE*2);\nif(!temp){\nprintf(\"Realloc failed!\n\");\nreturn 1;\n}else{\nDAP->items=temp;\nDARRAYSIZE*=2;\nprintf(\"Darray doubled and current contents are:\n\");\nprint(DAP);\nreturn 0;\n}\n}\nvoid destroy(DArray *DAP){ //destroies the DArray\nfree(DAP->items);\n}\nint main(void){\nDArray newDA;\nif(!init(&newDA)){\nint i;\nfor(i=1;i<30;i++)\nadd(&newDA,i);\n}else\nexit(1);\ndestroy(&newDA);\nreturn 0;\n}\n'''\nWhat I did was print the contents of the array as soon as its size is doubled in function grow(). I compiled the code using:\n:gcc -version\ni686-apple-darwin11-llvm-gcc-4.2\nand below is the output:\n\nwith the unexpected 0's in the output.\nPlease kindly advise what I'm doing wrong here, thanks!"},"Answer":{"kind":"string","value":"You forgot 'sizeof(int)' in your 'realloc()', so you keep shrinking your array.\nYou also need to keep track of the number of items in use and the amount of space allocated in the dynamic array structure; these are two separate measures, and both are needed. But you can't use a global variable (currently DYNARRAYSIZE) to hold the size of every dynamic array. You need one per dynamic array.\n'full()'\n---\n### Working Output\n'''\nDarray doubled and current contents are:\nMax = 10; Cur = 5\n1 2 3 4 5\nDarray doubled and current contents are:\nMax = 20; Cur = 10\n1 2 3 4 5 6 7 8 9 10\nDarray doubled and current contents are:\nMax = 40; Cur = 20\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20\n'''\n### Working Code\n'''\n#include \n#include \n#include \nenum { DARRAYSIZE = 5 };\ntypedef struct dynamicArray\n{\nint max_size;\nint cur_size;\nint *items;\n} DArray;\nextern int init(DArray *DAP);\nextern void add(DArray *DAP, int val);\nextern void destroy(DArray *DAP);\nextern void print(DArray *DAP);\nstatic int full(DArray *DAP);\nstatic int grow(DArray *DAP);\n//initialise the DArray\nint init(DArray *DAP)\n{\nDAP->items=(int *)malloc(sizeof(int)*DARRAYSIZE);\nif (DAP->items)\n{\nDAP->max_size = DARRAYSIZE;\nDAP->cur_size = 0;\nreturn 0;\n}\nelse\n{\nprintf(\"Malloc failed!\n\");\nreturn 1;\n}\n}\n//print all elements in the DArray\nvoid print(DArray *DAP)\n{\nprintf(\"Max = %d; Cur = %d\n\", DAP->max_size, DAP->cur_size);\nfor (int i = 0; i < DAP->cur_size; i++)\nprintf(\"%d \", DAP->items[i]);\nprintf(\"\n\");\n}\n//add the new val into the DArray\nvoid add(DArray *DAP, int val)\n{\nif (!full(DAP))\nDAP->items[DAP->cur_size++] = val;\nelse if (!grow(DAP))\nDAP->items[DAP->cur_size++] = val;\nelse\nexit(1);\n}\n//returns 1 if the DAarray is full\nstatic int full(DArray *DAP)\n{\nassert(DAP->cur_size >= 0 && DAP->max_size >= 0);\nassert(DAP->cur_size <= DAP->max_size);\nif (DAP->cur_size == DAP->max_size)\nreturn 1;\nelse\nreturn 0;\n}\n//grows the DArray to double its original size\nstatic int grow(DArray *DAP)\n{\nint *temp=(int *)realloc(DAP->items, sizeof(*temp) * DAP->max_size * 2);\nif (!temp)\n{\nprintf(\"Realloc failed!\n\");\nreturn 1;\n}\nelse\n{\nDAP->items = temp;\nDAP->max_size *= 2;\nprintf(\"Darray doubled and current contents are:\n\");\nprint(DAP);\nreturn 0;\n}\n}\n//destroys the DArray\nvoid destroy(DArray *DAP)\n{\nfree(DAP->items);\nDAP->items = 0;\nDAP->max_size = 0;\nDAP->cur_size = 0;\n}\nint main(void)\n{\nDArray newDA;\nif (!init(&newDA))\n{\nfor (int i = 1; i < 30; i++)\nadd(&newDA, i);\n}\nelse\nexit(1);\ndestroy(&newDA);\nreturn 0;\n}\n'''"},"Image":{"kind":"image","value":{"src":"https://datasets-server.huggingface.co/assets/mirzaei2114/stackoverflowVQA-filtered/--/f7f8542dcc90dcbfbd6754ed4e1db8f518357867/--/default/train/18/Image/image.jpg?Expires=1755824187&Signature=Z10XfqgYa92msm2pB2wnmWFkPxAhPFFFBVDDQV5SAaBM0OpCcYPqV97N2rqEB4YFeG9iBkmxwxxEqhYed2oj3FxLOvvI1jYu-aCADrL0p9QqZ-~QAsRpH0Uv3F1EYwJRNbPTs7b-7QTey17TLPHpUwSGdPhpiNSqM6LQeDt-70BEJuekbtCmjOQM-zeMlVJA3TsMznW0IUNHJjzKGaJHaegil2FW8Q6Csj-JKzTqfelAMa8~N-l~TzpK8KT-FGQ7LN8O8tZ2FKak8IpJ6XPYxfhkOh0EAVUAqGBXCv~cIiqqNkNnG49beQXp858FasRqtNwX16yLjYQ35GzZFSqf2g__&Key-Pair-Id=K3EI6M078Z3AC3","height":86,"width":947},"inferredFromUrl":false}}},{"rowIdx":19,"cells":{"Id":{"kind":"number","value":29823843,"string":"29,823,843"},"PostTypeId":{"kind":"number","value":1,"string":"1"},"AcceptedAnswerId":{"kind":"number","value":29823976,"string":"29,823,976"},"Question":{"kind":"string","value":"I have HTML page which have multiple check boxes and individually they can be checked. I have button 'select', so what I am suppose to do is. When I click on select all the check boxes should get selected, and deselected.\n'''\n\n\n\n\n