qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,421,905
<p>I am trying to create Post API, which has following Model as request</p> <pre><code>public partial class Employee { public Employee() { EmployeeDetails = new HashSet&lt;EmployeeDetail&gt;(); } public int Id { get; set; } public string? Name { get; set; } public string? Gender { get; set; } public int Age { get; set; } public virtual ICollection&lt;EmployeeDetail&gt; EmployeeDetails { get; set; } } public partial class EmployeeDetail { public int Id { get; set; } public int? EmployeeId { get; set; } public string? Details { get; set; } public virtual Employee Employee { get; set; } } </code></pre> <p>and I have and Post API which accept in parameter EmployeeDetail</p> <pre><code>public async Task&lt;IActionResult&gt; Post(EmployeeDetail empDetail){ } so for this getting error : Bad Request 400. </code></pre> <p>Code to insert empDetail,(Let assume Employee already exist in database so not binding any value with Employee object., and based on EmployeeId, inserting Employee detail in employeeDetail table.)</p> <pre><code>This is what swagger suggesting for body request. { &quot;id&quot;: 0, &quot;employeeId&quot;: 0, &quot;details&quot;: &quot;string&quot;, &quot;employee&quot;: { &quot;id&quot;: 0, &quot;name&quot;: &quot;string&quot;, &quot;gender&quot;: &quot;string&quot;, &quot;age&quot;: 0, &quot;employeeDetails&quot;: [ &quot;string&quot; ] } } //But I only want to pass { &quot;id&quot;: 0, &quot;employeeId&quot;: 0, &quot;details&quot;: &quot;string&quot; } </code></pre> <p><strong>Note : Requirement is to use only DbContext Model only.</strong> Any solution Thanks in Advance.</p>
[ { "answer_id": 74422177, "author": "Vivasvan Patel", "author_id": 8926214, "author_profile": "https://Stackoverflow.com/users/8926214", "pm_score": 1, "selected": false, "text": "// for each object in the option's api response.\nfor (let i = 0; i < dt.data.length; ++i) {\n\n // extrac...
2022/11/13
[ "https://Stackoverflow.com/questions/74421905", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17992860/" ]
74,421,940
<p>I'm learning <code>css</code> and want to code small calendar. I tried some templates and ended up with this:</p> <p>Somehow I can't <strong>change the width of days block</strong> to correspond with headers width and can only <strong>regulate weeks by percent</strong>. How can it be done properly?</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>ul {list-style-type: none;} .header { color: white; width: 320px; height: 40px; background: #1abc9c; text-align: center; } .header ul { margin: 0; padding: 0; } .header ul li { padding-top: 7px; color: white; font-size: 20px; letter-spacing: 3px; } /* Month header */ .month { width: 320px; height: 40px; background: black; text-align: center; } /* Month list */ .month ul { margin: 0; padding: 0; } .month ul li { padding-top: 7px; color: white; font-size: 20px; letter-spacing: 3px; } /* Previous button inside month header */ .month .prev { color: #1abc9c; float: left; padding-top: 5px; } /* Next button */ .month .next { color: #1abc9c; float: right; padding-top: 5px; } /* Days (1-31) */ .days { padding: 10px 10px; background: white; margin: 0; } .days li { margin: px; list-style-type: none; display: inline-block; width: 13.5%; text-align: left; margin-bottom: 5px; font-size: 12px; color: black; font-weight: bold; } /* Highlight the "current" day */ .days li .active { padding: 5px; background: #1abc9c; color: white !important } .days li .left { padding: 5px; color: gray !important }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;head&gt; &lt;meta charset="utf-8"&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt; &lt;link rel="stylesheet" type="text/css" href="styles.css"&gt; &lt;title&gt;Sample&lt;/title&gt; &lt;/head&gt; &lt;div class="header"&gt; &lt;ul&gt; &lt;li&gt;Archive&lt;span style="font-size:18px"&gt;&lt;/span&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;div class="month"&gt; &lt;ul&gt; &lt;li class="prev"&gt;&amp;#10094;&lt;/li&gt; &lt;li class="next"&gt;&amp;#10095;&lt;/li&gt; &lt;li&gt;December 2022&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;ul class="days"&gt; &lt;li&gt;1&lt;/li&gt; &lt;li&gt;2&lt;/li&gt; &lt;li&gt;3&lt;/li&gt; &lt;li&gt;&lt;span class="active"&gt;4&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span class="left"&gt;5&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span class="left"&gt;6&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span class="left"&gt;7&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span class="left"&gt;8&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span class="left"&gt;9&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span class="left"&gt;10&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span class="left"&gt;11&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span class="left"&gt;12&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span class="left"&gt;13&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span class="left"&gt;14&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span class="left"&gt;15&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span class="left"&gt;16&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span class="left"&gt;17&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span class="left"&gt;18&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span class="left"&gt;19&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span class="left"&gt;20&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span class="left"&gt;21&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span class="left"&gt;22&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span class="left"&gt;23&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span class="left"&gt;24&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span class="left"&gt;25&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span class="left"&gt;26&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span class="left"&gt;27&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span class="left"&gt;28&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span class="left"&gt;29&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span class="left"&gt;30&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span class="left"&gt;31&lt;/span&gt;&lt;/li&gt; &lt;/ul&gt;</code></pre> </div> </div> </p> <p>Desired template like this: <a href="https://i.stack.imgur.com/VudoI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VudoI.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74422247, "author": "Matias Bertoni", "author_id": 19272564, "author_profile": "https://Stackoverflow.com/users/19272564", "pm_score": 0, "selected": false, "text": "/*add*/\n.wrap {\n width: 320px;\n}\n\n/*changes */\nul {\n list-style-type: none;\n display: grid;\n g...
2022/11/13
[ "https://Stackoverflow.com/questions/74421940", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9137206/" ]
74,421,961
<p>My goal is to minimize the code using the Angular translate pipe. Currently, I have to use 8 curly brackets and write &quot;translate&quot; twice... a better way must exist.</p> <p>My current code looks like:</p> <pre><code>&lt;span *ngIf=&quot;checkoutForm.get('email')?.errors?.['email']&quot;&gt; {{ 'eMail' | translate }} {{ lowerCaseFirstLetter('isInvalid' | translate) }} &lt;/span&gt; </code></pre> <p>And I'm trying to do shorten it in something like</p> <pre><code>&lt;span *ngIf=&quot;checkoutForm.get('email')?.errors?.['email']&quot; translate&gt;eMail {{ lowerCaseFirstLetter('isInvalid' | translate) }} &lt;/span&gt; </code></pre> <p>or maybe even</p> <pre><code>&lt;span *ngIf=&quot;checkoutForm.get('email')?.errors?.['email']&quot; translate&gt;eMail lowerCaseFirstLetter('isInvalid') &lt;/span&gt; </code></pre> <h4>The Text</h4> <p>email <em>is a translation</em> = E-Mail<br /> isInvalid <em>is a translation</em> = Is invalid<br /> lowerCaseFirstLetter() <em>is a function which just lowercases first letter</em> this is important to not destroy the orthography in other languages</p>
[ { "answer_id": 74422153, "author": "Dennis", "author_id": 11646662, "author_profile": "https://Stackoverflow.com/users/11646662", "pm_score": 2, "selected": true, "text": "<span\n *ngIf=\"checkoutForm.get('email')?.errors?.['email']\"> \n {{ 'eMail' | error:'isInvalid' }}\n</span>\...
2022/11/13
[ "https://Stackoverflow.com/questions/74421961", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15791792/" ]
74,422,009
<p>How can I write a function that takes a two-dimensional sequence as an argument and returns which team earned the most wins? when multiple teams earn the same amount of wins, it should return the first team's serial number.</p> <p>It should return something like this:</p> <pre><code>who_won([['W', 'W', 'W'], ['L', 'L', 'L'], ['W', 'W', 'L'], ['L', 'L', 'W']]) 1 </code></pre> <p>ㅤ</p> <pre><code>who_won([['L', 'W', 'L'], ['W', 'W', 'L'], ['L', 'W', 'W'], ['L', 'W', 'L']]) 2 </code></pre> <p>Here's what I have right now:</p> <pre><code>def who_won(matrix): w_counter = 0 for x in matrix: for y in x: if 'W' in x: W_counter += 1 </code></pre>
[ { "answer_id": 74422153, "author": "Dennis", "author_id": 11646662, "author_profile": "https://Stackoverflow.com/users/11646662", "pm_score": 2, "selected": true, "text": "<span\n *ngIf=\"checkoutForm.get('email')?.errors?.['email']\"> \n {{ 'eMail' | error:'isInvalid' }}\n</span>\...
2022/11/13
[ "https://Stackoverflow.com/questions/74422009", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20425228/" ]
74,422,028
<p>I'm using Cypress for my tests:</p> <p><a href="https://i.stack.imgur.com/zUL4B.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zUL4B.png" alt="enter image description here" /></a></p> <p>This is my display. On this display I have 3 classes which have the same name. And in this class all the ben logo have the same class name too.</p> <p>How can I click on the &quot;Menu Test Ben&quot;? I tried this, but it doesn't work and give me an error:</p> <pre><code>cy.get('*[class^=&quot;sc-brCFrO hCaSdu&quot;]').eq(1).get('*[class^=&quot;MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeMedium css-78trlr-MuiButtonBase-root-MuiIconButton-root&quot;]').eq(-1).click() </code></pre> <p>The error is</p> <blockquote> <p>Timed out retrying after 4000ms: Expected to find element: *[class^=&quot;sc-fctJkW gvSlDc&quot;], but never found it.</p> </blockquote> <p>o am</p> <p>Classname.eq(1) to get the &quot;Menu&quot; then Classname.eq(-1) to get the last ben.</p> <p>There is the html code: <a href="https://i.stack.imgur.com/8cHmJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8cHmJ.png" alt="enter image description here" /></a></p> <pre><code> &lt;StyledDoubleDataContainer&gt; &lt;StyledDataContainer&gt; &lt;StyledRowContainer&gt; &lt;StyledRowTitleContainer&gt; &lt;StyledDataTitleIcon src={MealIcon} /&gt; &lt;StyledDataContainerTitle&gt;Menu de la semaine&lt;/StyledDataContainerTitle&gt; &lt;/StyledRowTitleContainer&gt; {!readOnly &amp;&amp; &lt;AddButton onClick={handleOpenMeal} /&gt;} &lt;/StyledRowContainer&gt; {meals.length &gt; 0 ? ( meals.map((element, index) =&gt; ( &lt;StyledValueRow key={index}&gt; &lt;StyledName&gt;{element.name}&lt;/StyledName&gt; {!readOnly &amp;&amp; ( &lt;StyledDeleteContainer&gt; &lt;Delete onClick={() =&gt; deleteThisMeal(element._id)} /&gt; &lt;/StyledDeleteContainer&gt; )} &lt;/StyledValueRow&gt; )) ) : ( &lt;NoDataClassic label=&quot;Aucun repas à afficher&quot; /&gt; )} &lt;/StyledDataContainer&gt; &lt;StyledDataContainer&gt; &lt;StyledRowContainer&gt; &lt;StyledRowTitleContainer&gt; &lt;StyledDataTitleIcon src={ActivityIcon} /&gt; &lt;StyledDataContainerTitle&gt;Activités de la semaine&lt;/StyledDataContainerTitle&gt; &lt;/StyledRowTitleContainer&gt; {!readOnly &amp;&amp; &lt;AddButton onClick={handleOpenActivity} /&gt;} &lt;/StyledRowContainer&gt; {activities.length &gt; 0 ? ( activities.map((element, index) =&gt; ( &lt;StyledValueRow key={index}&gt; &lt;StyledName&gt;{element.name}&lt;/StyledName&gt; {!readOnly &amp;&amp; ( &lt;StyledDeleteContainer&gt; &lt;Delete onClick={() =&gt; deleteThisActivity(element._id)} /&gt; &lt;/StyledDeleteContainer&gt; )} &lt;/StyledValueRow&gt; )) ) : ( &lt;NoDataClassic label=&quot;Aucune activité à afficher&quot; /&gt; )} &lt;/StyledDataContainer&gt; &lt;/StyledDoubleDataContainer&gt; &lt;/&gt; )} </code></pre> <p>I am a beginner with Cypress.</p>
[ { "answer_id": 74423852, "author": "PeaceAndQuiet", "author_id": 9947826, "author_profile": "https://Stackoverflow.com/users/9947826", "pm_score": 0, "selected": false, "text": "cy.contains()" }, { "answer_id": 74424052, "author": "Marcell Malbolge", "author_id": 19373867...
2022/11/13
[ "https://Stackoverflow.com/questions/74422028", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13934941/" ]
74,422,052
<p>Here I have attached an API response parsing model. Which I need do more refactoring by dividing the category , country and apikey. I have created a variable as apikey and assigned near to the apikey string. but the error shown as:</p> <p><em><strong>code</strong></em></p> <pre><code>class ApiServiceBusiness { final category1 = &quot;&quot;; final apiKey = &quot;df892d97b60e454db3f5ba14f4a4b12d&quot;; dynamic endPointUrla = Uri.parse(&quot;https://newsapi.org/v2/top-headlines?country=gb&amp;category=business&amp;apiKey=$apiKey&quot;); Future&lt;List&lt;Article&gt;&gt; getArticle() async { Response res1 = await get(endPointUrla); if (res1.statusCode == 200) { Map&lt;String, dynamic&gt; json = jsonDecode(res1.body); List&lt;dynamic&gt; body = json['articles']; List&lt;Article&gt; articlesBusiness = body.map((dynamic item) =&gt; Article.fromJson(item)).toList(); return articlesBusiness; } else { throw (&quot;Can't get the articles&quot;); } } } </code></pre> <p><em><strong>error</strong></em>: <strong>The instance member 'apiKey' can't be accessed in an initializer.</strong></p> <blockquote> <p>how to refactor the apikey, category and courtry each by each string. Thank You.</p> </blockquote>
[ { "answer_id": 74423852, "author": "PeaceAndQuiet", "author_id": 9947826, "author_profile": "https://Stackoverflow.com/users/9947826", "pm_score": 0, "selected": false, "text": "cy.contains()" }, { "answer_id": 74424052, "author": "Marcell Malbolge", "author_id": 19373867...
2022/11/13
[ "https://Stackoverflow.com/questions/74422052", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14402934/" ]
74,422,065
<p>None of the following filters worked when I tried to update a document, in JS/Node.js filtered by &quot;_id&quot;, where the value is the generic ObjectId (<code>ObjectId('6365050650c6be6d5d090135')</code>) :</p> <pre><code>{_id : ObjectId(123....7890)} {_id : ObjectId('123....7890')} {_id : &quot;ObjectId('123....7890')&quot;} + other variantions I came across </code></pre> <p>Nothing worked for me. I got <code>ReferenceError: ObjectId is not defined</code> or no errors.</p>
[ { "answer_id": 74423852, "author": "PeaceAndQuiet", "author_id": 9947826, "author_profile": "https://Stackoverflow.com/users/9947826", "pm_score": 0, "selected": false, "text": "cy.contains()" }, { "answer_id": 74424052, "author": "Marcell Malbolge", "author_id": 19373867...
2022/11/13
[ "https://Stackoverflow.com/questions/74422065", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6280857/" ]
74,422,074
<p>My task in VB.NET is as follows: Sum a number until it becomes a whole number and count how many times it was summed</p> <p>Sorry, I know that is not that hard but I am new to coding</p> <p>example: I have this number 4.25</p> <p>sum until he gets a whole number: 4.25 + 4.25 + 4.25 + 4.25 = 17 and count how many times he was sumed: 4 times</p> <p>How to do that in VB.NET ?</p>
[ { "answer_id": 74422394, "author": "Lajos Arpad", "author_id": 436560, "author_profile": "https://Stackoverflow.com/users/436560", "pm_score": 1, "selected": false, "text": "sum" }, { "answer_id": 74423007, "author": "Andrew Morton", "author_id": 1115360, "author_prof...
2022/11/13
[ "https://Stackoverflow.com/questions/74422074", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20493390/" ]
74,422,079
<p>hello everyone I just want to know here suppose we have three tables student table, course table, and teacher table something like this 'student' table</p> <pre><code>std_id std_name course_id teacher_id 1 Ramesh 1 1 2 Ganesh 1 3 3 Aadesh 3 3 4 Nilesh 3 1 5 Sonam 3 4 6 Abhi 2 4 7 Anil 2 4 </code></pre> <p>'course' table</p> <pre><code>course_id course_name std_id teacher_id 1 JAVA 1 1 2 JAVASCRIPT 1 2 3 VB.NET 1 1 4 C#.NET 5 2 5 PYTHON 5 4 6 SAP 6 4 7 C++ 6 1 </code></pre> <p>'teacher' table</p> <pre><code>teacher_id teacher_name course_id std_id 1 Roy 1 1 2 Amit 2 1 3 John 1 5 4 Yogesh 3 5 5 Rocky 3 1 </code></pre> <p>so here i have given three tables so now i want to show students who have the courses and teachers so here you can see in the 'student' table we have std_id and course_id and in the 'course' table we have course_id and std_id so as you can see here in the student table we have std_id and course_id and in the course table we have course_id and std_id as well so here which column should be used to join student table with the course table because both tables have std_id and course_id and if i want to show students who has courses so which column should be used here to join the student table and the course table and here i also want to show teachers so here in the teacher table we have teacher_id and course_id and std_id so here of which table column should be used here to join with teacher table because student table also has the teacher_id and course table also has the teacher_id so here of which table teacher_id should be used here to join with teacher please let me know guys how can i know which column should be used here to join?</p>
[ { "answer_id": 74422394, "author": "Lajos Arpad", "author_id": 436560, "author_profile": "https://Stackoverflow.com/users/436560", "pm_score": 1, "selected": false, "text": "sum" }, { "answer_id": 74423007, "author": "Andrew Morton", "author_id": 1115360, "author_prof...
2022/11/13
[ "https://Stackoverflow.com/questions/74422079", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20491801/" ]
74,422,080
<p>Tried this but it shows <code>DECADE</code> column and every row is <code>NULL</code>.</p> <pre class="lang-sql prettyprint-override"><code>SELECT ReleaseDate, COUNT (Title), CASE WHEN ReleaseDate BETWEEN 2010 AND 2019 THEN '2010 - 2019' WHEN ReleaseDate BETWEEN 2000 AND 2009 THEN '2000 - 2009' WHEN ReleaseDate BETWEEN 1990 AND 1999 THEN '1990 - 1999' WHEN ReleaseDate BETWEEN 1980 AND 1989 THEN '1980 - 1989' WHEN ReleaseDate BETWEEN 1970 AND 1979 THEN '1970 - 1979' WHEN ReleaseDate BETWEEN 1960 AND 1969 THEN '1960 - 1969' END AS DECADE FROM Film GROUP BY ReleaseDate </code></pre>
[ { "answer_id": 74422202, "author": "Destroyer", "author_id": 15073036, "author_profile": "https://Stackoverflow.com/users/15073036", "pm_score": -1, "selected": false, "text": "CASE \n WHEN YEAR(ReleaseDate) BETWEEN 2010 AND 2019 THEN '2010 - 2019' \n ...\n ...\nEND\n" }, { ...
2022/11/13
[ "https://Stackoverflow.com/questions/74422080", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18965196/" ]
74,422,087
<p>Let's say we have these 2 functions</p> <pre><code>f1 :: Int -&gt; [Int] -&gt; Int -&gt; [Int] f1 _ [] _ = [] f1 x (h:t) y = (x * h + y):(f1 x t y) f2 :: [Int] -&gt; Int f2 (h:t) = h </code></pre> <p>Why does <code>(f2 . f1 1 [1..10]) 1</code> work, but <code>(f2 . f1 1) [1..10] 1</code> doesn't work?</p>
[ { "answer_id": 74422577, "author": "chepner", "author_id": 1126841, "author_profile": "https://Stackoverflow.com/users/1126841", "pm_score": 4, "selected": true, "text": "f1" }, { "answer_id": 74440203, "author": "Ben", "author_id": 450128, "author_profile": "https://...
2022/11/13
[ "https://Stackoverflow.com/questions/74422087", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17360903/" ]
74,422,090
<p>I am setting up an Azure pipeline and need to get a specific step to run multiple times based on the defined environments. I also need to replace a placeholder in a file with variable values and I need to have different value for each environment. What is the most straight forward way to achieve that?</p>
[ { "answer_id": 74422577, "author": "chepner", "author_id": 1126841, "author_profile": "https://Stackoverflow.com/users/1126841", "pm_score": 4, "selected": true, "text": "f1" }, { "answer_id": 74440203, "author": "Ben", "author_id": 450128, "author_profile": "https://...
2022/11/13
[ "https://Stackoverflow.com/questions/74422090", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9683478/" ]
74,422,092
<p>If I have</p> <pre><code>map&lt;int, map&lt;int, int&gt;&gt; m; </code></pre> <p>And when I need to insert, I could use</p> <pre><code>m[1] = { {1, 1} }; </code></pre> <p>But now I want to use emplace/insert_or_assign to replace it, I may use</p> <pre><code>m.emplace(1, map&lt;int, int&gt;{ {1, 1} }); </code></pre> <p>But I think it is a bit complex to write, expecially I should write <code>map&lt;int, int&gt;</code>again, even more if the original map change into such as <code>map&lt;int, map&lt;int, map&lt;int, map&lt;int, int&gt;&gt;&gt;&gt;</code>, then I should repeat <code>map&lt;int, int&gt;</code> as much as it need. So is there any more simple and readable method?</p>
[ { "answer_id": 74422743, "author": "azhen7", "author_id": 20341797, "author_profile": "https://Stackoverflow.com/users/20341797", "pm_score": 0, "selected": false, "text": "typedef map<int, int> mp;\n" }, { "answer_id": 74422963, "author": "Ranoiaetep", "author_id": 12861...
2022/11/13
[ "https://Stackoverflow.com/questions/74422092", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16748945/" ]
74,422,106
<p>I have an application in which I am getting Shopify orders via Shopify webhooks. Now I have an issue is when I have only one client I mapped Shopify to receive an order via the traditional way with object properties and save it into the database.</p> <p>Now I got two more clients and all clients want to map class fields according to them.</p> <p>Let's suppose I got a Shopify order object with the following details:</p> <pre><code>{ &quot;id&quot;: 4655316533326, &quot;checkout_id&quot;: 29212941516878, &quot;user_id&quot;: 71894499406, &quot;note&quot;: &quot;hello world&quot;, &quot;subtotal_price_set&quot;: { &quot;shop_money&quot;: { &quot;amount&quot;: &quot;109.00&quot;, &quot;currency_code&quot;: &quot;USD&quot; } &quot;total_tax&quot;: &quot;0.00&quot;, &quot;total_tax_set&quot;: { &quot;shop_money&quot;: { &quot;amount&quot;: &quot;0.00&quot;, &quot;currency_code&quot;: &quot;USD&quot; }, &quot;presentment_money&quot;: { &quot;amount&quot;: &quot;0.00&quot;, &quot;currency_code&quot;: &quot;USD&quot; } } } </code></pre> <p>I have a class name Order as well in my application which contains some of the following properties:</p> <pre><code>public class Order { public string OrderNo { get; set; } public string DebtorID { get; set; } public virtual string DeliveryAddress1 { get; set; } public virtual string DeliveryAddress2 { get; set; } public virtual string RIRTNo { get; set; } public List&lt;OrderLine&gt; Lines { get; set; } public string OrderNote { get; set; } Public Customer Customer { get; set; } } </code></pre> <p>Now some customers want me to map shopify order <code>Note</code> property with mine <code>Order.Customer.Note</code></p> <p>and one want to map that <code>Note</code> proerty with <code>Order.Note</code></p> <p>same with <code>OrderNo</code>. One wants to map it directly with Order.OrderNo and others want to map it with ``RIRTNo```</p> <p>How to handle this kind of situation?</p> <p>I created one table on the database to keep this mapping information.</p> <p>I can get the customer detail from the Shopify order and then I make the DB query to get map information but the problem is in the database the detail is in dictionary like structure.</p> <p>Consider this below mapping info for x Customer: the key is a Shopify object property</p> <pre><code>&quot;Order&quot;: { &quot;note&quot;: &quot;Customer.Note&quot; &quot;Id&quot;: &quot;OrderId&quot; } </code></pre> <p>the <code>key</code> is the Shopify property name and the <code>value</code> is my application object name but I can't figure out how to make them based on this info.</p>
[ { "answer_id": 74422546, "author": "Mohm Zanaty", "author_id": 1609232, "author_profile": "https://Stackoverflow.com/users/1609232", "pm_score": 0, "selected": false, "text": "if (Customer.CustomerGroupId == 1)\n{\n // do mapping like Order.Note = shopify.Note\n}\nelse if (Customer.Custo...
2022/11/13
[ "https://Stackoverflow.com/questions/74422106", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18195314/" ]
74,422,127
<p>What is the best approach to display an array in a the cell of vaadin grid?</p> <p>I model a list of values like this in springboot.</p> <pre><code>private List&lt;String&gt; responsibilities; </code></pre> <p>If responsibilities contains [&quot;Cut grass&quot;, &quot;Wash dishes&quot;, &quot;Clean floor&quot;] I would like to render this as a bullet list in the cell:</p> <ul> <li>Cut grass</li> <li>Wash dishes</li> <li>Clean floor</li> </ul> <p>Sorry my typescripts skills a poor.</p> <p>Checked docs and examples and had a try with cell rendering but was not very obvious how to setup the array display.</p> <p>This attempt gives exception <strong>ERROR: Invalid binding pattern</strong>!</p> <pre><code>import '@vaadin/grid'; import { columnBodyRenderer } from '@vaadin/grid/lit.js'; import type { GridColumnBodyLitRenderer } from '@vaadin/grid/lit.js'; import { html } from 'lit'; import { Binder, field } from '@hilla/form'; import { customElement, state } from 'lit/decorators.js'; import { View } from '../../views/view'; import Career from 'Frontend/generated/com/example/application/models/Career'; import CareerModel from 'Frontend/generated/com/example/application/models/CareerModel'; import { getCareers } from 'Frontend/generated/CareerEndpoint'; @customElement('career-view') export class CareerView extends View { @state() private careers: Career[] = []; private binder = new Binder(this, CareerModel); async firstUpdated() { this.careers = await getCareers(); } render() { return html` &lt;div&gt; &lt;vaadin-grid theme=&quot;wrap-cell-content&quot; .items=${this.careers}&gt; &lt;vaadin-grid-column path=&quot;title&quot;&gt; &lt;/vaadin-grid-column&gt; &lt;vaadin-grid-column path=&quot;aliases&quot;&gt; &lt;/vaadin-grid-column&gt; &lt;vaadin-grid-column path=&quot;description&quot;&gt; &lt;/vaadin-grid-column&gt; &lt;vaadin-grid-column header=&quot;Responsibility&quot; ${columnBodyRenderer(this.responsibilityRenderer, [])} &gt;&lt;/vaadin-grid-column&gt; &lt;vaadin-grid-column path=&quot;experience&quot;&gt; &lt;/vaadin-grid-column&gt; &lt;/vaadin-grid&gt; &lt;/div&gt; `; } responsibilityRenderer: GridColumnBodyLitRenderer&lt;Career&gt; = (this.careers) =&gt; { return html` &lt;ul&gt; ${careers.responsibilities.map(r =&gt; html` &lt;li&gt;${r}&lt;/li&gt; `)} &lt;/ul&gt; `; }; } </code></pre>
[ { "answer_id": 74425969, "author": "Marcus Hellberg", "author_id": 5705554, "author_profile": "https://Stackoverflow.com/users/5705554", "pm_score": 1, "selected": false, "text": "responsibilityRenderer: GridColumnBodyLitRenderer<Person> = (person) => {\n return html`\n <ul>\n ...
2022/11/13
[ "https://Stackoverflow.com/questions/74422127", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20479500/" ]
74,422,135
<p>I don't understand how does my component Word will rerender. I have a redux state keeping my {history: {letters}} state. So the question is: If {<strong>letters</strong>} are passed into useEffect deps array, will my component Word rerender if {<strong>words</strong>} property is changed?</p> <p>`</p> <pre><code>function Word() { const { history: {letters, words} } = useAppSelector(state =&gt; state) useEffect(() =&gt; { }, [letters]) return ( &lt;div&gt; &lt;/div&gt; ) } </code></pre> <p>`</p> <p>I expect my component rerender only if letters are changed.</p>
[ { "answer_id": 74422412, "author": "Sennen Randika", "author_id": 11489268, "author_profile": "https://Stackoverflow.com/users/11489268", "pm_score": 1, "selected": false, "text": "Word" }, { "answer_id": 74424358, "author": "Yilmaz", "author_id": 10262805, "author_pr...
2022/11/13
[ "https://Stackoverflow.com/questions/74422135", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18050815/" ]
74,422,157
<pre><code> @if (items != null) { &lt;select required class=&quot;col-sm-10&quot; bind=&quot;searchByLocation&quot; @onchange=&quot;LocationOnChange&quot;&gt; &lt;option value=&quot;&quot; disabled selected hidden&gt;Search By Location&lt;/option&gt; @foreach (var r in items) { &lt;option value=&quot;@r.location&quot;&gt;@r.location&lt;/option&gt; } &lt;/select&gt; } </code></pre> <p>Below is my class and working code that displays location in the dropdown (but not unique values).</p> <pre><code>public class DisplayItem { public string itemKey { get; set; } public string id { get; set; } public string location{ get; set; } } List&lt;DisplayItem&gt; items = new (); private DisplayItem[] locationDropDown ; protected override async Task OnInitializedAsync() { items = (await ItemService.GetItems()) .GroupBy(x =&gt; x.ItemKey) .Select(x =&gt; new DisplayItem { ItemKey = x.Key, Id = x.FirstOrDefault(y =&gt; y.Key == &quot;Id&quot;)?.Value, Location = x.FirstOrDefault(y =&gt; y.Key == &quot;Location&quot;)?.Value, }) .ToList(); // locationDropDown = items.Select(x =&gt; x.location).Distinct().ToArray(); } </code></pre> <p>Below helps filter records by choosing a location from dropdown. But same country is displayed many times. I want to display only unique values in dropdown. Thank you.</p> <pre><code>private DisplayItem[] result; string searchByLocation; private async Task LocationOnChange(ChangeEventArgs args) { searchByLocation = (string)args.Value; await LocationChanged(); } private async Task LocationChanged() { result= items.Where(part =&gt; part.location == searchByLocation).ToArray(); } </code></pre>
[ { "answer_id": 74422283, "author": "Olivier Jacot-Descombes", "author_id": 880990, "author_profile": "https://Stackoverflow.com/users/880990", "pm_score": 3, "selected": true, "text": "@foreach (var l in items.Select(x => x.location).Distinct())\n{\n <option value=\"@r.location\">@l</...
2022/11/13
[ "https://Stackoverflow.com/questions/74422157", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16732381/" ]
74,422,180
<p>I have all the GitHub repositories that I work on in a local folder in my computer in this way:</p> <pre><code>all_repos/ ├── repo_1 ├── repo_2 ├── repo_3 ├── ... ├── repo_n </code></pre> <p>How can I keep them all updated with the version on GitHub automatically?</p>
[ { "answer_id": 74422201, "author": "Caridorc", "author_id": 3105485, "author_profile": "https://Stackoverflow.com/users/3105485", "pm_score": -1, "selected": false, "text": "pull_all.py" }, { "answer_id": 74426215, "author": "joanis", "author_id": 3216427, "author_pro...
2022/11/13
[ "https://Stackoverflow.com/questions/74422180", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3105485/" ]
74,422,195
<p>I am new to pandas and I need help. I have a set of data as given:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Index</th> <th>sensor</th> <th>timestamp</th> </tr> </thead> <tbody> <tr> <td>0</td> <td>temperature</td> <td>10/09/2019 10:49:00</td> </tr> <tr> <td>1</td> <td>humidity</td> <td>10/09/2019 10:50:00</td> </tr> <tr> <td>2</td> <td>light</td> <td>10/09/2019 10:50:00</td> </tr> <tr> <td>3</td> <td>motion</td> <td>10/09/2019 10:50:00</td> </tr> <tr> <td>4</td> <td>temperature</td> <td>10/09/2019 11:19:00</td> </tr> <tr> <td>5</td> <td>humidity</td> <td>10/09/2019 11:20:00</td> </tr> <tr> <td>6</td> <td>light</td> <td>10/09/2019 11:20:00</td> </tr> <tr> <td>7</td> <td>motion</td> <td>10/09/2019 11:20:00</td> </tr> <tr> <td>8</td> <td>temperature</td> <td>10/09/2019 11:34:00</td> </tr> </tbody> </table> </div> <p>Given data is not quite systematic for me, thus I want to add a new column named <code>temperature</code> and store its corresponding <code>timestamp</code> values.</p> <p>I want to make a new column named <code>Temperature</code> and store it's corresponding timestamp value. The expected dataframe would be like the figure:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>index</th> <th>sensor</th> <th>timestamp</th> <th>temperature</th> </tr> </thead> <tbody> <tr> <td>0</td> <td>temperature</td> <td>10/09/2019 10:49:00</td> <td>10/09/2019 10:49:00</td> </tr> <tr> <td>1</td> <td>humidity</td> <td>10/09/2019 10:50:00</td> <td>not related</td> </tr> <tr> <td>2</td> <td>light</td> <td>10/09/2019 10:50:00</td> <td>not related</td> </tr> <tr> <td>3</td> <td>motion</td> <td>10/09/2019 10:50:00</td> <td>not related</td> </tr> <tr> <td>4</td> <td>temperature</td> <td>10/09/2019 11:19:00</td> <td>10/09/2019 11:19:00</td> </tr> <tr> <td>5</td> <td>humidity</td> <td>10/09/2019 11:20:00</td> <td>not related</td> </tr> <tr> <td>6</td> <td>light</td> <td>10/09/2019 11:20:00</td> <td>not related</td> </tr> <tr> <td>7</td> <td>motion</td> <td>10/09/2019 11:20:00</td> <td>not related</td> </tr> <tr> <td>8</td> <td>temperature</td> <td>10/09/2019 11:34:00</td> <td>10/09/2019 11:34:00</td> </tr> </tbody> </table> </div> <p>The idea that I've come out with is that I inspect each row in the <code>sensor</code> column to either contain <code>temperature</code> or not. I've created an empty list so that I could append the value and add it to the original dataframe later on.</p> <pre><code>List = [] </code></pre> <p>If <code>sensor = 'temperature'</code> then the timestamp value will be stored in the new column and 'not_related' is given when <code>sensor != 'temperature'</code>. I tried to convert the idea into codes and this is where I am stuck.</p> <pre><code>for row in df['sensor']: if row == 'temperature' : List.append(df.loc[df[df['sensor']=='temperature'].index.values , 'timestamp']) else : List.append('Not related') </code></pre> <p>The problem with the code is that it stored <strong>all</strong> of the timestamp value that is equal to <code>temperature</code> and not its corresponding single value.</p> <p>Example of what I get when I run these codes:</p> <pre><code>List[4] </code></pre> <pre><code>0 2019-10-09 10:49:00 4 2019-10-09 11:19:00 8 2019-10-09 11:34:00 12 2019-10-09 11:49:00 16 2019-10-09 12:04:00 ... 86703 2021-03-22 13:29:00 86898 2021-03-25 14:36:00 86903 2021-03-25 14:51:00 86944 2021-03-28 16:52:00 87325 2021-07-19 10:03:00 Name: timestamp, Length: 8236, dtype: datetime64[ns] </code></pre> <pre><code>List[1] </code></pre> <p><code>'Not related'</code></p> <pre><code>List[0:5] </code></pre> <pre><code>[0 2019-10-09 10:49:00 4 2019-10-09 11:19:00 8 2019-10-09 11:34:00 12 2019-10-09 11:49:00 16 2019-10-09 12:04:00 ... 86703 2021-03-22 13:29:00 86898 2021-03-25 14:36:00 86903 2021-03-25 14:51:00 86944 2021-03-28 16:52:00 87325 2021-07-19 10:03:00 Name: timestamp, Length: 8236, dtype: datetime64[ns], 'Not related', 'Not related', 'Not related', 0 2019-10-09 10:49:00 4 2019-10-09 11:19:00 8 2019-10-09 11:34:00 12 2019-10-09 11:49:00 16 2019-10-09 12:04:00 ... 86703 2021-03-22 13:29:00 86898 2021-03-25 14:36:00 86903 2021-03-25 14:51:00 86944 2021-03-28 16:52:00 87325 2021-07-19 10:03:00 Name: timestamp, Length: 8236, dtype: datetime64[ns]] </code></pre> <p>The reason for such idea is to ease my calculation between column later on. Any insight or other methods would be much appreciated.</p>
[ { "answer_id": 74422201, "author": "Caridorc", "author_id": 3105485, "author_profile": "https://Stackoverflow.com/users/3105485", "pm_score": -1, "selected": false, "text": "pull_all.py" }, { "answer_id": 74426215, "author": "joanis", "author_id": 3216427, "author_pro...
2022/11/13
[ "https://Stackoverflow.com/questions/74422195", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19430917/" ]
74,422,203
<p>I have these 2 unknown equations problem(technically 4, two pairs)</p> <p><a href="https://i.stack.imgur.com/jnqrH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jnqrH.png" alt="first pair of equations" /></a> <a href="https://i.stack.imgur.com/CPCEF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CPCEF.png" alt="second pair of equations" /></a></p> <p>The results should be these or close to them:</p> <p>wI = 0.107 ∈ (a1, a2) , y= 0.176.</p> <p>wII = 0.123 ∈ (b1, b2) , x= 0.877.</p> <p>I wrote for each of them 2 types of solver, the first one is the case where the equations are equal to zero and the second when they are equal to ww1/ww2. In every case the program raise</p> <pre class="lang-none prettyprint-override"><code>NotImplementedError('could not solve %s' % eq2) </code></pre> <p>and</p> <pre class="lang-none prettyprint-override"><code>NotImplementedError: could not solve: -5*2**(4/5)*2**(24/25)*5**(19/25)*ww2 + 5*80000000000000000000**(1/25)*(1 - 2*ww2)**(22/25)*(-(40*10**(19/25)*ww2 - 9*(100*ww2 - 7)**(22/25))/(20*5**(19/25)*(1 - 4*ww2)**(22/25) - 9*(100*ww2 - 7)**(22/25)) + 1) + 2**(22/25)*(9 - 50*ww2)**(22/25)*(40*10**(19/25)*ww2 - 9*(100*ww2 - 7)**(22/25))/(20*5**(19/25)*(1 - 4*ww2)**(22/25) - 9*(100*ww2 - 7)**(22/25)) </code></pre> <p>error message and I don't know why or where is the problem.</p> <p>Thanks in advance for the help.</p> <pre><code>import nashpy as nash import numpy as np import math from sympy import symbols, Eq, solve a4 = 0.6 a3 = 0.242 a2 = 0.115 a1 = 0.043 b4 = 0.5 b3 = 0.25 b2 = 0.18 b1 = 0.07 alpha = 0.88 beta = alpha LambdaI = 2.25 LambdaII = LambdaI Mu = alpha Nu = alpha y,ww1=symbols('y ww1') eq3=Eq((y*pow((a4-ww1),alpha)+(1-y)*pow((a2-ww1),alpha)-ww1),0) eq4=Eq(((-1)*LambdaI*y*pow((ww1-a1),beta)+(1-y)*pow((a3-ww1),alpha)-ww1),0) print(solve((eq3,eq4), (y, ww1))) y,ww1=symbols('y ww1') eq3=Eq((y*pow((a4-ww1),alpha)+(1-y)*pow((a2-ww1),alpha)),ww1) eq4=Eq(((-1)*LambdaI*y*pow((ww1-a1),beta)+(1-y)*pow((a3-ww1),alpha)),ww1) print(solve((eq3,eq4), (y, ww1))) x,ww2=symbols('x ww2') eq5=Eq((x*pow((b3-ww2),Nu)-(-1)*LambdaII*(1-x)*pow((ww2-b1),Nu)),ww2) eq6=Eq((x*pow((b2-ww2),Nu)+(1-x)*pow((b4-ww2),Nu)),ww2) print(solve((eq5,eq6), (x, ww2))) x,ww2=symbols('x ww2') eq5=Eq((x*pow((b3-ww2),Nu)-(-1)*LambdaII*(1-x)*pow((ww2-b1),Nu)-ww2),0) eq6=Eq((x*pow((b2-ww2),Nu)+(1-x)*pow((b4-ww2),Nu)-ww2),0) print(solve((eq5,eq6), (x, ww2))) </code></pre>
[ { "answer_id": 74423755, "author": "Reinderien", "author_id": 313768, "author_profile": "https://Stackoverflow.com/users/313768", "pm_score": 2, "selected": true, "text": "slsqp" }, { "answer_id": 74438142, "author": "smichr", "author_id": 1089161, "author_profile": "...
2022/11/13
[ "https://Stackoverflow.com/questions/74422203", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18449751/" ]
74,422,210
<p>Is it possible to create C preprocessor macro that would allow me to call methods on strings(char[]).</p> <p>e.g.:</p> <pre><code>char myStr[10]; int len = strlen(myStr); </code></pre> <p>Would become:</p> <pre><code>char myStr[10]; int len = myStr.len; </code></pre> <p>or:</p> <pre><code>char myStr[10]; int len = LEN myStr; </code></pre> <p><strong>Edit:</strong> Just to clarify, this question is about <strong>C-preprocessor</strong> not C language itself. For all intents and purposes, the code above could be replaced with JavaScript, PHP, or <strong>even plain text</strong>.</p> <p>All I am asking is, whether is it possible to write macro that would wrap text before token or after token with some other text.</p> <p>Generally speaking, the following transformation:</p> <p><strong>token</strong> <em>text</em> =&gt; wrap <em>text</em> wrap</p> <p>or</p> <p><em>text</em> <strong>token</strong> =&gt; wrap <em>text</em> wrap</p>
[ { "answer_id": 74428629, "author": "0___________", "author_id": 6110094, "author_profile": "https://Stackoverflow.com/users/6110094", "pm_score": 0, "selected": false, "text": "#define strlen(str) str.len\n\nint foo(char *str)\n{\n size_t x = strlen(str);\n}\n" } ]
2022/11/13
[ "https://Stackoverflow.com/questions/74422210", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5264331/" ]
74,422,217
<p>So I'm having a very confusing issue where I'm attempting to print a string from a vector of arrays of structs to the console. Integers print just fine however strings stored within these structs get set to &quot;&quot;. I have no idea what's going on here but after setting up a test as shown bellow this issue is still persisting. Any help figuring this out would be greatly apricated.</p> <p>Should also mention I'm still new to c++ so I apologise if the issue here is something simple.</p> <pre><code>#include &lt;iostream&gt; #include &lt;string&gt; #include &lt;vector&gt; #include &quot;Header.h&quot; //Test struct struct testStruct { string testString; int testInt; }; testStruct testArray[1] = { testArray[0] = {&quot;String works&quot;, 69} }; int main() { srand(time(NULL)); vector &lt; testStruct &gt; test; test.push_back({ testArray[0] }); cout &lt;&lt; test[0].testString &lt;&lt; &quot;\n&quot;; // prints &quot;&quot;, should print &quot;String works&quot; cout &lt;&lt; test[0].testInt &lt;&lt; &quot;\n&quot;; // prints 69 characterCreation(); checkPlayerStats(); introduction(); return 0; } </code></pre>
[ { "answer_id": 74422260, "author": "john", "author_id": 882003, "author_profile": "https://Stackoverflow.com/users/882003", "pm_score": 3, "selected": true, "text": "testStruct testArray[1] = {\n testArray[0] = {\"String works\", 69}\n};\n" }, { "answer_id": 74422285, "aut...
2022/11/13
[ "https://Stackoverflow.com/questions/74422217", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20493511/" ]
74,422,233
<p>I have a python dataset that has the following structure:</p> <pre><code>cluster pts lon lat 0 5 45 24 1 6 47 23 2 10 45 20 </code></pre> <p>As you can see, I have a column that refers to a cluster, the number of points within a cluster, the representative latitude of the cluster and the representative longitude of the cluster. In the whole dataframe I have 140 clusters.</p> <p>Now I would like to calculate for each cluster the following operation by means of a combinatorial:</p> <pre><code>ℎ(,)=−+/(,) </code></pre> <p>where i refers to a cluster and j to another. where n refers to the number of pts</p> <p>On the one hand it does the sum of the points between cluster i and cluster j, and in the denominator it calculates by means of haversine the distance between the two clusters taking into account their representative coordinates.</p> <p>I've started by coming up with a code that uses itertools, but I have problems to continue. Any idea?</p> <pre><code>from itertools import combinations for c in combinations(df['cluster'],2): sum_pts= distance= weight=-(sum_pts/distance) print(c,weight) </code></pre>
[ { "answer_id": 74422260, "author": "john", "author_id": 882003, "author_profile": "https://Stackoverflow.com/users/882003", "pm_score": 3, "selected": true, "text": "testStruct testArray[1] = {\n testArray[0] = {\"String works\", 69}\n};\n" }, { "answer_id": 74422285, "aut...
2022/11/13
[ "https://Stackoverflow.com/questions/74422233", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20149210/" ]
74,422,238
<p>Difference between rounding using Decimal library and rounding using round() function in Python 3. I don't know whether to use the round() function or use the Decimal library to round numbers</p> <p>Decimal</p> <pre><code>from decimal import* getcontext().prec = 3 print(Decimal(10)/3) 3,33 </code></pre> <p>round()</p> <pre><code>print(round(10/3,2)) 3,33 </code></pre> <p>I hope everyone can answer my questions</p>
[ { "answer_id": 74422260, "author": "john", "author_id": 882003, "author_profile": "https://Stackoverflow.com/users/882003", "pm_score": 3, "selected": true, "text": "testStruct testArray[1] = {\n testArray[0] = {\"String works\", 69}\n};\n" }, { "answer_id": 74422285, "aut...
2022/11/13
[ "https://Stackoverflow.com/questions/74422238", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20493520/" ]
74,422,254
<p>I have a list[(position,id)] from the user based on the ids it chooses which I collect in <strong>data</strong></p> <pre><code>data[(position,id)] = [(1,0),(2,0),(7,3),(8,6),(3,11),(3,11),(4,0),(5,1),(5,1),(6,2),(9,5),(10,7),(15,0),(16,10),(11,0),(11,1),(12,15),(13,8),(13,8),(13,9),(14,9)] </code></pre> <p>There are some duplicate elements in the list which I sorted out using *set(list) command</p> <pre><code>listdata = data res=[] res = [*set(listdata)] print(res) </code></pre> <p>I get the res list as follows:</p> <pre><code>output: res = [(11, 1), (13, 8), (6, 2), (4, 0), (16, 10), (11, 0), (2, 0), (5, 1), (10, 7), (7, 3), (9, 5), (15, 0), (13, 9), (14, 9), (8, 6), (12, 15), (1, 0), (3, 11)] </code></pre> <p>But what I want is only 16 elements in the list on first come basis with positions 1 to 16, if you see here I have got 2 entries with position 11 [(11,1),(11,0)] and position 13[(13,8),(13,9)]</p> <p>Required output: <code>res=[(11, 1), (13, 8), (6, 2), (4, 0), (16, 10), (2, 0), (5, 1), (10, 7), (7, 3), (9, 5), (15, 0), (14, 9), (8, 6), (12, 15), (1, 0), (3, 11)]</code></p> <p>Can anyone suggest alternate solution?</p>
[ { "answer_id": 74427007, "author": "Xi Gou", "author_id": 10871150, "author_profile": "https://Stackoverflow.com/users/10871150", "pm_score": -1, "selected": true, "text": "data = [(1,0),(2,0),(7,3),(8,6),(3,11),(3,11),(4,0),(5,1),(5,1),(6,2),(9,5),(10,7),(15,0),(16,10),(11,0),(11,1),(12...
2022/11/13
[ "https://Stackoverflow.com/questions/74422254", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17673025/" ]
74,422,263
<p>I am reading data from multiple tables using JOIN, CONCAT, GROUP_CONCAT, JSON_OBJECT. The data is read into the below mentioned model using gorm.</p> <pre><code>type OrgUserDisPublisherData struct { Disciplines datatypes.JSON `json:&quot;disciplines&quot; example:&quot;[]&quot;` User datatypes.JSON `json:&quot;user&quot;` } </code></pre> <p>This process is successfully completed. But then when I try to unmarshal the <code>OrgUserDisPublisherData.Disciplines</code> into another struct which has <code>time.Time</code> datatypes. I am getting the following error <code>parsing time &quot;\&quot;2022-11-03 07:08:09.000000\&quot;&quot; as &quot;\&quot;2006-01-02T15:04:05Z07:00\&quot;&quot;: cannot parse &quot; 07:08:09.000000\&quot;&quot; as &quot;T&quot;</code></p> <p>Final model used for unmarshalling</p> <pre><code>type Discipline struct { Name string `json:&quot;name&quot;` Code string `json:&quot;code&quot;` IsPrimary uint `json:&quot;isPrimary&quot;` IsAligned uint `json:&quot;isAligned&quot;` IsTrainingFaculty uint `json:&quot;isTrainingFaculty&quot;` AlignmentDate time.Time `json:&quot;alignmentDate&quot;` UnalignmentDate time.Time `json:&quot;UnalignmentDate&quot;` ExpiryDate time.Time `json:&quot;expiryDate&quot;` ExternalId string `json:&quot;externalId&quot;` Status string `json:&quot;status&quot;` CreatedAt time.Time `json:&quot;createdAt&quot;` UpdatedAt time.Time `json:&quot;updatedAt&quot;` } </code></pre> <p>At the same time, while inserting data into the tables the same model was used and it does not throw any error related to time. How can I handle time while unmarshalling, irrespective of the data that is present against the time property?</p>
[ { "answer_id": 74425641, "author": "Deltics", "author_id": 123487, "author_profile": "https://Stackoverflow.com/users/123487", "pm_score": 2, "selected": true, "text": "T" }, { "answer_id": 74429065, "author": "Midhun Kumar", "author_id": 6509305, "author_profile": "h...
2022/11/13
[ "https://Stackoverflow.com/questions/74422263", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6509305/" ]
74,422,275
<p>In React, I'm unable to use a URL string in my Tailwind background image class:</p> <p>1: Not working, getting error &quot;can't resolve ${link}&quot;</p> <pre><code>const link = &quot;https://cdn.test.net/test.jpg&quot;; &lt;div className={`px-4 py-1 h-[22rem] lg:h-[28vw] bg-cover bg-center bg-[url('${link}')]`}&gt;&lt;/div </code></pre> <p>2: Working, but I need to use a variable inside my <code>bg-</code> class.</p> <pre class="lang-js prettyprint-override"><code>const link = &quot;bg-[url('https://cdn.test.net/test.jpg')]&quot;; &lt;div className={`px-4 py-1 h-[22rem] lg:h-[28vw] bg-cover bg-center ${link}`}&gt;&lt;/div&gt; </code></pre> <p>I still need to be able to use <code>${link}</code> inside <code>bg-[url('${link}')]</code>.</p>
[ { "answer_id": 74425641, "author": "Deltics", "author_id": 123487, "author_profile": "https://Stackoverflow.com/users/123487", "pm_score": 2, "selected": true, "text": "T" }, { "answer_id": 74429065, "author": "Midhun Kumar", "author_id": 6509305, "author_profile": "h...
2022/11/13
[ "https://Stackoverflow.com/questions/74422275", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20493580/" ]
74,422,286
<p>I need access div in a page.</p> <h2>page.aspx</h2> <pre><code>&lt;asp:Content ID=&quot;Content&quot; ContentPlaceHolderID=&quot;ContentPlaceHolderBody1&quot; runat=&quot;server&quot;&gt; &lt;div class=&quot;table-responsive&quot;&gt; &lt;div class=&quot;card card-authentication1 mx-auto my-5&quot; id=&quot;div_Payment&quot; runat=&quot;server&quot;&gt;&lt;/div&gt; &lt;/div &lt;/asp:Content&gt; </code></pre> <h2>masterpage</h2> <pre><code>protected void Admin_Load(object sender, EventArgs e) { HtmlControl control = (HtmlControl)Page.FindControl(&quot;ContentPlaceHolderBody1&quot;).FindControl(&quot;div_Payment&quot;); HtmlControl control = (HtmlControl)Master.FindControl(&quot;ContentPlaceHolderBody1&quot;).FindControl(&quot;div_Payment&quot;); control.Style.Add(&quot;display&quot;, &quot;none&quot;); } </code></pre> <p>no luck.</p>
[ { "answer_id": 74425641, "author": "Deltics", "author_id": 123487, "author_profile": "https://Stackoverflow.com/users/123487", "pm_score": 2, "selected": true, "text": "T" }, { "answer_id": 74429065, "author": "Midhun Kumar", "author_id": 6509305, "author_profile": "h...
2022/11/13
[ "https://Stackoverflow.com/questions/74422286", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20412749/" ]
74,422,305
<p>I am writing a test, using @pytest.mark.parametrize. The test looks like this:</p> <pre><code>@pytest.mark.parametrize( &quot;device_type,first_command,second_command&quot;, [ pytest.param( &lt;device_type&gt;, &lt;first_command&gt;, &lt;second_command&gt;, id=str(&lt;first_command&gt;) + &quot;,&quot; + str(&lt;second_command&gt;), ), .... ] ) </code></pre> <p>Actually &lt;first_command&gt; and &lt;second_command&gt; are commands from a list of commands, defined in an enumeration, and i have to check all possible combinations whether they are executed successfully. Is it possible to create automatically this param list instead of explicitly mentioning every possible combination of 2 commands?</p>
[ { "answer_id": 74423607, "author": "Ilya", "author_id": 1139541, "author_profile": "https://Stackoverflow.com/users/1139541", "pm_score": 1, "selected": false, "text": "@pytest.mark.parametrize" }, { "answer_id": 74427934, "author": "Eugeny Okulik", "author_id": 12023661,...
2022/11/13
[ "https://Stackoverflow.com/questions/74422305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4053840/" ]
74,422,325
<p>I have a DF:</p> <pre><code>df = pd.DataFrame({&quot;A&quot;:[0,1,3,5,6], &quot;B&quot;:['B0','B1','B3','B5','B6'], &quot;C&quot;:['C0','C1','C3','C5','C6']}) </code></pre> <p>I’m trying to insert 10 empty rows at the position where the number is missed from the continuous sequence of column A. For the 10 rows, values of column A, B and C's are the missed number, Nan, and Nan, respectively. Like this:</p> <pre><code>A B C 0 B0 C0 1 B1 C1 2 NaN NaN 2 NaN NaN 2 NaN NaN 2 NaN NaN 2 NaN NaN 2 NaN NaN 2 NaN NaN 2 NaN NaN 2 NaN NaN 2 NaN NaN 3 B3 C3 4 NaN NaN 4 NaN NaN 4 NaN NaN 4 NaN NaN 4 NaN NaN 4 NaN NaN 4 NaN NaN 4 NaN NaN 4 NaN NaN 4 NaN NaN 5 B5 C5 6 B6 C6 </code></pre> <p>I've played with index, but this adds only 1 row:</p> <pre><code>df1 = df.merge(how='right', on='A', right = pd.DataFrame({'A':np.arange(df.iloc[0]['A'], df.iloc[-1]['A']+1)})).reset_index().drop(['index'], axis=1) </code></pre> <p>Thanks in advance!</p>
[ { "answer_id": 74423607, "author": "Ilya", "author_id": 1139541, "author_profile": "https://Stackoverflow.com/users/1139541", "pm_score": 1, "selected": false, "text": "@pytest.mark.parametrize" }, { "answer_id": 74427934, "author": "Eugeny Okulik", "author_id": 12023661,...
2022/11/13
[ "https://Stackoverflow.com/questions/74422325", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18813174/" ]
74,422,326
<p>`</p> <pre><code>const data = [{'name': 'Apip'}, {'name': 'Rohmat'}, {'name': 'ujang'}] data.forEach(function (response) { res.json(response) }) </code></pre> <p>`</p> <p>I did the code above it doesn't work and then it throws an error &quot;Cannot set headers after they are sent to the client&quot;</p>
[ { "answer_id": 74423607, "author": "Ilya", "author_id": 1139541, "author_profile": "https://Stackoverflow.com/users/1139541", "pm_score": 1, "selected": false, "text": "@pytest.mark.parametrize" }, { "answer_id": 74427934, "author": "Eugeny Okulik", "author_id": 12023661,...
2022/11/13
[ "https://Stackoverflow.com/questions/74422326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20451182/" ]
74,422,347
<p>On specific, given website I want to:</p> <ol> <li>Check if specific service (provided by string) is available</li> <li>If available I want to get its price</li> </ol> <p>Let's assume that pricing is stored in <code>table</code> which name I don't know. <br> I've used <code>beautifulsoup</code> to find this service by variable called <code>strServiceVersion</code> on webiste (looking for columns which contains string).<br></p> <pre><code>arrDataCell = soup.find_all('td', text=strServiceVersion) if len(arrDataCell)&gt;0: #found data cell with given string print(&quot;\nPrint whole data cell: &quot;) print(arrDataCell) print(&quot;\nPrint parent of the 1st data cell: &quot;) #print below print(arrDataCell[0].parent()) </code></pre> <p>So I know this text (name of service) exist on the webpage in some table. <br> I can print parent of the 1st data cell: <br></p> <pre><code>[&lt;td class=&quot;column-1&quot;&gt; Some_Text_1&lt;/td&gt;, Some_Text_2, &lt;td class=&quot;column-2&quot;&gt;Price_1&lt;/td&gt;, Price_2] </code></pre> <p>Now I know this X table has two columns and I know its class names (column-1 and column-2 I presume?) <br> Now I would like to get this table as an object and being able to loop through it and extract it by row and column. <br></p> <p>How do I do that? <br> Or any other solution? <br></p>
[ { "answer_id": 74448719, "author": "HedgeHog", "author_id": 14460824, "author_profile": "https://Stackoverflow.com/users/14460824", "pm_score": 0, "selected": false, "text": "for e in soup.select('td:-soup-contains(\"Kompleksowe badanie\")'):\n print(e.text,e.find_next_sibling('td').t...
2022/11/13
[ "https://Stackoverflow.com/questions/74422347", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10234524/" ]
74,422,396
<p>I am trying to create a group that has the right to create databases and roles. And then inherit these privileges with the next role. But the error constantly pops up that I don't have rights</p> <p>Edited: (mistake between 'gg' and 'ggc', but steel doesn't work)</p> <pre><code>create role ggc with createdb createrole; create user gg login password 'gg'; grant ggс to gg; </code></pre> <p>Always get this error: &quot;SQL Error [42501]&quot;</p> <p>This way is also doesn't work</p> <pre><code>CREATE ROLE qwe WITH NOLOGIN CREATEDB CREATEROLE; CREATE ROLE ads WITH LOGIN PASSWORD 'pass'; GRANT qwe TO ads; SET ROLE ads; CREATE DATABASE test; </code></pre>
[ { "answer_id": 74448719, "author": "HedgeHog", "author_id": 14460824, "author_profile": "https://Stackoverflow.com/users/14460824", "pm_score": 0, "selected": false, "text": "for e in soup.select('td:-soup-contains(\"Kompleksowe badanie\")'):\n print(e.text,e.find_next_sibling('td').t...
2022/11/13
[ "https://Stackoverflow.com/questions/74422396", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17932782/" ]
74,422,421
<p>Sorry if the title makes no sense.. let me explain</p> <p>Say I have the following 2d array.. the first array representing ice cream and the second representing milkshakes</p> <pre><code>menu = [ ['vanilla', 'chocolate', 'almond'], ['vanilla', 'pineapple', 'strawberry'] ] </code></pre> <p>Now I create a class that takes this array as input</p> <pre><code>class cafe{ constructor(menu){ this.iceCreams = menu[0] this.milkshakes = menu[1] } } </code></pre> <p>Now I want to define a property called 'price' for each flavor of milkshake.</p> <p><code>this.milkshakes[n].price = &lt; a function that computes price based on value of n &gt;</code></p> <p>so that i can access them like this : <code>cafe.milkshakes[0].price</code></p> <p>So how do I incorporate the index 'n' of the array while defining the property</p> <p>I haven't tried anything bcos I dont know how to even approach this ☹️</p>
[ { "answer_id": 74422460, "author": "Mina", "author_id": 11887902, "author_profile": "https://Stackoverflow.com/users/11887902", "pm_score": 0, "selected": false, "text": "milkshakes" }, { "answer_id": 74422474, "author": "Sennen Randika", "author_id": 11489268, "autho...
2022/11/13
[ "https://Stackoverflow.com/questions/74422421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20398764/" ]
74,422,468
<p>self.room_group_name = &quot;chat_%s&quot; % self.room_name This is the line of code that defines the room group name from the room_name in the official tutorial on the channels website. (<a href="https://channels.readthedocs.io/en/stable/tutorial/part_2.html" rel="nofollow noreferrer">https://channels.readthedocs.io/en/stable/tutorial/part_2.html</a>)</p> <p>I am unable to understand what &quot;chat_%s&quot; % self.room_name&quot; means. Would appreciate any explanation of what this bit of code exactly does.</p>
[ { "answer_id": 74422527, "author": "Mark", "author_id": 2203038, "author_profile": "https://Stackoverflow.com/users/2203038", "pm_score": 3, "selected": true, "text": "\"chat_%s\" % self.room_name\n" }, { "answer_id": 74422528, "author": "Willem Van Onsem", "author_id": 6...
2022/11/13
[ "https://Stackoverflow.com/questions/74422468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13540111/" ]
74,422,502
<p>I've run into a problem trying to start a game with some additional parameters. Normally you enter them in the &quot;target line&quot; on <strong>Windows</strong>, such as:</p> <pre><code>&quot;C:\Path\To\game.exe&quot; --arg --arg2 --arg3 abc --arg4 xyz </code></pre> <p>There are both arguments that are simply the argument like --arg and --arg2, then there are other arguments that require another value, such as &quot;--arg3 50&quot;.</p> <p>I have already figured out how to run multiple arguments in a fixed manner such as below, &quot;localconfig_data[&quot;exe&quot;]&quot; contains the path as &quot;C:\Path\To\game.exe&quot;.</p> <pre><code>subprocess.run([localconfig_data[&quot;exe&quot;], &quot;--editor&quot;, &quot;--erode 100&quot;]) </code></pre> <p>My issue is that depending on previous selections in my program, I could end up with around 10 different arguments which makes it quite impractical to make cases for all different options.</p> <p>What I've tried that doesn't work:</p> <pre><code>args_string = &quot;--editor --erode 100 --hidden-hud&quot; #args_string is made in a for loop depending on the arguments given subprocess.run([localconfig_data[&quot;exe&quot;], args_string]) </code></pre> <p>Outcome is that nothing happens. My next best idea was to try to print it out:</p> <pre><code>args_list = [&quot;--editor&quot;, &quot;--erode 100&quot;, &quot;--hidden-hud&quot;] subprocess.run([localconfig_data[&quot;exe&quot;], for a in args_list: print(a)]) </code></pre> <p>This gives me a syntax error: <strong>SyntaxError: did you forget parentheses around the comprehension target?</strong>, so it was a proof of concept in my mind.</p> <p>Final question: how can I add all of my arguments dynamically when launching a program with subprocess.run() ?</p>
[ { "answer_id": 74481549, "author": "Wahlmat", "author_id": 3412539, "author_profile": "https://Stackoverflow.com/users/3412539", "pm_score": -1, "selected": true, "text": "argslist = [\"--arg1\", \"--arg2\", \"--arg3\"]\nexecuteString = 'subprocess.run([localconfig_data[\"exe\"]'\n\nfor ...
2022/11/13
[ "https://Stackoverflow.com/questions/74422502", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3412539/" ]
74,422,532
<p>I am creating a sports database and am trying to add a trigger to my DDL. The aim of the trigger is to insert values into a table (commitment) whenever another table (player) has a college commitment (col_commit) change from FALSE to TRUE. Whenever this happens I want to insert the player's id and the date of the update. This is what I have so far:</p> <pre><code>CREATE OR REPLACE FUNCTION commitment_log() RETURNS TRIGGER LANGUAGE plpgsql AS $$ BEGIN IF OLD.col_commit = TRUE THEN INSERT INTO commitment(player_id, committed_date) VALUES (OLD.player_id, now()); END IF; RETURN NEW; END; $$; CREATE TRIGGER commitment_trigger BEFORE UPDATE ON player FOR EACH ROW EXECUTE PROCEDURE commitment_log(); </code></pre> <p>As of now, when I update a player's commitment in the player table to TRUE, nothing is updated in the commitment table.</p>
[ { "answer_id": 74422644, "author": "Zegarek", "author_id": 5298879, "author_profile": "https://Stackoverflow.com/users/5298879", "pm_score": 1, "selected": false, "text": "old.col_commit=TRUE" }, { "answer_id": 74422872, "author": "nbk", "author_id": 5193536, "author_...
2022/11/13
[ "https://Stackoverflow.com/questions/74422532", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17421506/" ]
74,422,538
<p>I have a SingleChildScrollView inside of a Sized box. I thought this would make my page scrollable but it does not. I get this when I run it <a href="https://i.stack.imgur.com/9sB68.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9sB68.jpg" alt="Overflow" /></a></p> <p>I have the code</p> <pre><code>Container( width: double.infinity, alignment: Alignment.centerLeft, child: Column( children: [ const SizedBox( width: double.infinity, child: some text ), const SizedBox(height: 10), SizedBox( width: double.infinity, child: SingleChildScrollView( child: Column( children: items .map((e) =&gt; ListTile( most recent items )) .toList(), ), )), ], )) </code></pre>
[ { "answer_id": 74422574, "author": "Abdalla Tawfik", "author_id": 11601491, "author_profile": "https://Stackoverflow.com/users/11601491", "pm_score": 0, "selected": false, "text": "Expanded(\nchild :SizedBox(\nchild :...\n)\n)\n" }, { "answer_id": 74422575, "author": "eamirho...
2022/11/13
[ "https://Stackoverflow.com/questions/74422538", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14568913/" ]
74,422,555
<p>I'm trying to create shopping cart page. From controller I'm getting an array of order items. Order item has foreign key &quot;meal_id&quot; - relationship with table meals. I need to access to connected meal object, to display information. How should I do it correctly? I tried to include php key inside blade template:</p> <pre><code> @foreach($order_items as $order_item) ... @php $meal = \App\Models\Meal::where('id', '=', $order_item-&gt;meal_id)-&gt;get(); @endphp ... @endforeach </code></pre> <p>But it doesn't work. Of course I can send two different arrays of order_items and meals and hope, that sequence will be equal... Or I can somehow send one array with joint tables. But isn't there more simple way to do this?</p>
[ { "answer_id": 74422574, "author": "Abdalla Tawfik", "author_id": 11601491, "author_profile": "https://Stackoverflow.com/users/11601491", "pm_score": 0, "selected": false, "text": "Expanded(\nchild :SizedBox(\nchild :...\n)\n)\n" }, { "answer_id": 74422575, "author": "eamirho...
2022/11/13
[ "https://Stackoverflow.com/questions/74422555", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15493934/" ]
74,422,597
<p>This is a branch from my main code of a lottery ticket generator. The purpose of these two functions: (1) drawButton(length) to create rectangular buttons. (2) createMenu() to call drawButton(length) and to fill the buttons with labels.</p> <p>My issue is when the main code attempts to return to the main menu, it runs turtle.clearscreen(). Shortly after writing the main menu, it did not draw the first rectangle/button.</p> <p>Let me know if you guys get a different result than I do.</p> <pre><code>import turtle import time t1 = turtle.Turtle() t1.speed(0) t1.penup() def drawButton(length): length1 = length*5 for i in range(2): t1.fd(length1) t1.lt(90) t1.fd(length) t1.lt(90) def createMenu(): t1.sety(-13) down = t1.ycor() for i in range(4): t1.goto(-150, down) t1.pendown() drawButton(60) t1.penup() down = t1.ycor()-100 createMenu() time.sleep(2) turtle.clearscreen() createMenu() turtle.done() </code></pre> <p>This is what the program should draw on the second function call: <a href="https://i.stack.imgur.com/rMGuw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rMGuw.png" alt="This is what the program should draw on the second function call" /></a></p> <p>This is what I get after the second function call: <a href="https://i.stack.imgur.com/ptozl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ptozl.png" alt="This is what I get after the second function call" /></a></p>
[ { "answer_id": 74422574, "author": "Abdalla Tawfik", "author_id": 11601491, "author_profile": "https://Stackoverflow.com/users/11601491", "pm_score": 0, "selected": false, "text": "Expanded(\nchild :SizedBox(\nchild :...\n)\n)\n" }, { "answer_id": 74422575, "author": "eamirho...
2022/11/13
[ "https://Stackoverflow.com/questions/74422597", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20478942/" ]
74,422,605
<p>New learner here...</p> <p>i just trying to find word in a string. can i search multiple words in one string using .find/.index or any other method?</p> <pre><code>ex = &quot;welcome to my question. you are welcome to be here&quot; print(ex.find(&quot;welcome&quot;)) result = 0 </code></pre> <p>and if i try get the second word i will get -1 which mean not found</p> <pre><code>ex = &quot;welcome to my question. you are welcome to be here&quot; print(ex.find(&quot;welcome&quot;, 21, 0)) result = -1 </code></pre> <p>is there any other method i can use?</p>
[ { "answer_id": 74422741, "author": "mintyCoder", "author_id": 20493833, "author_profile": "https://Stackoverflow.com/users/20493833", "pm_score": 0, "selected": false, "text": "# very important\nimport re\n\nexample = \"Hello, in this string we will extract 2 numbers, number 1 and \nnumb...
2022/11/13
[ "https://Stackoverflow.com/questions/74422605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20344875/" ]
74,422,628
<p>I'm trying to create a data frame from other data, my current data includes 20 countries, 10 years from 2020-2030. I wish to now create a new df containing each country and each year separately which would look something like this;</p> <p>desired df:</p> <pre><code>Albania 2021 Albania 2022 ...... continued to 2030, then Algeria 2021 Algeria 2022 and so on </code></pre> <p>data needed for this:</p> <pre><code>CountryNames &quot;Albania&quot;, &quot;Algeria&quot;, &quot;Bosnia and Herzegovina&quot; &quot;Croatia&quot;, &quot;Cyprus&quot;, &quot;Egypt, Arab Rep.&quot;, &quot;France&quot;, &quot;Greece&quot;, &quot;Israel&quot;, &quot;Italy&quot;, &quot;Lebanon&quot;, &quot;Libya&quot;, &quot;Malta&quot;, &quot;Montenegro&quot;, &quot;Morocco&quot;, &quot;Slovenia&quot;, &quot;Spain&quot;, &quot;Syrian Arab. Rep&quot;, &quot;Tunisia&quot;, &quot;Turkey&quot; future_years 2021, 2022, 2023, 2024, 2025, 2025, 2026, 2027, 2028, 2029, 2030 </code></pre>
[ { "answer_id": 74422709, "author": "AndS.", "author_id": 9778513, "author_profile": "https://Stackoverflow.com/users/9778513", "pm_score": 3, "selected": true, "text": "expand.grid" }, { "answer_id": 74422794, "author": "TarJae", "author_id": 13321647, "author_profile...
2022/11/13
[ "https://Stackoverflow.com/questions/74422628", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18338223/" ]
74,422,630
<p>I have a problem converting string to float. For example, I want to get an input like <code>10**2</code> and I want the program to save the result of <code>10**2</code> in the variable.</p> <p>like this :</p> <pre class="lang-py prettyprint-override"><code>Number = float(input(&quot;Enter the number : &quot;)) print(number * 2) </code></pre> <p>something like this and when i run and it says :</p> <pre><code>Enter the number : </code></pre> <p>and I give it <code>10**2</code> I want it to return <code>200</code></p> <p>like this :</p> <pre><code>Enter the number : 10**2 200 </code></pre> <p>How can I do it? I tried different ways non worked.</p>
[ { "answer_id": 74422663, "author": "C-3PO", "author_id": 4667669, "author_profile": "https://Stackoverflow.com/users/4667669", "pm_score": 2, "selected": false, "text": "eval" }, { "answer_id": 74423068, "author": "Andrew", "author_id": 11844224, "author_profile": "ht...
2022/11/13
[ "https://Stackoverflow.com/questions/74422630", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19578300/" ]
74,422,635
<p>Like I said in the title, I am having a hard time writing this particular regular expression. Any help would be much appreciated.</p> <p>My best attempt in trying to solve this problem was writing this:</p> <pre><code>^([0-9]*[1-9][0-9]*)*[02468]$ </code></pre> <p>But this regular expression can't recognize a number like &quot;002&quot;. Then I have tried this:</p> <pre><code>^([0-9]*[1-9][0-9]*)*[02468]*[02468]$ </code></pre> <p>Now regular expression recognizes &quot;002&quot;, but also recognizes &quot;000&quot; (only zeros) and I can't avoid that happening.</p> <p>In conclusion, I am failing again and again in writing a regular expression that can recognize positive even numbers (including leading zeros, but excluding &quot;000&quot; - numbers with only zeros) like:</p> <p>2, 001234, 00123400, 002, 20, 16 etc.</p> <p>Thank you in advance.</p>
[ { "answer_id": 74422702, "author": "Ted Lyngmo", "author_id": 7582247, "author_profile": "https://Stackoverflow.com/users/7582247", "pm_score": 3, "selected": true, "text": "0" }, { "answer_id": 74422858, "author": "The fourth bird", "author_id": 5424988, "author_prof...
2022/11/13
[ "https://Stackoverflow.com/questions/74422635", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20266178/" ]
74,422,677
<p>I have 3 lists</p> <pre class="lang-py prettyprint-override"><code>a = [&quot;1&quot;, &quot;2&quot;, &quot;3&quot;, &quot;4&quot;, &quot;5&quot;, &quot;6&quot;] b = ['a', 'b', 'c'] c = [&quot;13&quot;, &quot;14&quot;] </code></pre> <p>and the format is:</p> <pre><code>1 3 a 2 13 b 3 13 c 4 14 a 5 14 b 6 14 c </code></pre> <p>How do I get the above format?</p>
[ { "answer_id": 74422770, "author": "Vrishab Sharma", "author_id": 14190971, "author_profile": "https://Stackoverflow.com/users/14190971", "pm_score": -1, "selected": false, "text": "for i in c:\n for j in b:\n for k in a:\n print(k,i,j,sep='\\n')\n" }, { "ans...
2022/11/13
[ "https://Stackoverflow.com/questions/74422677", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20493849/" ]
74,422,720
<p>Edit: the dummy dataframe is edited</p> <p>I have a pandas data frame with the below kind of column with 200 rows.</p> <p>Let's say the name of df is data.</p> <pre><code>-----------------------------------| B -----------------------------------| {'animal':'cat', 'bird':'peacock'...} </code></pre> <p>I want to extract the value of animal to a separate column C for all the rows.</p> <p>I tried the below code but it doesn't work.</p> <pre><code>data['C'] = data[&quot;B&quot;].apply(lambda x: x.split(':')[-2] if ':' in x else x) </code></pre> <p>Please help.</p>
[ { "answer_id": 74422770, "author": "Vrishab Sharma", "author_id": 14190971, "author_profile": "https://Stackoverflow.com/users/14190971", "pm_score": -1, "selected": false, "text": "for i in c:\n for j in b:\n for k in a:\n print(k,i,j,sep='\\n')\n" }, { "ans...
2022/11/13
[ "https://Stackoverflow.com/questions/74422720", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14656814/" ]
74,422,731
<p>why when we use chaining bind we get first context (why not last)?</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>function showName() { console.log(this.name); } let user = { name: "John", }; let user2 = { name: "Den", } let binded = showName.bind(user).bind(user2); binded(); // "John"</code></pre> </div> </div> </p> <p>why chaining bind works like that?</p>
[ { "answer_id": 74422770, "author": "Vrishab Sharma", "author_id": 14190971, "author_profile": "https://Stackoverflow.com/users/14190971", "pm_score": -1, "selected": false, "text": "for i in c:\n for j in b:\n for k in a:\n print(k,i,j,sep='\\n')\n" }, { "ans...
2022/11/13
[ "https://Stackoverflow.com/questions/74422731", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15748499/" ]
74,422,737
<p>I would need a help with reviewing of below nested conditional where for the life of me I am not able to find a syntax error which is causing the logic to be broken. Problem is not within the logic itself although I admit that it's bit messy but within the syntax how I am connecting one conditional branch to another</p> <pre><code>&quot;(${length(regexall(&quot;(?i)READ$&quot;, &quot;${trimspace(each.value.access_type)}&quot; )) &gt; 0 ? &quot;_AR_${substr(&quot;${split(&quot;,&quot;, trimspace(each.value.parameter_names))[0]}&quot;, 9, -1)}__${substr(&quot;${split(&quot;,&quot;, trimspace(each.value.parameter_names))[1]}&quot;, 7, -1)}__R&quot; : ( ${length(regexall(&quot;(?i)READ_WRITE&quot;, &quot;${trimspace(each.value.access_type)}&quot; )) &gt; 0 &quot;_AR_${substr(&quot;${split(&quot;,&quot;, trimspace(each.value.parameter_names))[0]}&quot;, 9, -1)}__${substr(&quot;${split(&quot;,&quot;, trimspace(each.value.parameter_names))[1]}&quot;, 7, -1)}__RW&quot; : ( ${length(regexall(&quot;(?i)READ_WRITE_CTRL&quot;, &quot;${trimspace(each.value.access_type)}&quot; )) &gt; 0 &quot;_AR_${substr(&quot;${split(&quot;,&quot;, trimspace(each.value.parameter_names))[0]}&quot;, 9, -1)}__${substr(&quot;${split(&quot;,&quot;, trimspace(each.value.parameter_names))[1]}&quot;, 7, -1)}__RWC&quot; : null))})&quot; </code></pre> <p>Flow stops right away during terraform init with below errors:</p> <p>This character is not used within the language. <br/> Quoted strings may not be split over multiple lines. To produce a multi-line string, either use the \n escape to represent a newline character or use the &quot;heredoc&quot; multi-line template syntax. <br/> Expected the start of an expression, but found an invalid expression token.</p> <p>Below is a functional version not utilizing nested conditional:</p> <pre><code>&quot;${length(regexall(&quot;(?i)READ$&quot;, &quot;${trimspace(each.value.access_type)}&quot; )) &gt; 0 ? &quot;_AR_${substr(&quot;${split(&quot;,&quot;, trimspace(each.value.parameter_names))[0]}&quot;, 9, -1)}__${substr(&quot;${split(&quot;,&quot;, trimspace(each.value.parameter_names))[1]}&quot;, 7, -1)}__R&quot; : &quot;TEST&quot;}&quot; </code></pre>
[ { "answer_id": 74422918, "author": "codermarcos", "author_id": 9021478, "author_profile": "https://Stackoverflow.com/users/9021478", "pm_score": 3, "selected": true, "text": "\"(${\nlength(regexall(\"(?i)READ$\", \"${trimspace(each.value.access_type)}\" )) > 0 \n ? \"_AR_${substr(\"${sp...
2022/11/13
[ "https://Stackoverflow.com/questions/74422737", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3368322/" ]
74,422,749
<p>I have a file with the following content:</p> <pre><code>{ &quot;Youtube tutorial bot test&quot;: { &quot;ivan4o assistant&quot;: 0, &quot;kurwa qvor&quot;: 1 } } </code></pre> <p>And I want it to read only the number.</p> <p>I've tried with this code:</p> <pre><code>def warns_check(member: discord.Member): with open('warns.json', 'r') as f: warns = json.load(f) warns[str(member.name)] return warns @client.command() async def checkwarns(ctx, member: discord.Member): warns = warns_check(member) await ctx.send(f&quot;{member.name} has {warns} warnings&quot;) </code></pre> <p>And it reads the whole file. How to fix this?</p>
[ { "answer_id": 74422918, "author": "codermarcos", "author_id": 9021478, "author_profile": "https://Stackoverflow.com/users/9021478", "pm_score": 3, "selected": true, "text": "\"(${\nlength(regexall(\"(?i)READ$\", \"${trimspace(each.value.access_type)}\" )) > 0 \n ? \"_AR_${substr(\"${sp...
2022/11/13
[ "https://Stackoverflow.com/questions/74422749", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20488690/" ]
74,422,751
<p>I want to move to the next page without clicking on button with flutter. Juste after changing the value of a button, I have to redirect to the next page after some delay without any self interaction. this is the code :</p> <pre><code> initialData: BluetoothDeviceState.disconnected, builder: (c, snapshot) { if (snapshot.data == BluetoothDeviceState.connected) { return ElevatedButton( child: const Text('CONNECTED'), onPressed: () =&gt; Navigator.of(context).push( MaterialPageRoute( builder: (context) =&gt; MainScreen())), ); } </code></pre>
[ { "answer_id": 74422918, "author": "codermarcos", "author_id": 9021478, "author_profile": "https://Stackoverflow.com/users/9021478", "pm_score": 3, "selected": true, "text": "\"(${\nlength(regexall(\"(?i)READ$\", \"${trimspace(each.value.access_type)}\" )) > 0 \n ? \"_AR_${substr(\"${sp...
2022/11/13
[ "https://Stackoverflow.com/questions/74422751", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20285309/" ]
74,422,756
<p>In Delphi 10.4, I was able to get a listing of files in an Android device's shared storage. In Delphi 11, with necessary permission set (either programmatically or on the device), <code>TDirectory.GetFiles()</code> is returning an empty list (ie. zero entries).</p> <p><code>TDirectory.GetDirectories()</code> is working correctly, and using <code>TFile.Exists()</code> with a filename which I know to be present returns true. But, if I try to open that file with, for instance, <code>TFile.ReadAllText()</code>, access is denied. Any suggestions?</p> <p>This is an example program which fails in Delphi 11:</p> <pre class="lang-pascal prettyprint-override"><code>uses System.Types,System.Classes,system.sysUtils,system.IOUtils,system.Permissions, {$IFDEF ANDROID} Androidapi.Helpers, Androidapi.JNI.JavaTypes, Androidapi.JNI.Os, {$ENDIF} FMX.Types,FMX.Forms,FMX.Dialogs; type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); private fOK:boolean; procedure PermissionsResult(Sender: TObject; const APermissions: TClassicStringDynArray; const AGrantResults: TClassicPermissionStatusDynArray); end; var Form1: TForm1; implementation {$R *.fmx} procedure Tform1.PermissionsResult(Sender: TObject; const APermissions: TClassicStringDynArray; const AGrantResults: TClassicPermissionStatusDynArray); var n:integer; begin if length(AGrantResults)&gt;0 then for n:=0 to length(AGrantResults)-1 do if not (AGrantResults[n] = TPermissionStatus.Granted) then fOK:=false; end; procedure FileList(dir:string;list:TstringList); var LList: TStringDynArray; I: Integer; begin list.Clear; Llist:=Tdirectory.GetFiles(dir); if length(LList)&gt;0 then for I := 0 to Length(LList) - 1 do list.Add(LList[I]); end; procedure TForm1.FormCreate(Sender: TObject); var DataDir:string; list:TstringList; p:Tarray&lt;string&gt;; begin fOK:=true; p:=[JStringToString(TJManifest_permission.JavaClass.READ_EXTERNAL_STORAGE), JStringToString(TJManifest_permission.JavaClass.WRITE_EXTERNAL_STORAGE)]; PermissionsService.RequestPermissions(p,PermissionsResult,nil); if fOK then begin list:=TstringList.Create; DataDir := TPath.GetSharedDocumentsPath; showmessage(DataDir); fileList(DataDir,list); showmessage(inttostr(list.Count)+' '+list.Text); list.Free; end else showmessage('permission refused'); end; end. </code></pre>
[ { "answer_id": 74423219, "author": "Winston", "author_id": 12063888, "author_profile": "https://Stackoverflow.com/users/12063888", "pm_score": -1, "selected": false, "text": "var\n FileList: TStringDynArray;\n myfileList: Tstringlist;\n s: string;\n DocDir: string; \nbegin\n DocDir ...
2022/11/13
[ "https://Stackoverflow.com/questions/74422756", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20492839/" ]
74,422,776
<p>I am facing an issue with having my res value (array) from the <em>getLogs</em> function to be populated to the DataGrid.</p> <p><strong>UPDATED CODES:</strong></p> <p><em>LogDetails.jsx</em></p> <pre><code>const columns = [ { field: &quot;id&quot;, headerName: &quot;ID&quot;, width: 30 }, { field: &quot;name&quot;, headerName: &quot;Name&quot;, width: 250, }, { field: &quot;activity&quot;, headerName: &quot;Activity&quot;, width: 350, }, { field: &quot;date&quot;, headerName: &quot;Date&quot;, width: 250, }, ]; export default function LogDetails() { const [logs, setLogs] = useState([]); useEffect(() =&gt; { function logs() { getLogs().then((res) =&gt; { setLogs(res); }); } logs(); }, []); return ( &lt;Box sx={{ width: &quot;100%&quot; }}&gt; {logs.length ? ( &lt;DataGrid rows={logs} columns={columns} pageSize={10} rowsPerPageOptions={[10]} disableSelectionOnClick autoHeight /&gt; ): null} &lt;/Box&gt; ); } </code></pre> <p><em>function.js</em></p> <pre><code>export async function getLogs() { var rows = []; const q = query(collection(db, &quot;logs&quot;), orderBy(&quot;date&quot;, &quot;desc&quot;)); const docQueury = await getDocs(q); var count = 1; docQueury.forEach(async (log) =&gt; { const useref = await getDoc(log.data().user); const date = new Timestamp( log.data().date.seconds, log.data().date.nanoseconds ) .toDate() .toLocaleString(&quot;en-sg&quot;); rows.push({ id: count++, name: useref.data().name, activity: log.data().activity, date: date, }); }); return rows; } </code></pre> <p>Output of &quot;rows&quot; from getLogs function:</p> <p><a href="https://i.stack.imgur.com/tBQyL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tBQyL.png" alt="rows output from getLogs Function" /></a></p> <p>Output of states from LogDetails.jsx:</p> <p><a href="https://i.stack.imgur.com/XiseK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XiseK.png" alt="enter image description here" /></a></p> <p><strong>UPDATE:</strong></p> <p>If I were to run the above codes and then delete what is under useEffect(), the data will be populated.</p> <pre><code>useEffect(() =&gt; { //delete what is under here }, []); </code></pre> <p>In addition, I happened to experiment using const rows in the page itself. The data was able to populate successfully to the grid. Thus, right now I suppose it has to do with how my codes under useEffect() has some issue?</p> <pre><code>const rows = [ { id: 1, name: &quot;test&quot;, activity: &quot;test&quot;, date: &quot;test&quot; } ] </code></pre>
[ { "answer_id": 74423219, "author": "Winston", "author_id": 12063888, "author_profile": "https://Stackoverflow.com/users/12063888", "pm_score": -1, "selected": false, "text": "var\n FileList: TStringDynArray;\n myfileList: Tstringlist;\n s: string;\n DocDir: string; \nbegin\n DocDir ...
2022/11/13
[ "https://Stackoverflow.com/questions/74422776", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19406817/" ]
74,422,788
<pre><code>block = [(1, 2), (6, 6), (8, 10), (13, 14)] def add_line(block, y): added_line = [] for (x1, x2) in block: added_line += zip((x1, x2), y) return added_line </code></pre> <p>It is supposed to add y to (x1, x2) tuple. Instead it produces TypeError: 'int' object is not iterable. What did I do wrong and where?</p>
[ { "answer_id": 74423219, "author": "Winston", "author_id": 12063888, "author_profile": "https://Stackoverflow.com/users/12063888", "pm_score": -1, "selected": false, "text": "var\n FileList: TStringDynArray;\n myfileList: Tstringlist;\n s: string;\n DocDir: string; \nbegin\n DocDir ...
2022/11/13
[ "https://Stackoverflow.com/questions/74422788", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20468549/" ]
74,422,796
<p>Suppose I've got a table <code>node</code> with two fields : <code>id</code>, and <code>child_id</code> :</p> <pre class="lang-none prettyprint-override"><code>id | name | child_id | ---------------------------- 1 | node1 | NULL | 2 | node2 | 3 | 3 | node3 | NULL | </code></pre> <p>It means that &quot;node1&quot; has no parent and no children, &quot;node2&quot; has no parent and child &quot;node2&quot;, and &quot;node2&quot; has parent &quot;node2&quot; and no children.</p> <p>Now I want to select all &quot;node&quot; that have no <em>parent</em>.<br /> In the example above I should get rows :</p> <pre class="lang-none prettyprint-override"><code>id | name | child_id | ---------------------------- 1 | node1 | NULL | 2 | node2 | 3 | </code></pre> <p>How would you implement this query ?</p>
[ { "answer_id": 74423246, "author": "The Impaler", "author_id": 6436191, "author_profile": "https://Stackoverflow.com/users/6436191", "pm_score": 3, "selected": true, "text": "select c.*\nfrom node c\nleft join node p on c.id = p.child_id\nwhere p.id is null\n" }, { "answer_id": 7...
2022/11/13
[ "https://Stackoverflow.com/questions/74422796", "https://Stackoverflow.com", "https://Stackoverflow.com/users/521070/" ]
74,422,848
<p>I have a table holding transaction dates and counter like this</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>NO CARD</th> <th>DATE</th> <th>COUNTER</th> </tr> </thead> <tbody> <tr> <td>1377370849</td> <td>2022/11/13 11:14:12</td> <td>76</td> </tr> <tr> <td>1377370849</td> <td>2022/11/13 11:14:33</td> <td>77</td> </tr> <tr> <td>1377370849</td> <td>2022/11/13 11:14:45</td> <td>80</td> </tr> <tr> <td>1377370849</td> <td>2022/11/13 11:14:55</td> <td>85</td> </tr> <tr> <td>1377370849</td> <td>2022/11/13 11:24:05</td> <td>86</td> </tr> <tr> <td>1377370849</td> <td>2022/11/13 11:24:11</td> <td>87</td> </tr> <tr> <td>1377370849</td> <td>2022/11/13 11:24:12</td> <td>88</td> </tr> <tr> <td>1377370849</td> <td>2022/11/13 11:24:13</td> <td><strong>12</strong></td> </tr> <tr> <td>1377370849</td> <td>2022/11/13 11:34:10</td> <td>89</td> </tr> <tr> <td>1377370849</td> <td>2022/11/13 11:44:01</td> <td>90</td> </tr> <tr> <td>1377370849</td> <td>2022/11/13 11:44:05</td> <td>91</td> </tr> <tr> <td>1377370849</td> <td>2022/11/13 11:44:11</td> <td>92</td> </tr> <tr> <td>1377370849</td> <td>2022/11/13 11:54:22</td> <td><strong>120</strong></td> </tr> <tr> <td>1377370849</td> <td>2022/11/13 11:54:26</td> <td>93</td> </tr> <tr> <td>1377370849</td> <td>2022/11/13 11:54:32</td> <td>99</td> </tr> <tr> <td>1377370849</td> <td>2022/11/13 11:54:45</td> <td>100</td> </tr> </tbody> </table> </div> <p>I have to find counter 12 and counter 120. The counter is an incrementing counter, and it becomes 1 again at 250. <br> 12 =&gt; counter incrementing but downs to 12 and become 89 again after 12 <br> 120 =&gt; counter jumps to 120 and become 93 after 120</p> <p>How I can write to SQL Query for this. (Oracle 11)</p>
[ { "answer_id": 74423386, "author": "p3consulting", "author_id": 4956336, "author_profile": "https://Stackoverflow.com/users/4956336", "pm_score": 0, "selected": false, "text": "WHERE counter NOT BETWEEN \n CASE WHEN 250 = LAG(counter) OVER(PARTITION BY no_card ORDER BY dat) THEN 0...
2022/11/13
[ "https://Stackoverflow.com/questions/74422848", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20493921/" ]
74,422,849
<pre><code> Stack( children: [ Container( height: MediaQuery.of(context).size.height * 0.5, decoration: BoxDecoration( borderRadius: BorderRadius.only( bottomLeft: Radius.circular(100.0), bottomRight: Radius.circular(100.0)), color: darkBlue, ), ), Positioned( bottom: 0, left: MediaQuery.of(context).size.width / 3, child: CircleAvatar( backgroundColor: white, radius: 70, child: Image.asset('assets/images/homepage.png'))), ], ) </code></pre> <p><a href="https://i.stack.imgur.com/4JJ5i.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4JJ5i.png" alt="enter image description here" /></a></p> <p>When I set the value as bottom : 0 in the code, since the image is inside the Stack, it sees it as a border and moves the image to the bottom of the Stack. But what I want is to place the image in the center of the Container, as shown by the black circle in the image.</p>
[ { "answer_id": 74423386, "author": "p3consulting", "author_id": 4956336, "author_profile": "https://Stackoverflow.com/users/4956336", "pm_score": 0, "selected": false, "text": "WHERE counter NOT BETWEEN \n CASE WHEN 250 = LAG(counter) OVER(PARTITION BY no_card ORDER BY dat) THEN 0...
2022/11/13
[ "https://Stackoverflow.com/questions/74422849", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17906689/" ]
74,422,854
<p>I have some HTML/CSS where I am trying to make use of Bootstrap 5.2 and <code>justify-content-between</code> to push 2 buttons out to the edges of the container.</p> <pre><code>&lt;div class=&quot;container&quot;&gt; &lt;div class=&quot;row&quot;&gt; &lt;div class=&quot;col-12&quot;&gt; &lt;ul class=&quot;d-flex justify-content-center align-items-center bg-grey&quot;&gt; &lt;li&gt;Test&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;div class=&quot;col-12&quot;&gt; &lt;div class=&quot;row justify-content-between&quot;&gt; &lt;div class=&quot;col-2 text-start&quot;&gt; &lt;button class=&quot;btn btn-primary btn-lg&quot;&gt;LEFT&lt;/button&gt; &lt;/div&gt; &lt;div class=&quot;col-2 text-end&quot;&gt; &lt;button class=&quot;btn btn-primary btn-lg&quot;&gt;RIGHT&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>This is how I want it to look - with the <code>LEFT</code> and <code>RIGHT</code> buttons aligned to the edges.</p> <p><a href="https://i.stack.imgur.com/nQZh6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nQZh6.png" alt="enter image description here" /></a></p> <p>It's fine until the viewport reaches anything under 768px wide (sm or xs), at which point the <code>RIGHT</code> button sticks out.</p> <p><a href="https://i.stack.imgur.com/caNHz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/caNHz.png" alt="enter image description here" /></a></p> <p>I can tweak the margin at the relevant responsive break points but it seems like I've got something wrong and shouldn't have to do that.</p> <p>Is there a correct / better way to achieve this?</p>
[ { "answer_id": 74423386, "author": "p3consulting", "author_id": 4956336, "author_profile": "https://Stackoverflow.com/users/4956336", "pm_score": 0, "selected": false, "text": "WHERE counter NOT BETWEEN \n CASE WHEN 250 = LAG(counter) OVER(PARTITION BY no_card ORDER BY dat) THEN 0...
2022/11/13
[ "https://Stackoverflow.com/questions/74422854", "https://Stackoverflow.com", "https://Stackoverflow.com/users/860539/" ]
74,422,859
<p>I just can play the animation once, and I want to play it every time when I click on it.<br /> I'm doing a game like dinosaur of google.<br /> The animation is on paused, and the onClick function from JavaScript does put it on the play.</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>var x = document.getElementById("macaco"); function saltar() { document.getElementById("macaco").style.WebkitAnimationPlayState = "running"; document.getElementById("macaco").style.AnimationPlayState = "running"; }</code></pre> <pre class="snippet-code-css lang-css prettyprint-override"><code>#macaco { background-color : orange; height : 70px; width : 40px; transform : translateX(15vw); position : absolute; bottom : 22px; position : absolute; animation : linear saltar 1s infinite; animation-play-state : paused; } @keyframes saltar { 0% { transform: translatey(0px) translateX(15vw) } 50% { transform: translatey(-120px) translateX(15vw) } 100% { transform: translatey(0px) translateX(15vw) } }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div onclick="saltar()" id="macaco" class="macaco"&gt;&lt;/div&gt; &lt;!-- Macaco --&gt;</code></pre> </div> </div> </p> <p>I tried with adding an event at the end, but don't know how to us the property because I barely read it. Read about toggle, but also don't know how to use it in this case.</p>
[ { "answer_id": 74423386, "author": "p3consulting", "author_id": 4956336, "author_profile": "https://Stackoverflow.com/users/4956336", "pm_score": 0, "selected": false, "text": "WHERE counter NOT BETWEEN \n CASE WHEN 250 = LAG(counter) OVER(PARTITION BY no_card ORDER BY dat) THEN 0...
2022/11/13
[ "https://Stackoverflow.com/questions/74422859", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19764008/" ]
74,422,880
<p>I am making a user profile page for our group app, I want to know that how I can make the size of the picture and the size of the text shrink when I shrink the size of the browser.</p> <p>below are the scss code for classes:</p> <pre><code> .show-picture{ width: 200px; height: 150px; border-radius: 10%; size-adjust:relative; } .Trip_info{ width: 20%; height: 200px; float:left; } .Planner_page{ width: 20%; height: 200px; margin-left:40%; } .Social{ width: 20%; height: 200px; float: left; } .Setting{ width: 20%; height: 200px; margin-left:40%; } .button{ font-size: 2em; letter-spacing: 0px; margin-bottom: 30px; margin: 4px 2px; cursor: pointer; text-align: center; text-decoration: none; color: grey; } </code></pre> <p>I tried to divided them into div of rows but the size will not shrink. And also I tried the width and height auto but that size will be very werid.</p>
[ { "answer_id": 74423460, "author": "macrodev", "author_id": 20494515, "author_profile": "https://Stackoverflow.com/users/20494515", "pm_score": 0, "selected": false, "text": " body{\n margin: 0;\n padding: 0;\n background-color: grey;\n ...
2022/11/13
[ "https://Stackoverflow.com/questions/74422880", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20493933/" ]
74,422,895
<p>I don't understand something in react-redux. I have created a slice called Introduction look below:</p> <pre><code>import { createSlice } from &quot;@reduxjs/toolkit&quot;; import { IntroductionFields } from &quot;../helpers/interface&quot;; const initialState: IntroductionFields = { fullName:'', subtitle:'', description:'', location:'', email:'', portfolio: {name:'' , url:''}, project: {name: '' , url: ''}, learning: '', collaborating: '', else: '', } const Introduction = createSlice({ name: 'intro', initialState, reducers:{ update(state, actions){ const key = actions.payload.name; const val = actions.payload.value; state.fullName = val; // WORK state = {...state, [key]: val} // NO WORK console.log(actions.payload.name , &quot; &quot; , actions.payload.value); }, } }) export const IntroductionActions = Introduction.actions; export default Introduction; </code></pre> <p>and I have two more components, first component has fields (inputs) and every field has an onChange that calls the dispatch and uses update on the reducer that I created in the introduction slice and I send the key and value, see below.</p> <pre><code>const Intro: React.FC&lt;Props&gt; = ({ moveForward }) =&gt; { const dispatch = useDispatch(); const changeHandler = (event: React.ChangeEvent&lt;HTMLInputElement&gt; | React.ChangeEvent&lt;HTMLTextAreaElement&gt;) =&gt; { const {name , value} = event.target; dispatch(IntroductionActions.update({name, value})) } return (.... // HERE I HAVE INPUTS...) } </code></pre> <p>In the second component I want to get the values from the Introduction slice so if I change some fields in Intro component, I want to see the changes in my Preview component.</p> <pre><code>import React, { useEffect } from 'react' import classes from './Preview.module.scss'; import { useSelector } from 'react-redux'; import { RootState } from '../../../store/store'; const Preview = () =&gt; { const introduction = useSelector((state:RootState) =&gt; state.intro); return ( &lt;div className={classes.previewContainer}&gt; {introduction.fullName &amp;&amp; &lt;h1&gt;Hi! My name is {introduction.fullName}&lt;/h1&gt;} &lt;/div&gt; ) } export default Preview </code></pre> <p>If you'll look to the first code section you will see these two lines.</p> <blockquote> <pre><code> state.fullName = val; // WORK state = {...state, [key]: val} // NO WORK </code></pre> </blockquote> <p>If I directly write into the field in state it works prefect, but if I try to do the second line it doesn't work... I want it to be dynamic that is why I want to use the second line...</p>
[ { "answer_id": 74423460, "author": "macrodev", "author_id": 20494515, "author_profile": "https://Stackoverflow.com/users/20494515", "pm_score": 0, "selected": false, "text": " body{\n margin: 0;\n padding: 0;\n background-color: grey;\n ...
2022/11/13
[ "https://Stackoverflow.com/questions/74422895", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14892098/" ]
74,422,929
<p>I want to create new dataframe with using pandas. The table has value name and how many row that value appear</p> <p>In SQL I can create the table that I want like this</p> <pre class="lang-sql prettyprint-override"><code>SELECT start_station_name, COUNT(*) as total_number FROM table GROUP BY start_station_name; </code></pre> <p>But when I used Pandas with assign function I tried in this way</p> <pre class="lang-py prettyprint-override"><code>casual_station_name = pd.DataFrame().assign(station_name = casual_filter['start_station_name'], total_ride = casual_filter['start_station_name'].value_counts() ) </code></pre> <p>But I can not do what I want</p>
[ { "answer_id": 74423460, "author": "macrodev", "author_id": 20494515, "author_profile": "https://Stackoverflow.com/users/20494515", "pm_score": 0, "selected": false, "text": " body{\n margin: 0;\n padding: 0;\n background-color: grey;\n ...
2022/11/13
[ "https://Stackoverflow.com/questions/74422929", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19998696/" ]
74,422,973
<p>I was wondering how to get the max value from every key from a dictionary. Let's say I have this:</p> <p><code>dict={(1,1,True):[-1, 0.26], (2,1,True):[0.1, 0],(1,2,True):[0.01, -1],(2,2,True):[1, -0.11],}</code></p> <p>And this is the expected output:</p> <p><code>new_dict={(1,1,True):0, (2,1,True):0,(1,2,True):1,(2,2,True):0,}</code></p> <p>The new 0 and 1 values means the following:</p> <ul> <li>If the absolute max value is the first element, the output value will be 0. If not, 1.</li> <li>Example: Abs(-1), Abs(0.26)-&gt; 1&gt;0.26 -&gt; 0 will be the expected output.</li> </ul>
[ { "answer_id": 74423460, "author": "macrodev", "author_id": 20494515, "author_profile": "https://Stackoverflow.com/users/20494515", "pm_score": 0, "selected": false, "text": " body{\n margin: 0;\n padding: 0;\n background-color: grey;\n ...
2022/11/13
[ "https://Stackoverflow.com/questions/74422973", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17792314/" ]
74,422,975
<p>I just encountered a problem. I am dockerizing a springboot application with MySQL as a database it is perfectly working in a local setup. But when I try to dockerize the application using <code>docker-compose</code>, MySQL container is working fine and is accessible in my workbench but my application is not able to access it throwing the communication link failure.</p> <p>This is the compose file I am using:</p> <pre class="lang-yaml prettyprint-override"><code>version: &quot;3.8&quot; services: mysqldb: image: mysql:5.7 restart:unless-stopped environment: - MYSQL_ROOT_PASSWORD=root - MYSQL_DATABASE=baskartest ports: - 3307:3306 volumes: - db:/var/lib/mysql app: depends_on: - mysqldb build: ./bezkoder-app restart:on-failure env_file: ./.env ports: - 8084:8080 environment: SPRING_APPLICATION_JSON: '{ &quot;spring.datasource.url&quot; : &quot;jdbc:mysql://mysqldb:3306/baskartest?useSSL=false&quot;, &quot;spring.datasource.username&quot; : &quot;root&quot;, &quot;spring.datasource.password&quot; : &quot;root&quot;, &quot;spring.jpa.properties.hibernate.dialect&quot; : &quot;org.hibernate.dialect.MySQL5InnoDBDialect&quot;, &quot;spring.jpa.hibernate.ddl-auto&quot; : &quot;update&quot; }' volumes: - .m2:/root/.m2 stdin_open: true tty: true </code></pre> <p>MySQL is working fine but my app in services is not able to communicate with it.</p> <p>Here is what I see:</p> <p><img src="https://i.stack.imgur.com/OfGel.png" alt="enter image description here" /></p> <p>Any help would be appreciated!</p>
[ { "answer_id": 74423460, "author": "macrodev", "author_id": 20494515, "author_profile": "https://Stackoverflow.com/users/20494515", "pm_score": 0, "selected": false, "text": " body{\n margin: 0;\n padding: 0;\n background-color: grey;\n ...
2022/11/13
[ "https://Stackoverflow.com/questions/74422975", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20494010/" ]
74,422,983
<p>I want to do correlations for each unique combination and grouped by another variable. My solutions works for a very small dataset buy imagine more columns it's getting very tedious.</p> <pre><code>set.seed((13)) df &lt;- data.frame(group = rep(LETTERS[1:3], 3), var1 = rnorm(9, 1), var2 = rnorm(9, 2), var3 = rnorm(9, 1)) df %&gt;% group_by(group) %&gt;% summarise(var1_var2 = cor(var1, var2), var1_var3 = cor(var1, var3), var2_var3 = cor(var2, var3)) </code></pre> <p>I also tried this one, but it doens't work.</p> <pre><code>df %&gt;% group_by(group) %&gt;% summarise(cor = cor(df[,2:ncol(df)])) </code></pre>
[ { "answer_id": 74423460, "author": "macrodev", "author_id": 20494515, "author_profile": "https://Stackoverflow.com/users/20494515", "pm_score": 0, "selected": false, "text": " body{\n margin: 0;\n padding: 0;\n background-color: grey;\n ...
2022/11/13
[ "https://Stackoverflow.com/questions/74422983", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12367858/" ]
74,422,998
<p>I know i can do it with preventDefault, but i don't know where to set the preventDefault on the code...</p> <pre><code>let navbar = document.querySelector(&quot;.navbar&quot;); document.querySelector(&quot;#menu-btn&quot;).onclick = () =&gt; { navbar.classList.toggle('active'); } window.onscroll = () =&gt; { navbar.classList.remove(&quot;active&quot;); } let hearts = document.querySelectorAll(&quot;.icons a&quot;); hearts.forEach(a =&gt; { a.addEventListener(&quot;click&quot;, ()=&gt; {a.classList.toggle(&quot;color&quot;);} ) }) </code></pre> <p>i think it is in the hearts.forEach block but i don't know where to put it</p>
[ { "answer_id": 74423034, "author": "Bruno Farias", "author_id": 6105926, "author_profile": "https://Stackoverflow.com/users/6105926", "pm_score": 2, "selected": false, "text": "hearts.forEach(a => {\n a.addEventListener(\"click\", (event) => {\n event.preventDefault(); \n a...
2022/11/13
[ "https://Stackoverflow.com/questions/74422998", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19341851/" ]
74,423,033
<p>Assume we have the following graph under R :</p> <pre><code>library(tidyverse) library(&quot;igraph&quot;) library(&quot;rmutil&quot;) library(&quot;cubature&quot;) cities &lt;- data.frame(name=c(&quot;Site A&quot;, &quot;Stantsiya port&quot;, &quot;Sahaidachnoha island&quot;, &quot;Ulyanivka&quot;, &quot;Lyubymivka&quot;,&quot;Dnipro&quot;,&quot;Voronezeh&quot;,&quot;Oryol&quot;,&quot;Hrakove&quot;,&quot;Poltava&quot;,&quot;Suponevo&quot;,&quot;Borshchevka&quot;,&quot;Krestopivshchyna&quot;,&quot;Kalinkavishy&quot;,&quot;Chernobyl&quot;)) relations &lt;- data.frame(from=c(&quot;Site A&quot;, &quot;Stantsiya port&quot;, &quot;Sahaidachnoha island&quot;, &quot;Ulyanivka&quot;, &quot;Lyubymivka&quot;,&quot;Dnipro&quot;, &quot;Voronezeh&quot;, &quot;Voronezeh&quot;, &quot;Oryol&quot;, &quot;Oryol&quot;, &quot;Oryol&quot;,&quot;Hrakove&quot;,&quot;Suponevo&quot;,&quot;Suponevo&quot;,&quot;Suponevo&quot;,&quot;Poltava&quot;,&quot;Krestopivshchyna&quot;,&quot;Borshchevka&quot;,&quot;Krestopivshchyna&quot;,&quot;Kalinkavishy&quot;), to=c(&quot;Stantsiya port&quot;, &quot;Sahaidachnoha island&quot;, &quot;Ulyanivka&quot;, &quot;Lyubymivka&quot;, &quot;Dnipro&quot;, &quot;Voronezeh&quot;,&quot;Oryol&quot;,&quot;Hrakove&quot;,&quot;Hrakove&quot;,&quot;Poltava&quot;,&quot;Suponevo&quot;,&quot;Poltava&quot;,&quot;Poltava&quot;,&quot;Krestopivshchyna&quot;,&quot;Borshchevka&quot;,&quot;Krestopivshchyna&quot;,&quot;Borshchevka&quot;,&quot;Kalinkavishy&quot;,&quot;Kalinkavishy&quot;,&quot;Chernobyl&quot;), weight=c(45, 30, 585, 1050, 493.8, 13800, 7800, 8400, 11400, 11100, 3600, 6000, 12000, 6600, 9000, 12600, 6000, 10200, 3600, 6000 )) g &lt;- graph_from_data_frame(relations, directed=FALSE, vertices=cities) </code></pre> <p>I want to plot this graph so :</p> <pre><code>plot(g, edge.arrow.size=.5, vertex.color=&quot;gold&quot;, vertex.size=15, vertex.frame.color=&quot;gray&quot;, vertex.label.color=&quot;black&quot;, vertex.label.cex=0.8, vertex.label.dist=2, edge.curved=0.2) </code></pre> <p>Output :</p> <p><a href="https://i.stack.imgur.com/L6SnJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/L6SnJ.png" alt="enter image description here" /></a></p> <p>Request : The graph paths / vertices / edges are not obvious in the previous plot , i need more clear / obious one ( edges with associated values if possible ).</p> <p>Thanks</p>
[ { "answer_id": 74423096, "author": "Tou Mou", "author_id": 10945401, "author_profile": "https://Stackoverflow.com/users/10945401", "pm_score": 0, "selected": false, "text": "igraph.options(plot.layout=layout.graphopt, vertex.size=7)\nplot(g)\n" }, { "answer_id": 74423536, "au...
2022/11/13
[ "https://Stackoverflow.com/questions/74423033", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10945401/" ]
74,423,070
<p>I have a plot which have 3 subplots and one dropdown. I want to change the yaxis subplot text when I select one from drowdown. <code>yaxis.title or yaxis2.title</code> is not working.</p> <p><strong>Note: without using dash</strong></p> <p>Is is possible if i can change only 3rd subplot yaxis title text (not 1st and 2nd subplot)?</p> <pre><code>import plotly.graph_objs as go from plotly import subplots trace0 = go.Scatter(x=[1, 2, 3], y=[4, 5, 6], mode=&quot;lines+markers&quot;) trace1 = go.Scatter(x=[1, 2, 3], y=[5, 4, 6], mode=&quot;lines+markers&quot;) trace2 = go.Scatter(x=[1, 2, 3], y=[6, 5, 4], mode=&quot;lines+markers&quot;) fig = subplots.make_subplots(rows=3,cols=1,shared_xaxes=True,horizontal_spacing=0.5) fig.add_trace(trace0, 1, 1) fig.add_trace(trace1, 1, 1) fig.add_trace(trace2, 1, 1) fig.add_trace(trace0, 2, 1) fig.add_trace(trace0, 3, 1) update_menus = [go.layout.Updatemenu( active=0, buttons=list( [dict(label = 'All', method = 'relayout', args = [{'visible': [True, True, True,True,True]}, {'title': 'all', 'showlegend':True}, {'yaxis.title':'fgv','yaxis2.title':'ram','yaxis3.title':'gen'}]), dict(label = 'First', method = 'relayout', args = [{'visible': [True, False, False,True,True]}, # the index of True aligns with the indices of plot traces {'title': 'first', 'showlegend':True}, {'yaxis.title':'fgv','yaxis2.title':'ram','yaxis3.title':'gen'}]), dict(label = 'Second', method = 'relayout', args = [{'visible': [False, True, False,True,True]}, {'title': 'second', 'showlegend':True}, {'yaxis.title':'fgv','yaxis2.title':'ram','yaxis3.title':'gen'}]), dict(label = 'Third', method = 'relayout', args = [{'visible': [False, False, True, False,False]}, {'title': 'third', 'showlegend':True}, {'yaxis.title':'fgv','yaxis2.title':'ram','yaxis3.title':'gen'}]), ]) ) ] fig.show() </code></pre>
[ { "answer_id": 74424068, "author": "Hamzah", "author_id": 16733101, "author_profile": "https://Stackoverflow.com/users/16733101", "pm_score": 2, "selected": true, "text": "update" }, { "answer_id": 74424130, "author": "Derek O", "author_id": 5327068, "author_profile":...
2022/11/13
[ "https://Stackoverflow.com/questions/74423070", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14266997/" ]
74,423,074
<p>I need to make a trolleybus number, which won't repeat for game. For example, there is a number &quot;101&quot; and there musn't be more &quot;101&quot;. How to do that? I have a code, but I know, he won't work and I won't test it lol</p> <pre><code>function giveNumber() local number = math.random(100, 199) local takedNumbers = {} local i = 0 local massiv = i+1 script.Parent.pered.SurfaceGui.TextLabel.Text = number script.Parent.zad.SurfaceGui.TextLabel.Text = number script.Parent.levo.SurfaceGui.TextLabel.Text = number script.Parent.pravo.SurfaceGui.TextLabel.Text = number takedNumbers[massiv] = {number} end script.Parent.Script:giveNumber() // what I wrote here? idk... if number == takedNumbers[massiv] then giveNumber() end </code></pre> <p>i didn't test it, because I think it won't work because this code is something bad</p>
[ { "answer_id": 74424068, "author": "Hamzah", "author_id": 16733101, "author_profile": "https://Stackoverflow.com/users/16733101", "pm_score": 2, "selected": true, "text": "update" }, { "answer_id": 74424130, "author": "Derek O", "author_id": 5327068, "author_profile":...
2022/11/13
[ "https://Stackoverflow.com/questions/74423074", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20494211/" ]
74,423,113
<p><a href="https://i.stack.imgur.com/9pMkT.png" rel="nofollow noreferrer">categories name</a></p> <p><a href="https://i.stack.imgur.com/pDCmZ.png" rel="nofollow noreferrer">pic of datas</a></p> <pre><code>import {useState, useEffect,useMemo} from 'react'; import { gql, useQuery } from '@apollo/client'; import {GET_CLOTHES} from &quot;./GetClothes.js&quot; import ArrowForwardIosIcon from '@mui/icons-material/ArrowForwardIos'; import ArrowBackIosNewIcon from '@mui/icons-material/ArrowBackIosNew'; function Clothes() { const { loading, error, data } = useQuery(GET_CLOTHES); const [products,setProducts] = useState([]); const [index,setIndex] = useState(0); useEffect(() =&gt; { if (data) { setProducts(data.categories.products); console.dir(data.categories.products); } },[data]); //console.dir(products); /* useEffect(() =&gt; { if(!loading &amp;&amp; data){ setProducts(data); } }, [loading, data]) */ if (loading) return 'Loading...' if (error) return `Error! ${error.message}` return &lt;div&gt; { // Products is actually products products?.map((product,index) =&gt; { if (product.name === 'clothes') { //filter // Iterate through products.products to obtain the product data. const {name,brand,description,gallery,category} = product; return &lt;p&gt;{name}&lt;/p&gt; }}) } &lt;/div&gt; } export default Clothes; </code></pre> <p>`</p> <p><a href="https://i.stack.imgur.com/8eyIQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8eyIQ.png" alt="console.log" /></a></p> <p>Hello everyone, I am trying to fetch my datas from graphlq however I can fetch to first data from array but when I try reach one of the nested array I got undefined. How I can solve this issue.</p>
[ { "answer_id": 74423684, "author": "Michel Floyd", "author_id": 2805154, "author_profile": "https://Stackoverflow.com/users/2805154", "pm_score": 1, "selected": false, "text": "data" }, { "answer_id": 74423782, "author": "Angshu31", "author_id": 11459416, "author_prof...
2022/11/13
[ "https://Stackoverflow.com/questions/74423113", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17465034/" ]
74,423,128
<p>It is possible to modify a function argument in-place with the following code snippet:</p> <pre class="lang-rust prettyprint-override"><code>let mut foo = 1; let mut fun: Box&lt;dyn FnMut(&amp;mut i32) -&gt; _&gt; = Box::new(|f| { *f += 1; }); fun(&amp;mut foo); assert_eq!(foo, 2); </code></pre> <p>However, I have the case where the function <code>fun</code> needs to return a future which modifies the argument once the future gets awaited. Basically I have the following scenario:</p> <pre class="lang-rust prettyprint-override"><code>let mut foo = 1; assert_eq!(foo, 1); let mut fun: Box&lt;dyn FnMut(&amp;mut i32) -&gt; _&gt; = Box::new(|f| { async move { *f += 1; } }); fun(&amp;mut foo).await; assert_eq!(foo, 2); </code></pre> <p><a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2021&amp;code=%0A%23%5Btokio%3A%3Amain%5D%0Aasync%20fn%20main()%20%7B%0A%20%20%20%20let%20mut%20foo%20%3D%201%3B%0A%20%20%20%20assert_eq!(foo%2C%201)%3B%0A%20%20%20%20let%20mut%20fun%3A%20Box%3Cdyn%20FnMut(%26mut%20i32)%20-%3E%20_%3E%20%3D%20Box%3A%3Anew(%7Cf%7C%20%7B%0A%20%20%20%20%20%20%20%20async%20move%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20*f%20%2B%3D%201%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D)%3B%0A%20%20%20%20fun(%26mut%20foo)%3B%0A%20%20%20%20assert_eq!(foo%2C%202)%3B%0A%7D%0A" rel="nofollow noreferrer">rust playground</a></p> <p>But this gives the compile error:</p> <pre class="lang-none prettyprint-override"><code>error: lifetime may not live long enough --&gt; src/main.rs:7:9 | 6 | let mut fun: Box&lt;dyn FnMut(&amp;mut i32) -&gt; _&gt; = Box::new(|f| { | -- return type of closure `impl Future&lt;Output = ()&gt;` contains a lifetime `'2` | | | has type `&amp;'1 mut i32` 7 | / async move { 8 | | *f += 1; 9 | | } | |_________^ returning this value requires that `'1` must outlive `'2` error: could not compile `playground` due to previous error </code></pre> <p>I am not sure how to annotate lifetimes in my code snippet above. I have tried <code>Box&lt;dyn FnMut(&amp;'static mut i32) -&gt; _&gt;</code>, but this gives that <code>foo</code> does not live long enough.</p> <p>Is there a way to get this working?</p>
[ { "answer_id": 74423684, "author": "Michel Floyd", "author_id": 2805154, "author_profile": "https://Stackoverflow.com/users/2805154", "pm_score": 1, "selected": false, "text": "data" }, { "answer_id": 74423782, "author": "Angshu31", "author_id": 11459416, "author_prof...
2022/11/13
[ "https://Stackoverflow.com/questions/74423128", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14923227/" ]
74,423,147
<p>I need to create a program in Java that finds all the occurrences of a 4-letter string, in this case <code>&quot;lane&quot;</code>, within the given String.</p> <p>Comparison should be case-insensitive, and the second letter of the matching substring should not be taken into account while evaluating whether a substring matches or not.</p> <p>My current code can handle some cases, but in others it returns an incorrect number of occurrences or produces an <code>IndexOutOfBoundsException</code>.</p> <p>I tried the following cases:</p> <ol> <li><code>&quot;Lanee&quot;</code> - returns <code>1</code>, as expected (<code>&quot;Lane&quot;</code> matches <code>&quot;lane&quot;</code>).</li> <li><code>&quot;LineLone&quot;</code> - returns <code>2</code>, as expected (both <code>&quot;Line&quot;</code> and &quot;Lone&quot;<code>match</code>&quot;lane&quot;`).</li> <li><code>&quot;LLoenLL&quot;</code> - produces an <code>IndexOutOfBoundsException</code>.</li> <li><code>&quot;enaLLLmnee&quot;</code> - returns <code>0</code>, but should be <code>1</code></li> <li><code>&quot;LLONElllneL&quot;</code> - produces an <code>IndexOutOfBoundsException</code>.</li> </ol> <p><em>My code:</em></p> <pre><code>public class Stringer { public Stringer() {} public int getOccurrences(String s) { String lower = s.toLowerCase(); int occurrences = 0; int x = 0; while (x &lt; lower.length()) { int traverser = lower.indexOf(&quot;l&quot;, x); if (traverser != -1 &amp;&amp; lower.length() &gt; 3) { String sub = lower.substring(x += 2, x += 2); if (sub.equals(&quot;ne&quot;)) { occurrences++; } } else { break; } } return occurrences; } } </code></pre> <p>How can I resolve this issue?</p>
[ { "answer_id": 74423684, "author": "Michel Floyd", "author_id": 2805154, "author_profile": "https://Stackoverflow.com/users/2805154", "pm_score": 1, "selected": false, "text": "data" }, { "answer_id": 74423782, "author": "Angshu31", "author_id": 11459416, "author_prof...
2022/11/13
[ "https://Stackoverflow.com/questions/74423147", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13893138/" ]
74,423,153
<p>I receive some data in excel files and I would like to process it in pandas in order to have the proper format and then insert it into a table in sql developer.</p> <p>I found several tutorials in the internet and I tried the following code but I can't understand why is not working.</p> <pre><code>import cx_Oracle import datetime as dt import pandas as pd # connection string in the format # &lt;username&gt;/&lt;password&gt;@&lt;dbHostAddress&gt;:&lt;dbPort&gt;/&lt;dbServiceName&gt; connStr = '&lt;username&gt;/&lt;password&gt;@&lt;dbHostAddress&gt;:&lt;dbPort&gt;/&lt;dbServiceName&gt;' # initialize the connection object conn = None try: # create a connection object conn = cx_Oracle.connect(connStr) # get a cursor object from the connection cur = conn.cursor() # read dataframe from excel df = pd.read_excel('C:...', sheet_name='...', header=11) # reorder the columns as per the requirement df.columns = [&quot;COL_1&quot;,&quot;COL_2&quot;,&quot;COL_3&quot;,&quot;COL_4&quot;] # prepare data insertion rows from dataframe dataInsertionTuples = [tuple(x) for x in df.values] # create sql for data insertion sqlTxt = 'INSERT INTO MYTABLE\ (COL_1, COL_2, COL_3, COL_4)\ VALUES (:1, :2, :3, :4)' # execute the sql to perform data extraction cur.executemany(sqlTxt, dataInsertionTuples) rowCount = cur.rowcount print(&quot;number of inserted rows =&quot;, rowCount) # commit the changes conn.commit() except Exception as err: print('Error while inserting rows into db') print(err) finally: if(conn): # close the cursor object to avoid memory leaks cur.close() # close the connection object also conn.close() print(&quot;number of inserted rows =&quot;, rowCount) </code></pre> <p>The error that I get is <code>expecting Number</code> Does anyone understand what I am doing wrong. Here i use the username and pass that I have in the DB then the &quot;HOST&quot;, &quot;PORT&quot; and &quot;Service Name&quot; from the tns file. connStr = '/@:/'</p> <p>Also i am using a VPN to connect to my db, i don't know if that affects. But anyway while I am executing this script I am connected to the VPN.</p>
[ { "answer_id": 74423684, "author": "Michel Floyd", "author_id": 2805154, "author_profile": "https://Stackoverflow.com/users/2805154", "pm_score": 1, "selected": false, "text": "data" }, { "answer_id": 74423782, "author": "Angshu31", "author_id": 11459416, "author_prof...
2022/11/13
[ "https://Stackoverflow.com/questions/74423153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15212664/" ]
74,423,168
<p>As title states, after <a href="https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_excel.html" rel="nofollow noreferrer">reviewing docs</a></p> <p>I am reading an .xlsx file, with a column 'HOUR' which has many values, when an instance has value 99, i want to convert to None</p> <p>I have tried the na_values param with different values:</p> <pre><code>na_values = ['99'] na_values = [r'99'] na_values = 99 ... </code></pre> <p>To then read the excel like this:</p> <pre><code>accidents = pd.read_excel(filename, sheet_name= 'datos', na_values=[99]) </code></pre> <p>but it doesn't seem to work, when i do:</p> <pre><code>np.sum(accidents['HOUR'] == 99) </code></pre> <p>I get a value &gt; than 0 (which means the instances with value = 99 have not been transformed to None/NaN)</p> <p>I have also read that i should include the option</p> <pre><code>keep_default_na=False </code></pre> <p>but to no avail.</p> <p>The values of the 'HOUR' column are:</p> <pre><code>accidents['HOUR'].unique() array([ 8, 15, 9, 14, 11, 0, 13, 20, 3, 19, 17, 7, 22, 21, 16, 6, 23, 18, 10, 12, 1, 99, 4, 5, 2, 24], dtype=int64) </code></pre> <p>I have updated my pandas version to 1.5.1 and it still doesn't work, any ideas why?</p> <p>.xls file can be found in: <a href="http://www.transtats.bts.gov/Fields.asp?Table_ID=1158" rel="nofollow noreferrer">http://www.transtats.bts.gov/Fields.asp?Table_ID=1158</a></p> <p>Thank you</p>
[ { "answer_id": 74423684, "author": "Michel Floyd", "author_id": 2805154, "author_profile": "https://Stackoverflow.com/users/2805154", "pm_score": 1, "selected": false, "text": "data" }, { "answer_id": 74423782, "author": "Angshu31", "author_id": 11459416, "author_prof...
2022/11/13
[ "https://Stackoverflow.com/questions/74423168", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20494239/" ]
74,423,171
<p>This was also on streamlit <a href="https://discuss.streamlit.io/t/upload-image-to-drive-from-numpy-ndarray/27363/4?u=srinu" rel="nofollow noreferrer">discussion</a></p> <p>I want to help others who are facing the same problem!</p>
[ { "answer_id": 74423226, "author": "NAGA VENKATA SRINIVAS MENTA", "author_id": 14964109, "author_profile": "https://Stackoverflow.com/users/14964109", "pm_score": 1, "selected": false, "text": "st.file_uploader()" }, { "answer_id": 74430715, "author": "ferdy", "author_id"...
2022/11/13
[ "https://Stackoverflow.com/questions/74423171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14964109/" ]
74,423,229
<p>I'm stuck with the below scenarios. This is working fine on the local computer, however with GCP+NodeJs is not working.</p> <p>Problem - I have an API that generates QR-Images using <a href="https://www.npmjs.com/package/qr-image" rel="nofollow noreferrer">https://www.npmjs.com/package/qr-image</a>, then it creates a zip using <a href="https://www.npmjs.com/package/archiver" rel="nofollow noreferrer">https://www.npmjs.com/package/archiver</a>. Once the archive is done, it uses the nodemailer(<a href="https://www.npmjs.com/package/nodemailer" rel="nofollow noreferrer">https://www.npmjs.com/package/nodemailer</a>) to send the mail.</p> <p>Now, to store the generated image &amp; archieve processing I'm using the <code>fs</code> library of NPM.</p> <p>GCP Configuration - It's dynamic/Flexi app engine where the node app is deployed.</p> <p>The mkdir function is giving the problem. I don't want to use bucket for simple stuff. Is there any other way, I can use the existing code without a tweak to send mail using nodemail (after archiving files(qr codes))?</p> <p>Tried the API on the local computer working. For the mail test using mailtrap.io which seems to be working well. But not with GCP.</p> <p>It is clear some GCP tweak is needed or some node/express JS magic.</p> <p>Code part which is triggering the error -</p> <pre class="lang-js prettyprint-override"><code>const codesFolder = 'codes'; if (!fs.existsSync(codesFolder)) { fs.mkdirSync(codesFolder); } </code></pre> <p>Error from the GCP Log -</p> <pre><code>2022-11-13 18:48:58 default[20221113t223118] Processing email 2022-11-13 18:48:58 default[20221113t223118] /workspace/node_modules/mysql/lib/protocol/Parser.js:437 2022-11-13 18:48:58 default[20221113t223118] throw err; // Rethrow non-MySQL errors 2022-11-13 18:48:58 default[20221113t223118] ^ 2022-11-13 18:48:58 default[20221113t223118] Error: EROFS: read-only file system, mkdir 'codes' at Object.mkdirSync (node:fs:1382:3) at Query.&lt;anonymous&gt; (/workspace/index.js:243:16) at Query.&lt;anonymous&gt; (/workspace/node_modules/mysql/lib/Connection.js:526:10) at Query._callback (/workspace/node_modules/mysql/lib/Connection.js:488:16) at Query.Sequence.end (/workspace/node_modules/mysql/lib/protocol/sequences/Sequence.js:83:24) at Query._handleFinalResultPacket (/workspace/node_modules/mysql/lib/protocol/sequences/Query.js:149:8) at Query.EofPacket (/workspace/node_modules/mysql/lib/protocol/sequences/Query.js:133:8) at Protocol._parsePacket (/workspace/node_modules/mysql/lib/protocol/Protocol.js:291:23) at Parser._parsePacket (/workspace/node_modules/mysql/lib/protocol/Parser.js:433:10) at Parser.write (/workspace/node_modules/mysql/lib/protocol/Parser.js:43:10) { 2022-11-13 18:48:58 default[20221113t223118] errno: -30, 2022-11-13 18:48:58 default[20221113t223118] syscall: 'mkdir', 2022-11-13 18:48:58 default[20221113t223118] code: 'EROFS', 2022-11-13 18:48:58 default[20221113t223118] path: 'codes' 2022-11-13 18:48:58 default[20221113t223118] } </code></pre> <p>App.YAML file</p> <pre class="lang-yaml prettyprint-override"><code>runtime: nodejs16 env_variables: # The following environment variables are set for all instances # of the app. NODE_ENV : &quot;production&quot; </code></pre>
[ { "answer_id": 74460333, "author": "Ysr Shk", "author_id": 3402693, "author_profile": "https://Stackoverflow.com/users/3402693", "pm_score": 1, "selected": true, "text": "runtime: nodejs\nenv: flex\n\nenv_variables:\n # The following environment variables are set for all instances\n # ...
2022/11/13
[ "https://Stackoverflow.com/questions/74423229", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3402693/" ]
74,423,248
<p>I am trying to iterate through all the letters in the list, although i am not making much progress.</p> <p>EX:</p> <pre><code>L = [&quot;pizza&quot;,&quot;burger&quot;,&quot;shawarma&quot;,&quot;nuggets&quot;] </code></pre> <p>the program should output</p> <pre class="lang-none prettyprint-override"><code>p b s n i u h u z r a g </code></pre> <p>and so on, basically iterating the words by their indexes.</p> <p>I tried doing it by a for loop like this:</p> <pre><code>newlist = [i[0] for i in a] </code></pre> <p>Which only outputs the first letters in the list. I am wondering about how to iterate it to have all the indexes if it is possible.</p>
[ { "answer_id": 74460333, "author": "Ysr Shk", "author_id": 3402693, "author_profile": "https://Stackoverflow.com/users/3402693", "pm_score": 1, "selected": true, "text": "runtime: nodejs\nenv: flex\n\nenv_variables:\n # The following environment variables are set for all instances\n # ...
2022/11/13
[ "https://Stackoverflow.com/questions/74423248", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20487116/" ]
74,423,270
<p>I would like to take the word &quot;buy&quot;</p> <pre><code>browser.find_element_by_xpath(&quot;//*[@id='js-commentaire']&quot;) print(commentaire) </code></pre> <p>and i also did</p> <pre><code>browser.find_element_by_id(&quot;js-commentaire&quot;) print(commentaire) </code></pre> <p>This the source code</p> <pre><code>&quot;div class=&quot;col-6 form-control form-control-sm overflow-auto&quot; id=&quot;js-commentaire&quot;&gt; buy&lt;/div&quot; </code></pre>
[ { "answer_id": 74460333, "author": "Ysr Shk", "author_id": 3402693, "author_profile": "https://Stackoverflow.com/users/3402693", "pm_score": 1, "selected": true, "text": "runtime: nodejs\nenv: flex\n\nenv_variables:\n # The following environment variables are set for all instances\n # ...
2022/11/13
[ "https://Stackoverflow.com/questions/74423270", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20460828/" ]
74,423,272
<p>I have such code that can't be compiled:</p> <pre><code>fn my_cool_replace&lt;T: Copy&gt;(arr: &amp;mut [T]) { swap(&amp;mut arr[2], &amp;mut arr[5]); } fn swap&lt;T: Copy&gt;(a: &amp;mut T, b: &amp;mut T) { let c: T = *a; *a = *b; *b = c; } </code></pre> <p>The error is:</p> <pre><code>error[E0499]: cannot borrow `arr[_]` as mutable more than once at a time </code></pre> <p>I want the function <code>my_cool_replace</code> to replace 2-th and 5-th elements in the given mutable slice of an array or a vector. Why do I have such error and what is the best way to fix it?</p>
[ { "answer_id": 74423423, "author": "Pandemonium", "author_id": 1965774, "author_profile": "https://Stackoverflow.com/users/1965774", "pm_score": 3, "selected": true, "text": "swap" }, { "answer_id": 74436322, "author": "Kaplan", "author_id": 11199879, "author_profile"...
2022/11/13
[ "https://Stackoverflow.com/questions/74423272", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3467698/" ]
74,423,293
<p>If you have two classes, class a and class b, could you create a variable in class a from class b? <strong>main.cpp</strong></p> <pre class="lang-cpp prettyprint-override"><code>class A { public: A() {} }; class B { public: B() { test = A(); test.&lt;variable name&gt; = &lt;variable value&gt;; } }; </code></pre> <p>The code above is just an example. It will probably cause an error.</p> <p>&quot;variable name&quot; doesn't exist in class A. Is there a way to create this variable for class A in the constructor for class B?</p>
[ { "answer_id": 74423423, "author": "Pandemonium", "author_id": 1965774, "author_profile": "https://Stackoverflow.com/users/1965774", "pm_score": 3, "selected": true, "text": "swap" }, { "answer_id": 74436322, "author": "Kaplan", "author_id": 11199879, "author_profile"...
2022/11/13
[ "https://Stackoverflow.com/questions/74423293", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18131236/" ]
74,423,308
<p>I take it from the database and send it via ajax (wordpress). Everything works fine, except that I don't get the <strong>first row</strong> from the database. As I read on the Internet, a similar problem is in the array, maybe. Can someone explain and help me fix it so that all rows are displayed?</p> <p>Code:</p> <pre><code>$sql = $wpdb-&gt;prepare( &quot;SELECT * FROM users&quot; ); $count = 0; $user_object = array(); foreach( $wpdb-&gt;get_results( $sql ) as $key =&gt; $row ) { $user_id = $row-&gt;user_ID; $user_name = $row-&gt;user_name; $user_object[$count]= array( &quot;user_ID&quot;=&gt;$user_id, &quot;user_name&quot;=&gt;$user_name, ); $count++; } return wp_send_json( $user_object ); </code></pre>
[ { "answer_id": 74425143, "author": "mickmackusa", "author_id": 2943403, "author_profile": "https://Stackoverflow.com/users/2943403", "pm_score": 3, "selected": true, "text": "prepare()" }, { "answer_id": 74426832, "author": "zillionera_dev", "author_id": 15306153, "au...
2022/11/13
[ "https://Stackoverflow.com/questions/74423308", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11593555/" ]
74,423,320
<p>How can I use sys.argv to ask for user input instead of input? I started this program using input but I want the program to use sys.argv instead.</p> <p>here is my code:</p> <pre><code>import turtle import random import statistics name=input(&quot;Please enter Pa,Mi-Ma,Reg, or All: &quot;) stepper=int(input(&quot;Please enter number of steps: &quot;)) reps=int(input(&quot;Please input number of trials: &quot;)) TOTAL=0 TOTAL2=0 TOTAL3=0 list=[] list2=[] list3=[] def PaWalk(steps): x,y=0,0 for _ in range(steps): (dx,dy)=random.choice([(0,1),(0,-1),(1,0),(-1,0)]) x+=dx y+=dy return(x,y) def miMaWalk(steps): (x,y)=(0,0) for _ in range(steps): (dx,dy)=random.choice([(0,1),(0,-2),(1,0),(-1,0)]) x+=dx y+=dy return(x,y) def Reg(steps): (x,y) = 0,0 for _ in range(steps): (dx,dy) = random.choice([(1,0),(-1,0)]) x += dx y += dy return(x,y) for i in range(reps): if name == 'Pa': walk = PaWalk(stepper) list.append(abs(walk[0]+abs(walk[1]))) TOTAL += abs(walk[0]+abs(walk[1])) if stepper== 100: turtle.pencolor(&quot;green&quot;) turtle.penup() turtle.tracer(0,0) for i in range(stepper): turtle.goto(walk[0]*3,walk[1]*3) turtle.stamp() turtle.hideturtle() turtle.update() elif name == 'Mi-Ma': walk2 = miMaWalk(stepper) list.append(abs(walk2[0]+abs(walk2[1]))) TOTAL += abs(walk2[0]+abs(walk2[1])) if stepper == 100: turtle.pencolor(&quot;red&quot;) turtle.penup() turtle.tracer(0,0) for _ in range(stepper): turtle.goto(walk2[0]*3,walk2[1]*3) turtle.stamp() turtle.hideturtle() turtle.update() elif name == 'Reg': walk3 = Reg(stepper) list.append(abs(walk3[0]+abs(walk3[1]))) TOTAL += abs(walk3[0]+abs(walk3[1])) if stepper == 100: turtle.pencolor(&quot;blue&quot;) turtle.penup() turtle.tracer(0,0) for _ in range(stepper): turtle.goto(walk3[0]*3,walk3[1]*3) turtle.stamp() turtle.hideturtle() turtle.update() elif name == 'All': walk=PaWalk(stepper) walk2=miMaWalk(stepper) walk3=Reg(stepper) list.append(abs(walk[0]+abs(walk[1]))) TOTAL += abs(walk[0]+abs(walk[1])) list2.append(abs(walk2[0]+abs(walk2[1]))) TOTAL2 += abs(walk2[0]+abs(walk2[1])) list3.append(abs(walk3[0]+abs(walk3[1]))) TOTAL3 += abs(walk3[0]+abs(walk3[1])) if stepper == 100: pa=turtle.Turtle() reg=turtle.Turtle() turtle.pencolor(&quot;Green&quot;) pa.pencolor(&quot;Red&quot;) reg.pencolor(&quot;Blue&quot;) reg.penup() turtle.penup() pa.penup() turtle.tracer(0,0) for i in range(stepper): turtle.speed(0) turtle.goto(walk[0]*5,walk[1]*5) pa.goto(walk2[0]*5,walk2[1]*5) reg.goto(walk3[0]*5,walk3[1]*5) reg.stamp() pa.stamp() turtle.stamp() turtle.hideturtle() turtle.update() MEAN = TOTAL/reps MEAN2 = TOTAL2/reps MEAN3 = TOTAL3/reps if name == &quot;All&quot;: print('Pa random walk of ' + str(stepper)) print(&quot;mean: &quot;+str(MEAN)) print('max: '+str(max(list))) print('min: '+str(min(list))) print('CV: '+str(round(statistics.pstdev(list)/MEAN, 2))) print('Mi-Ma random walk of ' +str(stepper)) print(&quot;mean: &quot;+str(MEAN2)) print('max: '+str(max(list2))) print('min: '+str(min(list2))) print('CV: '+str(round(statistics.pstdev(list2)/MEAN2, 2))) print('Reg random walk of ' +str(stepper)) print(&quot;mean: &quot;+str(MEAN3)) print('max: '+str(max(list3))) print('min: '+str(min(list3))) print('CV: '+str(round(statistics.pstdev(list3)/MEAN3, 2))) elif name== 'Pa' or 'Mi-Ma' or 'Reg': print(name, &quot;random walk of &quot;+str(stepper)) print(&quot;mean: &quot;+str(MEAN)) print('max: '+str(max(list))) print('min: '+str(min(list))) print('CV: '+str(round(statistics.pstdev(list)/MEAN, 2))) </code></pre> <p>I'm not an expert so I'm not entirely familiar with how sys.argv works but I would rather have my program take a command line argument instead of input. Anything helps, thanks.</p>
[ { "answer_id": 74425143, "author": "mickmackusa", "author_id": 2943403, "author_profile": "https://Stackoverflow.com/users/2943403", "pm_score": 3, "selected": true, "text": "prepare()" }, { "answer_id": 74426832, "author": "zillionera_dev", "author_id": 15306153, "au...
2022/11/13
[ "https://Stackoverflow.com/questions/74423320", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20352630/" ]
74,423,348
<p>I'm learning React (v18) and I've tried implementing some similar solutions that I've found here, but so far no success. I have been trying display &quot;cards&quot; with names and pictures from a list of authors; the url for the each picture is remote (for example from wikipedia):</p> <pre><code>export const Authors = () =&gt; { const authors = [ { id: 1, name: 'Tayeb Salih', wikipedia: 'https://en.wikipedia.org/wiki/Tayeb_Salih', picture_url: 'https://upload.wikimedia.org/wikipedia/commons/a/ae/Tayeb_saleh.jpg' }, { id: 2, name: 'Adolfo Bioy Casares', wikipedia: 'https://en.wikipedia.org/wiki/Adolfo_Bioy_Casares', picture_url: 'https://upload.wikimedia.org/wikipedia/commons/a/a9/Bioy.png' }, { id: 3, name: 'Lucy Foley', wikipedia: 'https://en.wikipedia.org/wiki/Lucy_Foley', picture_url: 'https://www.intrinseca.com.br/upload/autor/Lucy%20Foley%20G.jpg' }, { id: 4, name: 'Matt Ruff', wikipedia: 'https://en.wikipedia.org/wiki/Matt_Ruff', picture_url: 'https://images.gr-assets.com/authors/1597587995p5/40577.jpg' }]; const cards:any[] = []; authors.forEach((author, index) =&gt; { const borderColor = index &gt; 1 ? null : index &gt; 0 ? '#57b60a' : '#b60a57'; const item = ( &lt;Card borderColor={borderColor} title={author.name} subtitle={author.id.toString()} key={index}&gt; &lt;img src={require(`${author.picture_url}`)} alt={author.name} /&gt; &lt;/Card&gt; ); cards.push(item); }); return ( &lt;section id=&quot;section-authors&quot;&gt; &lt;h1&gt;Authors&lt;/h1&gt; &lt;div className=&quot;group-cards&quot;&gt; {cards} &lt;/div&gt; &lt;img src=&quot;https://upload.wikimedia.org/wikipedia/commons/a/a9/Bioy.png&quot; alt=&quot;&quot; height=&quot;200&quot; /&gt; &lt;/section&gt; ); }; </code></pre> <p>In this way I get the following error: <em>Uncaught Error: Cannot find module 'https://upload.wikimedia.org/wikipedia/commons/a/ae/Tayeb_saleh.jpg'</em>.</p> <p>When I change the code to <code>&lt;img src={require(author.picture_url)} alt={author.name} /&gt;</code>, the same error occurs.</p> <p>If I trying use only <code>&lt;img src={author.picture_url} alt={author.name} /&gt;</code>, error: *Uncaught Error: img is a void element tag and must neither have <code>children</code> nor use <code>dangerouslySetInnerHTM*... then, with a little bit of insanity: ```&lt;img src={</code>${author.picture_url}`} alt={author.name} /&gt;```... same error...</p> <p>What's wrong anyway?</p> <h1><strong>EDITED</strong> including <code>&lt;Card/&gt;</code></h1> <pre><code>export const Card = (props: { title?: string | null | undefined; subtitle?: string | null | undefined; borderColor?: string | null | undefined; children?: any; }) =&gt; { const cardStyle = { borderColor: props.borderColor || '#ded3d3', }; return ( &lt;div className=&quot;card-minhoteca&quot; style={cardStyle}&gt; &lt;CardHeader title={props.title} subtitle={props.subtitle} /&gt; &lt;CardBody&gt; { React.Children.map(props.children, (child, i) =&gt; { return React.cloneElement(child, { ...props, key: i }); }) } &lt;/CardBody&gt; &lt;CardFooter&gt; &lt;p&gt;Card Footer&lt;/p&gt; &lt;/CardFooter&gt; &lt;/div&gt; ); }; export const CardHeader = (props: { title?: string; subtitle?: string; }) =&gt; { return ( &lt;div className=&quot;card-header&quot;&gt; &lt;h3 className=&quot;title&quot;&gt;{props.title}&lt;/h3&gt; &lt;h4 className=&quot;card-subtitle&quot;&gt;{props.subtitle}&lt;/h4&gt; &lt;/div&gt; ); }; export const CardBody = (props: { children?: any }) =&gt; { return ( &lt;div className=&quot;card-body&quot;&gt; {props.children} &lt;/div&gt; ); }; export const CardFooter = (props: { children?: any; callBack?: any; }) =&gt; { return ( &lt;div className=&quot;card-footer&quot;&gt; {props.children} &lt;button onClick={(e) =&gt; { e.preventDefault(); props.callBack(); }}&gt;Click!&lt;/button&gt; &lt;/div&gt; ); }; </code></pre>
[ { "answer_id": 74423434, "author": "John Li", "author_id": 20436957, "author_profile": "https://Stackoverflow.com/users/20436957", "pm_score": 2, "selected": true, "text": "{props.children}" } ]
2022/11/13
[ "https://Stackoverflow.com/questions/74423348", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2417587/" ]
74,423,356
<p>I have been learning Flutter for some time trying to understand from existing Flutter projects, so the code that will follow is not mine.</p> <p>Currently I am testing a project but I am facing an error that I had never seen.</p> <pre><code>The getter 'length' was called on null. Receiver: null Tried calling: length </code></pre> <p>I think it comes from this part of the code.</p> <pre><code>StreamBuilder&lt;List&lt;DocumentSnapshot&gt;&gt;( stream: postListBloc.postStream, builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) return Center( child: CircularProgressIndicator(), ); else { int presentLength = snapshot.data.length; return ListView.builder( physics: NeverScrollableScrollPhysics(), shrinkWrap: true, itemCount: snapshot.data.length, itemBuilder: (context, index) { DocumentSnapshot documentSnapshot = snapshot.data[index]; String id = documentSnapshot.id; debugPrint('${snapshot.data.length}'); return Column(children: [ Padding( padding: EdgeInsets.only(bottom: 10), child: PostCardView( documentSnapshot.get('community'), id, true)), (index != snapshot.data.length - 1) ? Container() : buildProgressIndicator(presentLength) ]); }); } }, ), </code></pre> <p>I have searched here for different solutions but so far nothing has worked.</p> <p>If anyone knows how to solve this problem.</p>
[ { "answer_id": 74423434, "author": "John Li", "author_id": 20436957, "author_profile": "https://Stackoverflow.com/users/20436957", "pm_score": 2, "selected": true, "text": "{props.children}" } ]
2022/11/13
[ "https://Stackoverflow.com/questions/74423356", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20494351/" ]
74,423,368
<p>I have created a VSTO excel plug-in, which is supposed to store a comment text in a database each time the comment has been changed.</p> <p>(I'm giving you the code example in VBA since usually this is where I test initial ideas first)</p> <p>When a comment is selected TypeName(Selection) returns “TextBox” <a href="https://i.stack.imgur.com/CtY7k.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CtY7k.png" alt="enter image description here" /></a></p> <p>so what I initially thought would work is to put it into Workbook_SheetSelectionChange:</p> <pre><code>Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range) If TypeName(Target) = &quot;TextBox&quot; Then 'let the user enter or change the comment 'once the user has done that and changes the selection 'trigger the save option to DB End If End Sub </code></pre> <p>The problem is that selecting the comment does not trigger Workbook_SheetSelectionChange. Any suggestions on how to approach this problem is much appreciated.</p>
[ { "answer_id": 74423505, "author": "user3598756", "author_id": 3598756, "author_profile": "https://Stackoverflow.com/users/3598756", "pm_score": 2, "selected": false, "text": "Option Explicit\n\nDim lastAddress As String\nDim cmtAddress As String\nDim cmtText As String\n\nPrivate Sub Wor...
2022/11/13
[ "https://Stackoverflow.com/questions/74423368", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4021971/" ]
74,423,373
<p>I have attached a screenshot of the original table and the desired result.</p> <p>What I want is basically to return records from an excel table based on a single criterion (CustomerID), sort the results on another criterion (Date), attach discontiguous columns from an original table, and return only n-rows from that filtered selection (in this case last 3)?</p> <p>Is there a way to do it in a single step without the use of helper formulas or helper tables including RANK, LARGE, and so on?</p> <p>Thanks</p> <p><a href="https://i.stack.imgur.com/f0PoZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/f0PoZ.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74423736, "author": "David Leal", "author_id": 6237093, "author_profile": "https://Stackoverflow.com/users/6237093", "pm_score": 1, "selected": false, "text": "J2" }, { "answer_id": 74423744, "author": "Mayukh Bhattacharya", "author_id": 8162520, "autho...
2022/11/13
[ "https://Stackoverflow.com/questions/74423373", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9178508/" ]
74,423,399
<p>I have a POJO.</p> <pre><code>@Data @AllArgsConstructor @Builder public class Emp { private String name; private String position; } </code></pre> <p>Suppose, we have created an object</p> <pre><code>Emp emp = new Emp(&quot;Manager&quot;, &quot;Bob&quot;); </code></pre> <p>How can I convert it to a list and save it in a database in JSON format?</p> <p>The data should be stored in the database in the format below:</p> <pre><code>{ list:[ { position: Manager name: Bob } ] } </code></pre> <p>Are there any ready solutions for that?</p> <p>I converted an object into a list and then I called the .toString() method on it:</p> <pre><code>Collections.singletonList(emp); </code></pre> <p>But when I store it in the database, the next save goes to the database:</p> <pre><code>[Emp(position=Manager, name=Bob)] </code></pre> <p>But I need to store the record in a different way</p>
[ { "answer_id": 74423512, "author": "KunalVarpe", "author_id": 3649352, "author_profile": "https://Stackoverflow.com/users/3649352", "pm_score": -1, "selected": false, "text": "ObjectMapper" }, { "answer_id": 74424173, "author": "Alexander Ivanchenko", "author_id": 1794994...
2022/11/13
[ "https://Stackoverflow.com/questions/74423399", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16793182/" ]
74,423,401
<p>I have an array within an array with dates and an amount <code>var finances = [ ['jan', 25000], ['feb', 22000], ['mars', 21000] ] </code> I want to find out by how much the number changes each month. Then I want to find the difference between this change each month and add it up. I thought I had it but it is not working as I thought and I am really lost. I think I may be trying it completely the wrong way. Sorry if this is poorly worded.</p> <p>I want to get the average of the amount the number changes by each month. At the moment I ma getting NAN.</p> <pre><code>var finances = [ ['Jan-2010', 867884], ['Feb-2010', 984655], ['Mar-2010', 322013], ['Apr-2010', -69417], ['May-2010', 310503], ['Jun-2010', 522857], ['Jul-2010', 1033096], ['Aug-2010', 604885], ['Sep-2010', -216386], ['Oct-2010', 477532], ['Nov-2010', 893810], ['Dec-2010', -80353], ['Jan-2011', 779806], ['Feb-2011', -335203], ['Mar-2011', 697845], ['Apr-2011', 793163], ['May-2011', 485070], ['Jun-2011', 584122], ['Jul-2011', 62729], ['Aug-2011', 668179], ['Sep-2011', 899906], ['Oct-2011', 834719], ['Nov-2011', 132003], ['Dec-2011', 309978], ['Jan-2012', -755566], ['Feb-2012', 1170593], ['Mar-2012', 252788], ['Apr-2012', 1151518], ['May-2012', 817256], ['Jun-2012', 570757], ['Jul-2012', 506702], ['Aug-2012', -1022534], ['Sep-2012', 475062], ['Oct-2012', 779976], ['Nov-2012', 144175], ['Dec-2012', 542494], ['Jan-2013', 359333], ['Feb-2013', 321469], ['Mar-2013', 67780], ['Apr-2013', 471435], ['May-2013', 565603], ['Jun-2013', 872480], ['Jul-2013', 789480], ['Aug-2013', 999942], ['Sep-2013', -1196225], ['Oct-2013', 268997], ['Nov-2013', -687986], ['Dec-2013', 1150461], ['Jan-2014', 682458], ['Feb-2014', 617856], ['Mar-2014', 824098], ['Apr-2014', 581943], ['May-2014', 132864], ['Jun-2014', 448062], ['Jul-2014', 689161], ['Aug-2014', 800701], ['Sep-2014', 1166643], ['Oct-2014', 947333], ['Nov-2014', 578668], ['Dec-2014', 988505], ['Jan-2015', 1139715], ['Feb-2015', 1029471], ['Mar-2015', 687533], ['Apr-2015', -524626], ['May-2015', 158620], ['Jun-2015', 87795], ['Jul-2015', 423389], ['Aug-2015', 840723], ['Sep-2015', 568529], ['Oct-2015', 332067], ['Nov-2015', 989499], ['Dec-2015', 778237], ['Jan-2016', 650000], ['Feb-2016', -1100387], ['Mar-2016', -174946], ['Apr-2016', 757143], ['May-2016', 445709], ['Jun-2016', 712961], ['Jul-2016', -1163797], ['Aug-2016', 569899], ['Sep-2016', 768450], ['Oct-2016', 102685], ['Nov-2016', 795914], ['Dec-2016', 60988], ['Jan-2017', 138230], ['Feb-2017', 671099] ]; for (var i = 0; i &lt; finances.length; i++) { for (var j = 0; j &lt; finances[i].length; j++) { if (typeof finances[i][j] !== 'string') { onlyNumbers.push(finances[i][j]) console.log(finances[i][j]); amountTotal = amountTotal + (finances[i][j]); } } } </code></pre> <pre><code>for (var k = 1; k &lt; onlyNumbers.length; k++) { monthlyChanges.push(onlyNumbers[k] - onlyNumbers[k - 1]); } for (var m = 1; m &lt; monthlyChanges.length; m++) { monthlyChangesArray.push(monthlyChanges[m] - monthlyChanges[m - 1]); monthlyChangesAmount = monthlyChangesAmount + (monthlyChangesArray[m]); } console.log(onlyNumbers); console.log(amountTotal); console.log(monthlyChanges); console.log(monthlyChangesArray); console.log(monthlyChangesAmount); </code></pre> <pre><code></code></pre>
[ { "answer_id": 74423512, "author": "KunalVarpe", "author_id": 3649352, "author_profile": "https://Stackoverflow.com/users/3649352", "pm_score": -1, "selected": false, "text": "ObjectMapper" }, { "answer_id": 74424173, "author": "Alexander Ivanchenko", "author_id": 1794994...
2022/11/13
[ "https://Stackoverflow.com/questions/74423401", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19604754/" ]
74,423,412
<p>I wanted to create a python program with user defined function which should read a year entered by user and return True/False by checking whether the entered year is a leap year or not.</p> <p>This is what I tried</p> <pre><code>def is_leap(year): leap = False if(year%4==0): if(year%100!=0): if(year%400==0): leap= True else: leap= False else: leap= False else: leap= False return leap year = int(input()) print(is_leap(year)) </code></pre> <p>And I am not getting the desired output.</p> <p>I tried this code with following two inputs</p> <pre><code>2024 </code></pre> <p>Output was</p> <pre><code>False </code></pre> <p>And</p> <pre><code>2023 </code></pre> <p>Output was</p> <pre><code>False </code></pre> <p>What am I missing here?</p>
[ { "answer_id": 74423426, "author": "mozway", "author_id": 16343464, "author_profile": "https://Stackoverflow.com/users/16343464", "pm_score": 0, "selected": false, "text": "def is_leap(year):\n if (year%4==0) and (year%100!=0) or (year%400==0):\n return True\n return False\n...
2022/11/13
[ "https://Stackoverflow.com/questions/74423412", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16779642/" ]
74,423,435
<p>I'm studying NestJS with a sample app.</p> <p><a href="https://github.com/nestjs/nest/tree/master/sample/12-graphql-schema-first" rel="nofollow noreferrer">https://github.com/nestjs/nest/tree/master/sample/12-graphql-schema-first</a></p> <p>However, what I am curious about is that even if the service does not have an injectable decorator, it can be registered as a provider of the module, and the constructor of other providers can use the registered provider without the injectable decorator.</p> <p>Actually, I removed the injectable decorator from src/cats/cats.service.ts in the example above. But it works fine.</p> <p>Even without the Injectable decorator, the same object was passed to the provider's constructor.</p> <p>Why is the injectable decorator necessary?</p>
[ { "answer_id": 74423495, "author": "Jay McDoniel", "author_id": 9576186, "author_profile": "https://Stackoverflow.com/users/9576186", "pm_score": 1, "selected": true, "text": "@Injectable()" } ]
2022/11/13
[ "https://Stackoverflow.com/questions/74423435", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7973784/" ]
74,423,446
<p>I am trying to find the minimum of a variable input of the scanner class. I have as many inputs as the user wants but I cannot seem to find out how to find the minimum of multiple inputs. Any help would be appreciated.</p> <pre><code>public static void minimum(int count) { double input; boolean lessThan; double lesser = 0; for(count = count; count &gt; 0; count--) { System.out.print(&quot;Enter a double: &quot;); input = console.nextDouble(); lessThan = input &lt; input; if(lessThan = true) { lesser = input; } else { lesser = input; } } System.out.println(&quot;The minimum is &quot; + lesser); } </code></pre>
[ { "answer_id": 74423495, "author": "Jay McDoniel", "author_id": 9576186, "author_profile": "https://Stackoverflow.com/users/9576186", "pm_score": 1, "selected": true, "text": "@Injectable()" } ]
2022/11/13
[ "https://Stackoverflow.com/questions/74423446", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20429066/" ]
74,423,473
<p>I have data stored in the list. Below you can see my data.</p> <pre><code>listName = ['column1','column2','column3','column4'] </code></pre> <p>Now I want to drop elements with titles <code>'column2'</code> and <code>'column3'</code></p> <p>I tried this command but is not work.</p> <pre><code>listName=listName.drop(['column2','column3'],axis=1) </code></pre> <p>Can anybody help me how to solve this problem?</p>
[ { "answer_id": 74423516, "author": "Celius Stingher", "author_id": 11897007, "author_profile": "https://Stackoverflow.com/users/11897007", "pm_score": 3, "selected": true, "text": "to_remove = ['column2','column3']\n\nfiltered = [x for x in listName if x not in to_remove]\n" }, { ...
2022/11/13
[ "https://Stackoverflow.com/questions/74423473", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10924836/" ]
74,423,476
<p>Suppose I have a tensor 2D tensor <code>x</code> of shape <code>(n,m)</code>. How can I extend the first dimension of the tensor by appending zero rows in <code>x</code> by specifying the indices of where the zero rows will be located in the resulting tensor? For a concrete example:</p> <pre><code>x = torch.tensor([[1,1,1], [2,2,2], [3,3,3], [4,4,4]]) </code></pre> <p>And I want to append 2 zero rows such that their row-index will be 1,3, respectively, in the resulting tensor? I.e. in the example the result would be</p> <pre><code>X = torch.tensor([1,1,1], [0,0,0], [2,2,2], [0,0,0], [3,3,3], [4,4,4]]) </code></pre> <p>I tried using <code>F.pad</code> and <code>reshape</code>.</p>
[ { "answer_id": 74423516, "author": "Celius Stingher", "author_id": 11897007, "author_profile": "https://Stackoverflow.com/users/11897007", "pm_score": 3, "selected": true, "text": "to_remove = ['column2','column3']\n\nfiltered = [x for x in listName if x not in to_remove]\n" }, { ...
2022/11/13
[ "https://Stackoverflow.com/questions/74423476", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9213648/" ]
74,423,478
<p>I have a set of five images which are in a grid like setting. For visual, here is what I'm trying to achieve:</p> <p><a href="https://i.stack.imgur.com/sl1B6.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sl1B6.jpg" alt="enter image description here" /></a></p> <p>To my knowledge, such as design could only work if these items are positioned absolute. However, the issue with this is that if the screen is resized in height, or width, the images start to overlap or the spacing between them starts to increase.</p> <p>For example, here is the gap on an extra large screen:</p> <p><a href="https://i.stack.imgur.com/vsBOa.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vsBOa.jpg" alt="enter image description here" /></a></p> <p>My demo showcases my current &quot;static&quot; / hardcoded approach. But, I'm don't believe that my approach is the best way to achieve this design, but can't think of alternatives.</p> <p>Any guidance would be appreciated.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>.imageGrid { overflow: hidden; padding: 120px 0 814px 0; position: relative; } .imageGrid__images-img { background-size: cover; background-repeat: no-repeat; background-position: center; position: absolute; } .imageGrid__images-img-1 { width: 280px; height: 320px; top: 485px; left: 0; } .imageGrid__images-img-2 { width: 427px; height: 319px; top: 485px; left: 310px; } .imageGrid__images-img-3 { width: 737px; height: 342px; left: 0; bottom: 30px; } .imageGrid__images-img-4 { width: 500px; height: 527px; right: 0; top: 119px; } .imageGrid__images-img-5 { width: 600px; height: 500px; right: 0; top: calc(500px + 119px + 30px); }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;section class="imageGrid"&gt; &lt;div class="imageGrid__images"&gt; &lt;div class="imageGrid__images-img imageGrid__images-img-1" loading="lazy" style="background-image: url('https://i.imgur.com/k7fNrV9.png');"&gt;&lt;/div&gt; &lt;div class="imageGrid__images-img imageGrid__images-img-2" loading="lazy" style="background-image: url('https://i.imgur.com/knI2LcY.png');"&gt;&lt;/div&gt; &lt;div class="imageGrid__images-img imageGrid__images-img-3" loading="lazy" style="background-image: url('https://i.imgur.com/Hyn2v1J.png');"&gt;&lt;/div&gt; &lt;div class="imageGrid__images-img imageGrid__images-img-4" loading="lazy" style="background-image: url('https://i.imgur.com/oZG4m8k.png');"&gt;&lt;/div&gt; &lt;div class="imageGrid__images-img imageGrid__images-img-5" loading="lazy" style="background-image: url('https://i.imgur.com/dOvSc80.png');"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/section&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74424092, "author": "Sigma", "author_id": 15289789, "author_profile": "https://Stackoverflow.com/users/15289789", "pm_score": 1, "selected": false, "text": ".img {\n background-size: cover;\n background-repeat: no-repeat;\n background-position: center;\n}\n\n.grid-conta...
2022/11/13
[ "https://Stackoverflow.com/questions/74423478", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4329847/" ]
74,423,547
<p>I am new to C#. This is my code. When I run this code, I input the car name, mileage, year, make, model, color, and bodytype to a list that looks like this</p> <pre class="lang-none prettyprint-override"><code> Name of Car: Car 1 Enter Mileage: 4000 (my input) Enter year: 2022 (my input) Enter make: ford (my input, etc.) Enter model: fusion Enter color: red Enter bodytype: coupe Name of Car: Car 2 Enter Mileage: 4000 Enter year: 2022 Enter make: ford Enter model: fusion Enter color: red Enter bodytype: coupe Name of Car: Car 3 Enter Mileage: 4000 Enter year: 2022 Enter make: ford Enter model: fusion Enter color: red Enter bodytype: coupe </code></pre> <p>and I want to return what I input for car 1, car 2, car 3 as three side by side arrays with commas looking like this?</p> <pre class="lang-none prettyprint-override"><code>car 1, 4000, 2022, ford, fusion, red, coupe car 2, 4000, 2022, ford, fusion, red, coupe car 3, 4000, 2022, ford, fusion, red coupe </code></pre> <p>Below is what I wrote for code, at the very end of this code is where I want to print the side by side arrays. Applying concepts of objects and methods, what should I write in order print that side by side array on the console window?</p> <pre class="lang-cs prettyprint-override"><code>using System; using System.Management.Instrumentation; using Assignment5; namespace Assignment5 { public class Car { //public: public void Set_Name_of_Car(string name) { name_of_car = name; } public void Set_Body_Type(string Type) //methods that you can call { bodytype = Type; } public void Set_Make(string Color, string Make, string Model ) { color = Color; make = Make; model = Model; } public void Set_Mileage(int Mileage, int Year) { mileage = Mileage; year = Year; } public void Show() { Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); } } } </code></pre> <pre class="lang-cs prettyprint-override"><code>namespace Program { internal class Program { static void Main(string[] args) { Car car1 = carInfo(); Car car2 = carInfo(); Car car3 = carInfo(); } public static Car carInfo() { Console.WriteLine(&quot;Enter Name of Car: &quot;); string n_Aim = Console.ReadLine(); Console.WriteLine(&quot;Enter Mileage:&quot;); int miles = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(&quot;Enter Year:&quot;); int yr = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(&quot;Enter Make:&quot;); string meigh_k = Console.ReadLine(); Console.WriteLine(&quot;Enter Model:&quot;); string mod_L = Console.ReadLine(); Console.WriteLine(&quot;Enter Color:&quot;); string Col_R = Console.ReadLine(); Console.WriteLine(&quot;Enter Bodytype: &quot;); string Bdy_Typ = Console.ReadLine(); Car inputcar = new Car(); inputcar.Set_Name_of_Car(n_Aim); inputcar.Set_Mileage(miles, yr); inputcar.Set_Make(Col_R, meigh_k, mod_L); inputcar.Set_Body_Type(Bdy_Typ); return inputcar; } } } </code></pre> <p>What I want to try is using but I don't think my instructor wants us to use that method because it's too simplistic. Do you have any other suggestions please? and thank you :D</p> <pre class="lang-cs prettyprint-override"><code>Console.WriteLine(&quot;car 1, 4000, 2022, ford, fusion, red, coupe&quot;); Console.WriteLine(&quot;car 2, 4000, 2022, ford, fusion, red, coupe&quot;); Console.WriteLine(&quot;car 3, 4000, 2022, ford, fusion, red coupe&quot;); </code></pre>
[ { "answer_id": 74424092, "author": "Sigma", "author_id": 15289789, "author_profile": "https://Stackoverflow.com/users/15289789", "pm_score": 1, "selected": false, "text": ".img {\n background-size: cover;\n background-repeat: no-repeat;\n background-position: center;\n}\n\n.grid-conta...
2022/11/13
[ "https://Stackoverflow.com/questions/74423547", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20101467/" ]
74,423,596
<p>If <code>formattedDate</code> is declared as a global variable and <code>formattedDate</code> is output in startScreenRecord, the output is good. However, if <code>formattedDate</code> is output again in stopScreenRecord, it is output as null. how can I solve this?</p> <pre><code> class _HomePageState extends State&lt;HomePage&gt; { var formattedDate; bool recording = false; var directory = Directory('/storage/emulated/0/DCIM/BackCamera').create(recursive: true); bool inProgress = false; Future&lt;File&gt; moveFile(File sourceFile, String newPath) async { try { return await sourceFile.rename(newPath); } on FileSystemException catch (e) { final newFile = await sourceFile.copy(newPath); await sourceFile.delete(); return newFile; } } startScreenRecord(bool audio, String formattedDate) async { bool start = false; var now = new DateTime.now(); var formatter = new DateFormat('yyyy_MM_dd_HH_mm_ss'); formattedDate = formatter.format(now); print('-------------'); print(formattedDate); print('-------------'); if (audio) { start = await FlutterScreenRecording.startRecordScreenAndAudio(formattedDate); } else { start = await FlutterScreenRecording.startRecordScreen(formattedDate); } if (start) { setState(() =&gt; recording = !recording); } return start; } stopScreenRecord() async { String path = await FlutterScreenRecording.stopRecordScreen; setState(() { recording = !recording; }); print(&quot;Opening video&quot;); print(path); final directory = await getTemporaryDirectory(); print(directory.path); // Move Title.mp4 to Download folder final newPath = '/storage/emulated/0/DCIM/' + &quot;$formattedDate.mp4&quot;; print(formattedDate); print(newPath); print(formattedDate.toString()); final file = await moveFile(File(path), newPath); print(file.path); } </code></pre>
[ { "answer_id": 74424092, "author": "Sigma", "author_id": 15289789, "author_profile": "https://Stackoverflow.com/users/15289789", "pm_score": 1, "selected": false, "text": ".img {\n background-size: cover;\n background-repeat: no-repeat;\n background-position: center;\n}\n\n.grid-conta...
2022/11/13
[ "https://Stackoverflow.com/questions/74423596", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12769152/" ]
74,423,605
<p>I am coding a Battleships game in Python and can use some help regarding the while loop to check whether a user has not input any data.</p> <pre class="lang-py prettyprint-override"><code> def getUserInput(self): try: x_row = input(&quot;Please Select the row coorinate (1-8)&quot;) while x_row not in '12345678': print(&quot;You are either out of bounds, or don't know what numbers are&quot;) x_row = input(&quot;Please Select the row coorinate (1-8)&quot;) y_column = input(&quot;Please Select the column coordinate (A-H)&quot;).upper() while y_column not in 'ABCDEFGH': print(&quot;You are either out of bounds, or don't know what Letters are&quot;) y_column = input(&quot;Please Select the column coordinate (A-H)&quot;).upper() </code></pre> <p>It checks for whether the input is in the data range well, but I need it to also check if the user didn't put anything in the input.</p> <p>I tried an if statement to check whether the user input '' or ' ', as well as equating it to None, but it either just skips over the step to ask for the next input or comes back with a syntax error.</p>
[ { "answer_id": 74424092, "author": "Sigma", "author_id": 15289789, "author_profile": "https://Stackoverflow.com/users/15289789", "pm_score": 1, "selected": false, "text": ".img {\n background-size: cover;\n background-repeat: no-repeat;\n background-position: center;\n}\n\n.grid-conta...
2022/11/13
[ "https://Stackoverflow.com/questions/74423605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20494609/" ]
74,423,610
<p>I'm trying to do this code, and I split it up into <code>.c</code> files (lets say <code>file1.c</code> and <code>file2.c</code>) and <code>file1.h</code> file. I'm not allowed to change which parameters I can send to the function, so I need to find another way to &quot;send&quot;/access another variable. I tried to make the variable static in the header file <code>file1.h</code>, and include it in the <code>file2.c</code>. The function in <code>file1.c</code> look something like this:</p> <pre><code>int function(int *array, int a, int b){ ... ... if(global_variable == 1){ point = array[(a+b)/2]; }else if(global_variable == 0){ point = array[b]; } </code></pre> <p>and in the <code>file2.c</code> I have a function something like this:</p> <pre><code>double function2(t_sort_funcp fun, const case_t c, int array_length, result_t *buf, t_generate_array_funcp g_array){ int array[array_length]; switch (c) { case first: global_variable = 1; g_array(array, array_length); return debugg(fun, array, array_length); break; case second:// Wors case is an inverted sorted array. global_variable = 0; g_array(array, array_length); return debugg(fun, array, array_length); break; case third: global_variable = 1; g_array(array, array_length); return debugg(fun, array, array_length); break; } return 0; } </code></pre> <p>In the <code>file1.h</code> I have:</p> <pre><code>#ifndef ALGORITHM_H #define ALGORITHM_H #include &lt;stdbool.h&gt; // bool static int global_variable; #endif </code></pre> <p>as you can see, I'm trying to change the <code>global_variable</code> variable in <code>file2.c</code> and use it in <code>file1.c</code> but that does not work, the if-statement in <code>file1.c</code> always executes the code in the else-statement, even if I changed the variable to 1. NOTE: <code>file2.c</code> always executes before <code>file1.c</code></p>
[ { "answer_id": 74423655, "author": "0___________", "author_id": 6110094, "author_profile": "https://Stackoverflow.com/users/6110094", "pm_score": 2, "selected": true, "text": "#ifndef ALGORITHM_H\n#define ALGORITHM_H\n\n#include <stdbool.h> // bool\nextern int global_variable;\n\n#endif\...
2022/11/13
[ "https://Stackoverflow.com/questions/74423610", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17701708/" ]
74,423,680
<p>I got <code>FutureBuilder</code> snapshot error when I parsing my JSON i got the:</p> <p>type 'List' is not a subtype of type 'FutureOr&lt;List&gt;' is it my Product model error or a parsing error?</p> <p>my code</p> <pre><code> late Future&lt;List&lt;Product&gt;&gt; productFuture = getProducts(); static Future&lt;List&lt;Product&gt;&gt; getProducts() async { var url = '${Constants.API_URL_DOMAIN}action=catalog&amp;category_id=$id'; final response = await http.get(Uri.parse(url)); final body = jsonDecode(response.body); print(body['data']); return body['data'].map((e)=&gt;Product.fromJson(e)).toList(); } FutureBuilder&lt;List&lt;Product&gt;&gt;( future: productFuture, builder: (context, snapshot) { print(snapshot); if (snapshot.connectionState == ConnectionState.waiting) { return Center(child: CircularProgressIndicator()); } else if (snapshot.hasData) { final catalog = snapshot.data; return buildCatalog(catalog!); } else { print('SNAPSOT DATA ${snapshot.data}'); return Text(&quot;No widget to build&quot;); } }), </code></pre>
[ { "answer_id": 74423805, "author": "Yeasin Sheikh", "author_id": 10157127, "author_profile": "https://Stackoverflow.com/users/10157127", "pm_score": 2, "selected": true, "text": "return List.from(body['data'].map((e)=>Product.fromJson(e)));\n" }, { "answer_id": 74424815, "aut...
2022/11/13
[ "https://Stackoverflow.com/questions/74423680", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20320364/" ]
74,423,690
<p>So I'm trying to make a section under each appointment details that shows their payment transactions of the appointment specifically. all my tries so far didn't work, i can only show all payment updates which is not the wanted result obviously. this is the code:</p> <p>views.py the view for updating payments</p> <pre><code>def edit_payment(request, id): search_patient_form = SearchPatient() current_user_phone = request.session.get('user') current_user = get_object_or_404(Doctor, phone = current_user_phone) if current_user: appointment = get_object_or_404(Appointment, id=id) if request.method == 'POST': form = AddAppointmentForm(request.POST) searchPatient = SearchPatient(request.POST) if searchPatient.is_valid(): patient_id_phone = searchPatient.cleaned_data['patient_id_phone'] return redirect('search_patient', id_phone=patient_id_phone) elif form.is_valid(): patient_phone = form.cleaned_data['patient_phone'] patient = Patient.objects.filter(phone = patient_phone).first() doctor_select = form.cleaned_data['doctor_field'] doctor = Doctor.objects.filter(username = doctor_select).first() appointment_date = form.cleaned_data['appointment_date'] time_slot_field = form.cleaned_data['time_slot_field'] #time_slot = TimeSlot.objects.filter(slotname=time_slot_field).first() appointment_description = form.cleaned_data['appointment_description'] service_name = form.cleaned_data['service_name'] total_price = form.cleaned_data['total_price'] upfront_payment = form.cleaned_data['upfront_payment'] grand_total = form.cleaned_data['grand_total'] discount = form.cleaned_data['discount'] payment_type = form.cleaned_data['payment_type'] appointment.patient = patient appointment.doctor_of_appointment = doctor appointment.appointment_date = appointment_date appointment.receptionist_of_appointment = current_user appointment.appointment_timeslot = time_slot_field appointment.appointment_description = appointment_description appointment.service_name = service_name appointment.total_price = total_price appointment.upfront_payment = upfront_payment appointment.grand_total = grand_total appointment.discount = discount appointment.payment_type = payment_type appointment.save() new_log = Log( log_user = current_user, log_descripton = 'Appointment has been editted. {0}'.format( str(id)), ) new_log.save() #Payment Update Section new_update = PaymentUpDate( payment_amount = 'Total Price : {0} - Patient Payment: {1} - Balance: {2}'.format( total_price,upfront_payment,grand_total ) ) new_update.save() return redirect('appointment_details', id=appointment.id) else: form = AddAppointmentForm(initial={ 'patient_phone' : appointment.patient.phone, 'doctor_field' : appointment.doctor_of_appointment.username, 'appointment_date' : appointment.appointment_date, 'time_slot_field' : appointment.appointment_timeslot, 'appointment_description' : appointment.appointment_description, 'service_name': appointment.service_name, 'total_price': appointment.total_price, 'upfront_payment': appointment.upfront_payment, 'grand_total': appointment.grand_total, 'discount': appointment.discount, 'payment_type': appointment.payment_type, }) return render(request, 'edit-payment.html', { 'current_user': current_user, 'sayfa': 'appointments', 'form': form, 'search_patient_form': search_patient_form }) else: return redirect('login') </code></pre> <p>the one I'm trying to make it work</p> <pre><code>def appointment_details(request, id): search_patient_form = SearchPatient() current_user_phone = request.session.get('user') current_user = get_object_or_404(Doctor, phone = current_user_phone) if current_user: if request.method == 'POST': searchPatient = SearchPatient(request.POST) if searchPatient.is_valid(): patient_id_phone = searchPatient.cleaned_data['patient_id_phone'] return redirect('search_patient', id_phone=patient_id_phone) else: appointment = get_object_or_404(Appointment, id = id) updates = PaymentUpDate.objects.all() return render(request, 'about-appointment.html', { 'current_user': current_user, 'sayfa': 'appointments', 'appointment': appointment, 'updates': updates, 'search_patient_form': search_patient_form }) else: return redirect('login') </code></pre> <p>models.py</p> <p>This is the class the makes the updates</p> <pre><code>class PaymentUpDate(models.Model): payment_date = models.DateTimeField(auto_now_add=True) payment_amount = models.CharField(max_length=550) </code></pre> <p>I've tried doing the same approach as I did to show a specific appointment, which is:</p> <pre><code>appointment = get_object_or_404(Appointment, id = id) </code></pre> <p>to the updates, which looked something like :</p> <pre><code>updates = get_object_or_404(PaymentUpDate, id = id) </code></pre> <p>which resulted in the following error :</p> <pre><code>TypeError at /appointment-details/3 'PaymentUpDate' object is not iterable </code></pre> <p>and i also tried this guide: <a href="https://stackoverflow.com/questions/57440333/how-to-show-every-user-specific-payment-for-them-in-django">How to show every user specific payment for them in django?</a>, which made my code look like this:</p> <pre><code>class PaymentUpDate(models.Model): payment_date = models.DateTimeField(auto_now_add=True) payment_amount = models.CharField(max_length=550, null=True) appointment = models.ForeignKey(Appointment, on_delete = models.CASCADE, null=True) </code></pre> <p>views.py</p> <pre><code>updates = PaymentUpDate.objects.filter(appointment=id) </code></pre> <p>which resulted in not getting any updates for some reason.</p>
[ { "answer_id": 74425717, "author": "Sunderam Dubey", "author_id": 17562044, "author_profile": "https://Stackoverflow.com/users/17562044", "pm_score": 2, "selected": false, "text": "PaymentUpDate.objects.filter(appointment=appointment)\n" }, { "answer_id": 74431495, "author": ...
2022/11/13
[ "https://Stackoverflow.com/questions/74423690", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20256273/" ]
74,423,694
<p>Hi guys I have a problem with some sites from my university and at my localhost. We started with web developement and learned html and css. The thing is I found a very weird CSS Tag in my Head with very weird and scammy looking refs. I looked at some of the links and maybe it sounds weird but some links are P*rn sites or some tracker sites as it seems from the names. I only have this problem on the sites my Uni gives me where my tasks are and at my localhost when I work with Spring and Intellij on my own Website. I am a little scared tbh. I run the Opera GX browser. I tried Firefox to check if the style tag was there aswell but there wasnt. The tag starts like this : : &quot;some weird root: tags and hrefs&quot; Anyone has a clue whats going on?</p> <p>I also checked at my laptop since it runs opera GX aswell and the weird style tag is there aswell. I didnt find any help when I checked in google for a solution.</p>
[ { "answer_id": 74424951, "author": "Shaman Technology", "author_id": 15475207, "author_profile": "https://Stackoverflow.com/users/15475207", "pm_score": -1, "selected": false, "text": "<link rel=\"stylesheet\" type=\"text/css\" href=\"mystyle.css\">\n" } ]
2022/11/13
[ "https://Stackoverflow.com/questions/74423694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17603934/" ]