qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,273,579
<p>I would like to wait until no more images are downloading:</p> <pre class="lang-js prettyprint-override"><code>const waitForImages = async () =&gt; { const cleanupHandler = new Set(); const images = document.querySelectorAll(&quot;img&quot;); console.log(&quot;wait for images&quot;, images.length); await Promise.all( Array.from(images).map((image) =&gt; new Promise&lt;void&gt;((resolve) =&gt; { if (image.complete) { return resolve(); } const timeout = setTimeout(() =&gt; { console.log(image, &quot;timed out&quot;); resolve(); }, 500); const cleanup = () =&gt; { clearTimeout(timeout); image.removeEventListener(&quot;load&quot;, imageLoadingDone); image.removeEventListener(&quot;error&quot;, imageLoadingDone); cleanupHandler.delete(cleanup); }; cleanupHandler.add(cleanup); const imageLoadingDone = () =&gt; { console.log(image, &quot;done&quot;); cleanup(); resolve(); }; image.addEventListener(&quot;load&quot;, imageLoadingDone); image.addEventListener(&quot;error&quot;, imageLoadingDone); }) ) ); console.log(&quot;all images loaded&quot;); cleanupHandler.forEach((cleanup) =&gt; cleanup()); } </code></pre> <p>The code works very well. Unfortunately as soon as there is a hidden <code>&lt;img loading=&quot;lazy&quot;&gt;</code> on the page the <code>load</code> event is never fired. (see <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/loading" rel="nofollow noreferrer">HTML Image Element loading</a>)</p> <p>Is there any way to skip those <code>loading=&quot;lazy&quot;</code> images which don't start their download?</p>
[ { "answer_id": 74273714, "author": "Saleh Hashemi", "author_id": 1926454, "author_profile": "https://Stackoverflow.com/users/1926454", "pm_score": 0, "selected": false, "text": " ${'array' . $counter} = 'your array';\n" }, { "answer_id": 74273732, "author": "Bl457Xor", "a...
2022/11/01
[ "https://Stackoverflow.com/questions/74273579", "https://Stackoverflow.com", "https://Stackoverflow.com/users/159319/" ]
74,273,618
<p>I'm trying to make my square jump in Unity 2D when I press Space button. I have the following code:</p> <pre><code>using System.Collections; using System.Collections.Generic; using UnityEngine; public class Movement : MonoBehaviour { public float moveSpeed; public float jumpSpeed; float moveX; Vector2 pos; // Update is called once per frame void Update() { MoveHorizontally(); Jump(); } void MoveHorizontally(){ moveX = Input.GetAxis(&quot;Horizontal&quot;) * Time.deltaTime; pos.x = moveX * moveSpeed; transform.position = new Vector2(transform.position.x + pos.x,transform.position.y + pos.y); } void Jump(){ if (Input.GetKeyDown(&quot;space&quot;)){ GetComponent&lt;Rigidbody2D&gt;().AddForce(new Vector2(0,jumpSpeed * Time.deltaTime), ForceMode2D.Impulse); Debug.Log(&quot;Jumped!&quot;); } } } </code></pre> <p>When I press Space button, &quot;Jumped!&quot; message shows up, but my square not jumping. Any idea?</p> <p>Thanks a lot.</p> <p>I tried using Input.GetKey function. It works, but that function keeps making my square go upwards if i keep holding Space button.</p>
[ { "answer_id": 74273714, "author": "Saleh Hashemi", "author_id": 1926454, "author_profile": "https://Stackoverflow.com/users/1926454", "pm_score": 0, "selected": false, "text": " ${'array' . $counter} = 'your array';\n" }, { "answer_id": 74273732, "author": "Bl457Xor", "a...
2022/11/01
[ "https://Stackoverflow.com/questions/74273618", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20386360/" ]
74,273,624
<p>I am trying to get up the keycloak instance via using keycloak, and the compose file I used is below which I get it from</p> <p><a href="https://github.com/keycloak/keycloak-containers/blob/main/docker-compose-examples/keycloak-postgres.yml" rel="nofollow noreferrer">https://github.com/keycloak/keycloak-containers/blob/main/docker-compose-examples/keycloak-postgres.yml</a></p> <pre><code># keycloak dependencies postgres-keycloak: image: postgres volumes: - postgres_data:/var/lib/postgresql/data environment: POSTGRES_DB: keycloak POSTGRES_USER: keycloak POSTGRES_PASSWORD: password keycloak: image: quay.io/keycloak/keycloak:legacy environment: DB_VENDOR: POSTGRES DB_ADDR: postgres DB_DATABASE: keycloak DB_USER: keycloak DB_SCHEMA: public DB_PASSWORD: password KEYCLOAK_USER: admin KEYCLOAK_PASSWORD: admin # Uncomment the line below if you want to specify JDBC parameters. The parameter below is just an example, and it shouldn't be used in production without knowledge. It is highly recommended that you read the PostgreSQL JDBC driver documentation in order to use it. #JDBC_PARAMS: &quot;ssl=true&quot; ports: - 8082:8082 depends_on: - postgres-keycloak volumes: postgres_data: driver: local </code></pre> <p>When I run the file I am getting connection errors as below :</p> <pre class="lang-none prettyprint-override"><code>backend_services-keycloak-1 | Caused by: javax.resource.ResourceException: IJ031084: Unable to create connection backend_services-keycloak-1 | Caused by: org.postgresql.util.PSQLException: FATAL: password authentication failed for user &quot;keycloak&quot; backend_services-keycloak-1 | 08:53:53,533 FATAL [org.keycloak.services] (ServerService Thread Pool -- 68) Error during startup: java.lang.RuntimeException: Failed to connect to database backend_services-keycloak-1 | Caused by: javax.resource.ResourceException: IJ000453: Unable to get managed connection for java:jboss/datasources/KeycloakDS backend_services-keycloak-1 | 08:53:54,449 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation (&quot;add&quot;) failed - address: ([(&quot;subsystem&quot; =&gt; &quot;metrics&quot;)]): java.lang.NullPointerException backend_services-keycloak-1 | 08:53:54,460 ERROR [org.jboss.as.server] (ServerService Thread Pool -- 45) WFLYSRV0022: Deploy of deployment &quot;keycloak-server.war&quot; was rolled back with no failure message </code></pre>
[ { "answer_id": 74273714, "author": "Saleh Hashemi", "author_id": 1926454, "author_profile": "https://Stackoverflow.com/users/1926454", "pm_score": 0, "selected": false, "text": " ${'array' . $counter} = 'your array';\n" }, { "answer_id": 74273732, "author": "Bl457Xor", "a...
2022/11/01
[ "https://Stackoverflow.com/questions/74273624", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
74,273,643
<p>Basically what my controller does is update the data from database. However when testing the api for the controller, the data passed through query parameters works while data passed from body doesn't.</p> <p>For eg: When passing data from query parameters <a href="https://i.stack.imgur.com/SNVgZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SNVgZ.png" alt="When passing data from query parameters" /></a></p> <p>vs When passing data from body <a href="https://i.stack.imgur.com/bukKg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bukKg.png" alt="When passing data from body" /></a></p> <p>My controller looks like this</p> <pre><code>public function update(Request $request, $id) { if (Contact::where('id', $id)-&gt;exists()) { $editedContactData = Contact::find($id); $editedContactData-&gt;province = is_null($request-&gt;province) ? $editedContactData-&gt;province : $request-&gt;province; $editedContactData-&gt;district = is_null($request-&gt;district) ? $editedContactData-&gt;district : $request-&gt;district; $editedContactData-&gt;local = is_null($request-&gt;local) ? $editedContactData-&gt;local : $request-&gt;local; $editedContactData-&gt;spokesman = is_null($request-&gt;spokesman) ? $editedContactData-&gt;spokesman : $request-&gt;spokesman; $editedContactData-&gt;phone = is_null($request-&gt;phone) ? $editedContactData-&gt;phone : $request-&gt;phone; $editedContactData-&gt;email = is_null($request-&gt;email) ? $editedContactData-&gt;email : $request-&gt;email; $editedContactData-&gt;save(); return response()-&gt;json([ &quot;message&quot; =&gt; &quot;Contact Updated successfully&quot;, &quot;editedContactData&quot; =&gt; $editedContactData ], 201); }else{ return response()-&gt;json([ &quot;message&quot; =&gt; &quot;Contact Not Found.&quot; ], 404); } } </code></pre> <p>I think there is problem with my controller, yet I'm unable to find the solutions. Any problem the code might have?</p> <p>For anybody who want to see headers passed <a href="https://i.stack.imgur.com/ZzZkd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZzZkd.png" alt="headers" /></a></p>
[ { "answer_id": 74275995, "author": "Leena Patel", "author_id": 3348994, "author_profile": "https://Stackoverflow.com/users/3348994", "pm_score": 0, "selected": false, "text": "post()" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74273643", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14009092/" ]
74,273,660
<p>Hey guys I don't know if I can ask this but I'm working on the original files in google collab and I wrote a function that sums all the sizes of the file</p> <pre><code>import os def recls_rtsize(argpath): sumsize = 0 for entry in os.scandir(argpath): path= argpath+'/'+entry.name size= os.path.getsize(path) sumsize+=size return sumsize print(&quot;total:&quot;,recls_rtsize('/var/log')) </code></pre> <p>But I need a way to make this function a recursive function or if there is some kind of formula or idea to convert no-recursive into recursive</p>
[ { "answer_id": 74273814, "author": "funnydman", "author_id": 9926721, "author_profile": "https://Stackoverflow.com/users/9926721", "pm_score": 1, "selected": true, "text": "import os\n\n\ndef recls_rtsize(argpath):\n def helper(dirs):\n if not dirs:\n return 0\n ...
2022/11/01
[ "https://Stackoverflow.com/questions/74273660", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20156403/" ]
74,273,667
<p>I am creating a React app that uses Fetch to pull a API using SQLite, however for some reason it shows in console length: 3, and Array[0] only. I cannot pull from data just id 1 for example.</p> <pre><code>import React, { useState, useEffect } from &quot;react&quot;; export default () =&gt; { const [brands, setBrands] = useState(null); useEffect(() =&gt; { fetch(&quot;/api/brands&quot;) .then((response) =&gt; response.json()) .then((data) =&gt; console.log(data)) .then((data) =&gt; { setBrands(data); }); }, []); return ( &lt;&gt; {brands ? ( &lt;&gt; &lt;h1&gt;Brands&lt;/h1&gt; &lt;ul&gt; {brands.map((brand) =&gt; ( &lt;li key={brand.id}&gt;{brand.name}&lt;/li&gt; ))} &lt;/ul&gt; &lt;/&gt; ) : ( &lt;div&gt;Loading...&lt;/div&gt; )} &lt;/&gt; ); }; </code></pre> <p><a href="https://i.stack.imgur.com/e07nJ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/e07nJ.jpg" alt="Example Screen shot of Array being 0" /></a></p> <p>How would I be able to pull from this id 1 for example? at the moment only all the brands show when I remove the console log and show as I pasted in the screen shot above in console.</p>
[ { "answer_id": 74283702, "author": "Leigh.D", "author_id": 7759286, "author_profile": "https://Stackoverflow.com/users/7759286", "pm_score": 1, "selected": false, "text": "fetch(`/api/brands/${some_id_for_the_record_i_want}`)\n" }, { "answer_id": 74340287, "author": "Syed Asa...
2022/11/01
[ "https://Stackoverflow.com/questions/74273667", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8475361/" ]
74,273,675
<p>I have multiple lists created in python. I am trying to convert these lists into HTML rows.</p> <pre><code>week = ['1','2'] date = ['2022-10-01','2022-10-09'] </code></pre> <p>My HTML table should look like below:</p> <pre><code>Week Date 1 2022-10-01 2 2022-10-09 </code></pre> <p>what I tried so far:</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>{% for val in data %} &lt;tr&gt; &lt;td&gt; {% for item in val.week %} {{ item }} &lt;br&gt; {% endfor %} &lt;/td&gt; &lt;td&gt; {% for item in val.date %} {{ item }} &lt;br&gt; {% endfor %} &lt;/td&gt; &lt;/tr&gt; {% endfor %}</code></pre> </div> </div> </p> <p>The problem with above code is every value is treated as cell instead of row and hence I am unable to apply any row related styles to the above.</p> <p>Could someone help with how to convert these to rows instead of cells.</p> <p>Thank you.</p>
[ { "answer_id": 74283702, "author": "Leigh.D", "author_id": 7759286, "author_profile": "https://Stackoverflow.com/users/7759286", "pm_score": 1, "selected": false, "text": "fetch(`/api/brands/${some_id_for_the_record_i_want}`)\n" }, { "answer_id": 74340287, "author": "Syed Asa...
2022/11/01
[ "https://Stackoverflow.com/questions/74273675", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8832641/" ]
74,273,713
<p>I have the following statement in TypeScript:</p> <pre class="lang-js prettyprint-override"><code>let foo = { bar: [] }; foo.bar.push(&quot;Hello World!&quot;); </code></pre> <p>However VSCode keeps complaining that this <em>isn't allowed</em>.</p> <blockquote> <p>Argument of type 'string' is not assignable to parameter of type 'never'.ts(2345)</p> </blockquote> <p>So I try to define the type as follows:</p> <pre class="lang-js prettyprint-override"><code>let foo = { bar: Array&lt;string&gt; }; </code></pre> <p>But then I get the message that the method push is not allowed:</p> <blockquote> <p>Property 'push' does not exist on type '{ (arrayLength: number): string[]; (...items: string[]): string[]; new (arrayLength: number): string[]; new (...items: string[]): string[]; isArray(arg: any): arg is any[]; readonly prototype: any[]; from(arrayLike: ArrayLike): T[]; from&lt;T, U&gt;(arrayLike: ArrayLike&lt;...&gt;, mapfn: (v: T, k: number) =&gt; U, thisArg?:...'.ts(2339)</p> </blockquote> <p>Only way I found it to work was by defining it as follows:</p> <pre class="lang-js prettyprint-override"><code>let arr : Array&lt;string&gt; = []; let foo = { bar: arr }; foo.bar.push('Hello World!') </code></pre> <p>Why can't I define the type inside the object itself? It seems cumbersome having to extract the types outside of it, into a variable.</p>
[ { "answer_id": 74273736, "author": "JC97", "author_id": 5985593, "author_profile": "https://Stackoverflow.com/users/5985593", "pm_score": 2, "selected": false, "text": "let foo = {\n bar: [] as string[]\n};\n" }, { "answer_id": 74273907, "author": "T.J. Crowder", "author...
2022/11/01
[ "https://Stackoverflow.com/questions/74273713", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3845362/" ]
74,273,758
<p>Ruby version: 3.1.0 Rails version: 7.0.4 RVM 1.29.12 Ubuntu 20.04 It is a digital ocean droplet</p> <p>I have SSH'ed into an ubuntu 20.04 server. I have installed rvm and rails. If I stand in the rails user folder and write rails -v it gives me the rail version. If I go into a project folder and try the same thing it just says.</p> <pre><code>Could not find rails-7.0.4, sprockets-rails-3.4.2, puma-5.6.5, importmap-rails-1.1.5, turbo-rails-1.3.2, stimulus-rails-1.1.0, jbuilder-2.11.5, bootstrap-5.2.2, simple_form-5.1.0, ransack-3.2.1, bootstrap-select-rails-1.13.8, jquery-rails-4.5.0, sqlite3-1.5.3-x86_64-linux, sprockets-4.1.1, sassc-rails-2.1.2, sassc-2.4.0, tilt-2.0.11, ffi-1.15.5 in locally installed gems Run `bundle install` to install missing gems. </code></pre> <p>Running bundle install ends with the text &quot;Killed&quot; My bundle config is</p> <pre><code>--- BUNDLE_DEPLOYMENT: &quot;true&quot; BUNDLE_WITHOUT: &quot;development:test&quot; BUNDLE_PATH: &quot;vendor/bundle&quot; </code></pre> <p>It seems bundle install doesn't install ffi 1.15.5 correct.</p> <pre><code>Installing ffi 1.15.5 with native extensions Killed </code></pre> <p>and it does that everytime I run bundle install</p> <p>I tried to run rails -v in the rails user folder and it gives the rails version. If I try in the project folder It throws an error and ask me to run bundle install. I run bundle install and it seems to finish without issues, but it doesn't fix the problem</p>
[ { "answer_id": 74273736, "author": "JC97", "author_id": 5985593, "author_profile": "https://Stackoverflow.com/users/5985593", "pm_score": 2, "selected": false, "text": "let foo = {\n bar: [] as string[]\n};\n" }, { "answer_id": 74273907, "author": "T.J. Crowder", "author...
2022/11/01
[ "https://Stackoverflow.com/questions/74273758", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5910923/" ]
74,273,759
<p>The below code creates two datasets:</p> <pre><code>df1 &lt;- read.table(textConnection(&quot;ID Code Date1 Date2 1 I611 01/01/2021 03/01/2021 2 L111 04/01/2021 09/01/2021 3 L111 01/01/2021 03/01/2021 4 Z538 08/01/2021 11/01/2021 5 I613 08/08/2021 09/09/2021 &quot;), header=TRUE) df2 &lt;- read.table(textConnection(&quot;ID State 1 Washington 49 California 1 Washington 40 Texas 1 Texas 2 Texas 2 Washington 50 Minnesota 60 Washington&quot;), header=TRUE) </code></pre> <p>What I am looking to achieve is to search the second dataset for ID values that occur at least once in the first dataset 'ID' column and then group matches by the 'State' column in the second dataset. So the output would be:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>State</th> <th>IDs</th> </tr> </thead> <tbody> <tr> <td>Washington</td> <td>3</td> </tr> <tr> <td>Texas</td> <td>2</td> </tr> </tbody> </table> </div> <p>Any assistance will be very much appreciated - thank you.</p>
[ { "answer_id": 74273864, "author": "zephryl", "author_id": 17303805, "author_profile": "https://Stackoverflow.com/users/17303805", "pm_score": 3, "selected": true, "text": "dplyr::semi_join()" }, { "answer_id": 74273868, "author": "zx8754", "author_id": 680068, "autho...
2022/11/01
[ "https://Stackoverflow.com/questions/74273759", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17137505/" ]
74,273,776
<p>Say, we have a Stimulus controller that toggles a sidebar. The button that triggers the toggle action is located in different places, though, depending on the device. E.g. in the header when you are on a mobile device and in the main navigation when you are on a Desktop device.</p> <p>What do you do in this situation? Is it better to initialise 2 Stimulus controllers (one in the div that belongs to the header and one that belongs to the main navigation) or to initialise just one Stimulus controller, for example in a wrapper div tag that encloses both the header as well as the main navigation?</p>
[ { "answer_id": 74273864, "author": "zephryl", "author_id": 17303805, "author_profile": "https://Stackoverflow.com/users/17303805", "pm_score": 3, "selected": true, "text": "dplyr::semi_join()" }, { "answer_id": 74273868, "author": "zx8754", "author_id": 680068, "autho...
2022/11/01
[ "https://Stackoverflow.com/questions/74273776", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12544391/" ]
74,273,785
<p>I'm trying to figure out a way to turn and object like this :</p> <p><code>{ &quot;test.subtest.pass&quot; : &quot;test passed&quot;, &quot;test.subtest.fail&quot; : &quot;test failed&quot; } </code></p> <p>into JSON like this:</p> <p><code>{ &quot;test&quot;: { &quot;subtest&quot;: { &quot;pass&quot;: &quot;test passed&quot;, &quot;fail&quot;: &quot;test failed&quot; }}}</code></p> <p>sometimes there may be duplicate keys, as above perhaps there would be another entry like &quot;test.subtest.pass.mark&quot;</p> <p>I have tried using the following method and it works but it's incredibly ugly:</p> <pre><code> convertToJSONFormat() { const objectToTranslate = require('&lt;linkToFile&gt;'); const resultMap = this.objectMap(objectToTranslate, (item: string) =&gt; item.split('.')); let newMap:any = {}; for (const [key,value] of Object.entries(resultMap)) { let previousValue = null; // @ts-ignore for (const item of value) { // @ts-ignore if (value.length === 1) { if(!newMap.hasOwnProperty(item)) { newMap[item] = key } // @ts-ignore } else if (item === value[value.length - 1]) { if(typeof previousValue[item] === 'string' ) { const newKey = previousValue[item].toLowerCase().replace(/\s/g, '');; const newValue = previousValue[item]; previousValue[item] = {}; previousValue[item][newKey] = newValue; previousValue[item][item] = key; } else { previousValue[item] = key; } } else if (previousValue === null) { if (!newMap.hasOwnProperty(item)) { newMap[item] = {}; } previousValue = newMap[item]; } else { if (!previousValue.hasOwnProperty(item)) { previousValue[item] = {} previousValue = previousValue[item]; } else if (typeof previousValue[item] === 'string') { const newValue = previousValue[item]; previousValue[item] = {}; previousValue[item][item] = newValue; } else { previousValue = previousValue[item]; } } } } return newMap; } </code></pre>
[ { "answer_id": 74274521, "author": "Mikkel Christensen", "author_id": 7712755, "author_profile": "https://Stackoverflow.com/users/7712755", "pm_score": 1, "selected": false, "text": "function convertToJSONFormat(objectToTranslate) {\n // create root object for the conversion result\n c...
2022/11/01
[ "https://Stackoverflow.com/questions/74273785", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7332022/" ]
74,273,788
<p>I'm working on a project where I will retrieve data from various files and this data will then be written down in a file in geojson format.</p> <p>Below you see a simplified example of some of the code and output:</p> <p>Code:</p> <pre><code>def get_data(data): features = { &quot;type&quot;: &quot;FeatureCollection&quot;, &quot;features&quot;: [ { &quot;type&quot;: &quot;Feature&quot;, &quot;geometry&quot;: { &quot;type&quot;: &quot;Point&quot;, &quot;coordinates&quot;: [ data[&quot;lat&quot;], data[&quot;long&quot;], ], }, &quot;properties&quot;: { &quot;obsid&quot;: data[&quot;file_name&quot;], &quot;name&quot;: data[&quot;guid_id&quot;], &quot;h_gs&quot;: data[&quot;z&quot;], }, } ], } for id, top, bot, code in zip( data[&quot;id&quot;], data[&quot;top&quot;], data[&quot;bot&quot;], data[&quot;code&quot;], ): info = { id: { &quot;top&quot;: top, &quot;bot&quot;: bot, &quot;code&quot;: code, }, } features[&quot;features&quot;].append(info) return features def main(data): data = get_data(data) to_json = json.dumps(data, indent=4) print(to_json) if __name__ == &quot;__main__&quot;: # example data data = { &quot;lat&quot;: 40.730610, &quot;long&quot;: -73.935242, &quot;z&quot;: 28.37, &quot;file_name&quot;: &quot;tmrx.txt&quot;, &quot;guid_id&quot;: &quot;d4d5b10a-c5fc-450a-9b3b-f309e7cb9613&quot;, &quot;id&quot;: [&quot;id_0&quot;, &quot;id_1&quot;, &quot;id_2&quot;, &quot;id_3&quot;, &quot;id_4&quot;], &quot;top&quot;: [100, 200, 300, 400, 500], &quot;bot&quot;: [90, 190, 290, 390, 490], &quot;code&quot;: [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;, &quot;e&quot;], } main(data) </code></pre> <p>Output:</p> <pre><code>{ &quot;type&quot;: &quot;FeatureCollection&quot;, &quot;features&quot;: [ { &quot;type&quot;: &quot;Feature&quot;, &quot;geometry&quot;: { &quot;type&quot;: &quot;Point&quot;, &quot;coordinates&quot;: [ 40.73061, -73.935242 ] }, &quot;properties&quot;: { &quot;obsid&quot;: &quot;tmrx.txt&quot;, &quot;name&quot;: &quot;d4d5b10a-c5fc-450a-9b3b-f309e7cb9613&quot;, &quot;h_gs&quot;: 28.37 } }, { &quot;id_0&quot;: { &quot;top&quot;: 100, &quot;bot&quot;: 90, &quot;code&quot;: &quot;a&quot; } }, { &quot;id_1&quot;: { &quot;top&quot;: 200, &quot;bot&quot;: 190, &quot;code&quot;: &quot;b&quot; } }, { &quot;id_2&quot;: { &quot;top&quot;: 300, &quot;bot&quot;: 290, &quot;code&quot;: &quot;c&quot; } }, { &quot;id_3&quot;: { &quot;top&quot;: 400, &quot;bot&quot;: 390, &quot;code&quot;: &quot;d&quot; } }, { &quot;id_4&quot;: { &quot;top&quot;: 500, &quot;bot&quot;: 490, &quot;code&quot;: &quot;e&quot; } } ] } </code></pre> <p>This works fine but I wish I could get the output to look a little different.</p> <p>Desired output:</p> <pre><code>{ &quot;type&quot;: &quot;FeatureCollection&quot;, &quot;features&quot;: [ { &quot;type&quot;: &quot;Feature&quot;, &quot;geometry&quot;: { &quot;type&quot;: &quot;Point&quot;, &quot;coordinates&quot;: [ 40.73061, -73.935242 ] }, &quot;properties&quot;: { &quot;obsid&quot;: &quot;tmrx.txt&quot;, &quot;name&quot;: &quot;d4d5b10a-c5fc-450a-9b3b-f309e7cb9613&quot;, &quot;h_gs&quot;: 28.37 } &quot;id_0&quot;: { &quot;top&quot;: 100, &quot;bot&quot;: 90, &quot;code&quot;: &quot;a&quot; } &quot;id_1&quot;: { &quot;top&quot;: 200, &quot;bot&quot;: 190, &quot;code&quot;: &quot;b&quot; } &quot;id_2&quot;: { &quot;top&quot;: 300, &quot;bot&quot;: 290, &quot;code&quot;: &quot;c&quot; } &quot;id_3&quot;: { &quot;top&quot;: 400, &quot;bot&quot;: 390, &quot;code&quot;: &quot;d&quot; } &quot;id_4&quot;: { &quot;top&quot;: 500, &quot;bot&quot;: 490, &quot;code&quot;: &quot;e&quot; } } ] } </code></pre> <p>There, the 'unnecessary' brackets are removed.</p> <p>Does anyone here on the forum know how i could achieve this result in the above code?</p> <p>Best Regards, Mikael</p> <p>See the code sample above.</p>
[ { "answer_id": 74274154, "author": "Edu", "author_id": 14765387, "author_profile": "https://Stackoverflow.com/users/14765387", "pm_score": 0, "selected": false, "text": "features[\"features\"].append(info)" }, { "answer_id": 74274311, "author": "Chirath LV", "author_id": ...
2022/11/01
[ "https://Stackoverflow.com/questions/74273788", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20385667/" ]
74,273,805
<p>The branches of my colleagues has only 1 commit every time. Mine, includes all other commits I made like changes and fixes. How to do that? Or does it means they really commit only once before pushing it. They said rebase it onto master but I tried couple ways of procedure to do it but nothing happens.</p> <p>I tried</p> <p>1.)</p> <pre><code>git pull (master) git checkout feature-branch git rebase master </code></pre> <p>Then fixed the conflicts and nothing happens still all my commit history are there.</p> <p>2.)</p> <pre><code>git pull (master) git checkout feature-branch git rebase --onto feature-branch &lt;specific commit ID&gt; </code></pre> <p>Still same</p>
[ { "answer_id": 74273903, "author": "Özgür Murat Sağdıçoğlu", "author_id": 5106317, "author_profile": "https://Stackoverflow.com/users/5106317", "pm_score": 1, "selected": false, "text": "rebase" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74273805", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7523658/" ]
74,273,858
<p>I am learning express node.js and trying to run simple calculator code but anytime i press on the button i don't get any response back and also i don't get any errors in my code so i am kind of lost of what i am doin wrong. here is the sample of it so hoping someone can pinpoint me where i am goin wrong will include html code and calculator.js and the error which i am getting. Thank you in advance.</p> <pre class="lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt; &lt;html lang=&quot;en&quot; dir=&quot;ltr&quot;&gt; &lt;head&gt; &lt;meta charset=&quot;utf-8&quot;&gt; &lt;title&gt;&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;Calculator&lt;/h1&gt; &lt;form action=&quot;/&quot; method=&quot;post&quot;&gt; &lt;input type=&quot;text&quot; name=&quot;n1&quot; placeholder=&quot;Enter Number1&quot; value=&quot;&quot;&gt; &lt;input type=&quot;text&quot; name=&quot;n2&quot; placeholder=&quot;Enter Number2&quot; value=&quot;&quot;&gt; &lt;button type=&quot;submit&quot; name=&quot;submit&quot;&gt;Calculate&lt;/button&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <pre class="lang-js prettyprint-override"><code>const express = require(&quot;express&quot;); const bodyParser = require(&quot;body-parser&quot;); const app = express(); app.use(bodyParser.urlencoded({extended : true})); app.get(&quot;/&quot;,function(req,res){ res.sendFile(__dirname +&quot;/index.html&quot;); }); app.post(&quot;/&quot;,function(res,req){ var n1 = Number(req.body.n1); var n2= Number(req.body.n2); var result= n1 + n2; res.send(&quot;The result of calculation is&quot; + result); }); app.listen(2424,function(){ console.log(&quot;Server started on 2424&quot;); }); </code></pre> <p>But here is the error i am getting as soon as i am clicking calculate button:</p> <pre class="lang-js prettyprint-override"><code>TypeError: Cannot read properties of undefined (reading 'n1')    at C:\Users\Taniya\desktop\calculator\calc.js:12:28    at Layer.handle [as handle_request] (C:\Users\Taniya\desktop\calculator\node_modules\express\lib\router\layer.js:95:5)    at next (C:\Users\Taniya\desktop\calculator\node_modules\express\lib\router\route.js:144:13)    at Route.dispatch (C:\Users\Taniya\desktop\calculator\node_modules\express\lib\router\route.js:114:3)    at Layer.handle [as handle_request] (C:\Users\Taniya\desktop\calculator\node_modules\express\lib\router\layer.js:95:5)    at C:\Users\Taniya\desktop\calculator\node_modules\express\lib\router\index.js:284:15    at Function.process_params (C:\Users\Taniya\desktop\calculator\node_modules\express\lib\router\index.js:346:12)    at next (C:\Users\Taniya\desktop\calculator\node_modules\express\lib\router\index.js:280:10)    at C:\Users\Taniya\desktop\calculator\node_modules\body-parser\lib\read.js:137:5    at AsyncResource.runInAsyncScope (node:async_hooks:203:9) </code></pre>
[ { "answer_id": 74273903, "author": "Özgür Murat Sağdıçoğlu", "author_id": 5106317, "author_profile": "https://Stackoverflow.com/users/5106317", "pm_score": 1, "selected": false, "text": "rebase" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74273858", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20386442/" ]
74,273,866
<p>Hi I'm making a simple Hangman game in C</p> <p>I have a while Loop that is suppose to wait for the user to input a character. However, it skips pass that on the 2nd iteration.</p> <pre><code>void startGuessing(char *word){ char dummyWord[13]; strcpy(dummyWord, word); int dummyWordLength = strlen(dummyWord); for (size_t i = 0; i &lt; dummyWordLength; i++) { dummyWord[i] = '_'; } int remaindingChances = 7; while(remaindingChances &gt; 0){ printf(&quot;Player 2 has so far guessed: %s\n&quot;, dummyWord); printf(&quot;Player 2, you have %d guesses remaining. Enter your next guess:\n&quot;, remaindingChances); char guess; guess = getchar(); int wordLength = strlen(word); for (size_t i = 0; i &lt; wordLength; i++) { if(guess == word[i]){ dummyWord[i] = word[i]; } } remaindingChances--; } } </code></pre> <p>The following is the output I'm seeing:</p> <pre><code>Player 2 has so far guessed: ___ Player 2, you have 7 guesses remaining. Enter your next guess: c Player 2 has so far guessed: c__ Player 2, you have 6 guesses remaining. Enter your next guess: Player 2 has so far guessed: c__ Player 2, you have 5 guesses remaining. Enter your next guess: </code></pre> <p>Am i doing something wrong? O.o I can't seem to figure out this issue.</p>
[ { "answer_id": 74274008, "author": "William Pursell", "author_id": 140750, "author_profile": "https://Stackoverflow.com/users/140750", "pm_score": 2, "selected": true, "text": "guess = getchar()" }, { "answer_id": 74274033, "author": "Mateo Vozila", "author_id": 17571431,...
2022/11/01
[ "https://Stackoverflow.com/questions/74273866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9404560/" ]
74,273,878
<p>I want to print all employee names and also if the employee is present in a table.</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>EMP_ID</th> <th>ENAME</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>ALLEN</td> </tr> <tr> <td>2</td> <td>MAX</td> </tr> <tr> <td>3</td> <td>BEN</td> </tr> </tbody> </table> </div><div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>EMP_ID</th> <th>EC_CODE</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>CONFIG_1</td> </tr> <tr> <td>2</td> <td>CONFIG_2</td> </tr> <tr> <td>3</td> <td>CONFIG_1</td> </tr> </tbody> </table> </div> <p>Query:</p> <pre><code>SELECT ename, (CASE WHEN EXISTS (SELECT 1 FROM m_emp_config ec WHERE ec_code = 'CONFIG_1' AND emp_id = emp.emp_id) THEN 'Y' ELSE 'N' END) config FROM emp emp </code></pre> <p>Can we write the <code>CASE WHEN EXISTS</code> in the <code>WHERE</code> clause instead of there?</p> <p>I am new to SQL, please help me.</p> <p>Expected output for the SQL statement:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>ENAME</th> <th>CONFIG</th> </tr> </thead> <tbody> <tr> <td>ALLEN</td> <td>Y</td> </tr> <tr> <td>MAX</td> <td>N</td> </tr> <tr> <td>BEN</td> <td>Y</td> </tr> </tbody> </table> </div>
[ { "answer_id": 74273997, "author": "Tim Biegeleisen", "author_id": 1863229, "author_profile": "https://Stackoverflow.com/users/1863229", "pm_score": 3, "selected": true, "text": "SELECT DISTINCT\n e.ENAME,\n CASE WHEN ec.EMP_ID IS NOT NULL THEN 'Y' ELSE 'N' END AS CONFIG\nFROM emp ...
2022/11/01
[ "https://Stackoverflow.com/questions/74273878", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20386448/" ]
74,273,912
<p>How do I find all the previous items from the array by target item via javascript?</p> <p>Suppose I have an array of items <code>[&quot;Volvo&quot;, &quot;BMW&quot;, &quot;Mercedez&quot;, &quot;Suzuki&quot;, &quot;Honda&quot;]</code> and if my target value is <code>Suzuki</code> I should get <code>[&quot;Volvo&quot;, &quot;BMW&quot;, &quot;Mercedez&quot;]</code></p> <p>Thank you!</p>
[ { "answer_id": 74273997, "author": "Tim Biegeleisen", "author_id": 1863229, "author_profile": "https://Stackoverflow.com/users/1863229", "pm_score": 3, "selected": true, "text": "SELECT DISTINCT\n e.ENAME,\n CASE WHEN ec.EMP_ID IS NOT NULL THEN 'Y' ELSE 'N' END AS CONFIG\nFROM emp ...
2022/11/01
[ "https://Stackoverflow.com/questions/74273912", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17156981/" ]
74,273,932
<p>I have a nested dict in elixir, from which I want to save the latest items in a new dict.</p> <pre class="lang-elixir prettyprint-override"><code>sorted_slides = [ %{ id: 1, visual_events: [ %{entity_id: 1, payload: &quot;abc&quot;}, %{entity_id: 2, payload: &quot;def&quot;} ] }, %{ id: 2, visual_events: [ %{entity_id: 2, payload: &quot;yui&quot;}, %{entity_id: 3, payload: &quot;def&quot;}, %{entity_id: 4, payload: &quot;ghi&quot;}, ] }, %{ id: 3, visual_events: [ %{entity_id: 2, payload: &quot;ert&quot;}, %{entity_id: 4, payload: &quot;poi&quot;}, ] } ] dict = %{} Enum.each(sorted_slides, fn slide -&gt; Enum.each(slide.visual_events, fn ve -&gt; eid = ve.entity_id dict = Map.put(dict, eid, ve) IO.inspect(dict) end) end) IO.inspect(dict) </code></pre> <p>My original data structure contains items that may be overwritten by newer items. I want the new <code>dict</code> to be:</p> <pre class="lang-elixir prettyprint-override"><code>dict = %{ 1 =&gt; %{entity_id: 1, payload: &quot;abc&quot;}, 2 =&gt; %{entity_id: 2, payload: &quot;ert&quot;}, 3 =&gt; %{entity_id: 3, payload: &quot;def&quot;}, 4 =&gt; %{entity_id: 4, payload: &quot;poi&quot;} } </code></pre> <p>I want the <code>dict</code> to save the changes made to it by each iteration, but I guess that scoping works different from some other languages here.</p> <p>How would I achieve this in Elixir?</p>
[ { "answer_id": 74273997, "author": "Tim Biegeleisen", "author_id": 1863229, "author_profile": "https://Stackoverflow.com/users/1863229", "pm_score": 3, "selected": true, "text": "SELECT DISTINCT\n e.ENAME,\n CASE WHEN ec.EMP_ID IS NOT NULL THEN 'Y' ELSE 'N' END AS CONFIG\nFROM emp ...
2022/11/01
[ "https://Stackoverflow.com/questions/74273932", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4691187/" ]
74,273,943
<p>I am getting the default language after restarting my app but i want to get the upadated langauge</p> <p>`</p> <pre><code>void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return GetMaterialApp( translations: LocalString(), locale: const Locale('en', 'US'), debugShowCheckedModeBanner: false, ), home: homeScreen(); </code></pre> <p>`</p>
[ { "answer_id": 74274051, "author": "Nguyen family", "author_id": 19992458, "author_profile": "https://Stackoverflow.com/users/19992458", "pm_score": -1, "selected": false, "text": "class PrefsInstance {\n static PrefsInstance _instance = new PrefsInstance.internal();\n\n PrefsInstance....
2022/11/01
[ "https://Stackoverflow.com/questions/74273943", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20378705/" ]
74,273,950
<p><strong>Requirement</strong></p> <p>I am using WhatsApp API to receive and send messages. Now, someone sent me an image and the response I am getting by API is in the form of binary data as shown in the screenshot below.</p> <p><a href="https://i.stack.imgur.com/v2Phk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/v2Phk.png" alt="enter image description here" /></a></p> <p>(and ofcourse the binary data is far more lengthy than the screenshot)</p> <p><strong>My requirement is to convert this string to Data URL so that I can display it in the browser.</strong></p> <p>#######################################################################</p> <p><strong>What I have tried</strong></p> <p>I have tried the following as per googling for a bit but it is not helping.</p> <pre><code>const extractedImage = `data:${mimeType};base64,${Buffer.from(response.data).toString(&quot;base64&quot;)}`; // where response.data gives the binary data of image and mimeType is image/jpeg </code></pre> <p>The string after the above conversion is as displayed below.</p> <p><a href="https://i.stack.imgur.com/Ab45c.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ab45c.png" alt="enter image description here" /></a></p> <p>The Data URL is not valid and I am getting a blank output. Please guide me how to resolve this problem.</p>
[ { "answer_id": 74306632, "author": "Naveen S", "author_id": 19024142, "author_profile": "https://Stackoverflow.com/users/19024142", "pm_score": 0, "selected": false, "text": "{\n\"entry\": [\n {\n \"changes\": [\n {\n \"field\": \"messages\",\n ...
2022/11/01
[ "https://Stackoverflow.com/questions/74273950", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13978572/" ]
74,273,978
<p>I am using JPA Criteria to run a like query on a NVARCHAR column. The column(events) can hold maximum(2000) characters. Now this is the query :</p> <pre><code>if (Objects.nonNull(eventStatus)) { String eStat = &quot;\&quot;event_status\&quot;&quot;; String val =&quot;\&quot;&quot;+eventStatus+&quot;\&quot;&quot;; predicates.add(cb.like(item.get(&quot;events&quot;).as(String.class), &quot;%&quot;+eStat+&quot;%&quot;+&quot; &quot;+val+&quot;%&quot;)); } </code></pre> <p>Now this is not generating expected result and when I saw query log I saw this :</p> <pre><code>Hibernate: select count(itemadditi0_.item_additional_info_id) as col_0_0_ from Allocation.item_additional_info itemadditi0_ where itemadditi0_.tenant_id=? and ( cast(itemadditi0_.events as varchar(255)) like ? ) </code></pre> <p>So I guess I am not getting the result because of this line : <strong><code>cast(itemadditi0_.events as varchar(255)) like ?</code></strong></p> <p>In SSMS this query working just fine:</p> <pre><code>(select item_nbr,item_status,events from Allocation.item_additional_info where events like '%&quot;event_status&quot;%&quot;Past&quot;%'); </code></pre> <p>In Model we are saving events as follow</p> <pre><code>@Column(name=&quot;events&quot;,columnDefinition=&quot;nvarchar&quot;) @Convert(converter = EventConverterJson.class) private List&lt;EventInfo&gt; events; </code></pre> <p>So can you please help me on how resolve issue like in this scenario ? Or how to stop JPA Criteria from that casting?</p>
[ { "answer_id": 74306632, "author": "Naveen S", "author_id": 19024142, "author_profile": "https://Stackoverflow.com/users/19024142", "pm_score": 0, "selected": false, "text": "{\n\"entry\": [\n {\n \"changes\": [\n {\n \"field\": \"messages\",\n ...
2022/11/01
[ "https://Stackoverflow.com/questions/74273978", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10432355/" ]
74,273,986
<p>I have this dataset</p> <pre><code> dat=structure(list(A = c(&quot;n&quot;, &quot;n&quot;, &quot;F&quot;, &quot;F&quot;), Par = c(1, 1, 8, 3), var = c(1, 10, 1,5), dat = c(&quot;T&quot;, &quot;T&quot;, &quot;T&quot;, &quot;T&quot;)), row.names = c(NA, 4L ), class = &quot;data.frame&quot;) </code></pre> <p>I want to add by the groups in A , i tried this did not work:</p> <pre><code> dat%&gt;%group_by(A)%&gt;% mutate(ye = c( &quot;40-25&quot;, &quot;25-200&quot;)) </code></pre> <p>Error: ! Assigned data <code>value</code> must be compatible with existing data. ✖ Existing data has 4 rows. ✖ Assigned data has 2 rows. ℹ Only vectors of size 1 are recycled. Run <code>rlang::last_error()</code> to see where the error occurred.</p> <p>Desired output:</p> <pre><code> A Par var dat ye 1 n 1 1 T &quot;40-25&quot; 2 n 1 10 T &quot;25-200&quot; 3 F 8 1 T &quot;40-25&quot; 4 F 3 5 T &quot;25-200&quot; </code></pre>
[ { "answer_id": 74274053, "author": "SamR", "author_id": 12545041, "author_profile": "https://Stackoverflow.com/users/12545041", "pm_score": 2, "selected": false, "text": "dat[5, ] <- dat[4, ]\ndat\n# A Par var dat\n# 1 n 1 1 T\n# 2 n 1 10 T\n# 3 F 8 1 T\n# 4 F 3 5 ...
2022/11/01
[ "https://Stackoverflow.com/questions/74273986", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11101169/" ]
74,274,040
<p>Whenever I use <code>id</code> as my variable name, my IDE shows the term in different colour from other variables. Is this expected or is it some feature of IDE (I'm using vs code) or shouldn't i use <code>id</code> as a variable?</p> <p>I haven't faced any issues while running code. Only the colour change makes me curious.</p> <p>Example Image from my IDE: <a href="https://i.stack.imgur.com/dlHz6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dlHz6.png" alt="Example Image" /></a></p>
[ { "answer_id": 74274091, "author": "shaohua zhang", "author_id": 8487049, "author_profile": "https://Stackoverflow.com/users/8487049", "pm_score": 0, "selected": false, "text": "id" }, { "answer_id": 74458128, "author": "Floyd", "author_id": 6804636, "author_profile":...
2022/11/01
[ "https://Stackoverflow.com/questions/74274040", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16475089/" ]
74,274,058
<p>i have created a list view builder below the search bar. i wanted the generated API data to be filtered and listed in the search bar. iam a beginner and please help</p> <pre><code>ListView.builder( shrinkWrap: true, itemCount: product?.length, physics: const NeverScrollableScrollPhysics(), itemBuilder: (context, index) { return Padding( padding: const EdgeInsets.only(left: 15), child: Expanded( child: ListTile( title: Text(product![index].title.toString()), leading: CircleAvatar( backgroundImage: NetworkImage( product![index].image.toString()), )), ), ); }, ), </code></pre> <p><a href="https://i.stack.imgur.com/kSajA.png" rel="nofollow noreferrer">output of the list view builder</a></p>
[ { "answer_id": 74274091, "author": "shaohua zhang", "author_id": 8487049, "author_profile": "https://Stackoverflow.com/users/8487049", "pm_score": 0, "selected": false, "text": "id" }, { "answer_id": 74458128, "author": "Floyd", "author_id": 6804636, "author_profile":...
2022/11/01
[ "https://Stackoverflow.com/questions/74274058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19963134/" ]
74,274,065
<p>We have a PostgreSQL table with jsonb column. Some of the nodes in the json can come in as array or object in the input. I am trying to write a query that will give me the array length, if the node is an array and array size is greater than 1</p> <pre><code>select count(*) as policycount, policynumber from policymaster where jsonb_typeof((payload-&gt; 'node1'::text) -&gt; 'node2'::text) = 'array' -- and jsonb_array_length((payload-&gt; 'node1'::text) -&gt; 'node2'::text) &gt; 1 group by policynumber order by 1 desc </code></pre> <p>If I try adding</p> <p><code>and jsonb_array_length((payload-&gt; 'node1' -&gt; 'node2') &gt; 1</code></p> <p>then I get</p> <pre><code>SQL Error [42601]: ERROR: syntax error at or near &quot;group&quot; Position: 310 </code></pre> <p>If I try</p> <pre><code> and jsonb_array_length((payload-&gt; 'node1'::text) -&gt; 'node2'::text) &gt; 1 </code></pre> <p>I get</p> <pre><code>SQL Error [22023]: ERROR: cannot get array length of a non-array </code></pre> <p>Since it is mix of object and array, having the check for array in</p> <pre><code>where jsonb_typeof((payload-&gt; 'node1'::text) -&gt; 'node2'::text) = 'array' </code></pre> <p>also doesn't seem to help</p> <p>How can I get only those records where node2 is an array and the size of that array is greater than 1?</p> <p><strong>Sub Question</strong></p> <p>When I executed the query by @jjanes as is</p> <pre><code>select count(*) as policycount, policynumber from policymaster where case when jsonb_typeof((payload-&gt; 'node1'::text) -&gt; 'node2'::text) = 'array' then jsonb_array_length((payload-&gt; 'node1'::text) -&gt; 'node2'::text) &gt; 1 else false end group by policynumber order by 1 desc ; </code></pre> <p>The results was empty.</p> <p>When I changed the input parameters to both of the function calls to below, then it gave the results I was expecting</p> <pre><code>select count(*) as policycount, policynumber from policymaster where case when jsonb_typeof(payload-&gt; 'node1' -&gt; 'node2') = 'array' then jsonb_array_length(payload-&gt; 'node1' -&gt; 'node2') &gt; 1 else false end group by policynumber order by 1 desc ; </code></pre> <p>I just started working on PostgreSQL so do not have full understanding of the json / jsonb functions.</p> <p>From What I have understood the <code>::text</code> part on any jsonb object converts it from jsonb to text but not sure exactly how this part behaves</p> <pre><code>(payload-&gt; 'node1'::text) -&gt; 'node2'::text) </code></pre> <p>Can you explain that part. Maybe then it will help me understand why the query with <code>::text</code> for both of these nodes doesn't work in the case statement, but works when used individually in a different way</p> <p>Thank you</p>
[ { "answer_id": 74274091, "author": "shaohua zhang", "author_id": 8487049, "author_profile": "https://Stackoverflow.com/users/8487049", "pm_score": 0, "selected": false, "text": "id" }, { "answer_id": 74458128, "author": "Floyd", "author_id": 6804636, "author_profile":...
2022/11/01
[ "https://Stackoverflow.com/questions/74274065", "https://Stackoverflow.com", "https://Stackoverflow.com/users/913749/" ]
74,274,069
<p>Here are my code:</p> <p><a href="https://i.stack.imgur.com/jdrou.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jdrou.png" alt="enter image description here" /></a></p> <p><a href="https://i.stack.imgur.com/hpskB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hpskB.png" alt="enter image description here" /></a></p> <p>This is in android.</p> <p><a href="https://i.stack.imgur.com/FB3LC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FB3LC.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74274257, "author": "Himanshu Prajapati", "author_id": 20289252, "author_profile": "https://Stackoverflow.com/users/20289252", "pm_score": 0, "selected": false, "text": "<KeyboardAvoidingView>\n //your component\n</KeyboardAvoidingView> \n" }, { "answer_id": 742...
2022/11/01
[ "https://Stackoverflow.com/questions/74274069", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19522981/" ]
74,274,081
<p>I am trying to make a request to the Stripe API (which is a payment API) to get a json response which the API gives. I tried the following code I found in a Python course, but as the API needs to authenticate to get the response, I don't know how can I add that data in the request.</p> <p>Making it in a curl request will be like this:</p> <pre><code>curl https://api.stripe.com/v1/checkout/sessions -u pk_test_51LoUz3BgfM0E8ZiCV8UO79gw8zw7fhSgHUEAVj4wS7igs5D4kKiNsxXGeKQEUhorImNUiCxCNNtidwNkhFPUHP4i0060lsvsbw: -d success_url=&quot;http://127.0.0.1:5500/pages/success.html&quot; -d cancel_url=&quot;http://127.0.0.1:5500/pages/nosuccess.html&quot; -d &quot;line_items[0][price]&quot;=price_1LvNRkBgfM0E8ZiCTSiaNvNL -d &quot;line_items[0][quantity]&quot;=1 -d mode=subscription -d client_reference_id=&quot;123&quot; -d customer_email=&quot;email@email.com&quot; -d client_reference_id=&quot;tokenized&quot; -d phone_number_collection[&quot;enabled&quot;]=true </code></pre> <p>This will create a new checkout session in your stripe account and the response is a json with the info of the checkout session.</p> <p><strong>The authorisation I use in the curl request is the '-u' value of the publishable_key followed by ':' which means no password is required</strong></p> <p>But when I try to make this in Python I get the following error:</p> <pre><code>Traceback (most recent call last): File &quot;/home/pau/Desktop/bsnbl/Backend/borrar.py&quot;, line 17, in &lt;module&gt; respuesta = urllib.request.urlopen(request) File &quot;/usr/lib/python3.8/urllib/request.py&quot;, line 222, in urlopen return opener.open(url, data, timeout) File &quot;/usr/lib/python3.8/urllib/request.py&quot;, line 531, in open response = meth(req, response) File &quot;/usr/lib/python3.8/urllib/request.py&quot;, line 640, in http_response response = self.parent.error( File &quot;/usr/lib/python3.8/urllib/request.py&quot;, line 569, in error return self._call_chain(*args) File &quot;/usr/lib/python3.8/urllib/request.py&quot;, line 502, in _call_chain result = func(*args) File &quot;/usr/lib/python3.8/urllib/request.py&quot;, line 649, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 401: Unauthorized </code></pre> <p><strong>Python code:</strong></p> <pre><code>import urllib.request import json # Debido a cambios en la libreria ahora se deben pasar algunos cabeceros html paymentInfo = '-u pk_test_51LoUz3BgfM0E8ZiCV8UO79gw8zw7fhSgHUEAVj4wS7igs5D4kKiNsxXGeKQEUhorImNUiCxCNNtidwNkhFPUHP4i0060lsvsbw: -d success_url=&quot;http://127.0.0.1:5500/pages/success.html&quot; -d cancel_url=&quot;http://127.0.0.1:5500/pages/nosuccess.html&quot; -d &quot;line_items[0][price]&quot;=price_1LvNRkBgfM0E8ZiCTSiaNvNL -d &quot;line_items[0][quantity]&quot;=1 -d mode=subscription -d client_reference_id=&quot;123&quot; -d customer_email=&quot;abrix07@gmail.com&quot; -d client_reference_id=&quot;tokenized&quot; -d phone_number_collection[&quot;enabled&quot;]=true' res = bytes(paymentInfo,'utf-8') print(str(type(res))) request = urllib.request.Request( 'https://api.stripe.com/v1/checkout/sessions', data=res, headers={ 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36' } ) respuesta = urllib.request.urlopen(request) print('1. ',respuesta) cuerpo_respuesta = respuesta.read() print(cuerpo_respuesta) #Procesamos la respuesta json json_respuesta = json.loads(cuerpo_respuesta.decode(&quot;utf-8&quot;)) print(json_respuesta) </code></pre> <p><strong>For asking the question I am using the publishable key of my Stripe account for security reasons, if you try the code with the publishable code it will ask you for the secret key, which I can't give through here. Sorry for the inconvenience</strong></p>
[ { "answer_id": 74274327, "author": "Jonathan Steele", "author_id": 15784650, "author_profile": "https://Stackoverflow.com/users/15784650", "pm_score": 0, "selected": false, "text": "urllib" }, { "answer_id": 74289348, "author": "Pavel K", "author_id": 7864454, "author...
2022/11/01
[ "https://Stackoverflow.com/questions/74274081", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19851042/" ]
74,274,107
<p>I have multiple cdkDropLists, and I drag and drop items from one to the other. However, I want one of them to be hidden in certain conditions, defined by a function in my Angular component's .ts file.</p> <p>The HTML code snippet on how I want to do it is presented below:</p> <pre><code>&lt;div cdkDropList #weisen=&quot;cdkDropList&quot; [cdkDropListData]=&quot;weisenList&quot; [cdkDropListConnectedTo]=&quot;[playerThreeHand]&quot; class=&quot;horizontal weisen&quot; *ngIf=&quot;isFirstRound()&quot; cdkDropListOrientation=&quot;horizontal&quot; (cdkDropListDropped)=&quot;drop($event)&quot;&gt; &lt;div *ngFor=&quot;let card of weisenList&quot;&gt; &lt;img class=&quot;horizontal_card&quot; src=&quot;assets/french_cards/{{card.cardID}}.svg&quot; cdkDrag&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>However, this cdkDropList is referenced by another cdkDropList:</p> <pre><code>&lt;div cdkDropList #playerThreeHand=&quot;cdkDropList&quot; [cdkDropListData]=&quot;playerThreeHandList&quot; [cdkDropListConnectedTo]=&quot;[cardsOnTable, weisen]&quot; class=&quot;horizontal bottom&quot; cdkDropListOrientation=&quot;horizontal&quot; (cdkDropListDropped)=&quot;drop($event)&quot;&gt; &lt;div *ngFor=&quot;let card of playerThreeHandList&quot;&gt; &lt;img class=&quot;horizontal_card&quot; src=&quot;assets/french_cards/{{card.cardID}}.svg&quot; cdkDrag&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Without the ngIf, the code compiles; but when ngIf attribute is added, the following error message pops:</p> <pre class="lang-none prettyprint-override"><code>Error: src/app/game/game.component.html:83:50 - error TS2551: Property 'weisen' does not exist on type 'GameComponent'. 83 [cdkDropListConnectedTo]=&quot;[cardsOnTable, weisen]&quot; ~~~~~~ src/app/game/game.component.ts:9:16 9 templateUrl: './game.component.html', ~~~~~~~~~~~~~~~~~~~~~~~ Error occurs in the template of component GameComponent. </code></pre>
[ { "answer_id": 74274327, "author": "Jonathan Steele", "author_id": 15784650, "author_profile": "https://Stackoverflow.com/users/15784650", "pm_score": 0, "selected": false, "text": "urllib" }, { "answer_id": 74289348, "author": "Pavel K", "author_id": 7864454, "author...
2022/11/01
[ "https://Stackoverflow.com/questions/74274107", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20282334/" ]
74,274,116
<p>I really need help. My application has no errors in the build or as I build it in aab/apk. But when I debug the app on an emulator it keeps crashing after the splashscreen. The LogCat gives an error which I could not fix. Plz help.</p> <p><a href="https://i.stack.imgur.com/UsFIm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UsFIm.png" alt="LogCat" /></a></p> <p><a href="https://i.stack.imgur.com/oIoCJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oIoCJ.png" alt="AndroidManifest (1)" /></a></p> <p>I cleaned and rebuilt it many times, but it did not work at all.</p>
[ { "answer_id": 74274327, "author": "Jonathan Steele", "author_id": 15784650, "author_profile": "https://Stackoverflow.com/users/15784650", "pm_score": 0, "selected": false, "text": "urllib" }, { "answer_id": 74289348, "author": "Pavel K", "author_id": 7864454, "author...
2022/11/01
[ "https://Stackoverflow.com/questions/74274116", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19959380/" ]
74,274,134
<p>:-) So I do have edited some code I found online to this:</p> <pre><code>function timeZone_funch( $atts ) { extract(shortcode_atts(array('timezone' =&gt; 'Europe/Berlin'), $atts)); /* Europe/Berlin is default Timezone */ $output = ''; if (in_array($timezone, DateTimeZone::listIdentifiers())) { date_default_timezone_set($timezone); $currentTime = date( 'H:i', strtotime('+30 minutes')); $output = $currentTime; } else { $output = &quot;Invalid Timezone&quot;; } return $output; } add_shortcode( 'current_time', 'timeZone_funch' ); </code></pre> <p>It works as it should. It displays the timezones hour and minute + adding 30 minutes.</p> <p>What I want to do now is to make it round up to the nearest quater hour.</p> <p>Similar to this thread: <a href="https://stackoverflow.com/questions/2480637/round-minute-down-to-nearest-quarter-hour">Round minute down to nearest quarter hour</a></p> <p>I also believe that this thread contains my answer BUT due to my lack of knowledge and experience, I'm not able to work the code from the thread above into the code I have right now.</p> <p>If anybody could show me how I can integrate it, this would be amazing!</p> <p>Thank you for your time and maybe even your answer!</p> <p>With kind regards Chris</p> <p>Finding the correct way to integrate the round up function inside of the code I'am using.</p>
[ { "answer_id": 74274327, "author": "Jonathan Steele", "author_id": 15784650, "author_profile": "https://Stackoverflow.com/users/15784650", "pm_score": 0, "selected": false, "text": "urllib" }, { "answer_id": 74289348, "author": "Pavel K", "author_id": 7864454, "author...
2022/11/01
[ "https://Stackoverflow.com/questions/74274134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19331418/" ]
74,274,135
<p>My Code is :</p> <pre><code>$hm = strtotime('33:00:00')-strtotime('00:30:00'); $hms = gmdate(&quot;H:i:s&quot;, $hm); </code></pre> <p>i need the output is 32:30:00</p>
[ { "answer_id": 74275051, "author": "Furqan Ajmal", "author_id": 19405864, "author_profile": "https://Stackoverflow.com/users/19405864", "pm_score": 2, "selected": false, "text": "$time1 = '33:00:00';\n$time2 = '00:00:00';\n\necho 'Subtract = '.subtractTwoTimes($time1, $time2);\n\nfunctio...
2022/11/01
[ "https://Stackoverflow.com/questions/74274135", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20386737/" ]
74,274,173
<p>I'm trying to make a query that will look like <code>SELECT * from `table` WHERE args</code> I need to have my args the date from 'yesterday' and time 23:00 until date'Today' and time 22:59.</p> <p>I'm very bad at writing SQL and I will need masters help for this one. I know how to write basic SQL and I'm not sure how to write. Date and time are 2 different rows.</p> <p>Basic SQL stuff. Expecting all data from date yesterday starting with time 23:00 until date = today and time = 22:59 Logically is simple, I'm just bad at writing SQL logic. Date has to be always generated based on current date, time will be static.</p> <p><code>SELECT * from `table` WHERE date= Yesterday And time= 23:00 TO date=today time=22:59</code></p> <p>Edit: Database is MariaDB from Xamp</p>
[ { "answer_id": 74275051, "author": "Furqan Ajmal", "author_id": 19405864, "author_profile": "https://Stackoverflow.com/users/19405864", "pm_score": 2, "selected": false, "text": "$time1 = '33:00:00';\n$time2 = '00:00:00';\n\necho 'Subtract = '.subtractTwoTimes($time1, $time2);\n\nfunctio...
2022/11/01
[ "https://Stackoverflow.com/questions/74274173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13281893/" ]
74,274,176
<p>I have written some HTML and CSS for a website, and some media queries to reformat the code when the screen shrinks. This works on browsers, when I shrink the browser window size, but isn't working on mobile devices. Can anyone think of why? See the Media CSS below:</p> <pre><code>@media screen and (max-width:500px) { #education-table td { display: block; text-align: center; } } </code></pre> <p>Thanks in advance!</p> <p>I have looked at similar issues and thus added the &quot;screen and&quot;, but this has not fixed the issue.</p> <p>Update: I am testing the code on a pixel 7. When resizing the browser to the same width as my phone it works perfectly. I have ensured my phone width is indeed below 500px. TO clarify, this code works when used on a browser where I have both emulated a pixel 5 (through dev tools on edge) as well as just resizing the browser window. However, when I load the same site on my pixel 7 (and a pixel 6a, + Samsung galaxy a30) this CSS does not kick in, and it loads the standard &quot;desktop&quot; CSS styling - so the columns of tables do not collapse and are impossible to read</p>
[ { "answer_id": 74274429, "author": "HackerFrosch", "author_id": 20357737, "author_profile": "https://Stackoverflow.com/users/20357737", "pm_score": 1, "selected": false, "text": "768px" }, { "answer_id": 74275636, "author": "Ninowis", "author_id": 3245139, "author_pro...
2022/11/01
[ "https://Stackoverflow.com/questions/74274176", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13654189/" ]
74,274,196
<p>I need to convert <strong>Convert.ToUInt32(char value)</strong> code to java. this function return uint value in C# same implementation i need for java.</p> <p>I have done bit google work but didnt get expected output.</p>
[ { "answer_id": 74274429, "author": "HackerFrosch", "author_id": 20357737, "author_profile": "https://Stackoverflow.com/users/20357737", "pm_score": 1, "selected": false, "text": "768px" }, { "answer_id": 74275636, "author": "Ninowis", "author_id": 3245139, "author_pro...
2022/11/01
[ "https://Stackoverflow.com/questions/74274196", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8547718/" ]
74,274,226
<p>I have prices coming in my source file like below -</p> <p>78-22¼, 78-18⅝</p> <p>I need to calculate these price. For example for first case result should be 78-22.25. I searched a lot but found that SQL supports few of these characters only. Is there anyway to make sure we are able to calculate for whatever value we are getting. Solution in either SQL or PowerShell could work.</p>
[ { "answer_id": 74274429, "author": "HackerFrosch", "author_id": 20357737, "author_profile": "https://Stackoverflow.com/users/20357737", "pm_score": 1, "selected": false, "text": "768px" }, { "answer_id": 74275636, "author": "Ninowis", "author_id": 3245139, "author_pro...
2022/11/01
[ "https://Stackoverflow.com/questions/74274226", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9199007/" ]
74,274,245
<p>I merge two datasets using following code:</p> <pre><code>output1 = classen_gravity.merge(fdi, how= &quot;left&quot;, right_on=[&quot;Country&quot;, &quot;Year&quot;, &quot;regime&quot;], left_on=[&quot;country&quot;, &quot;regime&quot;, &quot;year&quot;]) </code></pre> <p>&quot;regime&quot; is supposed to stay as one column but after a merge, it becomes regime_x and regime_y.</p> <p>Why would it happen?</p>
[ { "answer_id": 74274429, "author": "HackerFrosch", "author_id": 20357737, "author_profile": "https://Stackoverflow.com/users/20357737", "pm_score": 1, "selected": false, "text": "768px" }, { "answer_id": 74275636, "author": "Ninowis", "author_id": 3245139, "author_pro...
2022/11/01
[ "https://Stackoverflow.com/questions/74274245", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19562955/" ]
74,274,336
<p>I have manually constructed the dataframe (df1,code below). For this dataframe df1, how could I remove the first column (row number)? Many thanks in advance</p> <pre><code>df1 = pd.DataFrame({&quot;date&quot;: ['2021-3-22', '2021-4-7', '2021-4-18', '2021-5-12'], &quot;x&quot;: [3, 3, 3, 0 ]}) Output: date x 0 2021-3-22 3 1 2021-4-7 3 2 2021-4-18 3 3 2021-5-12 0 </code></pre>
[ { "answer_id": 74274394, "author": "Abdul Niyas P M", "author_id": 6699447, "author_profile": "https://Stackoverflow.com/users/6699447", "pm_score": 1, "selected": false, "text": ".to_string" }, { "answer_id": 74274494, "author": "gtj520", "author_id": 19920392, "auth...
2022/11/01
[ "https://Stackoverflow.com/questions/74274336", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18836406/" ]
74,274,377
<p>Below is my input dataframe:</p> <pre class="lang-none prettyprint-override"><code>+---+----------+--------+ |ID |date |shift_by| +---+----------+--------+ |1 |2021-01-01|2 | |1 |2021-02-05|2 | |1 |2021-03-27|2 | |2 |2022-02-28|1 | |2 |2022-04-30|1 | +---+----------+--------+ </code></pre> <p>I need to groupBy &quot;ID&quot; and shift based on the &quot;shift_by&quot; column. In the end, the result should look like below:</p> <pre class="lang-none prettyprint-override"><code>+---+----------+----------+ |ID |date1 |date2 | +---+----------+----------+ |1 |2021-01-01|2021-03-27| |2 |2022-02-28|2022-04-30| +---+----------+----------+ </code></pre> <p>I have implemented the logic using UDF, but it makes my code slow. I would like to understand if this logic can be implemented <strong>without using UDF</strong>.</p> <p>Below is a sample dataframe:</p> <pre class="lang-py prettyprint-override"><code>from datetime import datetime from pyspark.sql.types import * data2 = [(1, datetime.date(2021, 1, 1), datetime.date(2021, 3, 27)), (2, datetime.date(2022, 2, 28), datetime.date(2022, 4, 30)) ] schema = StructType([ StructField(&quot;ID&quot;, IntegerType(), True), StructField(&quot;date1&quot;, DateType(), True), StructField(&quot;date2&quot;, DateType(), True), ]) df = spark.createDataFrame(data=data2, schema=schema) </code></pre>
[ { "answer_id": 74274601, "author": "samkart", "author_id": 8279585, "author_profile": "https://Stackoverflow.com/users/8279585", "pm_score": 2, "selected": true, "text": "first" }, { "answer_id": 74274633, "author": "ZygD", "author_id": 2753501, "author_profile": "htt...
2022/11/01
[ "https://Stackoverflow.com/questions/74274377", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6903126/" ]
74,274,406
<p>I have a one field with admissionDate in Student object, which is suppose should be null anytime When am inserting that value into the excel using apache poi i am getting NullPointerException. Data type of admissionDate is Date</p> <p>Below is my code</p> <pre><code> Row studentRow = studentSheet.createRow(0); studentRow.createCell(0).setCellValue(&quot;Id&quot;); studentRow.createCell(1).setCellValue(&quot;Name&quot;); studentRow.createCell(2).setCellValue(&quot;Admission_Date&quot;); int studentCount = 1; for(Student student : listOfStudent) { Row studentRow = accountSheet.createRow(studentCount); studentRow.createCell(0).setCellValue(student.getId()); studentRow.createCell(1).setCellValue(student.getName()); studentRow.createCell(2).setCellValue(student.getAdmissionDate()); studentCount++; } </code></pre> <p>But when admission date is null then i have getting below exception</p> <pre><code>Exception in thread &quot;main&quot; java.lang.NullPointerException at java.util.Calendar.setTime(Calendar.java:1770) at org.apache.poi.ss.usermodel.DateUtil.getExcelDate(DateUtil.java:86) at org.apache.poi.xssf.usermodel.XSSFCell.setCellValue(XSSFCell.java:600) at com.wd.classes.CreateExcelFile.generateExcelFile(CreateExcelFile.java:269) </code></pre> <p>How can i insert a NULL cell if admissiondate is not available</p>
[ { "answer_id": 74274443, "author": "SurfMan", "author_id": 914032, "author_profile": "https://Stackoverflow.com/users/914032", "pm_score": 3, "selected": true, "text": "for(Student student : listOfStudent) {\n Row studentRow = accountSheet.createRow(studentCount);\n student...
2022/11/01
[ "https://Stackoverflow.com/questions/74274406", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20076454/" ]
74,274,411
<p>In my code I used datepicker to selcte birthday .In date picker has a rang.And when the user select birthday and close the app and reopen later then also display that selected birthday.For that I used sharedprefernces , I want calculate age from birthday when the user select birthday then should automatically calculate age.</p> <p>Image of UI</p> <p><a href="https://i.stack.imgur.com/llnjZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/llnjZ.png" alt="enter image description here" /></a></p> <p>package</p> <p><a href="https://i.stack.imgur.com/rT1aO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rT1aO.png" alt="enter image description here" /></a></p> <p>code</p> <pre><code>import 'package:age_calculator/age_calculator.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; class BirthdayScreen extends StatefulWidget { const BirthdayScreen({Key? key}) : super(key: key); @override State&lt;BirthdayScreen&gt; createState() =&gt; _BirthdayScreenState(); } class _BirthdayScreenState extends State&lt;BirthdayScreen&gt; { // 1st dropdown button @override void initState() { super.initState(); dropdownValueBirthday = birthday.first; checkValueBirthday(); } //date picker DateTime? selectedDate; DateTime now = new DateTime.now(); void showDatePicker() { DateTime mindate = DateTime(now.year - 2, now.month, now.day - 29); DateTime maxdate = DateTime(now.year - 1, now.month, now.day); showCupertinoModalPopup( context: context, builder: (BuildContext builder) { return Container( height: MediaQuery.of(context).copyWith().size.height * 0.25, color: Colors.white, child: CupertinoDatePicker( mode: CupertinoDatePickerMode.date, initialDateTime: mindate, onDateTimeChanged: (value) { if (value != selectedDate) { setState(() { selectedDate = value; dropdownValueBirthday = '${selectedDate?.year}/${selectedDate?.month}/${selectedDate?.day} '; calAge(); }); } }, maximumDate: maxdate, minimumDate: mindate, ), ); }); } String? dropdownValueBirthday; List&lt;String&gt; birthday = [ 'Birthday', ]; //IF &quot;dropdownValueMembers&quot; is empty pass &quot;which&quot; word as a initial value if al ready selected then pass the shared preference value checkValueBirthday() { _getDataBirthday(); } _saveDataBirthday(String dropdownValueBirthdayShared) async { SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); sharedPreferences.setString(&quot;dataBirthday&quot;, dropdownValueBirthdayShared); } _getDataBirthday() async { SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); dropdownValueBirthday = sharedPreferences.getString(&quot;dataBirthday&quot;) ?? birthday.first; setState(() {}); } String age = &quot;&quot;; DateDuration? duration; getAge(DateTime fromDate) =&gt; DateTime.now().difference(fromDate).inDays ~/ 365; void calAge() { // DateTime birthday = DateTime.parse(dropdownValueBirthday!); // // setState(() { // duration = AgeCalculator.age(birthday); // }); DateTime? birt; // DateTime(1990); if (birt != null) { print('age from birt: ${getAge(birt)}'); } else { print('birt is null'); } } @override Widget build(BuildContext context) { print(duration); print(dropdownValueBirthday); return Scaffold( body: Container( child: Column( children: [ Center( child: Padding( padding: const EdgeInsets.only(left: 15, top: 100), child: Row( children: &lt;Widget&gt;[ const Icon( Icons.brightness_1, color: Colors.black, size: 10, ), const Padding( padding: EdgeInsets.only(left: 15.0), child: Text(&quot;birthday&quot;, style: TextStyle( fontSize: 16.0, )), ), Padding( padding: const EdgeInsets.only(left: 25.0), child: SizedBox( width: 110.0, height: 25.0, child: DecoratedBox( decoration: BoxDecoration( borderRadius: BorderRadius.circular(12), color: Colors.white, ), child: Center( child: Text( selectedDate == null ? (dropdownValueBirthday ?? birthday.first) : '${selectedDate?.year}/${selectedDate?.month}/${selectedDate?.day} ', style: const TextStyle( fontSize: 16, fontWeight: FontWeight.w500), ), ), ), ), ), Padding( padding: const EdgeInsets.only(left: 15.0, top: 30.0), child: SizedBox( width: 88.0, height: 25.0, child: MaterialButton( onPressed: showDatePicker, shape: const StadiumBorder(), color: Colors.blue, child: const Text( 'select', style: TextStyle(color: Colors.white, fontSize: 12), ), ), ), ), ], ), ), ), Padding( padding: const EdgeInsets.only( bottom: 0.0, ), child: 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: () { _saveDataBirthday(dropdownValueBirthday!); // _saveDataAgree(isChecked!); }, child: const Text('next')), ), ), ], ), ), ); } } </code></pre> <p>now display this</p> <p><a href="https://i.stack.imgur.com/kwciY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kwciY.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74274443, "author": "SurfMan", "author_id": 914032, "author_profile": "https://Stackoverflow.com/users/914032", "pm_score": 3, "selected": true, "text": "for(Student student : listOfStudent) {\n Row studentRow = accountSheet.createRow(studentCount);\n student...
2022/11/01
[ "https://Stackoverflow.com/questions/74274411", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20000775/" ]
74,274,452
<p>I am trying to write a program, which shows numbers 1 to 100. I would like to have a line break after every 20th number. I have tried using a counterloop, which resets itself after every 20th number, but the program runs infinite. How do I fix this?</p> <pre><code>public class zahlen1_bis_100 { public static void main(String[] args) { for (int x = 1; x &lt;= 100; x++) { for (int counter = 1;counter &lt;= 20; counter++) { if (counter == 20) { System.out.println(); counter = 1; } } System.out.print(x + &quot; &quot;); } } } </code></pre>
[ { "answer_id": 74274443, "author": "SurfMan", "author_id": 914032, "author_profile": "https://Stackoverflow.com/users/914032", "pm_score": 3, "selected": true, "text": "for(Student student : listOfStudent) {\n Row studentRow = accountSheet.createRow(studentCount);\n student...
2022/11/01
[ "https://Stackoverflow.com/questions/74274452", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9240628/" ]
74,274,459
<p>I want to check if there exist a folder in the current folder my code is in, how can this be done?</p> <p>What I mean is, we have folder called code_folder, which has the python code, i want to check in this python code if in this code_folder we have another folder called folder_1, if is it exists we can store something in it, if not we creat the folder and store something in it.</p>
[ { "answer_id": 74274554, "author": "Ajay K", "author_id": 10782096, "author_profile": "https://Stackoverflow.com/users/10782096", "pm_score": 2, "selected": true, "text": "import os\npath = \"code_folder\"\n# Check whether the defined path exists or not\nif not os.path.exists(path):\n ...
2022/11/01
[ "https://Stackoverflow.com/questions/74274459", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15970133/" ]
74,274,463
<p>I would like to truncate all characters in a column, no matter where they are.</p> <p>Example: &quot;+49123/4567890(testnumber)&quot;</p> <p>Should be changed to &quot;491234567890&quot;</p> <p>Is there a way without doing a replace for each char?</p> <p>I have tried to replace it with several, but it is very time-consuming.</p>
[ { "answer_id": 74274582, "author": "PSK", "author_id": 297322, "author_profile": "https://Stackoverflow.com/users/297322", "pm_score": 2, "selected": true, "text": "[a-zA-z()/+]" }, { "answer_id": 74275090, "author": "Stu", "author_id": 15332650, "author_profile": "ht...
2022/11/01
[ "https://Stackoverflow.com/questions/74274463", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16806565/" ]
74,274,481
<p>I'm doing an IF statement in PowerShell and at some point I do this:</p> <pre><code>(Get-BitlockerVolume -MountPoint &quot;C:&quot;).KeyProtector.keyprotectortype </code></pre> <p>which gives me the results in this format, on top of each other</p> <p><a href="https://i.stack.imgur.com/1Y48y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1Y48y.png" alt="enter image description here" /></a></p> <p>I want to write my IF statement to check whether the output of the command above contains both &quot;TpmPin&quot; and &quot;RecoveryPassword&quot; but not sure what the correct syntax is.</p> <p>I tried something like this but it doesn't work as expected, the result is always true even if it should be false.</p> <pre><code>if ((Get-BitlockerVolume -MountPoint &quot;C:&quot;).KeyProtector.keyprotectortype -contains &quot;tpmpin&quot; &amp;&amp; &quot;RecoveryPassword&quot;) </code></pre> <p>this doesn't work either:</p> <pre><code>if ((Get-BitlockerVolume -MountPoint &quot;C:&quot;).KeyProtector.keyprotectortype -contains &quot;tpmpinRecoveryPassword&quot;) </code></pre> <p>p.s I don't want to do nested IF statements because I'm already doing multiple of them.</p>
[ { "answer_id": 74274614, "author": "Mathias R. Jessen", "author_id": 712649, "author_profile": "https://Stackoverflow.com/users/712649", "pm_score": 3, "selected": true, "text": "Get-BitLockerVolume" }, { "answer_id": 74274670, "author": "Venkataraman R", "author_id": 634...
2022/11/01
[ "https://Stackoverflow.com/questions/74274481", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
74,274,487
<p>I found out that structures without any named members (and without any members in particular, as I understood) <a href="https://stackoverflow.com/a/53952132/19168278">invoke</a> UB in C. Only GNU GCC <a href="https://gcc.gnu.org/onlinedocs/gcc/Empty-Structures.html" rel="nofollow noreferrer">supports</a> such structures as an extension. I've tried to create a piece of code which will behave differently when compiled using GCC vs. Clang but with no success. I'm wondering if there is a C program that if you compile it via Clang, it will work differently than if it was compiled using GCC. The opposite option, in a nutshell, is that Clang also supports empty structures but this is not mentioned in documentation.</p>
[ { "answer_id": 74274898, "author": "Lundin", "author_id": 584518, "author_profile": "https://Stackoverflow.com/users/584518", "pm_score": 3, "selected": true, "text": "-Wgnu-empty-struct" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74274487", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19168278/" ]
74,274,489
<p>I found a code on the internet to encrypt user input with Caesar encryption. But in the code the loop head bother me, because we didn't have things like &quot;message[i]&quot; or &quot;\0&quot; in class. Is it possible to write this in a different way? But we had not used arrays as far as in this loop header. This is not homework or anything like that. I'm practicing for my computer science test next week and there will probably be something similar. The loop header always looked like this for example for(i = 0; i &lt; 4; i++). How can I write this code without arrays?</p> <p>How can I write the loop differently? Or do I have to change other code parts?</p> <pre><code>#include &lt;iostream&gt; using namespace std; int main() { char message[100], ch; int i, key; cout &lt;&lt; &quot;Enter a message to encrypt: &quot;; cin.getline(message, 100); cout &lt;&lt; &quot;Enter key: &quot;; cin &gt;&gt; key; for (i = 0; message[i] != '\0'; ++i) { //&lt;- ch = message[i]; //&lt;- if (ch &gt;= 'a' &amp;&amp; ch &lt;= 'z') { ch = ch + key; if (ch &gt; 'z') { ch = ch - 'z' + 'a' - 1; } message[i] = ch; //&lt;- } else if (ch &gt;= 'A' &amp;&amp; ch &lt;= 'Z') { ch = ch + key; if (ch &gt; 'Z') { ch = ch - 'Z' + 'A' - 1; } message[i] = ch; //&lt;- } } cout &lt;&lt; &quot;Encrypted message: &quot; &lt;&lt; message; return 0; } </code></pre>
[ { "answer_id": 74274691, "author": "oleg.cherednik", "author_id": 3461397, "author_profile": "https://Stackoverflow.com/users/3461397", "pm_score": 0, "selected": false, "text": "#include <iostream>\n#include <cctype>\n \nusing namespace std;\n \nint main() {\n char message[100];\n ...
2022/11/01
[ "https://Stackoverflow.com/questions/74274489", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
74,274,490
<p>I have 2 arrays with objects.</p> <pre><code>const users1 = [ { name: 'John', age: 15, gender: 'M', city: 'London', country: 'UK' }, { name: 'Jack', age: 20, gender: 'M', city: 'New York', country: 'USA' }, { name: 'Jinny', age: 30, gender: 'F', city: 'London', country: 'UK' }, { name: 'Key', age: 15, gender: 'M', city: 'Leeds', country: 'UK' }, ], const users2 = [ { name: 'Jack', age: 20, gender: 'M', city: 'New York', country: 'USA' }, { name: 'Key', age: 15, gender: 'M', city: 'Leeds', country: 'UK' }, ], </code></pre> <p>I need to get index from <em>users1</em> of that parts that are contains in <em>users2</em>.</p> <p>As a result I should get <code>[{1: true}, {3: true}]</code>. I try in this way but it's not correct</p> <pre><code>const arr = user1.filter((item, index) =&gt; user2.map(i) =&gt; { if(i.id === item.id) return {index: true} return null; }) </code></pre>
[ { "answer_id": 74274691, "author": "oleg.cherednik", "author_id": 3461397, "author_profile": "https://Stackoverflow.com/users/3461397", "pm_score": 0, "selected": false, "text": "#include <iostream>\n#include <cctype>\n \nusing namespace std;\n \nint main() {\n char message[100];\n ...
2022/11/01
[ "https://Stackoverflow.com/questions/74274490", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13861133/" ]
74,274,505
<p>I have dataframe</p> <pre><code>df1 = pd.DataFrame({'id': ['1','2','2','3','3','4','5'], 'event': ['Basket','Soccer','Soccer','Basket','Soccer','Basket','Soccer']}) </code></pre> <p>I want to count unique values of event but exclude the repeated id. The result I expect are:</p> <pre><code>event count Basket 3 Soccer 3 </code></pre>
[ { "answer_id": 74274691, "author": "oleg.cherednik", "author_id": 3461397, "author_profile": "https://Stackoverflow.com/users/3461397", "pm_score": 0, "selected": false, "text": "#include <iostream>\n#include <cctype>\n \nusing namespace std;\n \nint main() {\n char message[100];\n ...
2022/11/01
[ "https://Stackoverflow.com/questions/74274505", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20341621/" ]
74,274,536
<p>I've created 3 counters. the first two have a plus and minus button that makes the counter in the middle of the buttons go up and down to a max of 8. and they both also effect the last counter (global counter) which has a max of 12.</p> <p>the problem im having is how do i stop either of the add buttons from working when the globalCounter reaches 12? e.g. if counterOne is at 7, how do i get counterTwo to turn off when it reaches 5 (global counter would be 12)</p> <pre><code>here is my code: void main() { runApp( const MyApp(), ); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return const MaterialApp( home: Scaffold( backgroundColor: Colors.black, body: SafeArea(child: ButtonProblem()), ), ); } } class ButtonProblem extends StatefulWidget { const ButtonProblem({Key? key}) : super(key: key); @override State&lt;ButtonProblem&gt; createState() =&gt; _ButtonProblemState(); } class _ButtonProblemState extends State&lt;ButtonProblem&gt; { int counterOne = 0; int counterTwo = 0; int globalCounter = 0; @override Widget build(BuildContext context) { return Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ ClipRRect( borderRadius: BorderRadius.circular(5.0), child: InkWell( onTap: () { setState(() { if (counterOne &gt; 0) counterOne--; if (globalCounter &gt; 0) globalCounter--; }); }, child: Container( child: Icon(Icons.remove, color: Colors.white), width: 25.0, height: 35.0, color: Colors.blueGrey[900], ), ), ), Container( child: Text( '$counterOne', style: TextStyle( fontFamily: 'SourceSansPro', fontSize: 40.0, color: Colors.white, fontWeight: FontWeight.bold, ), ), ), ClipRRect( borderRadius: BorderRadius.circular(5.0), child: InkWell( onTap: () { setState(() { if (counterOne &lt; 8) counterOne++; if (globalCounter &lt; 12) globalCounter++; }); }, child: Container( child: Icon(Icons.add, color: Colors.white), width: 25.0, height: 35.0, color: Colors.blueGrey[900], ), ), ), ], ), Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ ClipRRect( borderRadius: BorderRadius.circular(5.0), child: InkWell( onTap: () { setState(() { if (counterTwo &gt; 0) counterTwo--; if (globalCounter &gt; 0) globalCounter--; }); }, child: Container( child: Icon(Icons.remove, color: Colors.white), width: 25.0, height: 35.0, color: Colors.blueGrey[900], ), ), ), Container( child: Text( '$counterTwo', style: TextStyle( fontFamily: 'SourceSansPro', fontSize: 40.0, color: Colors.white, fontWeight: FontWeight.bold, ), ), ), ClipRRect( borderRadius: BorderRadius.circular(5.0), child: InkWell( onTap: () { setState(() { if (counterTwo &lt; 8) counterTwo++; if (globalCounter &lt; 12) globalCounter++; }); }, child: Container( child: Icon(Icons.add, color: Colors.white), width: 25.0, height: 35.0, color: Colors.blueGrey[900], ), ), ), ], ), Container( child: Center( child: Text( '$globalCounter/12', textAlign: TextAlign.center, style: TextStyle( fontFamily: 'SourceSansPro', fontSize: 35.0, color: Colors.white, fontWeight: FontWeight.bold, ), ), ), ), ], ); } } </code></pre> <p><a href="https://i.stack.imgur.com/cmqtD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cmqtD.png" alt="button problem" /></a></p>
[ { "answer_id": 74274691, "author": "oleg.cherednik", "author_id": 3461397, "author_profile": "https://Stackoverflow.com/users/3461397", "pm_score": 0, "selected": false, "text": "#include <iostream>\n#include <cctype>\n \nusing namespace std;\n \nint main() {\n char message[100];\n ...
2022/11/01
[ "https://Stackoverflow.com/questions/74274536", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20373623/" ]
74,274,551
<p>I am trying to port the basic neural network application from Andrew Ng's course from Python to Julia but got stuck in this part.</p> <p>I am using my own data set, and therefore I am creating my own solution to process images and resize them. In order to have the exact same as in the Python code (and to have all images as vectors inside one matrix) I need to convert them from RGB to Array type so I can store them as columns in a matrix, but I keep an error and I can't seem to find information anywhere else.</p> <p>I'm currently using an adapted version of the idea presented <a href="https://discourse.julialang.org/t/efficiently-loading-and-processing-large-number-of-images/58278/5?u=williantleite" rel="nofollow noreferrer">here</a>.</p> <pre><code>using Images, FileIO, TestImages cat_path = &quot;path/Cat/&quot; cat_imgs = joinpath.(cat_path, readdir(cat_path)) function process_image(path_vec::Vector{String}, h::Int64, w::Int64, label::Int64) result = zeros((h*w), length(path_vec)) class = [] for i in enumerate(path_vec) img = load(i[2])::Array{RGB{N0f8},2} img = imresize(img,(h,w))::Array{RGB{N0f8},2} img = vec(img)::Vector{RGB{N0f8}} result[:,i[1]] = img # this is the line where I believe Im getting the error push!(class, label) end return result, class end </code></pre> <p>If I try to change the images from RGB to Gray it works (which makes sense as they will have just one channel and will easily become an array), but if I want to keep all channels in the vector I can't just use save them into the matrix as a Vector{RGB{N0f8}}, and if I try to use <code>img = convert(Array{Float64,1},img)</code> I get the error: <code>MethodError: Cannot </code>convert<code> an object of type RGB{N0f8} to an object of type Float64</code></p> <p>I'm not sure how to make the code easily reproducible, but I believe that if you create a folder with a single image and update the file paths it should be possible. Or just running the individual lines inside the function using a test image:</p> <pre><code>using TestImages img = testimage(&quot;mandrill&quot;) </code></pre>
[ { "answer_id": 74275680, "author": "Willian Leite", "author_id": 12944885, "author_profile": "https://Stackoverflow.com/users/12944885", "pm_score": 1, "selected": false, "text": "function process_image(path_vec::Vector{String}, h::Int64, w::Int64, label::Int64)\n result = zeros((h*w*3)...
2022/11/01
[ "https://Stackoverflow.com/questions/74274551", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12944885/" ]
74,274,565
<p>I have a form and I want to do some checks on all the fields on <code>keyup</code>.</p> <p>Only if all of the inputs are completed, then the message should be displayed.</p> <p>In JS there's this function called <code>checkValidity()</code> which checks if an input is validated, but on my example it doesn't work right.</p> <p>If I complete the first three fields, that message appears, but I don't want that.</p> <p>I want that message to appear only when all of the nine fields are completed.</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 inputs = document.querySelectorAll('input'); inputs.forEach(input =&gt; { input.addEventListener('keyup', () =&gt; { console.log(input); if (!input.checkValidity()) { document.querySelector('.message').classList.remove('d-none'); } else { document.querySelector('.message').classList.add('d-none') } }) })</code></pre> <pre class="snippet-code-css lang-css prettyprint-override"><code>.d-none { display: none; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;form action=""&gt; &lt;div class="participants-data"&gt; &lt;div class="form-content-holder"&gt; &lt;div class="js-form-content form-content"&gt; &lt;div class="participant-index"&gt;Participant&lt;/div&gt; &lt;div class="input-holder"&gt; &lt;input type="text" name="firstName" fieldName="firstName" class="input-participant-data"&gt; &lt;label for=""&gt;First Name&lt;/label&gt; &lt;input type="text" name="lastName" fieldName="lastName" class="input-participant-data"&gt; &lt;label for=""&gt;Last Name&lt;/label&gt; &lt;input type="email" name="email" fieldName="email" class="input-participant-data"&gt; &lt;label for=""&gt;Email&lt;/label&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="js-form-content form-content"&gt; &lt;div class="participant-index"&gt;Participant&lt;/div&gt; &lt;div class="input-holder"&gt; &lt;input type="text" name="firstName" fieldName="firstName" class="input-participant-data"&gt; &lt;label for=""&gt;First Name&lt;/label&gt; &lt;input type="text" name="lastName" fieldName="lastName" class="input-participant-data"&gt; &lt;label for=""&gt;Last Name&lt;/label&gt; &lt;input type="email" name="email" fieldName="email" class="input-participant-data"&gt; &lt;label for=""&gt;Email&lt;/label&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="js-form-content form-content"&gt; &lt;div class="participant-index"&gt;Participant&lt;/div&gt; &lt;div class="input-holder"&gt; &lt;input type="text" name="firstName" fieldName="firstName" class="input-participant-data"&gt; &lt;label for=""&gt;First Name&lt;/label&gt; &lt;input type="text" name="lastName" fieldName="lastName" class="input-participant-data"&gt; &lt;label for=""&gt;Last Name&lt;/label&gt; &lt;input type="email" name="email" fieldName="email" class="input-participant-data"&gt; &lt;label for=""&gt;Email&lt;/label&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="message d-none"&gt;Validated&lt;/div&gt; &lt;/form&gt;</code></pre> </div> </div> </p> <p>Codepen: <a href="https://codepen.io/make96/pen/yLEeMpO?editors=1111" rel="nofollow noreferrer">https://codepen.io/make96/pen/yLEeMpO?editors=1111</a></p>
[ { "answer_id": 74274854, "author": "Hagatopaxi", "author_id": 9060711, "author_profile": "https://Stackoverflow.com/users/9060711", "pm_score": -1, "selected": false, "text": "!" }, { "answer_id": 74275086, "author": "Feki Hamza", "author_id": 17811762, "author_profil...
2022/11/01
[ "https://Stackoverflow.com/questions/74274565", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18114084/" ]
74,274,590
<p>I want to do an API call using the Forecast air pollution data from this website <a href="https://openweathermap.org/api/air-pollution" rel="nofollow noreferrer">https://openweathermap.org/api/air-pollution</a></p> <p>The API call of the website state that it is these:</p> <pre><code>http://api.openweathermap.org/data/2.5/air_pollution/forecast?lat={lat}&amp;lon={lon}&amp;appid={API key} </code></pre> <p>Now I have a dataframe in pandas which has the longitude and latitude of 180 cities around the world.</p> <p>To collect the forecast data I gave this</p> <pre><code>lon= df.Longitude lat= df.Latitude appid= 'b0gs3g26768234d11ss6jh722ff100r8e' url = 'http://api.openweathermap.org/data/2.5/air_pollution/forecast?lat={lat}&amp;lon={lon}&amp;appid={b0gs3g26768234d11ss6jh722ff100r8e}' r= requests.get(url) r r.text </code></pre> <p>But it always say invalid API key and my API key is activated. I don't know what I doing wrong. Could someone please help me</p>
[ { "answer_id": 74275008, "author": "yeti", "author_id": 5647853, "author_profile": "https://Stackoverflow.com/users/5647853", "pm_score": 2, "selected": true, "text": "url = f\"http://api.openweathermap.org/data/2.5/air_pollution/forecast?lat={lat}&lon={lon}&appid={appid}\"\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74274590", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
74,274,595
<p>I have a dataverse table like this:</p> <p>E-mail: EDS:</p> <p>user1@gmail.com 221</p> <p>user1@gmail.com 123</p> <p>MyEmail@gmail.com 13</p> <p>MyEmail@gmail.com 21</p> <p>user3@gmail.com 123</p> <p>user4@gmail.com 221</p> <p>I want to check which EDS -s have user access on.</p> <p>for example, if user1 opens app it should return (221; 123)</p> <p><strong>Set(currentEDS, Concat(ConnexionConfigs, LookUp(ConnexionConfigs,'E-mail' = User().Email, EDS), &quot;; &quot;))</strong> that's how my code looks like. I am logged in with MyEmail@gmail.com, for some reason code returns 21; 21; 21; 21; 21; 21; there is 21 6 times, I think thats because there is 6 records in my dataverse table.</p>
[ { "answer_id": 74275008, "author": "yeti", "author_id": 5647853, "author_profile": "https://Stackoverflow.com/users/5647853", "pm_score": 2, "selected": true, "text": "url = f\"http://api.openweathermap.org/data/2.5/air_pollution/forecast?lat={lat}&lon={lon}&appid={appid}\"\n" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74274595", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18805039/" ]
74,274,622
<p>This is my xml source file.</p> <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt; &lt;ZEQUIPMENT_SVMX01_01&gt; &lt;IDOC BEGIN=&quot;1&quot;&gt; &lt;Z1EQUIPMENT_SVMX SEGMENT=&quot;1&quot;&gt; &lt;Z1CAWNM_SVMX SEGMENT=&quot;1&quot;&gt; &lt;ATNAM&gt;TS_DEVICE_USAGE_DEPARTMENT&lt;/ATNAM&gt; &lt;ATWRT&gt;ABC&lt;/ATWRT&gt; &lt;ATZHL&gt; 1&lt;/ATZHL&gt; &lt;/Z1CAWNM_SVMX&gt; &lt;/Z1EQUIPMENT_SVMX&gt; &lt;/IDOC&gt; &lt;IDOC BEGIN=&quot;1&quot;&gt; &lt;Z1EQUIPMENT_SVMX SEGMENT=&quot;1&quot;&gt; &lt;Z1CAWNM_SVMX SEGMENT=&quot;1&quot;&gt; &lt;ATNAM&gt;TS_DEVICE_USAGE_DEPARTMENT&lt;/ATNAM&gt; &lt;ATWRT&gt;LOA&lt;/ATWRT&gt; &lt;ATZHL&gt; 1&lt;/ATZHL&gt; &lt;/Z1CAWNM_SVMX&gt; &lt;Z1CAWNM_SVMX SEGMENT=&quot;1&quot;&gt; &lt;ATNAM&gt;TS_DEVICE_USAGE_DEPARTMENT&lt;/ATNAM&gt; &lt;ATWRT&gt;VET&lt;/ATWRT&gt; &lt;ATZHL&gt; 2&lt;/ATZHL&gt; &lt;/Z1CAWNM_SVMX&gt; &lt;/Z1EQUIPMENT_SVMX&gt; &lt;/IDOC&gt; &lt;/ZEQUIPMENT_SVMX01_01&gt; </code></pre> <p>and below is the output after my xslt mapping. as you can see there are 2 repeat line and my expected result is only 1 line. I have already spend a few day trying to solve the issue but until now still no idea how to remove it. any helps is much appreciate!!</p> <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt; &lt;a:Upsert_Installed_Product_Buffer_Object__cBulkRequest xmlns:a=&quot;http:///10&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&gt; &lt;batch&gt; &lt;sObject&gt; &lt;R3_DEVICE_USAGE_DEPARTMENT__c&gt;ABC&lt;/R3_DEVICE_USAGE_DEPARTMENT__c&gt; &lt;/sObject&gt; &lt;sObject&gt; &lt;R3_DEVICE_USAGE_DEPARTMENT__c&gt;LOA;VET&lt;/R3_DEVICE_USAGE_DEPARTMENT__c&gt; &lt;R3_DEVICE_USAGE_DEPARTMENT__c&gt;LOA;VET&lt;/R3_DEVICE_USAGE_DEPARTMENT__c&gt; &lt;/sObject&gt; &lt;/batch&gt; &lt;/a:Upsert_Installed_Product_Buffer_Object__cBulkRequest&gt; </code></pre> <p>here is my xslt mapping:</p> <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt; &lt;xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot; xmlns:a=&quot;http:///10&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&gt; &lt;xsl:output method=&quot;xml&quot; encoding=&quot;UTF-8&quot; indent=&quot;yes&quot;/&gt; &lt;xsl:template match=&quot;/&quot;&gt; &lt;a:Upsert_Installed_Product_Buffer_Object__cBulkRequest&gt; &lt;batch&gt; &lt;xsl:choose&gt; &lt;xsl:when test=&quot;ZEQUIPMENT_SVMX01&quot;&gt; &lt;xsl:apply-templates select=&quot;ZEQUIPMENT_SVMX01/IDOC&quot;/&gt; &lt;/xsl:when&gt; &lt;xsl:when test=&quot;ZEQUIPMENT_SVMX01_01&quot;&gt; &lt;xsl:apply-templates select=&quot;ZEQUIPMENT_SVMX01_01/IDOC&quot;/&gt; &lt;/xsl:when&gt; &lt;/xsl:choose&gt; &lt;/batch&gt; &lt;/a:Upsert_Installed_Product_Buffer_Object__cBulkRequest&gt; &lt;/xsl:template&gt; &lt;xsl:template match=&quot;IDOC&quot;&gt; &lt;sObject&gt; &lt;xsl:apply-templates select=&quot;Z1EQUIPMENT_SVMX/Z1CAWNM_SVMX[not(ATNAM=preceding::ATNAM[position()=0])]&quot;/&gt; &lt;/sObject&gt; &lt;/xsl:template&gt; &lt;xsl:template match=&quot;Z1CAWNM_SVMX&quot;&gt; &lt;xsl:variable name=&quot;ChararcteristicName&quot; select=&quot;ATNAM&quot;/&gt; &lt;xsl:element name=&quot;{concat('R3_',substring-after(ATNAM,'TS_'),'__c')}&quot;&gt; &lt;xsl:apply-templates select=&quot;../Z1CAWNM_SVMX[ATNAM = $ChararcteristicName]/ATWRT&quot;/&gt; &lt;/xsl:element&gt; &lt;/xsl:template&gt; &lt;xsl:template match=&quot;ATWRT&quot;&gt; &lt;xsl:value-of select=&quot;.&quot;/&gt; &lt;xsl:if test=&quot;position() != last()&quot;&gt; &lt;xsl:text&gt;;&lt;/xsl:text&gt; &lt;/xsl:if&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre>
[ { "answer_id": 74275381, "author": "Conal Tuohy", "author_id": 7372462, "author_profile": "https://Stackoverflow.com/users/7372462", "pm_score": 0, "selected": false, "text": "Z1EQUIPMENT_SVMX/Z1CAWNM_SVMX[not(ATNAM=preceding::ATNAM[position()=0])]\n" }, { "answer_id": 74275456, ...
2022/11/01
[ "https://Stackoverflow.com/questions/74274622", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7616185/" ]
74,274,649
<p>I made a program to find the same element in two arrays(only once) and take those element in new Array. It is running fine but don't know why I am getting 0 at the first index of my new arary. suppose if the answer should like <code>[9,8]</code> but it is printing <code>[0,9,8]</code>! Can you correct me where I am going wrong?</p> <p>newArray size should be 2 but I know it should have started with 0 but I am doing this because if I am starting newArray size with 0 - array out of bound exception will occur.</p> <pre><code>package Arrays; import java.util.Arrays; public class InteractionOfTwoArrays { public static void main(String[] args) { int arr1[]= new int[] {6,9,8,5}; int arr2[]= new int[] {9,2,4,1,8}; intersections(arr1,arr2); } public static void intersections(int arr1[], int arr2[]) { int newArraysize=1; for(int i=0; i&lt;arr1.length; i++) { // for getting size of the array for(int j=0; j&lt;arr2.length; j++) { if(arr1[i]==arr2[j]) { System.out.println(arr1[i]+&quot; and &quot;+arr2[j]+&quot; match!&quot;); newArraysize++; System.out.println(newArraysize); } } } System.out.println(newArraysize); int newArray[] = new int[newArraysize]; for(int i=0; i&lt;arr1.length; i++) { for(int j=0; j&lt;arr2.length;j++) { if(arr1[i]==arr2[j]) { newArray[i] = arr1[i]; System.out.println(arr1[i]+&quot; moved to &quot;+ newArray[i]); break; } } } System.out.println(Arrays.toString(newArray)); } } </code></pre> <p>I have tried to print where I am going wrong but failed to identify.</p>
[ { "answer_id": 74274945, "author": "Syed Aqeel Ashiq", "author_id": 2266682, "author_profile": "https://Stackoverflow.com/users/2266682", "pm_score": 0, "selected": false, "text": "System.out.println(newArraysize);" }, { "answer_id": 74275005, "author": "DummyBeginner", "...
2022/11/01
[ "https://Stackoverflow.com/questions/74274649", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19783908/" ]
74,274,663
<p>As we know, in CAN Acknowledgement bit is set when receiver receives the transmitted data correctly. Can you please explain how this bit is set and who monitors and sets at CAN lower level ?</p> <p>I am trying to test the below test case : In which tester is sending high priority frames until maximum timeout for Ar and after this maximum timeout i am getting positive response but ideally we should get no response. So i am trying to understand who sets the bit for Acknowledgement as I am getting positive response for my test case.</p>
[ { "answer_id": 74274945, "author": "Syed Aqeel Ashiq", "author_id": 2266682, "author_profile": "https://Stackoverflow.com/users/2266682", "pm_score": 0, "selected": false, "text": "System.out.println(newArraysize);" }, { "answer_id": 74275005, "author": "DummyBeginner", "...
2022/11/01
[ "https://Stackoverflow.com/questions/74274663", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20386718/" ]
74,274,667
<p>I am trying to restrict users from seeing certain information on a landing page to only page by comparing if todays date is after Tuesday at 6pm within the current week.</p> <p>I have been trying to setup this condition but Date/Time functions aren't my forte.</p> <p>Using the below I am able to determine the days of the week, but it seems a little buggy in that if within a calendar week a new month starts, the logic resets to the next/previous month.</p> <pre><code>const today = new Date(&quot;2022-11-03 16:20:04&quot;); const first = today.getDate() - today.getDay() + 1; const tuesday = new Date(today.setDate(first + 1)); const wednesday = new Date(today.setDate(first + 2)); const thursday = new Date(today.setDate(first + 3)); const friday = new Date(today.setDate(first + 4)); console.log('tuesday: ' + tuesday); const diffTime = Math.abs(tuesday - today); const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24)); console.log(diffDays + &quot; days&quot;); </code></pre> <p>I figured by determining by how many days from monday, I could determine if this had been surpassed or not. Unfortunately, this also doesn't take into account time, only date as well.</p>
[ { "answer_id": 74274945, "author": "Syed Aqeel Ashiq", "author_id": 2266682, "author_profile": "https://Stackoverflow.com/users/2266682", "pm_score": 0, "selected": false, "text": "System.out.println(newArraysize);" }, { "answer_id": 74275005, "author": "DummyBeginner", "...
2022/11/01
[ "https://Stackoverflow.com/questions/74274667", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1145731/" ]
74,274,681
<p>I can't find a solution to my problem. I want to create a <code>change_nick</code> command and I don't know the type/number of this option to use.</p> <p>My command creator:</p> <pre class="lang-js prettyprint-override"><code>commands.create ( { name: 'change_nick', description: 'changes nick for specified person', options: [ { name: 'user', description: 'user that name will be changed', type: 6, }, { name: &quot;new_username&quot;, description: &quot;new username&quot;, type: &quot;&quot; //that's what I'm searching for, }, ] }, ); </code></pre> <p>I tried browsing and reading the documentation but I couldn't find anything</p>
[ { "answer_id": 74274772, "author": "Zsolt Meszaros", "author_id": 6126373, "author_profile": "https://Stackoverflow.com/users/6126373", "pm_score": 2, "selected": false, "text": "commands.create({\n name: 'change_nick',\n description: 'changes nick for specified person',\n options: [\...
2022/11/01
[ "https://Stackoverflow.com/questions/74274681", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19271972/" ]
74,274,685
<p>I'm having a problem with what i asked on the title. In my program, I'm trying to wrap a dll file with folder. When I made the folder name as same as file name and try to find existance with Directory.Exists func... it doesn't work.</p> <p>[Detail Example]</p> <pre><code>string fileName = &quot;C:\User\Installprogram\Temp.dll&quot; //&lt;- &quot;Temp.dll&quot; is Directory if (!Directory.Exists(fileName)) return false; </code></pre> <p>I double checked if the directory is in proper place. Weird point is other folder names properly return true with above example. I'm sort of guessing if folder name contains &quot;.dll&quot; making unable to catch directory by Directory.Exists func.</p> <p>Help me</p>
[ { "answer_id": 74274777, "author": "Tim Schmelter", "author_id": 284240, "author_profile": "https://Stackoverflow.com/users/284240", "pm_score": 1, "selected": false, "text": "string folder = @\"C:\\User\\Installprogram\\Temp.dll\";\nstring file = @\"C:\\User\\Installprogram\\Temp.dll\\T...
2022/11/01
[ "https://Stackoverflow.com/questions/74274685", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20387078/" ]
74,274,713
<p>I have a Laravel 9 project and in the migration of one of the tables, I would like to insert some data as well when creating the table:</p> <pre><code>public function up() { Schema::create('tag_filters', function (Blueprint $table) { $table-&gt;id(); $table-&gt;string('tag_name'); $table-&gt;string('tag_uri')-&gt;nullable(); $table-&gt;string('tag_color'); $table-&gt;unsignedBigInteger('tag_parent')-&gt;nullable(); $table-&gt;timestamps(); $table-&gt;foreign('tag_parent')-&gt;references('id')-&gt;on('tag_filters')-&gt;onDelete('cascade'); DB::table('tag_filters')-&gt;insert( array( [ 'tag_name' =&gt; 'javascript', 'tag_color' =&gt; 'f9bc64', ], ) ); }); } </code></pre> <p>But now when I run the migrations by saying <code>php artisan migrate</code>, I get this error:</p> <p><strong>SQLSTATE[42S02]: Base table or view not found: 1146 Table 'forum.tag_filters' doesn't exist (SQL: insert into <code>tag_filters</code>...</strong></p> <p>So what's going wrong here?</p> <p>How can I properly insert some data when creating a new table via the Migrations in Laravel?</p>
[ { "answer_id": 74274855, "author": "ThePigeon", "author_id": 20387210, "author_profile": "https://Stackoverflow.com/users/20387210", "pm_score": 3, "selected": true, "text": "tag_filters" }, { "answer_id": 74274896, "author": "Delano van londen", "author_id": 19923550, ...
2022/11/01
[ "https://Stackoverflow.com/questions/74274713", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17119202/" ]
74,274,720
<p>I'm trying to make a function that will accept a list of filenames as parameter to access data from two files at a time and compare the values, if value matches it will be added to the set and then print set. The problem is that files have some matching values but function prints an empty set at the end.</p> <pre><code>def cross_reference(files): set_of_users = set() n = len(files) files = cycle(files) for index in range(n): with open(next(files), mode='r') as read_file: with open(next(files), mode='r') as read_file1: for contact in read_file: for contact1 in read_file1: if contact == contact1: set_of_users.add(contact) break print(set_of_users) </code></pre> <p>The files having values are:</p> <p><code>file1.txt</code>:</p> <pre class="lang-none prettyprint-override"><code>0709-12345 0724-87234 0723-67890 0721-16273 </code></pre> <p><code>file2.txt</code>:</p> <pre class="lang-none prettyprint-override"><code>0709-87263 0743-76346 0724-87234 0777-89264 </code></pre> <p><code>file3.txt</code>:</p> <pre class="lang-none prettyprint-override"><code>0724-87234 0743-87469 0709-12398 0709-78548 </code></pre> <p><code>0724-87234</code> is common in all files but is not added in the set.</p>
[ { "answer_id": 74275040, "author": "Yevhen Kuzmovych", "author_id": 4727702, "author_profile": "https://Stackoverflow.com/users/4727702", "pm_score": 0, "selected": false, "text": "for contact1 in read_file1:" }, { "answer_id": 74275165, "author": "sunnytown", "author_id"...
2022/11/01
[ "https://Stackoverflow.com/questions/74274720", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19914532/" ]
74,274,724
<p>I've multiple python packages installed on my system. My update script calls <code>pip-review --local --auto</code> to update all the python packages. However, I don't want to update all packages. What I want is <code>pip-review</code> to update all packages except <code>scons</code>, since one of my programs needs an older version of <code>scons</code>. Currently to do this, I run <code>pip-review --local --auto &amp;&amp; python3 pip uninstall -y scons &amp;&amp; python3 -m pip install -Iv scons==3.1.2</code> which updates all packages and then uninstalls the new version of <code>scons</code> and then re-installs it with a specific version number. Is there a nicer way to do this?</p>
[ { "answer_id": 74274961, "author": "nannerpuss", "author_id": 7292279, "author_profile": "https://Stackoverflow.com/users/7292279", "pm_score": -1, "selected": false, "text": "pip install -r $(grep -v '^ *#\\|^pkg1\\|^pkg2' requirements.txt | grep .)\n" }, { "answer_id": 74428647...
2022/11/01
[ "https://Stackoverflow.com/questions/74274724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19827830/" ]
74,274,725
<p>Employee table have multiple employee name for same employee id. Need to identify correct name from name table and display matched row alone. In case name table don't have employee id present in employee table then display multiple employee name.<br /> Emp table</p> <pre class="lang-none prettyprint-override"><code>id name status 1 David 0 1 James 1 2 Kelvin 0 2 John 1 </code></pre> <pre class="lang-none prettyprint-override"><code>Name table id Name 1 James </code></pre> <p>Expected output</p> <pre class="lang-none prettyprint-override"><code>Id Name status 1 James 1 2 Kelvin 0 2 John 1 </code></pre> <p>If I do inner join then I will get only match record. When emp id available in both employee and name then display only matched record, when empid present in employee table not available in name table then display all rows.</p>
[ { "answer_id": 74274961, "author": "nannerpuss", "author_id": 7292279, "author_profile": "https://Stackoverflow.com/users/7292279", "pm_score": -1, "selected": false, "text": "pip install -r $(grep -v '^ *#\\|^pkg1\\|^pkg2' requirements.txt | grep .)\n" }, { "answer_id": 74428647...
2022/11/01
[ "https://Stackoverflow.com/questions/74274725", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3675044/" ]
74,274,759
<p>I am trying to make a program where I have a list <code>my_list_1 = [1,2,3,...]</code> and a second list `my_list_2 = [1,2,3,...] and len(my_list_1) &lt; len(my_list_2). I want to iterate through the lists like this:</p> <pre><code>my_list_1 = [1,2,3] my_list_2 = [5,6,7,8,9] result = [] for i in range(len(my_list_2)): result.append(my_list_1[i] + my_list_2[i]) # i == 0: 1 + 5 = 6 # i == 1: 2 + 6 = 8 # i == 2: 3 + 7 = 10 # i == 3: 1 + 8 = 9 # i == 4: 2 + 9 = 11 &quot;&quot;&quot; what I want to happen is when i &gt; len(my_list_1), instead of giving a index out of range error, I want the loop to start at the beginning if the smaller list&quot;&quot;&quot; </code></pre> <p>I tried something like this:</p> <pre><code> for i in range(len(my_list_2)): if i % (len(my_list_1) - 1) == 0 or i == 0: x = 0 else: x+=1 result.append(my_list_1[x] + my_list_2[i]) </code></pre> <p>or</p> <pre><code>for i in range(len(my_list_2)): if x == (len(my_list_1) - 1) or i == 0: x = 0 else: x += 1 result.append(my_list_1[x] + my_list_2[i]) </code></pre> <p>this works but I am looking for something a bit more elegant and possibibly even making a copy of <code>my_list_1</code> and extend it to the length of <code>my_list_2</code> so that it would look like this:</p> <pre><code>&gt;&gt;&gt; my_list_1 = [1,2,3] &gt;&gt;&gt; my_list_2 = [5,6,7,8,9] &gt;&gt;&gt; extend_list(my_list_1, len(my_list_2)) [1,2,3,1,2] </code></pre>
[ { "answer_id": 74274961, "author": "nannerpuss", "author_id": 7292279, "author_profile": "https://Stackoverflow.com/users/7292279", "pm_score": -1, "selected": false, "text": "pip install -r $(grep -v '^ *#\\|^pkg1\\|^pkg2' requirements.txt | grep .)\n" }, { "answer_id": 74428647...
2022/11/01
[ "https://Stackoverflow.com/questions/74274759", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19199509/" ]
74,274,826
<p>I am writing a utility script to fix a Verilog code using <code>sed</code>. What I'm trying to do is converting code as follows</p> <p>input file</p> <pre><code>my_instance_name ( .port1 (port1 ) .port2 (port2 ) // comment for port line 2 .port3 (port3 ) .port4 (port4 ) // comment for port line 4 ); </code></pre> <p>What I want</p> <pre><code>my_instance_name ( .port1 (port1 ), .port2 (port2 ), // comment for port line 2 .port3 (port3 ), .port4 (port4 ) // comment for port line 4 ); </code></pre> <p>The points are</p> <ol> <li>Append comma just after the closing parenthesis of each 'port' lines</li> <li>Do not append comma for the last 'port'</li> <li>Preserve the comments if exist (comment starts with double-slash like C)</li> <li>Whitespaces (except the line breaks) are not important. it is only for human readability.</li> <li>There can be multiple linebreaks after the last port line</li> </ol> <p>If the <code>sed</code> script becomes too complicated, it is also OK to just prepend the comma just before the dot, except the first port line. i.e, the following code is OK although it is not pretty.</p> <pre><code>my_instance_name ( .port1 (port1 ) ,.port2 (port2 ) // comment for port line 2 ,.port3 (port3 ) ,.port4 (port4 ) // comment for port line 4 ); </code></pre> <p>I could only manage appending commas to all 'port' lines via the following two line</p> <pre><code>sed -i /^\s*my_instance_name.*/,/);/{s/^\(\s*\..*)\)\(\s*\/\/.*\)/\1,\2/} my_verilog.txt sed -i /^\s*my_instance_name.*/,/);/{s/^\(\s*\..*)\)\s*\$/\1,/} my_verilog.txt </code></pre> <p>It detects the code scope from &quot;my_instance_name&quot; to &quot;);&quot;. The first line insert comma between the closing parenthesis and comment. The second line is for port lines without comments.</p> <p>But I have no idea how to exclude the last line.</p>
[ { "answer_id": 74274916, "author": "tripleee", "author_id": 874188, "author_profile": "https://Stackoverflow.com/users/874188", "pm_score": 1, "selected": false, "text": "awk '/my_instance_name/ { p=1 }\n p && /\\);/ { if (prev) print prev; print; p=0; next }\n p && /port/ { if (prev) ...
2022/11/01
[ "https://Stackoverflow.com/questions/74274826", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17416055/" ]
74,274,828
<p>I created an &quot;Excel VSTO document-level&quot; project in Visual Studio. I have a pre designed &quot;Action Pane&quot; and a Tab Ribbon with a button in it to show my action pane.</p> <p>My problem is my action pane keeps popping up (show) at least 1 time and quickly disappears before I do anything.</p> <p>Here is my code so far in my ribbon:</p> <pre><code>Imports Microsoft.Office.Tools.Ribbon Public Class Ribbon1 Dim actionsPane1 As New ActionsPaneControl1() Private Sub Ribbon1_Load(ByVal sender As System.Object, ByVal e As RibbonUIEventArgs) Handles MyBase.Load Globals.ThisWorkbook.ActionsPane.Clear() Globals.ThisWorkbook.ActionsPane.Controls.Add(actionsPane1) actionsPane1.Hide() Globals.ThisWorkbook.Application.DisplayDocumentActionTaskPane = False End Sub Dim boolAP1toggle As Boolean = True Private Sub Button1_Click(sender As Object, e As RibbonControlEventArgs) Handles Button1.Click If boolAP1toggle = True Then Globals.ThisWorkbook.Application.DisplayDocumentActionTaskPane = True actionsPane1.Show() boolAP1toggle = False Else Globals.ThisWorkbook.Application.DisplayDocumentActionTaskPane = False actionsPane1.Hide() boolAP1toggle = True End If End Sub End Class </code></pre>
[ { "answer_id": 74279802, "author": "Eugene Astafiev", "author_id": 1603351, "author_profile": "https://Stackoverflow.com/users/1603351", "pm_score": 1, "selected": false, "text": "true" }, { "answer_id": 74285387, "author": "Milad", "author_id": 11224593, "author_prof...
2022/11/01
[ "https://Stackoverflow.com/questions/74274828", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11224593/" ]
74,274,859
<p>Suppose we have current time and then add the 60 munites to the current time.</p> <pre><code>Time.now + 1.hours # =&gt; 2022-11-01 16:47:02.965861 +0500 </code></pre> <p>after that we get the next half hour like <code>17:00:00</code></p> <p>I'm able to get the previous half hour time from this code, but unable to find the next half hour time.</p> <pre><code>time = Time.now - 30.minutes # =&gt; 2022-11-01 15:22:59.942013 +0500 Time.at((time.to_time.to_i/1800).round * 1800).to_datetime # =&gt; Tue, 01 Nov 2022 15:00:00 +0500 </code></pre>
[ { "answer_id": 74275050, "author": "Abdul Rehman", "author_id": 9379722, "author_profile": "https://Stackoverflow.com/users/9379722", "pm_score": 0, "selected": false, "text": "5:01 and 5:29" }, { "answer_id": 74275260, "author": "Stefan", "author_id": 477037, "author...
2022/11/01
[ "https://Stackoverflow.com/questions/74274859", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17096125/" ]
74,274,867
<p>I am building a carousel where I want the preview page only on the right. This is the kind of result that I want.</p> <p><a href="https://i.stack.imgur.com/6y1Qi.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6y1Qi.jpg" alt="enter image description here" /></a></p> <p>I saw <a href="https://stackoverflow.com/questions/54328666/flutter-pageview-show-preview-of-page-on-left-and-righthttps://">this</a> question but it has previews on both sides. Can anyone suggest what I should do?</p>
[ { "answer_id": 74275118, "author": "Md. Kamrul Amin", "author_id": 6067774, "author_profile": "https://Stackoverflow.com/users/6067774", "pm_score": 0, "selected": false, "text": "import 'package:flutter/material.dart';\n\nclass NewPage extends StatelessWidget {\n const NewPage({Key? ke...
2022/11/01
[ "https://Stackoverflow.com/questions/74274867", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9451058/" ]
74,274,888
<p>I have a table like these</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>country</th> <th>gender</th> <th>player</th> <th>score</th> <th>year</th> </tr> </thead> <tbody> <tr> <td>Germany</td> <td>male</td> <td>Michael</td> <td>14</td> <td>1990</td> </tr> <tr> <td>Austria</td> <td>male</td> <td>Simon</td> <td>13</td> <td>1990</td> </tr> <tr> <td>Germany</td> <td>female</td> <td>Mila</td> <td>16</td> <td>1990</td> </tr> <tr> <td>Austria</td> <td>female</td> <td>Simona</td> <td>15</td> <td>1990</td> </tr> </tbody> </table> </div> <p>This is a table in the database. It shows 70 countries around the world with player names and gender. It shows which player score how many goals in which year. The years goes from 1990 to 2015. So the table is large. Now I would like to know which female player and which male player score most in every year from 2010 to 2012.</p> <p>I expect this:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>gender</th> <th>player</th> <th>score</th> <th>year</th> </tr> </thead> <tbody> <tr> <td>male</td> <td>Michael</td> <td>24</td> <td>2010</td> </tr> <tr> <td>male</td> <td>Simon</td> <td>19</td> <td>2011</td> </tr> <tr> <td>male</td> <td>Milos</td> <td>19</td> <td>2012</td> </tr> <tr> <td>female</td> <td>Mara</td> <td>16</td> <td>2010</td> </tr> <tr> <td>female</td> <td>Simona</td> <td>16</td> <td>2011</td> </tr> <tr> <td>female</td> <td>Dania</td> <td>17</td> <td>2012</td> </tr> </tbody> </table> </div> <p>I used that code but got an error</p> <pre><code>SELECT gender,year,player, max(score) as score from (football) where player = max(score) and year in ('2010','2011','2012') group by 1,2,3 </code></pre> <p>football is the table name</p>
[ { "answer_id": 74275118, "author": "Md. Kamrul Amin", "author_id": 6067774, "author_profile": "https://Stackoverflow.com/users/6067774", "pm_score": 0, "selected": false, "text": "import 'package:flutter/material.dart';\n\nclass NewPage extends StatelessWidget {\n const NewPage({Key? ke...
2022/11/01
[ "https://Stackoverflow.com/questions/74274888", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20378009/" ]
74,274,931
<p>The following NoSuchMethodError was thrown building FutureBuilder&lt;DocumentSnapshot&lt;Map&lt;String, dynamic&gt;&gt;&gt;(dirty, state: _FutureBuilderState&lt;DocumentSnapshot&lt;Map&lt;String, dynamic&gt;&gt;&gt;#6c166):</p> <pre><code>The getter 'hasData' was called on null. Receiver: null Tried calling: hasData </code></pre> <p>I get this issue when like my product and this product added to favorite screen.can anyone know what is the error.all packages is up to date with null safety</p> <pre><code>class _FavoriteScreenState extends State&lt;FavoriteScreen&gt; { @override Widget build(BuildContext context) { return Container( child: StreamBuilder( stream: FirebaseFirestore.instance .collection('users') .doc(parentIdGlobal) .collection('favorites') .snapshots(), builder: (context, AsyncSnapshot snapshot) { if (!snapshot.hasData) return Center( child: CircularProgressIndicator(), ); final List&lt;QueryDocumentSnapshot&lt;Map&lt;String, dynamic&gt;&gt;&gt; docSnapList = snapshot.data?.docs ?? []; if (docSnapList.isEmpty) { return Center( child: Padding( padding: const EdgeInsets.all(10.0), child: WebsafeSvg.asset( 'assets/images/no_favorite_item.svg', fit: BoxFit.cover, height: MediaQuery.of(context).size.height / 5, ), ), ); } final List&lt;Map&lt;String, dynamic&gt;&gt; docList = docSnapList.map((QueryDocumentSnapshot&lt;Map&lt;String, dynamic&gt;&gt; queryDocumentSnapshot) =&gt; queryDocumentSnapshot.data()).toList(); return ListView.builder( scrollDirection: Axis.vertical, shrinkWrap: true, itemCount: docList.length, itemBuilder: (context, index) { if (docSnapList.isEmpty) { return Center(child: Text('No items yet!')); } final itemId = docList[index]['id']; final isLiked = docList[index]['isLiked']; return Visibility( visible: isLiked, child: FutureBuilder( future: FirebaseFirestore.instance .collection('items') .doc(itemId) .get(), builder: (context, AsyncSnapshot) { var data; if (!data.hasData) return Center( child: CircularProgressIndicator(), ); bool isSold = docList[index]['isSold']; bool isLiked = docList[index]['isLiked']; String itemId = docList[index]['itemId']; String seller = docList[index]['seller']; String sellerName = docList[index]['sellerName']; String title = docList[index]['title']; String desc = docList[index]['desc']; String price = docList[index]['price']; String condition = docList[index]['condition']; String category = docList[index]['category']; String location = docList[index]['location']; String itemImage = docList[index]['imageDownloadUrl']; print('ITEM IMAGE VALUE: $itemImage'); return EcommerceScreenProductItem( itemId: itemId, seller: seller, sellerName: sellerName, title: title, desc: desc, price: price, isLiked: isLiked, isSold: isSold, condition: condition, category: category, location: location, itemImage: itemImage, ); }, ), ); }); }, ), ); } } </code></pre>
[ { "answer_id": 74275343, "author": "Albert", "author_id": 12371668, "author_profile": "https://Stackoverflow.com/users/12371668", "pm_score": 1, "selected": false, "text": "if (!snapshot.hasData)\n return Center(\n child: CircularProgressIndicator(),\n );\n" }, ...
2022/11/01
[ "https://Stackoverflow.com/questions/74274931", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20061332/" ]
74,274,971
<p>Using the dataframe <code>mtcars</code> I would like to add the column <code>qsec_control</code> which is calculated as the <code>mean(qsec)</code> of all rows that don't have the same <code>cyl</code> as the current row (e.g. if <code>cyl == 6</code>, it would take <code>mean(qsec[cyl != 6])</code>). The question feels somewhat dumb, but I cant figure out how to do this.</p>
[ { "answer_id": 74275168, "author": "diomedesdata", "author_id": 10366237, "author_profile": "https://Stackoverflow.com/users/10366237", "pm_score": 2, "selected": false, "text": "data.table" }, { "answer_id": 74275512, "author": "zephryl", "author_id": 17303805, "auth...
2022/11/01
[ "https://Stackoverflow.com/questions/74274971", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8275345/" ]
74,274,983
<p>I started recently as a developer and I am still struggling a bit with the way I write my code.</p> <p>Is there a better way to write this two if-statements? How would you write it and why?</p> <p>Java code:</p> <pre><code>@Override @Transactional public void deleteItem(final ConfigurationType type, final long itemId, final boolean force) { this.applicationNameUtils.throwOnInvalidApplication(type.getApplication()); final ConfigurationItemModel item = this.configurationItemRepository.findByApplicationAndTopicAndId(type.getApplication(), type.getTopic(), itemId) .orElseThrow(() -&gt; new ResourceNotFoundException(itemId, &quot;Configuration Item&quot;)); if (Boolean.TRUE.equals(item.getContentModificationOnly()) &amp;&amp; Boolean.FALSE.equals(force)) { throw new ContentModificationOnlyException(&quot;Configuration Item cannot be deleted&quot;); } if ((Boolean.TRUE.equals(item.getContentModificationOnly()) || Boolean.FALSE.equals(item.getContentModificationOnly())) &amp;&amp; Boolean.TRUE.equals(force)) { this.assignmentService.deleteAssignmentsByItem(item); this.configurationInstanceRepository.deleteByItem(item); this.configurationItemRepository.deleteById(itemId); } } </code></pre> <p>I am not sure if I can somehow combine this two in a if-else.</p>
[ { "answer_id": 74275168, "author": "diomedesdata", "author_id": 10366237, "author_profile": "https://Stackoverflow.com/users/10366237", "pm_score": 2, "selected": false, "text": "data.table" }, { "answer_id": 74275512, "author": "zephryl", "author_id": 17303805, "auth...
2022/11/01
[ "https://Stackoverflow.com/questions/74274983", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19018545/" ]
74,274,991
<p>I know we can retry a failed HTTP API request through <code>retry</code> or <code>retryWhen</code> pipe mehtods from rxjs. I want to do something similar on a successful API call, based on a particular condition in the response received.</p> <p>Any help on this is much appreciated.</p>
[ { "answer_id": 74275168, "author": "diomedesdata", "author_id": 10366237, "author_profile": "https://Stackoverflow.com/users/10366237", "pm_score": 2, "selected": false, "text": "data.table" }, { "answer_id": 74275512, "author": "zephryl", "author_id": 17303805, "auth...
2022/11/01
[ "https://Stackoverflow.com/questions/74274991", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1990582/" ]
74,275,017
<p>I have a spreadsheet that has two values; &quot;Show Start&quot; time (eg 20:30) and &quot;Off Sale&quot; time (eg: 20:25)</p> <p>I'm using a large amount of data to check these values are set as they should be.</p> <p>I'm looking to set a conditional format, to show if the &quot;Off Sale&quot; time is anything but exactly 5 minutes before the &quot;Show Start&quot; time, to check that shows are set to come off sale 5 minutes before the show starts.</p> <p>EG:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Show Start</th> <th>Off Sale</th> </tr> </thead> <tbody> <tr> <td>20:30</td> <td>18:55</td> </tr> <tr> <td>19:00</td> <td>18:55</td> </tr> </tbody> </table> </div> <p>Link to an example spreadsheet <a href="https://docs.google.com/spreadsheets/d/1NU-F9io67d5eFOf2N1eV00W0_kT-KRSGPbRHPAc4PPk/edit?usp=sharing" rel="nofollow noreferrer">here</a></p> <p>I am limited with how much I can change the data from hour:time format, as other users need to read the sheet in hour &amp; time format</p> <p>Tried a variety of conditional formatting custom formulas, less than / greater than values, but I'm not familiar with using hour &amp; date formats enough to subtract 5 minutes from the Show Start value for example</p>
[ { "answer_id": 74275184, "author": "player0", "author_id": 5632629, "author_profile": "https://Stackoverflow.com/users/5632629", "pm_score": 2, "selected": true, "text": "=(B3+\"0:05\")=A3\n" }, { "answer_id": 74275216, "author": "Osm", "author_id": 19529694, "author_...
2022/11/01
[ "https://Stackoverflow.com/questions/74275017", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19976866/" ]
74,275,028
<p>I'm trying to send multiple images to nodejs and upload them to Cloudinary using multer, not multiple images from one file input, but from different file inputs, like so:</p> <pre><code>&lt;input class=&quot;form-control&quot; type=&quot;file&quot; id=&quot;eventimage1&quot; &gt; &lt;input class=&quot;form-control&quot; type=&quot;file&quot; id=&quot;eventimage2&quot; &gt; </code></pre> <p>but I don't know if multer can do it. There are some solutions online but it doesn't apply to may case, I don't know if there is a way to manipulate this:</p> <pre><code>var upload = multer(); app.post('/PATH', upload.array('uploadedImages', 10),FUNCTION) </code></pre> <p>to solve the issue multer has.</p> <p>this is what I'm currently working with:</p> <pre><code>var upload = multer(); app.post('/PATH', upload.single(&quot;Upload_event_image&quot;),FUNCTION) </code></pre> <p>and sending it to Cloudinary this way:</p> <pre><code>const img = await cloudinary.uploader.upload(req.file.path, { public_id: `${Event_title}_eventImage${Event_owners_id}`, }); </code></pre> <p>so my question is how can I get the multiple images with multer and send all of them using Cloudinary</p>
[ { "answer_id": 74276027, "author": "Heiko Theißen", "author_id": 16462950, "author_profile": "https://Stackoverflow.com/users/16462950", "pm_score": 2, "selected": true, "text": "upload.any()" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74275028", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11120306/" ]
74,275,067
<p>I have a requirement to sort XML tag value by name and not by position, as the xml tags are dynamic i.e the number of tags aren't fixed. So far I've tried below code but it fails to give the expected output.</p> <pre><code>$ sed -e 's/&lt;timestamp&gt;/&amp; /' file | sort -n -k2 | sed 's/ //g' </code></pre> <p>XML records :-</p> <pre><code>&lt;data1&gt;&lt;Version&gt;101&lt;/Version&gt;&lt;timestamp&gt;2022-11-01T05:51:33.540&lt;/timestamp&gt;&lt;newtag&gt;xlc&lt;newtag&gt;&lt;name&gt;XXX&lt;/name&gt;&lt;/data1&gt; &lt;data1&gt;&lt;Version&gt;102&lt;/Version&gt;&lt;timestamp&gt;2022-11-01T05:49:32.511&lt;/timestamp&gt;&lt;newtag&gt;xlc&lt;newtag&gt;&lt;name&gt;BBB&lt;/name&gt;&lt;/data1&gt; &lt;data1&gt;&lt;Version&gt;101&lt;/Version&gt;&lt;timestamp&gt;2022-11-01T05:54:30.540&lt;/timestamp&gt;&lt;name&gt;AAA&lt;/name&gt;&lt;/data1&gt; &lt;data2&gt;&lt;Version&gt;102&lt;/Version&gt;&lt;timestamp&gt;2022-11-01T05:50:33.540&lt;/timestamp&gt;&lt;newtag&gt;xlc&lt;newtag&gt;&lt;name&gt;XXX&lt;/name&gt;&lt;/data2&gt; &lt;data2&gt;&lt;Version&gt;101&lt;/Version&gt;&lt;timestamp&gt;2022-11-01T05:41:33.540&lt;/timestamp&gt;&lt;name&gt;YYY&lt;/name&gt;&lt;/data2&gt; &lt;data2&gt;&lt;Version&gt;102&lt;/Version&gt;&lt;newtag&gt;xlc&lt;newtag&gt;&lt;timestamp&gt;2022-11-01T05:50:12.510&lt;/timestamp&gt;&lt;name&gt;BBB&lt;/name&gt;&lt;/data2&gt; </code></pre> <p>expected output :-</p> <pre><code>&lt;data2&gt;&lt;Version&gt;101&lt;/Version&gt;&lt;timestamp&gt;2022-11-01T05:41:33.540&lt;/timestamp&gt;&lt;name&gt;YYY&lt;/name&gt;&lt;/data2&gt; &lt;data1&gt;&lt;Version&gt;102&lt;/Version&gt;&lt;timestamp&gt;2022-11-01T05:49:32.511&lt;/timestamp&gt;&lt;newtag&gt;xlc&lt;newtag&gt;&lt;name&gt;BBB&lt;/name&gt;&lt;/data1&gt; &lt;data2&gt;&lt;Version&gt;102&lt;/Version&gt;&lt;newtag&gt;xlc&lt;newtag&gt;&lt;timestamp&gt;2022-11-01T05:50:12.510&lt;/timestamp&gt;&lt;name&gt;BBB&lt;/name&gt;&lt;/data2&gt; &lt;data2&gt;&lt;Version&gt;102&lt;/Version&gt;&lt;timestamp&gt;2022-11-01T05:50:33.540&lt;/timestamp&gt;&lt;newtag&gt;xlc&lt;newtag&gt;&lt;name&gt;XXX&lt;/name&gt;&lt;/data2&gt; &lt;data1&gt;&lt;Version&gt;101&lt;/Version&gt;&lt;timestamp&gt;2022-11-01T05:51:33.540&lt;/timestamp&gt;&lt;newtag&gt;xlc&lt;newtag&gt;&lt;name&gt;XXX&lt;/name&gt;&lt;/data1&gt; &lt;data1&gt;&lt;Version&gt;101&lt;/Version&gt;&lt;timestamp&gt;2022-11-01T05:54:30.540&lt;/timestamp&gt;&lt;name&gt;AAA&lt;/name&gt;&lt;/data1&gt; </code></pre>
[ { "answer_id": 74276027, "author": "Heiko Theißen", "author_id": 16462950, "author_profile": "https://Stackoverflow.com/users/16462950", "pm_score": 2, "selected": true, "text": "upload.any()" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74275067", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20387293/" ]
74,275,099
<p>I have a table showing subscriptions with a column for active date and a column for inactive date. I need a query which counts the number of active subscriptions for each specific date in a date range.</p> <p>I'm struggling to add in a row for each date in my date range so that I can then compare with the other date columns in my table.</p> <p>Example of my table</p> <p><a href="https://i.stack.imgur.com/nRSFw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nRSFw.png" alt="enter image description here" /></a></p> <p>Example of the result I need</p> <p><a href="https://i.stack.imgur.com/5Vgg2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5Vgg2.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74275300, "author": "mtm1186", "author_id": 13919405, "author_profile": "https://Stackoverflow.com/users/13919405", "pm_score": 0, "selected": false, "text": "SELECT \ntype,\nTO_DATE(date, 'DD-MM-YYYY') as date,\ncount(date) AS count_of_dates\nFROM table\nGROUP BY type, da...
2022/11/01
[ "https://Stackoverflow.com/questions/74275099", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11771017/" ]
74,275,200
<p>I have to create a program creates a new string from a given string, removing the first and last characters of the string if the first or last character are 'P'. Then return the original string if the condition is not satisfied. The code I wrote does not throw an error, but clearly the <strong>if</strong> condition is wrong since the code is always returning only the <strong>str</strong>. Could someone clarify what's the issue?</p> <pre><code>function remove(str) { if (str.indexOf(0) === &quot;p&quot; &amp;&amp; str.indexOf(-1) === &quot;p&quot;) { return str.substring(1, str.length - 1); } else { return str; } } console.log(remove(&quot;pparallelepipedp&quot;)); </code></pre>
[ { "answer_id": 74275288, "author": "Hashim", "author_id": 7725195, "author_profile": "https://Stackoverflow.com/users/7725195", "pm_score": -1, "selected": false, "text": "const remove = (str) => {\n // This will convert the string into an array\n // https://www.w3schools.com/jsref/j...
2022/11/01
[ "https://Stackoverflow.com/questions/74275200", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20364230/" ]
74,275,204
<p>Hi I want to know what is the exact event.keycode number values for below special characters ! @ # $ % ^ &amp; * ( ) .</p> <p>I have the below code.</p> <pre><code>$(window).keydown(function (event) { if (event.keyCode == 116 || event.keyCode == 93 || event.keyCode == 33 || event.keyCode == 34 || event.keyCode == 123 || event.keyCode == 154 || event.keyCode == 82 || event.keyCode == 17 || event.keyCode === 38 || event.keyCode === 40 || event.keyCode === 13 ) { event.preventDefault(); return false; } }); </code></pre> <p>I want to use the above function and prevent the special characters from typing when using mobile devices.</p> <p>I tried the below event.keycode numbers . But the same is not working.</p> <pre><code> event.keyCode == 161 || event.keyCode == 64 || event.keyCode == 163 || event.keyCode == 164 || event.keyCode == 165 || event.keyCode == 160 || event.keyCode == 166 || event.keyCode == 171 || event.keyCode === 168 || event.keyCode === 169 </code></pre> <p>I am trying to find the solution and learn in the process.</p>
[ { "answer_id": 74275306, "author": "DBS", "author_id": 1650337, "author_profile": "https://Stackoverflow.com/users/1650337", "pm_score": 2, "selected": false, "text": ".key" }, { "answer_id": 74275329, "author": "Fralle", "author_id": 3155183, "author_profile": "https...
2022/11/01
[ "https://Stackoverflow.com/questions/74275204", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2526830/" ]
74,275,206
<p>I'm trying to code a memory game to get better with my C programming skills, but I'm now facing a run time error and I really have no clue how to fix it. These are the game rules: &quot; Simple Simon is a memory-test game. In this game, the computer displays a sequence of digits on the screen for a short period of time. You then have to memorize them, and when the digits disappear from the screen, you must enter the same sequence of digits. When you succeed 3 times in a row, the process repeats with a longer sequence of digits for you to try. The objective is to continue the process for as long as possible &quot; The game starts with a 3 digit sequence and it runs smoothly till it gets to a sequence of 5 digits. At this point, in the block that confront the user input (<code>guessedNumArr[]</code>) with the sequence to guess (<code>numToGuess[]</code>), it changes the number of <code>numToGuess[]</code> at index [0]. This change that I really can not explain to myself makes the user automatically lose the game.</p> <p>This is the code: `</p> <pre><code>#include &lt;stdio.h&gt; #include &quot;stdbool.h&quot; #include &quot;time.h&quot; #include &quot;stdlib.h&quot; #include &quot;ctype.h&quot; int main() { //declaring variables bool play = true; time_t now; int try=1, anotherGame, difficulty=5, numToGuess[difficulty]; int count=0, guessedNum, guessedNumArr[difficulty], singleScore=0, totalScore=0; //initializing the game puts(&quot;\nSimple Simon is a memory-test game. In this game, the\n&quot; &quot;computer displays a sequence of digits on the screen for a short period of time.\n&quot; &quot;You then have to memorize them, and when the digits disappear from the screen,\n&quot; &quot;you must enter exactly the same sequence of digits. &quot; &quot;Each time you succeed 3 times in a row, the process repeats with a longer sequence of digits for you to try.\n&quot; &quot;The objective is to continue the process for as long as possible\n&quot; &quot;Press enter to play&quot;); scanf(&quot;%c&quot;, &amp;anotherGame); do { qui:; const unsigned int DELAY = 2; //Creating the array of nums to guess srand(time(NULL)); for (int i = 0; i &lt; difficulty; i++) { int casualNum = rand()%10; numToGuess[i] = casualNum; printf(&quot;%d &quot;, numToGuess[i]); } //hiding the nums to guess now=clock(); for (; clock() - now &lt; DELAY * CLOCKS_PER_SEC;); puts(&quot;\n&quot;); //scanning player guessed nums for (int k = 0; k &lt; difficulty; k++) { if (k &lt; 1) { puts(&quot;Try to enter the same exact sequence of numbers, remember to put a space in between the numbers:\n&quot;); } scanf(&quot;%u&quot;, &amp;guessedNum); guessedNumArr[k] = guessedNum; } //counting how much nums player guessed correctly for (int j = 0; j &lt; difficulty; j++) { /* this two prinf() show where the error is, as you can see the program will change the element of numToGuess[0] and i really don't know why */ printf(&quot;%d --- &quot;, guessedNumArr[j]); printf(&quot;%d\n&quot;, numToGuess[j]); if (guessedNumArr[j] == numToGuess[j]) { ++count; } } ++try; //scoring a point if player guessed all nums and detecting if player lost the game if (count == difficulty) { singleScore++; totalScore++; count = 0; if(singleScore&lt;3){ goto qui; } } else { char Y_N; printf(&quot;sorry, you lost. You reached a score of: %d.\nDo you want to play again? Y or N\n&quot;, totalScore); bool i = true; while (i == true) { scanf(&quot;%s&quot;, &amp;Y_N); if (tolower(Y_N) == 'y') { try = 0; totalScore=0; singleScore=0; difficulty=3; count = 0; i = false; goto jump; } else if (tolower(Y_N) == 'n') { printf(&quot;Game ended&quot;); play = false; i = false; goto jump; } else { printf(&quot;say whaaat?, plz tell me 'Y' or 'N'&quot;); } } } // singleScore = 0; int gotItwrong=0; here:; char yOrN; if(gotItwrong==0){puts(&quot;You guessed correctly 3 times in a row, enter a 'Y' to keep playing or enter a 'N' to stop the game\n&quot;);} scanf(&quot;%s&quot;, &amp;yOrN); if (tolower(yOrN) == 'y') { difficulty++; count = 0; } else if (tolower(yOrN) == 'n') { printf(&quot;Game ended, your score was: %d&quot;, totalScore); play = false; } else { printf(&quot;say what?, plz tell me 'Y' or 'N'&quot;); ++gotItwrong; goto here; } jump:; }while(play==true); return 0; } </code></pre> <p>`</p>
[ { "answer_id": 74275306, "author": "DBS", "author_id": 1650337, "author_profile": "https://Stackoverflow.com/users/1650337", "pm_score": 2, "selected": false, "text": ".key" }, { "answer_id": 74275329, "author": "Fralle", "author_id": 3155183, "author_profile": "https...
2022/11/01
[ "https://Stackoverflow.com/questions/74275206", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20028311/" ]
74,275,210
<p>I have the following code:</p> <pre><code>$check = array('person a','person c'); $data = array('person c','person a','person d','person e'); define('check',$check); //asort($data); print'&lt;pre&gt;';print_r($data);print'&lt;/pre&gt;'; usort($data,function($a,$b){ return empty(check[$a]) ? 1 : $a &lt;=&gt; $b; }); print'&lt;pre&gt;';print_r($data);print'&lt;/pre&gt;'; exit; </code></pre> <p>What I am trying to achieve is:</p> <pre><code>person d person e person a person c </code></pre> <p>What I get is</p> <pre><code>person e person a person d person c </code></pre> <p>Because person a and c are in the <code>$check</code> array, I'm trying to sort my array based on alphabetically for those not in the $check group and then those who are. I could probably split things up a bit and am not overly familiar with the <code>usort</code> custom functions, but is it possible to acheive it this way?</p>
[ { "answer_id": 74275323, "author": "duncan", "author_id": 492335, "author_profile": "https://Stackoverflow.com/users/492335", "pm_score": 0, "selected": false, "text": "$data = array_diff($data, $check);\n" }, { "answer_id": 74275616, "author": "bloodyKnuckles", "author_i...
2022/11/01
[ "https://Stackoverflow.com/questions/74275210", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3897214/" ]
74,275,215
<p>I want to return aggregate count along with the main attributes using SDN OGM.</p> <p>This is my data in Neo4j</p> <pre><code>{ &quot;identity&quot;: 777777, &quot;labels&quot;: [ &quot;RootMarker&quot; ], &quot;properties&quot;: { &quot;lastModifiedDate&quot;: 1666934940115, &quot;p5Latest&quot;: true, &quot;messageIds&quot;: [ &quot;fake-900b-49ac-92c7-fake&quot;, &quot;fake-fd73-4058-b07b-fake&quot; ], &quot;messageId&quot;: &quot;fake-fd73-4058-b07b-fake&quot;, &quot;deviceId&quot;: &quot;XXXXX&quot;, &quot;domainId&quot;: &quot;fake-35d5-11ed-9299-fake&quot;, &quot;resources&quot;: 1, &quot;createdDate&quot;: 1666896513598, &quot;drniId&quot;: 111111111111, &quot;isFull&quot;: true, &quot;resyncId&quot;: &quot;fake-46d3-4ab1-bf34-fake&quot;, &quot;status&quot;: &quot;resync&quot;, &quot;latest&quot;: [ 22 ] } } </code></pre> <p>My Repo</p> <pre><code>public interface StackOverFlowRepository extends Neo4jRepository&lt;RootMarkerDTO, Long&gt; { @Query(&quot;MATCH (n:RootMarker {current: true}) RETURN n.domainId as domainId, count(n.domainId) as count ORDER BY n.domainId&quot;) List&lt;TestProjections&gt; getRootMarker(); } </code></pre> <p>My main objective is return attributes as well this <em>count(n.domainId) as count</em></p> <p>Both here below works</p> <pre><code>@Query(&quot;MATCH (n:RootMarker {current: true}) RETURN count(n.domainId) as count ORDER BY n.domainId&quot;) Long itWorks1(); @Query(&quot;MATCH (n:RootMarker {current: true}) RETURN n.domainId as domainId ORDER BY n.domainId&quot;) List&lt;RootMarkerDTO&gt; itWorks2(); </code></pre> <p>RootMarkerDTO:</p> <pre><code>@Node(labels = &quot;RootMarker&quot;) @Getter @Setter @AllArgsConstructor @NoArgsConstructor public class RootMarkerDTO{ @Id @GeneratedValue private Long id; private String domainId; private String resyncId; private String status; private String deviceId; } </code></pre> <p>This here do NOT work</p> <pre><code>@Node(labels = &quot;RootMarker&quot;) @Getter @Setter @AllArgsConstructor @NoArgsConstructor public class RootMarkerDTO{ @Id @GeneratedValue private Long id; private String domainId; private String resyncId; private String status; private String deviceId; //Here private Long count; } </code></pre> <p>TestProjections</p> <pre><code>import lombok.Value; @Value public class TestProjections { String domainId; Long count; } </code></pre> <p>Error:</p> <pre><code>org.springframework.data.neo4j.core.mapping.NoRootNodeMappingException: Could not find mappable nodes or relationships inside Record&lt;{domainId: &quot;78d89740-35d5-11ed-9299-d5f548819a2b&quot;, count: 280}&gt; for org.springframework.data.neo4j.core.mapping.DefaultNeo4jPersistentEntity@6d2db15b </code></pre> <p>I missing something really important about SDN understanding. Any help is appreciated.</p> <p>EDIT:</p> <p>I have created this completed replicable setup.</p> <p><a href="https://github.com/goldman7911/spring-data-understanding" rel="nofollow noreferrer">https://github.com/goldman7911/spring-data-understanding</a></p> <p>MyRepository there is a method customCount() with a more realistic scenario.</p> <pre><code>//THAT'S NOT WORKING @Query(&quot;match (r:RootMarker) UNWIND r.messageIds as rx return r.resyncId as resyncId, count(rx) as counter&quot;) List&lt;MyDTO&gt; customCount(); </code></pre> <p>That's is the same return from Neo4j</p> <p><a href="https://i.stack.imgur.com/t0rNh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/t0rNh.png" alt="enter image description here" /></a></p> <p>And the error:</p> <blockquote> <p>org.springframework.data.neo4j.core.mapping.NoRootNodeMappingException: Could not find mappable nodes or relationships inside Record&lt;{resyncId: &quot;fake-7777-4ab1-7777-fake&quot;, counter: 4}&gt; for org.springframework.data.neo4j.core.mapping.DefaultNeo4jPersistentEntity@7fc420b8</p> </blockquote> <p>EDIT2:</p> <p>Following @meistermeier propose it works. I just do not understand why upper SDN layers can't handle it. What exactly is not capable of understand that.</p> <pre><code>public Collection&lt;MyDTO&gt; getRootMarkerByNeo4jClient() throws NoSuchElementException { Collection&lt;MyDTO&gt; result = neo4jClient.query(&quot;match (r:RootMarker) UNWIND r.messageIds as rx return r.resyncId as resyncId, count(rx) as counter&quot;) .fetchAs(MyDTO.class) .mappedBy((typeSystem, record) -&gt; { String resyncId = record.get(&quot;resyncId&quot;).asString(); Long counter = record.get(&quot;counter&quot;).asLong(); return new MyDTO(resyncId, counter); }).all(); return result; } </code></pre>
[ { "answer_id": 74458821, "author": "meistermeier", "author_id": 2650436, "author_profile": "https://Stackoverflow.com/users/2650436", "pm_score": 2, "selected": true, "text": "count" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74275215", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2952510/" ]
74,275,220
<p>If i have a list calle dates (for example) that goes like this: [2022,2021,2020....] Until 20 or 30 values. And I reverse it with</p> <pre><code>reversed(list) </code></pre> <p>So it looks like this now: [1980.1981,1982...] How can I make a loop that starts in value 2020 for example and goes till 2022? So far i tried in the loop something like this:</p> <pre><code>for i in reversed(range((len(dates)))): </code></pre> <p>Which gives me the second list i wrote up, but i can't make it start in a certain index with:</p> <pre><code>for idx in reversed(range(3,(len(dates)))): </code></pre> <p>Any ideas on how to fix this? Thank you.</p>
[ { "answer_id": 74458821, "author": "meistermeier", "author_id": 2650436, "author_profile": "https://Stackoverflow.com/users/2650436", "pm_score": 2, "selected": true, "text": "count" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74275220", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14715236/" ]
74,275,246
<p>Seems that there is a limit of retrieving only 1000 values per facet from the AzureSearch api. Is there any way to overcome this? We just want to run a report listing the values/counts per facet. We do not need the actual documents returned for this report.</p> <p>Looks like our only alternative is to query the database, but with all the money we're spending on AzureSearch it's disappointing to not find an easy solution.</p>
[ { "answer_id": 74458821, "author": "meistermeier", "author_id": 2650436, "author_profile": "https://Stackoverflow.com/users/2650436", "pm_score": 2, "selected": true, "text": "count" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74275246", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1331773/" ]
74,275,302
<p>I want to acess m_rcnn.py file in jupyter notebook. The folder structure is as follows collab_mask_rcnn(working directory). Inside this workinhg directory i have a folder name maskrcnn_colab and inside this maskrcnn_colab folder i have another folder named mrcnn_demo where i have all the python file like m_rcnn.py, config.py located which i am trying to import</p> <pre><code>import sys sys.path.append('C:/Users/BIUTeamUser3/Desktop/collab_mask_rcnn/maskrcnn_colab/mrcnn_demo') from m_rcnn import * </code></pre> <p>When i excute this i get the following error</p> <pre><code>ModuleNotFoundError Traceback (most recent call last) &lt;ipython-input-2-3841d2b3769e&gt; in &lt;module&gt; 3 import sys 4 sys.path.append(&quot;C:/Users/BIUTeamUser3/Desktop/collab_mask_rcnn/maskrcnn_colab/mrcnn_demo&quot;) ----&gt; 5 from m_rcnn import * 6 get_ipython().run_line_magic('matplotlib', 'inline') C:/Users/BIUTeamUser3/Desktop/collab_mask_rcnn/maskrcnn_colab/mrcnn_demo\m_rcnn.py in &lt;module&gt; 19 # Import Mask RCNN 20 sys.path.append(ROOT_DIR) # To find local version of the library ---&gt; 21 from mrcnn_demo.config import Config 22 from mrcnn_demo import utils 23 import mrcnn_demo.model as modellib ModuleNotFoundError: No module named 'mrcnn_demo' </code></pre> <p>What am i missing?</p>
[ { "answer_id": 74458821, "author": "meistermeier", "author_id": 2650436, "author_profile": "https://Stackoverflow.com/users/2650436", "pm_score": 2, "selected": true, "text": "count" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74275302", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18168227/" ]
74,275,327
<p>I have the following URLs, I want to download these images using a code. There is millions of URL so I want to do it using python.</p> <pre><code>1) https://image.lexica.art/md/dbbb96f1-fce2-4970-ab62-b4b4e6859fe9 2) https://image.lexica.art/md/76318f25-5736-4cda-965d-96fe34823263 3) https://image.lexica.art/md/c11dd279-757e-43ff-8305-43e106f6c345 4) https://image.lexica.art/md/f38d92bb-99bc-4611-938f-c5d6cc70d6ea </code></pre> <p><strong>I have tried the following code but didn't work.</strong></p> <pre><code>url = 'https://image.lexica.art/md/76318f25-5736-4cda-965d-96fe34823263' folder_path = 'images_artistics' file_name = url.split('/')[-1][:-4] image_content = requests.get(url).content image_file = io.BytesIO(image_content) image = Image.open(image_file).convert('RGB') file_path = os.path.join(folder_path, file_name) f = open(file_path, 'wb') image.save(f, &quot;JPEG&quot;, quality=85) print(f&quot;SAVED - {url} - AT: {file_path}&quot;) </code></pre> <p>Error that I am getting; <a href="https://i.stack.imgur.com/ROkjP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ROkjP.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74275482, "author": "Ovski", "author_id": 8610346, "author_profile": "https://Stackoverflow.com/users/8610346", "pm_score": 0, "selected": false, "text": "requests" }, { "answer_id": 74287410, "author": "JasonL", "author_id": 2587749, "author_profile": ...
2022/11/01
[ "https://Stackoverflow.com/questions/74275327", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19454065/" ]
74,275,353
<p>I know that in matlab I can do the following:</p> <pre><code>s = tf('s') G11 = (s + 1)/(s + 2) G12 = 1/(2*s + 1) G21 = 1/(3*s + 1) G22 = 1/(4*s + 1) A = [G11 G12; G21, G22] Ai = inv(A) bode(A) </code></pre> <p>and it will work just fine. In python, I tried to do something similar:</p> <pre><code>import control as co import numpy as np s = co.tf('s') G11 = (s + 1)/(s + 2) G12 = 1/(2*s + 1) G21 = 1/(3*s + 1) G22 = 1/(4*s + 1) A = np.array([[G11, G12], [G21, G22]]) Ai = np.linalg.inv(A) co.bode(A) </code></pre> <p>But this doesnt work - numpy doesnt know how to invert this matrix.</p> <p>Is there a good way to do this in python? I know that I can use scipy with s being a symbol, but I think that doesnt help me when using the others tools in the control toolbox.</p> <p>Edit:</p> <p>numpy returns the following error:</p> <pre><code>--------------------------------------------------------------------------- UFuncTypeError Traceback (most recent call last) &lt;ipython-input-1-ec46afd90eb6&gt; in &lt;module&gt; 10 11 A = np.array([[G11, G12], [G21, G22]]) ---&gt; 12 Ai = np.linalg.inv(A) 13 co.bode(A) &lt;__array_function__ internals&gt; in inv(*args, **kwargs) /usr/local/lib/python3.7/dist-packages/numpy/linalg/linalg.py in inv(a) 543 signature = 'D-&gt;D' if isComplexType(t) else 'd-&gt;d' 544 extobj = get_linalg_error_extobj(_raise_linalgerror_singular) --&gt; 545 ainv = _umath_linalg.inv(a, signature=signature, extobj=extobj) 546 return wrap(ainv.astype(result_t, copy=False)) 547 UFuncTypeError: Cannot cast ufunc 'inv' input from dtype('O') to dtype('float64') with casting rule 'same_kind' </code></pre>
[ { "answer_id": 74276060, "author": "Reinderien", "author_id": 313768, "author_profile": "https://Stackoverflow.com/users/313768", "pm_score": 2, "selected": false, "text": "import sympy\n\ns = sympy.Symbol('s', imaginary=True)\ng11 = (s + 1)/(s + 2)\ng12 = 1/(2*s + 1)\ng21 = 1/(3*s + 1)\...
2022/11/01
[ "https://Stackoverflow.com/questions/74275353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10265524/" ]
74,275,359
<p>In my project, I using laravel as <code>api</code></p> <blockquote> <p>UserController &gt; profile() <code>need token to run</code></p> </blockquote> <p>For example when I call it without <strong>token</strong>, laravel display error which <strong>&quot;Route [login] not defined&quot;</strong> <em>and it's right because we don't have any template in laravel.</em></p> <p>How can I return <strong>json response</strong> instead redirect to login page as html?</p> <pre><code>public function profile(): JsonResponse { //using protected method return response()-&gt;json($this-&gt;guard()-&gt;user()); } </code></pre>
[ { "answer_id": 74276060, "author": "Reinderien", "author_id": 313768, "author_profile": "https://Stackoverflow.com/users/313768", "pm_score": 2, "selected": false, "text": "import sympy\n\ns = sympy.Symbol('s', imaginary=True)\ng11 = (s + 1)/(s + 2)\ng12 = 1/(2*s + 1)\ng21 = 1/(3*s + 1)\...
2022/11/01
[ "https://Stackoverflow.com/questions/74275359", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1575598/" ]
74,275,363
<p>Hey i have a scrip that takes data for sheest and populates a gdoc file one of the lines is a date</p> <pre><code>const friendlyDate = new Date(row[2]).toLocaleDateString(); </code></pre> <p>but if there is not entered a date in the cell it returns &quot;Invbalid Date&quot; to the Gdoc file how whould i go about adding a if satement to check if there is a valid date in the cell and if not make the output text &quot;Not registered on date&quot;</p> <p>I did try different if combinations but i am not that skilled in appscript</p>
[ { "answer_id": 74276060, "author": "Reinderien", "author_id": 313768, "author_profile": "https://Stackoverflow.com/users/313768", "pm_score": 2, "selected": false, "text": "import sympy\n\ns = sympy.Symbol('s', imaginary=True)\ng11 = (s + 1)/(s + 2)\ng12 = 1/(2*s + 1)\ng21 = 1/(3*s + 1)\...
2022/11/01
[ "https://Stackoverflow.com/questions/74275363", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20284252/" ]
74,275,372
<p>I have this single <code>pd.DataFrame</code></p> <pre><code>pd.DataFrame(columns=pd.MultiIndex.from_product([['X', 'Y'], ['L', 'R']]), data=[[1, 5, 2, 6], [3, 7, 4, 8]]) </code></pre> <p>which produces</p> <pre><code> X Y L R L R ----------------- 0 1 5 2 6 1 3 7 4 8 </code></pre> <p>I would like to add the upper index as a suffix to the column names, such that I produce something like this:</p> <pre><code> L_X R_X L_Y R_Y ---------------------- 0 1 5 2 6 1 3 7 4 8 </code></pre> <p>It is the inverse problem of <a href="https://stackoverflow.com/questions/53125606/convert-column-suffixes-from-pandas-join-into-a-multiindex">this question</a>, which is why I chose the exact same table.</p> <p>How can I do this?</p>
[ { "answer_id": 74275428, "author": "Rabinzel", "author_id": 15521392, "author_profile": "https://Stackoverflow.com/users/15521392", "pm_score": 1, "selected": false, "text": "map" }, { "answer_id": 74275467, "author": "Naveed", "author_id": 3494754, "author_profile": ...
2022/11/01
[ "https://Stackoverflow.com/questions/74275372", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12052180/" ]
74,275,385
<p>I have a contact info div with an email and a phone number displayed as an icon followed by the email and number:</p> <p><a href="https://i.stack.imgur.com/JqFN1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JqFN1.png" alt="enter image description here" /></a></p> <p>However, when I go below a certain threashold the email text seems to jump a little bit below the icon:</p> <p><a href="https://i.stack.imgur.com/nescS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nescS.png" alt="enter image description here" /></a></p> <p>The content is put on a &quot;card&quot; which is placed on the website, here is the general code:</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> .content-card{ max-width: 100vw; padding: 0 2em 0; } .contact-options-wrapper{ padding: 1em 0em; } .fs-contact-info{ font-size: clamp(1vw, 4vw, 1.5em); }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css"&gt; &lt;div class="content-card"&gt; &lt;div class="fs-contact-info contact-options-wrapper"&gt; &lt;div&gt;&lt;a href="mailto:myemail_12345@gmail.com"&gt;&lt;i class="fa-solid fa-envelope"&gt;&lt;/i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;myemail_12345@gmail.com&lt;/a&gt;&lt;/div&gt; &lt;div&gt;&lt;a href="tel:+46123456789"&gt;&lt;i class="fa-solid fa-phone"&gt;&lt;/i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;+46 12 345 67 89&lt;/a&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <p>I removed some of the background color and similar styling that don't affect the question.</p> <p>How can I get the text next to the icon to always be in line and not jump down like that?</p> <p>Ps. In my example you might need to run the snippet, go into full mode, then inspect and make it really narrow. On my real website the effect comes into play at around 500px, which makes this &quot;wrong&quot; on basically all mobiles.</p>
[ { "answer_id": 74275428, "author": "Rabinzel", "author_id": 15521392, "author_profile": "https://Stackoverflow.com/users/15521392", "pm_score": 1, "selected": false, "text": "map" }, { "answer_id": 74275467, "author": "Naveed", "author_id": 3494754, "author_profile": ...
2022/11/01
[ "https://Stackoverflow.com/questions/74275385", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12053079/" ]
74,275,387
<p>I have an array of enums where each enum either contains an image or video. I would like to loop through the array and get the values inside each enum. If the enum contains an image I would like get that value and if it contains a video then get that value.</p> <blockquote> <p>So how do I loop through an array if enums?</p> </blockquote> <p><strong>This is my code:</strong></p> <pre><code>import UIKit import AVFoundation enum ContentSource { case image(UIImage) case video(AVPlayer) } var post : [ContentSource] = [] </code></pre>
[ { "answer_id": 74275428, "author": "Rabinzel", "author_id": 15521392, "author_profile": "https://Stackoverflow.com/users/15521392", "pm_score": 1, "selected": false, "text": "map" }, { "answer_id": 74275467, "author": "Naveed", "author_id": 3494754, "author_profile": ...
2022/11/01
[ "https://Stackoverflow.com/questions/74275387", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13708093/" ]
74,275,389
<p>Im using ASP Net Core Web App with Razor Pages. Im struggling with index.html Swagger as main/default page. When App Starts -&gt; automatically forwards to Swagger. Im also hosting my app on Azure - same problem in that hosting env, Swagger is main page. This is problem for accessing site from Internet when u are forwarded from main url to swagger. Fresh example project from .NET is not accessing index.html. I need to change default page and root &quot;/&quot; from Swagger to page i choose. Below sample of my Program.cs and result of accessing my page.</p> <p><strong>Program.cs</strong></p> <pre><code>`using System.Reflection; using Microsoft.EntityFrameworkCore; using Microsoft.OpenApi.Models; using SwimmingSchool.Repositories; using SwimmingSchool.Repositories.Interfaces; using Microsoft.AspNetCore.Authentication.OpenIdConnect; using Microsoft.AspNetCore.Authorization; using Microsoft.Identity.Web; using Microsoft.Identity.Web.UI; using Microsoft.AspNetCore.Mvc.Authorization; var builder = WebApplication.CreateBuilder(args); var services = builder.Services; var config = builder.Configuration; // Frontend services services.AddRazorPages().AddMicrosoftIdentityUI(); services.AddMvc().AddRazorPagesOptions(opt =&gt; { opt.RootDirectory = &quot;/Frontend&quot;; }); services.AddControllersWithViews(options =&gt; { var policy = new AuthorizationPolicyBuilder() .RequireAuthenticatedUser() .Build(); options.Filters.Add(new AuthorizeFilter(policy)); }); // Authentication services services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme) .AddMicrosoftIdentityWebApp(config.GetSection(&quot;AzureAd&quot;)) .EnableTokenAcquisitionToCallDownstreamApi(Environment.GetEnvironmentVariable(&quot;DownstreamApi:Scopes&quot;)?.Split(' ')) .AddMicrosoftGraph(config.GetSection(&quot;DownstreamApi&quot;)) .AddInMemoryTokenCaches(); //Database services services.AddDatabaseDeveloperPageExceptionFilter(); services.AddDbContext&lt;SwimmingSchoolDbContext&gt;(options =&gt; options.UseSqlServer(Environment.GetEnvironmentVariable(&quot;SwimmingSchoolDb&quot;))); //Scoped services services.AddScoped&lt;ICustomersRespository, CustomersRepository&gt;(); //Swagger services services.AddSwaggerGen(c =&gt; { c.SwaggerDoc(&quot;v1&quot;, new OpenApiInfo { Version = &quot;v1&quot;, Title = &quot;SwimmingcSchool&quot;, Description = &quot;Company application for manage swimming school&quot;, TermsOfService = new Uri(&quot;http://SwimmingSchool.pl&quot;), Contact = new OpenApiContact { Name = &quot;Biuro&quot;, Email = &quot;biuro@SwimmingSchool.pl&quot;, Url = new Uri($&quot;http://swimmingschool.pl&quot;), } }); var xmlFile = $&quot;{Assembly.GetExecutingAssembly().GetName().Name}.xml&quot;; var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); //c.IncludeXmlComments(xmlPath); }); var app = builder.Build(); // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { app.UseMigrationsEndPoint(); } else { app.UseExceptionHandler(&quot;/Home/Error&quot;); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseSwagger(); app.UseSwaggerUI(c =&gt; { c.SwaggerEndpoint(&quot;/swagger/v1/swagger.json&quot;, &quot;SwimmingSchool&quot;); c.RoutePrefix = string.Empty; } ); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints =&gt; { endpoints.MapControllers(); endpoints.MapRazorPages(); }); app.Run();` </code></pre> <p>Here what is happening when i try to access main url : <a href="https://i.stack.imgur.com/uaQp9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uaQp9.png" alt="UrlForwarding" /></a></p> <p>I tried add:</p> <p><code>options.Conventions.AddPageRoute(&quot;/Index.html&quot;, &quot;&quot;);</code></p> <p>Also tried to remove Swagger and nothings helped :(</p>
[ { "answer_id": 74275428, "author": "Rabinzel", "author_id": 15521392, "author_profile": "https://Stackoverflow.com/users/15521392", "pm_score": 1, "selected": false, "text": "map" }, { "answer_id": 74275467, "author": "Naveed", "author_id": 3494754, "author_profile": ...
2022/11/01
[ "https://Stackoverflow.com/questions/74275389", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20387385/" ]
74,275,394
<p>in non .tsx pages we used to enum like this:</p> <pre><code>const enumUrl= { xxx: [BRAND], yyy: [BRAND], }; </code></pre> <p>In .tsx pages I would like to use <code>enum</code>. So I created:</p> <pre><code> enum EnumUrl { xxx = &quot;https://example.com/&quot;, yyy = &quot;https://example.net&quot; } </code></pre> <p>And in JSX:</p> <pre><code> Visit &lt;a href={EnumUrl[BRAND}} target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt; {EnumUrl[BRAND]} &lt;/a&gt; </code></pre> <p>However it says:</p> <pre><code>Element implicitly has an 'any' type because expression of type 'any' can't be used to index type 'typeof EnumUrl'.ts(7053) </code></pre> <p>Then I read this possible solution: <a href="https://stackoverflow.com/a/41970976/1580094">https://stackoverflow.com/a/41970976/1580094</a> and did the following:</p> <pre><code> enum EnumUrl { xxx = &quot;https://example.com/&quot;, yyy = &quot;https://example.net&quot; } var url : EnumUrl = EnumUrl[BRAND as keyof typeof EnumUrl]; ... Visit &lt;a href={url[BRAND}} target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt; {url[BRAND]} &lt;/a&gt; </code></pre> <p>Console logs: console.log(url); // <a href="https://example.com/" rel="nofollow noreferrer">https://example.com/</a> console.log(url[BRAND]); // undefined console.log(BRAND); // xxx</p> <p>But doing this way, the <code>&lt;a</code> element completely disappears from DOM. No errors.</p> <p>What am I doing wrong and how can I fix it?</p>
[ { "answer_id": 74276103, "author": "Jared Smith", "author_id": 3757232, "author_profile": "https://Stackoverflow.com/users/3757232", "pm_score": 3, "selected": true, "text": "enum URLs {\n A = \"www.foo.com\",\n B = \"www.bar.com\"\n}\n" }, { "answer_id": 74276105, "author"...
2022/11/01
[ "https://Stackoverflow.com/questions/74275394", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1580094/" ]
74,275,400
<p>Im currently working on a project with features like send certificate to email by using ajax, phpmailer and fpdf library. But when i click the send button its not sending and this error pop up inside the button &quot;</p> <pre><code>Trying to access array offset on value of type bool </code></pre> <p>&quot;.</p> <p>I tried this block of code to generate and send certificate to email &quot;</p> <pre><code>&lt;?php use PHPMailer\PHPMailer\PHPMailer; if(isset($_POST['email_data'])){ require 'phpmailer/src/Exception.php'; require 'phpmailer/src/PHPMailer.php'; require 'phpmailer/src/SMTP.php'; require 'fpdf/fpdf.php'; require 'connection.php'; $output=''; foreach($_POST['email_data']as $row) { $image= imagecreatefrompng('D:/App Projects/Source/idonate/Admin/include/Certificate Template/certificate2.png'); $white = imagecolorallocate($image, 255, 255, 255); $black = imagecolorallocate($image, 0, 0, 0); $font=&quot;D:/App Projects/Source/idonate/Admin/fonts/Roboto-Black.ttf&quot;; $size =110; $box = imagettfbbox($size, 0, $font, $row['donor_name']); $text_width = abs($box[2]) - abs($box[0]); $text_height = abs($box[5]) - abs($box[3]); $image_width = imagesx($image); $image_height = imagesy($image); $x = ($image_width - $text_width) / 2; $y = ($image_height + $text_height) / 2; // add text imagettftext($image, $size, 0, $x, $y, $black,$font, $row['donor_name']); $file=time(); $file_path=&quot;download-certificate/&quot;.$file.&quot;.png&quot;; $file_path_pdf= &quot;download-certificate/&quot;.$file.&quot;.pdf&quot;; imagepng($image,$file_path); imagedestroy($image); $pdf= new FPDF(); $pdf-&gt;AddPage('L','A5'); $pdf-&gt;Image($file_path,0,0,210,150); $mail=new PHPMailer; $mail-&gt;isSMTP(); $mail-&gt;Host= 'smtp.gmail.com'; $mail-&gt;SMTPAuth= true; $mail-&gt;Username='testcdrrmo@gmail.com' ; $mail-&gt;Password= 'mlytxekfgplnhsap'; $mail-&gt;SMTPSecure='ssl'; $mail-&gt;Port=465; $mail-&gt;setFrom('testcdrrmo@gmail.com'); $mail-&gt;addAddress($row['donor_email']); $mail-&gt;isHTML(true); $mail-&gt;Subject= &quot;Certificate&quot;; $mail-&gt;Body= &quot;This is certificate&quot;; $mail-&gt;addStringAttachment($pdf-&gt;Output(&quot;S&quot;,'AcknowledgementReciept.pdf'), 'AcknowledgementReciept.pdf', $encoding = 'base64', $type = 'application/pdf'); $mail-&gt;AltBody=''; $sendEmail= $mail-&gt;send(); </code></pre> <p>&quot;</p> <p>But when I add this code for connection and validation to ajax&quot;</p> <pre><code> if($sendEmail[&quot;code&quot;]==('400')){ $output .= html_entity_decode($sendEmail['full_error']); } } if($output==''){ echo 'ok'; }else{ echo $output; } } </code></pre> <p>&quot;Its not working but when a remove it its sending the email but the button is not disabled after success.</p> <p>This is for the ajax&quot;</p> <pre><code>$.ajax({ url:&quot;http://localhost:3000/Admin/include/sendcerti.php&quot; , method: &quot;POST&quot;, data: {email_data:email_data}, beforeSend:function(){ $('#'+donor_id).html('Sending...'); $('#' + donor_id).addClass('btn-danger'); }, success: function(data){ if (data == 'ok') { $('#' +donor_id).text(&quot;Success&quot;); $('#' + donor_id).removeClass('btn-danger'); $('#' + donor_id).removeClass('btn-info'); $('#' + donor_id).addClass('btn-success'); } else{ $('#' +donor_id).text(data); } $('#'+ donor_id).attr('disabled', false); } }) </code></pre> <p>&quot; I want to disable the button after success to prevent duplication of certificate</p>
[ { "answer_id": 74276103, "author": "Jared Smith", "author_id": 3757232, "author_profile": "https://Stackoverflow.com/users/3757232", "pm_score": 3, "selected": true, "text": "enum URLs {\n A = \"www.foo.com\",\n B = \"www.bar.com\"\n}\n" }, { "answer_id": 74276105, "author"...
2022/11/01
[ "https://Stackoverflow.com/questions/74275400", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19609605/" ]
74,275,410
<p>I am trying to show data from api and while loading data , there should be shown a circularprogressindicator,</p> <p>but when I start app..it directly showing data instead of circularprogressindicator</p> <pre><code> class _HomeScreenState extends State&lt;HomeScreen&gt; { bool isloading = false; var maplist ; Future&lt;void&gt; fetchdata() async { setState(() { isloading=true; }); var resp = await http.get(Uri.parse(&quot;https://jsonplaceholder.typicode.com/posts&quot;)); maplist = json.decode(resp.body); setState(() { isloading = false; }); } @override void initState() { // TODO: implement initState super.initState(); fetchdata(); } @override Widget build(BuildContext context) { return SafeArea( child: Scaffold( body: MyBody(), )); } MyBody() { return isloading==true ? Center(child: CircularProgressIndicator()) : ListView.builder( itemCount: maplist.length, itemBuilder: (context,index){ return Container( padding: EdgeInsets.all(8.0), child: Text(maplist[index]['title'])); }); } } </code></pre>
[ { "answer_id": 74275450, "author": "Jasmin Sojitra", "author_id": 11557906, "author_profile": "https://Stackoverflow.com/users/11557906", "pm_score": 0, "selected": false, "text": "class _HomeScreenState extends State<HomeScreen> {\n bool isloading = true;\n var maplist ;\n Future<voi...
2022/11/01
[ "https://Stackoverflow.com/questions/74275410", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18817235/" ]
74,275,425
<p>How can I catch an error in node.js?</p> <p>Here's my code:</p> <pre class="lang-js prettyprint-override"><code>const { Client, Message, MessageEmbed } = require(&quot;discord.js&quot;) const translate = require('@iamtraction/google-translate') module.exports = { name: &quot;ترجم&quot;, description: `يترجم اللغه فقط أستعمل !translate &quot;الكلمه/الجمله يلي بدك تترجمها&quot;`, aliases: ['translate'], run: async (client, message, args) =&gt; { const query = args.join(&quot; &quot;) const lang = args[0] if(!query) return message.reply('Please specify a text to translate'); const translated = await translate(query, { to: lang }); message.reply(translated.text); }, }; </code></pre> <p>It works when I type in chat:</p> <p><code>!translate ar hello</code></p> <p>But when I type:</p> <p><code>!translate &quot;not a real lang&quot; hello</code></p> <p>It shutdowns with the error:</p> <p><code>Error: The language 'not a real lang' is not supported</code></p> <p>I tried <code>.catch</code>, I tried if and else, I tried <code>try</code></p>
[ { "answer_id": 74275579, "author": "Rokus", "author_id": 2422617, "author_profile": "https://Stackoverflow.com/users/2422617", "pm_score": 2, "selected": false, "text": "async" }, { "answer_id": 74278876, "author": "Blaxyy", "author_id": 19010766, "author_profile": "h...
2022/11/01
[ "https://Stackoverflow.com/questions/74275425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20082648/" ]
74,275,438
<p>I have a list of strings i will like to access and print its inner elements as shown below:</p> <pre><code>mylist = ['apple', 'balls', 'camera', 'dough', 'eleven'] specified_index = random.choices((range(len(mylist))), k=len(mylist)) print(&quot;specified_index =&quot;, specified_index) merged_index = [mylist[tt] for tt in specified_index] print(&quot;merged_index =&quot;, merged_index) </code></pre> <p>The result of merged_index keeps printing the words found at specified_index. Sample Output:</p> <pre><code>specified_index = [2, 3, 4, 0, 1] merged_index = ['camera', 'dough', 'eleven', 'apple', 'balls'] </code></pre> <p><strong>What i want instead is to keep printing the corresponding letter of specified_index -not the whole words</strong> even if the list is shuffled. #For example: <strong>My preferred output == &quot;mgeaa&quot;</strong></p> <pre><code>specified_index = [2, 3, 4, 0, 1] merged_index = ['caMera', 'douGh', 'elevEn', 'Apple', 'bAlls'] </code></pre> <p><strong>Note:::</strong> I tried</p> <pre><code>import more_itertools as mit merged_list = mit.random_product(mylist) </code></pre> <p>but it doesn't allow me to maintain same specified_index whenever mylist is shuffled #Other answers i found does not really solve this.</p>
[ { "answer_id": 74275579, "author": "Rokus", "author_id": 2422617, "author_profile": "https://Stackoverflow.com/users/2422617", "pm_score": 2, "selected": false, "text": "async" }, { "answer_id": 74278876, "author": "Blaxyy", "author_id": 19010766, "author_profile": "h...
2022/11/01
[ "https://Stackoverflow.com/questions/74275438", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19413504/" ]
74,275,449
<p>I was using the <code>difftime</code> function from the <code>base</code> package in R and based on my data I found a couple of weird return values of this function:</p> <pre><code>&gt; difftime(&quot;2014-10-29&quot;, &quot;2014-10-21&quot;, units = &quot;days&quot;) Time difference of 8.041667 days &gt; difftime(&quot;2020-4-04&quot;, &quot;2020-3-28&quot;, units = &quot;days&quot;) Time difference of 6.958333 days </code></pre> <p>Any idea why those values are not integers? Thanks!</p> <p>All I see in the doc, relevant to it is: &quot;Note that units = &quot;days&quot; means a period of 24 hours, hence takes no account of Daylight Savings Time. Differences in objects of class &quot;Date&quot; are computed as if in the UTC time zone.&quot;</p>
[ { "answer_id": 74275673, "author": "ThomasIsCoding", "author_id": 12158757, "author_profile": "https://Stackoverflow.com/users/12158757", "pm_score": 3, "selected": true, "text": "as.Date" } ]
2022/11/01
[ "https://Stackoverflow.com/questions/74275449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1116518/" ]