qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,154,972
<p>I have a function of some parameters that will return a probability. How can I set <code>scipy</code>'s <code>minimize</code> to terminate as soon as finds some parameters that will return a probability below a certain threshold (even if it is a &quot;large&quot; probability like 0.1 or so)?</p> <p>Thanks a lot!</p>
[ { "answer_id": 74155014, "author": "OttherCreek", "author_id": 13261694, "author_profile": "https://Stackoverflow.com/users/13261694", "pm_score": 0, "selected": false, "text": "align-items: center;" }, { "answer_id": 74155015, "author": "G-Cyrillus", "author_id": 2442099...
2022/10/21
[ "https://Stackoverflow.com/questions/74154972", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5827413/" ]
74,155,013
<p>I have a field in my Material-Table which contains a very long string. The string contains <code>\n</code> separators but the table is just ignoring these.</p> <p>I have tried using <code>\n\n</code>, <code>\r</code>, <code>\r\n</code>, <code>\n\r</code>. None of these have worked.</p> <p>Here is a quick example of the the field:</p> <pre><code>&quot;Domain: Corporate, DomainLeader: John Doe,\n Experience: Finance,\n ExperienceLeader: Jane Doe,\n ProductLine: Finance Systems,\n ProductLineLeader: John Doe&quot; </code></pre>
[ { "answer_id": 74155226, "author": "Dulaj Ariyaratne", "author_id": 13368318, "author_profile": "https://Stackoverflow.com/users/13368318", "pm_score": 1, "selected": false, "text": "white-space: pre-wrap;" }, { "answer_id": 74155338, "author": "Ciaran Crowley", "author_i...
2022/10/21
[ "https://Stackoverflow.com/questions/74155013", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9452311/" ]
74,155,019
<p>Please check the image- how can I do that in my react native app <a href="https://i.stack.imgur.com/qPAEM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qPAEM.png" alt="enter image description here" /></a></p> <pre><code>import React, { useContext, useState } from 'react'; import { View, Button, Text, StyleSheet, Switch} from 'react-native'; const Testing = ({ navigation }) =&gt; { return ( &lt;View&gt; &lt;Text&gt; My mother has blue eyes and my father has dark green eyes.&lt;/Text&gt; &lt;/View&gt; ); } export default Testing; </code></pre>
[ { "answer_id": 74155157, "author": "Behrad Hajmiri", "author_id": 14707633, "author_profile": "https://Stackoverflow.com/users/14707633", "pm_score": 0, "selected": false, "text": " document.getElementById('mother').style.color = document.getElementById('mother').innerHTML;\ndocument....
2022/10/21
[ "https://Stackoverflow.com/questions/74155019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10922432/" ]
74,155,036
<p>I am a beginner at python and have been stuck on a line of code for a while now and am unsure how to fix it.</p> <p>The program requests user input, a HEX value and then converts this to a RGB value. I perform error checking to ensure that the input is a HEX value. However, when I input FEE<strong>Z</strong>00 it doesn't recognize that the char 'Z' is not in the string hexChars. (this should result in the break statement being activated)</p> <p>I would greatly appreciate some help (please don't give me the full answer, I would like to learn) Thank you!</p> <pre><code>hexChars = '0123456789ABCDEF' rgb1 = (input(&quot;Enter 1st color: #&quot;)).upper() rgb2 = (input(&quot;Enter 2nd color: #&quot;)).upper() if(len(rgb1) != 6 and len(rgb2) != 6): print(&quot;Not a valid input!&quot;, end = &quot;\n\n&quot;) break for i in range(6): if((rgb1[i] not in hexChars) and (rgb2[i] not in hexChars)): print(&quot;Not a valid input!&quot;, end = &quot;\n\n&quot;) break </code></pre> <p>My input:</p> <pre><code>Enter 1st color: #feez00 Enter 2nd color: #feed00 </code></pre> <p>Edit: Clarification is needed. As this is a beginner course we are not allowed to use functions or imports.</p>
[ { "answer_id": 74155141, "author": "rv.kvetch", "author_id": 10237506, "author_profile": "https://Stackoverflow.com/users/10237506", "pm_score": 1, "selected": false, "text": "re" }, { "answer_id": 74155153, "author": "Alex Grounds", "author_id": 2232394, "author_prof...
2022/10/21
[ "https://Stackoverflow.com/questions/74155036", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20301848/" ]
74,155,039
<p>When I parse for more than 1 class I get an error on line 12 (when I add all to find) Error: ResultSet object has no attribute 'find'. You're probably treating a list of elements like a single element</p> <pre><code>import requests from bs4 import BeautifulSoup heroes_page_list=[] url = f'https://dota2.fandom.com/wiki/Dota_2_Wiki' q = requests.get(url) result = q.content soup = BeautifulSoup(result, 'lxml') heroes = soup.find_all('div', class_= 'heroentry').find('a') for hero in heroes: hero_url = heroes.get('href') heroes_page_list.append(&quot;https://dota2.fandom.com&quot; + hero_url) # print(heroes_page_list) with open ('heroes_page_list.txt', &quot;w&quot;) as file: for line in heroes_page_list: file.write(f'{line}\n') </code></pre>
[ { "answer_id": 74155127, "author": "Rahul K P", "author_id": 4407666, "author_profile": "https://Stackoverflow.com/users/4407666", "pm_score": 3, "selected": true, "text": "a" }, { "answer_id": 74155185, "author": "Maiels", "author_id": 7878047, "author_profile": "htt...
2022/10/21
[ "https://Stackoverflow.com/questions/74155039", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16422359/" ]
74,155,056
<p>I'm trying to import the google.cloud bigquery library, but I keep getting an error. The error I got:</p> <p><code>ImportError: cannot import name 'bigquery' from 'google.cloud' (unknown location)</code></p> <pre><code>pip install google-cloud-bigquery pip install --upgrade google-cloud pip install --upgrade google-cloud-bigquery </code></pre> <p>I also tried these methods but still the error persists</p>
[ { "answer_id": 74155127, "author": "Rahul K P", "author_id": 4407666, "author_profile": "https://Stackoverflow.com/users/4407666", "pm_score": 3, "selected": true, "text": "a" }, { "answer_id": 74155185, "author": "Maiels", "author_id": 7878047, "author_profile": "htt...
2022/10/21
[ "https://Stackoverflow.com/questions/74155056", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14102059/" ]
74,155,058
<p>I am using SQL Server 2016. I have a table more than 10m rows. When I want to search with the query show here, it is very slow.</p> <pre class="lang-sql prettyprint-override"><code>CREATE TABLE dbo.table_name ( Col1 int NOT NULL, Col2 int NULL, Col3 char(2) NULL, Col4 char(15) NULL, Col5 varchar(8) NULL, Col6 varchar(12) NULL, Col7 varchar(8) NULL, Col8 int NULL, Col9 int NULL, Col10 varchar(16) NOT NULL ) ON PRIMARY SELECT colum3 + column4 FROM tablename WHERE column3 + column4 = @variable </code></pre> <p>What index method should I use to speed up this query? (of type varchar in two columns)</p>
[ { "answer_id": 74155122, "author": "Stuck at 1337", "author_id": 20091109, "author_profile": "https://Stackoverflow.com/users/20091109", "pm_score": 3, "selected": true, "text": "ALTER TABLE dbo.tablename ADD concat_column AS\n CONCAT(column1 + column2);\n\nCREATE INDEX ix_concat_column...
2022/10/21
[ "https://Stackoverflow.com/questions/74155058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19732732/" ]
74,155,072
<p>I have a DataTable that has a date field within it. I am trying to loop through it and put the value in the date field into a variable.</p> <p>However when ever it is null the <code>oosDate = Convert.ToDateTime(dt.Rows[0][0]);</code> part causes an error.</p> <p>So i tried to wrap it in an if statement as shown below that checks in the fields value is null before if carries out the function. It doesnt work though and still carries out the <code>Convert.ToDateTime(dt.Rows[0][0])</code> function. Can anyone tell me why the != null isnt working?</p> <p>I have checked the data that is in dt.rows[0][0] when the error occurs and it definitely appears to be null</p> <pre><code>foreach (DataRow row in dt.Rows) { if (dt.Rows[0][0] != null ) { oosDate = Convert.ToDateTime(dt.Rows[0][0]); } } </code></pre>
[ { "answer_id": 74155102, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 2, "selected": false, "text": "DBNull.Value" }, { "answer_id": 74155364, "author": "Tim Schmelter", "author_id": 284240, "auth...
2022/10/21
[ "https://Stackoverflow.com/questions/74155072", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15078457/" ]
74,155,087
<p>I need to get from all the images the src and alt of the html code. I managed to get it but I have the following problem:</p> <ul> <li>If the image has no alt, it does not detect me the image. In these cases I need to get only the src.</li> </ul> <p>The following code works with problem: <a href="https://regex101.com/r/3Vlkql/1" rel="nofollow noreferrer">https://regex101.com/r/3Vlkql/1</a></p> <pre><code>(&lt;img\s)[^&gt;]*(src=\S+)[^&gt;]*(\salt=[&quot;|'].*?[&quot;|'])[^&gt;]*(\/?&gt;) </code></pre> <p>Substitution:</p> <pre><code>$1$2$3$4 </code></pre> <p>Result:</p> <pre><code>&lt;img src=&quot;https://example.com/image&quot; alt=&quot;example1&quot;&gt; </code></pre> <p>Problem: My regex only detect if have src and alt. But if not have alt, the regex not detect me. How can I do with regex to get both?</p> <p>This not match with regex:</p> <pre><code>&lt;img src=&quot;https://example.com/image&quot;&gt; </code></pre> <ul> <li>src &amp; alt</li> <li>only src</li> </ul> <p>I dont have problem if i need to use 2 regex to get my purpose.</p>
[ { "answer_id": 74155102, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 2, "selected": false, "text": "DBNull.Value" }, { "answer_id": 74155364, "author": "Tim Schmelter", "author_id": 284240, "auth...
2022/10/21
[ "https://Stackoverflow.com/questions/74155087", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20301743/" ]
74,155,090
<p>Is ther any clear way of doing the following in one SQL (PL) code? :)</p> <p>What I have in the tables is the following:</p> <p><strong>CONTACT_TBL (HEADER)</strong></p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>CONTRACT_ID</th> <th>BEGIN_DATE</th> <th>END_DATE</th> <th>TOT_AMOUNT</th> </tr> </thead> <tbody> <tr> <td>123</td> <td>13-MAY-16</td> <td>12-MAY-34</td> <td>100</td> </tr> <tr> <td>456</td> <td>13-JAN-14</td> <td>12-DEC-25</td> <td>300</td> </tr> <tr> <td>789</td> <td>13-SEP-14</td> <td>12-OCT-34</td> <td>700</td> </tr> </tbody> </table> </div> <p><strong>CONTRACT_ACTIVTY (DETAIL)</strong></p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>CONTRACT_ID</th> <th>SEQNUM</th> <th>END_DATE</th> <th>AMOUNT</th> <th>COMMENTS</th> </tr> </thead> <tbody> <tr> <td>123</td> <td>1</td> <td>12-MAY-19</td> <td>25</td> <td>25 - Initial Expiration</td> </tr> <tr> <td>123</td> <td>2</td> <td>12-MAY-24</td> <td>25</td> <td>25</td> </tr> <tr> <td>123</td> <td>3</td> <td>12-MAY-29</td> <td>25</td> <td>25</td> </tr> <tr> <td>123</td> <td>4</td> <td>12-MAY-34</td> <td>25</td> <td>25 - End of Contract</td> </tr> </tbody> </table> </div> <p>What we need is to populate for each row:</p> <ol> <li>BEGIN_DATE</li> </ol> <ul> <li>For SEQNUM #1 - BEGIN_DATE is always CONTACT_TBL.BEGIN_DATE (in this case 13-MAY-15, a 3 year span)</li> <li>For SEQNUM #2 to N - BEGIN_DATE is 1 day more than previous row's END_DATE (in this case 12-MAY-19 + 1 = 13-MAY-19, all 5 year spans)</li> </ul> <ol start="2"> <li>Mark the row 'Active' if the SYSDATE is between BEGIN_DATE and END_DATE (in this case it's Row #2)</li> </ol> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>CONTRACT_ID</th> <th>SEQNUM</th> <th>BEGIN_DATE</th> <th>END_DATE</th> <th>AMOUNT</th> <th>STATUS</th> </tr> </thead> <tbody> <tr> <td>123</td> <td>1</td> <td>13-MAY-16</td> <td>12-MAY-19</td> <td>25</td> <td></td> </tr> <tr> <td>123</td> <td>2</td> <td>13-MAY-19</td> <td>12-MAY-24</td> <td>25</td> <td>Active</td> </tr> <tr> <td>123</td> <td>3</td> <td>13-MAY-24</td> <td>12-MAY-29</td> <td>25</td> <td></td> </tr> <tr> <td>123</td> <td>4</td> <td>13-MAY-29</td> <td>12-MAY-34</td> <td>25</td> <td></td> </tr> </tbody> </table> </div>
[ { "answer_id": 74155102, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 2, "selected": false, "text": "DBNull.Value" }, { "answer_id": 74155364, "author": "Tim Schmelter", "author_id": 284240, "auth...
2022/10/21
[ "https://Stackoverflow.com/questions/74155090", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20301188/" ]
74,155,091
<p>I am working on a Blazor project in which I am using Bootstrap; which, of course, requires jQuery and Popper for the tooltips and popovers to work.</p> <p>Originally, I just &quot;manually&quot; downloaded the required files:</p> <ul> <li>jQuery</li> <li>Popper</li> <li>Bootstrap (css and js)</li> </ul> <p>and put them where they need to go:</p> <ul> <li>wwwroot/css</li> <li>wwwroot/js</li> </ul> <p>The structure of <code>wwwroot</code> looked like this:</p> <pre><code>/wwwroot | |- css/ | | | |- bootstrap/ | | | `- site.css | |- images/ | `- js/ | |- bootstrap/ | |- jquery/ | |- popper/ | |- BootstrapJavascript.js | `- JavaScript.js </code></pre> <p>However, the &quot;powers that be&quot; have decided they would like to make this more efficient and automatic, so I now need to use LibMan to install everything, and I am using this method:</p> <pre><code>Solution Explorer -&gt; Project -&gt; Add -&gt; Client-Side Library... </code></pre> <p>So, everything went smoothly when installing, however I am having trouble with Popper. After installing, <code>wwwroot</code> now looks like this:</p> <pre><code>/wwwroot | |- css/ | | | |- bootstrap*.* | | | `- site.css | |- images/ | |- js/ | | | |- bootstrap*.* | | | |- cjs/ | | | |- esm/ | | | |- umd/ | | | `- BootstrapJavascript.js | `- scss/ </code></pre> <p>And I am receiving errors indicating that the application cannot find certain libraries or components of libraries.</p> <p>Originally, when using LibMan to install Popper, LibMan wanted to put Popper here:</p> <pre><code>wwwroot/lib/popper.js/ </code></pre> <p>However, I elected to put Popper in:</p> <pre><code>wwwroot/js/ </code></pre> <p>Also, on Bootstraps website, they instruct to pre-load the ability to use tooltips and popovers like this:</p> <pre><code>// For Bootstrap's Tooltips // https://getbootstrap.com/docs/5.2/components/tooltips/ const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle=&quot;tooltip&quot;]') const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl =&gt; new bootstrap.Tooltip(tooltipTriggerEl)) // For Bootstrap's Popovers // https://getbootstrap.com/docs/5.2/components/popovers/ const popoverTriggerList = document.querySelectorAll('[data-bs-toggle=&quot;popover&quot;]') const popoverList = [...popoverTriggerList].map(popoverTriggerEl =&gt; new bootstrap.Popover(popoverTriggerEl)) </code></pre> <p>Which I have in my BootstrapJavascript.js file.</p> <p>Some of the errors I am getting:</p> <pre><code>ReferenceError: exports is not defined at https://localhost:5003/js/cjs/popper.js:7:23 </code></pre> <p>Error at <code>App.razor:line 48</code>, which is in here:</p> <pre><code>protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender) { await JSRuntime.InvokeAsync&lt;IJSObjectReference&gt;(&quot;import&quot;, &quot;/js/cjs/popper.js&quot;); // THIS IS LINE #48 await JSRuntime.InvokeAsync&lt;IJSObjectReference&gt;(&quot;import&quot;, &quot;/js/bootstrap.js&quot;); await JSRuntime.InvokeAsync&lt;IJSObjectReference&gt;(&quot;import&quot;, &quot;/js/BootstrapJavaScript.js&quot;); } } </code></pre> <p>The application was working &quot;perfectly&quot; when I was hand installing Bootstrap, Popper, and jQuery, now it is not.</p> <p>What do I need to do to get this working like when I was hand-installing?</p> <hr /> <hr /> <p><strong>EDIT:</strong></p> <p><strong>libman.json</strong></p> <pre><code>{ &quot;version&quot;: &quot;1.0&quot;, &quot;defaultProvider&quot;: &quot;cdnjs&quot;, &quot;libraries&quot;: [ { &quot;library&quot;: &quot;jquery@3.6.1&quot;, &quot;destination&quot;: &quot;wwwroot/js/jquery/&quot; }, { &quot;library&quot;: &quot;popper.js@2.11.6&quot;, &quot;destination&quot;: &quot;wwwroot/js/popper/&quot; }, { &quot;library&quot;: &quot;twitter-bootstrap@5.2.2&quot;, &quot;destination&quot;: &quot;wwwroot/&quot; } ] } </code></pre> <p><strong>App.razor</strong></p> <pre><code>protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender) { await JSRuntime.InvokeAsync&lt;IJSObjectReference&gt;(&quot;import&quot;, &quot;/js/jquery/jquery.min.js&quot;); await JSRuntime.InvokeAsync&lt;IJSObjectReference&gt;(&quot;import&quot;, &quot;/js/popper/cjs/popper.min.js&quot;); await JSRuntime.InvokeAsync&lt;IJSObjectReference&gt;(&quot;import&quot;, &quot;/js/bootstrap.min.js&quot;); await JSRuntime.InvokeAsync&lt;IJSObjectReference&gt;(&quot;import&quot;, &quot;/js/BootstrapJavaScript.js&quot;); } } </code></pre> <p><strong>_Host.cshtml:</strong></p> <pre><code>&lt;head&gt; &lt;meta charset=&quot;utf-8&quot; /&gt; &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot; /&gt; &lt;base href=&quot;~/&quot; /&gt; &lt;link rel=&quot;stylesheet&quot; href=&quot;~/css/bootstrap.css&quot; /&gt; &lt;link rel=&quot;stylesheet&quot; href=&quot;~/css/site.css&quot; /&gt; &lt;/head&gt; ... &lt;/div&gt; &lt;script&gt; var blackpearlScript = document.createElement('script'); blackpearlScript.setAttribute('src', '/js/JavaScript.js'); document.head.appendChild(blackpearlScript); &lt;/script&gt; &lt;/body&gt; </code></pre>
[ { "answer_id": 74177314, "author": "AlirezaK", "author_id": 4444757, "author_profile": "https://Stackoverflow.com/users/4444757", "pm_score": 0, "selected": false, "text": "LibMan" }, { "answer_id": 74205861, "author": "Nb777", "author_id": 13256346, "author_profile":...
2022/10/21
[ "https://Stackoverflow.com/questions/74155091", "https://Stackoverflow.com", "https://Stackoverflow.com/users/319020/" ]
74,155,098
<p>Given two columns (Animal and Name) how do I write a SQL statement that finds the rows that don't have a 1 to 1 relationship i.e. Dog = Patch and Dog = Rover ?</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Animal</th> <th>Name</th> </tr> </thead> <tbody> <tr> <td>Dog</td> <td>Patch</td> </tr> <tr> <td>Cat</td> <td>Sylvester</td> </tr> <tr> <td>Mouse</td> <td>Gerry</td> </tr> <tr> <td>Mouse</td> <td>Gerry</td> </tr> <tr> <td>Dog</td> <td>Rover</td> </tr> </tbody> </table> </div>
[ { "answer_id": 74155231, "author": "ahmed", "author_id": 12705912, "author_profile": "https://Stackoverflow.com/users/12705912", "pm_score": 2, "selected": true, "text": "EXISTS" }, { "answer_id": 74155273, "author": "aloofball", "author_id": 9802940, "author_profile"...
2022/10/21
[ "https://Stackoverflow.com/questions/74155098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7507731/" ]
74,155,111
<p>I'm trying to gather some information from transfermarkt with a scraper, but when I open the page with a bot I always get a huge prompt to accept cookies. I've tried finding the element for the accept button by copying the full xpath, copying the relative xpath, and using '//button[@title=&quot;ACCEPTEER ALLE&quot;]', but it can never find the element. I've also tried using the wait until method, but that always led to time out errors because it still couldn't find it, and the page loads quickly. Does anyone know what's wrong?</p> <p>This is the button:</p> <pre><code>&lt;button title=&quot;ACCEPTEER ALLE&quot; class=&quot;message-component message-button no-children focusable sp_choice_type_11 last-focusable-el&quot; style=&quot;padding: 10px 15px; margin: 5px 10px; border-width: 2px; border-color: rgb(92, 166, 255); border-radius: 4px; border-style: solid; font-size: 14px; font-weight: 400; color: rgb(255, 255, 255); font-family: verdana, geneva, sans-serif; width: 225px; background: rgb(0, 25, 63);&quot;&gt;ACCEPTEER ALLE&lt;/button&gt; </code></pre> <p>This is my code:</p> <pre><code>league = &quot;Primera División&quot; url = &quot;https://www.transfermarkt.nl/schnellsuche/ergebnis/schnellsuche?query={}&quot;.format(league) browser = webdriver.Chrome() browser.get(url) sleep(10) button = browser.find_element(By.XPATH, '//button[@title=&quot;ACCEPTEER ALLE&quot;]') button.click() </code></pre>
[ { "answer_id": 74155406, "author": "Archiee", "author_id": 11756439, "author_profile": "https://Stackoverflow.com/users/11756439", "pm_score": 0, "selected": false, "text": " from selenium.webdriver.common.action_chains import ActionChains\n\n action = ActionChains(driver)\n cookie_page ...
2022/10/21
[ "https://Stackoverflow.com/questions/74155111", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19556055/" ]
74,155,114
<p>I used shared preference dependency to my project.At the initially open app dropdown value must be <strong>'howmany'</strong> but when select any other value and click next button and close application from mobile recents and user when reopen again then should display the value selected value by the user.</p> <p><strong>Ex:-</strong> At the initially user open app then dropdown value must be <strong>'howmany'</strong> and he select <strong>&quot;three&quot;</strong> and click next button after close the app and remove from recents apps. Later when he reopen the app must display dropdown value is <strong>&quot;three&quot;</strong></p> <p>images initial value</p> <p><a href="https://i.stack.imgur.com/DmOwl.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DmOwl.jpg" alt="enter image description here" /></a></p> <p>And according to this scenario, I tried to code but then shows these errors. 1st error</p> <p><a href="https://i.stack.imgur.com/88amc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/88amc.png" alt="enter image description here" /></a></p> <p>2nd error</p> <p><a href="https://i.stack.imgur.com/426Gb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/426Gb.png" alt="enter image description here" /></a></p> <p>MY code</p> <pre><code>import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; class FamilyDetailsScreen extends StatefulWidget { @override State&lt;FamilyDetailsScreen&gt; createState() =&gt; _FamilyDetailsScreenState(); } class _FamilyDetailsScreenState extends State&lt;FamilyDetailsScreen&gt; { // dropdown buttons late String dropdownValueMembersShared; // List of items in our dropdown menu var items = ['howmany', 'one', 'two', 'three ', 'four ', '5 or more']; void initState() { super.initState(); checkValueMembers(); } //IF &quot;dropdownValueMembers&quot; is empty pass &quot;howmany&quot; word as a initial value if al ready selected then pass the shared preference value checkValueMembers() { if (dropdownValueMembersShared != false) { // Initial Selected Value Members String dropdownValueMembers = 'howmany'; } else { String dropdownValueMembers = dropdownValueMembersShared; } } _saveData(String dropdownValueMembersShared) async { SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); sharedPreferences.setString(&quot;data&quot;, dropdownValueMembersShared); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, resizeToAvoidBottomInset: false, body: Container( child: SafeArea( child: Column( children: &lt;Widget&gt;[ const Text( 'family details', textAlign: TextAlign.center, style: TextStyle( color: Colors.black, fontSize: 18.00, fontWeight: FontWeight.w700, ), ), const SizedBox( height: 30, ), Padding( padding: const EdgeInsets.only(top: 10, left: 15), child: Row( children: &lt;Widget&gt;[ const Icon( Icons.brightness_1, color: Colors.black, size: 10.0, ), const Padding( padding: EdgeInsets.only(left: 13), child: Text( &quot;Number of children&quot;, style: TextStyle( fontSize: 15, fontWeight: FontWeight.w600), ), ), Padding( padding: const EdgeInsets.only(left: 2), child: Container( height: 25, decoration: BoxDecoration( boxShadow: const &lt;BoxShadow&gt;[ //apply shadow on Dropdown button BoxShadow( color: Color.fromRGBO( 0, 0, 0, 0.37), //shadow for button blurRadius: 5) //blur radius of shadow ], color: Colors.white, borderRadius: BorderRadius.circular(15), ), child: DropdownButton( underline: Container(), borderRadius: BorderRadius.circular(20), // Initial Value value: dropdownValueMembers, // Down Arrow Icon icon: const Icon(Icons.keyboard_arrow_down), // Array list of items items: items.map((String items) { return DropdownMenuItem( value: items, child: SizedBox( height: 15, width: 120.0, // for example child: Text(items, style: const TextStyle( fontSize: 13.0, fontWeight: FontWeight.w700), textAlign: TextAlign.center), ), ); }).toList(), // After selecting the desired option,it will // change button value to selected value onChanged: (String? newValue) { setState( () { dropdownValueMembers = newValue!; }, ); }, ), ), ), ], ), ), const SizedBox( height: 25, ), Padding( padding: const EdgeInsets.only(bottom: 0.0, top: 150), 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: () { _saveData; }, child: const Text('next')), ), ), ], ), ), ), ); } } </code></pre> <p><strong>How to solve these errors and How to adding sharedpreference to this code help me......</strong></p>
[ { "answer_id": 74155406, "author": "Archiee", "author_id": 11756439, "author_profile": "https://Stackoverflow.com/users/11756439", "pm_score": 0, "selected": false, "text": " from selenium.webdriver.common.action_chains import ActionChains\n\n action = ActionChains(driver)\n cookie_page ...
2022/10/21
[ "https://Stackoverflow.com/questions/74155114", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20000775/" ]
74,155,123
<p>I have two projects and for each of them I use one <code>github repo</code>. Both repos belong to one github account. I have registered the<code>ssh keys</code> of the corresponding <code>remote repo</code> in <code>.ssh/config</code>. Problem is that the <code>push</code> command works only for the repo, for one repo at a time:</p> <pre><code>IdentityFile ~/.ssh/id_rsa1 </code></pre> <p>When I try to put mutliple <code>ssh keys</code> into <code>config</code>:</p> <pre><code>IdentityFile ~/.ssh/id_rsa1 IdentityFile ~/.ssh/id_rsa2 </code></pre> <p>git throws this:</p> <pre><code>ERROR: Repository not found. fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. </code></pre> <p>When I do it like so, only the first key works:</p> <pre><code>Host github.com IdentityFile ~/.ssh/id_rsa1 Host github.com-repo2 IdentityFile ~/.ssh/id_rsa2 </code></pre> <p>How can I make both keys work without having to edit <code>config</code> each time I want to use the other repo?</p> <p><strong><code>Edit:</code></strong></p> <p>Trying to push with this <code>config</code> file:</p> <pre><code>Host github.com-repo1:me/reponame1 User git IdentityFile ~/.ssh/id_repo1 Host github.com-repo2:me/reponame2 User git IdentityFile ~/.ssh/id_repo2 </code></pre> <p>command:</p> <pre><code>git push -u origin main </code></pre> <p>leads to the same error:</p> <pre><code>ERROR: Repository not found. fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. </code></pre> <p><strong><code>Edit2:</code></strong></p> <p>This works:</p> <p>1 set url in each project to corresponding repo:</p> <pre><code>git remote set-url origin git@github.com-repo1:accountName/repo1.git </code></pre> <p>or</p> <pre><code>git remote set-url origin git@github.com-repo1:accountName/repo2.git </code></pre> <p>2 <strong>.ssh/config</strong>:</p> <pre><code>Host github.com-repo1 HostName github.com IdentityFile ~/.ssh/id_repo1 Host github.com-repo2 HostName github.com IdentityFile ~/.ssh/id_repo2 </code></pre> <p>3 push (from each project):</p> <pre><code>git push -u origin main </code></pre>
[ { "answer_id": 74160564, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 3, "selected": true, "text": "Host" }, { "answer_id": 74200373, "author": "Philippe", "author_id": 2125671, "author_profile": "https://S...
2022/10/21
[ "https://Stackoverflow.com/questions/74155123", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7826511/" ]
74,155,128
<p>I have no idea if this is related to a newly update on my web servers to PHP 8.0 from 7.4, but this seems to have happened after the update.</p> <p>I am retrieving JSON (and decoding it) from another URL. But after the update the <code>file_get_contents</code> returns nothing - its empty.</p> <p>This is what I have tried to locate the problem:</p> <pre><code>$json = file_get_contents(&quot;https://www.example.com/json.php&quot;); // not actual link echo $json . &quot;&lt;br&gt;&quot;; $dataArray = json_decode($json); echo var_dump($dataArray); </code></pre> <p>The first echo is just blank and the second echo is <code>NULL</code>.</p> <p>What could be wrong here? This is at the TOP of the page, so no code is prior to this.</p> <p><strong>EDIT</strong> I added the code to get errors and this is the start of what I got:</p> <pre><code>Warning: file_get_contents(https://www.example.com/json.php): Failed to open stream: HTTP request failed! HTTP/1.1 406 Not Acceptable </code></pre> <p><strong>EDIT 2</strong></p> <p>The suggested solution is that I add the <code>$ctx</code>variable to file_get_contents, but I still get the same error.</p> <pre><code>$ctx = stream_context_create(['http' =&gt; ['protocol_version' =&gt; '1.0']]); echo file_get_contents('https://LINKHERE.com', false, $ctx); </code></pre>
[ { "answer_id": 74156273, "author": "András Pál", "author_id": 11196806, "author_profile": "https://Stackoverflow.com/users/11196806", "pm_score": 0, "selected": false, "text": "PHP Warning: file_get_contents(https://www.example.com/json.php): Failed to open stream: HTTP request failed! ...
2022/10/21
[ "https://Stackoverflow.com/questions/74155128", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9942644/" ]
74,155,167
<p>I am having some problems with using v-model in my ionic application. It does not seems to update the data while using two way binding. See my code:</p> <pre class="lang-html prettyprint-override"><code>&lt;template&gt; &lt;form class=&quot;ion-padding&quot; @submit.prevent=&quot;submitForm&quot;&gt; &lt;ion-list&gt; &lt;ion-item&gt; &lt;ion-label position=&quot;flaoting&quot;&gt;Title&lt;/ion-label&gt; &lt;ion-input type=&quot;text&quot; v-model=&quot;enteredTitle&quot; /&gt; &lt;/ion-item&gt; &lt;ion-item&gt; &lt;ion-label position=&quot;flaoting&quot;&gt;Image URL&lt;/ion-label&gt; &lt;ion-input type=&quot;url&quot; required v-model=&quot;enteredImageUrl&quot; /&gt; &lt;/ion-item&gt; &lt;ion-item&gt; &lt;ion-label position=&quot;flaoting&quot;&gt;Description&lt;/ion-label&gt; &lt;ion-textarea rows=&quot;5&quot; v-model=&quot;enteredDescription&quot;&gt;&lt;/ion-textarea&gt; &lt;/ion-item&gt; &lt;/ion-list&gt; &lt;ion-button type=&quot;submit&quot; expand=&quot;full&quot;&gt;Save&lt;/ion-button&gt; &lt;/form&gt; &lt;/template&gt; &lt;script lang=&quot;ts&quot;&gt; import { reactive, toRefs } from 'vue'; export default { setup() { const enteredMemoryData = reactive({ enteredTitle: '', enteredImageUrl: '', enteredDescription: '', }); // METHOD function submitForm(){ console.log('Form is getting submitted'); const memoryData = { title: enteredMemoryData.enteredTitle, imageUrl: enteredMemoryData.enteredImageUrl, description: enteredMemoryData.enteredDescription, } console.log('Following data will be submitted', memoryData); } return { ...toRefs(enteredMemoryData), submitForm } }, } &lt;/script&gt; </code></pre> <p>Whenever I press the button I get the following console outputs:</p> <p><a href="https://i.stack.imgur.com/eYUAk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eYUAk.png" alt="enter image description here" /></a></p> <p>Am I doing something wrong?</p>
[ { "answer_id": 74156273, "author": "András Pál", "author_id": 11196806, "author_profile": "https://Stackoverflow.com/users/11196806", "pm_score": 0, "selected": false, "text": "PHP Warning: file_get_contents(https://www.example.com/json.php): Failed to open stream: HTTP request failed! ...
2022/10/21
[ "https://Stackoverflow.com/questions/74155167", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1976975/" ]
74,155,189
<p><strong>What is the standard way to log uncaught expressions in Flask routes with <code>logging</code>?</strong></p> <p>This nearly works:</p> <pre><code>import logging, sys, flask logging.basicConfig(filename='test.log', filemode='a', format='%(asctime)s %(levelname)s %(message)s') sys.excepthook = lambda exctype, value, tb: logging.error(&quot;&quot;, exc_info=(exctype, value, tb)) logging.warning(&quot;hello&quot;) app = flask.Flask('hello') @app.route('/') def index(): sjkfq # uncaught expresion return &quot;hello&quot; app.run() </code></pre> <p>but there are some ANSI escape characters in the log: <code>[31m[1m</code> etc. (probably for console colors)</p> <p>See here in the produced <code>test.log</code> file:</p> <pre><code>2022-10-21 16:23:06,817 WARNING hello 2022-10-21 16:23:07,096 INFO [31m[1mWARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.[0m * Running on http://127.0.0.1:5000 2022-10-21 16:23:07,097 INFO [33mPress CTRL+C to quit[0m 2022-10-21 16:23:07,691 ERROR Exception on / [GET] Traceback (most recent call last): File &quot;C:\Python38\lib\site-packages\flask\app.py&quot;, line 2525, in wsgi_app response = self.full_dispatch_request() File &quot;C:\Python38\lib\site-packages\flask\app.py&quot;, line 1822, in full_dispatch_request rv = self.handle_user_exception(e) File &quot;C:\Python38\lib\site-packages\flask\app.py&quot;, line 1820, in full_dispatch_request rv = self.dispatch_request() File &quot;C:\Python38\lib\site-packages\flask\app.py&quot;, line 1796, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) File &quot;D:\test.py&quot;, line 10, in index sjkfq NameError: name 'sjkfq' is not defined 2022-10-21 16:23:07,694 INFO 127.0.0.1 - - [21/Oct/2022 16:23:07] &quot;[35m[1mGET / HTTP/1.1[0m&quot; 500 - </code></pre> <p>Note that this is totally reproducible if you run the same code.</p> <p>Is there a documented way to do proper logging of uncaught exceptions in Flask routes, with Python <code>logging</code>? I didn't exactly find this in <a href="https://flask.palletsprojects.com/en/2.2.x/logging/" rel="nofollow noreferrer">https://flask.palletsprojects.com/en/2.2.x/logging/</a>.</p> <p>(Note: this code shows it's <em>not</em> the right way to do logging. We shouldn't intercept a logging string, do some reverse engineering to clean the escape characters, and then log to a file. There surely is a a standard logging way.)</p>
[ { "answer_id": 74179273, "author": "puchal", "author_id": 9730358, "author_profile": "https://Stackoverflow.com/users/9730358", "pm_score": 1, "selected": false, "text": "[31m[1m" }, { "answer_id": 74181636, "author": "c8999c 3f964f64", "author_id": 11803687, "author_...
2022/10/21
[ "https://Stackoverflow.com/questions/74155189", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1422096/" ]
74,155,199
<p>I have this code.</p> <pre><code>n_nodes = len(data_x) X = np.zeros((n_nodes, n_nodes)) for i in range(n_nodes): for j in range(n_nodes): X[i, j] = data_x[i] ** j </code></pre> <p>I want to do the same task with no loops used at all. How can I do that with NumPy functions?</p>
[ { "answer_id": 74155380, "author": "user_na", "author_id": 4177926, "author_profile": "https://Stackoverflow.com/users/4177926", "pm_score": 2, "selected": false, "text": "data_x" }, { "answer_id": 74155447, "author": "mozway", "author_id": 16343464, "author_profile":...
2022/10/21
[ "https://Stackoverflow.com/questions/74155199", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12476943/" ]
74,155,202
<p>I have an API response which contains \r\n. I am not able to replace it by using replace(string, '\r\n', ''). It does not work for it. When I use replace(string, 'r', '') it replaced every word which contains r except \r. Do you have any solution?</p>
[ { "answer_id": 74155380, "author": "user_na", "author_id": 4177926, "author_profile": "https://Stackoverflow.com/users/4177926", "pm_score": 2, "selected": false, "text": "data_x" }, { "answer_id": 74155447, "author": "mozway", "author_id": 16343464, "author_profile":...
2022/10/21
[ "https://Stackoverflow.com/questions/74155202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13023189/" ]
74,155,217
<p>I've been trying to use <code>line_profiler</code> on a wrapped function. However, the wrapper function gets profiled instead of the wrapped function. The executable snippet below shows that I can see that my <code>@decorate</code> wrapper function gets profiled instead of my <code>d()</code> function.</p> <p>Snippet: testy_profiler.py</p> <pre><code>from line_profiler import LineProfiler def a(): print(&quot;a&quot;) from functools import wraps def decorate(func): @wraps(func) def wrapper(*args, **kwargs): r = func(*args, **kwargs) print(&quot;decorating&quot;) return r return wrapper @decorate def d(): print(&quot;d&quot;) def go(): a() d() lprofiler = LineProfiler() lprofiler.add_function(a) lprofiler.add_function(d) lp_wrapper = lprofiler(go) lp_wrapper() lprofiler.print_stats() </code></pre> <p>Output:</p> <pre><code>$ python test_profiler.py a d decorating Timer unit: 1e-07 s Total time: 1e-05 s File: C:\Users\RENARDCH\Workspace\testy_profiler\test_profiler.py Function: a at line 3 Line # Hits Time Per Hit % Time Line Contents ============================================================== 3 def a(): 4 1 100.0 100.0 100.0 print(&quot;a&quot;) Total time: 4.4e-06 s File: C:\Users\RENARDCH\Workspace\testy_profiler\test_profiler.py Function: wrapper at line 8 Line # Hits Time Per Hit % Time Line Contents ============================================================== 8 @wraps(func) 9 def wrapper(*args, **kwargs): 10 1 24.0 24.0 54.5 r = func(*args, **kwargs) 11 1 18.0 18.0 40.9 print(&quot;decorating&quot;) 12 1 2.0 2.0 4.5 return r Total time: 1.87e-05 s File: C:\Users\RENARDCH\Workspace\testy_profiler\test_profiler.py Function: go at line 19 Line # Hits Time Per Hit % Time Line Contents ============================================================== 19 def go(): 20 1 126.0 126.0 67.4 a() 21 1 61.0 61.0 32.6 d() </code></pre> <p>This especially poses problem when two functions are wrapped with the same wrapper, since a global profiling will be generated for the wrapper, instead of a profiling for each functions individually.</p> <p><code>line_profiler</code> version is <code>3.4.0</code></p>
[ { "answer_id": 74155614, "author": "Vulpo", "author_id": 1924194, "author_profile": "https://Stackoverflow.com/users/1924194", "pm_score": 0, "selected": false, "text": "d()" }, { "answer_id": 74156265, "author": "Nick ODell", "author_id": 530160, "author_profile": "h...
2022/10/21
[ "https://Stackoverflow.com/questions/74155217", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1924194/" ]
74,155,278
<p>Given I have this array of objects:</p> <pre><code> let array1 = [ {id: 1, name: &quot;Test Item 1&quot;, price: 100, type: 'item'}, {id: 1, name: &quot;Test Fee 1&quot;, price: 200, type: 'fee'}, {id: 3, name: &quot;Test 3&quot;, price: 300, type: 'item'}, ] </code></pre> <p>Now i want to filter so I only have the objects where every key value of the following array match:</p> <pre><code> let array2 = [ {id: 1, type: &quot;item&quot;}, {id: 3, type: &quot;item&quot;}, ] </code></pre> <p>This should return <code>array1[0]</code> and <code>array1[2]</code>. My current solution has been this, but it wont work if array2 has multiple object keys to compare to:</p> <pre><code>array1.filter(row =&gt; { return array2.find(r =&gt; { return Object.entries(row).some(([key, value]) =&gt; r[key] === value); }) }); </code></pre>
[ { "answer_id": 74155488, "author": "bbbbbbbboat", "author_id": 8428405, "author_profile": "https://Stackoverflow.com/users/8428405", "pm_score": 3, "selected": true, "text": "array1.filter((row) =>\n array2.some((template) =>\n Object.keys(template).every((key) => template[key] === r...
2022/10/21
[ "https://Stackoverflow.com/questions/74155278", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6578746/" ]
74,155,319
<p>everyone. Here's the problem:</p> <pre><code>Column1 Column2 da fa fa da ra da ta ta </code></pre> <p>I need to count how many times each string appears in both columns: I mean, &quot;da&quot; appears 1 time in Column1 and 2 times in Column2, so I need the count of 3. Ps.: I can't stack them, because it will generate new rows with null values in my dataframe.</p>
[ { "answer_id": 74155334, "author": "akrun", "author_id": 3732271, "author_profile": "https://Stackoverflow.com/users/3732271", "pm_score": 1, "selected": false, "text": "sum" }, { "answer_id": 74155509, "author": "Karthik S", "author_id": 10722752, "author_profile": "...
2022/10/21
[ "https://Stackoverflow.com/questions/74155319", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19613162/" ]
74,155,347
<p>This question has been popping up a few times here on SO. I notice that most are dead because there is no minimal working example included so I have included that this time. The other thing that happens a lot, seemingly, is multiple Tk instances, so I did my best to keep it to one.</p> <p>The problem is that I cannot update the label in the InfoPane using a button in the AssetTree. I think that I do not really share the variable but make a copy of it. I'd like to make a pointer of <code>self.shared_data</code> to <code>parent.shared_data</code> but this is Python.</p> <pre><code>import random import tkinter as tk from tkinter import ttk class AssetTree(tk.Frame): def __init__(self, parent): super().__init__() self.config(background='white') self.shared_data = parent.shared_data self.button = ttk.Button(self, text=&quot;Test&quot;, command=self.btn) self.button.pack() def btn(self): print('click') print(self.shared_data) self.shared_data.set(&quot;HELLO&quot;) class InfoPane(tk.Frame): def __init__(self, parent): super().__init__() self.config(height=100, width=100, background='blue') self.label = ttk.Label(self, text=parent.shared_data.get()) self.label.pack() class MainApplication(tk.Frame): def __init__(self, parent, *args, **kwargs): tk.Frame.__init__(self, parent, *args, **kwargs) self.parent = parent self.shared_data = tk.StringVar() self.assettree = AssetTree(self) self.infopane = InfoPane(self) self.assettree.pack(side=&quot;left&quot;, fill=&quot;both&quot;, expand=True) self.infopane.pack(side=&quot;right&quot;, fill=&quot;both&quot;, expand=True) if __name__ == &quot;__main__&quot;: root = tk.Tk() root.title(&quot;Xyrim&quot;) MainApplication(root).pack(side=&quot;top&quot;, fill=&quot;both&quot;, expand=True) root.mainloop() </code></pre>
[ { "answer_id": 74155479, "author": "Kevin", "author_id": 953482, "author_profile": "https://Stackoverflow.com/users/953482", "pm_score": 3, "selected": true, "text": "self.label = ttk.Label(self, text=parent.shared_data.get())\n" }, { "answer_id": 74155480, "author": "JRiggle...
2022/10/21
[ "https://Stackoverflow.com/questions/74155347", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3275705/" ]
74,155,359
<p>This is a simple REST API for listing, creating and deleting products in/from database. I am having issues with validating/checking if certain values duplicate or if certain input field is not filled. I've attempted doing that with rowCount for the duplicate, in the php file, however I think there must be a better way for this, however I am having issues finding out how to do that.</p> <p>here is the post.php</p> <pre><code>$query_check = 'SELECT * FROM skandi WHERE sku = :sku'; $stmt_check = $this-&gt;conn-&gt;prepare($query_check); $stmt_check-&gt;bindParam(':sku', $this-&gt;sku); $stmt_check-&gt;execute(); if ($stmt_check-&gt;rowCount() &gt; 0) { echo 'product name already exists!'; } else { $query = 'INSERT INTO ' . $this-&gt;table . ' SET sku = :sku, name = :name, price = :price, productType = :productType, size = :size, weight = :weight, height = :height, length = :length, width = :width'; $stmt = $this-&gt;conn-&gt;prepare($query); $this-&gt;sku; $this-&gt;name; $this-&gt;price; $this-&gt;productType; $this-&gt;size; $this-&gt;weight; $this-&gt;height; $this-&gt;length; $this-&gt;width; $stmt-&gt;bindParam(':sku', $this-&gt;sku); $stmt-&gt;bindParam(':name', $this-&gt;name); $stmt-&gt;bindParam(':price', $this-&gt;price); $stmt-&gt;bindParam(':productType', $this-&gt;productType); $stmt-&gt;bindParam(':size', $this-&gt;size); $stmt-&gt;bindParam(':weight', $this-&gt;weight); $stmt-&gt;bindParam(':height', $this-&gt;height); $stmt-&gt;bindParam(':length', $this-&gt;length); $stmt-&gt;bindParam(':width', $this-&gt;width); if($stmt-&gt;execute()) { return true; } else { ini_set('display_errors',1); return false; } } </code></pre> <p>this is the ajaxcall for posting</p> <pre><code>$(document).ready(function () { $(&quot;#saveBtn&quot;).click(function (e) { e.preventDefault(); //serialize form data var url = $(&quot;form&quot;).serialize(); //function to turn url to an object function getUrlVars(url) { var hash; var myJson = {}; var hashes = url.slice(url.indexOf(&quot;?&quot;) + 1).split(&quot;&amp;&quot;); for (var i = 0; i &lt; hashes.length; i++) { hash = hashes[i].split(&quot;=&quot;); myJson[hash[0]] = hash[1]; } return JSON.stringify(myJson); } //pass serialized data to function var test = getUrlVars(url); //post with ajax $.ajax({ type: &quot;POST&quot;, url: &quot;/api/post/create.php&quot;, data: test, ContentType: &quot;application/json&quot;, success: function () { alert(&quot;successfully posted&quot;); }, error: function () { console.log(&quot;Could not be posted&quot;); }, }); </code></pre> <p>}); });</p>
[ { "answer_id": 74155479, "author": "Kevin", "author_id": 953482, "author_profile": "https://Stackoverflow.com/users/953482", "pm_score": 3, "selected": true, "text": "self.label = ttk.Label(self, text=parent.shared_data.get())\n" }, { "answer_id": 74155480, "author": "JRiggle...
2022/10/21
[ "https://Stackoverflow.com/questions/74155359", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20299597/" ]
74,155,360
<p>I wonder how the compilers deal with undefined behavior. I will take <code>GCC 10.4</code> for <code>x86</code> architecture and <code>-O2 -std=c++03</code> flags as an example, but please feel free to comment on other compilers. What does it take to alter the outcome of an operation with UB? The language standard does not prescribe what should happen if an operation has UB, but compiler will do something. That is, I'm not asking what happens in UB from C++'s perspective but from compiler's perspective. I know the c++ standard does not impose any restriction on the behavior of the program.</p> <p>For example, if I have UB due to the value of the object in a memory location being modified more than once by the evaluation of an expression, like so:</p> <pre><code>int i = 0; i = ++i + i++; // UB pre-C++11 </code></pre> <p>the chosen compiler in this setup generates the assembly code that reduces the computation to a constant, 3 in this case, see <a href="https://godbolt.org/z/MEEGT15dM" rel="nofollow noreferrer">https://godbolt.org/z/MEEGT15dM</a>.</p> <p>What can cause the constant to become anything rather than 3 if I do not change the compiler, its version, flags or architecture? Could editing the function without changing the value of <code>i</code> before the erroneous statement cause it?</p>
[ { "answer_id": 74166343, "author": "Eric Postpischil", "author_id": 298225, "author_profile": "https://Stackoverflow.com/users/298225", "pm_score": 2, "selected": true, "text": "i = ++i + i++;" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74155360", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3166723/" ]
74,155,373
<p>I am working with angular material matTable and I always get this type of error in the console:</p> <pre><code>Cannot read properties of undefined (reading 'template') at MatHeaderRowDef.extractCellTemplate </code></pre> <p>This my code:</p> <pre><code>&lt;table mat-table [dataSource]=&quot;dataSource&quot; multiTemplateDataRows&gt; &lt;ng-container matColumnDef=&quot;numero&quot;&gt; &lt;mat-header-row *matHeaderRowDef=&quot;displayedColumns&quot;&gt; &lt;mat-header-cell title=&quot;Numero&quot; *matHeaderCellDef mat-sort-header&gt; Numero&lt;/mat-header-cell&gt; &lt;/mat-header-row&gt; &lt;mat-row *matRowDef=&quot;let row; columns: displayedColumns;&quot;&gt; &lt;mat-cell *matCellDef=&quot;let item&quot;&gt;{{item.numero}}&lt;/mat-cell&gt; &lt;/mat-row&gt; &lt;/ng-container&gt; &lt;ng-container matColumnDef=&quot;amount&quot;&gt; &lt;mat-header-row *matHeaderRowDef=&quot;displayedColumns&quot;&gt; &lt;mat-header-cell *matHeaderCellDef mat-sort-header&gt; Amount&lt;/mat-header-cell&gt; &lt;/mat-header-row&gt; &lt;mat-row *matRowDef=&quot;let row; columns: displayedColumns;&quot;&gt; &lt;mat-cell *matCellDef=&quot;let item&quot;&gt; {{item.amount}} &lt;/mat-cell&gt; &lt;/mat-row&gt; &lt;/ng-container&gt; &lt;/table&gt; </code></pre>
[ { "answer_id": 74166343, "author": "Eric Postpischil", "author_id": 298225, "author_profile": "https://Stackoverflow.com/users/298225", "pm_score": 2, "selected": true, "text": "i = ++i + i++;" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74155373", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19749902/" ]
74,155,375
<p>while running command npm i i got this error npm ERR! code ERR_SSL_CIPHER_OPERATION_FAILED npm ERR! 78530000:error:1C800066:Provider routines:ossl_gcm_stream_update:cipher operation failed:c:\ws\deps\openssl\openssl\providers\implementations\ciphers\ciphercommon_gcm.c:312:</p> <p>I tried many ways to solve this like cache clear deleting package-log.json node modules but the error dont goes please help me with this</p>
[ { "answer_id": 74166343, "author": "Eric Postpischil", "author_id": 298225, "author_profile": "https://Stackoverflow.com/users/298225", "pm_score": 2, "selected": true, "text": "i = ++i + i++;" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74155375", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20302093/" ]
74,155,473
<p>I try to use the speak method also to re use with the Zebra class with composition.</p> <p>SO I have it like this:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>class Animal { constructor(name, age) { this.name = name; this.age = age; } speak() { return `my name is: ${this.name} and I am ${this.age} old`; } } class Zebra { constructor(Animal) { this.animal = Animal(); } } let animal = new Animal("hello", 99); let zebra = new Zebra(); console.log(zebra.speak());</code></pre> </div> </div> </p> <p>also composition!!:</p> <pre><code> class Person { String Title; String Name; Int Age; public Person(String title, String name, String age) { this.Title = title; this.Name = name; this.Age = age; } } class Employee { Int Salary; private Person person; public Employee(Person p, Int salary) { this.person = p; this.Salary = salary; } } Person johnny = new Person (&quot;Mr.&quot;, &quot;John&quot;, 25); Employee john = new Employee (johnny, 50000); </code></pre>
[ { "answer_id": 74155607, "author": "Konrad", "author_id": 5089567, "author_profile": "https://Stackoverflow.com/users/5089567", "pm_score": 0, "selected": false, "text": "const animal = {\n age: 10,\n name: 'hello',\n speak() {\n return `my name is: ${this.name} and I am ${this.age...
2022/10/21
[ "https://Stackoverflow.com/questions/74155473", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7713770/" ]
74,155,483
<p>i have the code which doing multiply requests</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 allCategory = []; if (Array.isArray(categoryTreeItems.value)) { const categoryFilter = [3338, 4775, 3411, 3995, 3949, 2934, 3071, 3462, 3629, 5239]; categoryFilter.forEach(async (cate) =&gt; { const {category: categoryData, search: searchCategoriesData} = useCategory('category-data-search'); await searchCategoriesData({id: cate}); if (categoryData.value.image_url.length &gt; 0) { allCategory.push(categoryData.value); } }); }</code></pre> </div> </div> </p> <p>and i need to send single by 'id:in' any help?</p> <p>below is part for which it calls categories</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>&lt;div class="show-shop-cate" v-show="allCategory.length &gt; 0"&gt; &lt;div class="position-slide"&gt; &lt;div class="slide-shop"&gt; &lt;p class="title-slide font-bold" :style="{color: '#fff'}"&gt;{{ "Shop By Category" }}&lt;/p&gt; &lt;VueSlickCarousel class="custom-slick" v-bind="getSettingSlide()"&gt; &lt;div v-for="(item, idx) in allCategory" :key="idx" class="custom-item radius-10 cursor-pointer relative"&gt; &lt;button type="button" @click="pushRouter(item)"&gt; &lt;img :src="item.image_url" class="radius-10"&gt; &lt;/button&gt; &lt;/div&gt; &lt;/VueSlickCarousel&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74155639, "author": "anuragb26", "author_id": 3104312, "author_profile": "https://Stackoverflow.com/users/3104312", "pm_score": 0, "selected": false, "text": "const promises = [];\nlet ids =[]; // id's to be collected \nlet result // result \nif (Array.isArray(categoryTree...
2022/10/21
[ "https://Stackoverflow.com/questions/74155483", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20302164/" ]
74,155,493
<p>How can I return resize logic of borders in Frameless Window?</p> <p>The frame windows has this logic: <a href="https://i.stack.imgur.com/g2VcW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/g2VcW.png" alt="enter image description here" /></a></p> <p>Code in QML:</p> <pre><code>import QtQuick import QtQuick.Controls 2.5 import Qt5Compat.GraphicalEffects import NR 1.0 Window { id: mainWindow width: 640 height: 720 visible: true title: qsTr(&quot;Hello World&quot;) flags: Qt.Window | Qt.FramelessWindowHint color: &quot;transparent&quot; // (1) MouseArea { id: bottomArea height: 5 anchors { bottom: parent.bottom left: parent.left right: parent.right } cursorShape: Qt.SizeVerCursor onPressed: { previousY = mouseY } onMouseYChanged: { var dy = mouseY - previousY mainWindow.setHeight(mainWindow.height + dy) } } // Some code of another Items here } </code></pre> <p>I tried this code for left side:</p> <pre><code> MouseArea { id: leftSideMouseArea anchors.fill: parent property point lastMousePos: Qt.point(0, 0) onPressed: { lastMousePos = Qt.point(mouseX, mouseY); } onMouseXChanged: mainWindow.width += (mouseX + lastMousePos.x) } </code></pre> <p>I put this code in (1) place, but it doesn't work - on click (without move) windows resize to the rigth and app crashes with error:</p> <blockquote> <p>QQuickPaintedItem::textureProvider: can only be queried on the rendering thread of an exposed window</p> </blockquote> <p>This looks like on picture: <a href="https://i.stack.imgur.com/V4pg3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/V4pg3.png" alt="enter image description here" /></a></p> <p>Can you help me?</p> <p>Thanks!</p>
[ { "answer_id": 74158375, "author": "Rawen", "author_id": 9857129, "author_profile": "https://Stackoverflow.com/users/9857129", "pm_score": 0, "selected": false, "text": "import QtQuick 2.15\nimport QtQuick.Window 2.15\n\nWindow {\n id: window\n width: 640\n height: 480\n visi...
2022/10/21
[ "https://Stackoverflow.com/questions/74155493", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9780820/" ]
74,155,494
<p>Can someone explain to me why you can use a method like count() for a QuerySet Object but something like pop() does not work.</p>
[ { "answer_id": 74155609, "author": "msamsami", "author_id": 13476175, "author_profile": "https://Stackoverflow.com/users/13476175", "pm_score": 3, "selected": true, "text": ".filter()" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74155494", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19490662/" ]
74,155,508
<p>I want to convert a nested dict to dataframe</p> <pre><code>{ '2022-09-08T15:00:00Z': { 'INMET_BRASILIA_A001_M': { &quot;DVENTO&quot;: [ {'value' : '95.0', 'quality': 'qf-GOOD', 'quality_flag': 'GOOD','structure' : 'INMET_BRASILIA_A001_M', 'element' : 'DVENTO'}], &quot;TD_MN_C&quot;:[ {'value' : '6.0', 'quality': 'qf-GOOD', 'quality_flag': 'GOOD','structure' : 'INMET_BRASILIA_A001_M', 'element' : 'TD_MN_C'},] }, }, '2022-09-09T12:00:00Z': { 'INMET_GOIANIA_A002_M': { &quot;DVENTO&quot; : [ {'value' : '25', 'quality' : 'qf-GOOD', 'quality_flag' : 'GOOD', 'structure' : 'INMET_GOIANIA_A002_M', 'element' : 'DVENTO' }], &quot;TD_MN_C&quot;:[{ 'value' : '3.0', 'quality' : 'qf-GOOD', 'quality_flag' : 'GOOD', 'structure' : 'INMET_GOIANIA_A002_M', 'element' : 'TD_MN_C'}], }, } } </code></pre> <p>I had this nested dict and now i want to convert to dataframe, something like this</p> <pre><code> DVENTO TD_MN_C 2022-09-08T15:00:00Z 95.0 6.0 2022-09-09T12:00:00Z 25 3.0 </code></pre> <p>please help me, I've been trying this for days</p>
[ { "answer_id": 74155797, "author": "msamsami", "author_id": 13476175, "author_profile": "https://Stackoverflow.com/users/13476175", "pm_score": 2, "selected": false, "text": "import pandas as pd\n\n\ndata = {\n '2022-09-08T15:00:00Z': {\n 'INMET_BRASILIA_A001_M':\n {\n...
2022/10/21
[ "https://Stackoverflow.com/questions/74155508", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18996279/" ]
74,155,514
<p>I am in 10th grade and was trying to build a simple calculator in c. Although I've checked multiple times even though the code was correct as per the syntax, it is not showing the proper output. Multiplication gives an output of 0, and addition/subtraction gives output as the first number input. tried alternative methods, yet everything results in the same output</p> <p>please try to troubleshoot the code explain me where am i going wrong.</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;math.h&gt; //Creating a simple calculator in c //add func int add(int n1, int n2) { int result = n1 + n2; return(result); } //subtract func int subtract(int n1, int n2) { int result = n1 - n2; return(result); } //divide func int divide(int n1, int n2) { int result = n1 / n2; return(result); } //multiply func int multiply(int n1, int n2) { int result = n1 * n2; return(result); } int main() { int num1, num2, ans; char op;//op means operator //use input printf(&quot;Enter first number: &quot;); scanf(&quot;%d&quot;, &amp;num1); //takes first number printf(&quot;\nEnter second number: &quot;); scanf(&quot;%d&quot;, &amp;num2); //takes second number printf(&quot;\nEnter operation: &quot;); scanf(&quot;%s&quot;, &amp;op); //takes an operator character like '+', '-', '/', '*' //checks which operator has been inputted if (op =='+') { int ans = add(num1, num2); printf(&quot;Answer: %d&quot;, ans); } else if (op=='-') { ans = num1-num2; printf(&quot;Aswer: %d&quot;, ans); } else if (op=='/') { ans = divide(num1, num2); printf(&quot;Answer: %d&quot;,ans); } else if (op == '*') { ans = multiply(num1, num2); printf(&quot;Answer: %d&quot;,ans); } else //exits with error if input instead of + - / * { printf(&quot;Invalid operator!&quot;); } return 0; } </code></pre>
[ { "answer_id": 74155797, "author": "msamsami", "author_id": 13476175, "author_profile": "https://Stackoverflow.com/users/13476175", "pm_score": 2, "selected": false, "text": "import pandas as pd\n\n\ndata = {\n '2022-09-08T15:00:00Z': {\n 'INMET_BRASILIA_A001_M':\n {\n...
2022/10/21
[ "https://Stackoverflow.com/questions/74155514", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20302071/" ]
74,155,522
<p>I'm using DRF's example of multiple updates which works fine except every <code>self.child.update</code> is a separate update query to the database.</p> <p>Is there a way I can rewrite this to call the updates as one query as a bulk update?</p> <pre><code>class BookListSerializer(serializers.ListSerializer): def update(self, instance, validated_data): book_mapping = {book.id: book for book in instance} data_mapping = {item['id']: item for item in validated_data} ret = [] for book_id, data in data_mapping.items(): book = book_mapping.get(book_id, None) ret.append(self.child.update(book, data)) return ret class BookSerializer(serializers.Serializer): id = serializers.IntegerField() class Meta: list_serializer_class = BookListSerializer </code></pre>
[ { "answer_id": 74155797, "author": "msamsami", "author_id": 13476175, "author_profile": "https://Stackoverflow.com/users/13476175", "pm_score": 2, "selected": false, "text": "import pandas as pd\n\n\ndata = {\n '2022-09-08T15:00:00Z': {\n 'INMET_BRASILIA_A001_M':\n {\n...
2022/10/21
[ "https://Stackoverflow.com/questions/74155522", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6060482/" ]
74,155,550
<p>tl,dr: An if conditional is activated when I know the condition is not TRUE.</p> <p>This is probably a question about python in general, but I came across this using tkinter, so i'm sticking with that. I was trying to understand code I got from here, when I found this problem (I stripped it down to make it plain):</p> <pre><code>import tkinter as tk after_id = None def post(): global after_id if after_id: print('How can this print if \&quot;after_id == True\&quot; is ' + str(after_id == True)) root = customtkinter.CTk() after_id = root.after(500, post) root.mainloop() </code></pre> <p>Evidently, this does print, and as you can see, after_id is not TRUE, it is not even Boolean. This sort of flies against everything I thought I knew about if statements. Can someone please explain to me what is going on here?</p>
[ { "answer_id": 74155631, "author": "Pycoder", "author_id": 20195962, "author_profile": "https://Stackoverflow.com/users/20195962", "pm_score": 1, "selected": false, "text": "if" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74155550", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6450378/" ]
74,155,563
<p>I have a Gnuplot data file broken into sections (2 blank lines). I wish to capture the indices I've selected to plot into the key of the plot, &quot;plot 'datafile' index 5:10:1 us 7:8 ti XXX&quot;, where XXX is the index. I understand the the pseudocolumn, column(-2), contains the index value.</p> <p>How do I capture the index and 'sprint' it into the title? The index is, of course, and integer.</p>
[ { "answer_id": 74155631, "author": "Pycoder", "author_id": 20195962, "author_profile": "https://Stackoverflow.com/users/20195962", "pm_score": 1, "selected": false, "text": "if" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74155563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12520696/" ]
74,155,565
<p>I'm reading the book <em>The Little Schemer</em>, I implement the functions in Clojure, How to rewrite this function as a tail-recursive function in Clojure?</p> <pre class="lang-clj prettyprint-override"><code>(defn rember* [a lat] (cond (empty? lat) [] (clojure.inspector/atom? (first lat)) (if (= a (first lat)) (rember* a (rest lat)) (cons (first lat) (rember* a (rest lat)))) :else (cons (rember* a (first lat)) (rember* a (rest lat))))) </code></pre>
[ { "answer_id": 74159341, "author": "Rulle", "author_id": 1008794, "author_profile": "https://Stackoverflow.com/users/1008794", "pm_score": 2, "selected": true, "text": "(defn rember* [a lat]\n (loop [[[op-type a lat] & rest-ops] (list [:rember a lat])\n data '()]\n (case op-t...
2022/10/21
[ "https://Stackoverflow.com/questions/74155565", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18847078/" ]
74,155,568
<p>I have json data which is in the structure below:</p> <pre><code>{&quot;Text1&quot;: 4, &quot;Text2&quot;: 1, &quot;TextN&quot;: 123} </code></pre> <p>I want to read the json file and make a dataframe such as</p> <p><a href="https://i.stack.imgur.com/OfzBY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OfzBY.png" alt="enter image description here" /></a></p> <p>Each key value pairs will be a row in the dataframe and I need to need headers &quot;Sentence&quot; and &quot;Label&quot;. I tried with using <strong>lines = True</strong> but it returns all the key-value pairs in one row.</p> <pre><code>data_df = pd.read_json(PATH_TO_DATA, lines = True) </code></pre> <p>What is the correct way to load such json data?</p>
[ { "answer_id": 74155722, "author": "Bushmaster", "author_id": 15415267, "author_profile": "https://Stackoverflow.com/users/15415267", "pm_score": 2, "selected": true, "text": "with open('json_example.json') as json_data:\n data = json.load(json_data)\n\ndf=pd.DataFrame.from_dict(data,...
2022/10/21
[ "https://Stackoverflow.com/questions/74155568", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4299527/" ]
74,155,572
<p>The TextFormField whenever clicked on causes the widgets to be resized. In the process the app suffers from a RenderFlex Overflow.</p> <p><strong>Note: Looking for a solution besides the disabling of resizeToAvoidBottomInset.</strong></p> <pre><code> // Center is a layout widget. It takes a single child and positions it // in the middle of the parent. child: Column( mainAxisAlignment: MainAxisAlignment.start, children: [ SingleChildScrollView( child: Column( children: [ const Padding( padding: EdgeInsets.symmetric(vertical: 10), child: Text( 'Enter contacts here', textScaleFactor: 1.5, ), ), Padding( padding: const EdgeInsets.all(8.0), child: InternationalPhoneNumberInput(onInputChanged: (value) {}), ), Padding( padding: const EdgeInsets.all(8.0), child: InternationalPhoneNumberInput(onInputChanged: (value) {}), ), Padding( padding: const EdgeInsets.all(8.0), child: InternationalPhoneNumberInput(onInputChanged: (value) {}), ), Padding( padding: const EdgeInsets.all(8.0), child: InternationalPhoneNumberInput(onInputChanged: (value) {}), ), Padding( padding: const EdgeInsets.all(8.0), child: TextFormField( autofocus: false, initialValue: &quot;Help! This is an emergency text sent as a call for help. Call the sender or police for assistance.&quot;, minLines: 2, maxLines: 5, decoration: const InputDecoration( border: OutlineInputBorder(), ), ), ), ], ) ), ], ), ),``` </code></pre>
[ { "answer_id": 74155722, "author": "Bushmaster", "author_id": 15415267, "author_profile": "https://Stackoverflow.com/users/15415267", "pm_score": 2, "selected": true, "text": "with open('json_example.json') as json_data:\n data = json.load(json_data)\n\ndf=pd.DataFrame.from_dict(data,...
2022/10/21
[ "https://Stackoverflow.com/questions/74155572", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20076721/" ]
74,155,576
<p>I'm trying to understand the behavior of on how the elements of a String[] contentsOfBag are added into a linkedbag which is csc220bag (for this programming case).</p> <p>First concern: from my understanding, each elements of String[] contentsOfBag are added such as element &quot;A&quot; goes into a Node with the data &quot;A&quot;. Inside this same Node we have another Node where the next element &quot;_&quot; will be the data of this next Node and so on? Please correct me if I'm wrong/not totally correct.</p> <p>Second concern is the purpose of constructor &quot;private Node(T dataPortion)&quot; &amp; &quot; private Node(T dataPortion, Node nextNode)&quot; ?</p> <p>It'll be very helpful for my understanding since I need to implement removeAllOccurences method. Ty</p> <p>Here is the code : Driver Code</p> <pre><code>public class LinkedBagCSC220JavaDriver { public static void main(String[] args) { System.out.println(&quot;=== LINKED BAG 220 JAVA ==========================================================&quot;); System.out.println(&quot;[+] Creating a CSC220 LinkedBag...&quot;); PrimaryDataStructureBagInterface&lt;String&gt; csc220Bag = new LinkedBag&lt;&gt;(); testAdd(csc220Bag); testRemoveAllOccurrences(csc220Bag); System.out.println(&quot;=== LINKED BAG 220 JAVA ==========================================================&quot;); } private static void displayBag(PrimaryDataStructureBagInterface&lt;String&gt; aBag) { System.out.print(&quot;[&gt;] The bag now contains &quot; + aBag.getCurrentSize() + &quot; string(s): \t&quot;); Object[] bagArray = aBag.toArray(); for (Object bagArray1 : bagArray) { System.out.print(bagArray1 + &quot; &quot;); } System.out.println(); } private static void testRemoveAllOccurrences(PrimaryDataStructureBagInterface&lt;String&gt; aBag) { // Removing all occurrences of the given entries from a bag System.out.println(&quot;[+] Creating... a 2D test array with the below contents: \t&quot;); String[][] testArray = { { &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot; }, { &quot;B&quot;, &quot;A&quot;, &quot;Bb&quot;, &quot;B&quot;, &quot;Bb&quot;, &quot;B&quot; }, { &quot;C&quot;, &quot;B&quot;, &quot;_&quot;, &quot;A&quot; }, { &quot;n&quot;, &quot;u&quot;, &quot;l&quot;, &quot;l&quot; } }; for (String[] row : testArray) { System.out.print(&quot;\t\t\t\t\t&quot;); for (String col : row) { System.out.print(col + &quot; &quot;); } System.out.println(&quot;&quot;); } aBag.removeAllOccurrences(testArray); displayBag(aBag); } private static void testAdd(PrimaryDataStructureBagInterface&lt;String&gt; aBag) { // Adding strings String[] contentsOfBag = { &quot;A&quot;, &quot;_&quot;, &quot;_&quot;, &quot;G&quot;, &quot;Bb&quot;, &quot;A&quot;, &quot;_&quot;, &quot;u&quot;, &quot;n&quot;, &quot;o&quot;, &quot;A&quot;, &quot;o&quot;, &quot;d&quot;, &quot;Bb&quot;, &quot;A&quot;, &quot;A&quot;, &quot;l&quot;, &quot;l&quot; }; System.out.print(&quot;[+] Adding.... these items to the bag: \t&quot;); for (String entry : contentsOfBag) { aBag.add(entry); // trying to understand behind the scene of this line System.out.print(entry + &quot; &quot;); } System.out.println(); displayBag(aBag); } </code></pre> <p>}</p> <p>Linkedbag</p> <pre><code>public final class LinkedBag&lt;T&gt; implements PrimaryDataStructureBagInterface&lt;T&gt; { private Node firstNode; private int numberOfEntries; public LinkedBag() { firstNode = null; numberOfEntries = 0; } @Override public boolean removeAllOccurrences(T[][] entries) { } private class Node { private T data; private Node next; private Node(T dataPortion) { this(dataPortion, null); } // end constructor private Node(T dataPortion, Node nextNode) { data = dataPortion; next = nextNode; } } </code></pre> <p>}</p> <p>Interface class - PrimaryDataStructureBagInterface</p> <pre><code>public interface PrimaryDataStructureBagInterface&lt;T&gt; { public int getCurrentSize(); public boolean isEmpty(); public boolean add(T newEntry); public boolean removeAllOccurrences(T[][] entries); public T[] toArray(); </code></pre> <p>}</p>
[ { "answer_id": 74155722, "author": "Bushmaster", "author_id": 15415267, "author_profile": "https://Stackoverflow.com/users/15415267", "pm_score": 2, "selected": true, "text": "with open('json_example.json') as json_data:\n data = json.load(json_data)\n\ndf=pd.DataFrame.from_dict(data,...
2022/10/21
[ "https://Stackoverflow.com/questions/74155576", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20299795/" ]
74,155,602
<p>I am extremely new to PHP, and I am having some issues with the number_format() function.</p> <p>I am performing a calculation which is, correctly, returning this result: 6215. However, I want this value to be displayed/echoed as 62.15. I have played around with the number_format() function to no avail.</p> <p>Any help would be greatly appreciated!</p>
[ { "answer_id": 74155681, "author": "mexslacker", "author_id": 13000645, "author_profile": "https://Stackoverflow.com/users/13000645", "pm_score": 0, "selected": false, "text": "\n<?php\n\n$number = 1234.56;\n\n// english notation (default)\n$english_format_number = number_format($number)...
2022/10/21
[ "https://Stackoverflow.com/questions/74155602", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17202274/" ]
74,155,613
<p>I'm new here and just started learning CSS. This is my first (question)post and maybe the format of my (question)post might not be appropriate.In that case I humbley ask your forgiveness. I'm not very successful in applying/editting css for my site. I'm trying to center (image)content in the @media only screen and (max-width: 420px)viewport. Searched,found and tried a few solutions for this issue as mentioned in this forum but to no avail. One of the problems is that my wordpress 6.x theme has a load of different style sheets and i have no clue in which order they operate. This is what i found browsing the style sheets; Beneath each code is the name of the css source file it came from. Can someone please point out which file i should edit and what code i should alter or apply? If needed i can give access to my site (which is local only atm) or post screenshots!</p> <p>*source: responsive.min.css :</p> <p>@media only screen and (max-width:420px){body.boxed:not(.has_general_padding) .wrapper .wrapper_inner,body.boxed.has_general_padding .wrapper .wrapper_inner,body.boxed footer,body.boxed .header_inner,body.boxed .full_width .parallax_content,body.boxed .carousel-inner,body.boxed .content_wrapper{width:320px}.header_bottom,footer .container_inner,nav.content_menu{padding:0 15px}.side_menu .close_side_menu_holder{right:12px}.pp_content{height:250px!important}.pp_hoverContainer{height:200px!important}nav.content_menu .nav_select_menu{border:0}</p> <hr /> <p>*source: responsive.css</p> <p>@media only screen and (max-width: 420px){</p> <pre><code>body.boxed:not(.has_general_padding) .wrapper .wrapper_inner, body.boxed.has_general_padding .wrapper .wrapper_inner, body.boxed footer, body.boxed .header_inner, body.boxed .full_width .parallax_content, body.boxed .carousel-inner, body.boxed .content_wrapper{ width: 320px; } .header_bottom, footer .container_inner, nav.content_menu{ padding: 0 15px; } .side_menu .close_side_menu_holder{ right: 12px; } .pp_content { height: 250px !important; } .pp_hoverContainer{ height: 200px !important; } nav.content_menu .nav_select_menu{ border: none; } </code></pre> <p>}</p>
[ { "answer_id": 74180377, "author": "Worsha", "author_id": 20299597, "author_profile": "https://Stackoverflow.com/users/20299597", "pm_score": 0, "selected": false, "text": "if (isset($_POST['sku']) {\n //exists\n}\n" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74155613", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20300920/" ]
74,155,676
<p>I tried many answers on stackoverflow and other websites but all of them actually move my mouse cursor.</p> <p>I'm looking for a way to click in a position (x, y) without actually moving my mouse cursor.</p> <p>Also I want to run it in a Windows RDP, so that when I exit the RDP, it still runs and clicks on it.</p> <p>I tried python modules like <code>pyautogui</code>, <code>mouse</code>, <code>clickpy</code> and <code>pymouse</code> but I failed.</p> <p>Do you help me for this?</p> <p>This is my simple HTML/JS code if you intend to test with:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;script&gt; var clicks = 0; function myFunction() { clicks += 1; document.getElementById(&quot;demo&quot;).innerHTML = clicks; } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;p&gt;Click the button to trigger a function.&lt;/p&gt; &lt;button onclick=&quot;myFunction()&quot;&gt;Click me&lt;/button&gt; &lt;p id=&quot;demo&quot;&gt;&lt;/p&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
[ { "answer_id": 74157327, "author": "rafathasan", "author_id": 9465840, "author_profile": "https://Stackoverflow.com/users/9465840", "pm_score": 2, "selected": false, "text": "import pyautogui as ag\n\ndef clickAndResetCursor(x,y):\n i,j = ag.position()\n ag.moveTo(x,y)\n ag.clic...
2022/10/21
[ "https://Stackoverflow.com/questions/74155676", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5790653/" ]
74,155,680
<p>I have been using flutter reactive and I have the following problem. When I when I use the function scanForDevices, it displays the found devices duplicate an infinite amount of times. I'm used to using libraries where the found devices appear only one time but this implementation seem to notify you whenever the device makes an advertisement. What can I do to get only one instance of the device? Is my only solution to make a map and add the device id as a key?</p>
[ { "answer_id": 74157327, "author": "rafathasan", "author_id": 9465840, "author_profile": "https://Stackoverflow.com/users/9465840", "pm_score": 2, "selected": false, "text": "import pyautogui as ag\n\ndef clickAndResetCursor(x,y):\n i,j = ag.position()\n ag.moveTo(x,y)\n ag.clic...
2022/10/21
[ "https://Stackoverflow.com/questions/74155680", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20302277/" ]
74,155,702
<p>How to combine two awk commands:</p> <ol> <li><code>awk NF file_name.csv &gt; file_name_after_NF.csv</code> the output is used in next step:</li> <li><code>awk 'BEGIN{f=&quot;&quot;}{if($0!=f){print $0}if(NR==1){f=$0}}' file_name_after_NF.csv &gt; file_name_postprocess.csv</code></li> </ol>
[ { "answer_id": 74157327, "author": "rafathasan", "author_id": 9465840, "author_profile": "https://Stackoverflow.com/users/9465840", "pm_score": 2, "selected": false, "text": "import pyautogui as ag\n\ndef clickAndResetCursor(x,y):\n i,j = ag.position()\n ag.moveTo(x,y)\n ag.clic...
2022/10/21
[ "https://Stackoverflow.com/questions/74155702", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18950478/" ]
74,155,710
<pre><code>[ { &quot;id&quot;: 1, &quot;pos&quot;: &quot;adverb&quot; }, { &quot;id&quot;: 2, &quot;pos&quot;: &quot;verb&quot; }, { &quot;id&quot;: 3, &quot;pos&quot;: &quot;noun&quot; }, { &quot;id&quot;: 4, &quot;pos&quot;: &quot;verb&quot; }, { &quot;id&quot;: 5, &quot;pos&quot;: &quot;noun&quot; }, { &quot;id&quot;: 6, &quot;pos&quot;: &quot;verb&quot; }, { &quot;id&quot;: 7, &quot;pos&quot;: &quot;adjective&quot; }, { &quot;id&quot;: 8, &quot;pos&quot;: &quot;noun&quot; }, { &quot;id&quot;: 9, &quot;pos&quot;: &quot;adjective&quot; }, { &quot;id&quot;: 10, &quot;pos&quot;: &quot;noun&quot; } ] </code></pre> <p><strong>Return Random Array With 10 Items In JavaScript, The array should include at least 1 of each &quot;pos&quot;</strong></p> <p>want to return a random array that includes 10 items from the array above, which should have at least 1 of each pos.</p> <p>I tried to do it but I'm getting random data and cannot control having at least 1 of each pos.</p>
[ { "answer_id": 74157327, "author": "rafathasan", "author_id": 9465840, "author_profile": "https://Stackoverflow.com/users/9465840", "pm_score": 2, "selected": false, "text": "import pyautogui as ag\n\ndef clickAndResetCursor(x,y):\n i,j = ag.position()\n ag.moveTo(x,y)\n ag.clic...
2022/10/21
[ "https://Stackoverflow.com/questions/74155710", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16192549/" ]
74,155,713
<p>I would like to create the graphic of a truss. I have two lists of lists; one gives the bar number and the nodes that make them, it looks like this:</p> <pre><code>elements = [[1, 1, 2], [2, 2, 3], [3, 3, 4], [4, 4, 5], [5, 5, 1], [6, 1, 4], [7, 2, 4], [8, 4, 6], [9, 6, 5]] </code></pre> <p>For example, element one is composed by node 1 and node 2. The other dataset gives the nodes followed by its coordinates in the 2D plane. It looks like this:</p> <pre><code>nodes= [[1.0, 0.0, 1.2], [2.0, -1.5, 1.2], [3.0, -1.5, 0.0], [4.0, 0.0, 0.0], [5.0, 1.5, 1.2], [6.0, 1.5, 0.0]] </code></pre> <p>For example, node 1 has the (0.0, 1.2) coordinates.</p> <p>I want to recreate with pyplot the following graphic using the lists of list above. Where A is 1.5m and B 1.2m.</p> <p><a href="https://i.stack.imgur.com/UnKDr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UnKDr.png" alt="Example of required image" /></a></p> <p>I thought doing something like this:</p> <pre><code>def draw(nodes): draw1=[] for i in range(len(nodes)): for j in range(len(nodes[1])): mmc+=[(nodes[i][j][1][1],nodes[i][j][1][2])] for t in [draw1]: xs1, ys1 = zip(*t) plot(xs1, ys1, 'o') plot(xs1, ys1, '-') plot.show() </code></pre> <p>I know I am not doing the for right (out of index) but I don´t really know how to solve it.</p>
[ { "answer_id": 74157745, "author": "gboffi", "author_id": 2749397, "author_profile": "https://Stackoverflow.com/users/2749397", "pm_score": 4, "selected": true, "text": "In [8]: class Bar():\n ...: def __init__(self, i, j):\n ...: self.i = i\n ...: self.j = j\n"...
2022/10/21
[ "https://Stackoverflow.com/questions/74155713", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20276952/" ]
74,155,717
<p>In the code below I have a borrow of <code>self</code> so how would I return <code>Self</code> here? Or would I create a new instance of impl and return that?</p> <pre class="lang-rust prettyprint-override"><code>pub fn add_minutes(&amp;self, minutes: i32) -&gt; Self { self.minutes += minutes; // TODO return Self } </code></pre>
[ { "answer_id": 74155769, "author": "Aleksander Krauze", "author_id": 13078067, "author_profile": "https://Stackoverflow.com/users/13078067", "pm_score": 2, "selected": false, "text": "Self" }, { "answer_id": 74155827, "author": "tadman", "author_id": 87189, "author_pr...
2022/10/21
[ "https://Stackoverflow.com/questions/74155717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3331102/" ]
74,155,721
<p>I'm writing a cuda library and I need to check the differences in performance between the option CPU and GPU. So I created a simple class called Timer to measure the time required to execute first a GPU function and then the CPU version.</p> <pre><code>class Timer { public: Timer() { _StartTimepoint = std::chrono::steady_clock::now(); } ~Timer() {} void Stop() { _stopped = true; using namespace std::chrono; auto endTimepoint = steady_clock::now(); auto start = time_point_cast&lt;milliseconds&gt;(_StartTimepoint).time_since_epoch().count(); auto end = time_point_cast&lt;milliseconds&gt;(endTimepoint).time_since_epoch().count(); auto _ms = end - start; _secs = _ms / 1000; _ms -= _secs * 1000; _mins = _secs / 60; _secs -= _mins * 60; _hour = _mins / 60; _mins -= _hour * 60; } double GetTime(){ if(_stopped == true) return _ms; else{ Stop(); return _ms; } } private: std::chrono::time_point&lt; std::chrono::steady_clock&gt; _StartTimepoint; double _secs,_ms,_mins,_hour; bool _stopped = false; }; </code></pre> <p>Since I need to check the performances for different values of a parameter m I just run both the functions inside a for loop as you can see:</p> <pre><code>for (size_t m = MIN_M; m &lt; MAX_M; m+=M_STEP){ m_array[m_cont] = m; //simulate double time_gpu,time_cpu; Timer timer_gpu; run_device(prcr_args,seeds,&amp;m_array[m_cont]); timer_gpu.Stop(); time_gpu = timer_gpu.GetTime(); Timer timer_cpu; simulate_host(prcr_args,seeds,&amp;m_array[m_cont]); timer_cpu.Stop(); time_cpu = timer_cpu.GetTime(); double g = time_cpu/time_gpu; ofs &lt;&lt; m //stream to print the results &lt;&lt; &quot;,&quot; &lt;&lt; time_cpu &lt;&lt; &quot;,&quot; &lt;&lt; time_gpu &lt;&lt; &quot;,&quot; &lt;&lt; g &lt;&lt; &quot;\n&quot;; m_cont ++; } </code></pre> <p>The problem is that the results i obtain are incredibly small and clearly wrong since they all are equal (the execution time should increase with m) and that my code requires a couple of minutes to run.</p> <pre><code>m,cpu_time,gpu_time,g 10,9.88131e-324,6.90979e-310,1.43004e-14 15,9.88131e-324,6.90979e-310,1.43004e-14 .... 90,9.88131e-324,6.90979e-310,1.43004e-14 95,9.88131e-324,6.90979e-310,1.43004e-14 100,9.88131e-324,6.90979e-310,1.43004e-14 </code></pre> <p>My guess is that the CPU doesn't execute the cycle sequentially and therefore starts and stops the clock immediately.</p>
[ { "answer_id": 74156631, "author": "Robert Crovella", "author_id": 1695960, "author_profile": "https://Stackoverflow.com/users/1695960", "pm_score": 1, "selected": false, "text": " auto _ms = end - start;\n\n\n\n _secs = _ms / 1000;\n _ms -= _secs * 1000;\n _mins = _...
2022/10/21
[ "https://Stackoverflow.com/questions/74155721", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14146932/" ]
74,155,724
<p>I have some code that plots a map with markers that represent a given pair of longitude and latitude (as a point).</p> <pre><code>df = pd.read_csv(&quot;geo.csv&quot;, delimiter=';', skiprows=0, low_memory=False) geometry = [Point(xy) for xy in zip(df['longitude'], df['latitude'])] gdf = GeoDataFrame(df, geometry=geometry) world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres')) gdf.plot(ax=world.plot(figsize=(10, 6)), marker='o', color='red', markersize=15); </code></pre> <p>Is it possible to plot a map with only a latitude (OR longitude) &quot;as a line&quot;? How would I do that?</p>
[ { "answer_id": 74156631, "author": "Robert Crovella", "author_id": 1695960, "author_profile": "https://Stackoverflow.com/users/1695960", "pm_score": 1, "selected": false, "text": " auto _ms = end - start;\n\n\n\n _secs = _ms / 1000;\n _ms -= _secs * 1000;\n _mins = _...
2022/10/21
[ "https://Stackoverflow.com/questions/74155724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20302308/" ]
74,155,729
<p>Assume I have two packages</p> <ul> <li><code>package1</code> <ul> <li>data sets d1, d2, d3</li> </ul> </li> <li><code>package2</code> which should use data sets from <code>package1</code></li> </ul> <p><code>package1</code> contains data sets, which I want to use for testing. I can access each of these via e.g. <code>package1::d1</code>. But how can I load all of them in an automated way?</p> <p>Something like</p> <pre><code>ds &lt;- data(package = &quot;package1&quot;) # you can try e.g. &quot;carData&quot; ds$results[1, 3] # gives the first entry mydataset &lt;- load(ds$results[1, 3]) # this does not work </code></pre> <p>Other will use both packages, so it should work for others and on different platforms (Windows, Mac) Any ideas?</p> <hr /> <pre><code>ds$results[1, 3] # Item # &quot;d1&quot; </code></pre> <p>looks promising, but</p> <pre><code>data(ds$results[1, 3]) # Warning message: # In data(ds$results[1, 3]) : data set ‘ds$results[1, 3]’ not found </code></pre>
[ { "answer_id": 74184432, "author": "MichiSmith", "author_id": 6705755, "author_profile": "https://Stackoverflow.com/users/6705755", "pm_score": 1, "selected": false, "text": "data()" }, { "answer_id": 74628238, "author": "Christoph", "author_id": 5784831, "author_prof...
2022/10/21
[ "https://Stackoverflow.com/questions/74155729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5784831/" ]
74,155,742
<p>I need to click on an element until the element is not visible, it goes of after clicking 30 times at max. So I've been trying out an for loop for this process. But I am completely new to Robot framework so I need some help. Here's my code from which I've been trying.</p> <pre><code> ${BUTTON} = run keyword and return status element should be visible ${NextButton} FOR ${BUTTON} IN RANGE 30 IF ${BUTTON} == ${True} click element ${NextButton} sleep 2s ${BUTTON} = run keyword and return status element should be visible ..${NextButton} EXIT FOR LOOP IF ${BUTTON} == ${False} END </code></pre>
[ { "answer_id": 74184432, "author": "MichiSmith", "author_id": 6705755, "author_profile": "https://Stackoverflow.com/users/6705755", "pm_score": 1, "selected": false, "text": "data()" }, { "answer_id": 74628238, "author": "Christoph", "author_id": 5784831, "author_prof...
2022/10/21
[ "https://Stackoverflow.com/questions/74155742", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20256339/" ]
74,155,786
<p>I am using direct query mode in power Bi, and I unable to use format function or add column from query editor. I want Day like this table:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Full Date</th> <th>Day</th> </tr> </thead> <tbody> <tr> <td>21/10/2022</td> <td>21</td> </tr> <tr> <td>1/5/2022</td> <td>1</td> </tr> </tbody> </table> </div> <p>Is there any other way I could get Day from date in direct query mode?</p>
[ { "answer_id": 74184432, "author": "MichiSmith", "author_id": 6705755, "author_profile": "https://Stackoverflow.com/users/6705755", "pm_score": 1, "selected": false, "text": "data()" }, { "answer_id": 74628238, "author": "Christoph", "author_id": 5784831, "author_prof...
2022/10/21
[ "https://Stackoverflow.com/questions/74155786", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20160998/" ]
74,155,800
<p>so this is my code. while the loop is running and I input bowl it should output 8,50. next input from loop should be added to the last output, this loop has to continue until control+d is entered. anybody got some tips for me? I'm pretty new to coding. I've tried adding the output from the validated input to a new list eventually printing the sum of that list, but so far I haven't got lucky</p> <pre><code>def main(): a = order() menu = { &quot;Baja Taco&quot;: 4.00, &quot;Burrito&quot;: 7.50, &quot;Bowl&quot;: 8.50, &quot;Nachos&quot;: 11.00, &quot;Quesadilla&quot;: 8.50, &quot;Super Burrito&quot;: 8.50, &quot;Super Quesadilla&quot;: 9.50, &quot;Taco&quot;: 3.00, &quot;Tortilla Salad&quot;: 8.00 } def order(): while True: try: i = input(&quot;Input: &quot;) i = i.title() # converts letter from input to titlecase if i in menu: print(&quot;total: ${:.2f}&quot;.format(menu.get(i))) except (EOFError): print('') break main() </code></pre>
[ { "answer_id": 74184432, "author": "MichiSmith", "author_id": 6705755, "author_profile": "https://Stackoverflow.com/users/6705755", "pm_score": 1, "selected": false, "text": "data()" }, { "answer_id": 74628238, "author": "Christoph", "author_id": 5784831, "author_prof...
2022/10/21
[ "https://Stackoverflow.com/questions/74155800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20302324/" ]
74,155,888
<p>I have 2 dataframes: <code>wd_patients</code> and <code>wd_appointments</code>.</p> <p>How do I check if all patients in wd_patients are also listed in wd_appointments and vice versa. And then how can I update these two files such that every patient in one dataset also exists in the other one as well?</p> <p>Please see the structures of my dataframes below:</p> <pre><code> str(wd_patients) Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 990 obs. of 5 variables: $ ID : chr &quot;QJSkgvEFvP&quot; &quot;UwSKF6tmaG&quot; &quot;TgO3Lo9cR6&quot; &quot;DFDaFnBxU9&quot; ... $ Age : num 63 64 60 76 66 68 69 87 74 85 ... $ Gender : chr &quot;Male&quot; &quot;Female&quot; &quot;Female&quot; &quot;Female&quot; ... $ AppointmentCount : num 3 3 3 3 5 2 2 2 5 2 ... $ TreatmentCompleted: chr &quot;Yes&quot; &quot;No&quot; &quot;No&quot; &quot;Yes&quot; ... str(wd_appointments) Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 3473 obs. of 3 variables: $ patientID : chr &quot;IEBQggWteS&quot; &quot;nCOytLO2tK&quot; &quot;Kc7D1GZhqr&quot; &quot;GTyawkFnQn&quot; ... $ apptDate : POSIXct, format: &quot;2022-06-01&quot; &quot;2022-06-01&quot; &quot;2022-06-01&quot; &quot;2022-06-01&quot; ... $ apptStatus: chr &quot;No Show&quot; &quot;No Show&quot; &quot;Cancelled&quot; &quot;Cancelled&quot; ... </code></pre>
[ { "answer_id": 74155963, "author": "br00t", "author_id": 4028717, "author_profile": "https://Stackoverflow.com/users/4028717", "pm_score": 1, "selected": false, "text": "ids1 <- setdiff(wd_patients$ID, wd_appointments$patientID) # ids in wd_patients but not wd_appointments\nids2 <- setdi...
2022/10/21
[ "https://Stackoverflow.com/questions/74155888", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20292030/" ]
74,155,897
<p>I am trying to select values from a table that are not duplicates - for example, with the following input set, I would like to select only the values in Column 1 that <em>don't</em> have a duplicated value in Column 2</p> <pre><code>Column 1 Column 2 A X B X C Y D Y E Z </code></pre> <p>Resulting in</p> <pre><code>Column 1 Column 2 E Z </code></pre> <p>This is made harder by my having a character limit for my SQL statement, and my having to join a couple of tables in the same query.</p> <p>My existing statement is here, and this is where I am stuck.</p> <pre><code>SELECT d.o_docguid, d.o_itemdesc FROM dms_doc d INNER JOIN (SELECT s.o_itemno as si, s.o_projectno as sp, t.o_itemno as ti, t.o_projectno as tp FROM env_bs1192_1 s, env_bs1192_2 t WHERE s.TB_FILE_ID = t.TB_FILE_ID) as r ON (si = d.o_itemno AND sp = d.o_projectno) OR (ti = d.o_itemno AND tp = d.o_projectno) </code></pre> <p>Results look like</p> <pre><code>o_docguid o_itemdesc aguid adescription bguid adescription cguid bdescription </code></pre> <p>I want to filter this list out such that all that remains are the unique descriptions and their associated guid (i.e. only the rows that have specifically a single unique entry in the description, or put another way, if there is a duplicate, throw both away - in this instance, cguid and bdescription should be the only results).</p> <p>The last challenge, which I still haven't solved, is that this SQL statement needs to fit into a character limit of 242 characters.</p>
[ { "answer_id": 74155963, "author": "br00t", "author_id": 4028717, "author_profile": "https://Stackoverflow.com/users/4028717", "pm_score": 1, "selected": false, "text": "ids1 <- setdiff(wd_patients$ID, wd_appointments$patientID) # ids in wd_patients but not wd_appointments\nids2 <- setdi...
2022/10/21
[ "https://Stackoverflow.com/questions/74155897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17901391/" ]
74,155,907
<p>I have an array and I want to convert that array into a csv file here is my code and how i store my arrays :</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 words = ['item1','item2','item3'] const txtNumber = 2; let newArr = [] for(let t= 1 ; t &lt;= txtNumber ; t++) { const data = "item1 , item2 , item3 ,item4"; const findWord = (word) =&gt; data.split(",").filter(x =&gt; x.includes(word)) const array = []; for(let i = 0; i &lt; words.length ; i++) { const x = findWord(words[i]); array.push(x[0]) } newArr = array.map(x =&gt; x === undefined ? '' : x.trim()); console.log(newArr) }</code></pre> </div> </div> </p> <p>how can i store newArr values into items.csv into my pc ?</p>
[ { "answer_id": 74156029, "author": "Mohammad Ali Rony", "author_id": 2773184, "author_profile": "https://Stackoverflow.com/users/2773184", "pm_score": 0, "selected": false, "text": "newArr" }, { "answer_id": 74156607, "author": "NickSlash", "author_id": 212869, "autho...
2022/10/21
[ "https://Stackoverflow.com/questions/74155907", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20302353/" ]
74,155,924
<p>I have this input</p> <pre><code>arr = [1,2,1,3,4,2,4,2] </code></pre> <p>What I'm trying to achieve is make elements of the given list as keys of a map and its indices as values in the form of a list.</p> <p>Like this :</p> <pre><code>mp = {1:[0,2],2:[1,5,7],3:[3],4:[4,6]} </code></pre> <p>And what will be the time-complexity for this?</p>
[ { "answer_id": 74156069, "author": "Gijs", "author_id": 1303355, "author_profile": "https://Stackoverflow.com/users/1303355", "pm_score": 2, "selected": false, "text": "from collections import defaultdict\n\nresult = defaultdict(list)\n\nfor pos, num in enumerate(array):\n result[num]....
2022/10/21
[ "https://Stackoverflow.com/questions/74155924", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14713427/" ]
74,155,933
<p>Apologies I am very new to Docker. I have the following <code>Docker</code> file which contains the following commands (see below). I am not sure I understand all commands and I would appreciate some explanation. I commented all the lines I understood but put a question mark in others. Please see below</p> <pre><code>#That this line means that python will be our base. Can some comment here please and explain this line more? FROM python:3.9 as base #create a working directory in the virtual machine (VM) WORKDIR /code # copy all the python requirements stored in requirements.txt into the new directoy (in the VM) COPY ./requirements.txt /code/requirements.txt # activate the package manager pip. But why use no-cache-dir? RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt # copy all files to the new directory (in the VM) COPY ./ /code/ # I don't understand the line below. Please explain? why uvicorn? app.main:app is the #location of the fastapi CMD [&quot;uvicorn&quot;, &quot;app.main:app&quot;, &quot;--host&quot;, &quot;0.0.0.0&quot;, &quot;--port&quot;, &quot;180&quot;] </code></pre> <p>Thank you</p>
[ { "answer_id": 74156069, "author": "Gijs", "author_id": 1303355, "author_profile": "https://Stackoverflow.com/users/1303355", "pm_score": 2, "selected": false, "text": "from collections import defaultdict\n\nresult = defaultdict(list)\n\nfor pos, num in enumerate(array):\n result[num]....
2022/10/21
[ "https://Stackoverflow.com/questions/74155933", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20176161/" ]
74,155,954
<p>I have a date value in windows console application like this one <code>&quot;P0Y0M0DT23H43M52.103S&quot;</code>, and I want to parse this datetime value in c# to get minutes out of datetime value. It is easily done in Java by using <code>new java.time.Duration.parse(&quot;P0Y0M0DT23H43M52.103S&quot;).toMinutes()</code>.</p> <p><a href="https://docs.oracle.com/javase/8/docs/api/java/time/Duration.html#parse-java.lang.CharSequence-" rel="nofollow noreferrer">The documentation</a> for <code>Duration.parse(CharSequence text)</code> says:</p> <blockquote> <p>This will parse a textual representation of a duration, including the string produced by <code>toString()</code>. The formats accepted are based on the ISO-8601 duration format <code>PnDTnHnMn.nS</code> with days considered to be exactly 24 hours.</p> </blockquote> <p>I am looking for a similar functionality in .net c# which can help me workout time in minutes accurately without having to run loop and split.</p> <p>Thank you</p>
[ { "answer_id": 74156042, "author": "Mathias R. Jessen", "author_id": 712649, "author_profile": "https://Stackoverflow.com/users/712649", "pm_score": 1, "selected": false, "text": "XmlConvert.ToTimeSpan()" }, { "answer_id": 74156166, "author": "Jon Skeet", "author_id": 226...
2022/10/21
[ "https://Stackoverflow.com/questions/74155954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3778549/" ]
74,155,955
<p>I have a string, it's a long text, the words are separated by white spaces (as usually).</p> <p>But it looks like people love to use different characters for their white spaces in the same text !</p> <p>Look at this screenshot, you will see regular white spaces (Hex Code 0020) and you will see another type of white space in yellow (Hex Code 00A0)</p> <p><a href="https://i.stack.imgur.com/DHjDj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DHjDj.png" alt="enter image description here" /></a></p> <p>Knowing that strings can have much more than 2 ways of &quot;writing&quot; white spaces. How can I unify (like a string replace) to a single white space?</p> <p>In other words : &quot;Replace all different white spaces by Hex Code 0020 whitespace&quot;</p>
[ { "answer_id": 74156156, "author": "Dmitry Bychenko", "author_id": 2319407, "author_profile": "https://Stackoverflow.com/users/2319407", "pm_score": 2, "selected": false, "text": "using System.Text.RegularExpressions;\n\n...\n\n// If you want to remove double spaces as well: \"A B C\" ...
2022/10/21
[ "https://Stackoverflow.com/questions/74155955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5466477/" ]
74,155,957
<p>Having a dataframe like this:</p> <pre><code>data.frame(id = c(1,2,3,4), time_stamp_1 = c(&quot;Nov 2016-Current&quot;, &quot;May 2013-Current&quot;, &quot;Oct 2015-Current&quot;, &quot;May 2014-Current&quot;), time_stamp_2 = c(&quot;Mar 2015-Nov 2016&quot;, &quot;May 2008-May 2013&quot;, &quot;Aug 2005-Current&quot;, &quot;Oct 2014-Jan 2015&quot;)) </code></pre> <p>How is it possible to add new columns which have the time difference in months for every row and whete current insert the &quot;Sept 2022&quot;.</p> <p>Example output:</p> <pre><code>data.frame(id = c(1,2,3,4), time_stamp_1 = c(&quot;Nov 2016-Current&quot;, &quot;May 2013-Current&quot;, &quot;Oct 2015-Current&quot;, &quot;May 2014-Current&quot;), time_stamp_2 = c(&quot;Mar 2015-Nov 2016&quot;, &quot;May 2008-May 2013&quot;, &quot;Aug 2005-Current&quot;, &quot;Oct 2014-Jan 2015&quot;), time_stamp_1_duration = c(41,43,24,53), time_stamp_2_duration = c(32,12,45,32)) </code></pre> <p>duration is an example only it is not the real, just for example.</p>
[ { "answer_id": 74156200, "author": "br00t", "author_id": 4028717, "author_profile": "https://Stackoverflow.com/users/4028717", "pm_score": 1, "selected": false, "text": "library(stringr)\n\ntimespan_to_duration <- function(x) {\n x[ x == 'Current' ] <- 'Sep 2022'\n x <- str_replace_all...
2022/10/21
[ "https://Stackoverflow.com/questions/74155957", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20224217/" ]
74,155,975
<div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>ID</th> <th>Name</th> <th>Count</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>John</td> <td>1</td> </tr> <tr> <td>1</td> <td>NULL</td> <td>10</td> </tr> <tr> <td>2</td> <td>Sam</td> <td>11</td> </tr> <tr> <td>3</td> <td>Mike</td> <td>13</td> </tr> <tr> <td>3</td> <td>NULL</td> <td>15</td> </tr> <tr> <td>4</td> <td>Tom</td> <td>80</td> </tr> <tr> <td>5</td> <td>Null</td> <td>90</td> </tr> <tr> <td>5</td> <td>Clare</td> <td>10</td> </tr> <tr> <td>6</td> <td>NULL</td> <td>10</td> </tr> </tbody> </table> </div> <p>The output I'm looking for in SQL/BigQuery</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>ID</th> <th>Name</th> <th>Count</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>John</td> <td>11</td> </tr> <tr> <td>2</td> <td>Sam</td> <td>11</td> </tr> <tr> <td>3</td> <td>Mike</td> <td>28</td> </tr> <tr> <td>4</td> <td>Tom</td> <td>80</td> </tr> <tr> <td>5</td> <td>Clare</td> <td>100</td> </tr> <tr> <td>6</td> <td>NULL</td> <td>10</td> </tr> </tbody> </table> </div> <p>I think there is a COALESCE function involved but not sure how to approach this.</p> <p>If there is a NULL Name, I want the count column to be added + for the NULL Name to be dropped</p>
[ { "answer_id": 74156200, "author": "br00t", "author_id": 4028717, "author_profile": "https://Stackoverflow.com/users/4028717", "pm_score": 1, "selected": false, "text": "library(stringr)\n\ntimespan_to_duration <- function(x) {\n x[ x == 'Current' ] <- 'Sep 2022'\n x <- str_replace_all...
2022/10/21
[ "https://Stackoverflow.com/questions/74155975", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19535408/" ]
74,156,002
<p>With a SQL database (in my case Sqlite, using Python), what is a standard way to have a column which is a set of elements?</p> <pre><code>id name items_set 1 Foo apples,oranges,tomatoes,ananas 2 Bar tomatoes,bananas ... </code></pre> <p>A simple implementation is using</p> <pre><code>CREATE TABLE data(id int, name text, items_set text); </code></pre> <p>but there are a few drawbacks:</p> <ul> <li><p>to query all rows that have <code>ananas</code>, we have to use <code>items_set LIKE '%ananas%'</code> and some tricks with separators to avoid querying &quot;ananas&quot; to also return rows with &quot;bananas&quot;, etc.</p> </li> <li><p>when we insert a new item in one row, we have to load the whole <code>items_set</code>, and see if the item is already in the list or not, before concatenating <code>,newitem</code> at the end.</p> </li> <li><p>etc.</p> </li> </ul> <p>There is surely better, what is a standard SQL solution for a column which is a list or set?</p> <p>Note: I don't know in advance all the possible values for the set/list.</p> <p>I can see a solution with a few additional tables, but in my tests, it multiplies the size on disk by a factor x2 or x3, which is a problem with many gigabytes of data.</p> <p>Is there a better solution?</p>
[ { "answer_id": 74156137, "author": "Rahul K P", "author_id": 4407666, "author_profile": "https://Stackoverflow.com/users/4407666", "pm_score": 0, "selected": false, "text": "set" }, { "answer_id": 74156164, "author": "ussu", "author_id": 13210063, "author_profile": "h...
2022/10/21
[ "https://Stackoverflow.com/questions/74156002", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1422096/" ]
74,156,017
<p>In Angular-14, I have this service:</p> <pre><code>import { Injectable } from '@angular/core'; @Injectable({ providedIn: 'root' }) export class PaginationService { //Pagination Variables temppage: number = 0; pageField = []; exactPageList: any; constructor() { } // On page load pageOnLoad() { if (this.temppage == 0) { this.pageField = []; for (var a = 0; a &lt; this.exactPageList; a++) { this.pageField[a] = this.temppage + 1; this.temppage = this.temppage + 1; } } } } </code></pre> <p>But I got this error:</p> <blockquote> <p>Type 'number' is not assignable to type 'never'</p> </blockquote> <p>and <strong>this.pageField[a]</strong> is highlighted.</p> <p>How do I get this resolved?</p> <p>Thanks</p>
[ { "answer_id": 74156152, "author": "Ali Adravi", "author_id": 586227, "author_profile": "https://Stackoverflow.com/users/586227", "pm_score": 1, "selected": false, "text": "pageField = [];\nTO\npageField: Number[] =[];\n" }, { "answer_id": 74156157, "author": "TmTron", "a...
2022/10/21
[ "https://Stackoverflow.com/questions/74156017", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9037515/" ]
74,156,026
<p>.Net Maui page with <code>CarouselView</code> and list of cards created via data binding to the collection of items in ViewModel (VM). I'm looking for ways to animate control inside <code>CarouselView</code> by some property in VM set to a particular value. Animation should be done in c# code (code-behind, trigger action, behavior etc.), not by xaml. Not sure how to properly implement that. This is what I considered as possible solutions:</p> <ul> <li><p>Declare event in VM and subscribe for it in code-behind. Works very well for non-template controls, but with <code>CarouselView</code> which consists of collection Card controls described inside <code>DataTemplate</code> I need to find that particular active control only, let's say <code>Label</code> that I want to animate. Not sure how to find it, there are one instance of it per each item in VM collection, but even if I do it does not look to be a good MVVM oriented design.</p> </li> <li><p>My big hope was on <code>TriggerAction&lt;Label&gt;</code> (given I want to animate <code>Label</code>), but then problem is TriggerAction seems to only work inside <code>EventTrigger</code> which only catches <strong>xaml control</strong> events, not VM events. What can catch VM events and property changes is <code>DataTrigger</code>, but it does not allow to have <code>TriggerAction&lt;T&gt;</code> declared inside on the other hand. Not sure why there is such limitation in .Net Maui, I wish I had some mix of both.</p> </li> <li><p>Behaviors, - as with triggers not sure how to run them by any property change or event declared in VM</p> </li> </ul> <pre class="lang-cs prettyprint-override"><code>// ViewModel (mvvm community toolkit is used): public partial class CollectionOfItems : ObservableObject { public Item[] Items {get; set;} } public partial class Item : ObservableObject { [ObservableProperty] public string _name; // Setting this to false should trigger Label animation [ObservableProperty] public bool _isInvalid; } </code></pre> <pre class="lang-xml prettyprint-override"><code> ... &lt;CarouselView ItemsSource=&quot;{Binding Items}&quot;&gt; &lt;CarouselView.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;Label Text=&quot;{Binding Name}&quot;&gt; &lt;Label.Triggers&gt; &lt;DataTrigger TargetType=&quot;Label&quot; Binding=&quot;{Binding IsInvalid}&quot; Value=&quot;True&quot;&gt; &lt;!-- I wish I was able to trigger InvalidDataTriggerAction from here, but it's not compatible with DataTrigger --&gt; &lt;/DataTrigger&gt; &lt;/Label.Triggers&gt; &lt;/Label&gt; &lt;/DataTemplate&gt; &lt;/CarouselView.ItemTemplate&gt; &lt;/CarouselView&gt; ... </code></pre> <pre class="lang-cs prettyprint-override"><code> // Animation should be implemented in c#, not XAML // Should be triggered by IsInvalid=false, but I do not know how: public class InvalidDataTriggerAction : TriggerAction&lt;Label&gt; { protected override void Invoke(Label label) { label.TranslateTo(-30, 0, 100); label.TranslateTo(60, 0, 100); label.TranslateTo(-30, 0, 100); } } </code></pre>
[ { "answer_id": 74156152, "author": "Ali Adravi", "author_id": 586227, "author_profile": "https://Stackoverflow.com/users/586227", "pm_score": 1, "selected": false, "text": "pageField = [];\nTO\npageField: Number[] =[];\n" }, { "answer_id": 74156157, "author": "TmTron", "a...
2022/10/21
[ "https://Stackoverflow.com/questions/74156026", "https://Stackoverflow.com", "https://Stackoverflow.com/users/738999/" ]
74,156,053
<p>I failed to generate the directory allure-results in my project. I have tried many methods from google(create src/test/resources/allure.properties, set <code>&lt;resultsDirectory&gt;${project.build.directory}/allure-results&lt;/resultsDirectory&gt;</code> in pom.xml, etc.), but all setting seems not to take effect. I also failed to redirect the result to other directories. It always said <em>&quot;[ERROR] Directory &lt;project_path&gt;/target/allure-results not found&quot;</em>.</p> <p>My command to generate report is</p> <pre class="lang-bash prettyprint-override"><code>mvn clean test -Dtest=aaaTestClass io.qameta.allure:allure-maven:report </code></pre> <p>My pom.xml is like:</p> <pre class="lang-xml prettyprint-override"><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt; &lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt; &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt; &lt;groupId&gt;***&lt;/groupId&gt; &lt;artifactId&gt;***&lt;/artifactId&gt; &lt;version&gt;***&lt;/version&gt; &lt;packaging&gt;jar&lt;/packaging&gt; &lt;parent&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt; &lt;version&gt;2.1.4.RELEASE&lt;/version&gt; &lt;/parent&gt; &lt;properties&gt; ... &lt;aspectj.version&gt;1.9.9&lt;/aspectj.version&gt; &lt;allure.version&gt;2.13.9&lt;/allure.version&gt; &lt;/properties&gt; &lt;dependencyManagement&gt; &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt; &lt;artifactId&gt;spring-cloud-dependencies&lt;/artifactId&gt; &lt;version&gt;Greenwich.SR1&lt;/version&gt; &lt;type&gt;pom&lt;/type&gt; &lt;scope&gt;import&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-dependencies&lt;/artifactId&gt; &lt;version&gt;${spring.boot.version}&lt;/version&gt; &lt;type&gt;pom&lt;/type&gt; &lt;scope&gt;import&lt;/scope&gt; &lt;/dependency&gt; &lt;/dependencies&gt; &lt;/dependencyManagement&gt; &lt;dependencies&gt; ... &lt;dependency&gt; &lt;groupId&gt;org.junit.platform&lt;/groupId&gt; &lt;artifactId&gt;junit-platform-launcher&lt;/artifactId&gt; &lt;version&gt;1.6.0&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-data-redis&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.junit.jupiter&lt;/groupId&gt; &lt;artifactId&gt;junit-jupiter&lt;/artifactId&gt; &lt;version&gt;${junit-jupiter.version}&lt;/version&gt; &lt;scope&gt;test&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.junit.jupiter&lt;/groupId&gt; &lt;artifactId&gt;junit-jupiter-params&lt;/artifactId&gt; &lt;version&gt;${junit-jupiter.version}&lt;/version&gt; &lt;scope&gt;test&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.junit.jupiter&lt;/groupId&gt; &lt;artifactId&gt;junit-jupiter-api&lt;/artifactId&gt; &lt;version&gt;${junit-jupiter.version}&lt;/version&gt; &lt;scope&gt;test&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.junit.vintage&lt;/groupId&gt; &lt;artifactId&gt;junit-vintage-engine&lt;/artifactId&gt; &lt;version&gt;${junit-jupiter.version}&lt;/version&gt; &lt;scope&gt;test&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.junit.platform&lt;/groupId&gt; &lt;artifactId&gt;junit-platform-engine&lt;/artifactId&gt; &lt;version&gt;1.7.0&lt;/version&gt; &lt;scope&gt;test&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.junit.platform&lt;/groupId&gt; &lt;artifactId&gt;junit-platform-commons&lt;/artifactId&gt; &lt;version&gt;1.7.0&lt;/version&gt; &lt;scope&gt;test&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.testng&lt;/groupId&gt; &lt;artifactId&gt;testng&lt;/artifactId&gt; &lt;version&gt;6.8&lt;/version&gt; &lt;scope&gt;test&lt;/scope&gt; &lt;/dependency&gt; ... &lt;!-- test report dependencies --&gt; &lt;dependency&gt; &lt;groupId&gt;io.qameta.allure&lt;/groupId&gt; &lt;artifactId&gt;allure-junit4&lt;/artifactId&gt; &lt;version&gt;${allure.version}&lt;/version&gt; &lt;scope&gt;test&lt;/scope&gt; &lt;/dependency&gt; &lt;/dependencies&gt; &lt;build&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt; &lt;version&gt;${spring.boot.version}&lt;/version&gt; &lt;configuration&gt; &lt;classifier&gt;runnable&lt;/classifier&gt; &lt;attach&gt;false&lt;/attach&gt; &lt;/configuration&gt; &lt;executions&gt; &lt;execution&gt; &lt;goals&gt; &lt;goal&gt;repackage&lt;/goal&gt; &lt;/goals&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt; &lt;!-- &lt;version&gt;${maven.jar.version}&lt;/version&gt; --&gt; &lt;version&gt;2.4&lt;/version&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;default-jar&lt;/id&gt; &lt;phase&gt;package&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;jar&lt;/goal&gt; &lt;/goals&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; &lt;!-- &lt;plugin&gt;--&gt; &lt;!-- &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;--&gt; &lt;!-- &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;--&gt; &lt;!-- &lt;version&gt;2.19.1&lt;/version&gt;--&gt; &lt;!-- &lt;configuration&gt;--&gt; &lt;!-- &lt;testFailureIgnore&gt;true&lt;/testFailureIgnore&gt;--&gt; &lt;!-- &lt;argLine&gt;--&gt; &lt;!-- -javaagent:&quot;${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar&quot;--&gt; &lt;!-- &lt;/argLine&gt;--&gt; &lt;!-- &lt;systemProperties&gt;--&gt; &lt;!-- &lt;property&gt;--&gt; &lt;!-- &lt;name&gt;allure.results.directory&lt;/name&gt;--&gt; &lt;!-- &lt;value&gt;${project.build.directory}/allure-results&lt;/value&gt;--&gt; &lt;!-- &lt;/property&gt;--&gt; &lt;!-- &lt;/systemProperties&gt;--&gt; &lt;!-- &lt;properties&gt;--&gt; &lt;!-- &lt;property&gt;--&gt; &lt;!-- &lt;name&gt;listener&lt;/name&gt;--&gt; &lt;!-- &lt;value&gt;io.qameta.allure.junit4.AllureJunit4&lt;/value&gt;--&gt; &lt;!-- &lt;/property&gt;--&gt; &lt;!-- &lt;/properties&gt;--&gt; &lt;!-- &lt;/configuration&gt;--&gt; &lt;!-- &lt;dependencies&gt;--&gt; &lt;!-- &lt;dependency&gt;--&gt; &lt;!-- &lt;groupId&gt;org.aspectj&lt;/groupId&gt;--&gt; &lt;!-- &lt;artifactId&gt;aspectjweaver&lt;/artifactId&gt;--&gt; &lt;!-- &lt;version&gt;${aspectj.version}&lt;/version&gt;--&gt; &lt;!-- &lt;/dependency&gt;--&gt; &lt;!-- &lt;/dependencies&gt;--&gt; &lt;!-- &lt;/plugin&gt;--&gt; &lt;!-- &lt;plugin&gt;--&gt; &lt;!-- &lt;groupId&gt;io.qameta.allure&lt;/groupId&gt;--&gt; &lt;!-- &lt;artifactId&gt;allure-maven&lt;/artifactId&gt;--&gt; &lt;!-- &lt;version&gt;2.10.0&lt;/version&gt;--&gt; &lt;!-- &lt;configuration&gt;--&gt; &lt;!-- &lt;reportVersion&gt;${allure.version}&lt;/reportVersion&gt;--&gt; &lt;!-- &lt;resultsDirectory&gt;${project.build.directory}/allure-results&lt;/resultsDirectory&gt;--&gt; &lt;!-- &lt;allureDownloadUrl&gt;--&gt; &lt;!-- https://***/io/qameta/allure/allure-commandline/2.18.1/allure-commandline-2.18.1.zip--&gt; &lt;!-- &lt;/allureDownloadUrl&gt;--&gt; &lt;!-- &lt;/configuration&gt;--&gt; &lt;!-- &lt;/plugin&gt;--&gt; &lt;/plugins&gt; &lt;/build&gt; &lt;profiles&gt; &lt;profile&gt; &lt;id&gt;aaa&lt;/id&gt; &lt;build&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt; &lt;version&gt;2.19.1&lt;/version&gt; &lt;configuration&gt; &lt;includes&gt; &lt;include&gt;**/aaatest/*Test&lt;/include&gt; &lt;/includes&gt; &lt;testFailureIgnore&gt;true&lt;/testFailureIgnore&gt; &lt;argLine&gt; -javaagent:&quot;${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar&quot; &lt;/argLine&gt; &lt;properties&gt; &lt;property&gt; &lt;name&gt;listener&lt;/name&gt; &lt;value&gt;io.qameta.allure.junit4.AllureJunit4&lt;/value&gt; &lt;/property&gt; &lt;/properties&gt; &lt;systemPropertyVariables&gt; &lt;allure.results.directory&gt;${project.build.directory}/allure-results&lt;/allure.results.directory&gt; &lt;/systemPropertyVariables&gt; &lt;/configuration&gt; &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;org.aspectj&lt;/groupId&gt; &lt;artifactId&gt;aspectjweaver&lt;/artifactId&gt; &lt;version&gt;${aspectj.version}&lt;/version&gt; &lt;/dependency&gt; &lt;/dependencies&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;groupId&gt;io.qameta.allure&lt;/groupId&gt; &lt;artifactId&gt;allure-maven&lt;/artifactId&gt; &lt;version&gt;2.11.2&lt;/version&gt; &lt;configuration&gt; &lt;reportVersion&gt;${allure.version}&lt;/reportVersion&gt; &lt;resultsDirectory&gt;${project.build.directory}/allure-results&lt;/resultsDirectory&gt; &lt;allureDownloadUrl&gt; https://***/io/qameta/allure/allure-commandline/2.18.1/allure-commandline-2.18.1.zip &lt;/allureDownloadUrl&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;/plugins&gt; &lt;/build&gt; &lt;/profile&gt; &lt;profile&gt; &lt;id&gt;bbb&lt;/id&gt; &lt;build&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt; &lt;version&gt;2.19.1&lt;/version&gt; &lt;configuration&gt; &lt;includes&gt; &lt;include&gt;**/bbbtest/*Test&lt;/include&gt; &lt;/includes&gt; &lt;testFailureIgnore&gt;true&lt;/testFailureIgnore&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;/plugins&gt; &lt;/build&gt; &lt;/profile&gt; &lt;/profiles&gt; &lt;/project&gt; </code></pre>
[ { "answer_id": 74171617, "author": "djmonki", "author_id": 11543023, "author_profile": "https://Stackoverflow.com/users/11543023", "pm_score": 1, "selected": false, "text": "<profiles>\n <profile>\n <id>aaa</id>\n <build>\n <plugins>\n <plugin>\n <artifactId>m...
2022/10/21
[ "https://Stackoverflow.com/questions/74156053", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6624547/" ]
74,156,056
<p>I am trying to connect Flink 1.14.4 with HBase version 2.2.14; I am added Hbase SQL connector jar flink-sql-connector-hbase-2.2-1.15.2.jar , but for version 2.2.x becauce it is the last version of jar.</p> <p>but I got the following error:</p> <pre><code>py4j.protocol.Py4JJavaError: An error occurred while calling o1.executeSql. : org.apache.flink.table.api.ValidationException: Unable to create a sink for writing table 'default_catalog.default_database.hTable'. Table options are: 'connector'='hbase-2.2' 'table-name'='test' 'zookeeper.quorum'='127.0.0.1:2181' at org.apache.flink.table.factories.FactoryUtil.createTableSink(FactoryUtil.java:184) at org.apache.flink.table.planner.delegation.PlannerBase.getTableSink(PlannerBase.scala:388) at org.apache.flink.table.planner.delegation.PlannerBase.translateToRel(PlannerBase.scala:222) at org.apache.flink.table.planner.delegation.PlannerBase$$anonfun$1.apply(PlannerBase.scala:182) at org.apache.flink.table.planner.delegation.PlannerBase$$anonfun$1.apply(PlannerBase.scala:182) at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234) at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234) at scala.collection.Iterator$class.foreach(Iterator.scala:891) at scala.collection.AbstractIterator.foreach(Iterator.scala:1334) at scala.collection.IterableLike$class.foreach(IterableLike.scala:72) at scala.collection.AbstractIterable.foreach(Iterable.scala:54) at scala.collection.TraversableLike$class.map(TraversableLike.scala:234) at scala.collection.AbstractTraversable.map(Traversable.scala:104) at org.apache.flink.table.planner.delegation.PlannerBase.translate(PlannerBase.scala:182) at org.apache.flink.table.api.internal.TableEnvironmentImpl.translate(TableEnvironmentImpl.java:1665) at org.apache.flink.table.api.internal.TableEnvironmentImpl.executeInternal(TableEnvironmentImpl.java:752) at org.apache.flink.table.api.internal.TableEnvironmentImpl.executeInternal(TableEnvironmentImpl.java:872) at org.apache.flink.table.api.internal.TableEnvironmentImpl.executeSql(TableEnvironmentImpl.java:742) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.flink.api.python.shaded.py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244) at org.apache.flink.api.python.shaded.py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357) at org.apache.flink.api.python.shaded.py4j.Gateway.invoke(Gateway.java:282) at org.apache.flink.api.python.shaded.py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132) at org.apache.flink.api.python.shaded.py4j.commands.CallCommand.execute(CallCommand.java:79) at org.apache.flink.api.python.shaded.py4j.GatewayConnection.run(GatewayConnection.java:238) at java.lang.Thread.run(Thread.java:750) Caused by: java.lang.NoSuchMethodError: org.apache.flink.table.factories.DynamicTableFactory$Context.getPhysicalRowDataType()Lorg/apache/flink/table/types/DataType; at org.apache.flink.connector.hbase2.HBase2DynamicTableFactory.createDynamicTableSink(HBase2DynamicTableFactory.java:95) at org.apache.flink.table.factories.FactoryUtil.createTableSink(FactoryUtil.java:181) ... 28 more </code></pre> <p>My hbase table is defined:</p> <pre><code>sink_ddl = &quot;&quot;&quot; CREATE TABLE hTable ( datemin STRING, family2 ROW&lt;datemax STRING&gt;, family3 ROW&lt;channel_title STRING, channel_id STRING&gt;, PRIMARY KEY (datemin) NOT ENFORCED ) WITH ( 'connector' = 'hbase-2.2', 'table-name' = 'test', 'zookeeper.quorum' = '127.0.0.1:2181' ) &quot;&quot;&quot; </code></pre> <p>T created a view to select data for elements and to insert them in hTable:</p> <pre><code>table_env.create_temporary_view('table_api_table', table) table_env.execute_sql(&quot;&quot;&quot; INSERT INTO hTable SELECT datemin, ROW(datemax), ROW(channel_title, channel_id) FROM table_api_table &quot;&quot;&quot;).wait() </code></pre> <p>I see that Flink 1.14 dont't support Hbase <a href="https://i.stack.imgur.com/TWvlf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TWvlf.png" alt="enter image description here" /></a></p> <p>So do I have to change hbase version?</p>
[ { "answer_id": 74197228, "author": "Zak_Stack", "author_id": 18748312, "author_profile": "https://Stackoverflow.com/users/18748312", "pm_score": 1, "selected": true, "text": "# Extra Java CLASSPATH elements. Optional.\nexport HBASE_CLASSPATH=/home/hadoop/hbase/conf\n" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74156056", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18748312/" ]
74,156,060
<p>I have a sorted dictionary (here the bids of an order book) with the following form, where the items in the parentheses are {price: amount} and sorted.</p> <pre><code>bids = SortedDict({0.0005: 11.0, 0.006: 10.0, 0.01: 28.6, 0.0105: 21.8, 0.012: 25.1}) </code></pre> <p>I also know my own quotes, which are:</p> <pre><code>own_bids = [{0.006: 10.0}, {0.012: 5.1}] </code></pre> <p>My goal is to exclude my own orders from the order book. The result should look like:</p> <pre><code>SortedDict({0.0005: 11.0, 0.01: 28.6, 0.0105: 21.8, 0.012: 20}) </code></pre> <p>I have tried to delete them by looping through my own orders and deleting the elements if quantity is 0. But it increased the run time by 12x so I am wondering if there is no simple operation to do this. Is there a fast method to do this in python?</p>
[ { "answer_id": 74156187, "author": "Andrej Kesely", "author_id": 10035985, "author_profile": "https://Stackoverflow.com/users/10035985", "pm_score": 3, "selected": true, "text": "own_bids" }, { "answer_id": 74156284, "author": "GOKARNA ADHIKARI", "author_id": 18089268, ...
2022/10/21
[ "https://Stackoverflow.com/questions/74156060", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5211023/" ]
74,156,079
<p>can I append a list of elements inside of each other infinitely using JS Vanilla? For example:</p> <pre><code>let list = [&quot;div&quot;,&quot;ul&quot;,&quot;li&quot;, &quot;a&quot;...] </code></pre> <p>results:</p> <pre><code>&lt;div&gt; &lt;ul&gt; &lt;li&gt; &lt;a&gt;...&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre>
[ { "answer_id": 74156187, "author": "Andrej Kesely", "author_id": 10035985, "author_profile": "https://Stackoverflow.com/users/10035985", "pm_score": 3, "selected": true, "text": "own_bids" }, { "answer_id": 74156284, "author": "GOKARNA ADHIKARI", "author_id": 18089268, ...
2022/10/21
[ "https://Stackoverflow.com/questions/74156079", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18785284/" ]
74,156,087
<p>I'm currently trying to import an Oracle DB .dmp (dump) file into my Oracle DB using DBeaver but have trouble doing so.</p> <p>The Oracle DB in question is running in a docker container. I successfully connected to this Oracle database with DBeaver, and can thus browse the database using DBeaver. Currently however, the DB is empty. That's where the .dmp file comes in.</p> <p>I want to import this .dmp file into my database, under a certain schema but I cannot seem to do this. The dump file looks something like this: 'export.dmp' and is around 16MB big.</p> <p>I'd like to import the data from the .dmp file to be able to browse the data to get familiar with it, as similar data will be stored in our own database.</p> <p>I looked online but was unable to get an answer that works for me.</p> <p>I tried using DBeaver but I don't seem to have the option to import or restore a DB via a .dmp file. At best, DBeaver proposes to import data using a .CSV file. I also downloaded the Oracle tool SQLDeveloper, but I can't manage to connect to my database in the docker container.</p> <p>Online there is also talk of an import / export tool that supposedly can create these .dmp files and import them, but I'm unsure how to get this tool and whether that is the way to do it. If so, I still don't understand how I can get to browse the data in DBeaver.</p> <p><strong>How can I import and browse the data from the .dmp file in my Oracle DB using DBeaver?</strong></p>
[ { "answer_id": 74156485, "author": "kfinity", "author_id": 3061852, "author_profile": "https://Stackoverflow.com/users/3061852", "pm_score": 1, "selected": false, "text": "docker cp export.dmp container_id:/u01/app/oracle/admin/<mydatabase>/dpdump/export.dmp\n" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74156087", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20302385/" ]
74,156,092
<p>I've been trying to figure this out, but I had no success until now.</p> <p>I found how to repeat a specific sequence (forever), how to show a sequence (1 to N) value only if another cell is not empty. But I can't find a solution to repeat a specific sequence (1 to 11 as many time as necessary) value only if a cell is NOT empty.</p> <p>The table will be updated by a Google Form, the empty cell to check would be the timestamp.</p> <p><img src="https://i.stack.imgur.com/fBaL8.png" alt="Here is a image showing the idea" /></p> <p><a href="https://docs.google.com/spreadsheets/d/1YoFXDIzipzyAlUiFvtYaMGJakFD6J5HDoOTLd4jhmXc/edit?usp=sharing" rel="nofollow noreferrer">Here is a link to a working sheet, with the idea hard-coded</a></p>
[ { "answer_id": 74156485, "author": "kfinity", "author_id": 3061852, "author_profile": "https://Stackoverflow.com/users/3061852", "pm_score": 1, "selected": false, "text": "docker cp export.dmp container_id:/u01/app/oracle/admin/<mydatabase>/dpdump/export.dmp\n" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74156092", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14185258/" ]
74,156,094
<p>I wrote a crop editor image profile but I want to change a state variable if file is picked up.</p> <pre><code>&lt;input type=&quot;file&quot; name=&quot;profilePicBtn&quot; accept=&quot;image/png, image/jpeg&quot; onChange={profilePicChange} id=&quot;upload&quot; style={{display:&quot;none&quot;}} /&gt; </code></pre> <p>this is my input element and in continue we have</p> <pre><code> let test = document.getElementById('upload') </code></pre> <p>and my props are</p> <pre><code> &lt;CropImage imageSrc={selectedImage} setEditorRef={editor} onCrop={onCrop} scaleValue={scaleValue} onScaleChange={onScaleChange} onTest={test} /&gt; </code></pre> <p>and in other component we have</p> <pre><code>const [isModalOpen, setIsModalOpen] = React.useState(false); if (onTest != null) { console.log('done') setIsModalOpen(true) } </code></pre> <p>but I got trapped in a infinite loop and receive this error</p> <blockquote> <p>react-dom.development.js:16317 Uncaught Error: Too many re-renders. React limits the number of renders to prevent an infinite loop.</p> </blockquote>
[ { "answer_id": 74156219, "author": "Timon", "author_id": 6419868, "author_profile": "https://Stackoverflow.com/users/6419868", "pm_score": 0, "selected": false, "text": "setIsModalOpen(true)" }, { "answer_id": 74156297, "author": "Dulaj Ariyaratne", "author_id": 13368318,...
2022/10/21
[ "https://Stackoverflow.com/questions/74156094", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19450127/" ]
74,156,104
<p>I was trying to run a flutter app on Ubuntu 22.04 LTS. Everything was working fine. But, today this problem came up while running the app. The Flutter SDK fails to build the app throwing the below error.</p> <pre><code>/snap/flutter/130/usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/../../../../lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /usr/lib/x86_64-linux-gnu/gio/modules/libgvfsdbus.so) Failed to load module: /usr/lib/x86_64-linux-gnu/gio/modules/libgvfsdbus.so </code></pre> <p>After searching on the internet I realized I need a backward version of libc. If I do <code>file /snap/flutter/130/usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/../../../../lib/x86_64-linux-gnu/libc.so.6</code>.<br/> I get the result <code>/snap/flutter/130/usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/../../../../lib/x86_64-linux-gnu/libc.so.6: symbolic link to libc-2.31.so</code>.</p> <p>Probably I need to install <strong>libc-2.31</strong>. But, how? I did not find any solution. Both Flutter and Ubuntu are upgraded to the latest versions.</p>
[ { "answer_id": 74160377, "author": "Employed Russian", "author_id": 50617, "author_profile": "https://Stackoverflow.com/users/50617", "pm_score": 1, "selected": false, "text": "libgvfsdbus.so" }, { "answer_id": 74162559, "author": "NoxusDraven", "author_id": 17030190, ...
2022/10/21
[ "https://Stackoverflow.com/questions/74156104", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9916154/" ]
74,156,130
<p>I have a variadic function that can take any combination of input arguments, as long as each one of those arguments is convertible to <code>bool</code>:</p> <pre class="lang-cpp prettyprint-override"><code>#include &lt;concepts&gt; #include &lt;cstddef&gt; // internal helper functions namespace { template &lt;typename T&gt; constexpr std::size_t count_truths(T t) { return (bool)t; } template &lt;typename T, typename... Args&gt; constexpr std::size_t count_truths(T t, Args... args) { // recursive variadic function return count_truths(t) + count_truths(args...); } } template &lt;typename T&gt; concept Booly = std::convertible_to&lt;T, bool&gt;; // variadic function for which all arguments should be constrained to Booly&lt;T&gt; // e.g. only_one(true, false, true, false, true) = false; only_one(true, false) = true template &lt;typename T, typename... Args&gt; requires Booly&lt;T&gt; constexpr bool only_one(T t, Args... args) { return count_truths(t, args...) == 1; } </code></pre> <p>I have attempted to constrain the templates using concepts to only allow bool-convertible types to be passed, but I have only managed to do so for the first parameter:</p> <pre class="lang-cpp prettyprint-override"><code>// following lines compile: only_one(true, false, false); only_one(BoolConvertible(), true, false); // this line is correctly forced to failure due to the concept not being satisfied: only_one(NonBoolConvertible(), false, true); // BUT this line is not detected as a concept constraint failure (but still compilation failure): only_one(true, NonBoolConvertible(), false, true); </code></pre> <p>How can I use C++20 concepts to constrain the remaining template parameters to ensure each one of them in <code>Args...</code> satisfies <code>Booly&lt;&gt;</code> ?</p>
[ { "answer_id": 74156131, "author": "saxbophone", "author_id": 6177253, "author_profile": "https://Stackoverflow.com/users/6177253", "pm_score": 0, "selected": false, "text": "requires" }, { "answer_id": 74156254, "author": "康桓瑋", "author_id": 11638718, "author_profile...
2022/10/21
[ "https://Stackoverflow.com/questions/74156130", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6177253/" ]
74,156,146
<p>Continuing on from a <a href="https://stackoverflow.com/questions/74148670/">previous question</a> of mine, I am attempting to implement <a href="https://www.microsoft.com/en-us/research/wp-content/uploads/2003/01/hmap.pdf" rel="nofollow noreferrer">Scrap Your Boilerplate</a> in scala 3 and am running into an issue now with the <code>mkT</code> function described in the paper. Given the following definition of <code>cast</code>:</p> <pre class="lang-scala prettyprint-override"><code> trait Cast[A, B]: def apply(a: A): Option[B] object Cast: given cSome[A, B](using t: A =:= B): Cast[A, B] with def apply(a: A) = Some(t(a)) given cNone[A, B](using t: NotGiven[A =:= B]): Cast[A, B] with def apply(a: A) = None def cast[A, B](a: A)(using c: Cast[A, B]): Option[B] = c(a) </code></pre> <p>I have tried to make <code>mkT</code> as follows:</p> <pre class="lang-scala prettyprint-override"><code> class MakeTransform[A] (val f: A =&gt; A) { def apply[B](b: B)(using c: Cast[A =&gt; A, B =&gt; B]): B = c(f) match { case Some(fb) =&gt; fb(b) case _ =&gt; b } } def mkT[A](f: A =&gt; A): MakeTransform[A] = MakeTransform(f) </code></pre> <p>And this seems to work fine with the boolean example:</p> <pre class="lang-scala prettyprint-override"><code>def not(a: Boolean): Boolean = !a mkT(not)(true) // false, function is clearly called on input value mkT(not)('a') // 'a' </code></pre> <p>However, when I try it with the company model objects, I can only get it to function as expected when I provide an explicit type call and the parameter matches that type. So given the following <code>Salary</code> definition:</p> <pre class="lang-scala prettyprint-override"><code>sealed trait Salary case class S(amt: Float) extends Salary def incS(amt: Float): Salary =&gt; Salary = { case S(a) =&gt; S(a * (1 + amt)) } val ralf: Employee = E(P(&quot;Ralf&quot;, &quot;Amsterdam&quot;), S(8000)) </code></pre> <p>I attempt to raise a <code>Salary</code>:</p> <pre class="lang-scala prettyprint-override"><code>inc(.1)(S(8000)) // S(8000) &lt;= no change </code></pre> <p>Unless, however, I am explicit with the type:</p> <pre class="lang-scala prettyprint-override"><code>inc(.1)[Salary](S(8000)) // S(8800.0) </code></pre> <p>But when I do that, I can only pass objects of the specified type as input:</p> <pre class="lang-scala prettyprint-override"><code>inc(.1)[Salary](ralf) // does not compile </code></pre> <p>which obviously defeats the purpose.</p> <p>My thought was, that because <code>MakeTransform</code>'s <code>apply</code> method takes a type parameter, that the input type would be inferred by the value passed to it, but that doesn't seem to always be the case. Even more baffling to me is the inconsistent behavior between the <code>Boolean</code> and <code>Salary</code> examples. Any ideas why? Also, while debugging things like this, is there a way to see what types are being inferred? The debugger shows the runtime type of the variables, but it would be helpful if there was a way to see what type parameters are at runtime.</p> <p>UPDATE: new thought, does this have to do with the fact that <code>S &lt;: Salary</code> and not <code>S =:= Salary</code>?</p>
[ { "answer_id": 74156131, "author": "saxbophone", "author_id": 6177253, "author_profile": "https://Stackoverflow.com/users/6177253", "pm_score": 0, "selected": false, "text": "requires" }, { "answer_id": 74156254, "author": "康桓瑋", "author_id": 11638718, "author_profile...
2022/10/21
[ "https://Stackoverflow.com/questions/74156146", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4234254/" ]
74,156,173
<p>I've got a dataset that has a lot of numerical columns (in the example below these columns are x, y, z). I want to create individual flagging variables for each of those columns (x_YN, y_YN, z_YN) such that, if the numerical column is &gt; 0, the flagging variable is = 1 and otherwise it's = 0. What might be the most efficient way to tackle this?</p> <p>Thanks for the help!</p> <pre><code>x &lt;- c(3, 7, 0, 10) y &lt;- c(5, 2, 20, 0) z &lt;- c(0, 0, 4, 12) df &lt;- data.frame(x,y,z) </code></pre>
[ { "answer_id": 74156189, "author": "akrun", "author_id": 3732271, "author_profile": "https://Stackoverflow.com/users/3732271", "pm_score": 2, "selected": false, "text": "df[paste0(names(df), \"_YN\")] <- +(df > 0)\n" }, { "answer_id": 74156251, "author": "Maël", "author_i...
2022/10/21
[ "https://Stackoverflow.com/questions/74156173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17959404/" ]
74,156,182
<p>I'm new to JS and I'm trying to populate a dropdown menu with items from an array but every time I loop through the array it displays letter after letter rather than the full string. Please let me know what am I doing wrong. Thank you</p> <p>JS:</p> <pre><code>var ProjectNames = []; ProjectNames = CProject; var select = document.getElementById(&quot;ProjectList&quot;); for (var i = 0; i &lt; ProjectNames.length; i++) { var el = document.createElement(&quot;option&quot;); console.log(ProjectNames[i]); var opt = ProjectNames[i]; el.textContent = opt; el.value = opt; select.appendChild(el); } </code></pre> <p>HTML:</p> <pre><code>&lt;select id=&quot;ProjectList&quot; onchange=&quot;AddHoursForm()&quot;&gt; &lt;option&gt; --Choose Project-- &lt;/option&gt; &lt;/select&gt; </code></pre> <p>Data in array is coming from Firebase. If I print console.log(ProjectNames) it gives the array objects but if I do console.log(ProjectNames[i]) it prints it letter by letter.</p>
[ { "answer_id": 74156204, "author": "IT goldman", "author_id": 3807365, "author_profile": "https://Stackoverflow.com/users/3807365", "pm_score": 2, "selected": true, "text": "var ProjectNames = [];\nProjectNames = [\"hello\", \"world\"];\n\nconsole.log(ProjectNames) // <--- check this i...
2022/10/21
[ "https://Stackoverflow.com/questions/74156182", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20302542/" ]
74,156,244
<p>My tests are in the following folder structure. Though I have also placed a sample test in the root, which doesn't work either. I get <code>no tests ran in 6.08s</code></p> <pre><code>root/ test/ integrations/ test_sample.py __init__.py __init__.py </code></pre> <p>I have tried using the command <code>pytest</code> by itself as well as specifying the test location <code>pytest ./test/integrations/test_sample.py</code></p> <p>I've been using a class to define multiple tests, but simple functions aren't running either.</p> <p>Class:</p> <pre class="lang-py prettyprint-override"><code>class TestClass: def add(self): pass </code></pre> <p>Function:</p> <pre class="lang-py prettyprint-override"><code>def add(): pass </code></pre>
[ { "answer_id": 74156345, "author": "picobit", "author_id": 6030926, "author_profile": "https://Stackoverflow.com/users/6030926", "pm_score": 3, "selected": true, "text": "test" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74156244", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1551027/" ]
74,156,256
<p>I'm currently experimenting with WPF/XAML animations. In doing so, the question arose whether it was possible: by hovering over one control element, to trigger the animation of another control element?</p> <p>Example: When I hover over Label1, the background of Label2 turns yellow and Label3 turns red.</p> <p>My Try:</p> <pre><code>&lt;UserControl.Resources&gt; &lt;Style TargetType=&quot;{x:Type Label}&quot; x:Key=&quot;styleOfButtonOne&quot;&gt; &lt;Setter Property=&quot;Background&quot; Value=&quot;White&quot;/&gt; &lt;Style.Triggers&gt; &lt;Trigger Property=&quot;IsMouseOver&quot; Value=&quot;True&quot;&gt; &lt;Setter Property=&quot;Background&quot; Value=&quot;Red&quot; TargetName=&quot;btn_Two&quot;/&gt; &lt;Setter Property=&quot;Background&quot; Value=&quot;Green&quot; TargetName=&quot;btn_Three&quot;/&gt; &lt;/Trigger&gt; &lt;/Style.Triggers&gt; &lt;/Style&gt; &lt;/UserControl.Resources&gt; &lt;Grid&gt; &lt;StackPanel Orientation=&quot;Vertical&quot;&gt; &lt;Label x:Name=&quot;btn_One&quot; Content=&quot;Button One&quot; Style=&quot;{StaticResource styleOfButtonOne}&quot;/&gt; &lt;Label x:Name=&quot;btn_Two&quot; Content=&quot;Button Two&quot;/&gt; &lt;Label x:Name=&quot;btn_Three&quot; Content=&quot;Button Three&quot;/&gt; &lt;/StackPanel&gt; &lt;/Grid&gt; </code></pre>
[ { "answer_id": 74156345, "author": "picobit", "author_id": 6030926, "author_profile": "https://Stackoverflow.com/users/6030926", "pm_score": 3, "selected": true, "text": "test" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74156256", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11565787/" ]
74,156,289
<p>I’m trying to call a Web service via SOAP (<a href="https://modelviewers.pilotfishtechnology.com/modelviewers/OTA/model/Format.OTA_HotelRoomListRQ.html" rel="nofollow noreferrer">https://modelviewers.pilotfishtechnology.com/modelviewers/OTA/model/Format.OTA_HotelRoomListRQ.html</a>).</p> <p>My code, so far, is:</p> <pre><code>var OTA_HotelRoomListRQ = new MyMapping.OTA_HotelRoomListRQ() { TimeStamp = DateTime.Now, Version = 1, HotelRoomLists = new HotelRoomListType[] { new HotelRoomListType { HotelCode = &quot;12345&quot; } } }; MyMapping.OTA_HotelRoomListRS OTA_HotelRoomListRS = null; var test = MyMapping_PortTypeClient.ReadRoomTypes(securityHeaderType, ref MessageID, ref to, ref from, ref action, OTA_HotelRoomListRQ, out OTA_HotelRoomListRS); </code></pre> <p>I get the following error:</p> <pre><code>There was an error in serializing one of the headers in message ReadRoomTypesRequest: 'Unable to generate a temporary class (result=1). error CS0030: Cannot convert type 'MySolution.ReadMapping.VendorMessageType[]' to 'MySolution.ReadMapping.VendorMessageType' error CS0030: Cannot convert type 'MySolution.ReadMapping.VendorMessageType[]' to 'MySolution.ReadMapping.VendorMessageType' error CS0029: Cannot implicitly convert type 'MySolution.ReadMapping.VendorMessageType' to 'MySolution.ReadMapping.VendorMessageType[]' error CS0029: Cannot implicitly convert type 'MySolution.ReadMapping.VendorMessageType' to 'MySolution.ReadMapping.VendorMessageType[]' '. Please see InnerException for more details. </code></pre> <p>I don’t understand what I’m missing and what the error references.</p>
[ { "answer_id": 74156345, "author": "picobit", "author_id": 6030926, "author_profile": "https://Stackoverflow.com/users/6030926", "pm_score": 3, "selected": true, "text": "test" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74156289", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3918095/" ]
74,156,299
<p>While doing leetcode, it says adding to a specific node in a singly linked list requires O(1) time complexity:</p> <blockquote> <p>Unlike an array, we don’t need to move all elements past the inserted element. Therefore, you can insert a new node into a linked list in O(1) time complexity, which is very efficient.</p> </blockquote> <p>When deleting it's O(n) time which makes sense because you need to traverse to the node-1 and change the pointers. Isn't it the same when adding, which means it should also be O(n) time complexity?</p> <p>Specifically, when adding, you still need to traverse to the index-1 you want to add at and change that node's <code>.next</code> to the new node.</p> <p><a href="https://i.stack.imgur.com/qhBPY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qhBPY.png" alt="enter image description here" /></a></p> <p>Leetcode reference - adding: <a href="https://leetcode.com/explore/learn/card/linked-list/209/singly-linked-list/1288/" rel="nofollow noreferrer">here</a> <br /> Leetcode reference - conclusion: <a href="https://leetcode.com/explore/learn/card/linked-list/213/conclusion/1230/" rel="nofollow noreferrer">chart</a></p>
[ { "answer_id": 74156441, "author": "PMF", "author_id": 2905768, "author_profile": "https://Stackoverflow.com/users/2905768", "pm_score": 1, "selected": false, "text": "next" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74156299", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12894626/" ]
74,156,395
<p>I am currently working in VSCode and attempting to import various libraries into my file. I am currently using the interpreter <a href="https://i.stack.imgur.com/jli9Y.png" rel="nofollow noreferrer">image of interpreter</a>. The remainder of my code is shown <a href="https://i.stack.imgur.com/h9qwQ.png" rel="nofollow noreferrer">remainder of code</a>. I do not understand why my numpy is unable to be imported.</p>
[ { "answer_id": 74156441, "author": "PMF", "author_id": 2905768, "author_profile": "https://Stackoverflow.com/users/2905768", "pm_score": 1, "selected": false, "text": "next" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74156395", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20302753/" ]
74,156,415
<p>I have the following list</p> <pre><code>students = ['44560 Susan Pierce 46', '49509 John Lee 74', '49510 Kim Note 76', '49519 Jennifer Six 50', '49556 Maria Cruz 67', '49586 Martin Lewis 79', '55900 Richard White 100'] </code></pre> <p>I created this function which is supposed to return the entire element of the list if the inputted number matches the first five characters:</p> <pre><code>def search_student(number, students): student = [] for i in students: student.append(i[0:5]) for i in range(0, len(students)): if student[i] == number: return students[i] else: return &quot;student not found&quot; </code></pre> <p>As for now my code only works for the first element but not for any of the other ones.</p> <p>Any suggestions why the second for loop does not iterate through the entire list?</p> <p>Thankful for any suggestions or error detections.</p>
[ { "answer_id": 74156536, "author": "Jannes", "author_id": 19234686, "author_profile": "https://Stackoverflow.com/users/19234686", "pm_score": 1, "selected": false, "text": "students = ['44560 Susan Pierce 46', '49509 John Lee 74', '49510 Kim Note 76', '49519 Jennifer Six 50', '49556 Mari...
2022/10/21
[ "https://Stackoverflow.com/questions/74156415", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20279856/" ]
74,156,456
<p>i'm trying to generate random number between 0 and 10, but loop is not stops when it came to 10</p> <pre class="lang-js prettyprint-override"><code>function testNumber () { let i = (Math.floor(Math.random() * 10)+1) while (i &lt; 10) { setInterval(() =&gt; { document.write(&quot;Random number: &quot; + (Math.floor(Math.random() * 10)+1) )},1000) return i; } } function test() { testNumber(); } </code></pre>
[ { "answer_id": 74156519, "author": "being addicted to coding", "author_id": 20302831, "author_profile": "https://Stackoverflow.com/users/20302831", "pm_score": -1, "selected": false, "text": "function testNumber () {\n let i=(Math.floor(Math.random() * 10)+1)\n const interval=\n ...
2022/10/21
[ "https://Stackoverflow.com/questions/74156456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20204288/" ]
74,156,473
<p>The following code is working but I'm using a string instead of a char array. It is a homework question I received and I'm struggling to implement a 2D char array with pointers. Help would be much appreciated!</p> <pre><code>#include &lt;iostream&gt; #include &lt;iomanip&gt; #include &lt;fstream&gt; using namespace std; int readFromFile(string* P); void displayData(string* P, int S); int main() { const int Size = 30; string arrFriends[Size]; string* pName = arrFriends; int count = readFromFile(pName); displayData(pName, count); return 0; } int readFromFile(string* P) { ifstream infile; infile.open(&quot;friends.txt&quot;); int count = 0; cout &lt;&lt; &quot;Reading from the file.&quot;; if(infile.fail()) { cout &lt;&lt; &quot;\nError opening file!&quot;; } else { while(!(infile.eof())) { getline(infile, *(P + count)); count++; } infile.close(); } cout &lt;&lt; &quot;\nDone!\n&quot;; return count; } void displayData(string* P, int S) { cout &lt;&lt; &quot;\nContent of the array:\n&quot;; for(int i = 0; i &lt; S; i++) { cout &lt;&lt; *(P + i) &lt;&lt; endl; } } </code></pre> <p>2.1 Declare a char array called arrFriends that will be able to hold 30 elements. Declare a pointer for the array.</p> <p>2.2 Write a method called readFromFile that will receive a pointer to the address of the first element of the array as a parameter. Read the names of a few friends from the text file called friends.txt into an array using the pointer. Return the number of elements saved in the array.</p> <p>2.3 Write a function called displayData that will receive the pointer of the first element of the array and the number of elements stored in the array as parameters. Display a heading and a list of names.</p> <p>2.4 In the main function, call the methods to read the name from the file and display the names from the array.</p> <p><a href="https://i.stack.imgur.com/CcRmL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CcRmL.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74163321, "author": "fabian", "author_id": 2991525, "author_profile": "https://Stackoverflow.com/users/2991525", "pm_score": 0, "selected": false, "text": "char friends[30][MaxNameLength + 1]" }, { "answer_id": 74170582, "author": "A M", "author_id": 966601...
2022/10/21
[ "https://Stackoverflow.com/questions/74156473", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19840363/" ]
74,156,487
<p>I have two methods method1 and method2. we can not call method2 alone and it should be in method1. how can i make sure method1 has return statement in this scenario.</p> <pre><code>def method1(list1, dict1): for i in list1: updated_list = i.replace(&quot;.&quot;,&quot;,&quot;) #some logic that will update the list not exactly this method2(updated_list, dict1)#here i want to have a return statement with updated_list but need to call method2 as per the logic. can i do return here? def method2(updated_list, dict1): if updated_list[0] == &quot;success&quot;: dict1[updated_list[0]] = updated_list return dict1 def main_usuage_of_two_methods(list1): dict1 = {} method1(list1, dict1) # i want to store in a variable by giving return in method1 like test = method1(list1, dict1) print(dict1) </code></pre>
[ { "answer_id": 74163321, "author": "fabian", "author_id": 2991525, "author_profile": "https://Stackoverflow.com/users/2991525", "pm_score": 0, "selected": false, "text": "char friends[30][MaxNameLength + 1]" }, { "answer_id": 74170582, "author": "A M", "author_id": 966601...
2022/10/21
[ "https://Stackoverflow.com/questions/74156487", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20226512/" ]
74,156,495
<p>I'm writing a script part of which is isolating part numbers from emails. I have this Regex which is helping isolate the part numbers:</p> <pre><code>\b(\S[A-Z0-9/-]{3,30})\b </code></pre> <p>It works perfectly, except it also gives back phone numbers. Many part numbers might look familiar to a phone number, so changing that Regex is not likely. What I want to do is write something similar to &quot;Matches \b(\S[A-Z0-9/-]{3,30})\b with the exception of \d\d\d-\d\d\d-\d\d\d\d&quot;, but I'm having trouble finding any Regex tokens which would give me that exception or do not match. Lookaheads are unlikely to work because there's nothing consistent I can give it to look for ahead or behind the phone number. Below is an example email I've been working with on <a href="https://regex101.com/" rel="nofollow noreferrer">Regex101</a> to test if it will work. Thank you in advance for any help or ideas.</p> <p>this is an email, the part numbers are AB-CDE-FGHIJK and 3577/GFGFGF. my phone number is 585-555-6533 but i don't want that! fix it.</p>
[ { "answer_id": 74163321, "author": "fabian", "author_id": 2991525, "author_profile": "https://Stackoverflow.com/users/2991525", "pm_score": 0, "selected": false, "text": "char friends[30][MaxNameLength + 1]" }, { "answer_id": 74170582, "author": "A M", "author_id": 966601...
2022/10/21
[ "https://Stackoverflow.com/questions/74156495", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20078910/" ]
74,156,496
<p>I have this situation in product page I check the url and condition in this case: <code>{$string = $product.url} {$char = $string|strstr:&quot;incisione-si&quot;} {if !$configuration.is_catalog &amp;&amp; $char}</code> this run very good, but how can i add a second condition? example: &quot;incisione_40-si&quot; or &quot;incisione_20-si&quot;</p> <p>thanks</p>
[ { "answer_id": 74163321, "author": "fabian", "author_id": 2991525, "author_profile": "https://Stackoverflow.com/users/2991525", "pm_score": 0, "selected": false, "text": "char friends[30][MaxNameLength + 1]" }, { "answer_id": 74170582, "author": "A M", "author_id": 966601...
2022/10/21
[ "https://Stackoverflow.com/questions/74156496", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20302795/" ]
74,156,498
<p>I'm trying to commit an update to GitHub through gitbash, but it doesn't seem to work. The pictures below show</p> <p>Changes done in the files, but gitbash says it's up to date:</p> <p><img src="https://i.stack.imgur.com/auYSJ.png" alt="1" /></p> <p>My repository:</p> <p><img src="https://i.stack.imgur.com/NgGKs.png" alt="2" /></p>
[ { "answer_id": 74163321, "author": "fabian", "author_id": 2991525, "author_profile": "https://Stackoverflow.com/users/2991525", "pm_score": 0, "selected": false, "text": "char friends[30][MaxNameLength + 1]" }, { "answer_id": 74170582, "author": "A M", "author_id": 966601...
2022/10/21
[ "https://Stackoverflow.com/questions/74156498", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19495225/" ]
74,156,550
<p>How is it possible that when I try to add a unique constraint named &quot;serveurs_domain&quot; it says I can't because the constraint already exists. <strong>BUT</strong>, when I try to drop the constraint &quot;serveurs_abbr&quot; it says it doesn't exist.</p> <p>I'm confused ???</p> <ul> <li>SQL :</li> </ul> <pre><code>ALTER TABLE serveurs DROP CONSTRAINT serveurs_domain; </code></pre> <blockquote> <p>ERROR: constraint « serveurs_domain » of relation « serveurs » does not exist</p> </blockquote> <pre><code>ALTER TABLE serveurs ADD CONSTRAINT serveurs_domain UNIQUE (domain); </code></pre> <blockquote> <p>ERROR: constraint « serveurs_domain » already exists</p> </blockquote> <ul> <li>PgSQL Version :</li> </ul> <pre><code>select version(); </code></pre> <blockquote> <p>PostgreSQL 13.8 (Debian 13.8-0+deb11u1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit</p> </blockquote> <p><a href="https://i.stack.imgur.com/56wxK.png" rel="nofollow noreferrer">Screenshot</a></p>
[ { "answer_id": 74163321, "author": "fabian", "author_id": 2991525, "author_profile": "https://Stackoverflow.com/users/2991525", "pm_score": 0, "selected": false, "text": "char friends[30][MaxNameLength + 1]" }, { "answer_id": 74170582, "author": "A M", "author_id": 966601...
2022/10/21
[ "https://Stackoverflow.com/questions/74156550", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20302779/" ]
74,156,553
<p>This is the code but it returns in unidentified . It should return two arrays where the first one is a set of odd numbers in the original array and the second is odd</p> <pre class="lang-js prettyprint-override"><code>function evenAndOdd(array) { let odd = []; let even = []; for (i = 0; i &lt; array.length; i++) { if (array[i] % 2 === 0) { even.push(array[i]); } else { odd.push(array[i]); } } return even,odd; } </code></pre>
[ { "answer_id": 74156608, "author": "Nikkkshit", "author_id": 11850259, "author_profile": "https://Stackoverflow.com/users/11850259", "pm_score": 0, "selected": false, "text": "function evenAndOdd(array) {\n let odd = [];\n let even = [];\n let length = array.length\n for (i = 0; i < ...
2022/10/21
[ "https://Stackoverflow.com/questions/74156553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19595163/" ]
74,156,576
<p>I have following code:</p> <pre><code>var d = 1.25M; var val = $&quot;{d:#,#.#;(#,#.#);0}&quot;; </code></pre> <p>I would like to vary the formatter e.g. for 2 decimal places: <code>#,#.##;(#,#.##);0</code> so that it can be passed as a method argument. How would I do that?</p>
[ { "answer_id": 74156608, "author": "Nikkkshit", "author_id": 11850259, "author_profile": "https://Stackoverflow.com/users/11850259", "pm_score": 0, "selected": false, "text": "function evenAndOdd(array) {\n let odd = [];\n let even = [];\n let length = array.length\n for (i = 0; i < ...
2022/10/21
[ "https://Stackoverflow.com/questions/74156576", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4603068/" ]
74,156,579
<p>I'am working to find a match in text file from a shell script and get the desired output</p> <p>the format of text file is like this :</p> <pre><code> var1 = X var2 = X var3 = X var4 = BDH </code></pre> <p>My shell script is like this for now</p> <pre><code> values=$(grep -hnr -A2 &quot;$another_value_to_match&quot; exemple.txt | cut -d &quot;=&quot; -f2) find_all_values=$(ls -d $DIR/[&quot;$values&quot;]* | xargs -n 1 basename) </code></pre> <p><strong>another_value_to_match</strong> is a variable i'am taking from another function and should contain (var1, var2, var3, var4). <strong>find_all_values</strong> is trying to look into a large folder for sub-folders that start with (X, or B or D or H).</p> <p>My problem is that if <strong>another_value_to_match</strong> == var4 everything is fine and works correctly because it's the last line in the text file but if <strong>another_value_to_match</strong> == var1 or any other value I get as output : <strong>X X X BDH</strong>.</p> <p>My question is : How to stop after finding match whether it's in the first line of text file or the last line ? to simplify stuff if</p> <pre><code> if (another_value_to_match == var2) values=$(grep -hnr -A2 &quot;$another_value_to_match&quot; exemple.txt | cut -d &quot;=&quot; -f2 | add_something_to_pipe) echo $values values == X </code></pre>
[ { "answer_id": 74160597, "author": "Eric Marceau", "author_id": 9716110, "author_profile": "https://Stackoverflow.com/users/9716110", "pm_score": 0, "selected": false, "text": "cut -d \"=\" -f2\n" }, { "answer_id": 74164097, "author": "Bach Lien", "author_id": 3973676, ...
2022/10/21
[ "https://Stackoverflow.com/questions/74156579", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11154545/" ]
74,156,624
<p>Suppose I have a array like this.</p> <pre><code>const info = [ { productId: &quot;1&quot;, name: &quot;This is product name 1&quot;, sellerId: &quot;12&quot;, price: 30, }, { productId: &quot;2&quot;, name: &quot;This is product name 2&quot;, sellerId: &quot;12&quot;, price: 50 }, { productId: &quot;3&quot;, name: &quot;This is product name 3&quot;, sellerId: &quot;13&quot;, price: 50 } ] </code></pre> <p>**This is dynamic array. Array value can be changed.</p> <p>Now I have to combine this array or filter this array. I have not any idea about how can I write function. But my result will be like this-</p> <pre><code>const result = [ { sellerId: &quot;12&quot;, productIds: [ //Combine products by similar sellerId { name: &quot;This is product name 1&quot;, productId: &quot;1&quot; }, { name: &quot;This is product name 2&quot;, productId: &quot;2&quot; } ], total: 80 //Total price of this two product }, { sellerId: &quot;13&quot;, productIds: [ { name: &quot;This is product name 3&quot;, productId: &quot;3&quot; } ], total: 50 } ] </code></pre> <p>Please do not close my question. I almost check all similar questions. But I have a different issue here. Just please help me.</p>
[ { "answer_id": 74156868, "author": "dave", "author_id": 2082673, "author_profile": "https://Stackoverflow.com/users/2082673", "pm_score": 3, "selected": true, "text": ".reduce" }, { "answer_id": 74157462, "author": "PeterKA", "author_id": 3558931, "author_profile": "h...
2022/10/21
[ "https://Stackoverflow.com/questions/74156624", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19314389/" ]
74,156,647
<p>I'm having trouble getting Pythons random.choice to work</p> <p>Here's the working code:</p> <pre><code>import random letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] symbols = ['!', '#', '$', '%', '&amp;', '(', ')', '*', '+'] print(&quot;Password Generator&quot;) user_amount_letters = int(input(&quot;How many letters would you like in your password?\n&quot;)) user_amount_symbols = int(input(&quot;How many symbols?\n&quot;)) user_amount_numbers = int(input(&quot;How many numbers\n&quot;)) characters = [] for i in range(user_amount_letters): characters.append(random.choice(letters)) for i in range(user_amount_numbers): characters.append(random.choice(numbers)) for i in range(user_amount_symbols): characters.append(random.choice(symbols)) random.shuffle(characters) password = &quot;&quot;.join(characters) print(password) </code></pre> <p>Here's the same code within a function:</p> <pre><code>. . . def randomise_user_password(letters, symbols, numbers): user_letters = letters user_symbols = symbols user_numbers = numbers characters = [] for i in range(user_letters): characters.append(random.choice(letters)) for i in range(user_numbers): characters.append(random.choice(numbers)) for i in range(user_symbols): characters.append(random.choice(symbols)) random.shuffle(characters) password = &quot;&quot;.join(characters) return password print(randomise_user_password(user_amount_letters, user_amount_symbols, user_amount_numbers)) </code></pre> <p>The problem seems to be with random.choice, heres the error for reference:</p> <pre><code>3.8.12/lib/python3.8/password_generator.py&quot;, line 288, in choice i = self._randbelow(len(seq)) TypeError: object of type 'int' has no len() </code></pre> <p>I understand what the error is telling me, but have no clue how to resolve it.</p>
[ { "answer_id": 74156707, "author": "xFranko", "author_id": 17620209, "author_profile": "https://Stackoverflow.com/users/17620209", "pm_score": 0, "selected": false, "text": "import random\n\nlettersList = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q...
2022/10/21
[ "https://Stackoverflow.com/questions/74156647", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16257037/" ]
74,156,649
<p>im having problem with multiple usage of splice() method.</p> <pre><code>string= &quot;test&quot; splitted = string.split(''); splitted.splice(1,0,&quot;ww&quot;); console.log(splitted); </code></pre> <p>so when i use like this output is <code>(5) ['t', 'ww', 'e', 's', 't']</code> so all good. but lets assume that i want to use this method multiple times with a different indexes and different string to insert. im looking for somethig like this;</p> <pre><code>string= &quot;test&quot; splitted = string.split(''); splitted.splice((1,0,&quot;ww&quot;),(2,0,&quot;ss&quot;),(3,0,&quot;dd&quot;)); console.log(splitted); </code></pre> <p>thanks for your help</p>
[ { "answer_id": 74156684, "author": "Nestoro", "author_id": 7941160, "author_profile": "https://Stackoverflow.com/users/7941160", "pm_score": 2, "selected": false, "text": "splitted" }, { "answer_id": 74156949, "author": "epascarello", "author_id": 14104, "author_profi...
2022/10/21
[ "https://Stackoverflow.com/questions/74156649", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5622259/" ]
74,156,662
<p>I'm working on a <code>paste0</code> code using <code>for loop</code> and a vector's name. I want to make a vector become like</p> <pre><code>[chr] 1 2 3 4 5 </code></pre> <p>But <code>paste0</code> is usually used with each of vector's values like this</p> <pre><code>paste0(&quot;1&quot;, &quot;2&quot;, &quot;3&quot;, &quot;4&quot;, &quot;5&quot;) </code></pre> <p>So I'm confused how I can make this with vector's only name <code>ds</code>. Below is what I tried but returned only <code>1</code></p> <pre><code>ds &lt;- c(&quot;1&quot;,&quot;2&quot;,&quot;3&quot;,&quot;4&quot;,&quot;5&quot;) for (i in 1:length(ds)) { ans &lt;- paste0(ds[i]) } ans </code></pre>
[ { "answer_id": 74156684, "author": "Nestoro", "author_id": 7941160, "author_profile": "https://Stackoverflow.com/users/7941160", "pm_score": 2, "selected": false, "text": "splitted" }, { "answer_id": 74156949, "author": "epascarello", "author_id": 14104, "author_profi...
2022/10/21
[ "https://Stackoverflow.com/questions/74156662", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20275071/" ]
74,156,677
<p>I have a <code>Card</code> div that is supposed to show the scroll if the content exceeds it's height. I've used <code>overflow-y: auto</code> to do that. I'm trying to use a <code>Select</code> inside it, and the select menu is supposed to show in front of the card. The menu position is <code>absolute</code>.</p> <p>The problem is, even with <code>position: absolute</code>, the menu is taking space inside the card. making it scrollable.</p> <p><a href="https://i.stack.imgur.com/tS76j.png" rel="noreferrer"><img src="https://i.stack.imgur.com/tS76j.png" alt="image" /></a></p> <p>If I remove the overflow from the card, it works fine, but the content exceeds it. I've created a sandbox for it:</p> <p><a href="https://codesandbox.io/s/position-absolute-inside-overflow-y-9kppcy?file=/src/App.js" rel="noreferrer">https://codesandbox.io/s/position-absolute-inside-overflow-y-9kppcy?file=/src/App.js</a></p> <h2>Other things I have tried</h2> <ul> <li><p>Show the <code>SelectMenu</code> inside a portal.</p> <ul> <li>Better results I got so far, but when the window is scrolled, the menu got fixed in the screen.</li> </ul> </li> <li><p>Remove the overflow from the card, add it to a <code>CardBody</code> element, and keep the select outside it.</p> <ul> <li>Did the magic, but with deep nested divs, is really hard to keep it outside every element with overflow.</li> <li>Did not work if the Select is inside a modal (because modals should have a scroll).</li> </ul> </li> </ul> <h2>More details</h2> <ul> <li>I'm using <a href="https://react-select.com/" rel="noreferrer">react-select</a> to create my select, but the problem is strictly css and html.</li> </ul> <p>This might be a common question, but I could not find a solution.</p>
[ { "answer_id": 74156684, "author": "Nestoro", "author_id": 7941160, "author_profile": "https://Stackoverflow.com/users/7941160", "pm_score": 2, "selected": false, "text": "splitted" }, { "answer_id": 74156949, "author": "epascarello", "author_id": 14104, "author_profi...
2022/10/21
[ "https://Stackoverflow.com/questions/74156677", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11800354/" ]