qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,275,452
<p>I have an array of object as follows. Currently there is only one object but invocations has an array of objects.</p> <p>Depending on how many array of objects we have for <code>invocations</code>, we want to update the main array of objects. For e.g. if there are 2 objects in <code>invocations</code>, i want to separate those 2 invocations and replicate their parent object for both <code>invocations</code>.</p> <p>This is not a regular iteration of array of objects and thats why i am not able to get the desired result. Any help is appreciated</p> <pre><code>const input = [ { &quot;name&quot;: &quot;Test Data&quot;, &quot;invocations&quot;: [ { &quot;invocationId&quot;: &quot;123&quot; }, { &quot;invocationId&quot;: &quot;125&quot; }, ] }, ] </code></pre> <pre><code>const output = [ { &quot;name&quot;: &quot;Test Data&quot;, &quot;invocations&quot;: [ { &quot;invocationId&quot;: &quot;123&quot; }, ] }, { &quot;name&quot;: &quot;Test Data&quot;, &quot;invocations&quot;: [ { &quot;invocationId&quot;: &quot;125&quot; }, ] } ] </code></pre>
[ { "answer_id": 74275766, "author": "Fralle", "author_id": 3155183, "author_profile": "https://Stackoverflow.com/users/3155183", "pm_score": 1, "selected": false, "text": "const splitInvocations = array => {\n return array.reduce((result, obj) => {\n const parentAssignedObjects = obj.invocations.map(invocation => ({ ...obj, invocations: [invocation] }));\n return [...result, ...parentAssignedObjects];\n }, []);\n};\n" }, { "answer_id": 74275791, "author": "Apostolos", "author_id": 1121008, "author_profile": "https://Stackoverflow.com/users/1121008", "pm_score": 3, "selected": true, "text": "invocations" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74275452", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13622494/" ]
74,275,479
<p>I'm trying to accomplish what's described <a href="https://stackoverflow.com/questions/53227343/triggering-azure-devops-builds-based-on-changes-to-sub-folders/53229588#53229588">here</a> by fearnight as a means of getting the commit ID of the most recent successful pipeline run, but I'm having trouble with the API call itself.</p> <p>The API endpoint is described <a href="https://learn.microsoft.com/en-us/rest/api/azure/devops/build/latest/get?view=azure-devops-rest-6.0#uri-parameters" rel="nofollow noreferrer">here</a> and looks like this: GET <a href="https://dev.azure.com/%7Borganization%7D/%7Bproject%7D/_apis/build/latest/%7Bdefinition%7D?api-version=6.0-preview.1" rel="nofollow noreferrer">https://dev.azure.com/{organization}/{project}/_apis/build/latest/{definition}?api-version=6.0-preview.1</a></p> <p>The problem I'm having with it is that I don't know what to use for the &quot;definition&quot; segment. So I figured I could list out some information about my builds using <a href="https://learn.microsoft.com/en-us/rest/api/azure/devops/build/builds/list?view=azure-devops-rest-6.1#definitionreference" rel="nofollow noreferrer">this call</a>. I attempted this using code like this in my pipeline:</p> <pre><code>- task: PowerShell@2 inputs: targetType: 'inline' script: | $uri=&quot;https://dev.azure.com/mycompany/myproject/_apis/build/builds?resultFilter=succeeded&amp;api-version=6.1&quot; $builds=(Invoke-RestMethod -Uri $uri -Method GET -Headers @{ Authorization = &quot;Bearer $(System.AccessToken)&quot; }) echo &quot;Response: $builds&quot; echo &quot;Builds: $builds.Build[0].definition.name&quot; # echo &quot;name: $builds[0].definition.name&quot; # echo &quot;definition ID: $builds[0].definition.id&quot; # $builds | ForEach-Object { # echo &quot;Build definition name: $_.definition.name&quot; # } </code></pre> <p>I must be coding these calls incorrectly, though, as this is typical of the responses I get:</p> <pre><code>========================== Starting Command Output =========================== /usr/bin/pwsh -NoLogo -NoProfile -NonInteractive -Command . '/home/vsts/work/_temp/2ec4dfbd-d2d6-42e4-bd9e-9dfa3bad28f0.ps1' Response: @{count=1000; value=System.Object[]} Builds: @{count=1000; value=System.Object[]}.Build[0].definition.name Finishing: PowerShell </code></pre> <p>To reframe my question, I need help with the syntax for querying the ADO API, which in turn I need to do for the purpose of getting the commit ID of the last successful run for my pipeline.</p> <p>Can someone please help me out?</p> <p><strong>EDIT</strong> I've got the endpoint call working (I think) now, as I'm getting a response back, but I can't figure out how to access the values in the response from within my pipeline PS script. I'd think that to access one of these properties (e.g., sourceVersion, which is the one I need), I could do something like one of these:</p> <pre><code>$response=(Invoke-RestMethod -Uri $uri -Method GET -Headers @{ Authorization = &quot;Bearer $(System.AccessToken)&quot; }) echo &quot;Response: $response&quot; echo &quot;Source version: $response.value&quot; # echo &quot;Source version: $response.Build.sourceVersion&quot; </code></pre> <p>All these give me, though is:</p> <pre><code>Response: @{_links=; properties=; tags=System.Object[] ... sourceVersion=fb29c721eaaaacf47f35ff900fe7086084cd321356; </code></pre> <p>How do I access and use the sourceVersion value?</p>
[ { "answer_id": 74275766, "author": "Fralle", "author_id": 3155183, "author_profile": "https://Stackoverflow.com/users/3155183", "pm_score": 1, "selected": false, "text": "const splitInvocations = array => {\n return array.reduce((result, obj) => {\n const parentAssignedObjects = obj.invocations.map(invocation => ({ ...obj, invocations: [invocation] }));\n return [...result, ...parentAssignedObjects];\n }, []);\n};\n" }, { "answer_id": 74275791, "author": "Apostolos", "author_id": 1121008, "author_profile": "https://Stackoverflow.com/users/1121008", "pm_score": 3, "selected": true, "text": "invocations" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74275479", "https://Stackoverflow.com", "https://Stackoverflow.com/users/270326/" ]
74,275,480
<p>I am able to generate JS and golang protobuf files, but not typescript. I keep getting an error that reads.</p> <pre><code>protoc-gen-ts: program not found or is not executable Please specify a program using absolute path or make sure the program is available in your PATH system variable --ts_out: protoc-gen-ts: Plugin failed with status code 1. make: *** [proto-old] Error 1 </code></pre> <p>package.json deps</p> <pre><code>&quot;grpc-mp&quot;: &quot;^1.0.1&quot;, &quot;grpc-tools&quot;: &quot;^1.11.3&quot;, &quot;grpc_tools_node_protoc_ts&quot;: &quot;^5.3.2&quot;, &quot;ts-proto&quot;: &quot;^1.131.0&quot;, &quot;ts-protoc-gen&quot;: &quot;^0.15.0&quot;, &quot;vscode-ws-jsonrpc&quot;: &quot;^2.0.0&quot;, </code></pre> <p>command</p> <pre><code>protoc api.proto --proto_path=${PROJ_PATH}/proto \ --plugin=protoc-gen-grpc=${PROJ_PATH}/view/node_modules/.bin/grpc_tools_node_protoc_plugin \ --js_out=import_style=commonjs:${PROJ_PATH}/view/proto \ --plugin=${PROJ_PATH}/view/node_modules/.bin/protoc-gen-ts_proto \ --ts_proto_out=${PROJ_PATH}/view/proto \ --ts_out=${PROJ_PATH}/view/proto </code></pre> <p>Oddly, the JS files generated <strong>do not</strong> did not generate a client server. However, I would rather use typescript in combination with vue.js. As for the backend server I am using GO, and it did generate the server connection code. Hopefully once the typescript generation works the code to create the client server will be generated.</p> <p>Question:</p> <p>What is wrong with my proto command? The plugin is there and it appears to be inline with the docs.</p> <p>Advice?</p> <p>---- update 1 ----</p> <p>had a small typo, here is the update</p> <pre><code>protoc api.proto --proto_path=${PROJ_PATH}/proto \ --plugin=protoc-gen-grpc=${PROJ_PATH}/form/node_modules/.bin/grpc_tools_node_protoc_plugin \ --plugin=protoc-gen-ts=${PROJ_PATH}/form/proto \ --ts_out=service=grpc-web:${PROJ_PATH}/form/proto \ --js_out=import_style=commonjs:${PROJ_PATH}/form/proto </code></pre> <p>error:</p> <pre><code>Please specify a program using absolute path or make sure the program is available in your PATH system variable --ts_out: protoc-gen-ts: Plugin failed with status code 1. </code></pre> <p>For some reason I TS code will not generate. My goal is for the vue.js frontend to communicate with my go backend. I am only working with the directory &quot;form&quot; and &quot;api&quot; at the moment.</p>
[ { "answer_id": 74280326, "author": "vhthanh", "author_id": 13352796, "author_profile": "https://Stackoverflow.com/users/13352796", "pm_score": 0, "selected": false, "text": "\"devDependencies\": {\n \"@protobuf-ts/protoc\": \"^2.8.1\",\n \"@types/google-protobuf\": \"^3.15.6\",\n \"google-protobuf\": \"^3.21.0\",\n \"protoc-gen-ts\": \"^0.8.5\",\n \"protoc-gen-grpc\": \"^2.0.3\"\n}\n" }, { "answer_id": 74294360, "author": "DazWilkin", "author_id": 609290, "author_profile": "https://Stackoverflow.com/users/609290", "pm_score": 2, "selected": true, "text": "VERS=\"21.9\"\nARCH=\"linux-x86_64\"\n\nENDPOINT=\"https://github.com/protocolbuffers/protobuf/releases/download\"\n\nwget ${ENDPOINT}/v${VERS}/protoc-${VERS}-${ARCH}.zip \\\n-O ${PWD}/protoc-${VERS}-${ARCH}.zip && \\\nunzip \\\n protoc-${VERS}-${ARCH}.zip \\\n -d ${PWD}/protoc-${VERS}-${ARCH} && \\\nrm ${PWD}/protoc-${VERS}-${ARCH}.zip\n\nPATH=${PATH}:${PWD}/protoc-${VERS}-${ARCH}/bin\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74275480", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4753897/" ]
74,275,487
<p>I've been trying to make chart.js have a label for each dataset but the first label is located underneath both datasets and the second on an empty area of the chart.</p> <pre class="lang-js prettyprint-override"><code>var powerChart = new Chart(powerCanvas, { type: &quot;bar&quot;, data: { labels: [&quot;Volts&quot;, &quot;Amperes&quot;], datasets: [ { label: &quot;Volts&quot;, // This bar should have this label underneath itself data: [24.78], // Initial value, will be overwritten }, { label: &quot;Amperes&quot;, // This bar should have this label underneath itself data: [14.51], }, ], }, options: {}, }); </code></pre> <p>See <a href="https://jsfiddle.net/w20c3tru/2/" rel="nofollow noreferrer">https://jsfiddle.net/w20c3tru/2/</a> for what I have tried and a working example. Note: I tried to follow <a href="https://stackoverflow.com/questions/38101859/chart-js-line-chart-with-different-labels-for-each-dataset">Chart.js Line-Chart with different Labels for each Dataset</a> but could not see any difference.</p>
[ { "answer_id": 74276344, "author": "Zoraiz", "author_id": 14628358, "author_profile": "https://Stackoverflow.com/users/14628358", "pm_score": 2, "selected": false, "text": "var powerChart = new Chart(powerCanvas,\n {\n type: 'bar',\n data:\n {\n labels: ['Volts', 'Amperes'],\n datasets:\n [\n {\n label: 'Value', // This is actually the label that shows up when you hover over a bar\n data: [24.78, 14.51] // NOTE: Number of labels defined above should equal number of values here\n },\n ]\n },\n options:\n {\n }\n }\n);\n" }, { "answer_id": 74288301, "author": "Johnny", "author_id": 14576078, "author_profile": "https://Stackoverflow.com/users/14576078", "pm_score": 1, "selected": true, "text": "Code on jsFiddle\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74275487", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14576078/" ]
74,275,500
<p>I would like to simplify my code and merge common parts of the several methods into new one. Could you give me the piece of advice - what is the best way to do it? My methods are:</p> <pre><code>@ExceptionHandler(value = {ProhibitedScimTypeException.class}) public ResponseEntity&lt;ErrorDto&gt; policyConflict(final ProhibitedScimTypeException exception) { final var errorDto = new ErrorDto(); errorDto.setDetail(exception.getMessage()); errorDto.setStatus(BAD_REQUEST.toString()); errorDto.setScimType(&quot;prohibited&quot;); return new ResponseEntity&lt;&gt;(errorDto, HttpStatus.BAD_REQUEST); } @ExceptionHandler(value = {UserAlreadyExistsException.class}) public ResponseEntity&lt;ErrorDto&gt; userNameExistsConflict(final UserAlreadyExistsException exception) { final var errorDto = new ErrorDto(); errorDto.setDetail(exception.getMessage()); errorDto.setStatus(CONFLICT.toString()); errorDto.setScimType(&quot;uniqueness&quot;); return new ResponseEntity&lt;&gt;(errorDto, HttpStatus.CONFLICT); } @ExceptionHandler(value = {UserNotFoundException.class}) public ResponseEntity&lt;ErrorDto&gt; userNameNotFoundConflict(final UserNotFoundException exception) { final var errorDto = new ErrorDto(); errorDto.setDetail(exception.getMessage()); errorDto.setStatus(NOT_FOUND.toString()); errorDto.setScimType(&quot;prohibited&quot;); return new ResponseEntity&lt;&gt;(errorDto, HttpStatus.NOT_FOUND); } </code></pre> <p>I would like to separate the common part which is:</p> <pre><code>final var errorDto = new ErrorDto(); errorDto.setDetail(exception.getMessage()); errorDto.setStatus(MEHTOD.toString()); errorDto.setScimType(&quot;something&quot;); </code></pre>
[ { "answer_id": 74275646, "author": "sanurah", "author_id": 4079056, "author_profile": "https://Stackoverflow.com/users/4079056", "pm_score": 2, "selected": true, "text": "private ResponseEntity<ErrorDto> conflict(final Throwable exception, HttpStatus status, String scrimType) {\n final var errorDto = new ErrorDto();\n errorDto.setDetail(exception.getMessage());\n errorDto.setStatus(status.toString());\n errorDto.setScimType(scrimType);\n return new ResponseEntity<>(errorDto, status);\n}\n" }, { "answer_id": 74275678, "author": "Christoph Dahlen", "author_id": 20370596, "author_profile": "https://Stackoverflow.com/users/20370596", "pm_score": 0, "selected": false, "text": " private ResponseEntity<ErrorDto> conflict(final Throwable exception, final Object status, final String scimType, final HttpStatus httpStatus) {\n final var errorDto = new ErrorDto();\n errorDto.setDetail(exception.getMessage());\n errorDto.setStatus(status.toString());\n errorDto.setScimType(scimType);\n return new ResponseEntity<>(errorDto, httpStatus);\n }\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74275500", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17942621/" ]
74,275,501
<p>Ok, no code here, more trying to get some directions. I'm working on my home automation using tuya objects. Till now I was able to create a websocket (using python websockets and asyncio) that gets a message and turn on my devices. I created a flask website to configure passwords, keys etc. Now what I'm trying to achieve is using a NFC tag(scanned by my phone) call the websocket sending a message. I bought some NFC tags, got a an android app called NFC Tools to record data into the NFC tag.</p> <p>Problem is NFC tools doesnt give me too many options I can add text, and URLs but I dont know how to call my websocket from there. Can I call it using its URL like ws://something.go? Can I make the phone not open a browser when I scam the tag? Should I create a page on flask for that and put the page address?</p> <p>Anyway, I'm kind of lost. Can you guys point me in the right direction?</p>
[ { "answer_id": 74275646, "author": "sanurah", "author_id": 4079056, "author_profile": "https://Stackoverflow.com/users/4079056", "pm_score": 2, "selected": true, "text": "private ResponseEntity<ErrorDto> conflict(final Throwable exception, HttpStatus status, String scrimType) {\n final var errorDto = new ErrorDto();\n errorDto.setDetail(exception.getMessage());\n errorDto.setStatus(status.toString());\n errorDto.setScimType(scrimType);\n return new ResponseEntity<>(errorDto, status);\n}\n" }, { "answer_id": 74275678, "author": "Christoph Dahlen", "author_id": 20370596, "author_profile": "https://Stackoverflow.com/users/20370596", "pm_score": 0, "selected": false, "text": " private ResponseEntity<ErrorDto> conflict(final Throwable exception, final Object status, final String scimType, final HttpStatus httpStatus) {\n final var errorDto = new ErrorDto();\n errorDto.setDetail(exception.getMessage());\n errorDto.setStatus(status.toString());\n errorDto.setScimType(scimType);\n return new ResponseEntity<>(errorDto, httpStatus);\n }\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74275501", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14967757/" ]
74,275,517
<p>So, I have grafana, where my underlying database is AWS Timestream. I have around 20 widgets (panes) in my dashboard, which makes 20 calls to the datasource.</p> <p>AWS prices 10mb minimum per query, which causes me to pay 200mb worth of queries instead of few MB which is the amount of data scanned.</p> <p>What I want to do, is to run the a unified query (take the 20 queries and run them once with outer joins), then perform the queries of the panes against this result.</p> <p>Is this even possible?</p>
[ { "answer_id": 74275646, "author": "sanurah", "author_id": 4079056, "author_profile": "https://Stackoverflow.com/users/4079056", "pm_score": 2, "selected": true, "text": "private ResponseEntity<ErrorDto> conflict(final Throwable exception, HttpStatus status, String scrimType) {\n final var errorDto = new ErrorDto();\n errorDto.setDetail(exception.getMessage());\n errorDto.setStatus(status.toString());\n errorDto.setScimType(scrimType);\n return new ResponseEntity<>(errorDto, status);\n}\n" }, { "answer_id": 74275678, "author": "Christoph Dahlen", "author_id": 20370596, "author_profile": "https://Stackoverflow.com/users/20370596", "pm_score": 0, "selected": false, "text": " private ResponseEntity<ErrorDto> conflict(final Throwable exception, final Object status, final String scimType, final HttpStatus httpStatus) {\n final var errorDto = new ErrorDto();\n errorDto.setDetail(exception.getMessage());\n errorDto.setStatus(status.toString());\n errorDto.setScimType(scimType);\n return new ResponseEntity<>(errorDto, httpStatus);\n }\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74275517", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1845545/" ]
74,275,518
<p>In my code I tried to fecth age filed from users table using userID. Structure of database.</p> <p><a href="https://i.stack.imgur.com/M7IHs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/M7IHs.png" alt="enter image description here" /></a></p> <p>childPrivateDetails is a subcollection of user table</p> <p>**I want to fetch age from this table how to do that and pass when click next button should pass the age to &quot;void ageCa()&quot; method **</p> <p>code</p> <pre><code> class _GuideLineScreenState extends State&lt;GuideLineScreen&gt; { Future&lt;void&gt; getAge() async { final sp = context.read&lt;SignInProvider&gt;(); Future&lt;void&gt; getAge() async { final path = 'users/${sp.uid}/childPrivateDetails/${sp.uid}'; final reference = FirebaseFirestore.instance.doc(path); final age = await reference.get().then((value) =&gt; value.get('age')); print('age is: $age'); } } </code></pre> <p>next button code</p> <pre><code>SizedBox( width: 160.0, height: 35.0, child: ElevatedButton( style: ButtonStyle( shape: MaterialStateProperty.all&lt;RoundedRectangleBorder&gt;( RoundedRectangleBorder( borderRadius: BorderRadius.circular(18.0), side: const BorderSide( color: Colors.blueAccent, ), ), ), ), onPressed: () { ageCa(); }, child: const Text( 'next', style: TextStyle( color: Colors.white, ), ), ), ), </code></pre> <p>void ageCa() code</p> <pre><code>void ageCa() { String age = age; final data = age.split(&quot;,&quot;); final List&lt;int&gt; numbers = data.map((e) =&gt; int.parse(e.replaceAll(RegExp('[^0-9]'), ''))).toList(); //format &quot;Years: 2, Months: 00, Days: 00&quot;; only work on this format Duration ageDuration = Duration(days: numbers[0] * 365 + numbers[1] * 30 + numbers[2]); if (ageDuration &gt;= const Duration(days: 2 * 288)) { Navigator.push( context, MaterialPageRoute(builder: (context) =&gt; const LoginScreen()), ); } else { Navigator.push( context, MaterialPageRoute( builder: (context) =&gt; const HomeScreen(), )); } } </code></pre> <p>For this, I didn't use model path image <a href="https://i.stack.imgur.com/H6GXA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/H6GXA.png" alt="enter image description here" /></a></p> <p>User ID in console <a href="https://i.stack.imgur.com/jCmAo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jCmAo.png" alt="enter image description here" /></a></p> <p>code <a href="https://i.stack.imgur.com/9i2KM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9i2KM.png" alt="enter image description here" /></a></p> <p>I added print($age); at the Widget build(BuildContext context) { <a href="https://i.stack.imgur.com/6RT1f.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6RT1f.png" alt="enter image description here" /></a></p> <p>void ageCa() <a href="https://i.stack.imgur.com/CncLB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CncLB.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74275646, "author": "sanurah", "author_id": 4079056, "author_profile": "https://Stackoverflow.com/users/4079056", "pm_score": 2, "selected": true, "text": "private ResponseEntity<ErrorDto> conflict(final Throwable exception, HttpStatus status, String scrimType) {\n final var errorDto = new ErrorDto();\n errorDto.setDetail(exception.getMessage());\n errorDto.setStatus(status.toString());\n errorDto.setScimType(scrimType);\n return new ResponseEntity<>(errorDto, status);\n}\n" }, { "answer_id": 74275678, "author": "Christoph Dahlen", "author_id": 20370596, "author_profile": "https://Stackoverflow.com/users/20370596", "pm_score": 0, "selected": false, "text": " private ResponseEntity<ErrorDto> conflict(final Throwable exception, final Object status, final String scimType, final HttpStatus httpStatus) {\n final var errorDto = new ErrorDto();\n errorDto.setDetail(exception.getMessage());\n errorDto.setStatus(status.toString());\n errorDto.setScimType(scimType);\n return new ResponseEntity<>(errorDto, httpStatus);\n }\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74275518", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20000775/" ]
74,275,522
<p>I wrote the following code but when the rows are large it is slow</p> <pre><code>import numpy as np array = np.array([ [1,2],[1,2],[2,3], [1,2],[2,3],[5,2]]) d={} for l in array: t = tuple(l) if t in d: d[t]+=1 else: d[t]=1 print(d) </code></pre> <p>result:</p> <pre><code>`{(1, 2): 3, (2, 3): 2, (5, 2): 1}` </code></pre> <p>Is there a faster way to do this?</p>
[ { "answer_id": 74275632, "author": "Alex P", "author_id": 11554968, "author_profile": "https://Stackoverflow.com/users/11554968", "pm_score": 3, "selected": true, "text": "np.unique" }, { "answer_id": 74275704, "author": "Ajay K", "author_id": 10782096, "author_profile": "https://Stackoverflow.com/users/10782096", "pm_score": 1, "selected": false, "text": "final_count={}\nfor lst in [list(x) for x in set(tuple(x) for x in array)]:\n final_count[tuple(lst)]=array.count(lst)\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74275522", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19661530/" ]
74,275,540
<p>The search is working properly. The main problem occurs when I want to delete it but the previous numbers won't be back. In this code, I'm applying the changes directly to the main variable but I shall not. What is the way?</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>new Vue({ el: '#app', data() { return { list: [], search: '', } }, mounted() { for(let i = 1300; i &lt;= 1400; i++) { const _n = i.toString() this.list.push(_n) } }, methods: { handleSearch() { this.list = this.list.filter(i =&gt; i.includes(this.search)); } } })</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"&gt;&lt;/script&gt; &lt;div id="app"&gt; &lt;input @input="handleSearch()" v-model="search" placeholder="search number" /&gt; &lt;ul&gt; &lt;li v-for="(item, i) in list" :key="i"&gt;{{item}}&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74275632, "author": "Alex P", "author_id": 11554968, "author_profile": "https://Stackoverflow.com/users/11554968", "pm_score": 3, "selected": true, "text": "np.unique" }, { "answer_id": 74275704, "author": "Ajay K", "author_id": 10782096, "author_profile": "https://Stackoverflow.com/users/10782096", "pm_score": 1, "selected": false, "text": "final_count={}\nfor lst in [list(x) for x in set(tuple(x) for x in array)]:\n final_count[tuple(lst)]=array.count(lst)\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74275540", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15351296/" ]
74,275,574
<p><a href="https://i.stack.imgur.com/KC4Qt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KC4Qt.png" alt="enter image description here" /></a></p> <p>I am trying to link stripe payment to react native expo using the <code>@stripe/stripe-react-native</code> package but i am getting error while providing publishable key to stripe provider element</p>
[ { "answer_id": 74275632, "author": "Alex P", "author_id": 11554968, "author_profile": "https://Stackoverflow.com/users/11554968", "pm_score": 3, "selected": true, "text": "np.unique" }, { "answer_id": 74275704, "author": "Ajay K", "author_id": 10782096, "author_profile": "https://Stackoverflow.com/users/10782096", "pm_score": 1, "selected": false, "text": "final_count={}\nfor lst in [list(x) for x in set(tuple(x) for x in array)]:\n final_count[tuple(lst)]=array.count(lst)\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74275574", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20282726/" ]
74,275,584
<p>I am trying to create a saga, and start this saga by triggering an event. However, after the event is triggered, I just get an endless loop for &quot;claim on token&quot;. and it retries to execute this code all the time. and it just runs it after a few seconds.</p> <pre><code>@StartSaga @SagaEventHandler(associationProperty = &quot;eventId&quot;) fun on(event: CreateTargetReferenceEvent) { println(event.eventId) } </code></pre> <p>My issue here is that I try to trigger @EndSaga event, but it never happened. I am sure the eventId is the same in the @StartSaga and @EndSaga, and both of the events are triggered in the right way since the corresponding event handlers are triggered elsewhere.</p> <p>I'm not sure what I have missed here to make the @EndSaga triggered. Please help.</p> <p>This the @Saga component</p> <pre><code>@Component @Saga internal class TestSaga { var testString: String = &quot;&quot; @Autowired private lateinit var commandGateway: CommandGateway @StartSaga @SagaEventHandler(associationProperty = &quot;eventId&quot;) fun on(event: CreateTargetReferenceEvent) { println(event.eventId) } @EndSaga @SagaEventHandler(associationProperty = &quot;eventId&quot;) fun on(event: UpdateTargetReferenceEvent) { println(event.eventId) } } </code></pre> <p>And there are the outputs:</p> <pre><code> 2022-11-01 21:49:10.529 WARN 11916 --- [agaProcessor]-0] o.a.e.TrackingEventProcessor : Releasing claim on token and preparing for retry in 4s Hibernate: update token_entry set owner=null where owner=? and processor_name=? and segment=? 2022-11-01 21:49:10.530 INFO 11916 --- [agaProcessor]-0] o.a.e.TrackingEventProcessor : Released claim Hibernate: update token_entry set timestamp=? where processor_name=? and segment=? and owner=? Hibernate: update token_entry set timestamp=? where processor_name=? and segment=? and owner=? Hibernate: update token_entry set timestamp=? where processor_name=? and segment=? and owner=? Hibernate: select tokenentry0_.processor_name as processo1_7_0_, tokenentry0_.segment as segment2_7_0_, tokenentry0_.owner as owner3_7_0_, tokenentry0_.timestamp as timestam4_7_0_, tokenentry0_.token as token5_7_0_, tokenentry0_.token_type as token_ty6_7_0_ from token_entry tokenentry0_ where tokenentry0_.processor_name=? and tokenentry0_.segment=? for update Hibernate: update token_entry set owner=?, timestamp=?, token=?, token_type=? where processor_name=? and segment=? 2022-11-01 21:49:14.536 INFO 11916 --- [agaProcessor]-0] o.a.e.TrackingEventProcessor : Fetched token: null for segment: Segment[0/0] Hibernate: update token_entry set token=?, token_type=?, timestamp=? where owner=? and processor_name=? and segment=? Hibernate: select associatio0_.saga_id as col_0_0_ from association_value_entry associatio0_ where associatio0_.association_key=? and associatio0_.association_value=? and associatio0_.saga_type=? baccd32c-1547-4621-a04c-3a5cb285a9af 2022-11-01 21:49:14.551 WARN 11916 --- [agaProcessor]-0] o.a.e.TrackingEventProcessor : Releasing claim on token and preparing for retry in 8s Hibernate: update token_entry set owner=null where owner=? and processor_name=? and segment=? 2022-11-01 21:49:14.553 INFO 11916 --- [agaProcessor]-0] o.a.e.TrackingEventProcessor : Released claim </code></pre>
[ { "answer_id": 74285251, "author": "Gerard Klijs", "author_id": 8255027, "author_profile": "https://Stackoverflow.com/users/8255027", "pm_score": 1, "selected": false, "text": "@Component" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74275584", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4816915/" ]
74,275,639
<p>I'm trying to ask for students' IDs and save it to a file, and if a student inputs an ID number that already exists in the file, it will print an invalid message.</p> <p>I tried doing this by reading the file first and used if-else statement to check if the student ID is in the file or not. If it is, it will print the message; if not, it will add the student ID to the file. But for some reason, even when I input the same ID, it never shows the message and adds it to the file even though it already exists in the file. Where did I go wrong?</p> <p>Here is my code:</p> <pre class="lang-py prettyprint-override"><code>file = open('testfile.txt', 'r') if student_id in file: print(&quot;There is already a student with the same ID&quot;) else: names_file = open('testfile.txt', 'a') names_file.write(str(student_id) + ',' + name + ',' + str(mobile) + ',' + '0.0\n') names_file.close() </code></pre>
[ { "answer_id": 74275726, "author": "Vishu", "author_id": 19013029, "author_profile": "https://Stackoverflow.com/users/19013029", "pm_score": -1, "selected": false, "text": "#correct way to read file contents\nfile = open('testfile.txt', 'r').read()\n" }, { "answer_id": 74275751, "author": "tripleee", "author_id": 874188, "author_profile": "https://Stackoverflow.com/users/874188", "pm_score": 2, "selected": false, "text": "file" }, { "answer_id": 74278239, "author": "Arifa Chan", "author_id": 19574157, "author_profile": "https://Stackoverflow.com/users/19574157", "pm_score": 1, "selected": false, "text": "student_id" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74275639", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20059702/" ]
74,275,656
<p>I have a question while studying C++ MFC.</p> <pre><code>void AnchorDlg::OnGetdispinfoListctrl(NMHDR *pNMHDR, LRESULT *pResult) { NMLVDISPINFO *pDispInfo = reinterpret_cast&lt;NMLVDISPINFO*&gt;(pNMHDR); LV_ITEM* pItem = &amp;(pDispInfo)-&gt;item; CString str; if(pItem == NULL) return; int nRow = pItem-&gt;iItem; int nCol = pItem-&gt;iSubItem; if(nRow&lt;0 || nRow &gt;= mapShip-&gt;size()) return; auto iter = mapShip-&gt;begin(); if(pItem-&gt;pszText) { switch(nCol) { case 1: str.Format(_T(&quot;%.0f&quot;), iter-&gt;second-&gt;mmsi); //str.Format(_T(&quot;%.0f&quot;), iter-&gt;second-&gt;mmsi); lstrcpy(pItem-&gt;pszText, str); break; case 2: str.Format(_T(&quot;%.7f&quot;), iter-&gt;second-&gt;lat); lstrcpy(pItem-&gt;pszText, str); break; case 3: str.Format(_T(&quot;%.7f&quot;), iter-&gt;second-&gt;lng); lstrcpy(pItem-&gt;pszText, str); break; case 4: str.Format(_T(&quot;%.1f&quot;), iter-&gt;second-&gt;sog); lstrcpy(pItem-&gt;pszText, str); case 5: str.Format(_T(&quot;%.1f&quot;), iter-&gt;second-&gt;cog); lstrcpy(pItem-&gt;pszText, str); } } *pResult = 0; } </code></pre> <p><code>mapShip</code> consists of double and data objects.</p> <p>I want to print out 1000 data, but only one data is printed.</p> <p>I've used iter but only one data is output. Same data print repeat.</p> <p>I must used map data structure.</p> <p>I don't know how to use the map.</p>
[ { "answer_id": 74275726, "author": "Vishu", "author_id": 19013029, "author_profile": "https://Stackoverflow.com/users/19013029", "pm_score": -1, "selected": false, "text": "#correct way to read file contents\nfile = open('testfile.txt', 'r').read()\n" }, { "answer_id": 74275751, "author": "tripleee", "author_id": 874188, "author_profile": "https://Stackoverflow.com/users/874188", "pm_score": 2, "selected": false, "text": "file" }, { "answer_id": 74278239, "author": "Arifa Chan", "author_id": 19574157, "author_profile": "https://Stackoverflow.com/users/19574157", "pm_score": 1, "selected": false, "text": "student_id" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74275656", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20387659/" ]
74,275,666
<p>I'm using <code>ant design table</code>. I use a <code>onRow</code> property when a user clicks on a row of the table to go to another page(such as texts, empty spaces,...) but for a specific column of that Row I want to use another onClick and when user click on this column go to a specific page.</p> <p>for solving this problem I added a <code>a</code> tag but it just works when I click on the icon(Not the Whole of my column). my problem is I want the whole of my cell of this column to have a different onClick function (means icon and empty space!...).</p> <p>thank you for your help!</p> <p>here is my code :</p> <p><strong>column:</strong></p> <pre><code> { title: 'Platform', dataIndex: 'platform', key: 'platform', align: 'center', render: (_, record) =&gt; { return ( &lt;a href={placeUrl(routes.platformDetails, {})} &gt; &lt;Tooltip title={record.platform.name}&gt; &lt;Avatar src={record.platform.icon} size=&quot;large&quot; /&gt; &lt;/Tooltip&gt; &lt;/a&gt; ); }, sorter: (a, b) =&gt; a.platform.type.localeCompare(b.platform.type), }, ///other column </code></pre> <p><strong>Table:</strong></p> <pre><code> &lt;Table onRow={record =&gt; { return { onClick: () =&gt; { const { sId } = record; const sURL = placeURLQueryParams( PATHS.routes.sDetails, { sId, pId: props.isForAllP ? record.p.pId : pId, }, ); history.push(sURL); }, }; }} dataSource={data} columns={columns} /&gt; </code></pre>
[ { "answer_id": 74299485, "author": "alextrastero", "author_id": 2902063, "author_profile": "https://Stackoverflow.com/users/2902063", "pm_score": 2, "selected": true, "text": "onCell" }, { "answer_id": 74325597, "author": "Negin", "author_id": 14493830, "author_profile": "https://Stackoverflow.com/users/14493830", "pm_score": 0, "selected": false, "text": "onCell" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74275666", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14493830/" ]
74,275,674
<p>I have a data set like this</p> <pre><code>ID departure_airport arrival_airport journey id flight is_outbound n 1 ZRH MSY 1 1 TRUE 2 2 MSY IAD 1 2 TRUE 2 3 ZRH LAX 2 1 TRUE 2 4 ZRH BUD 3 1 TRUE 1 5 VIE ZRH 4 1 TRUE 1 6 ZRH KEF 5 1 TRUE 2 7 KEF BOS 5 2 TRUE 2 </code></pre> <p>I would like to duplicate the rows with a value of 2 in column &quot;n&quot; and invert their airport codes in the departure and arrival columns. Further, the values in &quot;is_outbound&quot; of the new created rows are to be put on FALSE and the numbering of the &quot;flight&quot; column should continue for the same journey_id. The output should look like this:</p> <pre><code>ID departure_airport arrival_airport journey id flight is_outbound n 1 ZRH MSY 1 1 TRUE 2 2 MSY IAD 1 2 TRUE 2 3 IAD MSY 1 3 FALSE 2 4 MSY ZRH 1 4 FALSE 2 5 ZRH LAX 2 1 TRUE 1 6 ZRH BUD 3 1 TRUE 1 7 VIE ZRH 4 1 TRUE 1 8 ZRH KEF 5 1 TRUE 2 9 KEF BOS 5 2 TRUE 2 10 BOS KEF 5 3 FALSE 2 11 KEF ZRH 5 4 FALSE 2 </code></pre> <p>Any suggestions on how I can get the resulting table?</p>
[ { "answer_id": 74276001, "author": "Ricardo Semião e Castro", "author_id": 13048728, "author_profile": "https://Stackoverflow.com/users/13048728", "pm_score": 1, "selected": false, "text": "df_dup = df %>%\n filter(n == 2) %>%\n group_by(`journey id`) %>% # to get the number of flights in each journey with n() in the last line of mutate\n mutate(departure_temp = arrival_airport, #see \"Obs 1\" below \n arrival_airport = departure_airport,\n departure_airport = departure_temp,\n departure_temp = NULL,\n is_outbound = FALSE,\n flight = flight + n()) #if there are 1 journey, 1 -> 2, if there are 2 journeys, 1 -> 3, 2 -> 4, etc.\n\ndf = rbind(df, df_dup) %>%\n arrange(`journey id`) %>%\n mutate(ID = rownames(.))\n\n> df\n# A tibble: 12 x 7\nID departure_airport arrival_airport `journey id` flight is_outbound n\n<chr> <chr> <chr> <dbl> <dbl> <chr> <dbl>\n1 1 ZRH MSY 1 1 TRUE 2\n2 2 MSY IAD 1 2 TRUE 2\n3 3 MSY ZRH 1 3 FALSE 2\n4 4 IAD MSY 1 4 FALSE 2\n5 5 ZRH LAX 2 1 TRUE 2\n6 6 LAX ZRH 2 2 FALSE 2\n7 7 ZRH BUD 3 1 TRUE 1\n8 8 VIE ZRH 4 1 TRUE 1\n9 9 ZRH KEF 5 1 TRUE 2\n10 10 KEF BOS 5 2 TRUE 2\n11 11 KEF ZRH 5 3 FALSE 2\n12 12 BOS KEF 5 4 FALSE 2\n" }, { "answer_id": 74276015, "author": "Captain Hat", "author_id": 4676560, "author_profile": "https://Stackoverflow.com/users/4676560", "pm_score": 2, "selected": false, "text": "require(vroom) # only need this to read in a copy/paste'd table\nrequire(dplyr)\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74275674", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18679050/" ]
74,275,694
<p>I have a question about my soap services(wcf) I implement my wcf service and all the function implement correctly at compile time I do not have any compile time error but when i run my code I received this error message</p> <blockquote> <p>An endpoint configuration section for contract 'test.ICore' could not be loaded because more than one endpoint configuration for that contract was found. Please indicate the preferred endpoint configuration</p> </blockquote> <p>I think in soap services we need some change in web.config file another point is that my project have multiple soap services. may it cause a problem?</p> <p>how can i solve this issue? thank you so much</p>
[ { "answer_id": 74284115, "author": "Jiayao", "author_id": 16430068, "author_profile": "https://Stackoverflow.com/users/16430068", "pm_score": 0, "selected": false, "text": "<service\n name=\"Microsoft.ServiceModel.Samples.CalculatorService\"\n behaviorConfiguration=\"CalculatorServiceBehavior\">\n <endpoint address=\"\"\n binding=\"basicHttpBinding\"\n contract=\"Microsoft.ServiceModel.Samples.ICalculator\" />\n <endpoint address=\"secure\"\n binding=\"wsHttpBinding\"\n contract=\"Microsoft.ServiceModel.Samples.ICalculator\" />\n</service>\n" }, { "answer_id": 74289608, "author": "Mehrdad Noroozi", "author_id": 15515069, "author_profile": "https://Stackoverflow.com/users/15515069", "pm_score": 2, "selected": true, "text": "<binding name=\"TestSoap\">\n <security mode=\"Transport\" />\n</binding>\n<binding name=\"TestSoap\" />\n\n\n<endpoint address=\"http://TestSoap/Core.svc/soap\"\n binding=\"basicHttpBinding\" bindingConfiguration=\"Soap\" contract=\"TestSoap.ICore\"\n name=\"TestSoap\" />\n<endpoint address=\"https://TestSoap/Core.svc/soap\"\n binding=\"basicHttpBinding\" bindingConfiguration=\"TestSoap\"\n contract=\"TestSoap.ICore\" name=\"TestSoap\" />\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74275694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20387676/" ]
74,275,708
<p>I am making a guessing game which makes a random number between 1 and 200. Whenever I guess, the program will tell me if its too high or too low, then ask me to try again.</p> <p>I'm supposed to put a &quot;try again&quot; input box inside my code. Now my code is only showing &quot;your guess is too high/too low&quot;. I don't understand where and how to put it.</p> <p>This is my code:</p> <pre class="lang-java prettyprint-override"><code>import static javax.swing.JOptionPane.*; class Tallspill { public int nyttTall() { int tilfeldig = (int) (Math.random() * 201); return tilfeldig; } public void visMelding(String melding) { showMessageDialog(null,melding); } private void forLite(int tall) { if (tall &lt; nyttTall()) { String melding = (tall + &quot; er for lite. Prøv igjen!&quot;); visMelding(melding); } } private void forStort(int tall) { if (tall&gt;nyttTall()) { String melding = (tall+&quot; er for stort. Prøv igjen!&quot;); visMelding(melding); } } public void avsluttRunde(int antall, int tall) { String melding = (tall + &quot;er riktig. Du brukte &quot; + antall + &quot; forsøk.&quot;); visMelding(melding); } public void kjørspill() { int random = nyttTall(); int tall = Integer.parseInt(showInputDialog(&quot;Skriv inn et tall mellom 0 og 200&quot;)); int antall = 0; while(tall != random) { if (tall &lt; random) { forLite(tall); //metode for nytt forsøk } antall++; if (tall &gt; random) { forStort(tall); //metode for nytt forsøk } antall++; if (tall == random) { avsluttRunde(antall,tall); } } } } </code></pre> <pre class="lang-java prettyprint-override"><code>public class Test { public static void main(String[] args) { Tallspill spill = new Tallspill(); spill.kjørspill(); } } </code></pre> <p>I tried putting an input string inside the while-loop, but then it just looped on &quot;try again&quot;. I also tried putting it inside the <code>toolow</code> and <code>toohigh</code> methods, but then I got an error.</p>
[ { "answer_id": 74284115, "author": "Jiayao", "author_id": 16430068, "author_profile": "https://Stackoverflow.com/users/16430068", "pm_score": 0, "selected": false, "text": "<service\n name=\"Microsoft.ServiceModel.Samples.CalculatorService\"\n behaviorConfiguration=\"CalculatorServiceBehavior\">\n <endpoint address=\"\"\n binding=\"basicHttpBinding\"\n contract=\"Microsoft.ServiceModel.Samples.ICalculator\" />\n <endpoint address=\"secure\"\n binding=\"wsHttpBinding\"\n contract=\"Microsoft.ServiceModel.Samples.ICalculator\" />\n</service>\n" }, { "answer_id": 74289608, "author": "Mehrdad Noroozi", "author_id": 15515069, "author_profile": "https://Stackoverflow.com/users/15515069", "pm_score": 2, "selected": true, "text": "<binding name=\"TestSoap\">\n <security mode=\"Transport\" />\n</binding>\n<binding name=\"TestSoap\" />\n\n\n<endpoint address=\"http://TestSoap/Core.svc/soap\"\n binding=\"basicHttpBinding\" bindingConfiguration=\"Soap\" contract=\"TestSoap.ICore\"\n name=\"TestSoap\" />\n<endpoint address=\"https://TestSoap/Core.svc/soap\"\n binding=\"basicHttpBinding\" bindingConfiguration=\"TestSoap\"\n contract=\"TestSoap.ICore\" name=\"TestSoap\" />\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74275708", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20387699/" ]
74,275,725
<p>I have a working Android webview App I made using Android Studio, I needed to make it open links that contains &quot;_blank&quot; externally. I added the code below</p> <pre><code> @Override public boolean onCreateWindow(WebView view, boolean dialog, boolean userGesture, android.os.Message resultMsg) { WebView.HitTestResult result = view.getHitTestResult(); String data = result.getExtra(); Context context = view.getContext(); Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(data)); context.startActivity(browserIntent); return false; } </code></pre> <p>But the first line of the code &quot;@Override&quot; shows the error below</p> <pre><code>&gt; Task :app:compileDebugJavaWithJavac FAILED ...\MainActivity.java:58: error: method does not override or implement a method from a supertype @Override ^ Note: ...\MainActivity.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. 1 error </code></pre> <p>Below is the Full &quot;MainActivity&quot; Code</p> <pre><code>import android.annotation.SuppressLint; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.net.http.SslError; import android.os.Bundle; import android.view.KeyEvent; import android.webkit.SslErrorHandler; import android.webkit.WebView; import android.webkit.WebViewClient; import androidx.appcompat.app.AppCompatActivity; public class MainActivity extends AppCompatActivity implements Main_Activity, Main__Activity { WebView webView; @SuppressLint(&quot;SetJavaScriptEnabled&quot;) @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); webView = findViewById(R.id.web); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setSupportZoom(false); webView.getSettings().setDomStorageEnabled(true); webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); webView.getSettings().setSupportMultipleWindows(true); webView.getSettings().setUseWideViewPort(false); webView.setWebViewClient(new WebViewClient() { }); webView.loadUrl(&quot;file:///android_asset/app.html&quot;); } public class myWebViewClient extends WebViewClient{ @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { webView.loadUrl(&quot;file:///android_asset/error.html&quot;); } @Override public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { super.onReceivedSslError(view, handler, error); handler.cancel(); } @Override public boolean onCreateWindow(WebView view, boolean dialog, boolean userGesture, android.os.Message resultMsg) { WebView.HitTestResult result = view.getHitTestResult(); String data = result.getExtra(); Context context = view.getContext(); Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(data)); context.startActivity(browserIntent); return false; } } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if ((keyCode == KeyEvent.KEYCODE_BACK) &amp;&amp; webView.canGoBack()) { webView.goBack(); return true; } return super.onKeyDown(keyCode, event); } } </code></pre> <p>I've tried several locations for the code but the error persists. I want to get the error off and achieve the reason why I added the code; to open target&quot;_blank&quot; outside the webview app.</p>
[ { "answer_id": 74284115, "author": "Jiayao", "author_id": 16430068, "author_profile": "https://Stackoverflow.com/users/16430068", "pm_score": 0, "selected": false, "text": "<service\n name=\"Microsoft.ServiceModel.Samples.CalculatorService\"\n behaviorConfiguration=\"CalculatorServiceBehavior\">\n <endpoint address=\"\"\n binding=\"basicHttpBinding\"\n contract=\"Microsoft.ServiceModel.Samples.ICalculator\" />\n <endpoint address=\"secure\"\n binding=\"wsHttpBinding\"\n contract=\"Microsoft.ServiceModel.Samples.ICalculator\" />\n</service>\n" }, { "answer_id": 74289608, "author": "Mehrdad Noroozi", "author_id": 15515069, "author_profile": "https://Stackoverflow.com/users/15515069", "pm_score": 2, "selected": true, "text": "<binding name=\"TestSoap\">\n <security mode=\"Transport\" />\n</binding>\n<binding name=\"TestSoap\" />\n\n\n<endpoint address=\"http://TestSoap/Core.svc/soap\"\n binding=\"basicHttpBinding\" bindingConfiguration=\"Soap\" contract=\"TestSoap.ICore\"\n name=\"TestSoap\" />\n<endpoint address=\"https://TestSoap/Core.svc/soap\"\n binding=\"basicHttpBinding\" bindingConfiguration=\"TestSoap\"\n contract=\"TestSoap.ICore\" name=\"TestSoap\" />\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74275725", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18258276/" ]
74,275,736
<p>I'm trying to build an app (macOS, but would be the same for iOS) that creates a number of grids, the outcome of which is to be shown in a second screen. For this, I'm sharing data across these screens, and I'm running into an issue here, I hope someone can help or point me in the right direction. I'll share a simplified version of the code below (working in Xcode 14.0.1)</p> <p>The code creates a dictionary that can be shown in a grid, on which calculations can be done. The idea is then to add this grid, with some descriptive variables, into another dictionary</p> <p>The building blocks of the grid are cells</p> <pre><code>Import Foundation struct Cell: Comparable, Equatable, Identifiable, Hashable { static func == (lhs: Cell, rhs: Cell) -&gt; Bool { lhs.randomVarOne == rhs.randomVarOne } var randomVarOne: Double var randomVarTwo: Bool // other vars omitted here var id: Int { randomVarOne } static func &lt; (lhs: Cell, rhs: Cell) -&gt; Bool { return lhs.randomVarOne &lt; rhs.randomVarOne } } </code></pre> <p>this is also where there are a bunch of funcs to calculate next neighbor cells in the grid etc</p> <p>then the grid is defined in a class:</p> <pre><code>class Info: ObservableObject, Hashable { static func == (lhs: Info, rhs: Info) -&gt; Bool { lhs.grid == rhs.grid } func hash(into hasher: inout Hasher) { hasher.combine(grid) } @Published var grid = [Cell]() var arrayTotal = 900 @Published var toBeUsedForTheGridCalculations: Double = 0.0 var toBeUsedToSetTheVarAbove: Double = 0.0 var rowTotalDouble: Double {sqrt(Double(arrayTotal)) } var rowTotal: Int { Int(rowTotalDouble) != 0 ? Int(rowTotalDouble) : 10 } </code></pre> <p>The class includes a func to create and populate the grid with Cells and add these Cells to the grid var. It also includes the formulas to do the calculations on the grid using a user input. The class did not seem to need an initializer.</p> <p>This is the Scenario struct:</p> <pre><code>struct Scenario: Comparable, Equatable, Identifiable, Hashable { static func == (lhs: Scenario, rhs: Scenario) -&gt; Bool { lhs.scenarioNumber == rhs.scenarioNumber } func hash(into hasher: inout Hasher) { hasher.combine(scenarioNumber) } var scenarioNumber: Int var date: Date var thisIsOneSnapshot = [Info]() var id: Int { scenarioNumber } static func &lt; (lhs: Scenario, rhs: Scenario) -&gt; Bool { return lhs.scenarioNumber &lt; rhs.scenarioNumber } } </code></pre> <p>added hashable since it uses the Info class as an input.</p> <p>Then there is the class showing the output overview</p> <pre><code>class OutputOverview: ObservableObject { @Published var snapshot = [Scenario]() </code></pre> <p>// the class includes a formula of how to add the collection of cells (grid) and the additional variables to the snapshot dictionary. Again no initializer was necessary.</p> <p>Now to go to the ContentView.</p> <pre><code>struct ContentView: View { @Environment(\.openURL) var openURL var scenarioNumberInput: Int = 0 var timeStampAssigned: Date = Date.now @ObservedObject private var currentGrid: Info = Info() @ObservedObject private var scenarios: Combinations = Combinations() var usedForTheCalculations: Double = 0.0 var rows = [ GridItem(.flexible()), // whole list of GridItems, I do not know how to calculate these: // var rows = Array(repeating: GridItem(.flexible()), count: currentGrid.rowTotal) //gives error &quot;Cannot use instance member 'currentGrid' within property initializer; // property iunitializers run before 'self' is available ] var body: some View { GeometryReader { geometry in VStack { ScrollView { LazyHGrid(rows: rows, spacing: 0) { ForEach(0..&lt;currentGrid.grid.count, id :\.self) { w in let temp = currentGrid.grid[w].varThatAffectsFontColor let temp2 = currentGrid.grid[w].varThatAffectsBackground Text(&quot;\(currentGrid.grid[w].randomVarOne, specifier: &quot;%.2f&quot;)&quot;) .frame(width: 25, height: 25) .border(.black) .font(.system(size: 7)) .foregroundColor(Color(wordName: temp)) .background(Color(wordName: temp2)) } } .padding(.top) } VStack{ HStack { Button(&quot;Start&quot;) { } // then some buttons to do the calculations Button(&quot;Add to collection&quot;){ scenarios.addScenario(numbering: scenarioNumberInput, timeStamp: Date.now, collection: currentGrid.grid) } // this should add the newly recalculated grid to the dictionary Button(&quot;Go to Results&quot;) { guard let url = URL(string: &quot;myapp://scenario&quot;) else { return } openURL(url) } // to go to the screen showing the scenarios </code></pre> <p>Then the second View, the ScenarioView:</p> <pre><code>struct ScenarioView: View { @State var selectedScenario = 1 @ObservedObject private var scenarios: OutputOverview var pickerNumbers = [ 1, 2, 3, 4 , 5] // this is to be linked to the number of scenarios completed,this code is not done yet. var rows = [ GridItem(.flexible()), GridItem(.flexible()), // similar list of GridItems here.... var body: some View { Form { Section { Picker(&quot;Select a scenario&quot;, selection: $selectedScenario) { ForEach(pickerNumbers, id: \.self) { Text(&quot;\($0)&quot;) } } } Section { ScrollView { if let idx = scenarios.snapshot.firstIndex(where: {$0.scenarioNumber == selectedScenario}) { LazyHGrid(rows: rows, spacing: 0) { ForEach(0..&lt;scenarios.snapshot[idx].thisIsOneSnapshot.count, id :\.self) { w in let temp = scenarios.snapshot[idx].thisIsOneSnapshot[w].varThatAffectsFontColor let temp2 = scenarios.snapshot[idx].thisIsOneSnapshot[w].varThatAffectsBackground Text(&quot;\(scenarios.snapshot[idx].thisIsOneSnapshot[w].randomVarOne, specifier: &quot;%.2f&quot;)&quot;) .frame(width: 25, height: 25) .border(.black) .font(.system(size: 7)) .foregroundColor(Color(wordName: temp)) .background(Color(wordName: temp2)) } } } } } } } } </code></pre> <p>Now while the above does not (for the moment..) give me error messages, I am not able to run the PreviewProvider in the second View. The main problem is in @main:</p> <pre><code>import SwiftUI @main struct ThisIsTheNameOfMyApp: App { var body: some Scene { WindowGroup { ContentView() } .handlesExternalEvents(matching: [&quot;main&quot;]) WindowGroup(&quot;Scenarios&quot;) { ScenarioView() // error messages here: 'ScenarioView' initializer is inaccessible due to &quot;private&quot; // protection level - I don't know what is set to private in ScenarioView that could // cause this // second error message: missing argument for parameter 'scenarios' in call } .handlesExternalEvents(matching: [&quot;scenario&quot;]) } } </code></pre> <p>I am at a loss on how to solve these 2 error messages and would be very grateful for any tips or guidance. Apologies if this question is very long, I scanned many other forum questions and could not find any good answers.</p> <p>I have tried adding pro forma data in @main as follows</p> <pre><code> @main struct FloodModelScenarioViewerApp: App { @State var scenarios = Scenario(scenarioNumber: 1, date: Date.now) var body: some Scene { WindowGroup { ContentView() } .handlesExternalEvents(matching: [&quot;main&quot;]) WindowGroup(&quot;Scenarios&quot;) { ScenarioView(scenarios: scenarios) } .handlesExternalEvents(matching: [&quot;scenario&quot;]) } } </code></pre> <p>This still gives 2 error messages:</p> <ul> <li>same issue with regards to ScenarioView initialiser being inaccessible due to being 'private'</li> <li>Cannot convert value of type 'Scenario' to expected argument type 'OutputOverview'</li> </ul>
[ { "answer_id": 74284115, "author": "Jiayao", "author_id": 16430068, "author_profile": "https://Stackoverflow.com/users/16430068", "pm_score": 0, "selected": false, "text": "<service\n name=\"Microsoft.ServiceModel.Samples.CalculatorService\"\n behaviorConfiguration=\"CalculatorServiceBehavior\">\n <endpoint address=\"\"\n binding=\"basicHttpBinding\"\n contract=\"Microsoft.ServiceModel.Samples.ICalculator\" />\n <endpoint address=\"secure\"\n binding=\"wsHttpBinding\"\n contract=\"Microsoft.ServiceModel.Samples.ICalculator\" />\n</service>\n" }, { "answer_id": 74289608, "author": "Mehrdad Noroozi", "author_id": 15515069, "author_profile": "https://Stackoverflow.com/users/15515069", "pm_score": 2, "selected": true, "text": "<binding name=\"TestSoap\">\n <security mode=\"Transport\" />\n</binding>\n<binding name=\"TestSoap\" />\n\n\n<endpoint address=\"http://TestSoap/Core.svc/soap\"\n binding=\"basicHttpBinding\" bindingConfiguration=\"Soap\" contract=\"TestSoap.ICore\"\n name=\"TestSoap\" />\n<endpoint address=\"https://TestSoap/Core.svc/soap\"\n binding=\"basicHttpBinding\" bindingConfiguration=\"TestSoap\"\n contract=\"TestSoap.ICore\" name=\"TestSoap\" />\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74275736", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16835035/" ]
74,275,810
<p>I am new to <code>AUTOSAR</code> and I would like to call a <code>RTE</code> function to get a specific value from one <code>SWC</code> to another <code>SWC</code>. The <code>RTE_Write</code> is performing by one <code>SWC 1</code> <code>runnable</code> with <code>10 msec</code> task and <code>RTE_read</code> is performing by another <code>SWC 2</code> with <code>15 msec task</code>. I am using <code>sender receiver interface</code> to implement this concept.</p> <pre><code>SWC 1 : Task_10msec() { eg: int val = 0; val = val +1 ; Rte_write_test_port(val); } SWC 2 : Task_15msec() { eg: int val = 0; Rte_read_test_port(&amp;val); } </code></pre> <p>Now here i am facing the problem is that <code>RTE_read</code> value is not <code>sync</code> with <code>RTE_Write</code> value because of the runnable timing (<code>SWC 1</code> is <code>10 msec</code> and <code>SWC 2</code> is <code>15 msec</code>). I would like to know, is there any way to design the interface/ any approach to get the exact read value in SWC 2 after writing from SWC 1?</p>
[ { "answer_id": 74325404, "author": "kesselhaus", "author_id": 8321975, "author_profile": "https://Stackoverflow.com/users/8321975", "pm_score": 1, "selected": false, "text": "QueuedReceiverComSpec" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74275810", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2986042/" ]
74,275,837
<p>I have a table with following data.</p> <pre><code>id country serial other_column 1 us 123 1 2 us 456 1 3 gb 123 1 4 gb 456 1 5 jp 777 1 6 jp 888 1 7 us 123 2 8 us 456 3 9 gb 456 4 10 us 123 1 11 us 123 1 </code></pre> <p>Is there a way to fetch 2 rows per unique country and unique serial?</p> <p>For example, expecting following results from my query.</p> <p>us,123,1 comes twice cos there was 3 of the same kind and I want 2 rows per unique country and unique serial.</p> <pre><code>us,123,1 us,123,1 us,456,1 gb,123,1 gb,456,1 jp,777,1 jp,888,1 </code></pre> <p>I can't use:</p> <pre><code>select distinct country, serial from my_table; </code></pre> <p>Since I want 2 rows per distinct value match for country and serial. Pls advice.</p>
[ { "answer_id": 74325404, "author": "kesselhaus", "author_id": 8321975, "author_profile": "https://Stackoverflow.com/users/8321975", "pm_score": 1, "selected": false, "text": "QueuedReceiverComSpec" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74275837", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9401029/" ]
74,275,856
<p>I would like to update my model if the user did not logged in the day before .</p> <pre><code>@receiver(post_save, sender=user_logged_in) def user_logged_in_streak(sender, instance, *args, **kwargs): today: date = timezone.now().date() class_completed = ClassAttempt.objects.filter(user=instance.user, status='completed',)\ .order_by('-updated_at')\ .first() if (instance.user.last_login == today - timedelta(days=2) and (class_completed.updated_at == today - timedelta(days=2))): UserStatisticStatus.objects.update(day_streak=0) else: pass </code></pre>
[ { "answer_id": 74325404, "author": "kesselhaus", "author_id": 8321975, "author_profile": "https://Stackoverflow.com/users/8321975", "pm_score": 1, "selected": false, "text": "QueuedReceiverComSpec" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74275856", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20240479/" ]
74,275,857
<p>i have this dataframe, and i want to extract cities in a separate column. You can also see, that the format is not same, and the city can be anywhere in the row. How can i extract only cities i a new column? <strong>Prompt. Here we are talking about German cities.</strong> May be to find a dictionary, that shows all German cities and somehow compare with my dataset?</p> <p>Here is dictionary of german cities: <a href="https://gist.github.com/embayer/772c442419999fa52ca1" rel="nofollow noreferrer">https://gist.github.com/embayer/772c442419999fa52ca1</a></p> <p><strong>Dataframe</strong></p> <pre><code>Adresse 0 Karlstr 10, 10 B, 30,; 04916 Hamburg 1 München Dorfstr. 28-55, 22555 2 Marnstraße. Berlin 12, 45666 Berlin 3 Musterstr, 24855 Dresden ... ... 850 Muster Hausweg 11, Hannover, 56668 851 Mariestr. 4, 48669 Nürnberg 852 Hilden Weederstr 33-55, 56889 853 Pt-gaanen-Str. 2, 45883 Potsdam </code></pre> <p>Output</p> <pre><code>Cities 0 Hamburg 1 München 2 Berlin 3 Dresden ... ... 850 Hannover 851 Nürnberg 852 Hilden 853 Potsdam </code></pre>
[ { "answer_id": 74276063, "author": "Zephyrus", "author_id": 11978973, "author_profile": "https://Stackoverflow.com/users/11978973", "pm_score": 0, "selected": false, "text": "**" }, { "answer_id": 74276067, "author": "sophocles", "author_id": 9167382, "author_profile": "https://Stackoverflow.com/users/9167382", "pm_score": 2, "selected": true, "text": "key" }, { "answer_id": 74276171, "author": "Nathan Furnal", "author_id": 9479128, "author_profile": "https://Stackoverflow.com/users/9479128", "pm_score": 1, "selected": false, "text": "str.extract" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74275857", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13860875/" ]
74,275,882
<p>I have an application that uses the google bucket to store media, as there are many media, it was necessary to use the CDN service to reduce latency when loading them. However, when I use the CDN, the media is public and accessible to any unauthenticated person. Is there any way to cache the media and at the same time keep it private through an authentication token?</p> <p>I tried in many ways following the documentation, keeping the Cache Type capturing the information from the Cache-Control header and the authorization token, but after caching the media it is accessible without the authentication token.</p> <p>Can anybody help me?</p>
[ { "answer_id": 74276063, "author": "Zephyrus", "author_id": 11978973, "author_profile": "https://Stackoverflow.com/users/11978973", "pm_score": 0, "selected": false, "text": "**" }, { "answer_id": 74276067, "author": "sophocles", "author_id": 9167382, "author_profile": "https://Stackoverflow.com/users/9167382", "pm_score": 2, "selected": true, "text": "key" }, { "answer_id": 74276171, "author": "Nathan Furnal", "author_id": 9479128, "author_profile": "https://Stackoverflow.com/users/9479128", "pm_score": 1, "selected": false, "text": "str.extract" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74275882", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6216711/" ]
74,275,891
<p>I am looking to create variables that sum based on date ranges unique to different features / categories to automate a current Excel task in Python. It is like a SUMIF in Excel but unique date ranges for different variables. I`ll try to recreate a similar situation as I cannot share the exact data. At the moment, I have a sales dataframe with sales per week by area like so:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Week</th> <th>Area</th> <th>Sales</th> </tr> </thead> <tbody> <tr> <td>08/02/2019</td> <td>London</td> <td>200</td> </tr> <tr> <td>08/02/2019</td> <td>Scotland</td> <td>150</td> </tr> <tr> <td>15/02/2019</td> <td>London</td> <td>100</td> </tr> <tr> <td>15/02/2019</td> <td>Scotland</td> <td>120</td> </tr> <tr> <td>22/02/2019</td> <td>London</td> <td>50</td> </tr> <tr> <td>22/02/2019</td> <td>Scotland</td> <td>20</td> </tr> </tbody> </table> </div> <p>I want to incorporate whether the date falls within sales periods for products, so say I have another dataframe like this:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Product</th> <th>Sale Start Week</th> <th>Sale End Week</th> </tr> </thead> <tbody> <tr> <td>Boots</td> <td>08/02/2019</td> <td>15/02/2019</td> </tr> <tr> <td>Accessories</td> <td>15/02/2019</td> <td>22/02/2019</td> </tr> </tbody> </table> </div> <p>I want to create something that sums if the dates fall within those specified for each product. For example, for Boots below, sum Sales if the weeks in Sales fall within the Sales Periods date range:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Area</th> <th>Boots</th> <th>Accessories</th> </tr> </thead> <tbody> <tr> <td>London</td> <td>300</td> <td>150</td> </tr> <tr> <td>Scotland</td> <td>270</td> <td>140</td> </tr> </tbody> </table> </div> <p>I`ve tried groupby and a pivot table but I am not sure how to incorporate the sales dates filters into it. At the moment, the sales period dataframe and the sales dataframe are separate.</p> <p>This is what I have for the pivot code which is almost there:</p> <pre><code>test = pd.pivot_table(df,index=['Area','Week'],columns=sales_period_df['Product'],values=['Sales'],aggfunc=np.sum) </code></pre> <p>But this doesnt include filtering for the sales periods and I`m not sure how to incorporate this. Would appreciate your advice, thanks in advance!</p>
[ { "answer_id": 74276063, "author": "Zephyrus", "author_id": 11978973, "author_profile": "https://Stackoverflow.com/users/11978973", "pm_score": 0, "selected": false, "text": "**" }, { "answer_id": 74276067, "author": "sophocles", "author_id": 9167382, "author_profile": "https://Stackoverflow.com/users/9167382", "pm_score": 2, "selected": true, "text": "key" }, { "answer_id": 74276171, "author": "Nathan Furnal", "author_id": 9479128, "author_profile": "https://Stackoverflow.com/users/9479128", "pm_score": 1, "selected": false, "text": "str.extract" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74275891", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18973159/" ]
74,275,893
<p>I have a conventional project that stores users in auth_user django table. Later, I decided to implement a <code>profiles</code> app. The <code>views.py</code> code is below</p> <pre><code>class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) </code></pre> <p>I do <code>makemigrations</code> and <code>migrate</code>. The table is created with empty data, i.e., previous users that exist in <code>auth_user</code> were not populated in the <code>profiles_profile</code> table. How can I populate old data in my new table? Thanks</p>
[ { "answer_id": 74276063, "author": "Zephyrus", "author_id": 11978973, "author_profile": "https://Stackoverflow.com/users/11978973", "pm_score": 0, "selected": false, "text": "**" }, { "answer_id": 74276067, "author": "sophocles", "author_id": 9167382, "author_profile": "https://Stackoverflow.com/users/9167382", "pm_score": 2, "selected": true, "text": "key" }, { "answer_id": 74276171, "author": "Nathan Furnal", "author_id": 9479128, "author_profile": "https://Stackoverflow.com/users/9479128", "pm_score": 1, "selected": false, "text": "str.extract" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74275893", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15130779/" ]
74,275,939
<p>I have a table with dates and some other information, where the dates are not continuous (no weekends). How do I get all records from the last two days/dates (which I don't necessarily know beforehand)?</p> <p>While</p> <p><code>SELECT datum FROM trackproc ORDER BY datum DESC LIMIT 1;</code></p> <p>gives me the last date, and</p> <p><code>SELECT datum FROM trackproc ORDER BY datum DESC LIMIT 1,1;</code></p> <p>the second last one, which is what I want, this statement</p> <pre><code>SELECT * FROM trackproc WHERE datum BETWEEN (SELECT datum FROM trackproc ORDER BY datum DESC LIMIT 1) AND (SELECT datum FROM trackproc ORDER BY datum DESC LIMIT 1,1) ORDER BY datum; </code></pre> <p>returns empty.</p> <p>How would I write such a statement?</p>
[ { "answer_id": 74276063, "author": "Zephyrus", "author_id": 11978973, "author_profile": "https://Stackoverflow.com/users/11978973", "pm_score": 0, "selected": false, "text": "**" }, { "answer_id": 74276067, "author": "sophocles", "author_id": 9167382, "author_profile": "https://Stackoverflow.com/users/9167382", "pm_score": 2, "selected": true, "text": "key" }, { "answer_id": 74276171, "author": "Nathan Furnal", "author_id": 9479128, "author_profile": "https://Stackoverflow.com/users/9479128", "pm_score": 1, "selected": false, "text": "str.extract" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74275939", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9228488/" ]
74,275,960
<p>I have a dictionary with dictionaries and I need to add numbers to the values 'plece'. Numbering according to the length of the main dictionary.</p> <pre class="lang-py prettyprint-override"><code>{'SVF': {'place': '', 'name': 'Sebastian Vettel', 'team': 'FERRARI', 'time': '1:04.415'}, 'VBM': {'place': '', 'name': 'Valtteri Bottas', 'team': 'MERCEDES', 'time': '1:12.434'}, 'SVM': {'place': '', 'name': 'Stoffel Vandoorne', 'team': 'MCLAREN RENAULT', 'time': '1:12.463'} </code></pre> <p>Example:</p> <pre><code>'SVM': {'place': '1', 'name': 'Stoffel Vandoorne', 'team': 'MCLAREN RENAULT', 'time': '1:12.463'}, 'VBM': {'place': '2', 'name': 'Valtteri Bottas', 'team': 'MERCEDES', 'time': '1:12.434'}, 'SVM': {'place': '3', 'name': 'Stoffel Vandoorne', 'team': 'MCLAREN RENAULT', 'time': '1:12.463'} </code></pre>
[ { "answer_id": 74276010, "author": "S.B", "author_id": 13944524, "author_profile": "https://Stackoverflow.com/users/13944524", "pm_score": 3, "selected": true, "text": "enumerate()" }, { "answer_id": 74276309, "author": "user99999", "author_id": 20070120, "author_profile": "https://Stackoverflow.com/users/20070120", "pm_score": 0, "selected": false, "text": "count" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74275960", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20197262/" ]
74,275,971
<p>!!! &gt;&gt; I'm a total newbie, I opened matplotlib like 3 hours ago and self-taught myself here. If you introduce any new commands/lines, please let me know what they're called so I can look up tutorials, thanks!</p> <p>Attempting to: Make a 3d plot of tracks/lines</p> <p>Problem: I have a .csv files with <strong>29 sets of x y z data points with 49 rows (time points). i.e. I'm tracking 29 particles in 3d space over 49 timepoints</strong>. The column headers ATM are &quot;x1, y1, z1, x2, y2, z2 ...&quot; etc. The 3D part is not an issue, but I'm kind of not interested in writing out 70+ lines of the same thing.</p> <p>I.e. I'd rather not write:</p> <pre><code>x = points['x'].values x2 = points['x2'].values x3 = points['x3'].values ... x29 = points['x29'].values </code></pre> <p>etc.</p> <p>Is there a way to say &quot;plot x1,y1,z1 to x29,y29,z29 from that .csv&quot; instead?</p> <pre><code>from mpl_toolkits.mplot3d import Axes3D import sys import matplotlib.pyplot as plt import pandas import numpy as np points = pandas.read_csv('D:Documents\PYTHON_FILES/test3d.csv') fig = plt.figure() ax = fig.add_subplot(111, projection='3d') x = points['x'].values y = points['y'].values z = points['z'].values x2 = points['x2'].values y2 = points['y2'].values z2 = points['z2'].values ax.plot(x, y, z, c='red', marker='o', linewidth=1.0, markersize=2) ax.plot(x2, y2, z2, c='blue', marker='o', linewidth=1.0, markersize=2) plt.show() </code></pre> <p>Thanks in advance!</p>
[ { "answer_id": 74276010, "author": "S.B", "author_id": 13944524, "author_profile": "https://Stackoverflow.com/users/13944524", "pm_score": 3, "selected": true, "text": "enumerate()" }, { "answer_id": 74276309, "author": "user99999", "author_id": 20070120, "author_profile": "https://Stackoverflow.com/users/20070120", "pm_score": 0, "selected": false, "text": "count" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74275971", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20387853/" ]
74,276,037
<p>How I can write this code in kotlin dsl?</p> <pre><code>dependencies{ api'org.slf4j:slf4j-api:1.7.25' } </code></pre> <p>I can't find for what I need to change groovy &quot;api&quot; (in dependencies block) in kotlin dsl. For example I want to use org.slf4j, I want to declare it like API, but I checked migration docs and found analogies only for implementation, compile, etc. I use intellij idea.</p> <p>I tried this:</p> <pre><code>plugins { id(&quot;java&quot;) } group = &quot;com.myapp&quot; version = &quot;1.0-SNAPSHOT&quot; repositories { mavenCentral() } dependencies { api(&quot;org.slf4j:slf4j-api:1.7.36&quot;) } </code></pre> <p>But is says: &quot;Unresolved reference: api&quot;</p> <p>I checked this: <a href="https://docs.gradle.org/current/userguide/migrating_from_groovy_to_kotlin_dsl.html" rel="nofollow noreferrer">https://docs.gradle.org/current/userguide/migrating_from_groovy_to_kotlin_dsl.html</a> <a href="https://docs.gradle.org/current/userguide/kotlin_dsl.html" rel="nofollow noreferrer">https://docs.gradle.org/current/userguide/kotlin_dsl.html</a></p>
[ { "answer_id": 74276010, "author": "S.B", "author_id": 13944524, "author_profile": "https://Stackoverflow.com/users/13944524", "pm_score": 3, "selected": true, "text": "enumerate()" }, { "answer_id": 74276309, "author": "user99999", "author_id": 20070120, "author_profile": "https://Stackoverflow.com/users/20070120", "pm_score": 0, "selected": false, "text": "count" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276037", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19511574/" ]
74,276,065
<p><strong>Context</strong></p> <ul> <li>I am not a developer</li> <li>I want to use Vanilla JS (no JQuery)</li> </ul> <p>I'm using the following code and it is giving me the desired outcome, however I'd like to improve the code and make it more efficient if possible.</p> <p><strong>Working code</strong></p> <pre><code>var score_A1 = localStorage.getItem(&quot;score_A1&quot;); var score_A2 = localStorage.getItem(&quot;score_A2&quot;); var score_A3 = localStorage.getItem(&quot;score_A3&quot;); var score_A4 = localStorage.getItem(&quot;score_A4&quot;); var score_A5 = localStorage.getItem(&quot;score_A5&quot;); a =+ score_A1; b =+ score_A2; c =+ score_A3; d =+ score_A4; e =+ score_A5; var scoreTotal_A = a + b + c + d + e; </code></pre> <p>I am then using innerHTML and calling <code>${scoreTotal_A}</code> to display the total.</p> <p><strong>Questions</strong></p> <ul> <li>Is there a 'better', more efficient way to code this?</li> <li>Is there a way to code it to GET and ADD together any localStorage item that begins with <code>score_A</code>?</li> </ul> <p>Thanks in advance for any help.</p>
[ { "answer_id": 74276151, "author": "Pointy", "author_id": 182668, "author_profile": "https://Stackoverflow.com/users/182668", "pm_score": 2, "selected": true, "text": ".key()" }, { "answer_id": 74276196, "author": "Zoraiz", "author_id": 14628358, "author_profile": "https://Stackoverflow.com/users/14628358", "pm_score": 0, "selected": false, "text": "localStorage.setItem()" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276065", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13730126/" ]
74,276,077
<p>I have a problem with <strong>localtime()</strong>. The scope is to transform my own <strong>struct tbDate</strong> to <strong>struct tm</strong>. Since the simple assignment doesn't fill the follow arguments:</p> <pre><code>tmp-&gt;tm_wday; tmp-&gt;tm_yday; tmp-&gt;tm_year; </code></pre> <p>that I need, since I have my own implementation of <strong>strftime()</strong> So, I fill a <strong>struct tm</strong> with my own data, I call <strong>mktime()</strong> to get the secunds, than I call <strong>localtime()</strong> to get a <strong>struct tm</strong> filled, and than I fill my <strong>struct tm</strong>.</p> <pre><code>int tbDate_to_tm(tbDate *date,struct tm *syst) { time_t t; struct tm *tmp; syst-&gt;tm_hour=0; syst-&gt;tm_min=0; syst-&gt;tm_sec=0; syst-&gt;tm_year=date-&gt;year-1900; syst-&gt;tm_mon=date-&gt;month-1; syst-&gt;tm_mday=date-&gt;day; t=mktime(syst); tmp=localtime(&amp;t); syst-&gt;tm_hour=tmp-&gt;tm_hour; syst-&gt;tm_isdst=tmp-&gt;tm_isdst; syst-&gt;tm_mday=tmp-&gt;tm_mday; syst-&gt;tm_min=tmp-&gt;tm_min; syst-&gt;tm_mon=tmp-&gt;tm_mon; syst-&gt;tm_sec=tmp-&gt;tm_sec; syst-&gt;tm_wday=tmp-&gt;tm_wday; syst-&gt;tm_yday=tmp-&gt;tm_yday; syst-&gt;tm_year=tmp-&gt;tm_year; return 1; } </code></pre> <p>The problem is that returns the date of the day before, rather than the correct date. The system is Windows, and the compiler mingw. Someone can notice something wrong? Example:</p> <pre><code>date-&gt;year=2022; date-&gt;month=11; date-&gt;day=1; //these settings returns a time_t t t=1667253600; //after I call localtime() tmp-&gt;tm_hour=23; tmp-&gt;tm_isdst=0; tmp-&gt;tm_mday=31; tmp-&gt;tm_min=0; tmp-&gt;tm_mon=9; tmp-&gt;tm_sec=0; tmp-&gt;tm_wday=1; tmp-&gt;tm_yday=303; tmp-&gt;tm_year=122; </code></pre> <p>rather than:</p> <pre><code>tmp-&gt;tm_hour=0; tmp-&gt;tm_isdst=0; tmp-&gt;tm_mday=1; tmp-&gt;tm_min=0; tmp-&gt;tm_mon=10; tmp-&gt;tm_sec=0; tmp-&gt;tm_wday=2; tmp-&gt;tm_yday=304; tmp-&gt;tm_year=122; </code></pre>
[ { "answer_id": 74276600, "author": "San Pei", "author_id": 19660507, "author_profile": "https://Stackoverflow.com/users/19660507", "pm_score": 0, "selected": false, "text": "int tbDate_to_tm(tbDate *date,struct tm *syst)\n{\n time_t t;\n\n struct tm *tmp;\n syst->tm_hour=0;\n syst->tm_min=0;\n syst->tm_sec=0;\n syst->tm_year=date->year-1900;\n syst->tm_mon=date->month-1;\n syst->tm_mday=date->day;\n syst->tm_isdst=-1; // added this\n\n t=mktime(syst);\n tmp=localtime(&t);\n \n syst->tm_hour=tmp->tm_hour;\n syst->tm_isdst=tmp->tm_isdst;\n syst->tm_mday=tmp->tm_mday;\n syst->tm_min=tmp->tm_min;\n syst->tm_mon=tmp->tm_mon;\n syst->tm_sec=tmp->tm_sec;\n syst->tm_wday=tmp->tm_wday;\n syst->tm_yday=tmp->tm_yday;\n syst->tm_year=tmp->tm_year;\n\n\n return 1;\n}\n" }, { "answer_id": 74276640, "author": "Weather Vane", "author_id": 4142924, "author_profile": "https://Stackoverflow.com/users/4142924", "pm_score": 2, "selected": true, "text": "*syst" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276077", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19660507/" ]
74,276,109
<p>How to make a label hide in the webpage but it must be readable for screen readers</p> <pre><code>&lt;label for=&quot;phone&quot; aria-describedby=&quot;input&quot;&gt; &lt;p id=&quot;input&quot;&gt; message &lt;/p&gt; &lt;/label&gt; </code></pre> <p>this one works for one field I am trying the same for the Separate fields .</p> <p>there is 3 fields for phone number local code , prefix last one is suffix which is in the same row but different Column , under these fields i have provided an example for the input so whenever the people uses screen reader it must read the example along with the field name .</p> <p><a href="https://i.stack.imgur.com/Rr5ED.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Rr5ED.jpg" alt="enter image description here" /></a> imagine this as my fields , the example as 123-456-7890</p> <p>any inputs would be appreciable !!</p>
[ { "answer_id": 74276600, "author": "San Pei", "author_id": 19660507, "author_profile": "https://Stackoverflow.com/users/19660507", "pm_score": 0, "selected": false, "text": "int tbDate_to_tm(tbDate *date,struct tm *syst)\n{\n time_t t;\n\n struct tm *tmp;\n syst->tm_hour=0;\n syst->tm_min=0;\n syst->tm_sec=0;\n syst->tm_year=date->year-1900;\n syst->tm_mon=date->month-1;\n syst->tm_mday=date->day;\n syst->tm_isdst=-1; // added this\n\n t=mktime(syst);\n tmp=localtime(&t);\n \n syst->tm_hour=tmp->tm_hour;\n syst->tm_isdst=tmp->tm_isdst;\n syst->tm_mday=tmp->tm_mday;\n syst->tm_min=tmp->tm_min;\n syst->tm_mon=tmp->tm_mon;\n syst->tm_sec=tmp->tm_sec;\n syst->tm_wday=tmp->tm_wday;\n syst->tm_yday=tmp->tm_yday;\n syst->tm_year=tmp->tm_year;\n\n\n return 1;\n}\n" }, { "answer_id": 74276640, "author": "Weather Vane", "author_id": 4142924, "author_profile": "https://Stackoverflow.com/users/4142924", "pm_score": 2, "selected": true, "text": "*syst" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18107944/" ]
74,276,138
<p>Method for calling API:</p> <pre><code> static FutureOr&lt;Iterable&lt;Appointment&gt;&gt; fetchAppointments(String title) async { // final url = Uri.parse('http://192.168.0.134:8080/AtdochubJ-3/appointment/'); final url = Uri.parse( 'http://13.233.206.251:8088/AtdochubJ-3/appointment/appointmentdetails'); final response = await http.get(url); if (response.statusCode == 200) { final List docs = json.decode(response.body) as List; return docs.map((json) =&gt; Appointment.fromJson(json)).where((doc) { final titleLower = doc.docTitle.toLowerCase(); final tokenLower = doc.partyName.toLowerCase(); final searchLower = title.toLowerCase(); return titleLower.contains(searchLower) || tokenLower.contains(searchLower); }).toList(); } else { throw Exception(); } } </code></pre> <p>The response of API: [{&quot;aptId&quot;:297,&quot;aptDate&quot;:&quot;2022-10-19&quot;,&quot;aptPlace&quot;:&quot;Kothrud&quot;,&quot;aptTime&quot;:&quot;11:31:00&quot;,&quot;city&quot;:&quot;pune&quot;,&quot;comments&quot;:&quot;No&quot;,&quot;totalFees&quot;:50000,&quot;feesCollected&quot;:40000,&quot;partyName&quot;:&quot;Swara Joshi&quot;,&quot;paymentMode&quot;:&quot;Cash&quot;,&quot;staffId&quot;:150,&quot;partyType&quot;:&quot;Owner&quot;,&quot;aptStatus&quot;:&quot;Open&quot;,&quot;contactNo&quot;:&quot;7845125487&quot;,&quot;docTitle&quot;:&quot;B/204, Spenta Palazzo&quot;,&quot;tokenNo&quot;:22092699900203,&quot;userName&quot;:&quot;Satish&quot;,&quot;docId&quot;:267}]</p> <p>Model Class:</p> <pre><code> import 'dart:core'; import 'dart:convert'; Appointment documnetModelJson(String str) =&gt; Appointment.fromJson(json.decode(str)); String documentModelToJson(Appointment data) =&gt; json.encode(data.toJson()); class Appointment { int aptId; String aptDate; String aptTime; String aptPlace; String city; String? comments; int? docId; int? feesCollected; int totalFees; String partyName; String? paymentMode; int staffId; String partyType; String docTitle; int tokenNo; String userName; String aptStatus; String contactNo; int get getaptId =&gt; this.aptId; set setaptId(aptId) =&gt; this.aptId = aptId; int? get getdocId =&gt; this.docId; set setdocId(final docId) =&gt; this.docId = docId; get getTokenNo =&gt; tokenNo; set setTokenNo(tokenNo) =&gt; this.tokenNo = tokenNo; get getDocTitle =&gt; docTitle; set setDocTitle(docTitle) =&gt; this.docTitle = docTitle; get getstaffId =&gt; this.staffId; set setstaffId(staffId) =&gt; this.staffId = staffId; get getPartyName =&gt; this.partyName; set setPartyName(partyName) =&gt; this.partyName = partyName; get getPartyType =&gt; this.partyType; set setPartyType(partyType) =&gt; this.partyType = partyType; get getAptDate =&gt; this.aptDate; set setAptDate(aptDate) =&gt; this.aptDate = aptDate; get getAptTime =&gt; this.aptTime; set setAptTime(aptTime) =&gt; this.aptTime = aptTime; get getAptPlace =&gt; this.aptPlace; set setAptPlace(aptPlace) =&gt; this.aptPlace = aptPlace; get getCity =&gt; this.city; set setCity(city) =&gt; this.city = city; get getFeesCollected =&gt; this.feesCollected; set setFeesCollected(feesCollected) =&gt; this.feesCollected = feesCollected; get getTotalFees =&gt; this.totalFees; set setTotalFees(totalFees) =&gt; this.totalFees = totalFees; get getPaymentMode =&gt; this.paymentMode; set setPaymentMode(paymentMode) =&gt; this.paymentMode = paymentMode; get getComments =&gt; this.comments; set setComments(comments) =&gt; this.comments = comments; get getuserName =&gt; this.userName; set setuserName(userName) =&gt; this.userName = userName; get getAptStatus =&gt; this.aptStatus; set setAptStatus(aptStatus) =&gt; this.aptStatus = aptStatus; get getContactNo =&gt; this.contactNo; set setContactNo(contactNo) =&gt; this.contactNo = contactNo; Appointment( {required this.aptId, required this.docId, required this.tokenNo, required this.docTitle, required this.staffId, required this.partyName, required this.partyType, required this.aptDate, required this.aptTime, required this.aptPlace, required this.city, required this.feesCollected, required this.totalFees, required this.paymentMode, required this.userName, required this.aptStatus, required this.contactNo, required this.comments}); factory Appointment.fromJson(Map&lt;String, dynamic&gt; json) { return Appointment( aptId: json['aptId'], docId: json['docId'] ?? '', tokenNo: json['tokenNo'], docTitle: json['docTitle'], staffId: json['staffId'], partyName: json['partyName'], partyType: json['partyType'], aptDate: json['aptDate'], aptTime: json['aptTime'], aptPlace: json['aptPlace'], city: json['city'], feesCollected: json['feesCollected'] ?? &quot;&quot;, totalFees: json['totalFees'], paymentMode: json['paymentMode'] ?? &quot;&quot;, userName: json['userName'], aptStatus: json['aptStatus'], contactNo: json['contactNo'], comments: json['comments'] ?? ''); } Map&lt;String, dynamic&gt; toJson() =&gt; { 'aptId': aptId, 'docId': docId, 'tokenNo': tokenNo, 'docTitle': docTitle, 'staffId': staffId, 'partyName': partyName, 'type': partyType, 'aptDate': aptDate, 'aptTime': aptTime.toString(), 'aptPlace': aptPlace, 'city': city, 'feesCollected': feesCollected, 'totalFees': totalFees, 'paymentMode': paymentMode, 'userName': userName, 'aptStatus': aptStatus, 'contactNo': contactNo, 'comments': comments, }; } </code></pre> <p>The UI:</p> <pre><code>import 'package:AtDocHUB/View/AppointmentPageFE.dart'; import './AppointmentsDetailsEditPage.dart'; import 'dart:core'; import 'package:AtDocHUB/Controller/AppointmentController.dart'; import 'package:AtDocHUB/Model/Appointment.dart'; import 'package:get/instance_manager.dart'; import 'package:flutter/material.dart'; class AppointmentDetails extends StatefulWidget { final int aptId; //final int docId; //final int staff_Id; AppointmentDetails( this.aptId, // this.docId, // this.staff_Id, ); @override _AppointmentDetailsState createState() =&gt; _AppointmentDetailsState( this.aptId, // this.docId, //this.staff_Id, ); } class _AppointmentDetailsState extends State&lt;AppointmentDetails&gt; { AppointmentController appointmentController = Get.put(AppointmentController()); late Future&lt;Appointment&gt; futureAppointments; final int aptId; //final int docId; // final int staff_Id; _AppointmentDetailsState( this.aptId, // this.docId, // this.staff_Id, ); @override void initState() { super.initState(); // futureDocuments = documentController // .fetchDocumentsByTitle('Skyone Building, Flat no 101'); // futureDocuments = documentController.fetchDocumentsByID(docId); futureAppointments = AppointmentController.fetchAppointmentsById(this.aptId) as Future&lt;Appointment&gt;; } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Color.fromARGB(255, 3, 87, 156), title: Text('Appointment Details'), leading: IconButton( icon: BackButtonIcon(), onPressed: () =&gt; Navigator.of(context).push(MaterialPageRoute( builder: (BuildContext context) =&gt; AppointmentPageFE()))), ), body: Center( child: FutureBuilder&lt;Appointment&gt;( future: futureAppointments, builder: (context, snapshot) { if (snapshot.hasData) { return ListView(children: [ SafeArea( child: SingleChildScrollView( child: Container( padding: EdgeInsets.all(15), height: 750, // child: Card( // child: SelectionArea( child: Column( mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( &quot;Document Title : &quot; + snapshot.data!.partyName, style: const TextStyle(fontSize: 15.0)), Text(&quot;Token No : &quot; + snapshot.data!.partyName, style: const TextStyle(fontSize: 15.0)), Text(&quot;Party Name : &quot; + snapshot.data!.partyName, style: const TextStyle(fontSize: 15.0)), // Text( // &quot;Appointment Executive : &quot; + // snapshot.data!.userName, // style: const TextStyle(fontSize: 15.0)), Text(&quot;Contact No : &quot; + snapshot.data!.contactNo, style: const TextStyle(fontSize: 15.0)), Text(&quot;Party Type : &quot; + snapshot.data!.partyType, style: const TextStyle(fontSize: 15.0)), Text( &quot;Appointment Place : &quot; + snapshot.data!.aptPlace, style: const TextStyle(fontSize: 15.0)), Text(&quot;Appointment City : &quot; + snapshot.data!.city, style: const TextStyle(fontSize: 15.0)), Text( &quot;Appointment Date : &quot; + snapshot.data!.aptDate, style: const TextStyle(fontSize: 15.0)), Text( &quot;Appointment Time : &quot; + snapshot.data!.aptTime, style: const TextStyle(fontSize: 15.0)), Text( &quot;Appointment Status : &quot; + snapshot.data!.aptStatus, style: const TextStyle(fontSize: 15.0)), Text(&quot;Fees : &quot; + snapshot.data!.partyType, style: const TextStyle(fontSize: 15.0)), Text( &quot;Fees Collected : &quot; + snapshot.data!.partyType, style: const TextStyle(fontSize: 15.0)), Text(&quot;Payment Mode : &quot; + snapshot.data!.partyName, style: const TextStyle(fontSize: 15.0)), // Text(&quot;Comments : &quot; + snapshot.data!.comments!, // style: const TextStyle(fontSize: 15.0)), // ])), // ), // child: Row( // children: [ // SizedBox( // width: 100, // ), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Container( alignment: Alignment.center, height: 35, width: 200, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), color: Color.fromARGB(255, 3, 89, 168), ), child: TextButton( // style: // TextButton.styleFrom(fixedSize: Size.fromHeight(300)), child: const Text( 'Edit ', style: TextStyle( fontSize: 17.0, fontWeight: FontWeight.bold, color: Colors.white, backgroundColor: Color.fromARGB(255, 3, 89, 168), ), ), onPressed: () { Navigator.of(context) .pushAndRemoveUntil( MaterialPageRoute( builder: (BuildContext context) =&gt; AppointmentDetailsEditPage( this.aptId, // this.docId, // this.staff_Id, )), (Route&lt;dynamic&gt; route) =&gt; false); }, ), ), ], ), ]), ), ), // ), padding: const EdgeInsets.all(10), ), ), ]); } else if (snapshot.hasError) { return Text('${snapshot.error}'); } // By default, show a loading spinner. return const CircularProgressIndicator(); }, ), ), ); } } </code></pre>
[ { "answer_id": 74276600, "author": "San Pei", "author_id": 19660507, "author_profile": "https://Stackoverflow.com/users/19660507", "pm_score": 0, "selected": false, "text": "int tbDate_to_tm(tbDate *date,struct tm *syst)\n{\n time_t t;\n\n struct tm *tmp;\n syst->tm_hour=0;\n syst->tm_min=0;\n syst->tm_sec=0;\n syst->tm_year=date->year-1900;\n syst->tm_mon=date->month-1;\n syst->tm_mday=date->day;\n syst->tm_isdst=-1; // added this\n\n t=mktime(syst);\n tmp=localtime(&t);\n \n syst->tm_hour=tmp->tm_hour;\n syst->tm_isdst=tmp->tm_isdst;\n syst->tm_mday=tmp->tm_mday;\n syst->tm_min=tmp->tm_min;\n syst->tm_mon=tmp->tm_mon;\n syst->tm_sec=tmp->tm_sec;\n syst->tm_wday=tmp->tm_wday;\n syst->tm_yday=tmp->tm_yday;\n syst->tm_year=tmp->tm_year;\n\n\n return 1;\n}\n" }, { "answer_id": 74276640, "author": "Weather Vane", "author_id": 4142924, "author_profile": "https://Stackoverflow.com/users/4142924", "pm_score": 2, "selected": true, "text": "*syst" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276138", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19363047/" ]
74,276,185
<p>I have a database having columns id and profile fields where profile fields is of the type jsonb</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>id</th> <th>profile_fields</th> </tr> </thead> <tbody> <tr> <td>101</td> <td>{&quot;1&quot;:&quot;Chess&quot; , &quot;2&quot;:&quot;08-02-2001&quot;}</td> </tr> <tr> <td>102</td> <td>{&quot;1&quot;:&quot;Hockey&quot; , &quot;2&quot;:&quot;1996-06-09&quot;}</td> </tr> </tbody> </table> </div> <p>In profile fields the key 2 stands for Date of Birth .</p> <p>Unfortunately many fields have values in format yyyy/mm/dd .</p> <p>I would like to change all the Date of birth values in dd/mm/yyyy format.</p> <p>The Expected results is like this</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>header 1</th> <th>header 2</th> </tr> </thead> <tbody> <tr> <td>101</td> <td>{&quot;1&quot;:&quot;Chess&quot; , &quot;2&quot;:&quot;08-02-2001&quot;}</td> </tr> <tr> <td>102</td> <td>{&quot;1&quot;:&quot;Hockey&quot; , &quot;2&quot;:&quot;09-06-1996&quot;}</td> </tr> </tbody> </table> </div> <p>I tried the update the update statement but i am stuck how can i apply in multiple values ? What will go inside where statement. And how to access the key 2 profile_fields-&gt;&quot;2&quot; is not in Update statement.</p> <p>Thank you.</p>
[ { "answer_id": 74276600, "author": "San Pei", "author_id": 19660507, "author_profile": "https://Stackoverflow.com/users/19660507", "pm_score": 0, "selected": false, "text": "int tbDate_to_tm(tbDate *date,struct tm *syst)\n{\n time_t t;\n\n struct tm *tmp;\n syst->tm_hour=0;\n syst->tm_min=0;\n syst->tm_sec=0;\n syst->tm_year=date->year-1900;\n syst->tm_mon=date->month-1;\n syst->tm_mday=date->day;\n syst->tm_isdst=-1; // added this\n\n t=mktime(syst);\n tmp=localtime(&t);\n \n syst->tm_hour=tmp->tm_hour;\n syst->tm_isdst=tmp->tm_isdst;\n syst->tm_mday=tmp->tm_mday;\n syst->tm_min=tmp->tm_min;\n syst->tm_mon=tmp->tm_mon;\n syst->tm_sec=tmp->tm_sec;\n syst->tm_wday=tmp->tm_wday;\n syst->tm_yday=tmp->tm_yday;\n syst->tm_year=tmp->tm_year;\n\n\n return 1;\n}\n" }, { "answer_id": 74276640, "author": "Weather Vane", "author_id": 4142924, "author_profile": "https://Stackoverflow.com/users/4142924", "pm_score": 2, "selected": true, "text": "*syst" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276185", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20240784/" ]
74,276,204
<p>I'm taking a class through zybooks, and the whitespace is a bit glitchy through here. I'm not sure what is causing this extra space, so any help would be appreciated.</p> <p>The instructions for this:</p> <p>Primary U.S. interstate highways are numbered 1-99. Odd numbers (like the 5 or 95) go north/south, and evens (like the 10 or 90) go east/west. Auxiliary highways are numbered 100-999, and service the primary highway indicated by the rightmost two digits. Thus, I-405 services I-5, and I-290 services I-90. Note: 200 is not a valid auxiliary highway because 00 is not a valid primary highway number.</p> <p>Given a highway number, indicate whether it is a primary or auxiliary highway. If auxiliary, indicate what primary highway it serves. Also indicate if the (primary) highway runs north/south or east/west.</p> <pre><code>highway_number = int(input()) if highway_number == 0: print(highway_number, 'is not a valid interstate highway number.') if highway_number in range(1,99+1): if highway_number % 2 == 0: print('I-',highway_number,&quot;is primary, going east/west.&quot;) else: print('I-',highway_number,&quot;is primary, going north/south.&quot;) else: served = highway_number % 100 if highway_number &gt;= 1000: print(highway_number,'is not a valid interstate highway number.') if highway_number in range(99,999+1): if highway_number == 200: print(highway_number,'is not a valid interstate highway number.') elif highway_number % 2 == 0: print('I-',highway_number,'is auxiliary, serving I-','%.f,'%served,'going east/west.') else: print('I-',highway_number,'is auxiliary, serving I-','%.f,'%served, 'going north/south.') </code></pre> <p><a href="https://i.stack.imgur.com/Xe4GT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Xe4GT.png" alt="Picture for reference of output" /></a></p> <p>Everything is working correctly, I just keep getting an extra space after the '-' in 'I-'.</p>
[ { "answer_id": 74276243, "author": "The Myth", "author_id": 15042008, "author_profile": "https://Stackoverflow.com/users/15042008", "pm_score": 1, "selected": false, "text": "print()" }, { "answer_id": 74276247, "author": "Hưng Trần", "author_id": 5980003, "author_profile": "https://Stackoverflow.com/users/5980003", "pm_score": 1, "selected": false, "text": "print('I-',highway_number,\"is primary, going east/west.\", sep=\"\")\n" }, { "answer_id": 74276289, "author": "Illusioner_", "author_id": 19467139, "author_profile": "https://Stackoverflow.com/users/19467139", "pm_score": 1, "selected": false, "text": "print('I-',highway_number,\"is primary, going east/west.\")\n" }, { "answer_id": 74276294, "author": "Kwallcoder", "author_id": 19852730, "author_profile": "https://Stackoverflow.com/users/19852730", "pm_score": -1, "selected": false, "text": "print('I-'+ str(highway_number) + \" is primary, going east/west.\")" }, { "answer_id": 74276353, "author": "chrslg", "author_id": 20037042, "author_profile": "https://Stackoverflow.com/users/20037042", "pm_score": 3, "selected": false, "text": "print(1,2,3)\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276204", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20388065/" ]
74,276,209
<p>i am making a simple to do list, yet in that there is some error on remove button and its action, if i dont add any function regarding remove list, everything is working fine...</p> <p>here is my code:</p> <p><strong>ToDo.js</strong></p> <pre><code>import React, { useState } from 'react' import AddNew from './Addnew'; import ToDoList from './ToDoList'; function Todo() { const[toDoList, setToDoList] = useState([]); function addNew(addText, date){ // console.log(addText); // console.log(date); const obj = { text : addText, expiry : date, completed : false } const newToDo = [...toDoList, obj]; setToDoList(newToDo); // console.log(toDoList); } function handleCheck(index){ const newToDOs = [...toDoList]; if(toDoList[index].completed==false){ newToDOs[index].completed = true; } else { newToDOs[index].completed = false; } setToDoList(newToDOs); } function RemoveList(index){ console.log(index); const newTo = [...toDoList]; newTo.splice(index,1); setToDoList(newTo); } return ( &lt;&gt; &lt;h1&gt;To Do List&lt;/h1&gt; &lt;AddNew addNew={addNew}/&gt; &lt;ul className=&quot;list-group&quot;&gt; &lt;ToDoList list={toDoList} handleCheck={handleCheck} RemoveList={RemoveList} /&gt; &lt;/ul&gt; &lt;/&gt; ); } export default Todo; </code></pre> <p><strong>ToDoList.js</strong></p> <pre><code>import React from &quot;react&quot;; function ToDoList(props) { return ( &lt;&gt; {/* {props.list.length == 0 ? &lt;h3&gt;To Do List is Empty&lt;/h3&gt; : null} */} {props.list.map((element, index) =&gt; { return ( &lt;&gt; &lt;li className={ element.completed ? &quot;list-group-item yes-comp&quot; : &quot;list-group-item no-comp&quot; } &gt; &lt;span className=&quot;badge text-bg-info&quot;&gt;{index + 1}&lt;/span&gt; &amp;ensp; &lt;input type=&quot;checkbox&quot; defaultChecked={element.completed} onChange={() =&gt; { props.handleCheck(index); }} /&gt;{&quot; &quot;} &amp;ensp; {element.text} &lt;span className=&quot;badge text-bg-light&quot;&gt; {element.expiry.toString().slice(4, 15)} &lt;/span&gt; &lt;button className=&quot;btn btn-danger&quot; onChange={props.RemoveList(index)} &gt;Remove&lt;/button&gt; &lt;/li&gt; &lt;/&gt; ); })} &lt;/&gt; ); } export default ToDoList; </code></pre> <p><strong>AddNew.js</strong></p> <pre><code>import React, { useState } from &quot;react&quot;; import DatePicker from &quot;react-datepicker&quot;; import &quot;react-datepicker/dist/react-datepicker.css&quot;; function AddNew(props) { const [startDate, setStartDate] = useState(new Date()); const [input, setInput] = useState(&quot;&quot;); function submitData() { props.addNew(input, startDate); setInput(&quot;&quot;); } return ( &lt;&gt; &lt;div className=&quot;Container InputContain&quot;&gt; &lt;input className=&quot;form-control&quot; placeholder=&quot;Add New in To Do List&quot; value={input} onInput={(e) =&gt; setInput(e.target.value)} /&gt; &lt;div&gt; &lt;DatePicker className=&quot;AddDate&quot; selected={startDate} onChange={(date) =&gt; setStartDate(date)} /&gt; &lt;button className=&quot;btn btn-primary btn-cust&quot; onClick={submitData}&gt;Add&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;/&gt; ); } export default AddNew; </code></pre> <p>the warnings are:</p> <pre><code>react-dom.development.js:86 Warning: Cannot update a component (`Todo`) while rendering a different component (`ToDoList`). To locate the bad setState() call inside `ToDoList`, follow the stack trace as described in https://reactjs.org/link/setstate-in-render at ToDoList (http://localhost:3000/static/js/bundle.js:262:21) at ul at Todo (http://localhost:3000/static/js/bundle.js:374:82) at App react-jsx-dev-runtime.development.js:87 Warning: Each child in a list should have a unique &quot;key&quot; prop. Check the render method of `ToDoList`. See https://reactjs.org/link/warning-keys for more information. at ToDoList (http://localhost:3000/static/js/bundle.js:262:21) at ul at Todo (http://localhost:3000/static/js/bundle.js:374:82) at App </code></pre> <p>i tried to change my function name, change method on how to remove from list and everything that i could find on google, yet not working!</p>
[ { "answer_id": 74276319, "author": "damonholden", "author_id": 17670742, "author_profile": "https://Stackoverflow.com/users/17670742", "pm_score": 3, "selected": true, "text": "<button className=\"btn btn-danger\" onChange={props.RemoveList(index)} >Remove</button>\n" }, { "answer_id": 74276368, "author": "Apostolos", "author_id": 1121008, "author_profile": "https://Stackoverflow.com/users/1121008", "pm_score": 1, "selected": false, "text": "onChange" }, { "answer_id": 74276506, "author": "user20386762", "author_id": 20386762, "author_profile": "https://Stackoverflow.com/users/20386762", "pm_score": 1, "selected": false, "text": "onClick()" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276209", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20385327/" ]
74,276,226
<p>I'm trying to create an animation like below</p> <p><a href="https://i.stack.imgur.com/T4BF9.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/T4BF9.gif" alt="enter image description here" /></a></p> <p>Description of the animation.</p> <ol> <li>Red bar's height increases to 50px.</li> <li>While the red bar remains at its height, set by step 1, the yellow bar height increases to 100px.</li> <li>While the yellow bar remains at its height, set by step 2, the green bar height increases to 75px.</li> <li>While the green bar remains at its height, set by step 3, the next and final green bar height increases to 75px.</li> </ol> <p>The problem is I can't get the bar to stay at its height. So I have made another animation which is somewhat the same, but not 100%. It's below.</p> <p><a href="https://i.stack.imgur.com/cBC6L.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cBC6L.gif" alt="enter image description here" /></a></p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>.equilizer { height: 100px; width: 100px; transform: rotate(180deg); } .bar { width: 18px; } .bar-1 { animation: equalize4 1.5s 0s infinite; } .bar-2 { animation: equalize3 1.5s 0s infinite; } .bar-3 { animation: equalize2 1.5s 0s infinite; } .bar-4 { animation: equalize1 1.5s 0s infinite; } @keyframes equalize1 { 0% { height: 0%; } 100% { height: 25%; } } @keyframes equalize2 { 0% { height: 0%; } 100% { height: 50%; } } @keyframes equalize3 { 0% { height: 0%; } 100% { height: 37.5%; } } @keyframes equalize4 { 0% { height: 0%; } 100% { height: 37.5%; } }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;svg xmlns="http://www.w3.org/2000/svg" class="equilizer" viewBox="0 0 128 128"&gt; &lt;g&gt; &lt;title&gt;Audio Equilizer&lt;/title&gt; &lt;rect class="bar bar-1" transform="translate(0,0)" y="15" rx="10" fill="#416031"&gt;&lt;/rect&gt; &lt;rect class="bar bar-2" transform="translate(25,0)" y="15" rx="10" fill="#416031"&gt;&lt;/rect&gt; &lt;rect class="bar bar-3" transform="translate(50,0)" y="15" rx="10" fill="#e5a32b"&gt;&lt;/rect&gt; &lt;rect class="bar bar-4" transform="translate(75,0)" y="15" rx="10" fill="#ad1e23"&gt;&lt;/rect&gt; &lt;/g&gt; &lt;/svg&gt;</code></pre> </div> </div> </p> <p>How can I achieve the above (Image 1) result?</p>
[ { "answer_id": 74276336, "author": "Maverick Fabroa", "author_id": 11555297, "author_profile": "https://Stackoverflow.com/users/11555297", "pm_score": 0, "selected": false, "text": "animimation-delay" }, { "answer_id": 74276542, "author": "tao", "author_id": 1891677, "author_profile": "https://Stackoverflow.com/users/1891677", "pm_score": 2, "selected": true, "text": ".equilizer {\n height: 100px;\n width: 100px;\n transform: rotate(180deg);\n}\n\n.bar {\n width: 18px;\n}\n\n.bar-1 {\n animation: equalize4 3s infinite;\n}\n\n.bar-2 {\n animation: equalize3 3s infinite; \n}\n\n.bar-3 {\n animation: equalize2 3s infinite;\n}\n\n.bar-4 {\n animation: equalize1 3s infinite;\n}\n\n\n@keyframes equalize1 {\n 0% {\n height: 0%;\n }\n 20% {\n height: 25%;\n }\n 95% {\n height: 25%\n }\n 100% {\n height: 0\n }\n}\n\n@keyframes equalize2{\n 0% {\n height: 0;\n }\n 20% {\n height: 0\n }\n 40% {\n height: 50%;\n }\n 95% {\n height: 50%\n }\n 100% {\n height: 0\n }\n}\n\n@keyframes equalize3{\n 0% {\n height: 0%;\n }\n 40% {\n height: 0\n }\n 60% {\n height: 37.5%\n }\n 95% {\n height: 37.5%;\n }\n 100% {\n height: 0\n }\n}\n\n@keyframes equalize4{\n 0% {\n height: 0%;\n }\n 60% {\n height: 0;\n }\n 80% {\n height: 37.5%\n }\n 95% {\n height: 37.5%;\n }\n 100% {\n height: 0\n }\n}" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276226", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11142587/" ]
74,276,249
<pre><code>''' [[[[[[[[[[[[[[[[[[[[[[[[[[[[1]]]]]]]]]]]]]]]]]]]]]]]]]]]] find 1 ''' key = 1 x = [[[[[[[[[[[[[[[[[[[[[[[[[[[[key]]]]]]]]]]]]]]]]]]]]]]]]]]]] #len(x) -&gt; 1 </code></pre> <p>Actually my question is simple, but i couldn't solve this problem... What should i use to solve it, i mean should i use recrusive functions or for loop ???</p> <pre><code>for i in range(len(x)): for j in range(len(x)): for k in range(len(x)): for _ in range(len(x)): for ... </code></pre>
[ { "answer_id": 74276341, "author": "Jab", "author_id": 225020, "author_profile": "https://Stackoverflow.com/users/225020", "pm_score": 0, "selected": false, "text": "x = [[[[[[[[[[[[[[[[[[[[[[[[[[[[1]]]]]]]]]]]]]]]]]]]]]]]]]]]]\n\ndef find_num(l):\n if isinstance(inner := l[0], list):\n return find_num(inner)\n return inner\n\nprint(find_num(x))\n" }, { "answer_id": 74276366, "author": "S.B", "author_id": 13944524, "author_profile": "https://Stackoverflow.com/users/13944524", "pm_score": 2, "selected": false, "text": "def extract_list(l: list):\n while True:\n l = l.pop()\n if not isinstance(l, list):\n return l\n\n\nx = [[[[[[[[[[[[[[[[[[[[[[[[[[[[1]]]]]]]]]]]]]]]]]]]]]]]]]]]]\nprint(extract_list(x)) # 1\n" }, { "answer_id": 74276394, "author": "Đorđe Radujković", "author_id": 20065169, "author_profile": "https://Stackoverflow.com/users/20065169", "pm_score": 1, "selected": false, "text": "key = 1\nx = [[[[[[[[[[[[[[[[[[[[[[[[[[[[key]]]]]]]]]]]]]]]]]]]]]]]]]]]]\n\ndef find_key(array):\n if type(array) is list:\n return find_key(array[0])\n return array\n\nprint(find_key(x))\n" }, { "answer_id": 74276420, "author": "Jox", "author_id": 20388213, "author_profile": "https://Stackoverflow.com/users/20388213", "pm_score": 3, "selected": true, "text": "more_itertools" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276249", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16406821/" ]
74,276,252
<p>I have a pandas dataframe with the following column:</p> <pre><code>import pandas as pd df = pd.DataFrame(['10/30/2022 7:00:00 AM +01:00', '10/31/2022 12:00:00 AM +01:00', '10/30/2022 3:00:00 PM +01:00', '10/30/2022 9:00:00 PM +01:00', '10/30/2022 5:00:00 PM +01:00', '10/30/2022 10:00:00 PM +01:00', '10/30/2022 3:00:00 AM +01:00', '10/30/2022 2:00:00 AM +02:00', '10/30/2022 10:00:00 AM +01:00', '10/30/2022 4:00:00 PM +01:00', '10/30/2022 1:00:00 AM +02:00'], columns = ['Date']) </code></pre> <p>I want to convert the date values so it looks like the following:</p> <blockquote> <p>2022-10-30T00:00:00+02:00</p> </blockquote> <p>I tried the following; <code>df['Date'] = pd.to_datetime(df['Date']).dt.strftime('%Y-%m-%dT%H:%M:%S')</code></p> <p>The code raises an error whenever the <code>.dt</code> is called:</p> <blockquote> <p>AttributeError: Can only use .dt accessor with datetimelike values</p> </blockquote> <p>Apparently the code <code>pd.to_datetime()</code> does not work.</p> <p>Anyone knows how to fix this?</p>
[ { "answer_id": 74276341, "author": "Jab", "author_id": 225020, "author_profile": "https://Stackoverflow.com/users/225020", "pm_score": 0, "selected": false, "text": "x = [[[[[[[[[[[[[[[[[[[[[[[[[[[[1]]]]]]]]]]]]]]]]]]]]]]]]]]]]\n\ndef find_num(l):\n if isinstance(inner := l[0], list):\n return find_num(inner)\n return inner\n\nprint(find_num(x))\n" }, { "answer_id": 74276366, "author": "S.B", "author_id": 13944524, "author_profile": "https://Stackoverflow.com/users/13944524", "pm_score": 2, "selected": false, "text": "def extract_list(l: list):\n while True:\n l = l.pop()\n if not isinstance(l, list):\n return l\n\n\nx = [[[[[[[[[[[[[[[[[[[[[[[[[[[[1]]]]]]]]]]]]]]]]]]]]]]]]]]]]\nprint(extract_list(x)) # 1\n" }, { "answer_id": 74276394, "author": "Đorđe Radujković", "author_id": 20065169, "author_profile": "https://Stackoverflow.com/users/20065169", "pm_score": 1, "selected": false, "text": "key = 1\nx = [[[[[[[[[[[[[[[[[[[[[[[[[[[[key]]]]]]]]]]]]]]]]]]]]]]]]]]]]\n\ndef find_key(array):\n if type(array) is list:\n return find_key(array[0])\n return array\n\nprint(find_key(x))\n" }, { "answer_id": 74276420, "author": "Jox", "author_id": 20388213, "author_profile": "https://Stackoverflow.com/users/20388213", "pm_score": 3, "selected": true, "text": "more_itertools" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276252", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13854431/" ]
74,276,257
<p>Here is my HTML, CSS, JS</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>const Col = document.querySelectorAll('.col') function onCol() { Col.forEach(function(el, idx) { el.style.transition = '0s'; el.style.height = '0%'; el.style.transition = '0.9s'; el.style.height = '100%'; }); } onCol()</code></pre> <pre class="snippet-code-css lang-css prettyprint-override"><code>.work { display: flex; height: 140px } .col { background: red; width: 20px; height: 100%; margin-left: 5px; max-height: 0 }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="work"&gt; &lt;div class="col"&gt;&lt;/div&gt; &lt;div class="col"&gt;&lt;/div&gt; &lt;div class="col"&gt;&lt;/div&gt; &lt;div class="col"&gt;&lt;/div&gt; &lt;div class="col"&gt;&lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <p>I think that columns should become bigger <strong>SMOOTHLY WITH TRANSITION 0.9 !!!</strong></p> <p>but they do not.</p> <p>If I type the word with <code>el.style.height = '100%';</code> into setTimeOut, it will work.</p> <p>but I don't want to make this in callback queue. I just want to solve this in the call stack.</p> <p>and I want to know why doesn't this work now.</p> <p>i changed this with for loop. but not works</p>
[ { "answer_id": 74277157, "author": "Thirunahari ManindraTeja", "author_id": 6208440, "author_profile": "https://Stackoverflow.com/users/6208440", "pm_score": 1, "selected": false, "text": ".work {display: flex; height: 140px}\n.col {\n background: red;\n width: 20px;\n margin-left: 5px;\n height: 0;\n }\n" }, { "answer_id": 74278380, "author": "Heretic Monkey", "author_id": 215552, "author_profile": "https://Stackoverflow.com/users/215552", "pm_score": 2, "selected": false, "text": "setInterval" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276257", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20388111/" ]
74,276,271
<p>I'm creating a Spring JPA project with the following structure:</p> <pre><code>public class Pipeline { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private long id; private String name; private SourceConfig sourceConfig; private SinkConfig sinkConfig; ... ... } public abstract class SourceConfig { private long id; private String name; } public abstract class SinkConfig { private long id; private String name; } public KafkaSourceConfig extends SourceConfig { private String topic; private String messageSchema; } public MysqlSourceConfig extends SourceConfig { private String databaseName; private String tableName; } </code></pre> <p>Now when the client passes the following JSON, how would the program know which SourceConfig subclass to add to the Pipeline object?</p> <pre><code>{ &quot;name&quot;: &quot;mysql_to_bq_1&quot;, &quot;sourceConfig&quot;: { &quot;source&quot;: &quot;MYSQL&quot;, }, &quot;sinkConfig&quot;: { }, &quot;createdBy&quot;: &quot;paul&quot; } </code></pre>
[ { "answer_id": 74277157, "author": "Thirunahari ManindraTeja", "author_id": 6208440, "author_profile": "https://Stackoverflow.com/users/6208440", "pm_score": 1, "selected": false, "text": ".work {display: flex; height: 140px}\n.col {\n background: red;\n width: 20px;\n margin-left: 5px;\n height: 0;\n }\n" }, { "answer_id": 74278380, "author": "Heretic Monkey", "author_id": 215552, "author_profile": "https://Stackoverflow.com/users/215552", "pm_score": 2, "selected": false, "text": "setInterval" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276271", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6766329/" ]
74,276,329
<p><strong>My line of code that gives errors and builds:</strong> <code> var app = builder.Build();</code></p> <p><strong>My ApplicationServiceRegister class:</strong></p> <pre><code> public static IServiceCollection AddApplicationServices(this IServiceCollection services) { services.AddAutoMapper(Assembly.GetExecutingAssembly()); services.AddMediatR(Assembly.GetExecutingAssembly()); services.AddValidatorsFromAssembly(Assembly.GetExecutingAssembly()); services.AddTransient(typeof(IPipelineBehavior&lt;,&gt;), typeof(AuthorizationBehavior&lt;,&gt;)); services.AddTransient(typeof(IPipelineBehavior&lt;,&gt;), typeof(CachingBehavior&lt;,&gt;)); services.AddTransient(typeof(IPipelineBehavior&lt;,&gt;), typeof(CacheRemovingBehavior&lt;,&gt;)); services.AddTransient(typeof(IPipelineBehavior&lt;,&gt;), typeof(LoggingBehavior&lt;,&gt;)); services.AddTransient(typeof(IPipelineBehavior&lt;,&gt;), typeof(RequestValidationBehavior&lt;,&gt;)); services.AddScoped&lt;IAuthService, AuthManager&gt;(); services.AddScoped&lt;IUserService, UserManager&gt;(); services.AddSingleton&lt;LoggerServiceBase, FileLogger&gt;(); return services; } </code></pre> <p><strong>Error Output:</strong></p> <p>System.AggregateException: 'Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: MediatR.IRequestHandler<code>2[Application.Feature.Auths.Commands.Register.RegisterCommand,Application.Feature.Auths.Dtos.RegisteredDto] Lifetime: Transient ImplementationType: Application.Feature.Auths.Commands.Register.RegisterCommand+RegisterCommandHandler': Unable to resolve service for type 'Core.Security.JWT.TokenOptions' while attempting to activate 'Application.Service.AuthService.AuthManager'.) (Error while validating the service descriptor 'ServiceType: MediatR.IRequestHandler</code>2</p> <p>I dwelt on the possibility of a bug with Dependency Injection, but I didn't see a problem.</p>
[ { "answer_id": 74276480, "author": "rotgers", "author_id": 2223566, "author_profile": "https://Stackoverflow.com/users/2223566", "pm_score": 2, "selected": true, "text": "AuthManager" }, { "answer_id": 74276578, "author": "Muhammad Usama", "author_id": 14404513, "author_profile": "https://Stackoverflow.com/users/14404513", "pm_score": 0, "selected": false, "text": "AuthManager" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18198387/" ]
74,276,348
<p>We are using Azure Ad authorization in .NET 6.0. Got critical vulnerability where algorithm type cannot be null.</p> <p>Here's the <a href="https://auth0.com/blog/critical-vulnerabilities-in-json-web-token-libraries/" rel="nofollow noreferrer">guide</a> which explains why this is critical vulnerability(Shout out to the author for detailed explanation)</p> <p>This is our implementation:</p> <pre><code> services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddMicrosoftIdentityWebApi(configuration); app.UseAuthentication(); app.UseAuthorization(); </code></pre> <p>All the references, we come across is asking to validate the signature. Now we don't use any secret key Or cert to validate the signature by generating a random HSA OR RSA keys. Kind of stuck with this vulnerability.</p>
[ { "answer_id": 74276480, "author": "rotgers", "author_id": 2223566, "author_profile": "https://Stackoverflow.com/users/2223566", "pm_score": 2, "selected": true, "text": "AuthManager" }, { "answer_id": 74276578, "author": "Muhammad Usama", "author_id": 14404513, "author_profile": "https://Stackoverflow.com/users/14404513", "pm_score": 0, "selected": false, "text": "AuthManager" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276348", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8340043/" ]
74,276,372
<p>How do I add class of <code>dropdown</code> in a class wrap by <em>li</em> - <code>&lt;li class=&quot;dropdown&quot;&gt;</code> in a wp_nav_menu function?</p> <p>My static menu</p> <pre><code>&lt;ul&gt; &lt;li&gt; &lt;a href=&quot;#hero&quot;&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&quot;blog.html&quot;&gt;Blog&lt;/a&gt;&lt;/li&gt; &lt;li class=&quot;dropdown&quot;&gt;&lt;a href=&quot;#&quot;&gt;&lt;span&gt;Drop Down&lt;/span&gt; &lt;i class=&quot;bi bi-chevron-down dropdown-indicator&quot;&gt;&lt;/i&gt;&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Drop Down 1&lt;/a&gt;&lt;/li&gt; &lt;li class=&quot;dropdown&quot;&gt;&lt;a href=&quot;#&quot;&gt;&lt;span&gt;Deep Drop Down&lt;/span&gt; &lt;i class=&quot;bi bi-chevron-down dropdown-indicator&quot;&gt;&lt;/i&gt;&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Deep Drop Down 1&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Drop Down 2&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p>I have this dynamic nav menu function,</p> <pre><code>&lt;?php if ( has_nav_menu( 'main-menu' ) ) : wp_nav_menu( array( 'theme_location' =&gt; 'main-menu', 'items_wrap' =&gt; '%3$s', 'add_li_class' =&gt; '', 'container' =&gt; '' )); endif; ?&gt; </code></pre> <p>How do I make my static menu dynamic with a dropdown in wordpress wp_nav_menu function?</p>
[ { "answer_id": 74276480, "author": "rotgers", "author_id": 2223566, "author_profile": "https://Stackoverflow.com/users/2223566", "pm_score": 2, "selected": true, "text": "AuthManager" }, { "answer_id": 74276578, "author": "Muhammad Usama", "author_id": 14404513, "author_profile": "https://Stackoverflow.com/users/14404513", "pm_score": 0, "selected": false, "text": "AuthManager" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276372", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20252367/" ]
74,276,409
<p>I have a dictionary as follows:</p> <pre><code>Measurments = {'Kitchen': '22°', 'Master bedroom': '19°', 'Sitting room': '21°', 'Toilet': '24°', 'Guest bedroom': '18°', 'Garage': '15°', 'Outside': '12°'} and want to save it in a new dictionary as follows: </code></pre> <p>newDictionary = {'Kitchen': 22, 'Master bedroom': 19, 'Sitting room': 21, 'Toilet': 24, 'Guest bedroom': 18, 'Garage': 15, 'Outside': 12}</p> <pre><code> i have tried : </code></pre> <pre><code>newDictionary = {str(k):int(v) for k,v in measurements.items()} </code></pre> <p>but it gave me this error code:</p> <pre><code>ValueError: invalid literal for int() with base 10: '22°' </code></pre> <p>How do i get rid of the degree sign so i can get the values as integers?</p>
[ { "answer_id": 74276458, "author": "Msvstl", "author_id": 13779320, "author_profile": "https://Stackoverflow.com/users/13779320", "pm_score": -1, "selected": false, "text": "measurements = {'Kitchen': '22°', 'Master bedroom': '19°', 'Sitting room': '21°', 'Toilet': '24°', 'Guest bedroom': '18°', 'Garage': '15°', 'Outside': '12°'}\n\nnewDictionary = {str(k):int(v[:-1]) for k,v in measurements.items()}\n\nprint(newDictionary)\n" }, { "answer_id": 74276465, "author": "Đorđe Radujković", "author_id": 20065169, "author_profile": "https://Stackoverflow.com/users/20065169", "pm_score": 0, "selected": false, "text": "newDictionary = {key:int(value.replace('°', '')) for key,value in Measurments.items()}\n" }, { "answer_id": 74276490, "author": "Jox", "author_id": 20388213, "author_profile": "https://Stackoverflow.com/users/20388213", "pm_score": 0, "selected": false, "text": "int" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276409", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20388207/" ]
74,276,422
<p>I'm not getting the expected output when trying to <a href="https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/sort-object?view=powershell-7.2" rel="nofollow noreferrer">sort</a> the output from <code>winget list</code> in powershell. The <code>Id</code> column is not sorted.</p> <pre><code> # winget list | Sort-Object -Property Id ScreenToGif NickeManarin.ScreenToGif 2.37.1 winget Microsoft Visual C++ 2015-2019 Redist… Microsoft.VCRedist.2015+.x64 14.28.29325.2 14.34.318… winget paint.net {28718A56-50EF-4867-B4C8-0860228B5EC9} 4.3.8 Python 3.10.0 (64-bit) {21b42743-c8f9-49d7-b8b6-b5855317c7ed} 3.10.150.0 Microsoft Support and Recovery Assist… 0527a644a4ddd31d 17.0.7018.4 ----------------------------------------------------------------------------------------------------------------------- Name Id Version Available Source Paint 3D Microsoft.MSPaint_8wekyb3d8bbwe 6.2009.30067.0 Microsoft .NET SDK 6.0.402 (x64) Microsoft.DotNet.SDK.6 6.0.402 winget 3D Viewer Microsoft.Microsoft3DViewer_8wekyb3d8… 7.2010.15012.0 Microsoft Sticky Notes Microsoft.MicrosoftStickyNotes_8wekyb… 3.8.8.0 </code></pre> <hr /> <p>Q: <em>How can I sort the output of <code>winget list</code> by the <code>Id</code> column in powershell?</em></p> <p>I would like to see a powershell solution similar to the Bash <code>sort -k &lt;column-number&gt;</code>, to sort on any column. I fail to see why this obvious function is not available in powershell?</p>
[ { "answer_id": 74277811, "author": "js2010", "author_id": 6654942, "author_profile": "https://Stackoverflow.com/users/6654942", "pm_score": 3, "selected": true, "text": "…" }, { "answer_id": 74281635, "author": "zett42", "author_id": 7571258, "author_profile": "https://Stackoverflow.com/users/7571258", "pm_score": 2, "selected": false, "text": "ID" }, { "answer_id": 74297741, "author": "mklement0", "author_id": 45375, "author_profile": "https://Stackoverflow.com/users/45375", "pm_score": 2, "selected": false, "text": "sort -k <column-number>" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276422", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1147688/" ]
74,276,454
<p>when I execute this code it always returns the same message even if i send different email</p> <pre><code> let message = &quot;&quot;; const findQuery = &quot;select email from Users where email = ?&quot;; const queryResult = await db.query(findQuery, [req.body.email]); if(queryResult[0] === req.body.email){ message = &quot;Welcome Back&quot; }else if (queryResult[0] != req.body.email) { message = &quot;No Access&quot; } res.send(message); </code></pre> <p>i expect deffrent message</p>
[ { "answer_id": 74277811, "author": "js2010", "author_id": 6654942, "author_profile": "https://Stackoverflow.com/users/6654942", "pm_score": 3, "selected": true, "text": "…" }, { "answer_id": 74281635, "author": "zett42", "author_id": 7571258, "author_profile": "https://Stackoverflow.com/users/7571258", "pm_score": 2, "selected": false, "text": "ID" }, { "answer_id": 74297741, "author": "mklement0", "author_id": 45375, "author_profile": "https://Stackoverflow.com/users/45375", "pm_score": 2, "selected": false, "text": "sort -k <column-number>" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276454", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19851959/" ]
74,276,469
<p>This is my json here: <a href="https://my-json-server.typicode.com/fluttirci/testJson/db" rel="nofollow noreferrer">https://my-json-server.typicode.com/fluttirci/testJson/db</a></p> <p>This code only works if there is an only one json object however, with this employees JSON, it doesn't work. Flutter documentation isn't very clear about this subject. They only work on one line jsons. What I wanna do is, I wanna get all that data into my phone screen. If I get it, I will show them on a table or a grid. But yet it doesn't won't work. It says type 'Null' is not a subtype of type 'int' . Here is my code:</p> <pre><code>import 'dart:async'; import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; Future&lt;Album&gt; fetchAlbum() async { final response = await http.get( Uri.parse('https://my-json-server.typicode.com/fluttirci/testJson/db')); print(response); Map&lt;String, dynamic&gt; userMap = jsonDecode(response.body); if (response.statusCode == 200) { return Album.fromJson(userMap); //testing } else { throw Exception('Failed to load album'); } } class Album { final int userId; final int id; final String title; Album(this.userId, this.id, this.title); Album.fromJson(Map&lt;String, dynamic&gt; json) : userId = json['userId'], id = json['id'], title = json['title']; Map&lt;String, dynamic&gt; toJson() =&gt; { 'userId': userId, 'id': id, 'title': title, }; } void main() =&gt; runApp(const MyApp()); class MyApp extends StatefulWidget { const MyApp({super.key}); @override State&lt;MyApp&gt; createState() =&gt; _MyAppState(); } class _MyAppState extends State&lt;MyApp&gt; { late Future&lt;Album&gt; futureAlbum; late Future&lt;Album&gt; user; @override void initState() { super.initState(); user = fetchAlbum(); } @override Widget build(BuildContext context) { return MaterialApp( title: 'Fetch Data Example', theme: ThemeData( brightness: Brightness.dark, primarySwatch: Colors.blue, ), home: Scaffold( appBar: AppBar( title: const Text('Fetch Data Example'), ), body: Center( child: FutureBuilder&lt;Album&gt;( future: user, builder: (context, snapshot) { if (snapshot.hasData) { return Text(snapshot.data!.title); } else if (snapshot.hasError) { return Text('${snapshot.error}'); } return const CircularProgressIndicator(); }, ), ), ), ); } } </code></pre>
[ { "answer_id": 74276552, "author": "eamirho3ein", "author_id": 10306997, "author_profile": "https://Stackoverflow.com/users/10306997", "pm_score": 3, "selected": true, "text": "Future<List<Album>> fetchAlbum() async {\n final response = await http.get(\n Uri.parse('https://my-json-server.typicode.com/fluttirci/testJson/db'));\n\n print(response);\n Map<String, dynamic> userMap = jsonDecode(response.body);\n if (response.statusCode == 200) {\n return (userMap['employees'] as List).map((e) => Album.fromJson(e)).toList()\n \n } else {\n throw Exception('Failed to load album');\n }\n}\n" }, { "answer_id": 74276670, "author": "Yeasin Sheikh", "author_id": 10157127, "author_profile": "https://Stackoverflow.com/users/10157127", "pm_score": 0, "selected": false, "text": "employees" }, { "answer_id": 74276719, "author": "Gwhyyy", "author_id": 18670641, "author_profile": "https://Stackoverflow.com/users/18670641", "pm_score": 0, "selected": false, "text": "resultMap" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276469", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15474032/" ]
74,276,484
<p>I want to pass some content from a elemental block up to a parent template (to change the page header) - Is this possible? I don't have any example code for what I'm trying because I don't have any idea how to implement it.</p> <p>This would be similar to the content_for facility in Rails / ERB templates.</p> <p>Parent:</p> <pre><code>Page Title &lt;%= yield :title %&gt; </code></pre> <hr /> <p>Child Template:</p> <pre><code>&lt;% content_for :title do %&gt; &lt;b&gt;, A simple page&lt;/b&gt; &lt;% end %&gt; </code></pre> <p>Is there anything like this or some other way to do this in SS templates?</p>
[ { "answer_id": 74281949, "author": "Guy Sartorelli", "author_id": 10936596, "author_profile": "https://Stackoverflow.com/users/10936596", "pm_score": 2, "selected": true, "text": "public function getTitleForTemplate()\n{\n return $this->MyBlock->PageTitle;\n}\n" }, { "answer_id": 74292841, "author": "Will", "author_id": 514860, "author_profile": "https://Stackoverflow.com/users/514860", "pm_score": 0, "selected": false, "text": "public function getTitleForTemplate(){ \n $output = \"\" ; \n foreach( $this->ElementalArea->Elements() as $element ){\n if($element->ClassName == 'MySite\\AwardsElement'){ \n if ( $element->Award() ){\n $output .= \"{$element->Award()->title } \";\n }\n } \n }\n return $output;\n}\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276484", "https://Stackoverflow.com", "https://Stackoverflow.com/users/514860/" ]
74,276,489
<p>i have a Data Grid table, there's a colomn that holds actions (edit and delete): (Below is my whole code)</p> <pre><code>import React, { useEffect } from 'react' import { DataGrid } from '@mui/x-data-grid' import { useNavigate } from 'react-router-dom' import EditIcon from '@mui/icons-material/Edit' import DeleteForeverIcon from '@mui/icons-material/DeleteForever' import { Button } from '@mui/material' const rows = [ { id: 1, lastName: 'Snow', firstName: 'Jon', age: 35, edit: EditIcon, delete: `${(&lt;Button variant=&quot;text&quot;&gt;Text&lt;/Button&gt;)}`, }, ] const Colors = () =&gt; { const columns = [ { field: 'id', headerName: 'ID', width: 70 }, { field: 'firstName', headerName: 'First name', width: 130 }, { field: 'lastName', headerName: 'Last name', width: 130 }, { field: 'age', headerName: 'Age', type: 'number', width: 90, }, { field: 'edit', headerName: 'Edit', width: 150 }, { field: 'delete', headerName: 'Delete', width: 150 }, ] return ( &lt;div style={{ height: 560, width: '100%' }}&gt; &lt;DataGrid sx={{ backgroundColor: 'white' }} rows={rows} columns={columns} pageSize={8} rowsPerPageOptions={[8]} checkboxSelection /&gt; &lt;/div&gt; ) } export default Colors </code></pre> <p>Now my problem is, i would like to use a material <code>icon</code> inside edit column. I tried by implementing icon directly like this:</p> <pre><code>const rows = [ { id: 1, lastName: 'Snow', firstName: 'Jon', age: 35, edit: EditIcon, //&lt;-- }, ] </code></pre> <p>Or calling a <code>button</code> by this way:</p> <pre><code>const rows = [ { id: 1, lastName: 'Snow', firstName: 'Jon', age: 35, delete: `${(&lt;Button variant=&quot;text&quot;&gt;Text&lt;/Button&gt;)}`, //&lt;-- }, ] </code></pre> <p><strong>Result</strong>: i'm getting a render <code>[object object]</code> instead of icon or button.<a href="https://i.stack.imgur.com/DYWcK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DYWcK.png" alt="enter image description here" /></a></p> <p><strong>How to properly render a button or icon inside Data Grid column?</strong></p>
[ { "answer_id": 74277008, "author": "Louis", "author_id": 10203720, "author_profile": "https://Stackoverflow.com/users/10203720", "pm_score": 1, "selected": false, "text": "import { GridActionsCellItem, GridRowParams } from \"@mui/x-data-grid-pro\";\nimport EditIcon from \"@mui/icons-material/Edit\";\n\n {\n field: \"actions\",\n type: \"actions\",\n align: \"left\",\n headerName: t(\"actions\"),\n getActions: (params: GridRowParams) => [\n <GridActionsCellItem\n key={0}\n icon={<EditIcon titleAccess={t(\"edit\")} color=\"primary\" />}\n label={t(\"edit\")}\n onClick={() => handleEditPressed(params)}\n />,\n ],\n },\n" }, { "answer_id": 74286400, "author": "jhon26", "author_id": 20168209, "author_profile": "https://Stackoverflow.com/users/20168209", "pm_score": 0, "selected": false, "text": "{\n field: 'edit',\n headerName: 'Edit',\n width: 70,\n renderCell: (params) => {\n return <EditIcon /> //<-- Mui icons should be put this way here.\n },\n},\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276489", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20168209/" ]
74,276,511
<p>Write a program that reads a series of lines, each of them containing a sequence of non negative integers, and prints as output the value of the sum of the first line that contains an even number of elements ending in 3. If there is no such line, the output will be -1.</p> <p>For instance, for the input:</p> <pre><code>23 12 4 25 44 43 23 3 12 8 33 4 9 73 14 88 92 55 </code></pre> <p>The output would be 133, because the third line contains 2 numbers ending in 3 (33 and 73), and the previous lines contained an odd number of such elements (1 and 3 respectively). Thus, the third line is the first with an even number of elements ending in 3. The sum of the element of this line is 33+4+9+73+14 = 133</p> <p>So, in conclusion:</p> <ul> <li>Input is a series of lines with numbers. Each line contains at least one number.</li> <li>Output is the sum of the elements in the first line that happens to have an even number of elements ending in 3, or -1 if there is no such line.</li> </ul> <p>My try far now is:</p> <pre><code>import sys line = sys.stdin.read().split() # even number of elements ending in 3 for i in range(len(line)): # Make str input int line[i] = int(line[i]) print(line) </code></pre> <p>With this all integer input in different lines is stored in a single list. But how I am able to distinguish which integers are from line 1? or 2? Solution needs to be with the import sys parameter. My question is about how to treat the input. How can I store values from each line in a list for each?</p> <p>UPDATE: I was trying some things, not the result for the question but maybe clears what I want.</p> <pre><code>import sys line = sys.stdin.readline().split() # ['23', '12', '4', '25'] while line != '': lista_numb = [] for i in line: if i.endswith('3'): lista_numb.append(i) print(lista_numb) line = sys.stdin.readline().split() if len(lista_numb)%2 == 0: # even print(sum(line)) </code></pre>
[ { "answer_id": 74277008, "author": "Louis", "author_id": 10203720, "author_profile": "https://Stackoverflow.com/users/10203720", "pm_score": 1, "selected": false, "text": "import { GridActionsCellItem, GridRowParams } from \"@mui/x-data-grid-pro\";\nimport EditIcon from \"@mui/icons-material/Edit\";\n\n {\n field: \"actions\",\n type: \"actions\",\n align: \"left\",\n headerName: t(\"actions\"),\n getActions: (params: GridRowParams) => [\n <GridActionsCellItem\n key={0}\n icon={<EditIcon titleAccess={t(\"edit\")} color=\"primary\" />}\n label={t(\"edit\")}\n onClick={() => handleEditPressed(params)}\n />,\n ],\n },\n" }, { "answer_id": 74286400, "author": "jhon26", "author_id": 20168209, "author_profile": "https://Stackoverflow.com/users/20168209", "pm_score": 0, "selected": false, "text": "{\n field: 'edit',\n headerName: 'Edit',\n width: 70,\n renderCell: (params) => {\n return <EditIcon /> //<-- Mui icons should be put this way here.\n },\n},\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276511", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20323813/" ]
74,276,512
<p>I believe that any valid latin1 character will either be interpreted correctly by Python's utf8 encoder or throw an error. I, therefore, claim that if you work with only either utf8 files or latin1 files, you can safely write the following code to read those files, without ending up with <a href="https://en.wikipedia.org/wiki/Mojibake" rel="nofollow noreferrer">Mojibake</a>:</p> <pre class="lang-py prettyprint-override"><code>from pathlib import Path def read_utf8_or_latin1_text(path: Path, args, kwargs): try: return path.read_text(encoding=&quot;utf-8&quot;) except UnicodeDecodeError: return path.read_text(encoding=&quot;latin1&quot;) </code></pre> <p>I tested this hypothesis out on <a href="https://github.com/bits/UTF-8-Unicode-Test-Documents/blob/master/UTF-8_sequence_unseparated/utf8_sequence_0-0x10ffff_including-unassigned_including-unprintable-asis_unseparated.txt" rel="nofollow noreferrer">this large character data set</a> and found that it holds up to scrutiny. Is this always the case?</p> <h3>Input:</h3> <pre class="lang-py prettyprint-override"><code>import requests insanely_many_characters = requests.get( &quot;https://github.com/bits/UTF-8-Unicode-Test-Documents/raw/master/UTF-8_sequence_unseparated/utf8_sequence_0-0x10ffff_including-unassigned_including-unprintable-asis_unseparated.txt&quot; ).text print( f&quot;\n=== test {len(insanely_many_characters)} utf-8 characters for same-same misinterpretations ===&quot; ) for char in insanely_many_characters: if (x := char.encode(&quot;utf-8&quot;).decode(&quot;utf-8&quot;)) != char: print(char, x) print( f&quot;\n=== test {len(insanely_many_characters)} latin1 characters for same-same misinterpretations ===&quot; ) latinable = [] nr = 0 for char in insanely_many_characters: try: if (x := char.encode(&quot;latin1&quot;).decode(&quot;latin1&quot;)) != char: print(char, x) latinable.append(char) except UnicodeEncodeError: nr += 1 if nr: print(f&quot;{nr} characters not in latin1 set&quot;) print('found the following valid latin1 characters: &quot;&quot;&quot;\n' + &quot;&quot;.join(latinable) + '\n&quot;&quot;&quot;') print( f&quot;\n=== test {len(latinable)} latin1 characters for utf-8 Mojibake ===&quot; ) for char in latinable: try: if (x := char.encode(&quot;latin1&quot;).decode(&quot;utf-8&quot;)) != char: print(char, x) except UnicodeDecodeError: pass </code></pre> <h3>Output:</h3> <pre><code> === test 1111998 utf-8 characters for same-same misinterpretations === === test 1111998 latin1 characters for same-same misinterpretations === 1111742 characters not in latin1 set found the following latin1 characters: &quot;&quot;&quot; !&quot;#$%&amp;'()*+,-./0123456789:;&lt;=&gt;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ &quot;&quot;&quot; === test 256 latin1 characters for utf-8 Mojibake === </code></pre> <h2>Addendum:</h2> <p>I see I totally forgot to test for sequences of latin1 characters, and only tested for individual characters. By adding this test:</p> <pre class="lang-py prettyprint-override"><code>print( f&quot;\n=== test {len(latinable)} latin1 sequences wrongly interoperable by utf-8 ===&quot; ) for char1 in latinable: for char2 in latinable: try: if (x := (char1 + char2).encode(&quot;latin1&quot;).decode(&quot;utf-8&quot;)) != char1 + char2: print(char1 + char2, x) except UnicodeDecodeError: pass </code></pre> <p>I ended up generating many utf-8 Mojibake (1920 instances in total), which is a counterexample to my hypothesis!:</p> <pre><code>=== test 256 latin1 sequences wrongly interoperable by utf-8 ===                                     ¡ ¡ ⋮ </code></pre>
[ { "answer_id": 74277008, "author": "Louis", "author_id": 10203720, "author_profile": "https://Stackoverflow.com/users/10203720", "pm_score": 1, "selected": false, "text": "import { GridActionsCellItem, GridRowParams } from \"@mui/x-data-grid-pro\";\nimport EditIcon from \"@mui/icons-material/Edit\";\n\n {\n field: \"actions\",\n type: \"actions\",\n align: \"left\",\n headerName: t(\"actions\"),\n getActions: (params: GridRowParams) => [\n <GridActionsCellItem\n key={0}\n icon={<EditIcon titleAccess={t(\"edit\")} color=\"primary\" />}\n label={t(\"edit\")}\n onClick={() => handleEditPressed(params)}\n />,\n ],\n },\n" }, { "answer_id": 74286400, "author": "jhon26", "author_id": 20168209, "author_profile": "https://Stackoverflow.com/users/20168209", "pm_score": 0, "selected": false, "text": "{\n field: 'edit',\n headerName: 'Edit',\n width: 70,\n renderCell: (params) => {\n return <EditIcon /> //<-- Mui icons should be put this way here.\n },\n},\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1490584/" ]
74,276,517
<p>I tried to install the Jupyter Notebook Kernel on VSCode, and it cant seem to connect, it shows this text in the VSCode:</p> <pre><code>Failed to start the Kernel. C:\Users\Theodore\AppData\Roaming\Python\Python310\site-packages\traitlets\traitlets.py:2412: FutureWarning: Supporting extra quotes around strings is deprecated in traitlets 5.0. You can use 'hmac-sha256' instead of '&quot;hmac-sha256&quot;' if you require traitlets &gt;=5. warn( C:\Users\Theodore\AppData\Roaming\Python\Python310\site-packages\traitlets\traitlets.py:2366: FutureWarning: Supporting extra quotes around Bytes is deprecated in traitlets 5.0. Use '7d0f2f44-841e-4868-9c82-374720d9f73e' instead of 'b&quot;7d0f2f44-841e-4868-9c82-374720d9f73e&quot;'. warn( Bad address (C:\projects\libzmq\src\epoll.cpp:100). View Jupyter log for further details. </code></pre> <p>Python version : 3.10.4 Jupyter Notebook Version: 6.4.12</p> <p>I tried switching to the kernel from Anaconda, but it also doesn't seem to work. Sometimes it just asks me to reinstall the ipykernel again. Thanks for your help.</p>
[ { "answer_id": 74283544, "author": "MingJie-MSFT", "author_id": 18359438, "author_profile": "https://Stackoverflow.com/users/18359438", "pm_score": 0, "selected": false, "text": "pip install ipykernel" }, { "answer_id": 74284596, "author": "Theodore Maximus", "author_id": 20388275, "author_profile": "https://Stackoverflow.com/users/20388275", "pm_score": 2, "selected": true, "text": "netsh winsock reset\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276517", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20388275/" ]
74,276,540
<p>Unit testing with Viper - Swift</p> <p>Hello,</p> <p>I have an Login module(LoginViewController,LoginPresenter,LoginInteractor,LoginRouter) that I wrote with Viper. I want to write a unit test for this module but I'm not sure exactly where to start. Can I get suggestions from people who write unit tests with Viper? Thank you,</p>
[ { "answer_id": 74283544, "author": "MingJie-MSFT", "author_id": 18359438, "author_profile": "https://Stackoverflow.com/users/18359438", "pm_score": 0, "selected": false, "text": "pip install ipykernel" }, { "answer_id": 74284596, "author": "Theodore Maximus", "author_id": 20388275, "author_profile": "https://Stackoverflow.com/users/20388275", "pm_score": 2, "selected": true, "text": "netsh winsock reset\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276540", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14604879/" ]
74,276,544
<p>I would like to add a legend for the country names below my map.</p> <p>I have this dataframe of frequency of event occurrences on different regions:</p> <pre><code>trend_country_freq &lt;- structure(list(country = c(&quot;US&quot;, &quot;CN&quot;, &quot;KR&quot;, &quot;IN&quot;, &quot;AU&quot;, &quot;GB&quot;, &quot;JP&quot;), n = c(25L, 20L, 12L, 5L, 2L, 1L, 1L), country_name = c(&quot;USA&quot;, &quot;China&quot;, &quot;South Korea&quot;, &quot;India&quot;, &quot;Australia&quot;, &quot;UK&quot;, &quot;Japan&quot;)), row.names = c(1L, 2L, 3L, 4L, 5L, 7L, 8L), class = &quot;data.frame&quot;) </code></pre> <p>Now I use the <code>maps</code> and <code>ggplot2</code> packages to create a world map showing the frequency of event occurences:</p> <pre><code>library(maps) library(ggplot2) world_map &lt;- map_data(&quot;world&quot;) world_map &lt;- subset(world_map, region != &quot;Antarctica&quot;) ggplot(trend_country_freq) + geom_map( dat = world_map, map = world_map, aes(map_id = region), fill = &quot;white&quot;, color = &quot;#7f7f7f&quot;, size = 0.25 ) + geom_map(map = world_map, aes(map_id = country_name, fill = n), size = 0.25) + scale_fill_gradient(low = &quot;#fff7bc&quot;, high = &quot;#cc4c02&quot;, name = &quot;Total Cases&quot;) + expand_limits(x = world_map$long, y = world_map$lat) + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), panel.background = element_blank()) + theme(axis.title = element_blank(), axis.ticks = element_blank(), axis.text = element_blank()) </code></pre> <p>The result looks like this:</p> <p><a href="https://i.stack.imgur.com/k9i4Z.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/k9i4Z.png" alt="enter image description here" /></a></p> <p>But I actually want something like this:</p> <p><a href="https://i.stack.imgur.com/MYutT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MYutT.png" alt="enter image description here" /></a></p> <p>Do you have ideas how to generate such a map? Thank you very much!</p>
[ { "answer_id": 74283544, "author": "MingJie-MSFT", "author_id": 18359438, "author_profile": "https://Stackoverflow.com/users/18359438", "pm_score": 0, "selected": false, "text": "pip install ipykernel" }, { "answer_id": 74284596, "author": "Theodore Maximus", "author_id": 20388275, "author_profile": "https://Stackoverflow.com/users/20388275", "pm_score": 2, "selected": true, "text": "netsh winsock reset\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276544", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12593600/" ]
74,276,613
<pre><code>declare type a is record(a1 number, a2 varchar2(10)); type b is record(b1 number, b2 varchar2(10)); type c is record(a1 number, b2 varchar2(10),c1 number, c2 varchar2(10)); begin null; end; </code></pre> <p>the record c is defined like that: the fields of c are the field of a + b.</p> <p>I have a real example with a lot of field. Is there a more efficient way to declare c.</p> <p>Something like that ?</p> <pre><code> type c is record( a..., c...); </code></pre> <p>And more importantly I would like thatif I change the definition of a or b, the definition of c change too. <a href="https://dbfiddle.uk/BArYilI1" rel="nofollow noreferrer">code on dbfiddle</a></p>
[ { "answer_id": 74276656, "author": "OldProgrammer", "author_id": 1745544, "author_profile": "https://Stackoverflow.com/users/1745544", "pm_score": 2, "selected": true, "text": "%ROWTYPE only applies to tables. Just do this:\n\ndeclare\n type a is record(a1 number, a2 varchar2(10));\n type b is record(b1 number, b2 varchar2(10));\n type c is record(a2 a, b2 b);\nbegin\n null;\nend;\n" }, { "answer_id": 74276826, "author": "MT0", "author_id": 1509264, "author_profile": "https://Stackoverflow.com/users/1509264", "pm_score": 1, "selected": false, "text": "..." }, { "answer_id": 74277217, "author": "d r", "author_id": 19023353, "author_profile": "https://Stackoverflow.com/users/19023353", "pm_score": 0, "selected": false, "text": "SET SERVEROUTPUT ON\nDeclare\n type a is record(a1 number := 1, a2 varchar2(10) := 'd');\n var_a a;\n type b is record(b1 number := 1, b2 varchar2(10) := 't');\n var_b b;\n type c is record(a1 number := var_a.a1, a2 varchar2(10) := var_a.a2, b1 number := var_b.b1, b2 varchar2(10) := var_b.b2);\n var_c c;\nBegin\n DBMS_OUTPUT.PUT_LINE('Record A = ' || To_Char(var_a.a1) || ', ' || var_a.a2);\n DBMS_OUTPUT.PUT_LINE('Record B = ' || To_Char(var_b.b1) || ', ' || var_b.b2);\n DBMS_OUTPUT.PUT_LINE('Record C = ' || To_Char(var_c.a1) || ', ' || var_c.a2 || ', ' || To_Char(var_c.b1) || ', ' || var_c.b2);\nEnd;\n\n/* R e s u l t :\nanonymous block completed\nRecord A = 1, d\nRecord B = 1, t\nRecord C = 1, d, 1, t\n*/\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276613", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8458083/" ]
74,276,622
<p>Here is a simple snippet:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>class A { constructor(func) { func(); } } class B { constructor() { this.field = "hello"; new A(this.printField); } printField() { console.log(this.field); } } new B();</code></pre> </div> </div> </p> <p>I would expect &quot;hello&quot; to be printed. However, I get the following error:</p> <blockquote> <p>Uncaught TypeError: Cannot read properties of undefined (reading 'field')</p> </blockquote> <p>It seems that after passing <code>printField</code>, <code>this</code> is now referring to <code>A</code> instead of <code>B</code>. How can I fix it?</p> <p><strong>Edit:</strong> Yes, yes, I know. When copying the snippet I accidentally wrote <code>new A(printField)</code> instead of <code>new A(this.printField)</code>. The question and the error I get are now fixed.</p>
[ { "answer_id": 74276646, "author": "Yury Tarabanko", "author_id": 351705, "author_profile": "https://Stackoverflow.com/users/351705", "pm_score": 1, "selected": true, "text": "() => this.printField()" }, { "answer_id": 74276677, "author": "Quentin", "author_id": 19068, "author_profile": "https://Stackoverflow.com/users/19068", "pm_score": 1, "selected": false, "text": "Uncaught ReferenceError: printField is not defined\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276622", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1925272/" ]
74,276,623
<p>I have agents pool that have different user capabilities (user paremeters). Also I have pipelines which contain different demands for agents. In other words, it is not possible to run pipeline in all agents.</p> <p>How to find out which agents are suitable for running the pipeline?</p> <p>How to check the possibility of running a pipeline on an agent?</p> <hr /> <p>I can get data (contains capabilities/paremeters) about agents using query: <code>https://dev.azure.com/{organization}/_apis/distributedtask/pools/{poolId}/agents?includeCapabilities=true</code></p> <p>I can find out the data (demands) of manual-pipelines (pipelines created manually by users) using query: <code>https://dev.azure.com/{organization}/{project}/_apis/build/definitions/{definitionId}</code></p> <p>But how to get the requirements of pipelines created using yaml files?</p> <p>Unfortunately, I did not find an answer to my question.</p>
[ { "answer_id": 74284700, "author": "Antonia Wu-MSFT", "author_id": 19229290, "author_profile": "https://Stackoverflow.com/users/19229290", "pm_score": 1, "selected": false, "text": "https://dev.azure.com/{organization}/{project}/_apis/build/definitions/{definitionId}" }, { "answer_id": 74290736, "author": "Doris Lv", "author_id": 13586071, "author_profile": "https://Stackoverflow.com/users/13586071", "pm_score": 0, "selected": false, "text": "https://dev.azure.com/{org-name}/{Project-name}/_apis/build/definitions/{definitionId}" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276623", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11807795/" ]
74,276,665
<p>Consider this example:</p> <pre class="lang-csharp prettyprint-override"><code>List&lt;int&gt; GetLengths(ICollection&lt;string&gt; strings) =&gt; strings .Select(s =&gt; s.Length) .ToList(); </code></pre> <p>If <code>Select()</code> checked that the input collection implements <code>ICollection&lt;T&gt;</code> and that its length is known in advance, it could have returned <code>ICollection&lt;T&gt;</code> too, so that <code>ToList()</code> would initialize the resulting list with capacity. Instead, the list adds each value one by one, expanding its storage log(N) times.</p> <p>Is there any reason it's not done so in LINQ?</p> <p><strong>Update</strong>: since there are many questions about my suggestion, here are some justifications for my concept:</p> <ol> <li>LINQ already <a href="https://github.com/microsoft/referencesource/blob/master/System.Core/System/Linq/Enumerable.cs#L42-L44" rel="nofollow noreferrer">returns</a> many different implementation of <code>IEnumerable&lt;T&gt;</code>. IMO there is nothing wrong with adding another iterator that implements one more interface.</li> <li>A read-only <code>ICollection&lt;T&gt;</code> doesn't have to be materialized in memory, it only has to have <code>Count</code>. <a href="https://pastebin.com/zX5fdZEf" rel="nofollow noreferrer">Here</a> is an example of a bare implementation of <code>ICollection&lt;T&gt;</code> that behaves similar to <code>Enumerable.Repeat&lt;T&gt;()</code> except it calls a delegate to generate each element. It throws exceptions left and right, but <a href="https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/Collections/ObjectModel/ReadOnlyCollection.cs#L59-L89" rel="nofollow noreferrer">so the stock <code>ReadOnlyCollection&lt;T&gt;</code> does</a>.</li> <li>The <code>List&lt;T&gt;(IEnumerable&lt;T&gt; collection)</code> constructor already <a href="https://github.com/microsoft/referencesource/blob/master/mscorlib/system/collections/generic/list.cs#L79-L91" rel="nofollow noreferrer">checks</a> if <code>collection</code> also implements <code>ICollection&lt;T&gt;</code>, so that the list can allocate its storage in advance. It doesn't violate any interfaces or conventions.</li> <li>From the architectural point of view, implementing <code>IReadOnlyCollection&lt;T&gt;</code> would make more sense, but unfortunately, it's often neglected in the BCL itself, and the <code>List&lt;T&gt;</code> constructor doesn't check it.</li> </ol>
[ { "answer_id": 74277010, "author": "Johnathan Barclay", "author_id": 8126362, "author_profile": "https://Stackoverflow.com/users/8126362", "pm_score": 1, "selected": false, "text": "Select()" }, { "answer_id": 74285156, "author": "Theodor Zoulias", "author_id": 11178549, "author_profile": "https://Stackoverflow.com/users/11178549", "pm_score": 3, "selected": true, "text": "source.Select().ToList()" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276665", "https://Stackoverflow.com", "https://Stackoverflow.com/users/934618/" ]
74,276,676
<p>We Implemented SSO using .Net Core 6, ITfoxtec framework (<a href="https://www.itfoxtec.com/identitysaml2" rel="nofollow noreferrer">https://www.itfoxtec.com/identitysaml2</a>) and Azure AD Enterprise application. everything is working as expected, while logging out we use following code, which logged out user from Microsoft account and as result the user also logged off from other applications as well, can we log out user only for specific Azure AD enterprise application?</p> <pre><code>[HttpPost(&quot;Logout&quot;)] [ValidateAntiForgeryToken] public async Task&lt;IActionResult&gt; Logout() { if (!User.Identity.IsAuthenticated) { return Redirect(Url.Content(&quot;~/&quot;)); } var binding = new Saml2PostBinding(); var saml2LogoutRequest = await new Saml2LogoutRequest(config, User).DeleteSession(HttpContext); return **binding.Bind(saml2LogoutRequest).ToActionResult();** /* logged out from Microsoft application */ } </code></pre> <p>var saml2LogoutRequest = await new Saml2LogoutRequest(config, User).DeleteSession(HttpContext); delete cookies as expected, our application does not have custom log in page, as soon as user hit webpage it will redirect user to log-in and because Azure AD session is still active it land user on home page. what we want is, once user logged out from the application and hit web page again it should ask to select Microsoft account to log-in.</p> <pre><code>[Route(&quot;Login&quot;)] public IActionResult Login(string returnUrl = null) { var binding = new Saml2RedirectBinding(); binding.SetRelayStateQuery(new Dictionary&lt;string, string&gt; { { relayStateReturnUrl, returnUrl ?? Url.Content(&quot;~/&quot;) } }); return binding.Bind(new Saml2AuthnRequest(config)).ToActionResult(); } </code></pre> <p>following is Azure AD Enterprise application SAML configuration</p> <p><a href="https://i.stack.imgur.com/4BsRi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4BsRi.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74293461, "author": "Dhruv Patel", "author_id": 2198089, "author_profile": "https://Stackoverflow.com/users/2198089", "pm_score": 0, "selected": false, "text": "binding.Bind(saml2LogoutRequest).ToActionResult();" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276676", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2198089/" ]
74,276,714
<p>I have the dataframe below:</p> <pre><code>import pandas as pd df = pd.DataFrame({'ID': ['ID001', 'ID002', 'ID003', 'ID004', 'ID005', 'ID006'], 'Color': ['Red', 'Green', 'Blue', 'Green', 'Yellow', 'Purple']}) ID Color 0 ID001 Red 1 ID002 Green 2 ID003 Blue 3 ID004 Green 4 ID005 Yellow 5 ID006 Purple </code></pre> <p>And I'm trying to get this kind of Excel spreadsheet output :</p> <p><a href="https://i.stack.imgur.com/uGKFA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uGKFA.png" alt="enter image description here" /></a></p> <p>By using <a href="https://xlsxwriter.readthedocs.io/index.html" rel="nofollow noreferrer"><strong><code>xlsxwriter</code></strong></a>, the code below that I made has no effect :</p> <pre><code>with pd.ExcelWriter('TestColor_SpreadSheet.xlsx') as writer: df.to_excel(writer, index=False, sheet_name='TestWorksheet') workbook = writer.book worksheet = writer.sheets['TestWorksheet'] format_red = workbook.add_format({'bg_color':'#FF0000'}) worksheet.conditional_format('B1:B7', {'type': 'cell', 'criteria': '=', 'value': &quot;Red&quot;, 'format': format_red}) </code></pre> <p>Do you have any propositions please on how to do this conditionnal formating in <a href="https://xlsxwriter.readthedocs.io/index.html" rel="nofollow noreferrer"><strong><code>xlsxwriter</code></strong></a> or maybe even with pandas ?</p>
[ { "answer_id": 74276809, "author": "jprebys", "author_id": 3268228, "author_profile": "https://Stackoverflow.com/users/3268228", "pm_score": 3, "selected": true, "text": ">>> from matplotlib import colors\n>>> \n>>> colors.to_rgb('blue')\n(0.0, 0.0, 1.0)\n>>> \n>>> colors.to_hex('blue')\n'#0000ff'\n" }, { "answer_id": 74277301, "author": "abokey", "author_id": 16120011, "author_profile": "https://Stackoverflow.com/users/16120011", "pm_score": 1, "selected": false, "text": "import pandas as pd\nfrom matplotlib import colors\n\ndf = pd.DataFrame({'ID': ['ID001', 'ID002', 'ID003', 'ID004', 'ID005', 'ID006'],\n 'Color': ['Red', 'Green', 'Blue', 'Green', 'Yellow', 'Purple']})\n\n# ---- Retrieving HEXes with matplotlib\n\ndef to_hex(df):\n return colors.to_hex(df[\"Color\"])\n\ndf[\"HEX\"] = df.apply(to_hex, axis=1)\n\n# ---- Creating a dictionnary of color names and their HEX\n\ndf_colors = df.loc[:, [\"Color\", \"HEX\"]].drop_duplicates()\ndico_colors = dict(zip(df_colors[\"Color\"], df_colors[\"HEX\"]))\n\ndf.drop(columns=\"HEX\", inplace=True)\n\n# --- Formatting the Excel Spreadsheet\n\nwith pd.ExcelWriter('TestColor_SpreadSheet.xlsx') as writer:\n df.to_excel(writer, index=False, sheet_name='TestWorksheet')\n \n workbook = writer.book\n worksheet = writer.sheets['TestWorksheet']\n \n dico_format = {}\n for idx, row in df.iterrows():\n key = row['Color']\n dico_format['bg_color'] = dico_colors[key]\n cell_format = workbook.add_format(dico_format)\n worksheet.write(idx+1, 1, key, cell_format)\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276714", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16120011/" ]
74,276,748
<p>I have a enum like this:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>using System.ComponentModel; using System; using System.Collections.Generic; namespace eVote.Data.Enums { public enum Positions { CEO =1, ProductManager, CTO, SalesManager, FinanceManager, HR, Accountant } }</code></pre> </div> </div> </p> <p>When i use this enum in a AddAsync function i use like this:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code> &lt;div class="form-group"&gt; &lt;label asp-for="position"&gt;Function &lt;/label&gt; &lt;select asp-for="position" class="form-control" asp-items="Html.GetEnumSelectList&lt;Positions&gt;()" asp-for="position"&gt;&lt;/select&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <p>But, when i go to index, the position displayed is the id of position</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;td&gt;@candidate.position&lt;/td&gt;</code></pre> </div> </div> </p> <p>Any thoughts?? <a href="https://i.stack.imgur.com/U8dm4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/U8dm4.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74276809, "author": "jprebys", "author_id": 3268228, "author_profile": "https://Stackoverflow.com/users/3268228", "pm_score": 3, "selected": true, "text": ">>> from matplotlib import colors\n>>> \n>>> colors.to_rgb('blue')\n(0.0, 0.0, 1.0)\n>>> \n>>> colors.to_hex('blue')\n'#0000ff'\n" }, { "answer_id": 74277301, "author": "abokey", "author_id": 16120011, "author_profile": "https://Stackoverflow.com/users/16120011", "pm_score": 1, "selected": false, "text": "import pandas as pd\nfrom matplotlib import colors\n\ndf = pd.DataFrame({'ID': ['ID001', 'ID002', 'ID003', 'ID004', 'ID005', 'ID006'],\n 'Color': ['Red', 'Green', 'Blue', 'Green', 'Yellow', 'Purple']})\n\n# ---- Retrieving HEXes with matplotlib\n\ndef to_hex(df):\n return colors.to_hex(df[\"Color\"])\n\ndf[\"HEX\"] = df.apply(to_hex, axis=1)\n\n# ---- Creating a dictionnary of color names and their HEX\n\ndf_colors = df.loc[:, [\"Color\", \"HEX\"]].drop_duplicates()\ndico_colors = dict(zip(df_colors[\"Color\"], df_colors[\"HEX\"]))\n\ndf.drop(columns=\"HEX\", inplace=True)\n\n# --- Formatting the Excel Spreadsheet\n\nwith pd.ExcelWriter('TestColor_SpreadSheet.xlsx') as writer:\n df.to_excel(writer, index=False, sheet_name='TestWorksheet')\n \n workbook = writer.book\n worksheet = writer.sheets['TestWorksheet']\n \n dico_format = {}\n for idx, row in df.iterrows():\n key = row['Color']\n dico_format['bg_color'] = dico_colors[key]\n cell_format = workbook.add_format(dico_format)\n worksheet.write(idx+1, 1, key, cell_format)\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17958040/" ]
74,276,758
<p>I'm working on a project using Git for versioning. I'm now working on a feature in a different branch. I have not completed my changes but I need to switch to a different branch from master branch. I have tried to stash my changes with</p> <pre><code>git stash </code></pre> <p>But it's not stashing my changes.</p> <p>I checked with</p> <pre><code>git stash list git status </code></pre>
[ { "answer_id": 74276805, "author": "sanurah", "author_id": 4079056, "author_profile": "https://Stackoverflow.com/users/4079056", "pm_score": 2, "selected": true, "text": "git add .\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276758", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20388357/" ]
74,276,764
<p>Can we use eval() to get multiple data ?</p> <p>Can we get three data like : <code>a , b , c = map(float , float(input().split(' '))</code> But i want these data are different by using eval()</p>
[ { "answer_id": 74276805, "author": "sanurah", "author_id": 4079056, "author_profile": "https://Stackoverflow.com/users/4079056", "pm_score": 2, "selected": true, "text": "git add .\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276764", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19066053/" ]
74,276,823
<p>I tried this code to implement the autoplay video feature without the control bars but the issue that I faced was, the video was not autoplaying after refreshing the page. this project is in react. even after adding an autoplay attribute, the video is not autoplaying. what's the mistake am I doing?</p> <p>I expect it to be autoplaying even after refreshing the page</p> <p>I tried this code to implement the autoplay video feature without the control bars but the issue that I faced was, the video was not autoplaying after refreshing the page. this project is in react. even after adding an autoplay attribute, the video is not autoplaying. whats the mistake am I doing?</p> <pre class="lang-html prettyprint-override"><code>&lt;video id=&quot;coinSaverIcon&quot; autoPlay playsInline&gt; &lt;source src={coinsaverIcon} type=&quot;video/webm&quot; /&gt; &lt;/video&gt; </code></pre>
[ { "answer_id": 74276805, "author": "sanurah", "author_id": 4079056, "author_profile": "https://Stackoverflow.com/users/4079056", "pm_score": 2, "selected": true, "text": "git add .\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276823", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
74,276,844
<p>I am very new in javascript and currently trying to read the value <code>newMap</code> but don't know, who do I read the values of Map?</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>const map1 = new Map(); map1.set('usagesUnkown', 10); map1.set('usagesUnkown2', 10); const newMap = new Map(); newMap.set("anoop",map1);</code></pre> </div> </div> </p> <p>I have already try these answer <a href="https://stackoverflow.com/questions/62901570/how-to-use-javascript-map-method-to-access-nested-objects">text</a> but nothing is working.</p>
[ { "answer_id": 74276805, "author": "sanurah", "author_id": 4079056, "author_profile": "https://Stackoverflow.com/users/4079056", "pm_score": 2, "selected": true, "text": "git add .\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276844", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5402072/" ]
74,276,852
<p>How to add options choice for this code for pine script?</p> <p>instead of this code :</p> <pre><code>distance = input.int(250, 'Time range', minval=5, step=10) </code></pre> <p>to :</p> <pre><code>distance = input.string(defval = '100', title = 'distance', options = ['100', '200', '300' , '500'], group = 'Settings') </code></pre> <p>To make supports and resistances by selecting &quot;Time Range&quot; &quot;Sensitivity&quot;</p> <p>as you see it at picture:</p> <p><a href="https://i.stack.imgur.com/bxOsJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bxOsJ.png" alt="enter image description here" /></a></p> <p><a href="https://i.stack.imgur.com/HU0qI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HU0qI.png" alt="enter image description here" /></a></p> <p>I think the indicator already there at tradingview but i don't find it..</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>//@version=5 indicator('Classic_Levels', overlay=true) // number of candles used distance = input.int(250, 'Time range', minval=5, step=10) // sensitivity when searching levels sensitivity = input.float(1, 'Sensitivity', minval=0.1, step=0.1) // weight coefficients float wOpenClose = 1 float wHighLow = 0.5 float wCross = 0.5 // number of intervals int n_intervals = 300 // block size (in intervals) int block_size = 11 // minimum and maximum values float min_value = barstate.islast ? low[-ta.lowestbars(distance)] : 0 float max_value = barstate.islast ? high[-ta.highestbars(distance)] : 0 // recalculate sensitivity according to the weights float sens = barstate.islast ? 2 / (sensitivity * (wOpenClose + wHighLow + wCross)) : 0 // calculate everything on the last bar if barstate.islast // number of "key points" falling into each interval // last element is stored but not used m = array.new_int(n_intervals + 1, 0) // sum of the "scores" of the points falling into each interval // last element is stored but not used r = array.new_float(n_intervals + 1, 0) // sums of the interval forming the block a = array.new_float(block_size, 0) // declaring variables int i_close = na int i_open = na int i_high = na int i_low = na int mn = na int mx = na float interval_size = (max_value - min_value) / float(n_intervals) // populate arrays r, m for k = 1 to distance - 1 by 1 i_close := math.floor((close[k] - min_value) / interval_size) i_open := math.floor((open[k] - min_value) / interval_size) i_high := math.floor((high[k] - min_value) / interval_size) i_low := math.floor((low[k] - min_value) / interval_size) array.set(r, i_close, array.get(r, i_close) + wOpenClose) array.set(r, i_open, array.get(r, i_open) + wOpenClose) array.set(r, i_high, array.get(r, i_high) + wHighLow) array.set(r, i_low, array.get(r, i_low) + wHighLow) array.set(m, i_close, array.get(m, i_close) + 1) array.set(m, i_open, array.get(m, i_open) + 1) array.set(m, i_high, array.get(m, i_high) + 1) array.set(m, i_low, array.get(m, i_low) + 1) // if current candle crosses the interval if math.abs(i_open - i_close) &gt;= 2 mn := math.min(i_open, i_close) mx := math.max(i_open, i_close) for i = mn + 1 to mx - 1 by 1 array.set(r, i, array.get(r, i) - wCross) array.set(m, i, array.get(m, i) + 1) // current block sum float cur_block = 0 // last extremum float extr_block = 0 // number of the first interval of extremum block int extr_val = 0 // level value float level_val = 0 // initial state: level search bool state = false // current interval sum float cur_sum = 0 // iterate intervals for i = 0 to n_intervals + block_size - 2 by 1 // shift all the interval sums array.shift(a) if i &lt; n_intervals array.push(a, array.get(r, i) / array.get(m, i)) else array.push(a, 0) // current block sum cur_block := array.sum(a) // check state if not state // searching level: &lt;extr_block&gt; keeps the last maximum if i == 0 or cur_block &gt; extr_block extr_block := cur_block extr_val := i - block_size + 1 extr_val else // if we've gone far enough from the maximum downwards if extr_block - cur_block &gt;= sens or i == n_intervals - 1 // draw level level_val := min_value + interval_size * (extr_val + float(block_size) / 2) line.new(bar_index - 1, level_val, bar_index, level_val, style=line.style_solid, extend=extend.both, color=color.blue, width=1) extr_block := cur_block extr_val := i - block_size + 1 state := true state else // level is found: &lt;extr_block&gt; keeps the last minimum if cur_block &lt; extr_block extr_block := cur_block extr_val := i - block_size + 1 extr_val else // if we've gone far enough from the minimum upwards if cur_block - extr_block &gt;= sens extr_block := cur_block extr_val := i - block_size + 1 state := false state plotshape(barstate.islast, style=shape.circle, color=color.new(color.navy, 0), size=size.tiny, offset=-distance)</code></pre> </div> </div> </p>
[ { "answer_id": 74276805, "author": "sanurah", "author_id": 4079056, "author_profile": "https://Stackoverflow.com/users/4079056", "pm_score": 2, "selected": true, "text": "git add .\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276852", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18627449/" ]
74,276,855
<p>I have a list of numpy arrays, which consists of all possible configurations of 0 and 1 in a 10-pixel arrays. I'm trying to determine the number of arrays that have specific group of 1s for more than two 1s. For example, the array is [1,0,0,1,1,1,1,1,0,1]. I want to determine this array has five 1s as a block. Another example, the array is [1,1,1,0,1,1,1,1,1,1]. I want to find the block as six 1s instead of three 1s block. I couldn't find a way to do this.</p> <p>Here is the code I generate the list of all possible arrays:</p> <pre><code>import numpy as np from itertools import product all_arrays = np.array(list(product([0,1], repeat=10))) </code></pre>
[ { "answer_id": 74276805, "author": "sanurah", "author_id": 4079056, "author_profile": "https://Stackoverflow.com/users/4079056", "pm_score": 2, "selected": true, "text": "git add .\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276855", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15162114/" ]
74,276,858
<p>I'm having trouble solving the Concatenate Error when it's present in a Tkinter Window. I tried using multiple methods but, they didn't work to well with what I'm trying to do. I'm trying to make it so where, at the click of a Tkinter button, it would randomly choose a value between 0 and 100. If the random value is less than or equal to 70, both &quot;Good Guy&quot; and &quot;Bad Guy&quot; would have their health reduced. But if it's greater than 70, Good guy would only take damage. It would then print their new hp into the window.</p> <pre><code>from random import randrange class App5(tk.Toplevel): def __init__(self, title: str): super().__init__() self.title(title) self.style = ttk.Style(self) self.style.theme_use(&quot;classic&quot;) self.geometry(&quot;490x250&quot;) self.tres_label = ttk.Label( self, text=&quot;Oh yeah, also while you were doing that, I enrolled you into a tournament. \nHave fun........what? Why did I sign you up for a tournament you didn't ask for? \nTo increase the total run time on this project.&quot;, ) self.tres_label.grid(row=0, column=0, padx=5, pady=5) self.rng_button = ttk.Button(self, text=&quot;Click Me&quot;, command=self.rng) self.rng_button.grid(row=2, column=0, padx=5, pady=5) def rng(self): class Character: def __init__(self, name: str, hp: int, damage: int): self.name = name self.hp = hp self.damage = damage Goodguy = Character(&quot;Goodguy&quot;, 300, 75) Badguy = Character(&quot;Badguy&quot;, 375, 25) score = 70 num = randrange(0, 100) G = Goodguy.hp - Badguy.damage B = Badguy.hp - Goodguy.damage if num &gt;= score: Goodguy.hp - Badguy.damage Badguy.hp - Goodguy.damage self.good = ttk.Label(self, text=&quot;Goodguy Hp:&quot; + G) self.good.grid(row=3, column=3) self.bad = ttk.Label(self, text=&quot;BadGuy Hp:&quot; + B) self.bad.grid(row=3, column=6) B = B - Goodguy.damage G = G - Badguy.damage else: Goodguy.hp - Badguy.damage self.good = ttk.Label(self, text=&quot;Goodguy Hp:&quot; + G) self.good.grid(row=3, column=3) self.bad = ttk.Label(self, text=&quot;BadGuy Hp:&quot; + B) self.bad.grid(row=3, column=6) B = B - Goodguy.damage G = G - Badguy.damage </code></pre>
[ { "answer_id": 74276901, "author": "vencaslac", "author_id": 7904315, "author_profile": "https://Stackoverflow.com/users/7904315", "pm_score": 1, "selected": true, "text": "self.good = ttk.Label(self, text=\"Goodguy Hp:\" + G)\n" }, { "answer_id": 74276903, "author": "AKX", "author_id": 51685, "author_profile": "https://Stackoverflow.com/users/51685", "pm_score": 2, "selected": false, "text": "\"Goodguy Hp:\" + G\n" }, { "answer_id": 74277913, "author": "Aarav ", "author_id": 17317309, "author_profile": "https://Stackoverflow.com/users/17317309", "pm_score": 0, "selected": false, "text": "can only concatenate str (not \"int\") to str\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276858", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20361152/" ]
74,276,872
<pre><code>import java.util.*; import java.util.Map.Entry; public class fff2 { public static void main(String[] args) throws NullPointerException{ try { LinkedHashMap&lt;String, Integer&gt; score = new LinkedHashMap&lt;String,Integer&gt;(); score.put(&quot;Fail&quot;,39); score.put(&quot;Third Class&quot;, 49); score.put(&quot;Second Class, Division 2&quot;,59); score.put(&quot;Second Class, Division 1&quot;,69); score.put(&quot;First Class&quot;,70); Scanner scan = new Scanner(System.in); System.out.println(&quot;What was your mark?&quot;); int mark = scan.nextInt(); if(mark &gt;100 &amp;&amp; mark &lt; 0) { System.out.println(&quot;Invalid Input: out of range.&quot;); } for(String i: score.keySet()) { if(mark&lt; score.get(i)) { System.out.println(&quot;You got a &quot;+i); break; } } } catch(InputMismatchException e) { System.out.println(&quot;Invalid Input, program terminating&quot;); } } </code></pre> <p>So I am trying to make a grading system but it isn't working can i have some help please? I am trying to make it so that a mark of 40 is a pass as a third class but i want to use a hashmap to challenge myself as opposed to the switch case.</p>
[ { "answer_id": 74276901, "author": "vencaslac", "author_id": 7904315, "author_profile": "https://Stackoverflow.com/users/7904315", "pm_score": 1, "selected": true, "text": "self.good = ttk.Label(self, text=\"Goodguy Hp:\" + G)\n" }, { "answer_id": 74276903, "author": "AKX", "author_id": 51685, "author_profile": "https://Stackoverflow.com/users/51685", "pm_score": 2, "selected": false, "text": "\"Goodguy Hp:\" + G\n" }, { "answer_id": 74277913, "author": "Aarav ", "author_id": 17317309, "author_profile": "https://Stackoverflow.com/users/17317309", "pm_score": 0, "selected": false, "text": "can only concatenate str (not \"int\") to str\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276872", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12768004/" ]
74,276,891
<p>I have an object in my state. Then I'm adding values dynamically and it can look something like this:</p> <pre><code>{ 2311: 2 } </code></pre> <p>How can I override that <code>2311</code> value if it already exists without mutating the state.</p> <p>Adding a new value is simple. I have an object <code>obj = { prop: val}</code> and then <code>{ ...this.state.obj, obj }</code> but I can't remember how can I change the <code>obj</code> value that is dynamic.</p> <p>I know that I can do deep copy using lodash or something, change that specific value and I' done but I want to know how to do that the way I described above.</p> <p>Thanks for any help.</p>
[ { "answer_id": 74276958, "author": "Guilhermo Masid", "author_id": 13367336, "author_profile": "https://Stackoverflow.com/users/13367336", "pm_score": 0, "selected": false, "text": "let obj = {test: 23, test2: 24, 2311: 2};\nobj = {...obj, 2311: \"new value\"}\nconsole.log(obj);" }, { "answer_id": 74277804, "author": "Thirunahari ManindraTeja", "author_id": 6208440, "author_profile": "https://Stackoverflow.com/users/6208440", "pm_score": 1, "selected": false, "text": "Object.assign(obj, { 2311: 'new value' })\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276891", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20388560/" ]
74,276,900
<p>Life has been tough on me lately. I have tried to scrape a website (<a href="https://osf.io/preprints/discover?subject=bepress%7CSocial%20and%20Behavioral%20Sciences" rel="nofollow noreferrer">https://osf.io/preprints/discover?subject=bepress%7CSocial%20and%20Behavioral%20Sciences</a>) with some of the HTML code below for a week now and have tried multiple things to get it to work. I need the div ID <code>ember499</code> all the way at the bottom. This div is the one that contains the whole website, and if I cant access it, I cant scrape anything. There are 4 divs in the main body tag, <code>MaxJax_Message</code>, <code>ember-bootstrap-wormhole</code>, <code>ember-basic-dropdown-wormhole</code> and <code>ember499</code> as seen below:</p> <pre class="lang-html prettyprint-override"><code> &lt;body class=&quot;ember-application&quot;&gt; &lt;div id=&quot;MathJax_Message&quot; style=&quot;display: none;&quot;&gt;&lt;/div&gt; &lt;noscript&gt; &lt;p&gt; For full functionality of this site it is necessary to enable JavaScript. Here are &lt;a href='https://www.enable-javascript.com/' target='_blank'&gt; instructions for enabling JavaScript in your web browser&lt;/a&gt;. &lt;/p&gt; &lt;/noscript&gt; &lt;script&gt; window.prerenderReady = false; &lt;/script&gt; &lt;script src=&quot;//cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js&quot;&gt;&lt;/script&gt; &lt;script src=&quot;//cdnjs.cloudflare.com/ajax/libs/ember.js/2.18.0/ember.min.js&quot;&gt;&lt;/script&gt; &lt;script&gt; (function() { var encodedConfig = document.head.querySelector(&quot;meta[name$='/config/environment']&quot;).content; var config = JSON.parse(unescape(encodedConfig)); var assetSuffix = config.ASSET_SUFFIX ? '-' + config.ASSET_SUFFIX : ''; var origin = window.location.origin; window.isProviderDomain = !~config.OSF.url.indexOf(origin); var prefix = '/' + (window.isProviderDomain ? '' : 'preprints/') + 'assets/'; [ 'vendor', 'preprint-service' ].forEach(function (name) { var script = document.createElement('script'); script.src = prefix + name + assetSuffix + '.js'; script.async = false; document.body.appendChild(script); var link = document.createElement('link'); link.rel = 'stylesheet'; link.href = prefix + name + assetSuffix + '.css'; document.head.appendChild(link); }); })(); &lt;/script&gt;&lt;script src=&quot;/preprints/assets/vendor-f46d275519d6cf7078493fc4564ccd3c7dc419ed.js&quot;&gt;&lt;/script&gt;&lt;script src=&quot;/preprints/assets/preprint-service-f46d275519d6cf7078493fc4564ccd3c7dc419ed.js&quot;&gt;&lt;/script&gt; &lt;script src=&quot;https://cdn.ravenjs.com/3.22.1/ember/raven.min.js&quot;&gt;&lt;/script&gt; &lt;script&gt; var encodedConfig = document.head.querySelector(&quot;meta[name$='/config/environment']&quot;).content; var config = JSON.parse(unescape(encodedConfig)); if (config.sentryDSN) { Raven.config(config.sentryDSN, config.sentryOptions || {}).install(); } &lt;/script&gt; &lt;div id=&quot;ember-basic-dropdown-wormhole&quot;&gt;&lt;/div&gt; &lt;div id=&quot;ember-bootstrap-wormhole&quot;&gt;&lt;/div&gt; &lt;div id=&quot;ember499&quot; class=&quot;ember-view&quot;&gt; &lt;!----&gt; &lt;div id=&quot;ember538&quot; class=&quot;__new-osf-navbar__b7554 ember-view&quot;&gt;&lt;div class=&quot;osf-nav-wrapper&quot;&gt; &lt;nav id=&quot;navbarScope&quot; role=&quot;navigation&quot; class=&quot;navbar navbar-inverse navbar-fixed-top&quot;&gt; &lt;div class=&quot;container&quot;&gt; &lt;div class=&quot;navbar-header&quot;&gt; &lt;a href=&quot;/&quot; aria-label=&quot;Go home&quot; class=&quot;navbar-brand&quot;&gt; &lt;span class=&quot;osf-navbar-logo&quot;&gt;&lt;/span&gt; &lt;/a&gt; &lt;div class=&quot;service-name&quot;&gt; &lt;a href=&quot;https://osf.io/preprints/&quot;&gt; &lt;span class=&quot;hidden-xs&quot;&gt; OSF &lt;/span&gt; </code></pre> <p>I have tried printing all of the divs that are contained in the main body for example:</p> <pre class="lang-py3 prettyprint-override"><code>wormhole = driver.find_element(By.CLASS_NAME, 'ember-application') divs = wormhole.find_elements(By.TAG_NAME, 'div') </code></pre> <p>I have tried finding via <code>XPATH</code>, <code>ID</code>, more or less everything. When I print the ID of each div and append it into a list I get this: <code>['MathJax_Message', 'ember-basic-dropdown-wormhole', 'ember-bootstrap-wormhole']</code> Funnily enough, when I print <code>len(divs)</code> i get 3 back, but when I dont append them into a list it takes an extra 2-3 seconds to finish executing once it reaches <code>div[3]</code>, this generally does not tend to happen with other sites:</p> <pre><code>OUTPUT MathJax_Message ember-basic-dropdown-wormhole ember-bootstrap-wormhole Process finished with exit code 0 </code></pre> <p>I have tried scrolling to the middle of the page in case its hidden, finding out what is in each of the 3 divs above it, going directly to the class names that I want, finding all elements of the webpage using <code>find_elements(By.XPATH, '//*')</code>. They all either only return the same 3 divs mentioned above, or they say 'element not found'. I cant think of what else to do/try.</p> <p>Please guide me Stack Gods.</p>
[ { "answer_id": 74276958, "author": "Guilhermo Masid", "author_id": 13367336, "author_profile": "https://Stackoverflow.com/users/13367336", "pm_score": 0, "selected": false, "text": "let obj = {test: 23, test2: 24, 2311: 2};\nobj = {...obj, 2311: \"new value\"}\nconsole.log(obj);" }, { "answer_id": 74277804, "author": "Thirunahari ManindraTeja", "author_id": 6208440, "author_profile": "https://Stackoverflow.com/users/6208440", "pm_score": 1, "selected": false, "text": "Object.assign(obj, { 2311: 'new value' })\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276900", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12206418/" ]
74,276,907
<p>I am trying to send the output of a linux command as an input to variable. Here is the command I tried</p> <pre><code>cat init.txt | grep glal20213lvdlb04 glal13lvd </code></pre> <p>The output of this should go into &quot;vm_name&quot; of the yml file. The yml file will look like this.</p> <pre><code>vim instant.yml </code></pre> <pre><code>resources: instance01: type: ../../../templates/ipnf.yaml properties: vm_name: 'THE OUTPUT SHOULD COME HERE' vm_flavour: 'dsolate' image_name: 'pdns_14121207' vm_az: 'az-1' vm_disk_root_size: '50' vm_disk_data_size: '50' network_mgmt_refs: 'int:dxs_pcg' network_mgmt_ip: '10.194.112.75' </code></pre> <p>Any help would be appreciated</p>
[ { "answer_id": 74276958, "author": "Guilhermo Masid", "author_id": 13367336, "author_profile": "https://Stackoverflow.com/users/13367336", "pm_score": 0, "selected": false, "text": "let obj = {test: 23, test2: 24, 2311: 2};\nobj = {...obj, 2311: \"new value\"}\nconsole.log(obj);" }, { "answer_id": 74277804, "author": "Thirunahari ManindraTeja", "author_id": 6208440, "author_profile": "https://Stackoverflow.com/users/6208440", "pm_score": 1, "selected": false, "text": "Object.assign(obj, { 2311: 'new value' })\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276907", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13334309/" ]
74,276,909
<p>I am doing a bit of a scraping project where I am scraping some data file information. The issue is that the response is a string that is sometimes in kB, MB, GB etc. What I need is to convert the response I get to MB and drop the text part eg. <code>290.5kB</code> should return <code>0.29</code> without <code>MB</code> at the end. The scraped section looks like this: <code>Format: MapInfo MIF, (290.5 kB)</code> Here is my code snippet:</p> <pre><code>f_file_size = file_format.split('Format: ')[1].split(',')[1].strip(' ()') output_dict['data_files'].append({'file_size': f_file_size}) </code></pre> <p>Which outputs:</p> <pre><code>&quot;data_files&quot; : [{ &quot;file_size&quot;: &quot;290.5 kB&quot; }] </code></pre> <p>Your assistance will be highly appreciated</p>
[ { "answer_id": 74276958, "author": "Guilhermo Masid", "author_id": 13367336, "author_profile": "https://Stackoverflow.com/users/13367336", "pm_score": 0, "selected": false, "text": "let obj = {test: 23, test2: 24, 2311: 2};\nobj = {...obj, 2311: \"new value\"}\nconsole.log(obj);" }, { "answer_id": 74277804, "author": "Thirunahari ManindraTeja", "author_id": 6208440, "author_profile": "https://Stackoverflow.com/users/6208440", "pm_score": 1, "selected": false, "text": "Object.assign(obj, { 2311: 'new value' })\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276909", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19166212/" ]
74,276,935
<p>I am using Textformfield in flutter it is working fine in android but not in IOS , in IOS need done button . I want to display a numeric keyboard with done button in IOS. Here is my code ..</p> <pre><code>TextFormField( controller: inputminsto1, style: TextStyle(color: Color(0xFF070A28).withOpacity(0.50),fontFamily: 'OpenSans', fontSize:14), decoration: InputDecoration( //icon of text field //labelText: 'Mins',labelStyle: TextStyle(color: Color(0xFF070A28).withOpacity(0.50),fontFamily: 'OpenSans', fontSize:14), //label text of field filled: true, fillColor: Color(0xFFF6F6F6), border: InputBorder.none, hintText: 'Mins', hintStyle: TextStyle(color: Color(0xFF070A28).withOpacity(0.50),fontFamily: 'OpenSans', fontSize:14), ), validator: (value) { if (value!.isEmpty) { return 'Required *'; } return null; }, textInputAction: TextInputAction.done, inputFormatters: &lt;TextInputFormatter&gt;[ LengthLimitingTextInputFormatter(3), FilteringTextInputFormatter.digitsOnly, FilteringTextInputFormatter.deny( RegExp(r'\s')) ], // Only numbers can be entered ), </code></pre>
[ { "answer_id": 74276958, "author": "Guilhermo Masid", "author_id": 13367336, "author_profile": "https://Stackoverflow.com/users/13367336", "pm_score": 0, "selected": false, "text": "let obj = {test: 23, test2: 24, 2311: 2};\nobj = {...obj, 2311: \"new value\"}\nconsole.log(obj);" }, { "answer_id": 74277804, "author": "Thirunahari ManindraTeja", "author_id": 6208440, "author_profile": "https://Stackoverflow.com/users/6208440", "pm_score": 1, "selected": false, "text": "Object.assign(obj, { 2311: 'new value' })\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15338351/" ]
74,276,947
<p>I want to Create Azure Build pipelines using Terraform code, but not able to find any proper documentation on this. Is it possible ?</p> <p>I tried terraform documentation, expecting some documentation or video guide how to create Azure build pipelines using terraform code</p>
[ { "answer_id": 74276958, "author": "Guilhermo Masid", "author_id": 13367336, "author_profile": "https://Stackoverflow.com/users/13367336", "pm_score": 0, "selected": false, "text": "let obj = {test: 23, test2: 24, 2311: 2};\nobj = {...obj, 2311: \"new value\"}\nconsole.log(obj);" }, { "answer_id": 74277804, "author": "Thirunahari ManindraTeja", "author_id": 6208440, "author_profile": "https://Stackoverflow.com/users/6208440", "pm_score": 1, "selected": false, "text": "Object.assign(obj, { 2311: 'new value' })\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276947", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20102892/" ]
74,276,961
<p>I have a very large list of dictionaries that looks like this (I show a simplified version):</p> <pre><code>list_of_dicts: [{'ID': 1234, 'Name': 'Bobby', 'Animal': 'Dog', 'About': [{'ID': 5678, 'Food': 'Dog Food'}]}, {'ID': 5678, 'Food': 'Dog Food'}, {'ID': 91011, 'Name': 'Jack', 'Animal': 'Bird', 'About': [{'ID': 1996, 'Food': 'Seeds'}]}, {'ID': 1996, 'Food': 'Seeds'}, {'ID': 2007, 'Name': 'Bean', 'Animal': 'Cat', 'About': [{'ID': 2008, 'Food': 'Fish'}]}, {'ID': 2008, 'Food': 'Fish'}] </code></pre> <p>I'd like to remove the dictionaries containing IDs that are equal to the ID's nested in the 'About' entries. For example, 'ID' 2008, is already nested in the nested 'About' value, therefore I'd like to remove that dictionary.</p> <p>I have some code that can do this, and for this specific example it works. However, the amount of data that I have is much larger, and the remove() function does not seem to remove all the entries unless I run it a couple of times.</p> <p>Any suggestions on how I can do this better?</p> <p>My code:</p> <pre><code>nested_ids = [5678, 1996, 2008] for i in list_of_dicts: if i['ID'] in nested_ids: list_of_dicts.remove(i) </code></pre> <p>Desired output:</p> <pre><code>[{'ID': 1234, 'Name': 'Bobby', 'Animal': 'Dog', 'About': [{'ID': 5678, 'Food': 'Dog Food'}]}, {'ID': 91011, 'Name': 'Jack', 'Animal': 'Bird', 'About': [{'ID': 1996, 'Food': 'Seeds'}]}, {'ID': 2007, 'Name': 'Bean', 'Animal': 'Cat', 'About': [{'ID': 2008, 'Food': 'Fish'}]}] </code></pre>
[ { "answer_id": 74277019, "author": "vencaslac", "author_id": 7904315, "author_profile": "https://Stackoverflow.com/users/7904315", "pm_score": 1, "selected": false, "text": "for i in list_of_dicts[::-1]:\n" }, { "answer_id": 74277032, "author": "ditev", "author_id": 20388626, "author_profile": "https://Stackoverflow.com/users/20388626", "pm_score": 2, "selected": false, "text": "filtered_dicts = []\nnested_ids = [5678, 1996, 2008]\nfor curr in list_of_dicts:\n if curr['ID'] not in nested_ids:\n filtered_dicts.append(curr)\n" }, { "answer_id": 74277039, "author": "jprebys", "author_id": 3268228, "author_profile": "https://Stackoverflow.com/users/3268228", "pm_score": 3, "selected": true, "text": "cleaned_list = [d for d in list_of_dicts if d['ID'] not in nested_ids]\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276961", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12368010/" ]
74,276,962
<p>I am using NetTopologySuite with C# to filter points inside the precise boundaries of a country with a pretty simple way:</p> <pre><code>var path = &quot;fr.shp&quot;; // &quot;big&quot; country and boundaries need to be precise in my case var reader = new ShapeDataReader(path); var mbr = reader.ShapefileBounds; var result = reader.ReadByMBRFilter(mbr); var polygons = new List&lt;Geometry&gt;(); using (var coll = result.GetEnumerator()) { while (coll.MoveNext()) { var item = coll.Current; if (item == null) { continue; } polygons.Add(item.Geometry); } } var polygon = new GeometryCombiner(polygons).Combine(); var points = new List&lt;Point&gt;(); List&lt;Point&gt; pointsToFilterWithBorders; // loaded from DB, not visible here but we have 1,350,000 points to filter Parallel.ForEach(pointsToFilterWithBorders, point =&gt; { if (polygon.Contains(point)) points.Add(point); }); </code></pre> <p>It's working fine (filtering works great!) but it's pretty slow... like one day to do the filtering for only 1,350,000 points!</p> <p>Any idea on how to improve that?</p> <p>I tried to use Parallel.ForEach but still very long and I tried to find something like a &quot;batch&quot; compare in NetTopologySuite but couldn't find a quicker solution to filter my points in this big shapefile...</p>
[ { "answer_id": 74277019, "author": "vencaslac", "author_id": 7904315, "author_profile": "https://Stackoverflow.com/users/7904315", "pm_score": 1, "selected": false, "text": "for i in list_of_dicts[::-1]:\n" }, { "answer_id": 74277032, "author": "ditev", "author_id": 20388626, "author_profile": "https://Stackoverflow.com/users/20388626", "pm_score": 2, "selected": false, "text": "filtered_dicts = []\nnested_ids = [5678, 1996, 2008]\nfor curr in list_of_dicts:\n if curr['ID'] not in nested_ids:\n filtered_dicts.append(curr)\n" }, { "answer_id": 74277039, "author": "jprebys", "author_id": 3268228, "author_profile": "https://Stackoverflow.com/users/3268228", "pm_score": 3, "selected": true, "text": "cleaned_list = [d for d in list_of_dicts if d['ID'] not in nested_ids]\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276962", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2771594/" ]
74,276,983
<p>How can I implement a functioning tab-navigation behavior?</p> <p>What I want to achieve is a underlying animated bar for each navigation-item that has been clicked.</p> <p>The transition-related styling is supposed to be based on css pseudo-elements.</p> <p>Below is the markup and the css-rules I came up with so far.</p> <p>What am I missing in my code? How could the approach be fixed?</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>li::after { border-radius: 2px; border-bottom: red solid 3px; transition: all .3s ease-in-out; } li::before { content: ""; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;nav&gt; &lt;ul class="nav_link"&gt; &lt;strong&gt; &lt;li onclick="tabs('avisos')"&gt;Avisos&lt;/li&gt; &lt;li onclick="tabs('atividades')"&gt;Atividades&lt;/li&gt; &lt;li onclick="tabs('trabalhos')"&gt;Trabalhos&lt;/li&gt; &lt;li onclick="tabs('provas')"&gt;Provas&lt;/li&gt; &lt;li onclick="tabs('aulas')"&gt;Aulas&lt;/li&gt; &lt;/strong&gt; &lt;/ul&gt; &lt;/nav&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74277023, "author": "Simmetric", "author_id": 1738491, "author_profile": "https://Stackoverflow.com/users/1738491", "pm_score": -1, "selected": false, "text": "li:active" }, { "answer_id": 74277720, "author": "Peter Seliger", "author_id": 2627243, "author_profile": "https://Stackoverflow.com/users/2627243", "pm_score": 0, "selected": false, "text": "::after" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276983", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19483853/" ]
74,276,989
<p>Scipy and numpy standard deviation methods give slightly different results. I don't understand why. Can anyone explain that to me?</p> <p>Here is an example.</p> <pre><code>import numpy as np import scipy.stats ar = np.arange(20) print(np.std(ar)) print(scipy.stats.tstd(ar)) </code></pre> <p>returns</p> <pre><code>5.766281297335398 5.916079783099616 </code></pre>
[ { "answer_id": 74277073, "author": "Bhargav", "author_id": 15358800, "author_profile": "https://Stackoverflow.com/users/15358800", "pm_score": 2, "selected": false, "text": "import numpy as np\nimport scipy.stats\nar = np.arange(20)\nprint(np.std(ar, ddof=1))\nprint(scipy.stats.tstd(ar))\n" }, { "answer_id": 74277119, "author": "T C Molenaar", "author_id": 8814131, "author_profile": "https://Stackoverflow.com/users/8814131", "pm_score": 3, "selected": true, "text": "np.std()" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276989", "https://Stackoverflow.com", "https://Stackoverflow.com/users/448521/" ]
74,276,991
<blockquote> <p>Write a method/function with name cpSeries that computes the nth element in a series of numbers, given by the formula: a(n) = (a(n-1))2+a(n-2) when: n&gt;1 and assuming that: a(1)=1, a(0)=0 Note that indexing of the series starts from 0.</p> </blockquote> <p>I have already written the above code but it runs for an infinite time and I don't know how to fix it in order to compute the nth element.</p> <p>Any ideas? I have to use only functions to solve this problem.</p> <pre><code># include &lt;stdio.h&gt; int cpSeries(int n) { int Nthterm = 0; int i; if (n==0) { cpSeries(0) == 0; } else if (n==1) { cpSeries(1) == 1; } for (i=0; i&lt;=n; i++){ Nthterm = cpSeries((n-1))*cpSeries((n-1)) + cpSeries((n-2)); return Nthterm; } } int main() { int n=6; printf(&quot;The Nth term of the series is: %d&quot;,cpSeries(n)); } </code></pre>
[ { "answer_id": 74277096, "author": "Mateo Vozila", "author_id": 17571431, "author_profile": "https://Stackoverflow.com/users/17571431", "pm_score": 0, "selected": false, "text": "if (n==0) {\n cpSeries(0) == 0;\n}\nelse if (n==1) {\n cpSeries(1) == 1;\n}\n" }, { "answer_id": 74277121, "author": "mkrieger1", "author_id": 4621513, "author_profile": "https://Stackoverflow.com/users/4621513", "pm_score": 0, "selected": false, "text": "y" }, { "answer_id": 74277367, "author": "LeKalan", "author_id": 14534275, "author_profile": "https://Stackoverflow.com/users/14534275", "pm_score": 2, "selected": true, "text": "int cpSeries(int n){\n \n int Nthterm;\n \n if (n==0){\n \n Nthterm = 0;\n }\n else if (n==1){\n \n Nthterm = 1;\n }\n else {\n\n Nthterm = cpSeries((n-1))*cpSeries((n-1)) + cpSeries((n-2)); \n }\n\n return Nthterm; \n}\n\n\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74276991", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19279395/" ]
74,277,009
<p>I'm making a program that needs to validate that certain data is in json format. What's in the json does not mater and will change each time a user runs the program. Could anyone provide examples of ways to validate that data is in a json format?</p> <p>Currently attempting to use the jsonschema library.</p>
[ { "answer_id": 74277096, "author": "Mateo Vozila", "author_id": 17571431, "author_profile": "https://Stackoverflow.com/users/17571431", "pm_score": 0, "selected": false, "text": "if (n==0) {\n cpSeries(0) == 0;\n}\nelse if (n==1) {\n cpSeries(1) == 1;\n}\n" }, { "answer_id": 74277121, "author": "mkrieger1", "author_id": 4621513, "author_profile": "https://Stackoverflow.com/users/4621513", "pm_score": 0, "selected": false, "text": "y" }, { "answer_id": 74277367, "author": "LeKalan", "author_id": 14534275, "author_profile": "https://Stackoverflow.com/users/14534275", "pm_score": 2, "selected": true, "text": "int cpSeries(int n){\n \n int Nthterm;\n \n if (n==0){\n \n Nthterm = 0;\n }\n else if (n==1){\n \n Nthterm = 1;\n }\n else {\n\n Nthterm = cpSeries((n-1))*cpSeries((n-1)) + cpSeries((n-2)); \n }\n\n return Nthterm; \n}\n\n\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74277009", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20232234/" ]
74,277,026
<p>I tried diferent technics but still don't get it. This function is in a class Player() so it moves the player from left to right automatically</p> <pre><code> def move(self): dx = 0 dy = 0 # CHECKING THE RECT IF HAS HIT THE BORDERS if self.rect.left + dx &lt; 0: pass # CHANGING DIRECTION TO RIGHT if self.rect.right + dx &gt; SCREEN_WIDHT: pass # CHANING DIRECTION TO LEFT self.rect.x += dx self.rect.y += dy </code></pre> <p>i don't have any ideas on how to make this loop</p>
[ { "answer_id": 74277108, "author": "Rabbid76", "author_id": 5577765, "author_profile": "https://Stackoverflow.com/users/5577765", "pm_score": 1, "selected": false, "text": "pygame.time.Clock.tick" }, { "answer_id": 74277210, "author": "Anubhav Sharma", "author_id": 13719128, "author_profile": "https://Stackoverflow.com/users/13719128", "pm_score": 0, "selected": false, "text": "import random as rnd\nimport time\nclass Player:\n dx=1\n dy=1\n maxx=100\n maxy=100\n def __init__(self):\n self.x=rnd.randint(1,100)\n self.y=rnd.randint(1,100)\n self.dir_x=1\n self.dir_y=1\n def move(self):\n self.x+=Player.dx*self.dir_x\n self.y+=Player.dy*self.dir_y\n \n if self.x+Player.dx*self.dir_x>Player.maxx or self.x+Player.dx*self.dir_x<0:\n self.dir_x=-self.dir_x\n if self.y+Player.dy*self.dir_y>Player.maxy or self.y+Player.dy*self.dir_y<0:\n self.dir_y=-self.dir_y\n\n def __str__(self):\n return \"[X : {} and Y : {}]\".format(self.x, self.y)\n\np = Player()\nwhile True:\n p.move()\n print(p, end=\"\\r\")\n time.sleep(0.1)\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74277026", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20383074/" ]
74,277,044
<p>I am trying to export an object to another module which includes a promise. I want results of the promises. I can get the result of promises, I just can't export. Or maybe I did everything wrong in this function.</p> <p>I am building an application for people to create their own interactive stories. I get a link, a heading, a story beginning, some story choices and story parts. I was able to store them and sort them. I've cloned the original arrays, so I could modify the code safely. Those clone arrays are the results of promises which are taken from the local storage. I've turned local storage functions to async functions so there is no problem about that. The promises were ready and I've created this final function where I stuck.</p> <pre><code>export const sendToHell = { res: [], kamino: async function () { this.res = await Promise.all([ stored.storedLink, stored.storedHeading, stored.storedBeginning, stored.storedChoices, stored.storedParts, ]); return this.res; }, cloneLink: [...sendToHell.res[0]], cloneHeading: [...sendToHell.res[1]], cloneBeginning: [...sendToHell.res[2]], cloneChoices: [...sendToHell.res[3]], cloneParts: [...sendToHell.res[4]], }; sendToHell.kamino(); </code></pre> <p>The error I am getting here is 'Cannot access sendToHell beofre init.' What I actually need from this code is, modified clone arrays. When I used &quot;this&quot; key word. I get an another error. which is 'Cannot read properties of undefined reading res'</p> <p>I've tried top level await but for a reason I don't know it doesn't work. &quot;I know top level await only works in modules.&quot; To be more clear. &quot;Stored&quot; is an array which includes other arrays like stored link, stored heading... &quot;StoredHeading&quot;, &quot;StoredBeginning&quot;... Those are arrays coming from local storage. They are resolved promises. &quot;CloneHeading&quot;, &quot;CloneBeginning&quot; ... These will be the arrays which will be clones of Stored arrays and exported to another module.</p> <p>Finally I know that exports and imports are synchronous. And if I write them in global scope they will be executed first while my promise is waiting. I've also tried the immediately executed function. Thank you for your time. Thank you for your time .</p>
[ { "answer_id": 74277865, "author": "lemek", "author_id": 4860179, "author_profile": "https://Stackoverflow.com/users/4860179", "pm_score": -1, "selected": false, "text": "kamino" }, { "answer_id": 74282971, "author": "Mulan", "author_id": 633183, "author_profile": "https://Stackoverflow.com/users/633183", "pm_score": 1, "selected": true, "text": "sendToHell" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74277044", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20358187/" ]
74,277,054
<p>Query:</p> <pre><code>select to_char(date, 'HH24:MI') as Timestamp, count(case when type = 5 then 1 end) as Counts1, count(case when type = 6 then 1 end) as Counts2, from data where date &gt;= to_date('2022-10-27 01:00', 'YYYY-MM-DD HH24:MI') and date &lt;= to_date('2022-10-27 01:20', 'YYYY-MM-DD HH24:MI') and type IN (5,6) group by to_char(date, 'HH24:MI') order by to_char(date, 'HH24:MI') </code></pre> <pre><code>+-----------+-----------+----------+ | Timestamp | Counts1 | Counts2 | +-----------+-----------+----------+ | 01:00 | 200 | 12 | | 01:01 | 250 | 35 | | 01:02 | 300 | 47 | | 01:03 | 150 | 78 | | 01:04 | 100 | 125 | | 01:05 | 125 | 5 | | 01:06 | 130 | 10 | | 01:07 | 140 | 12 | | 01:08 | 150 | 35 | | 01:09 | 160 | 47 | | 01:10 | 170 | 78 | | 01:11 | 180 | 125 | | 01:12 | 190 | 5 | | 01:13 | 210 | 10 | | 01:14 | 220 | 12 | | 01:15 | 230 | 35 | | 01:16 | 240 | 47 | | 01:17 | 260 | 78 | | 01:18 | 270 | 125 | | 01:19 | 280 | 5 | | 01:20 | 290 | 10 | +-----------+-----------+----------+ </code></pre> <p>From above query we are getting result for every 1 minute, we are looking for data sum of every 5 minutes interval from given timestamp.</p> <p>Expected result:</p> <pre><code>+-----------+-----------+----------+ | Timestamp | Counts1 | Counts2 | +-----------+-----------+----------+ | 01:05 | 1125 | 302 | | 01:10 | 750 | 182 | | 01:15 | 1030 | 187 | | 01:20 | 1340 | 265 | +-----------+-----------+----------+ </code></pre> <p>Can some one help on this</p> <p>Tried below:</p> <pre><code>select to_char(date + interval '5' minute, 'HH24:MI') as Timestamp, count(case when type = 5 then 1 end) as Counts1, count(case when type = 6 then 1 end) as Counts2, from data where date &gt;= to_date('2022-10-27 01:00', 'YYYY-MM-DD HH24:MI') and date &lt;= to_date('2022-10-27 01:20', 'YYYY-MM-DD HH24:MI') and type IN (5,6) group by to_char(date + interval '5' minute, 'HH24:MI') order by to_char(date + interval '5' minute, 'HH24:MI') </code></pre> <p>Below is the result we got:</p> <pre><code>+-----------+-----------+----------+ | Timestamp | Counts1 | Counts2 | +-----------+-----------+----------+ | 01:05 | 125 | 5 | | 01:06 | 130 | 10 | | 01:07 | 140 | 12 | | 01:08 | 150 | 35 | | 01:09 | 160 | 47 | | 01:10 | 170 | 78 | | 01:11 | 180 | 125 | | 01:12 | 190 | 5 | | 01:13 | 210 | 10 | | 01:14 | 220 | 12 | | 01:15 | 230 | 35 | | 01:16 | 240 | 47 | | 01:17 | 260 | 78 | | 01:18 | 270 | 125 | | 01:19 | 280 | 5 | | 01:20 | 290 | 10 | +-----------+-----------+----------+ </code></pre> <p>We are looking for sum of every 5 minutes interval and expected result is below:</p> <pre><code>+-----------+-----------+----------+ | Timestamp | Counts1 | Counts2 | +-----------+-----------+----------+ | 01:05 | 1125 | 302 | | 01:10 | 750 | 182 | | 01:15 | 1030 | 187 | | 01:20 | 1340 | 265 | +-----------+-----------+----------+ </code></pre>
[ { "answer_id": 74277865, "author": "lemek", "author_id": 4860179, "author_profile": "https://Stackoverflow.com/users/4860179", "pm_score": -1, "selected": false, "text": "kamino" }, { "answer_id": 74282971, "author": "Mulan", "author_id": 633183, "author_profile": "https://Stackoverflow.com/users/633183", "pm_score": 1, "selected": true, "text": "sendToHell" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74277054", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20061827/" ]
74,277,112
<p>Hi I would like to check if there's a way to convert one of my JSON property's value from string to an array of string.</p> <p>What I have:</p> <pre><code>const testJSON = { &quot;name&quot;: &quot;Albert&quot; } </code></pre> <p>What I want:</p> <pre><code>const testJSON = { &quot;name&quot;: [&quot;Albert&quot;] } </code></pre> <p>Many thanks for any help and direction I could explore!</p>
[ { "answer_id": 74277203, "author": "GSW", "author_id": 12260023, "author_profile": "https://Stackoverflow.com/users/12260023", "pm_score": -1, "selected": false, "text": " {name: [testJSON.name]}\n" }, { "answer_id": 74277232, "author": "fahomid", "author_id": 2492100, "author_profile": "https://Stackoverflow.com/users/2492100", "pm_score": 0, "selected": false, "text": "const testJSON = {\n \"name\": \"Albert\"\n}\n\n// new array which we will assign to previous array property\nconst newArray = [\"Albert\", \"John\"];\n\n// assigning new array to old json property\ntestJSON.name = newArray;" }, { "answer_id": 74285678, "author": "Rohìt Jíndal", "author_id": 4116300, "author_profile": "https://Stackoverflow.com/users/4116300", "pm_score": 1, "selected": true, "text": "Object.keys()" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74277112", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18159590/" ]
74,277,117
<p>You know how this shows up when you choose a directory in the terminal?</p> <p><a href="https://i.stack.imgur.com/WnoNI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WnoNI.png" alt="choosing a directory on terminal" /></a></p> <p>Is there a way I could create my own version of this, but when the user chooses one of the choices, it calls a function?</p> <p><em>i mean nothing about the terminal or directory, i am using it as an example</em></p> <p>user types <code>&quot;menu&quot;</code></p> <p>and there'd be a list of words that show up</p> <p><code>&quot;games&quot;</code> <code>&quot;text&quot;</code> <code>&quot;about&quot;</code></p> <p>user can type</p> <p><code>&quot;open games&quot;</code></p> <p>and it runs the function i named games</p> <p>here are my test functions:</p> <pre><code>void game() { cout &lt;&lt; &quot;you are in game&quot; } void text() { cout &lt;&lt; &quot;you are in text&quot; } void about() { cout &lt;&lt; &quot;you are in about&quot; </code></pre> <p>how do i make it so that a certain input LISTS the different functions, and a certain input CALLS the different functions?</p>
[ { "answer_id": 74277722, "author": "user253751", "author_id": 106104, "author_profile": "https://Stackoverflow.com/users/106104", "pm_score": 2, "selected": true, "text": "while(true) {\n string input;\n getline(cin, input);\n if(input == \"open games\")\n games();\n else if(input == \"open text\")\n text();\n else if(input == \"open about\")\n about();\n else if(input == \"options\")\n cout << \"games text about\\n\";\n else\n cout << \"unknown command\\n\";\n}\n" }, { "answer_id": 74278916, "author": "MSalters", "author_id": 15416, "author_profile": "https://Stackoverflow.com/users/15416", "pm_score": 0, "selected": false, "text": "std::map<std::string, std::function<void(void)>>" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74277117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20007599/" ]
74,277,126
<p>I have a list I created through a process that looks like this (so that I could pull from tidycensus):</p> <pre><code>dv_acs = c( hus = &quot;B25002_001&quot;, husocc = &quot;B25002_002&quot;, husvac = &quot;B17001_002&quot; ) </code></pre> <p>I want to know if I can turn that into a data.frame. When I try to ask it to be a data.frame by:</p> <pre><code>out &lt;- data.frame(dv_acs) </code></pre> <p>Then I get this:</p> <pre><code> dv_acs hus B25002_001 husocc B25002_002 husvac B17001_002 </code></pre> <p>Where the lefthand names replace what is normally 1:n but is not, in itself, a column of variables (data is noted as 3 obs of 1 variable).</p>
[ { "answer_id": 74277165, "author": "Allan Cameron", "author_id": 12500315, "author_profile": "https://Stackoverflow.com/users/12500315", "pm_score": 2, "selected": false, "text": "list" }, { "answer_id": 74277342, "author": "G. Grothendieck", "author_id": 516548, "author_profile": "https://Stackoverflow.com/users/516548", "pm_score": 2, "selected": false, "text": "stack(dv_acs)\n## values ind\n## 1 B25002_001 hus\n## 2 B25002_002 husocc\n## 3 B17001_002 husvac\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74277126", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14622403/" ]
74,277,144
<p>I want to use <strong>Pandas</strong> to create a new column in a dataframe in which it compares 2 columns in a row in the df, if the values are different to choose an specific column, if the values are equal to chose any of them, if one of them in NaN, to choose the other one (if both are NaN it will already be cover). I was using <strong>Numpy</strong> <em>select</em> and <strong>Pandas</strong> <em>where</em>, but can't make it work, and I don't want to use (yet) a <strong>for</strong> cycle.</p> <p>If i got this dataframe:</p> <pre><code>df1 = pd.DataFrame([[&quot;A&quot;, &quot;B&quot;], [&quot;C&quot;, &quot;D&quot;], [np.nan, &quot;A&quot;], [&quot;B&quot;, np.nan], [np.nan, np.nan], [&quot;E&quot;, &quot;E&quot;]], columns=[&quot;col1&quot;, &quot;col2&quot;]) df1 col1 col2 0 A B 1 C D 2 NaN A 3 B NaN 4 NaN NaN 5 E E </code></pre> <p>I want that the behavior is like this:</p> <ul> <li>In row 0 because (A != B) &amp; (A != np.nan) &amp; (B != np.nan) I want to choose the value from col1.</li> <li>In row 1 because (C != D) &amp; (C != np.nan) &amp; (D != np.nan) I want to choose the value from col1 (same as before).</li> <li>In row 2 because (NaN != A) &amp; (A != np.nan) &amp; (NaN == np.nan) I want to choose the value from col 2.</li> <li>In row 3 because (B != NaN) &amp; (NaN == np.nan) &amp; (B != np.nan) I want to choose the value from col 1.</li> <li>In row 4 because (NaN == NaN) &amp; (NaN == np.nan) &amp; (NaN == np.nan) I want to choose the value from col1 (either would work actually).</li> <li>In row 5 because (E == E) &amp; (E != np.nan) &amp; (E != np.nan) I want to choose the value form col 1 (same as before).</li> </ul> <p>In this case I should obtain something like:</p> <pre><code> col1 col2 col3 0 A B A 1 C D C 2 NaN A A 3 B NaN B 4 NaN NaN NaN 5 E E E </code></pre> <p>To achieve this I was doing this with <code>np.select</code>:</p> <pre><code>df1 = pd.DataFrame([[&quot;A&quot;, &quot;B&quot;], [&quot;C&quot;, &quot;D&quot;], [np.nan, &quot;A&quot;], [&quot;B&quot;, np.nan], [np.nan, np.nan], [&quot;E&quot;, &quot;E&quot;]], columns=[&quot;col1&quot;, &quot;col2&quot;]) conditions = [ ((df['col1'] == df['col2']) &amp; (df['col1'] != np.nan)), ((df['col1'] == df['col2']) &amp; (df['col1'] == np.nan)), ((df['col1'] != df['col2']) &amp; (df['col1'] != np.nan) &amp; (df['col2'] == np.nan)), ((df['col1'] != df['col2']) &amp; (df['col1'] == np.nan) &amp; (df['col2'] != np.nan)), ] choices = [df['col1'], np.nan, df['col1'], df['col2']] df['condition'] = np.select(conditions, choices, default=&quot;WHAT?&quot;) print(df) </code></pre> <p>But the result is:</p> <pre><code> col1 col2 condition 0 A B WHAT? 1 C D WHAT? 2 NaN A WHAT? 3 B NaN WHAT? 4 NaN NaN WHAT? 5 E E E </code></pre> <p>So, I don't understand what am I doing wrong.</p> <p><strong>SEMI-EDIT</strong>: While writing this I noticed that I was missing a case in choices, so I updated the code to this:</p> <p>Hope someone can help me, thanks</p> <pre><code>df1 = pd.DataFrame([[&quot;A&quot;, &quot;B&quot;], [&quot;C&quot;, &quot;D&quot;], [np.nan, &quot;A&quot;], [&quot;B&quot;, np.nan], [np.nan, np.nan], [&quot;E&quot;, &quot;E&quot;]], columns=[&quot;col1&quot;, &quot;col2&quot;]) conditions = [ ((df['col1'] == df['col2']) &amp; (df['col1'] != np.nan)), ((df['col1'] == df['col2']) &amp; (df['col1'] == np.nan)), ((df['col1'] != df['col2']) &amp; (df['col1'] != np.nan) &amp; (df['col2'] == np.nan)), ((df['col1'] != df['col2']) &amp; (df['col1'] == np.nan) &amp; (df['col2'] != np.nan)), ((df['col1'] != df['col2']) &amp; (df['col1'] != np.nan) &amp; (df['col2'] != np.nan)), ] choices = [df['col1'], np.nan, df['col1'], df['col2'], df[&quot;col1&quot;]] df['condition'] = np.select(conditions, choices, default=&quot;WHAT?&quot;) print(df) </code></pre> <p>The result was this one:</p> <pre><code> col1 col2 condition 0 A B A 1 C D C 2 NaN A NaN 3 B NaN B 4 NaN NaN NaN 5 E E E </code></pre> <p>To ilustrate a little bit more, I change choices to: [1, 2, 3, 4, 5]. This is the result:</p> <pre><code> col1 col2 condition 0 A B 5 1 C D 5 2 NaN A 5 3 B NaN 5 4 NaN NaN 5 5 E E 1 </code></pre> <p>It always enters in the fifth case, which is ok for row 0 and 1, but row 2 should enter case 4, row 3 should enter case 3, and row 4 should enter case 2. Row 5 is correct with case 1.</p> <p>Hope I made my self clear, thanks.</p> <p><strong>EDIT</strong>: someone commented and then delete something that worked for me. This person pointed out that if you do this: <code>print(np.nan == np.nan)</code> it will return <code>False</code>, so my logic will always fail. Therefore, I must user <code>notnull()</code> and <code>isna()</code> in the conditionals.</p>
[ { "answer_id": 74277165, "author": "Allan Cameron", "author_id": 12500315, "author_profile": "https://Stackoverflow.com/users/12500315", "pm_score": 2, "selected": false, "text": "list" }, { "answer_id": 74277342, "author": "G. Grothendieck", "author_id": 516548, "author_profile": "https://Stackoverflow.com/users/516548", "pm_score": 2, "selected": false, "text": "stack(dv_acs)\n## values ind\n## 1 B25002_001 hus\n## 2 B25002_002 husocc\n## 3 B17001_002 husvac\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74277144", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15899193/" ]
74,277,152
<p>I have dataset with float values with 6 decimals. I need to round it to two decimals.The problem becams with some floats nearly close to 1. After applying round(2) I got 1.00 instead of 0.99. May be this is mathematically right, but I need to have values like 0.99. My customer needs two decimals as result, I cant change it.</p> <pre><code>ones_list = [0.998344, 0.996176, 0.998344, 0.998082] df = pd.DataFrame(ones_list, columns=['value_to_round']) df['value_to_round'].round(2) 1.0 1.0 1.0 1.0 </code></pre>
[ { "answer_id": 74277165, "author": "Allan Cameron", "author_id": 12500315, "author_profile": "https://Stackoverflow.com/users/12500315", "pm_score": 2, "selected": false, "text": "list" }, { "answer_id": 74277342, "author": "G. Grothendieck", "author_id": 516548, "author_profile": "https://Stackoverflow.com/users/516548", "pm_score": 2, "selected": false, "text": "stack(dv_acs)\n## values ind\n## 1 B25002_001 hus\n## 2 B25002_002 husocc\n## 3 B17001_002 husvac\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74277152", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15520797/" ]
74,277,159
<p>I have the following lines to prompt a user to enter a date/time that I use further down in my script:</p> <pre><code>printf &quot;Please insert start of time window in format YYYY-MM-DD HH:MM:SS: \n&quot; read startDatetime </code></pre> <p>Is there a way I can have the &quot;read&quot; prompt insert in the dashes for the date, the space between the date and time, and the colons for the time dynamically as a user types? I know this is possible using JavaScript on the web, but I am specifically looking for a command line version of that functionality.</p> <p>I searched the web for an answer to this and cannot find one. I see an option for delimiter in the read Man Page but cannot see how it would achieve what I am trying to do.</p>
[ { "answer_id": 74277647, "author": "knittl", "author_id": 112968, "author_profile": "https://Stackoverflow.com/users/112968", "pm_score": 0, "selected": false, "text": "-p" }, { "answer_id": 74278062, "author": "Benjamin W.", "author_id": 3266847, "author_profile": "https://Stackoverflow.com/users/3266847", "pm_score": 2, "selected": false, "text": "-N" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74277159", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4843685/" ]
74,277,175
<p>After sending a post request to an api I get the following response body:</p> <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot;?&gt; &lt;header xmlns=&quot;mfp:anaf:dgti:spv:respUploadFisier:v1&quot; dateResponse=&quot;202211011543&quot; ExecutionStatus=&quot;0&quot; index_incarcare=&quot;5001131564&quot;/&gt; </code></pre> <p>I need the index_incarcare value, how can I get it in a variable using php?</p>
[ { "answer_id": 74277444, "author": "Jack Fleeting", "author_id": 9448090, "author_profile": "https://Stackoverflow.com/users/9448090", "pm_score": 2, "selected": true, "text": "$str = <<<XML\n<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<header xmlns=\"mfp:anaf:dgti:spv:respUploadFisier:v1\" dateResponse=\"202211011543\" \n ExecutionStatus=\"0\" index_incarcare=\"5001131564\"/>\nXML;\n$data = simplexml_load_string( $str, 'SimpleXMLElement', LIBXML_NOCDATA);\n$data->registerXPathNamespace('xxx', \"mfp:anaf:dgti:spv:respUploadFisier:v1\");\n\n$inca = $data->xpath('//xxx:header/@index_incarcare')[0];\necho $inca;\n" }, { "answer_id": 74277507, "author": "tvladan", "author_id": 4583217, "author_profile": "https://Stackoverflow.com/users/4583217", "pm_score": 0, "selected": false, "text": "$response = '<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<header xmlns=\"mfp:anaf:dgti:spv:respUploadFisier:v1\" dateResponse=\"202211011543\" ExecutionStatus=\"0\" index_incarcare=\"5001131564\"/>\n'; //from cURL Post request \n$xml=simplexml_load_string($response) or die(\"Error: Cannot create object\");\nfunction xml_attribute($object, $attribute)\n{\n if(isset($object[$attribute]))\n return (string) $object[$attribute];\n}\nprint xml_attribute($xml, 'index_incarcare')\n// returns 5001131564\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74277175", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4583217/" ]
74,277,180
<p>My app.component is not rendering child component template but after inspecting on the webpage I can see customer-form.component but it's not rendering. I have added my files for all the components.</p> <p>app.component.html=</p> <pre><code>&lt;h1&gt;Customer services&lt;/h1&gt; &lt;app-customer-form&gt;&lt;/app-customer-form&gt; </code></pre> <p>app.module.ts=</p> <pre><code>import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { BrowserModule } from '@angular/platform-browser'; import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; import { CustomDirectDirective } from './custom-direct.directive'; import { CustomerFormComponent } from './customer-form/customer-form.component'; import { DisplayCustomerComponent } from './display-customer/display-customer.component'; @NgModule({ declarations: [ AppComponent, CustomDirectDirective, CustomerFormComponent, DisplayCustomerComponent, ], imports: [ BrowserModule, AppRoutingModule, FormsModule, ], providers: [], bootstrap: [AppComponent] }) export class AppModule { } </code></pre> <p>customer-form.component.html=</p> <pre><code>&lt;h2&gt;this is customer form&lt;/h2&gt; </code></pre> <p>customer-form.component.ts=</p> <pre><code>import { Component, OnInit } from '@angular/core'; import { Customer } from '../customer'; @Component({ selector: 'app-customer-form', templateUrl: './customer-form.component.html', styleUrls: ['./customer-form.component.css'] }) export class CustomerFormComponent implements OnInit { constructor(public customer: Customer) { } ngOnInit(): void { } customerForm(data: any){ } } </code></pre> <p>It shows child component while inspecting but doesn't render on page.</p> <p><a href="https://i.stack.imgur.com/BS0ZQ.png" rel="nofollow noreferrer">Inspect element Image</a></p>
[ { "answer_id": 74277444, "author": "Jack Fleeting", "author_id": 9448090, "author_profile": "https://Stackoverflow.com/users/9448090", "pm_score": 2, "selected": true, "text": "$str = <<<XML\n<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<header xmlns=\"mfp:anaf:dgti:spv:respUploadFisier:v1\" dateResponse=\"202211011543\" \n ExecutionStatus=\"0\" index_incarcare=\"5001131564\"/>\nXML;\n$data = simplexml_load_string( $str, 'SimpleXMLElement', LIBXML_NOCDATA);\n$data->registerXPathNamespace('xxx', \"mfp:anaf:dgti:spv:respUploadFisier:v1\");\n\n$inca = $data->xpath('//xxx:header/@index_incarcare')[0];\necho $inca;\n" }, { "answer_id": 74277507, "author": "tvladan", "author_id": 4583217, "author_profile": "https://Stackoverflow.com/users/4583217", "pm_score": 0, "selected": false, "text": "$response = '<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<header xmlns=\"mfp:anaf:dgti:spv:respUploadFisier:v1\" dateResponse=\"202211011543\" ExecutionStatus=\"0\" index_incarcare=\"5001131564\"/>\n'; //from cURL Post request \n$xml=simplexml_load_string($response) or die(\"Error: Cannot create object\");\nfunction xml_attribute($object, $attribute)\n{\n if(isset($object[$attribute]))\n return (string) $object[$attribute];\n}\nprint xml_attribute($xml, 'index_incarcare')\n// returns 5001131564\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74277180", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20159612/" ]
74,277,211
<p>I have an excel sheet which has 150 rows of data. Now, I want to append a dataframe to that sheet without deleting or replacing the data using python.</p> <p>I have tried code like this, it is deleting the existing content from the excel and writing the dataframe into it.</p> <pre><code>import pandas as pd import openpyxl workbook = openpyxl.load_workbook(&quot;test.xlsx&quot;) writer = pd.ExcelWriter('test.xlsx', engine='openpyxl') writer.book = workbook writer.sheets = dict((ws.title, ws) for ws in workbook.worksheets) data_df.to_excel(writer, 'Existing_sheetname') writer.save() writer.close() </code></pre> <p>And other solutions provided <a href="https://stackoverflow.com/questions/38074678/append-existing-excel-sheet-with-new-dataframe-using-python-pandas">here</a> but with no outcome.</p> <p>Any suggestion is appreciated.</p>
[ { "answer_id": 74284784, "author": "Jason Baker", "author_id": 3249641, "author_profile": "https://Stackoverflow.com/users/3249641", "pm_score": -1, "selected": false, "text": "file_path = \"/path/to/file.xlsx\"\n\ndf_excel = pd.read_excel(file_path)\nresult = pd.concat([df_excel, df], ignore_index=True)\nresult.to_excel(file_path, index=False)\n" }, { "answer_id": 74300569, "author": "1001001", "author_id": 9774825, "author_profile": "https://Stackoverflow.com/users/9774825", "pm_score": 1, "selected": true, "text": "# Required imports\nimport pandas as pd\nfrom pathlib import Path\nimport numpy as np\n\n# Path to excel file\nxl_path = Path(\"C://Path//to//your//Excel_file.xlsx\")\n\n# sheet name\nsht_name = 'test'\n\n# columns names\ncols = list(\"ABCDEFG\")\n\n# random values\nvalues = np.random.randint(1000, size=(20,7))\n# create dataframe\ndf = pd.DataFrame(data=values, columns=cols)\n\n# since I am going to create writer object with 'openpyxl' engine all methods from \n# openpyxl could be used \nwith pd.ExcelWriter(xl_path, mode='a', engine='openpyxl', if_sheet_exists='overlay') as writer:\n # create new variable with sheet into which we are going to save the data\n ws = writer.sheets[sht_name]\n # check max row for columns of interest / in my case \"C\"\n max_row_for_c = max((c.row for c in ws['C'] if c.value is not None))\n # save data to excel starting in col C so startcol=2 since pandas counts from 0 \n # from this same reason there is no need to add 1 to max_row_from_c\n df.to_excel(writer, sheet_name=sht_name, startcol=2, startrow= max_row_for_c, header=None, index=False)\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74277211", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20222833/" ]
74,277,243
<pre><code>declare type a is record(a1 number, a2 varchar2(10)); type b is record(b1 number, b2 varchar2(10)); type c is record(a2 a, b2 b); ra a; rc c; begin with pa as( select 1,'a' from dual) select pa.* into ra from pa; dbms_output.put_line(ra.a2); --works with pa as( select 1, 'a' from dual)-- expression 'RC' in the INTO list is of wrong type select pa.*,pa.* into rc from pa; with pa as( select 1, 'a' from dual) --invalid user.table.column, table.column, or column specification select a(pa.*),b(pa.*) into rc from pa; with pa as( select 1, 'a' from dual) --invalid user.table.column, table.column, or column specification select c(a(pa.*),b(pa.*)) into rc from pa; end; </code></pre> <p>I've the record c which is a record of record. I would like to insert in c the result of a query. In this example I have tried wiht 3 different way. It doesn't work.</p> <p>Is it possible and how?</p> <p><a href="https://dbfiddle.uk/5JAmnf3j" rel="nofollow noreferrer">code on dbfiddle</a></p>
[ { "answer_id": 74284784, "author": "Jason Baker", "author_id": 3249641, "author_profile": "https://Stackoverflow.com/users/3249641", "pm_score": -1, "selected": false, "text": "file_path = \"/path/to/file.xlsx\"\n\ndf_excel = pd.read_excel(file_path)\nresult = pd.concat([df_excel, df], ignore_index=True)\nresult.to_excel(file_path, index=False)\n" }, { "answer_id": 74300569, "author": "1001001", "author_id": 9774825, "author_profile": "https://Stackoverflow.com/users/9774825", "pm_score": 1, "selected": true, "text": "# Required imports\nimport pandas as pd\nfrom pathlib import Path\nimport numpy as np\n\n# Path to excel file\nxl_path = Path(\"C://Path//to//your//Excel_file.xlsx\")\n\n# sheet name\nsht_name = 'test'\n\n# columns names\ncols = list(\"ABCDEFG\")\n\n# random values\nvalues = np.random.randint(1000, size=(20,7))\n# create dataframe\ndf = pd.DataFrame(data=values, columns=cols)\n\n# since I am going to create writer object with 'openpyxl' engine all methods from \n# openpyxl could be used \nwith pd.ExcelWriter(xl_path, mode='a', engine='openpyxl', if_sheet_exists='overlay') as writer:\n # create new variable with sheet into which we are going to save the data\n ws = writer.sheets[sht_name]\n # check max row for columns of interest / in my case \"C\"\n max_row_for_c = max((c.row for c in ws['C'] if c.value is not None))\n # save data to excel starting in col C so startcol=2 since pandas counts from 0 \n # from this same reason there is no need to add 1 to max_row_from_c\n df.to_excel(writer, sheet_name=sht_name, startcol=2, startrow= max_row_for_c, header=None, index=False)\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74277243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8458083/" ]
74,277,263
<p>So I got this line of code:</p> <pre><code> fun LiveTrainingScreen(viewModel: LiveTrainingViewModel = viewModel()) { Column(modifier = Modifier.padding(PaddingStatic.Small).zIndex(2f)) { //Large Video Display //here var videoLink = remember { mutableStateOf(LiveTrainingViewModel.cockPitRight) } val exoPlayerCamera1 = viewModel.GetCameraPlayer(videoLink.value) DisposableEffect( AndroidView( modifier = Modifier .weight(1f) .fillMaxSize() .clip(RoundedCornerShape(RoundedSizeStatic.Medium)) .clickable { videoLink = mutableStateOf(LiveTrainingViewModel.mapCamera) }, factory = { PlayerView(viewModel.context).apply { player = exoPlayerCamera1 useController = false resizeMode = AspectRatioFrameLayout.RESIZE_MODE_FILL FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT ) } } ) ) { onDispose { exoPlayerCamera1.release() } } } } </code></pre> <p>But when I click on the video element, the code is not being re-executed when I change the mediaItem Uri, because the video frame keeps displaying the same video.</p> <p>And I don't understand what I am doing wrong.</p> <p>Through mutablestate manual string change, re-execute code to change video display from the internet</p>
[ { "answer_id": 74277847, "author": "z.y", "author_id": 19023745, "author_profile": "https://Stackoverflow.com/users/19023745", "pm_score": 0, "selected": false, "text": "State<String>" }, { "answer_id": 74287919, "author": "Iets Iets", "author_id": 20129971, "author_profile": "https://Stackoverflow.com/users/20129971", "pm_score": 2, "selected": true, "text": ".clickable { exoPlayerCamera1.setMediaItem(MediaItem.fromUri(LiveTrainingViewModel.mapCamera))\n},\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74277263", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20129971/" ]
74,277,280
<p>I ma trying to iterate through a list of numbers to calculate the largest number, using list comprehension, but the syntax seems to be evading me. Precisely, I am not able to figure out where to place the expression. I am trying to use a counter, and store the largest number of the list in the counter. Is there a problem in my approach? Any help would be much appreciated. I have gone through a lot of questions concerning list comprehension but I have not been able to locate a working syntax to place the expression in list comprehension.</p> <pre><code>a = [1,2,3,4,5,6,722,4,35,353,5,4634,64,64,634,4,3] counter= 0 b = [counter = num for num in a if num &gt; counter] print(b) </code></pre> <p>I am not able to figure out how to utilize the expression. I used this code block to capture the largest number in the list using a counter variable and for loop. What could be the working syntax to write this using list comprehension?</p> <pre><code>a = [1,2,3,4,5,6,722,4,35,353,5,4634,64,64,634,4,3] counter = 0 for number in a: if number &gt; counter: counter = number print(counter) </code></pre>
[ { "answer_id": 74277379, "author": "fafl", "author_id": 5710637, "author_profile": "https://Stackoverflow.com/users/5710637", "pm_score": 0, "selected": false, "text": "result = float('-inf')\n\ndef check(n):\n global result\n if result < n:\n result = n\n return True\n else:\n return False\n\na = [1,2,3,4,5,6,722,4,35,353,5,4634,64,64,634,4,3]\nb = [x for x in a if check(x)]\n\nprint(b)\n" }, { "answer_id": 74277397, "author": "rv.kvetch", "author_id": 10237506, "author_profile": "https://Stackoverflow.com/users/10237506", "pm_score": -1, "selected": false, "text": ">>> a = [1,2,3,4,5,6,722,4,35,353,5,4634,64,64,634,4,3]\n>>> a.sort()\n>>> a\n[1, 2, 3, 3, 4, 4, 4, 5, 5, 6, 35, 64, 64, 353, 634, 722, 4634]\n>>> a[-1]\n4634\n>>> b = sorted(a, reverse=True)\n>>> b\n[4634, 722, 634, 353, 64, 64, 35, 6, 5, 5, 4, 4, 4, 3, 3, 2, 1]\n>>> b[0]\n4634\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74277280", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20388750/" ]
74,277,293
<p>Let me start by saying I'm learning Java, and come from the .NET/C# world.</p> <p><strong>TL;DR:</strong> This syntax does not work in VSCode or Eclipse IDE, does in IntelliJ. Why? What am I missing?</p> <pre><code> import path.to.class.Foo; import path.to.class.Foo_; // cannot be resolved error ... Foo_.barID; // cannot resolve to a variable </code></pre> <p>The underscore_ notation just causes the above errors... ugh</p> <p><strong>Long version:</strong></p> <p>I work on an API, and my team is newer to the project. None of us JAVA specific devs, and we've learned a ton over the last several months. The original devs created the project using IntelliJ, and supported it using that IDE. Unfortunately, our IntelliJ licenses keep being allowed to expire and it takes a week to get it back, and I'm not good with down time, so I tried Eclipse and VSCode. When trying to debug, the project won't build because some imports are unable to be resolved, as well as some variables that appear to be using JPA 2.0 notation for Dynamic, typesafe queries. Reading the following, this notation appears to have been around a long time, and Eclipse a long time Java IDE, so I think I'm clearly missing something. <a href="https://stackoverflow.com/questions/9379536/what-does-an-underscore-concatenated-to-a-class-name-mean">What does an underscore concatenated to a class name mean?</a> <a href="https://developer.ibm.com/articles/j-typesafejpa/#N102F2" rel="nofollow noreferrer">https://developer.ibm.com/articles/j-typesafejpa/#N102F2</a> <a href="https://developer.ibm.com/articles/j-typesafejpa/" rel="nofollow noreferrer">https://developer.ibm.com/articles/j-typesafejpa/</a></p> <p>I have a hard time believing this is only possible in IntelliJ, so it has to be something I'm missing within the IDE's. A package, or setting, or something that is not allowing the IDE to utilize the Criteria API?</p> <p>pom.xml file as requested:</p> <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt; &lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt; &lt;parent&gt; &lt;artifactId&gt;foo-app&lt;/artifactId&gt; &lt;groupId&gt;foo.bar.app&lt;/groupId&gt; &lt;version&gt;0.4.0-SNAPSHOT&lt;/version&gt; &lt;/parent&gt; &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt; &lt;artifactId&gt;bar-api&lt;/artifactId&gt; &lt;name&gt;Public Facing API&lt;/name&gt; &lt;properties&gt; &lt;mainClass&gt;foo.bar.fib.api.ApiService&lt;/mainClass&gt; &lt;jjwt.version&gt;0.11.4&lt;/jjwt.version&gt; &lt;/properties&gt; &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;foo.bar.fib&lt;/groupId&gt; &lt;artifactId&gt;fib-testing&lt;/artifactId&gt; &lt;version&gt;0.4.0-SNAPSHOT&lt;/version&gt; &lt;scope&gt;test&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;io.dropwizard&lt;/groupId&gt; &lt;artifactId&gt;dropwizard-core&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;io.dropwizard&lt;/groupId&gt; &lt;artifactId&gt;dropwizard-client&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;io.dropwizard&lt;/groupId&gt; &lt;artifactId&gt;dropwizard-migrations&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;io.dropwizard&lt;/groupId&gt; &lt;artifactId&gt;dropwizard-hibernate&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;io.dropwizard&lt;/groupId&gt; &lt;artifactId&gt;dropwizard-auth&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.apache.httpcomponents&lt;/groupId&gt; &lt;artifactId&gt;httpclient&lt;/artifactId&gt; &lt;scope&gt;compile&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;javax.xml.bind&lt;/groupId&gt; &lt;artifactId&gt;jaxb-api&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;com.hubspot.dropwizard&lt;/groupId&gt; &lt;artifactId&gt;dropwizard-guicier&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;${typesafe.config.groupID}&lt;/groupId&gt; &lt;artifactId&gt;typesafe-dropwizard-configuration&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;commons-io&lt;/groupId&gt; &lt;artifactId&gt;commons-io&lt;/artifactId&gt; &lt;version&gt;2.11.0&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;foo.bar.fib&lt;/groupId&gt; &lt;artifactId&gt;fib-queue&lt;/artifactId&gt; &lt;version&gt;0.4.0-SNAPSHOT&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;foo.bar.fib&lt;/groupId&gt; &lt;artifactId&gt;fib-common&lt;/artifactId&gt; &lt;version&gt;0.4.0-SNAPSHOT&lt;/version&gt; &lt;scope&gt;compile&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;foo.bar.fib&lt;/groupId&gt; &lt;artifactId&gt;fib-tokens&lt;/artifactId&gt; &lt;version&gt;0.4.0-SNAPSHOT&lt;/version&gt; &lt;scope&gt;compile&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;foo.bar.fib&lt;/groupId&gt; &lt;artifactId&gt;fib-buttonstuff&lt;/artifactId&gt; &lt;version&gt;0.4.0-SNAPSHOT&lt;/version&gt; &lt;scope&gt;compile&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;${hapi.fhir.groupID}&lt;/groupId&gt; &lt;artifactId&gt;hapi-fhir-client&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;com.jakewharton.fliptables&lt;/groupId&gt; &lt;artifactId&gt;fliptables&lt;/artifactId&gt; &lt;version&gt;1.1.0&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.bouncycastle&lt;/groupId&gt; &lt;artifactId&gt;bcprov-jdk15on&lt;/artifactId&gt; &lt;version&gt;${bouncey.version}&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.bouncycastle&lt;/groupId&gt; &lt;artifactId&gt;bcpkix-jdk15on&lt;/artifactId&gt; &lt;version&gt;${bouncey.version}&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;${hapi.fhir.groupID}&lt;/groupId&gt; &lt;artifactId&gt;hapi-fhir-structures-r4&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;${hapi.fhir.groupID}&lt;/groupId&gt; &lt;artifactId&gt;hapi-fhir-validation-resources-dstu3&lt;/artifactId&gt; &lt;scope&gt;compile&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;com.helger&lt;/groupId&gt; &lt;artifactId&gt;ph-schematron&lt;/artifactId&gt; &lt;scope&gt;compile&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;io.jsonwebtoken&lt;/groupId&gt; &lt;artifactId&gt;jjwt-api&lt;/artifactId&gt; &lt;version&gt;${jjwt.version}&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;io.jsonwebtoken&lt;/groupId&gt; &lt;artifactId&gt;jjwt-impl&lt;/artifactId&gt; &lt;version&gt;${jjwt.version}&lt;/version&gt; &lt;scope&gt;runtime&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;io.jsonwebtoken&lt;/groupId&gt; &lt;artifactId&gt;jjwt-jackson&lt;/artifactId&gt; &lt;version&gt;${jjwt.version}&lt;/version&gt; &lt;scope&gt;runtime&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;com.github.ben-manes.caffeine&lt;/groupId&gt; &lt;artifactId&gt;caffeine&lt;/artifactId&gt; &lt;version&gt;2.9.3&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;com.google.guava&lt;/groupId&gt; &lt;artifactId&gt;guava&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;com.newrelic.agent.java&lt;/groupId&gt; &lt;artifactId&gt;newrelic-java&lt;/artifactId&gt; &lt;version&gt;${newrelic.agent.version}&lt;/version&gt; &lt;type&gt;${newrelic.agent.type}&lt;/type&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;io.dropwizard&lt;/groupId&gt; &lt;artifactId&gt;dropwizard-json-logging&lt;/artifactId&gt; &lt;/dependency&gt; &lt;!--Test resources--&gt; &lt;dependency&gt; &lt;groupId&gt;io.dropwizard&lt;/groupId&gt; &lt;artifactId&gt;dropwizard-testing&lt;/artifactId&gt; &lt;scope&gt;test&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.mockito&lt;/groupId&gt; &lt;artifactId&gt;mockito-core&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.junit.jupiter&lt;/groupId&gt; &lt;artifactId&gt;junit-jupiter-params&lt;/artifactId&gt; &lt;scope&gt;test&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.glassfish.jersey.test-framework.providers&lt;/groupId&gt; &lt;artifactId&gt;jersey-test-framework-provider-grizzly2&lt;/artifactId&gt; &lt;version&gt;2.31&lt;/version&gt; &lt;scope&gt;test&lt;/scope&gt; &lt;exclusions&gt; &lt;exclusion&gt; &lt;groupId&gt;javax.servlet&lt;/groupId&gt; &lt;artifactId&gt;javax.servlet-api&lt;/artifactId&gt; &lt;/exclusion&gt; &lt;exclusion&gt; &lt;groupId&gt;junit&lt;/groupId&gt; &lt;artifactId&gt;junit&lt;/artifactId&gt; &lt;/exclusion&gt; &lt;/exclusions&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;com.google.code.gson&lt;/groupId&gt; &lt;artifactId&gt;gson&lt;/artifactId&gt; &lt;version&gt;2.9.0&lt;/version&gt; &lt;/dependency&gt; &lt;/dependencies&gt; &lt;build&gt; &lt;resources&gt; &lt;resource&gt; &lt;directory&gt;${project.basedir}/../src/main/resources&lt;/directory&gt; &lt;/resource&gt; &lt;resource&gt; &lt;directory&gt;src/main/resources&lt;/directory&gt; &lt;filtering&gt;true&lt;/filtering&gt; &lt;/resource&gt; &lt;/resources&gt; &lt;testResources&gt; &lt;testResource&gt; &lt;directory&gt;${project.basedir}/../src/main/resources&lt;/directory&gt; &lt;/testResource&gt; &lt;testResource&gt; &lt;directory&gt;src/test/resources&lt;/directory&gt; &lt;/testResource&gt; &lt;/testResources&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;artifactId&gt;maven-shade-plugin&lt;/artifactId&gt; &lt;configuration&gt; &lt;createDependencyReducedPom&gt;true&lt;/createDependencyReducedPom&gt; &lt;transformers&gt; &lt;transformer implementation=&quot;org.apache.maven.plugins.shade.resource.ServicesResourceTransformer&quot;/&gt; &lt;transformer implementation=&quot;org.apache.maven.plugins.shade.resource.ManifestResourceTransformer&quot;&gt; &lt;mainClass&gt;${mainClass}&lt;/mainClass&gt; &lt;/transformer&gt; &lt;/transformers&gt; &lt;filters&gt; &lt;filter&gt; &lt;artifact&gt;*:*&lt;/artifact&gt; &lt;excludes&gt; &lt;exclude&gt;META-INF/*.SF&lt;/exclude&gt; &lt;exclude&gt;META-INF/*.DSA&lt;/exclude&gt; &lt;exclude&gt;META-INF/*.RSA&lt;/exclude&gt; &lt;/excludes&gt; &lt;/filter&gt; &lt;/filters&gt; &lt;shadedArtifactAttached&gt;true&lt;/shadedArtifactAttached&gt; &lt;finalName&gt;${project.artifactId}&lt;/finalName&gt; &lt;/configuration&gt; &lt;executions&gt; &lt;execution&gt; &lt;phase&gt;package&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;shade&lt;/goal&gt; &lt;/goals&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt; &lt;configuration&gt; &lt;archive&gt; &lt;manifest&gt; &lt;addClasspath&gt;true&lt;/addClasspath&gt; &lt;mainClass&gt;${mainClass}&lt;/mainClass&gt; &lt;/manifest&gt; &lt;/archive&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;groupId&gt;com.google.cloud.tools&lt;/groupId&gt; &lt;artifactId&gt;jib-maven-plugin&lt;/artifactId&gt; &lt;configuration&gt; &lt;container&gt; &lt;args&gt; &lt;arg&gt;server&lt;/arg&gt; &lt;/args&gt; &lt;ports&gt; &lt;port&gt;8080&lt;/port&gt; &lt;/ports&gt; &lt;environment&gt; &lt;DB_MIGRATION&gt;1&lt;/DB_MIGRATION&gt; &lt;/environment&gt; &lt;entrypoint&gt;/entrypoint.sh&lt;/entrypoint&gt; &lt;/container&gt; &lt;extraDirectories&gt; &lt;paths&gt; &lt;path&gt;${project.basedir}/../bbcerts&lt;/path&gt; &lt;path&gt;${project.basedir}/target/jacoco-agent&lt;/path&gt; &lt;path&gt;${project.basedir}/docker&lt;/path&gt; &lt;path&gt;${project.basedir}/../src/main/resources/keypair&lt;/path&gt; &lt;path&gt;${project.basedir}/target/newrelic-agent&lt;/path&gt; &lt;/paths&gt; &lt;permissions&gt; &lt;permission&gt; &lt;file&gt;/entrypoint.sh&lt;/file&gt; &lt;mode&gt;755&lt;/mode&gt; &lt;/permission&gt; &lt;/permissions&gt; &lt;/extraDirectories&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt; &lt;configuration&gt; &lt;annotationProcessorPaths&gt; &lt;annotationProcessorPath&gt; &lt;groupId&gt;org.hibernate&lt;/groupId&gt; &lt;artifactId&gt;hibernate-jpamodelgen&lt;/artifactId&gt; &lt;version&gt;5.4.2.Final&lt;/version&gt; &lt;/annotationProcessorPath&gt; &lt;path&gt; &lt;groupId&gt;javax.xml.bind&lt;/groupId&gt; &lt;artifactId&gt;jaxb-api&lt;/artifactId&gt; &lt;version&gt;2.3.0&lt;/version&gt; &lt;/path&gt; &lt;path&gt; &lt;groupId&gt;javax.annotation&lt;/groupId&gt; &lt;artifactId&gt;javax.annotation-api&lt;/artifactId&gt; &lt;version&gt;1.3.1&lt;/version&gt; &lt;/path&gt; &lt;/annotationProcessorPaths&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;/plugins&gt; &lt;/build&gt; &lt;/project&gt; </code></pre> <p>EDIT: No longer monitoring this question since using the Community Edition of IntelliJ IDEA will work for my needs and I do not have to switch IDE's. I think the proposed answer will work for some, if not most; however, since I was unable (and unwilling to continue) to make the build work with another IDE I am leaving it unselected as the solution.</p>
[ { "answer_id": 74277379, "author": "fafl", "author_id": 5710637, "author_profile": "https://Stackoverflow.com/users/5710637", "pm_score": 0, "selected": false, "text": "result = float('-inf')\n\ndef check(n):\n global result\n if result < n:\n result = n\n return True\n else:\n return False\n\na = [1,2,3,4,5,6,722,4,35,353,5,4634,64,64,634,4,3]\nb = [x for x in a if check(x)]\n\nprint(b)\n" }, { "answer_id": 74277397, "author": "rv.kvetch", "author_id": 10237506, "author_profile": "https://Stackoverflow.com/users/10237506", "pm_score": -1, "selected": false, "text": ">>> a = [1,2,3,4,5,6,722,4,35,353,5,4634,64,64,634,4,3]\n>>> a.sort()\n>>> a\n[1, 2, 3, 3, 4, 4, 4, 5, 5, 6, 35, 64, 64, 353, 634, 722, 4634]\n>>> a[-1]\n4634\n>>> b = sorted(a, reverse=True)\n>>> b\n[4634, 722, 634, 353, 64, 64, 35, 6, 5, 5, 4, 4, 4, 3, 3, 2, 1]\n>>> b[0]\n4634\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74277293", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10358406/" ]