qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,210,531
<p>Consider the following DataFrame:</p> <pre><code> team player metric_a metric_b 0 1 player1 15 25 1 1 player2 20 30 2 1 player3 21 12 3 2 player4 9 46 4 2 player5 39 5 </code></pre> <p>How could we compute the (absolute) difference of every player with every other player of the <strong>same team</strong>?</p> <p>Output:</p> <pre><code> team player_a player_b metric_a_diff metric_b_diff 0 1 player1 player2 5 10 1 1 player1 player3 6 13 2 1 player2 player3 1 18 3 2 player4 player5 30 41 </code></pre> <p>I have tried something along the lines of:</p> <pre class="lang-py prettyprint-override"><code>from itertools import combinations combos = lambda s : pd.DataFrame(list(combinations(s.values, 2)), columns=['player_a', 'player_b']) df.groupby('team')['player'].apply(combos).reset_index(level=1, drop=True).reset_index() </code></pre> <p>but I don't know how to get <code>diff</code> in to play.</p>
[ { "answer_id": 74211389, "author": "Shubham Sharma", "author_id": 12833166, "author_profile": "https://Stackoverflow.com/users/12833166", "pm_score": 3, "selected": true, "text": "merge" }, { "answer_id": 74220224, "author": "R. Baraiya", "author_id": 13888486, "autho...
2022/10/26
[ "https://Stackoverflow.com/questions/74210531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14594208/" ]
74,210,532
<p>I have a huge number of string values in a list like below:</p> <p><code>a = ['1-0.0','1-0.1','4-0.1','4-0.2','4-1.0','4-1.1','4-2.0',...,'23012-11.23']</code> --&gt; Approx 25000 values</p> <p>In each value (consider example as '4-0.1'): 4 is x, 0 is y and 1 is z.</p> <p>I want to analyze this data and get info like below:</p> <pre><code>There are total n values starting with x. In which, there are n values with mid-value y and (n1,n2) are the z values. </code></pre> <p>From above example, if we take from '4-0.1':</p> <pre><code>There are total 5 values starting with 4. In which, there are 2 values with mid-value 0 and (1,2) are the z values. In which, there are 2 values with mid-value 1 and (0,1) are the z values. In which, there are 1 values with mid-value 2 and (0) are the z values. </code></pre> <p>Can anyone please let me know if there is any way to slice these values from list in one go and get the data like above?</p>
[ { "answer_id": 74210644, "author": "mlokos", "author_id": 19570235, "author_profile": "https://Stackoverflow.com/users/19570235", "pm_score": 1, "selected": false, "text": "import re\n\na=[\"4-1.0\", \"4-2.0\", \"4-1.2\", \"1-1.0\"]\nb = [[int(x) for x in re.split(\"-|\\.\", c)] for c in...
2022/10/26
[ "https://Stackoverflow.com/questions/74210532", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16232975/" ]
74,210,539
<p>I copy code from youtube. That guy's code works as I wish mine to. It defined 2 processes and 2 processes were executed. My whole code is executing 3 times. Why? And why doesn't he need to use <code>if __name__ == '__main__':</code>?</p> <pre><code>import multiprocessing import time start = time.perf_counter() def do_something(): print('Sleeping 1 second...') time.sleep(1) print('Done sleeping...') if __name__ == '__main__': p1 = multiprocessing.Process(target=do_something) p2 = multiprocessing.Process(target=do_something) p1.start() p2.start() p1.join() p2.join() finish = time.perf_counter() print(f'Finished in {round(finish-start, 2)} seconds(s)') </code></pre> <p>I expect the same to happen as the guy on youtube.</p> <p>My output:</p> <pre class="lang-none prettyprint-override"><code>Finished in 0.0 seconds(s) Sleeping 1 second... Finished in 0.0 seconds(s) Sleeping 1 second... Done sleeping... Done sleeping... Finished in 1.08 seconds(s) Youtube guy output: Sleeping 1 second... Sleeping 1 second... Done sleeping... Done sleeping... Finished in 1.01 seconds(s) </code></pre>
[ { "answer_id": 74210644, "author": "mlokos", "author_id": 19570235, "author_profile": "https://Stackoverflow.com/users/19570235", "pm_score": 1, "selected": false, "text": "import re\n\na=[\"4-1.0\", \"4-2.0\", \"4-1.2\", \"1-1.0\"]\nb = [[int(x) for x in re.split(\"-|\\.\", c)] for c in...
2022/10/26
[ "https://Stackoverflow.com/questions/74210539", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19183233/" ]
74,210,540
<p>what would goto, translate to in bash script</p> <hr /> <p>This is my code:</p> <pre><code>#!/bin/bash read distro &lt;/etc/issue echo $distro if [[ &quot;$distro&quot; = &quot;Debian GNU/Linux bookworm/sid n l&quot; ]]; then goto Debian: elif [[ &quot;$distro&quot; = &quot;Ubuntu GNU/Linux bookworm/sid n l&quot; ]]; then goto Ubuntu: elif [[ &quot;$distro&quot; = &quot;kali GNU/Linux bookworm/sid n l&quot; ]]; then goto Kali: elif [[ &quot;$distro&quot; = &quot;Arch GNU/Linux bookworm/sid n l&quot; ]]; then goto Arch: else echo No suported OS detected some thing may not work fi Debian: echo using Debian sleep 5 exit Ubuntu: echo using Ubuntu sleep 5 exit Kali: echo using kali sleep 5 exit Arch: echo using Arch sleep 5 exit </code></pre> <hr /> <p>Its a really simple code and I don't even know if the way I'm checking the Linux distro will work</p> <p>I have tried with the Goto function from a batch from windows but it wont work on Linux, how would i jump form line to line</p>
[ { "answer_id": 74210644, "author": "mlokos", "author_id": 19570235, "author_profile": "https://Stackoverflow.com/users/19570235", "pm_score": 1, "selected": false, "text": "import re\n\na=[\"4-1.0\", \"4-2.0\", \"4-1.2\", \"1-1.0\"]\nb = [[int(x) for x in re.split(\"-|\\.\", c)] for c in...
2022/10/26
[ "https://Stackoverflow.com/questions/74210540", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20300081/" ]
74,210,547
<p>This may seem simple.</p> <p>It could be vbNewLine</p> <p>or it can be</p> <p><a href="https://learn.microsoft.com/en-us/dotnet/api/system.environment.newline?redirectedfrom=MSDN&amp;view=net-6.0#System_Environment_NewLine" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/dotnet/api/system.environment.newline?redirectedfrom=MSDN&amp;view=net-6.0#System_Environment_NewLine</a></p> <p>However, that is NOT equivalent with &quot;\n&quot;</p> <p>That is equivalent with</p> <blockquote> <p>\r\n for non-Unix platforms, or \n for Unix platforms.</p> </blockquote> <p>What about if I want \n no matter what. \</p> <p>I tried to search for similar questions and I can't even find it.</p> <p>There is nothing here either.</p> <p><a href="https://learn.microsoft.com/en-us/dotnet/api/system.environment.newline?redirectedfrom=MSDN&amp;view=net-6.0#System_Environment_NewLine" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/dotnet/api/system.environment.newline?redirectedfrom=MSDN&amp;view=net-6.0#System_Environment_NewLine</a></p> <p>So not easy to fine.</p> <p>Update: One answer says that &quot;\n&quot; means vbNewLine <strong>both</strong> in windows and in Linux.</p> <p>Well, I am writing a vb.net <strong>windows</strong> program that interact with <strong>linux</strong> machine. You know, usual API stuff. In which case I need a character in windows that always mean &quot;\n&quot; in linux.</p> <p>Basically, I need the chr(10) character. Not chr(10)+chr(13) character.</p> <p>I think the answer I wrote my self is the answer to that.</p> <p>And I do not think there is a simple answer on that.</p> <p><a href="https://stackoverflow.com/questions/27223228/differences-between-vblf-vbcrlf-vbcr-constants">Differences Between vbLf, vbCrLf &amp; vbCr Constants</a> may make things clear. However, people that find that question are people that already guess that vbLf may be a solution.</p> <p>In fact, the questions and the answers over there do not even link &quot;\n&quot; to vbLF at all. They just say that vbLF is line feed. Is it &quot;\n&quot;? Another technicality</p> <p>This question answer the question more directly. So what's equivalent to linux/unix &quot;\n&quot; no matter what is vbLf</p>
[ { "answer_id": 74211119, "author": "user4951", "author_id": 700663, "author_profile": "https://Stackoverflow.com/users/700663", "pm_score": 2, "selected": false, "text": "using Microsoft.VisualBasic.CompilerServices;\n\nnamespace Microsoft.VisualBasic\n{\n // Summary:\n // ...
2022/10/26
[ "https://Stackoverflow.com/questions/74210547", "https://Stackoverflow.com", "https://Stackoverflow.com/users/700663/" ]
74,210,556
<p>I have a struct called <code>Cell</code></p> <pre><code>pub struct Cell { x: X, // Some other struct y: Y, // Some other struct weight: usize, } </code></pre> <p>I was trying to select the top preference cell out of some <code>Row</code> (a collection of <code>Cell</code>s).</p> <pre><code>// Return the top n-matching cells with a positive weight pub fn select_preference(&amp;mut self) -&gt; Vec&lt;Cell&gt; { let top = 3; self.sort(); // After sorting, omit the cells with weight = 0 // And select the top preference cells self.cells.split(|cell| cell.weight() == 0).take(top) } </code></pre> <p>However, I am getting an expected error actually:</p> <pre><code> Compiling playground v0.0.1 (/playground) error[E0308]: mismatched types --&gt; src/lib.rs:35:9 | 29 | pub fn select_preference(&amp;mut self) -&gt; Vec&lt;Cell&gt; { | --------- expected `Vec&lt;Cell&gt;` because of return type ... 35 | self.cells.split(|cell| cell.weight() == 0).take(top) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `Vec`, found struct `std::iter::Take` | = note: expected struct `Vec&lt;Cell&gt;` found struct `std::iter::Take&lt;std::slice::Split&lt;'_, Cell, [closure@src/lib.rs:35:26: 35:32]&gt;&gt;` For more information about this error, try `rustc --explain E0308`. error: could not compile `playground` due to previous error </code></pre> <p>I don't know how to convert the <code>Take</code> into <code>Vec&lt;Cell&gt;</code> or <code>&amp;[Cell]</code>. I know the <code>Take</code> is some sort of <code>Iterator</code> but unable to convert it :&gt;</p> <p><a href="https://play.rust-lang.org/?version=stable&amp;mode=release&amp;edition=2021&amp;code=type%20X%20%3D%20u32%3B%0Atype%20Y%20%3D%20u32%3B%0A%0Apub%20struct%20Cell%20%7B%0A%20%20%20%20x%3A%20X%2C%0A%20%20%20%20y%3A%20Y%2C%0A%20%20%20%20weight%3A%20usize%2C%0A%7D%0A%0Aimpl%20Cell%7B%0A%0A%20%20%20%20pub%20fn%20weight(%26self)%20-%3E%20usize%20%7B%0A%20%20%20%20%20%20%20%20self.weight%0A%20%20%20%20%7D%20%20%20%20%0A%7D%0A%0Apub%20struct%20Row%20%7B%0A%20%20%20%20pub%20cells%3A%20Vec%3CCell%3E%2C%0A%7D%0A%0Aimpl%20Row%20%7B%0A%0A%20%20%20%20pub%20fn%20sort(%26mut%20self)%20%7B%0A%20%20%20%20%20%20%20%20self.cells%0A%20%20%20%20%20%20%20%20%20%20%20%20.sort_by(%7Clighter%2C%20heavier%7C%20heavier.weight().cmp(%26lighter.weight()))%0A%20%20%20%20%7D%0A%20%20%20%20%0A%20%20%20%20%2F%2F%20Return%20the%20top%20n-matching%20cells%20with%20a%20positive%20weight%0A%20%20%20%20pub%20fn%20select_preference(%26mut%20self)%20-%3E%20Vec%3CCell%3E%20%7B%0A%20%20%20%20%20%20%20%20let%20top%20%3D%203%3B%0A%20%20%20%20%0A%20%20%20%20%20%20%20%20self.sort()%3B%0A%20%20%20%20%20%20%20%20%2F%2F%20After%20sorting%2C%20omit%20the%20cells%20with%20weight%20%3D%200%0A%20%20%20%20%20%20%20%20%2F%2F%20And%20select%20the%20top%20preference%20cells%0A%20%20%20%20%20%20%20%20self.cells.split(%7Ccell%7C%20cell.weight()%20%3D%3D%200).take(top)%0A%20%20%20%20%7D%0A%0A%7D" rel="nofollow noreferrer">Rust Playground</a></p>
[ { "answer_id": 74210920, "author": "frankplow", "author_id": 17419835, "author_profile": "https://Stackoverflow.com/users/17419835", "pm_score": 2, "selected": false, "text": "pub fn select_preference(&mut self) -> Vec<&Cell> {\n let top = 3;\n self.sort();\n self.cells.iter().f...
2022/10/26
[ "https://Stackoverflow.com/questions/74210556", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4326767/" ]
74,210,573
<p>I'm trying to install file picker except that when my button is clicked or the file picker function is assigned, I have this error that appears: &quot;MissingPluginException (MissingPluginException(No implementation found for method any on channel miguelruivo.flutter.plugins.filepicker))&quot;</p> <p>I couldn't find anything about it</p>
[ { "answer_id": 74210920, "author": "frankplow", "author_id": 17419835, "author_profile": "https://Stackoverflow.com/users/17419835", "pm_score": 2, "selected": false, "text": "pub fn select_preference(&mut self) -> Vec<&Cell> {\n let top = 3;\n self.sort();\n self.cells.iter().f...
2022/10/26
[ "https://Stackoverflow.com/questions/74210573", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18423075/" ]
74,210,602
<p>I was reading an article(<a href="https://www.techgeekbuzz.com/blog/how-to-read-emails-in-python/" rel="nofollow noreferrer">https://www.techgeekbuzz.com/blog/how-to-read-emails-in-python/</a>) that describes how to read emails using python, now its using _, before declaring a variable here is the code:</p> <pre class="lang-py prettyprint-override"><code>#modules import imaplib import email #credentials username =&quot;codehundred100@gmail.com&quot; #generated app password app_password= &quot;aqwertyuiopasdfa&quot; # https://www.systoolsgroup.com/imap/ gmail_host= 'imap.gmail.com' #set connection mail = imaplib.IMAP4_SSL(gmail_host) #login mail.login(username, app_password) #select inbox mail.select(&quot;INBOX&quot;) #select specific mails _, selected_mails = mail.search(None, '(FROM &quot;noreply@kaggle.com&quot;)') #total number of mails from specific user print(&quot;Total Messages from noreply@kaggle.com:&quot; , len(selected_mails[0].split())) for num in selected_mails[0].split(): _, data = mail.fetch(num , '(RFC822)') _, bytes_data = data[0] #convert the byte data to message email_message = email.message_from_bytes(bytes_data) print(&quot;\n===========================================&quot;) #access data print(&quot;Subject: &quot;,email_message[&quot;subject&quot;]) print(&quot;To:&quot;, email_message[&quot;to&quot;]) print(&quot;From: &quot;,email_message[&quot;from&quot;]) print(&quot;Date: &quot;,email_message[&quot;date&quot;]) for part in email_message.walk(): if part.get_content_type()==&quot;text/plain&quot; or part.get_content_type()==&quot;text/html&quot;: message = part.get_payload(decode=True) print(&quot;Message: \n&quot;, message.decode()) print(&quot;==========================================\n&quot;) break </code></pre> <p>Why is _, used every-time I remove it, it gives an error so I just wanna know what it does.</p> <p>Thanks!!</p>
[ { "answer_id": 74210920, "author": "frankplow", "author_id": 17419835, "author_profile": "https://Stackoverflow.com/users/17419835", "pm_score": 2, "selected": false, "text": "pub fn select_preference(&mut self) -> Vec<&Cell> {\n let top = 3;\n self.sort();\n self.cells.iter().f...
2022/10/26
[ "https://Stackoverflow.com/questions/74210602", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17856469/" ]
74,210,606
<p>I am sure that someone has a different way to do this, so please set me on the right path if this isn't the best method.</p> <p>In MS Access I have different user types that all have different dashboards. All of these users can press a button on their dashboard to get a common overlay to enter a new record. Upon hitting save on the overlay, I need to refresh the subform on the dashboard with the new records. I have used vba that looks for open forms and then refreshes based on the form that is open, but I don't like this method because each time I create a new user type I have to remember to go back and update the code to look for this new dashboard. More recently I tried updating an unbound textbox on the overlay with the name of the form/subfrm that needs to be update, but I can't seem to get that to run correctly.</p> <p>Here is my VBA that is run upon trying to save the record and update the correct form. (Note me.txtFrmRefresh is my unbound textbox)</p> <pre><code>Dim ctlFrmRefresh As Control Set ctlFrmRefresh = me.txtFrmRefresh ctlFrmRefresh.Form.Recordset.Requery DoCmd.Close acForm, &quot;frmClaimNew&quot;, acSaveNo </code></pre> <p>When I run this, get the following error &quot;You entered an expression that has an invalid reference to the property form/report.</p> <p>I know that the text in the unbound textbox is correct because I can change &quot;me.txtFrmRefresh&quot; to the form name and it works correctly.</p>
[ { "answer_id": 74210920, "author": "frankplow", "author_id": 17419835, "author_profile": "https://Stackoverflow.com/users/17419835", "pm_score": 2, "selected": false, "text": "pub fn select_preference(&mut self) -> Vec<&Cell> {\n let top = 3;\n self.sort();\n self.cells.iter().f...
2022/10/26
[ "https://Stackoverflow.com/questions/74210606", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14670074/" ]
74,210,657
<p>I would like to understand why the loop will not loop if i != 1234 and ask to &quot;please try again&quot;.</p> <pre><code>#include &lt;iostream&gt; int main() { //i want to create a program to stop after three attempts int i = 1234; for (i = 0; i &lt; 3; i++) { std::cout &lt;&lt; &quot;enter pin &quot;; std::cin &gt;&gt; i; if (i == 1234) { std::cout &lt;&lt; &quot;Thank you&quot; &lt;&lt; &quot;\n&quot;; } else if (i &lt; 1000 || i &gt; 9999) { std::cout &lt;&lt; &quot;Invalid&quot; &lt;&lt; &quot;\n&quot;; } else { std::cout &lt;&lt; &quot;incorrect, please try again&quot; &lt;&lt; &quot;\n&quot;; } } } </code></pre>
[ { "answer_id": 74210712, "author": "EJoshuaS - Stand with Ukraine", "author_id": 4032703, "author_profile": "https://Stackoverflow.com/users/4032703", "pm_score": 0, "selected": false, "text": "i" }, { "answer_id": 74211091, "author": "sweenish", "author_id": 6119582, ...
2022/10/26
[ "https://Stackoverflow.com/questions/74210657", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20341063/" ]
74,210,659
<p>here is an example code:</p> <p><code>money = 20</code></p> <p><code>var1 = 2f</code></p> <p><code>if var1 == 2f:</code></p> <p><code>if money &lt; 25:</code></p> <p><code>print(&quot;you dont have enough money&quot;)</code></p> <p>After that, i need something to exit the if statement (and the larger one, too.)</p> <p>is it possible? is there something like <code>break</code> but for if statements?</p> <pre class="lang-py prettyprint-override"><code>item1 = &quot;2f&quot; money = 20 inventory = [] if item1 == &quot;2f&quot;: if money &lt; 25: print(&quot;sorry mate, you don't have enough&quot;) #this is where i got stuck print(&quot;you bought the large cookie box for 25 dollars. &quot;) money -= 25 print(&quot;you now have&quot;, money, &quot;dollars&quot;) inventory.append(&quot;LCB&quot;) </code></pre> <p>it simply printed that and appended the LCB, made the money -5 and printed the other message. (this is part of a much larger code, so it's edited a little.) i can't use the function method because i'll need the list and variables later on. and i can't use loops, either. i'm also a bit of a beginner i don't want (too) complicated answers.</p> <p>quick edit: i actually found out how to solve the code at hand, but i'd still like some answers to help in other projects.</p>
[ { "answer_id": 74210741, "author": "Riley Martin", "author_id": 19266041, "author_profile": "https://Stackoverflow.com/users/19266041", "pm_score": 0, "selected": false, "text": "item1 = \"2f\"\nmoney = 20\ninventory = []\nif item1 == \"2f\":\n if money < 25:\n print(\"sorry ma...
2022/10/26
[ "https://Stackoverflow.com/questions/74210659", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20225586/" ]
74,210,662
<p>I am testing an event handler When I click the button nothing happens. Why does the code not work?</p> <p>This is my code:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>let btn = document.getElementById('button') btn.addEventListener('click', () =&gt; { window.location.href = 'https://www.youtube.com' })</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="container-login100-form-btn"&gt; &lt;div class="wrap-login100-form-btn"&gt; &lt;div class="login100-form-bgbtn"&gt;&lt;/div&gt; &lt;button class="login100-form-btn" id="button" type="submit" "&gt; Enter &lt;/button&gt; &lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74210890, "author": "Akash Ks", "author_id": 19341587, "author_profile": "https://Stackoverflow.com/users/19341587", "pm_score": -1, "selected": false, "text": "let btn = document.getElementById('button')\nbtn.addEventListener('click', () => {\n location.href = \"https:...
2022/10/26
[ "https://Stackoverflow.com/questions/74210662", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20340986/" ]
74,210,675
<p>Regex and text data noob here.</p> <p>I have a list of terms and I want to get a single sum of the total times the strings from my list appear in a separate string. In the example below, the letter &quot;o&quot; appears 3 times in my string and the letter &quot;b&quot; appears 2 times. I've created a variable called allcount which I know doesn't work, but ideally would have a total sum of 5.</p> <p>Any help is appreciated.</p> <pre><code>import re mylist = ['o', 'b'] my_string = 'Bob is cool' onecount = len(re.findall('o', my_string)) #this works #allcount = sum(len(re.findall(mylist, my_string))) #this doesn't work </code></pre>
[ { "answer_id": 74210890, "author": "Akash Ks", "author_id": 19341587, "author_profile": "https://Stackoverflow.com/users/19341587", "pm_score": -1, "selected": false, "text": "let btn = document.getElementById('button')\nbtn.addEventListener('click', () => {\n location.href = \"https:...
2022/10/26
[ "https://Stackoverflow.com/questions/74210675", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8543373/" ]
74,210,693
<p>I need to use a for loop that can add column 1 to column 3,5,7,9,11,13,15,17 and sort column 2,4,6,8,10,12.14,16,18</p> <p>I tried to use for but am having difficulties in applying it</p> <pre><code>first_column&lt;- c(&quot;^&quot;,&quot;G&quot;,&quot;A&quot;,&quot;T&quot;,&quot;T&quot;,&quot;A&quot;,&quot;C&quot;,&quot;A&quot;) second_column&lt;- sort(first_column) third_column&lt;-paste(first_column,second_column) fourth_column&lt;-sort(third_column) fifth_column&lt;-paste(first_column,fourth_column) sixth_column&lt;-sort(fifth_column) seventh_column&lt;-paste(first_column,sixth_column) eight_column&lt;-sort(seventh_column) ninth_coulmn&lt;-paste(first_column,eight_column) tenth_coulmn&lt;-sort(ninth_coulmn) elventh_coulmn&lt;-paste(first_column,tenth_coulmn) twelveth_coulmn&lt;-sort(elventh_coulmn) df&lt;-data.frame(first_column,second_column,third_column,fourth_column,fifth_column,sixth_column,seventh_column,eight_column,ninth_coulmn,tenth_coulmn,elventh_coulmn,twelveth_coulmn) df </code></pre>
[ { "answer_id": 74210890, "author": "Akash Ks", "author_id": 19341587, "author_profile": "https://Stackoverflow.com/users/19341587", "pm_score": -1, "selected": false, "text": "let btn = document.getElementById('button')\nbtn.addEventListener('click', () => {\n location.href = \"https:...
2022/10/26
[ "https://Stackoverflow.com/questions/74210693", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20333712/" ]
74,210,726
<p>I´am trying to call the function</p> <pre><code>getPost() </code></pre> <p>as soon as the url is called with an hashtag from the HashtagRepository as param. It should return an image link from the HashtagRepository when called. While testing the URL, my console just throws an error:</p> <pre><code>Cannot read properties of undefined(reading 'getPost') </code></pre> <p>I am a beginner and it's my first time working with Nest.JS and Typescript</p> <p>The HashtagRepository Class:</p> <pre><code>import { Injectable } from '@nestjs/common' type HashtaggedMedia = { image: string hashtag: string } @Injectable() export class HashtagRepository { private data: HashtaggedMedia[] = [ { image: 'https://scontent-frt3-2.cdninstagram.com/v/t51.2885-15/311661367_2148843741987513_3584984416517872912_n.webp?stp=dst-jpg_e35&amp;_nc_ht=scontent-frt3-2.cdninstagram.com&amp;_nc_cat=109&amp;_nc_ohc=sTRqy7BGzYkAX9Hj3Kd&amp;edm=AJ9x6zYBAAAA&amp;ccb=7-5&amp;ig_cache_key=Mjk0NzYxMjEwODY0NzE5NTU4OA%3D%3D.2-ccb7-5&amp;oh=00_AT8twEU1_NK0d_BiKbFaw7PFP8ihgiPz02pJkCpN2f65GQ&amp;oe=634F577F&amp;_nc_sid=cff2a4', hashtag: '#FranksBurgers', }, { image: 'https://scontent-frx5-1.cdninstagram.com/v/t51.2885-15/311152149_182028907724182_7846213112569143555_n.jpg?stp=dst-jpg_e35&amp;_nc_ht=scontent-frx5-1.cdninstagram.com&amp;_nc_cat=110&amp;_nc_ohc=t6dxbywE69YAX8_vRts&amp;edm=ALQROFkBAAAA&amp;ccb=7-5&amp;ig_cache_key=Mjk0NzMyODk5MDM0NDY0NzEyOQ%3D%3D.2-ccb7-5&amp;oh=00_AT8YzYRzkppuN9y8kL9cV_k8Z-gmL3PIbsnpCylyDr0x9w&amp;oe=635081E1&amp;_nc_sid=30a2ef', hashtag: '#FranksBurgers', }, { image: 'https://scontent-frt3-1.cdninstagram.com/v/t51.2885-15/251277124_605843170457678_5105607592633822570_n.jpg?stp=dst-jpg_e35&amp;_nc_ht=scontent-frt3-1.cdninstagram.com&amp;_nc_cat=102&amp;_nc_ohc=HXCQ2eywbUAAX8NVghy&amp;edm=ALQROFkBAAAA&amp;ccb=7-5&amp;ig_cache_key=MjY5NzQ0NDY1NTMzNzU2MTEyMw%3D%3D.2-ccb7-5&amp;oh=00_AT_9YGwuZnByJoXzMyunOdBH1kukXG2KAtsrBU71mMqdsw&amp;oe=6350DCD3&amp;_nc_sid=30a2ef', hashtag: '#FranksBurgers', }, { image: 'https://scontent-frx5-1.cdninstagram.com/v/t51.2885-15/271113427_238607281623214_5291842888525756529_n.jpg?stp=dst-jpg_e35&amp;_nc_ht=scontent-frx5-1.cdninstagram.com&amp;_nc_cat=110&amp;_nc_ohc=lSN2xj3PFfwAX9vnypL&amp;tn=Jrv1_r65tof7Hnsk&amp;edm=ALQROFkBAAAA&amp;ccb=7-5&amp;ig_cache_key=Mjc0MTY3NDI1MzI2NDU3MTUxMw%3D%3D.2-ccb7-5&amp;oh=00_AT-6rxO1Jd7kR9RQDy3ypDvc6mM1l0RJRbAtbxORP1L7lw&amp;oe=6350CBE8&amp;_nc_sid=30a2ef', hashtag: '#FranksBurgers', }, { image: 'empty', hashtag: 'franksburgers', }, ] } </code></pre> <p>The getPost() function in the HashTagRepositoryClass;</p> <pre><code> getPost(hashtag: string): Rest.HashtaggedMediaResponse { const images = this.data .filter((hashtaggedMedia) =&gt; hashtaggedMedia.hashtag===hashtag).map((hashtaggedMedia) =&gt; hashtaggedMedia.image)return { hashtag: hashtag, images, } } } </code></pre> <p>The Service class:</p> <pre><code>import { Injectable } from '@nestjs/common' import { FollowerCount } from './misc/follower-count.mock' import { HashtagRepository } from './misc/hashtag-repository.mock' @Injectable() export class AppService { hashtagRepository: HashtagRepository constructor( private followerCount: FollowerCount, private getPost: HashtagRepository, ) {} async fetchFollowerCount( profileHandle: string, ): Promise&lt;Rest.FollowerCountResponse&gt; { return this.followerCount.getCount(profileHandle) } async fetchPosts(hashtag: string): Promise&lt;Rest.HashtaggedMediaResponse&gt; { return this.hashtagRepository.getPost(hashtag) } } </code></pre> <p>The Controller class:</p> <pre><code>import { BadRequestException, Controller, Get, Param } from '@nestjs/common' import { AppService } from './app.service' @Controller() export class AppController { constructor(private readonly appService: AppService) {} @Get('/instagram/profiles/:profileHandle/') fetchFollowerCount(@Param('profileHandle') profileHandle?: string) { if (!profileHandle) throw new BadRequestException('Invalid ProfileHandle provided') return this.appService.fetchFollowerCount(profileHandle) } @Get('instagram/:hashtag/') fetchPosts(@Param('hashtag') hashtag?: string) { if (!hashtag) throw new BadRequestException('Invalid ImageLink provided') return this.appService.fetchPosts(hashtag) } } </code></pre> <p>I already tried to log if the function is even called, but without any result</p>
[ { "answer_id": 74210809, "author": "caTS", "author_id": 18244921, "author_profile": "https://Stackoverflow.com/users/18244921", "pm_score": 2, "selected": false, "text": "export class AppService {\n constructor(\n private followerCount: FollowerCount,\n private hashtagRe...
2022/10/26
[ "https://Stackoverflow.com/questions/74210726", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17102050/" ]
74,210,746
<p>I am working in a tool that uses Fancytree for lists. Currently when I drag and drop an item to nest it, the parent item will expand. I'd like to turn this off so that Fancytree remains in whatever state it's in. I've got a minimal coding background, but know enough that I think I can find the setting if I know what I am looking for.</p> <p>I've searched though the various files and tried to find the specific behavior configurations but so far, the changes I have made and tested have not resolved it.</p> <p>Thanks!</p>
[ { "answer_id": 74210809, "author": "caTS", "author_id": 18244921, "author_profile": "https://Stackoverflow.com/users/18244921", "pm_score": 2, "selected": false, "text": "export class AppService {\n constructor(\n private followerCount: FollowerCount,\n private hashtagRe...
2022/10/26
[ "https://Stackoverflow.com/questions/74210746", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20341095/" ]
74,210,753
<p>I have a small spreadsheet that is intended to display current freight costs per shipping merchant, by shipping port and by office location.</p> <p>I also have a smaller summary table that displays per shipping port, the cheapest rate, the merchant offering it, and the location to which it applies.</p> <p>The main table is administered by our end-users, but the smaller table should update itself based on the end-user's inputs.</p> <p><a href="https://i.stack.imgur.com/ZJiM8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZJiM8.png" alt="Merchant rates" /></a></p> <p>The values in the red box are how it should look. I have managed to display the lowest rate in its row by using AGGREGATE.</p> <p>But I cannot work out how to insert the corresponding depot and merchant into the summary in the same way. I've tried various combinations of INDEX, MATCH, VLOOKUP and HLOOKUP without success - it usually ends up with a circular reference somewhere.</p> <p>L</p>
[ { "answer_id": 74211680, "author": "Isolated", "author_id": 13118009, "author_profile": "https://Stackoverflow.com/users/13118009", "pm_score": 0, "selected": false, "text": "INDEX/MATCH" }, { "answer_id": 74216448, "author": "Mayukh Bhattacharya", "author_id": 8162520, ...
2022/10/26
[ "https://Stackoverflow.com/questions/74210753", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11085673/" ]
74,210,793
<p>I'm sort of a beginner to python right now. I work in VScode. After I downloaded python 3.11, I was experiencing issues in VScode (importing and installing libraries wasn't working). I realized I had multiple python versions on my disk, so I decided to do a purge to see if the issue would fix itself.</p> <p>-What I Did- I looked for every application and file with &quot;python&quot; in the name on my computer and removed it. I checked my environment variables for anything with &quot;python&quot; in the name, and I couldn't find anything. I thought I got everything, but when I reinstalled python 3.11, I still got errors when installing libraries like pygame with pip. I think I may have screwed up.</p> <p>-What I Think I Need To Do- There might be a file I missed somewhere in my C drive, but I'd have no idea where it is. If that isn't the issue, perhaps it has something to do with VScode and its settings not updating. Or, maybe it's an issue with pip. I'm confident I got rid of pip myself, but there could be other files out there that are tougher to recognize. I don't think it's an environment variable issue, because I see nothing with &quot;python&quot; in its name.</p> <p>So, what should I do? I'm not exactly sure where the problem is, or how to backtrack if I messed up somewhere. All I know is that:</p> <ol> <li>It was working before I installed python 3.11.</li> <li>The old python versions I used were 3.9.12 + 3.10, with the 3.9.12 saying &quot;global&quot; next to it when I pulled up the environment in VScode.</li> <li>It's not working properly now when I remove everything and install only 3.11.</li> </ol> <p>EDIT: Here's the error I got when I tried to install pygame with pip (it's long):</p> <pre><code>Defaulting to user installation because normal site-packages is not writeable Collecting pygame Using cached pygame-2.1.2.tar.gz (10.1 MB) Preparing metadata (setup.py) ... error error: subprocess-exited-with-error × python setup.py egg_info did not run successfully. │ exit code: 1 ╰─&gt; [77 lines of output] WARNING, No &quot;Setup&quot; File Exists, Running &quot;buildconfig/config.py&quot; Using WINDOWS configuration... Traceback (most recent call last): File &quot;&lt;string&gt;&quot;, line 2, in &lt;module&gt; File &quot;&lt;pip-setuptools-caller&gt;&quot;, line 34, in &lt;module&gt; File &quot;C:\Users\{My Name}\AppData\Local\Temp\pip-install-df9zydxm\pygame_7c731a410ab843a58a7dc3cf14f8979c\setup.py&quot;, line 359, in &lt;module&gt; buildconfig.config.main(AUTO_CONFIG) File &quot;C:\Users\{My Name}\AppData\Local\Temp\pip-install-df9zydxm\pygame_7c731a410ab843a58a7dc3cf14f8979c\buildconfig\config.py&quot;, line 225, in main deps = CFG.main(**kwds) ^^^^^^^^^^^^^^^^ File &quot;C:\Users\{My Name}\AppData\Local\Temp\pip-install-df9zydxm\pygame_7c731a410ab843a58a7dc3cf14f8979c\buildconfig\config_win.py&quot;, line 511, in main return setup_prebuilt_sdl2(prebuilt_dir) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File &quot;C:\Users\{My Name}\AppData\Local\Temp\pip-install-df9zydxm\pygame_7c731a410ab843a58a7dc3cf14f8979c\buildconfig\config_win.py&quot;, line 471, in setup_prebuilt_sdl2 DEPS.configure() File &quot;C:\Users\{My Name}\AppData\Local\Temp\pip-install-df9zydxm\pygame_7c731a410ab843a58a7dc3cf14f8979c\buildconfig\config_win.py&quot;, line 336, in configure from . import vstools File &quot;C:\Users\{My Name}\AppData\Local\Temp\pip-install-df9zydxm\pygame_7c731a410ab843a58a7dc3cf14f8979c\buildconfig\vstools.py&quot;, line 11, in &lt;module&gt; compiler.initialize() File &quot;C:\Program Files\Python311\Lib\site-packages\setuptools\_distutils\msvc9compiler.py&quot;, line 403, in initialize vc_env = query_vcvarsall(VERSION, plat_spec) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File &quot;C:\Program Files\Python311\Lib\site-packages\setuptools\_distutils\msvc9compiler.py&quot;, line 281, in query_vcvarsall raise DistutilsPlatformError(&quot;Unable to find vcvarsall.bat&quot;) distutils.errors.DistutilsPlatformError: Unable to find vcvarsall.bat Making dir :prebuilt_downloads: Downloading... https://www.libsdl.org/release/SDL2-devel-2.0.18-VC.zip ed561079ec622b0bab5a9e02976f5d540b0622da Unzipping :prebuilt_downloads\SDL2-devel-2.0.18-VC.zip: Downloading... https://www.libsdl.org/projects/SDL_image/release/SDL2_image-devel-2.0.5-VC.zip 137f86474691f4e12e76e07d58d5920c8d844d5b Unzipping :prebuilt_downloads\SDL2_image-devel-2.0.5-VC.zip: Downloading... https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-devel-2.0.15-VC.zip 1436df41ebc47ac36e02ec9bda5699e80ff9bd27 Unzipping :prebuilt_downloads\SDL2_ttf-devel-2.0.15-VC.zip: Downloading... https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-devel-2.0.4-VC.zip 9097148f4529cf19f805ccd007618dec280f0ecc Unzipping :prebuilt_downloads\SDL2_mixer-devel-2.0.4-VC.zip: Downloading... https://www.pygame.org/ftp/jpegsr9d.zip ed10aa2b5a0fcfe74f8a6f7611aeb346b06a1f99 Unzipping :prebuilt_downloads\jpegsr9d.zip: Downloading... https://pygame.org/ftp/prebuilt-x64-pygame-1.9.2-20150922.zip 3a5af3427b3aa13a0aaf5c4cb08daaed341613ed Unzipping :prebuilt_downloads\prebuilt-x64-pygame-1.9.2-20150922.zip: copying into .\prebuilt-x64 Path for SDL: prebuilt-x64\SDL2-2.0.18 ...Library directory for SDL: prebuilt-x64/SDL2-2.0.18/lib/x64 ...Include directory for SDL: prebuilt-x64/SDL2-2.0.18/include Path for FONT: prebuilt-x64\SDL2_ttf-2.0.15 ...Library directory for FONT: prebuilt-x64/SDL2_ttf-2.0.15/lib/x64 ...Include directory for FONT: prebuilt-x64/SDL2_ttf-2.0.15/include Path for IMAGE: prebuilt-x64\SDL2_image-2.0.5 ...Library directory for IMAGE: prebuilt-x64/SDL2_image-2.0.5/lib/x64 ...Include directory for IMAGE: prebuilt-x64/SDL2_image-2.0.5/include Path for MIXER: prebuilt-x64\SDL2_mixer-2.0.4 ...Library directory for MIXER: prebuilt-x64/SDL2_mixer-2.0.4/lib/x64 ...Include directory for MIXER: prebuilt-x64/SDL2_mixer-2.0.4/include Path for PORTMIDI: prebuilt-x64 ...Library directory for PORTMIDI: prebuilt-x64/lib ...Include directory for PORTMIDI: prebuilt-x64/include DLL for SDL2: prebuilt-x64/SDL2-2.0.18/lib/x64/SDL2.dll DLL for SDL2_ttf: prebuilt-x64/SDL2_ttf-2.0.15/lib/x64/SDL2_ttf.dll DLL for SDL2_image: prebuilt-x64/SDL2_image-2.0.5/lib/x64/SDL2_image.dll DLL for SDL2_mixer: prebuilt-x64/SDL2_mixer-2.0.4/lib/x64/SDL2_mixer.dll DLL for portmidi: prebuilt-x64/lib/portmidi.dll Path for FREETYPE not found. ...Found include dir but no library dir in prebuilt-x64. Path for PNG not found. ...Found include dir but no library dir in prebuilt-x64. Path for JPEG not found. ...Found include dir but no library dir in prebuilt-x64. DLL for freetype: prebuilt-x64/SDL2_ttf-2.0.15/lib/x64/libfreetype-6.dll --- For help with compilation see: https://www.pygame.org/wiki/CompileWindows To contribute to pygame development see: https://www.pygame.org/contribute.html --- [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed × Encountered error while generating package metadata. ╰─&gt; See above for output. note: This is an issue with the package mentioned above, not pip. hint: See above for details. </code></pre>
[ { "answer_id": 74211680, "author": "Isolated", "author_id": 13118009, "author_profile": "https://Stackoverflow.com/users/13118009", "pm_score": 0, "selected": false, "text": "INDEX/MATCH" }, { "answer_id": 74216448, "author": "Mayukh Bhattacharya", "author_id": 8162520, ...
2022/10/26
[ "https://Stackoverflow.com/questions/74210793", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20206433/" ]
74,210,804
<p>I used the latest method recommended by the <strong>Antd</strong> to build the menu (<a href="https://ant.design/components/menu/#header" rel="nofollow noreferrer">https://ant.design/components/menu/#header</a>). But the official document does not provide a method for how to pass props. I want to <strong>pass the project.id into menuItems from Menu component</strong>, so 'edit' and 'delete' in menuItems can accept project.id and trigger different functions. I would like to ask if is there any way to pass props.</p> <pre class="lang-js prettyprint-override"><code>import styled from '@emotion/styled'; import { ListProps } from '../types'; import { Table, Dropdown, Menu, Button } from 'antd'; import dayjs from 'dayjs'; import { Link } from 'react-router-dom'; import { Pin } from 'components/Pin'; import { useEditProject } from 'utils/project'; import { DeleteOutlined, EditOutlined, MoreOutlined } from '@ant-design/icons'; import { useProjectModal } from '../hooks/useProjectModal'; import type { MenuProps } from 'antd'; const List = ({ users, ...props }: ListProps) =&gt; { const { open } = useProjectModal(); const { mutate } = useEditProject(); const { startEdit } = useProjectModal(); const pinProject = (id: number) =&gt; (pin: boolean) =&gt; mutate({ id, pin }); const editProject = (id: number) =&gt; () =&gt; startEdit(id); const menuItems = [ { key: 'edit', label: &lt;ButtonItem type=&quot;link&quot;&gt;Edit&lt;/ButtonItem&gt;, icon: &lt;EditOutlinedIcon /&gt; // onClick: editProject() }, { key: 'delete', label: &lt;ButtonItem type=&quot;link&quot;&gt;Delete&lt;/ButtonItem&gt;, icon: &lt;DeleteOutlinedIcon /&gt; } ]; return ( &lt;Table rowKey={'id'} columns={[ { render(value, project) { return ( &lt;Dropdown overlay={&lt;Menu items={menuItems} /&gt;} trigger={['click']} &gt; &lt;MoreOutlinedIcon /&gt; &lt;/Dropdown&gt; ); } } ]} {...props} &gt;&lt;/Table&gt; ); }; export default List; </code></pre>
[ { "answer_id": 74211680, "author": "Isolated", "author_id": 13118009, "author_profile": "https://Stackoverflow.com/users/13118009", "pm_score": 0, "selected": false, "text": "INDEX/MATCH" }, { "answer_id": 74216448, "author": "Mayukh Bhattacharya", "author_id": 8162520, ...
2022/10/26
[ "https://Stackoverflow.com/questions/74210804", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14877188/" ]
74,210,811
<p>In simple words I am trying -</p> <pre><code>$animal = &quot;cat&quot;, &quot;dog&quot;, &quot;rabbit&quot; $animal -contains &quot;dog&quot; # -----&gt; Getting true, which is working! </code></pre> <p>However, when I try to check multiple values like -</p> <pre><code>$animal -contains &quot;dog&quot; -and &quot;bat&quot; # --&gt; still getting a &quot;True&quot; response. </code></pre> <p>How can I check multiple values using contains operator?</p>
[ { "answer_id": 74211024, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 3, "selected": true, "text": "$animal -contains \"dog\" -and $animal -contains \"bat\"\n" }, { "answer_id": 74211054, "author": "Santia...
2022/10/26
[ "https://Stackoverflow.com/questions/74210811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3501581/" ]
74,210,815
<p><a href="https://i.stack.imgur.com/HcKBp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HcKBp.png" alt="enter image description here" /></a> As you can see in screenshot there is huge whitespaces between 4.0 out of 5 stars and 12,467 ratings. How to remove that whitespace?</p> <p>I tried strip(), split(), replace() but i am not getting expected output</p>
[ { "answer_id": 74210916, "author": "Nathan Roberts", "author_id": 17135653, "author_profile": "https://Stackoverflow.com/users/17135653", "pm_score": 2, "selected": false, "text": "re" }, { "answer_id": 74211230, "author": "amirali mollaei", "author_id": 13897386, "au...
2022/10/26
[ "https://Stackoverflow.com/questions/74210815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20341051/" ]
74,210,881
<p>everybody! Really, I just want to understand what is going on with this references and pointers. Can you explain me, why in one case all is workking fine, but in another I receive nothing I will start with working case. So, there is a program (this is not mine):</p> <pre><code>#include &lt;iostream&gt; #include &lt;conio.h&gt; using namespace std; struct node{ double data; node *left; node *right; }; node *tree = NULL; void push(int a, node **t) { if ((*t) == NULL) { (*t) = new node; (*t)-&gt;data = a; (*t)-&gt;left = (*t)-&gt;right = NULL; return; } if (a &gt; (*t)-&gt;data) push(a, &amp;(*t)-&gt;right); else push(a, &amp;(*t)-&gt;left); } void print (node *t, int u) { if (t == NULL) return; else { print(t-&gt;left, ++u); for (int i=0; i&lt;u; ++i) cout &lt;&lt; &quot;|&quot;; cout &lt;&lt; t-&gt;data &lt;&lt; endl; u--; } print(t-&gt;right, ++u); } int main () { int n; int s; cout &lt;&lt; &quot;Enter the amount of elements &quot;; cin &gt;&gt; n; for (int i=0; i&lt;n; ++i) { cout &lt;&lt; &quot;Enter the value &quot;; cin &gt;&gt; s; push(s, &amp;tree); } cout &lt;&lt; &quot;Your binary tree\n&quot;; print(tree, 0); cin.ignore().get(); } </code></pre> <p>This is binary search tree made with struct, pointers and references. And it is work exactly fine But if i modify program in the way below it doesn't work. And i don't understand why, because</p> <pre><code>int *tree; int **treePointer; cout &lt;&lt; (tree = *treePointer) &lt;&lt;endl; // Shows 1 i.e. true </code></pre> <p>Modified code:</p> <pre><code> #include &lt;iostream&gt; #include &lt;conio.h&gt; using namespace std; struct node{ double data; node *left; node *right; }; node *tree = NULL; void push(int a, node *t) { if ((t) == NULL) { (t) = new node; (t)-&gt;data = a; (t)-&gt;left = (t)-&gt;right = NULL; return; } if (a &gt; (t)-&gt;data) push(a, (t)-&gt;right); else push(a, (t)-&gt;left); } void print (node *t, int u) { if (t == NULL) return; else { print(t-&gt;left, ++u); for (int i=0; i&lt;u; ++i) cout &lt;&lt; &quot;|&quot;; cout &lt;&lt; t-&gt;data &lt;&lt; endl; u--; } print(t-&gt;right, ++u); } int main () { int n; int s; cout &lt;&lt; &quot;Enter the amount of elements &quot;; cin &gt;&gt; n; for (int i=0; i&lt;n; ++i) { cout &lt;&lt; &quot;Enter the value &quot;; cin &gt;&gt; s; push(s, tree); } cout &lt;&lt; &quot;Your binary tree\n&quot;; print(tree, 0); cin.ignore().get(); } </code></pre> <p>As you see, all changes happen in push function argument. Why it is not working?</p> <p>I am expecting that original program and modified will work the same</p>
[ { "answer_id": 74211088, "author": "Simon Fry", "author_id": 6459640, "author_profile": "https://Stackoverflow.com/users/6459640", "pm_score": 0, "selected": false, "text": "(t) = new node;\n" }, { "answer_id": 74211363, "author": "Atharva Dubey", "author_id": 13594617, ...
2022/10/26
[ "https://Stackoverflow.com/questions/74210881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19700698/" ]
74,210,887
<p>I have a table:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Player</th> <th>Team</th> <th>GS</th> </tr> </thead> <tbody> <tr> <td>Jack</td> <td>A</td> <td>NaN</td> </tr> <tr> <td>John</td> <td>B</td> <td>1</td> </tr> <tr> <td>Mike</td> <td>A</td> <td>1</td> </tr> <tr> <td>James</td> <td>A</td> <td>1</td> </tr> </tbody> </table> </div> <p>And would like to make 2 separate lists (TeamA &amp; TeamB) so that they players are split by team and also filters so that the players that have a '1' in GS are only part of the list. The final lists would look like:</p> <pre><code>TeamA = Mike, James TeamB = John </code></pre> <p>In this case, Jack was excluded from the TeamA list because he did not have a 1 value in the GS column.</p> <p>Any direction would help. Thanks!</p>
[ { "answer_id": 74211088, "author": "Simon Fry", "author_id": 6459640, "author_profile": "https://Stackoverflow.com/users/6459640", "pm_score": 0, "selected": false, "text": "(t) = new node;\n" }, { "answer_id": 74211363, "author": "Atharva Dubey", "author_id": 13594617, ...
2022/10/26
[ "https://Stackoverflow.com/questions/74210887", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20151832/" ]
74,210,889
<p>I'm trying to create a Regex to match numbers, special chars, spaces and a specific whole word (&quot;ICT&quot;).</p> <p>Example for the string:</p> <pre><code>[Columbia (ICT-59)] </code></pre> <p>Currently I've this Regex to match the numbers, special chars and spaces:</p> <pre><code>[\W\s\d] </code></pre> <p>And this one to for the word &quot;ICT&quot;:</p> <pre><code>(ICT) </code></pre> <p>How can I match both of this in one Regular expression?</p>
[ { "answer_id": 74211088, "author": "Simon Fry", "author_id": 6459640, "author_profile": "https://Stackoverflow.com/users/6459640", "pm_score": 0, "selected": false, "text": "(t) = new node;\n" }, { "answer_id": 74211363, "author": "Atharva Dubey", "author_id": 13594617, ...
2022/10/26
[ "https://Stackoverflow.com/questions/74210889", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10802094/" ]
74,210,892
<p>Inside Visual Studio 2022, I have a &quot;Shared Project&quot; and I want to add a &quot;Resource File (*.resx)&quot;, but it's not listed inside the available elements.</p> <p>But if I try to add it to a &quot;Windows Forms App&quot;, it works as well.</p> <p><strong>How can I add a &quot;Resource File (*.resx)&quot; to a &quot;Shared Project&quot;?</strong></p>
[ { "answer_id": 74211088, "author": "Simon Fry", "author_id": 6459640, "author_profile": "https://Stackoverflow.com/users/6459640", "pm_score": 0, "selected": false, "text": "(t) = new node;\n" }, { "answer_id": 74211363, "author": "Atharva Dubey", "author_id": 13594617, ...
2022/10/26
[ "https://Stackoverflow.com/questions/74210892", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20138168/" ]
74,210,907
<p>In SQL Server, I have an existing <code>Document_Add</code> stored procedure that works and returns a good <code>DocID</code> value (in Visual Studio vb code) and cannot change. Calling it like this in SQL:</p> <pre><code>EXEC @DocID = PADS2.dbo.Document_Add @SystemCode... </code></pre> <p>This runs the stored procedure, but <code>@DocID</code> is always 0 (whether declared as <code>INT</code> or <code>varchar</code>).</p> <p>Expecting <code>@DocID</code> to be 2594631 or similar.</p> <p>Any ideas?</p>
[ { "answer_id": 74211088, "author": "Simon Fry", "author_id": 6459640, "author_profile": "https://Stackoverflow.com/users/6459640", "pm_score": 0, "selected": false, "text": "(t) = new node;\n" }, { "answer_id": 74211363, "author": "Atharva Dubey", "author_id": 13594617, ...
2022/10/26
[ "https://Stackoverflow.com/questions/74210907", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20304191/" ]
74,210,915
<p>I need to clone a div that contains an input file, and within the clone, there is a button to delete the created clone. My problem is that once the clone is created I cannot add the function on the button to delete the clone. The function does not work. Where am I wrong?</p> <pre class="lang-js prettyprint-override"><code>if (document.querySelector('.clona-input-file') !== null) { var clonaInputFile = document.querySelector('.clona-input-file'); clonaInputFile.addEventListener('click', function(e) { e.preventDefault(); var RowDaClonare = document.querySelector('#row-da-clonare'); var clone = RowDaClonare.cloneNode(true); clone.children[0].lastElementChild.value = ''; clone.id = 'row-da-clonare-' + Date.now(); RowDaClonare.after(clone); var _buttonDel = document.createElement(&quot;button&quot;); _buttonDel.id = 'cancellaInputClone'; _buttonDel.type = 'button'; _buttonDel.setAttribute(&quot;data-id-da-eliminare&quot;, clone.id); _buttonDel.classList.add(&quot;btn&quot;); _buttonDel.classList.add(&quot;btn-danger&quot;); _buttonDel.classList.add(&quot;cancellaInputClone&quot;); _buttonDel.innerHTML = '&lt;i class=&quot;bi bi-trash-fill&quot;&gt;&lt;/i&gt;'; clone.appendChild(_buttonDel); }); } var cloneSet = document.querySelectorAll(&quot;.cancellaInputClone&quot;); for (var i = 0; i &lt; cloneSet.length; i++) { cloneSet[i].addEventListener('click', fx_button); } function fx_button() { console.log(this) } </code></pre>
[ { "answer_id": 74211088, "author": "Simon Fry", "author_id": 6459640, "author_profile": "https://Stackoverflow.com/users/6459640", "pm_score": 0, "selected": false, "text": "(t) = new node;\n" }, { "answer_id": 74211363, "author": "Atharva Dubey", "author_id": 13594617, ...
2022/10/26
[ "https://Stackoverflow.com/questions/74210915", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2077311/" ]
74,210,933
<p>I'm trying to get my code to write the following list( a list of 3 floats) in a CSV file in 3 rows.</p> <pre><code>least_scores=[14.285714285714286, 14.375, 16.5] </code></pre> <p>I want it to be saved in rows in the CSV file like below:</p> <pre><code>14.285714285714286 14.375 16.5 </code></pre> <p>but the program save all the numbers in one row or when I change the code I get the error that float is not iterable. I have tried many things and checked a lot of similar questions here and there, but I can not find the solution to my problem.</p> <p>the following codes are the things that I have tried so far:</p> <pre><code>import csv from statistics import mean with open(&quot;E:\\Chapter5\input_file_name.csv&quot;) as inputi: data_list=[] score_list=[] mean_list=[] reader=csv.reader(inputi) for rows in reader: data_list.append(rows) #print(len(data_list)) for i in range(0,len(data_list)): score_list.append(data_list[i][1:]) #print(score_list) new_list=[ [float(x) for x in nested_lists] for nested_lists in score_list ] #print(new_list) for items in new_list: mean_list.append(mean(items)) #print(mean_list) least_scores=sorted(mean_list) least_scores=least_scores[0:3] print(least_scores) with open(&quot;E:\\Chapter5\output_file_name.csv&quot;,'w',newline='') as outi: writer=csv.writer(outi) writer.writerow(least_scores) </code></pre> <p>with the above code the list items will all be saved in a single row.</p> <p>so I tries <code>writer.writerows</code> instead of <code>writer.writero</code>w but I got the error &quot;iterable expected, not float&quot;</p> <p>the I tried the following code:</p> <pre><code>with open(&quot;E:\\Chapter5\output_file_name.csv&quot;,'w',newline='') as outi: writer=csv.writer(outi) for nums in least_scores: writer.writerows(nums) </code></pre> <p>and got the error &quot;'float' object is not iterable&quot; Could you please help me solve this issue please?</p>
[ { "answer_id": 74211067, "author": "Aron Atilla Hegedus", "author_id": 10846729, "author_profile": "https://Stackoverflow.com/users/10846729", "pm_score": 0, "selected": false, "text": "least_scores" }, { "answer_id": 74211099, "author": "Jorge Gx", "author_id": 9420118, ...
2022/10/26
[ "https://Stackoverflow.com/questions/74210933", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19288017/" ]
74,210,957
<p>So I'm pretty new to js. I've tried to make a button that logs <code>hey</code> in the console, but it already logs it before clicking the button. And when clicking the button it won't do anything. This is my code.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>let btn1 = document.getElementById("btn1"); btn1.onclick = console.log('hey');</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="UTF-8"&gt; &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt; &lt;title&gt;Document&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;input value="test" type="button" id="btn1" data="onclick"&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74210990, "author": "David", "author_id": 328193, "author_profile": "https://Stackoverflow.com/users/328193", "pm_score": 2, "selected": false, "text": "btn1.onclick = console.log('hey');\n" }, { "answer_id": 74211073, "author": "Usitha Indeewara", "author_...
2022/10/26
[ "https://Stackoverflow.com/questions/74210957", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20341164/" ]
74,210,964
<p>For example: How do I match the words <code>kein</code>, <code>keine</code>, <code>keiner</code> or <code>keines</code> with regex.</p> <p>I know how I can check for optional characters:</p> <pre><code>\bkein(?:e)?(?:r|s)?\b </code></pre> <p>But this way I would also match <code>keins</code> and <code>keinr</code> which is not what I want.</p>
[ { "answer_id": 74210990, "author": "David", "author_id": 328193, "author_profile": "https://Stackoverflow.com/users/328193", "pm_score": 2, "selected": false, "text": "btn1.onclick = console.log('hey');\n" }, { "answer_id": 74211073, "author": "Usitha Indeewara", "author_...
2022/10/26
[ "https://Stackoverflow.com/questions/74210964", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15378847/" ]
74,210,966
<p>I am studying for my PCEP and in the practice set there is a syntax for referencing lists I don't understand. Given:</p> <pre><code>numbers = [2, 3, 5, 8] print(numbers[numbers[0]]) print(numbers[0]) </code></pre> <p>The first print statement I can't understand, how am I getting 5 as the output? The second statement makes sense, it's how I have done it in the past which is index 0 but what is the first print statement doing? Calling a list within a list like a nested list? And how am I getting to index 2 to get the output of 5?</p> <p>Thanks in advance for your help/time, it's much appreciated.</p> <p>I've tried changing the refrenced index and counting through the list twice but often times I am seeing an index out of range response, or a number I wasn't expected. e.g, setting the print statement to</p> <pre><code>print(numbers[numbers[1]]) </code></pre> <p>Gives me the output of '8' and I don't understand how I am to get there with the index of 1.</p>
[ { "answer_id": 74211148, "author": "Barmar", "author_id": 1491895, "author_profile": "https://Stackoverflow.com/users/1491895", "pm_score": 0, "selected": false, "text": "print(numbers[numbers[0]])\n" } ]
2022/10/26
[ "https://Stackoverflow.com/questions/74210966", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20341257/" ]
74,210,984
<p>This might be a dumb question, i'm very sorry if that's the case. But i'm struggling to take advantage of the multiple cores in my computer to perform multiple computations at the same time in my Quad-Core MacBook. This is not for any particular project, just a general question, since i want to learn for when i eventually do need to do this kind of things</p> <p>I am aware of threads, but the seem to run in the same core, so i don't seem to gain any performance using them for compute-bound operations (They are very useful for socket based stuff tho!).</p> <p>I'm also aware of processed that can be created with fork, but i'm nor sure they are guaranteed to use more CPU, or if they, like threads, just help with IO-bound operations.</p> <p>Finally i'm aware of CUDA, allowing paralellism in the GPU (And i think OpenCL and Compute Shaders also allows my code to run in the CPU in parallel) but i'm currently looking for something that will allow me to take advantage of the multiple CPU cores that my computer has.</p> <p>In python, i'm aware of the multiprocessing module, which seems to provide an API very similar to threads, but there i do seem to gain an edge by running multiple functions performing computations in parallel. I'm looking into how could i get this same advantage in C, but i don't seem to be able</p> <p>Any help pointing me to the right direction would be very much appreciated</p> <p>Note: I'm trying to achive true parallelism, not concurrency</p> <p>Note 2: I'm only aware of threads and using multiple processes in C, with threads i don't seem to be able to win the performance boost i want. And i'm not very familiar with processes, but i'm still not sure if running multiple processes is guaranteed to give me the advantage i'm looking for.</p>
[ { "answer_id": 74211667, "author": "Erdal Küçük", "author_id": 11867590, "author_profile": "https://Stackoverflow.com/users/11867590", "pm_score": 2, "selected": true, "text": "#include <pthread.h>\n\nvoid* func(void *arg)\n{\n while (1);\n}\n\nint main()\n{\n #define NUM_THREADS 4...
2022/10/26
[ "https://Stackoverflow.com/questions/74210984", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12641617/" ]
74,210,989
<p>I need to sum the result of a formula, repeated several times, which has a single value that changes from 1 to 180.The final formula must be contained in a single cell.</p> <p><a href="https://i.stack.imgur.com/WZ1X5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WZ1X5.png" alt="my table" /></a></p> <ol> <li>Column A contains values ​​from 1 to 180 (to simplify in the example I have only put 13).</li> <li>Cell B1 contains a value expressed as a percentage.</li> <li>Column C (C1 to C13) contains the following formula (cell C1 in the example): <code>=+((1/(1+(A1*1/12*$B$1)))).</code></li> <li>Cell C14 contains the sum of all results.</li> </ol> <p>By defining X the variable value of column A, the formula is in practice the following: <a href="https://i.stack.imgur.com/qYkUE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qYkUE.png" alt="formula" /></a></p> <p>Column A will be not present in my sheet, so therefore I cannot refer my formula to the contents of any cell. My need is to have only two cells in my sheet: B1, with the rate value; and C1, with the sum of the products with X from 1 to 180. That is what is contained in cell C14.</p> <p>Thanks for your help and for your patience with my bad English.</p>
[ { "answer_id": 74211667, "author": "Erdal Küçük", "author_id": 11867590, "author_profile": "https://Stackoverflow.com/users/11867590", "pm_score": 2, "selected": true, "text": "#include <pthread.h>\n\nvoid* func(void *arg)\n{\n while (1);\n}\n\nint main()\n{\n #define NUM_THREADS 4...
2022/10/26
[ "https://Stackoverflow.com/questions/74210989", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19836730/" ]
74,211,069
<p>I am trying to display items, but only {Binding Peso} is displayed. If you change {Binding Peso} and use{Binding Contenido} you can see that it is displayed OK Any Help Pls? `</p> <pre><code> &lt;ListView x:Name=&quot;PaqueteList&quot;&gt; &lt;ListView.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;ViewCell&gt; &lt;Grid &gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width=&quot;1*&quot;&gt;&lt;/ColumnDefinition&gt; &lt;ColumnDefinition Width=&quot;1*&quot;&gt;&lt;/ColumnDefinition&gt; &lt;ColumnDefinition Width=&quot;1*&quot;&gt;&lt;/ColumnDefinition&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height=&quot;Auto&quot; /&gt; &lt;/Grid.RowDefinitions&gt; &lt;Frame BorderColor=&quot;Black&quot;&gt; &lt;StackLayout Margin=&quot;5&quot; Grid.Column=&quot;0&quot; Orientation=&quot;Vertical&quot; HorizontalOptions=&quot;StartAndExpand&quot; VerticalOptions=&quot;Center&quot;&gt; &lt;Label Text =&quot;{Binding Peso}&quot; TextColor=&quot;Blue&quot; BackgroundColor=&quot;White&quot; /&gt; &lt;Label Grid.Column=&quot;1&quot; Text =&quot;{Binding TrackingNumber} &quot; TextColor=&quot;Blue&quot; BackgroundColor=&quot;White&quot; /&gt; &lt;Label Grid.Column=&quot;2&quot; Text =&quot;{Binding Contenido}&quot; TextColor=&quot;Blue&quot; BackgroundColor=&quot;White&quot; /&gt; &lt;/StackLayout&gt; &lt;/Frame&gt; &lt;/Grid&gt; &lt;/ViewCell&gt; &lt;/DataTemplate&gt; &lt;/ListView.ItemTemplate&gt; &lt;/ListView&gt; </code></pre> <p>I have changed the {Binding Peso} to {Binding Contenido} and so on, and it is works. I just need to display something like this</p> <p>Peso Tracking Contenido xx yyyyy zzzz xx yyyyy zzzz xx yyyyy zzzz</p>
[ { "answer_id": 74213753, "author": "Shaw", "author_id": 10366303, "author_profile": "https://Stackoverflow.com/users/10366303", "pm_score": 2, "selected": false, "text": "ViewCell" }, { "answer_id": 74218103, "author": "Alexandar May - MSFT", "author_id": 9644964, "au...
2022/10/26
[ "https://Stackoverflow.com/questions/74211069", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16394300/" ]
74,211,071
<p>For security purposes, I want to have an entity that returns an entire column value.</p> <p>Example of an entity: stored-procedure, function, table-valued function.</p> <p>Example:</p> <pre><code> CREATE OR REPLACE FUNCTION simpleSelect RETURN VARCHAR2 AS output1 VARCHAR2(100); BEGIN Select (col1 ) INTO output1 from SCHEMA1.TABLE1; RETURN output1; END ; </code></pre> <p>The above gives the following error:</p> <pre><code>[Error] Execution (17: 9): ORA-01422: exact fetch returns more than requested number of rows ORA-06512: </code></pre> <p>What would be the syntax to create the entity and also to call the entity?</p>
[ { "answer_id": 74213753, "author": "Shaw", "author_id": 10366303, "author_profile": "https://Stackoverflow.com/users/10366303", "pm_score": 2, "selected": false, "text": "ViewCell" }, { "answer_id": 74218103, "author": "Alexandar May - MSFT", "author_id": 9644964, "au...
2022/10/26
[ "https://Stackoverflow.com/questions/74211071", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42552/" ]
74,211,078
<p>I have a simple dataframe as the following:</p> <pre><code>n_obs = 3 dd = pd.DataFrame({ 'WTL_exploded': [0, 1, 2]*n_obs, 'hazard': [0.3, 0.4, 0.5, 0.2, 0.8, 0.9, 0.6,0.6,0.65], }, index=[1,1,1,2,2,2,3,3,3]) dd </code></pre> <p>I want to group by the <em>index</em> and get the cumulative product of the <code>hazard</code> column. However, I want to multiply <strong>all but the last element</strong> of each group.</p> <p><strong>Desired output:</strong></p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>index</th> <th>hazard</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>0.3</td> </tr> <tr> <td>1</td> <td>0.12</td> </tr> <tr> <td>2</td> <td>0.2</td> </tr> <tr> <td>2</td> <td>0.16</td> </tr> <tr> <td>3</td> <td>0.6</td> </tr> <tr> <td>3</td> <td>0.36</td> </tr> </tbody> </table> </div> <p>How can I do that?</p>
[ { "answer_id": 74211079, "author": "Luca Clissa", "author_id": 7678074, "author_profile": "https://Stackoverflow.com/users/7678074", "pm_score": 0, "selected": false, "text": "ff = dd.groupby(lambda x:x, as_index=False).apply(lambda x: x.iloc[:-1])\nff\n" }, { "answer_id": 742111...
2022/10/26
[ "https://Stackoverflow.com/questions/74211078", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7678074/" ]
74,211,095
<p>I encountered the problem during an interview. I had to create a multimap which had as keys objects with one private member(a string, the name of the object) and mapped value ints(not relevant). There was one restriction imposed by the person leading the interview: there should be not get or set functions associated to the member string of the object. After some processing of the multimap with STL functions(like removing some elements), the following was requested: to extract the name of the key objects into a vector while removing any duplicates. I do not know how to extract the name of the key objects without having a get function(I could remove the duplicates once the extraction is performed). The person leading the interview brought into discussion functors and possibility to use a functor which could be a friend of the Object class. Please let me know if you have any idea how this could be solved! I provide bellow a simplified version of the code creating the multimap.</p> <pre><code>class Object { std::string m_name; /* no set or get function allowed */ public: Object(std::string name): m_name(name) {} friend bool operator&lt; (const Object&amp; o1, const Object&amp; o2) { return o1.m_name.compare(o2.m_name) &lt; 0; } }; void testMap() { std::multimap&lt;Object, int&gt; m1; m1.insert(std::make_pair(Object(&quot;abc&quot;), 1)); m1.insert(std::make_pair(Object(&quot;qwerty&quot;), 2)); m1.insert(std::make_pair(Object(&quot;def&quot;), 3)); m1.insert(std::make_pair(Object(&quot;qwerty&quot;), 4)) /* extract Objects names in a vector while removing duplicates without adding a get m_name function */ } </code></pre> <p>Please let me know if you have any idea how this could be solved! I do not know how to access m_name which is private without a get function...</p>
[ { "answer_id": 74211726, "author": "Cyril Schmidt", "author_id": 3445473, "author_profile": "https://Stackoverflow.com/users/3445473", "pm_score": 0, "selected": false, "text": "class Object\n{\n std::string m_name; /* no set or get function allowed */\npublic:\n Object(std::string...
2022/10/26
[ "https://Stackoverflow.com/questions/74211095", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20338996/" ]
74,211,102
<pre><code>import random mobs = { &quot;enemys&quot;: { &quot;Stray Dog&quot;: { &quot;health&quot;: 3, &quot;strenth&quot;: 2, &quot;dexterity&quot;: 1, }, &quot;Hobo&quot;: { &quot;health&quot;: 4, &quot;strenth&quot;: 2, &quot;dexterity&quot;: 2, }, &quot;Mugger&quot;: { &quot;health&quot;: 5, &quot;strenth&quot;: 2, &quot;dexterity&quot;: 2, }, &quot;Cop&quot;: { &quot;health&quot;: 7, &quot;strenth&quot;: 3, &quot;dexterity&quot;: 2, }, &quot;Ninja&quot;: { &quot;health&quot;: 9, &quot;strenth&quot;: 2, &quot;dexterity&quot;: 4, } }, &quot;Player&quot;: { &quot;phealth&quot;: 100, &quot;pstrength&quot;: 1, &quot;pdexterity&quot;: 1, &quot;pconstitution&quot;: 1, }, } levelrn = 3 phealth = mobs[&quot;Player&quot;][&quot;phealth&quot;] pstrength = mobs[&quot;Player&quot;][&quot;pstrength&quot;] pdexterity = mobs[&quot;Player&quot;][&quot;pdexterity&quot;] pconstitution = mobs[&quot;Player&quot;][&quot;pconstitution&quot;] ehealth = 0 estrength = 0 edexterity = 0 curenemy = &quot;&quot; def level(): global levelrn global pconstitution global pstrength global pdexterity global curenemy global ehealth global edexterity global estrength global phealth levelrn =3 print(&quot;Level &quot; + str(levelrn) + &quot;\n---------&quot;) print(&quot;Health: &quot; + str(phealth)) print(&quot;Strenth: &quot; + str(pstrength)) print(&quot;Dexterity: &quot; + str(pdexterity)) print(&quot;Constitution: &quot; + str(pconstitution)) if levelrn == 1: curenemy = &quot;Stray Dog&quot; elif levelrn == 2: curenemy = &quot;Hobo&quot; elif levelrn == 3: curenemy = &quot;Mugger&quot; elif levelrn == 4: curenemy = &quot;Cop&quot; elif levelrn == 5: curenemy = &quot;Ninja&quot; estrength = mobs[&quot;enemys&quot;][curenemy][&quot;strenth&quot;] edexterity = mobs[&quot;enemys&quot;][curenemy][&quot;dexterity&quot;] ehealth = mobs[&quot;enemys&quot;][curenemy][&quot;health&quot;] print(&quot;You find your self pitted against a &quot; + curenemy + &quot;.&quot;) print(&quot;Choose One\n----------\nAttack!&quot;) userin = input() if userin == &quot;Attack&quot; or &quot;A&quot; or &quot;a&quot; or &quot;attack&quot;: if pdexterity &gt; edexterity: pgdex() else: pldex() def pgdex(): pdamage = random.randrange(1, 3) print(&quot;You dealt &quot; + str(pdamage) + &quot; damage!&quot;) global ehealth ehealth -= pdamage pldex() def pldex(): if mobs[&quot;enemys&quot;][curenemy][&quot;strenth&quot;] == estrength: edamage = random.randrange(estrength - 1, estrength + 1) print(&quot;You took &quot; + str(edamage) + &quot; damage!&quot;) global phealth phealth -= edamage print(&quot;Hp: &quot; + phealth) pgdex() level() </code></pre> <p>This is the output of the code:</p> <pre><code>Level 1 --------- Health: 100 Strength: 1 Dexterity: 0 Constitution: 1 You find yourself pitted against a Stray Dog Choose One --------- Attack </code></pre> <p>It is supposed to run the level at 3 and the &quot;Stray Dog&quot; is supposed to be a &quot;Mugger&quot;.</p> <p>Also the dexterity and constitution and strength arent changing.</p>
[ { "answer_id": 74211726, "author": "Cyril Schmidt", "author_id": 3445473, "author_profile": "https://Stackoverflow.com/users/3445473", "pm_score": 0, "selected": false, "text": "class Object\n{\n std::string m_name; /* no set or get function allowed */\npublic:\n Object(std::string...
2022/10/26
[ "https://Stackoverflow.com/questions/74211102", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20341306/" ]
74,211,111
<p>I'm supposed to make a function with a list and a title as a string, and then return the item from the list, based on the title.</p> <pre><code>def find_appointment(lst, title = &quot;&quot;): if title in lst: funn = lst.find(title) return funn else: print(&quot;No result&quot;) appointments = [&quot;Zoo: 11.03.22&quot;, &quot;Shopping: 13.08.22&quot;, &quot;Christmas: 24.12.22&quot;, &quot;Funeral: 25.12.22&quot;] find_appointment(appointments, &quot;Zoo&quot;) </code></pre> <p>I hoped to get &quot;Zoo: 11.03.22&quot;, but instead got &quot;No result&quot;</p> <p>The list here is just a random one I made up. In the actual list I won't know the positions of the items.</p>
[ { "answer_id": 74211279, "author": "monos", "author_id": 20198370, "author_profile": "https://Stackoverflow.com/users/20198370", "pm_score": 0, "selected": false, "text": "appointments = {\"Zoo\":\"11.03.22\", \"Shopping\": \"13.08.22\"}\nsomething_to_find = \"Zoo\"\n" }, { "answ...
2022/10/26
[ "https://Stackoverflow.com/questions/74211111", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20122211/" ]
74,211,121
<p>I'm in a situation where every given time interval (let's say 1 second) I need to generate a thread that follows a pre-determined set of actions. Then after it is done, somehow I need to clean up the resources associated with that thread. But I'm not sure how I can do this while still generating new threads, since pthread_join is blocking, so I can't keep generating new threads while waiting for others to finish.</p> <p>The typical method I have seen suggested to do something like this is:</p> <pre><code>int i; pthread_t threads[NUM_THREADS]; for (i = 0; i &lt; NUM_THREADS; ++i) { pthread_create(&amp;threads[i], NULL, mythread, NULL); } for (i = 0; i &lt; NUM_THREADS; ++i) { pthread_join(threads[i], NULL); } </code></pre> <p>However, I don't want to generate a pre-determined amount of threads at the start and let them run. I want to generate the threads one at a time, and just keep generating (this will be ok since the threads reach a saturation point where they just end at the first step if there's more than 100 of them). One solution I thought of is to have the pthread_joins running in their own thread, but then I'm not sure how to tell it which ones to join. These threads have randomised sleep times within them so there's no specified order in which they ought to finish. What I have in mind as to how the program should run is something like this:</p> <ol> <li>Thread[1] created/running</li> <li>Thread[2] created/running</li> <li>Thread[3] created/running</li> <li>Thread[2] finished -&gt; join/free memory</li> <li>new Thread[2] created/running (since 2 finished, now create a new thread 2)</li> </ol> <p>So for example, you can never have more than 5 threads running, but every time one does finish you create a new one. The threads don't necessarily need to be in an array, I just thought that would make it easier to manage. I've been thinking about this for hours now and can't think of a solution. Am I just approaching the problem the completely wrong way, and there's something easier?</p>
[ { "answer_id": 74211202, "author": "ikegami", "author_id": 589924, "author_profile": "https://Stackoverflow.com/users/589924", "pm_score": 1, "selected": false, "text": "pthread_tryjoin_np" }, { "answer_id": 74212101, "author": "Erdal Küçük", "author_id": 11867590, "a...
2022/10/26
[ "https://Stackoverflow.com/questions/74211121", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20217095/" ]
74,211,152
<p>I'm trying to reimplement dasiamrpn tracker from opencv, but using openvino inference. In the init method I suppose some layer parameters have been changed by the tensors prodused by the r1 and cls1 heads</p> <pre><code> siamRPN.setInput(blob); cv::Mat out1; siamRPN.forward(out1, &quot;63&quot;); siamKernelCL1.setInput(out1); siamKernelR1.setInput(out1); cv::Mat cls1 = siamKernelCL1.forward(); cv::Mat r1 = siamKernelR1.forward(); std::vector&lt;int&gt; r1_shape = { 20, 256, 4, 4 }, cls1_shape = { 10, 256, 4, 4 }; //same shape as conv layers 65 and 68 siamRPN.setParam(siamRPN.getLayerId(&quot;65&quot;), 0, r1.reshape(0, r1_shape)); siamRPN.setParam(siamRPN.getLayerId(&quot;68&quot;), 0, cls1.reshape(0, cls1_shape)); </code></pre> <p>but I couldn't find an API or a some way to do this in openvino. Someone faced such problem?</p> <p><a href="https://i.stack.imgur.com/1swcO.png" rel="nofollow noreferrer">what I'm trying to do</a></p> <p>I suppose weight stored in this two nodes:</p> <pre><code> &lt;layer id=&quot;31&quot; name=&quot;new_layer_2.weight&quot; type=&quot;Const&quot; version=&quot;opset1&quot;&gt; &lt;data element_type=&quot;f32&quot; shape=&quot;10, 256, 4, 4&quot; offset=&quot;17349120&quot; size=&quot;163840&quot;/&gt; &lt;rt_info&gt; &lt;attribute name=&quot;fused_names&quot; version=&quot;0&quot; value=&quot;new_layer_2.weight&quot;/&gt; &lt;/rt_info&gt; &lt;output&gt; &lt;port id=&quot;0&quot; precision=&quot;FP32&quot; names=&quot;new_layer_2.weight&quot;&gt; &lt;dim&gt;10&lt;/dim&gt; &lt;dim&gt;256&lt;/dim&gt; &lt;dim&gt;4&lt;/dim&gt; &lt;dim&gt;4&lt;/dim&gt; &lt;/port&gt; &lt;/output&gt; &lt;/layer&gt; &lt;layer id=&quot;38&quot; name=&quot;new_layer_1.weight&quot; type=&quot;Const&quot; version=&quot;opset1&quot;&gt; &lt;data element_type=&quot;f32&quot; shape=&quot;20, 256, 4, 4&quot; offset=&quot;19873280&quot; size=&quot;327680&quot;/&gt; &lt;rt_info&gt; &lt;attribute name=&quot;fused_names&quot; version=&quot;0&quot; value=&quot;new_layer_1.weight&quot;/&gt; &lt;/rt_info&gt; &lt;output&gt; &lt;port id=&quot;0&quot; precision=&quot;FP32&quot; names=&quot;new_layer_1.weight&quot;&gt; &lt;dim&gt;20&lt;/dim&gt; &lt;dim&gt;256&lt;/dim&gt; &lt;dim&gt;4&lt;/dim&gt; &lt;dim&gt;4&lt;/dim&gt; &lt;/port&gt; &lt;/output&gt; &lt;/layer&gt; </code></pre> <p>I can view this nodes in model ops</p> <pre><code>auto ops = model-&gt;get_ops(); </code></pre> <p>but I have no idea how to change its weight data. There is a way to change it on runtime?</p>
[ { "answer_id": 74211202, "author": "ikegami", "author_id": 589924, "author_profile": "https://Stackoverflow.com/users/589924", "pm_score": 1, "selected": false, "text": "pthread_tryjoin_np" }, { "answer_id": 74212101, "author": "Erdal Küçük", "author_id": 11867590, "a...
2022/10/26
[ "https://Stackoverflow.com/questions/74211152", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18721763/" ]
74,211,156
<p><a href="https://i.stack.imgur.com/fuOji.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fuOji.png" alt="Input and output" /></a></p> <p>Can someone explain why this IF statement is returning false if the current UTC time is 16:21 and the function is to return true if the current UTC time is &gt;=09:00:00 &amp;&amp; &lt;=17:00:00</p> <p>Have tried separate IF statements and extending the time bracket beyond reasonable doubt</p>
[ { "answer_id": 74211202, "author": "ikegami", "author_id": 589924, "author_profile": "https://Stackoverflow.com/users/589924", "pm_score": 1, "selected": false, "text": "pthread_tryjoin_np" }, { "answer_id": 74212101, "author": "Erdal Küçük", "author_id": 11867590, "a...
2022/10/26
[ "https://Stackoverflow.com/questions/74211156", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20341387/" ]
74,211,176
<p>I am working on a react app with node/express on the backend. I want a component to render a video which URL is passed down from its parent component as prop.</p> <p>the parent component is named : <strong>Stepper</strong> and its child is named : <strong>ChestVideoWorkouts</strong>.</p> <p>The problem I face is that the video does not render to the DOM, whereas its src URL is loaded when I inspect. I have CORS installed.</p> <p>I get these errors in the console :</p> <blockquote> <p>Because a cookie’s SameSite attribute was not set or is invalid, it defaults to <code>SameSite=Lax</code>, which prevents the cookie from being sent in a cross-site request. This behavior protects user data from accidentally leaking to third parties and cross-site request forgery.</p> <p>Resolve this issue by updating the attributes of the cookie:</p> <ul> <li><p>Specify <code>SameSite=None</code> and Secure if the cookie should be sent in cross-site requests. This enables third-party use.</p> </li> <li><p>Specify <code>SameSite=Strict</code> or <code>SameSite=Lax</code> if the cookie should not be sent in cross-site requests.</p> </li> </ul> </blockquote> <p>Here is the code of Stepper :</p> <pre><code>import { Button, message, Steps } from &quot;antd&quot;; import React, { useState } from &quot;react&quot;; import { WorkoutInfosDrawer } from &quot;../drawer_content/WorkoutInfosDrawer&quot;; import { InfosvgIcon, RateIcon, VideoPlayer } from &quot;../icons/Icons&quot;; import { RateWorkout } from &quot;../rating/RateWorkout&quot;; import { ChestVideoWorkouts } from &quot;../video_components/ChestVideoWorkouts&quot;; import &quot;./steps_styles.scss&quot;; const { Step } = Steps; export const Stepper = ({ workoutTitle }) =&gt; { function videoUrl(url) { let videoUrl = workoutTitle === &quot;Barbell Flat Bench Press&quot; ? { url: &quot;https://www.youtube.com/watch?v=rT7DgCr-3pg&quot; } : &quot;&quot;; return videoUrl.url; } const steps = [ { title: &quot;&quot;, content: &lt;WorkoutInfosDrawer workoutTitle={workoutTitle} /&gt;, }, { title: &quot;&quot;, content: &lt;ChestVideoWorkouts videoUrl={videoUrl()} /&gt;, }, { title: &quot;&quot;, content: &lt;RateWorkout /&gt;, }, ]; const [current, setCurrent] = useState(0); const next = () =&gt; { setCurrent(current + 1); }; const prev = () =&gt; { setCurrent(current - 1); }; const onChange = (value) =&gt; { setCurrent(value); }; return ( &lt;div className={&quot;stepper-container&quot;}&gt; &lt;Steps current={current} onChange={onChange}&gt; &lt;Step icon={&lt;InfosvgIcon /&gt;} title={steps[0].title} /&gt; &lt;Step icon={&lt;VideoPlayer /&gt;} title={steps[1].title} /&gt; &lt;Step icon={&lt;RateIcon /&gt;} title={steps[2].title} /&gt; &lt;/Steps&gt; &lt;div className=&quot;steps-content&quot;&gt; {steps[current].content} &lt;div style={{ display: &quot;inline-block&quot; }}&gt;&lt;/div&gt; &lt;/div&gt; &lt;div className=&quot;steps-action&quot;&gt; {current &lt; steps.length - 1 &amp;&amp; ( &lt;Button type=&quot;primary&quot; onClick={() =&gt; next()}&gt; Next &lt;/Button&gt; )} {current === steps.length - 1 &amp;&amp; ( &lt;Button type=&quot;primary&quot; onClick={() =&gt; message.success(&quot;Processing complete!&quot;)} &gt; Done &lt;/Button&gt; )} {current &gt; 0 &amp;&amp; ( &lt;Button style={{ margin: &quot;0 8px&quot;, }} onClick={() =&gt; prev()} &gt; Previous &lt;/Button&gt; )} &lt;/div&gt; &lt;/div&gt; ); }; { /* &lt;Divider style={{ height: &quot;200px&quot; }} type=&quot;vertical&quot; dashed /&gt; */ } </code></pre> <p>and of ChestVideoWorkouts</p> <pre><code>import React from &quot;react&quot;; export const ChestVideoWorkouts = ({ videoUrl }) =&gt; { return ( &lt;div&gt; &lt;video style={{ border: &quot;1px solid red&quot; }} autoPlay loop muted src={videoUrl} width={`100%`} height={`100%`} &gt;&lt;/video&gt; &lt;/div&gt; ); }; </code></pre>
[ { "answer_id": 74211202, "author": "ikegami", "author_id": 589924, "author_profile": "https://Stackoverflow.com/users/589924", "pm_score": 1, "selected": false, "text": "pthread_tryjoin_np" }, { "answer_id": 74212101, "author": "Erdal Küçük", "author_id": 11867590, "a...
2022/10/26
[ "https://Stackoverflow.com/questions/74211176", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17119791/" ]
74,211,183
<p>On cppreference.com, in the section <a href="https://en.cppreference.com/w/c/language/conversion" rel="nofollow noreferrer">Implicit conversions</a>, in the subsection &quot;Lvalue conversion&quot;, it is noted that</p> <blockquote> <p>[i]f the lvalue designates an object of automatic storage duration <strong>whose address was never taken</strong> and if that object was uninitialized (not declared with an initializer and no assignment to it has been performed prior to use), the behavior is undefined. [emphasis mine]</p> </blockquote> <p>From that, I undestand that the &quot;act of taking an address&quot; of an object at some point in time may influence in some way whether the undefined behavior happens or not later when this object &quot;is used&quot;. If I'm right, then it seems at least unusual.</p> <p>Am I right? If so, how is that possible? If not, what am I missing?</p>
[ { "answer_id": 74211709, "author": "Eric Postpischil", "author_id": 298225, "author_profile": "https://Stackoverflow.com/users/298225", "pm_score": 3, "selected": true, "text": "register" } ]
2022/10/26
[ "https://Stackoverflow.com/questions/74211183", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20276305/" ]
74,211,195
<p>I have a strange issue with map. My goal is to return a list for every element. Conditional on the element I want a list of different length (or at least different logic applied to it). This seems to be very difficult and map is returning all kinds of values (see below):</p> <pre><code>map(1:2, ~ list(.x, .x + 1)) # returns list(list(1,2), list(2,3) map(1:2, ~ ifelse(.x &gt; 1, list(.x, .x + 1), list(.x, .x))) # returns list(list(1), list(2)) map(1:2, ~ case_when(.x &gt; 1 ~ list(.x, .x + 1), TRUE ~ list(.x))) # returns list(list(1,1), list(2,3) </code></pre> <p>I found two methods to solve this:</p> <pre><code># Add a list around it and then remove the list map(1:2, ~ ifelse(.x &gt; 1, list(list(.x, .x + 1)), list(.x))) %&gt;% map(., ~.[[1]]) # Use a two step map_if map_if(1:2, ~.x &gt; 1, ~list(.x, .x + 1)) %&gt;% map_if(is.integer, ~list(.x)) </code></pre> <p>Both feel a little weird to me.. What is the best practice in this regard?</p>
[ { "answer_id": 74211709, "author": "Eric Postpischil", "author_id": 298225, "author_profile": "https://Stackoverflow.com/users/298225", "pm_score": 3, "selected": true, "text": "register" } ]
2022/10/26
[ "https://Stackoverflow.com/questions/74211195", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6375668/" ]
74,211,206
<p>From the current directory, I try to <code>find</code> specific subfolders and <code>grep</code> files with specific extension.</p> <p><strong>sub-folder structure:</strong></p> <blockquote> <pre><code>.../1/A .../1/B .../2/A .../2/B .../3/A .../3/B </code></pre> </blockquote> <p>...I want to find each sub-folder contains B in PATH</p> <p><strong>desired output:</strong></p> <blockquote> <pre><code>.../1/B .../2/B .../3/B </code></pre> </blockquote> <p>... in each in this sub-folder (B) I want to run <code>grep</code>, but I get no desired output</p> <blockquote> <pre><code>grep -ro '...match_pattern...' .../1/B/*.out grep -ro '...match_pattern...' .../2/B/*.out grep -ro '...match_pattern...' .../3/B/*.out </code></pre> </blockquote> <p>I tried this code, but no luck. Any advise?</p> <pre><code>readarray LIST &lt; &lt;(find . -type d B | cut -c 3- ) for i in &quot;(LIST[@]}&quot; do echo $i/*.out grep -ro '...match_pattern...' $i*.out done </code></pre> <p>I got this and <code>grep</code> looking for two file</p> <pre><code>NOK outout - grep -ro '...match_pattern...' .../1/B /*.out desired output - grep -ro '...match_pattern...' .../1/B/*.out </code></pre>
[ { "answer_id": 74211315, "author": "SiKing", "author_id": 3124333, "author_profile": "https://Stackoverflow.com/users/3124333", "pm_score": 0, "selected": false, "text": "find \"$PWD\" -name B -type d -print -execdir sh -c 'grep ... *.out' \\;\n" }, { "answer_id": 74211383, "...
2022/10/26
[ "https://Stackoverflow.com/questions/74211206", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18450634/" ]
74,211,207
<p>I'm wondering how to repeat each of these rows 3 times to get them from Quarters into months.</p> <p>I need to repeat the same values in the first 2 columns but depending on the quarter in the third column I would need the other months in that quarter, i.e for the first row '31/01/2021' and '28/02/2021'</p> <p><a href="https://i.stack.imgur.com/dEKV8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dEKV8.png" alt="Original Data" /></a></p> <p>So desired output would look like: <a href="https://i.stack.imgur.com/1U8Ao.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1U8Ao.png" alt="Desired Output" /></a></p>
[ { "answer_id": 74211315, "author": "SiKing", "author_id": 3124333, "author_profile": "https://Stackoverflow.com/users/3124333", "pm_score": 0, "selected": false, "text": "find \"$PWD\" -name B -type d -print -execdir sh -c 'grep ... *.out' \\;\n" }, { "answer_id": 74211383, "...
2022/10/26
[ "https://Stackoverflow.com/questions/74211207", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20341310/" ]
74,211,210
<p>I have a bot which generates adaptive cards into the channel.</p> <p>I am trying to add colour to the text using conditions.</p> <pre><code>{ &quot;type&quot;: &quot;AdaptiveCard&quot;, &quot;$schema&quot;: &quot;http://adaptivecards.io/schemas/adaptive-card.json&quot;, &quot;version&quot;: &quot;1.3&quot;, &quot;body&quot;: [ { &quot;type&quot;: &quot;TextBlock&quot;, &quot;size&quot;: &quot;Medium&quot;, &quot;weight&quot;: &quot;Bolder&quot;, &quot;text&quot;: &quot;${title}&quot;, &quot;color&quot;: &quot;${if(10 &gt;= 0, 'good', 'attention')}&quot; } ] } </code></pre> <p><strong>Error</strong></p> <pre><code>&quot;error&quot;: { &quot;code&quot;: &quot;BadSyntax&quot;, &quot;message&quot;: &quot;Failed to read card payload as JSON&quot; } </code></pre>
[ { "answer_id": 74217363, "author": "Prasad-MSFT", "author_id": 16356296, "author_profile": "https://Stackoverflow.com/users/16356296", "pm_score": 0, "selected": false, "text": "{\n\"type\": \"AdaptiveCard\",\n\"$schema\": \"http://adaptivecards.io/schemas/adaptive-card.json\",\n\"versio...
2022/10/26
[ "https://Stackoverflow.com/questions/74211210", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14960723/" ]
74,211,221
<p>I have currently worked on a comparison function where I want to be able to print out whenever there has been a change in a dict. What I currently do is that I send request to my local-api where it returns different values and here is the example:</p> <pre><code>First request { '00194953243062': { 'value': '00194953243062', 'stock': 'OOS', 'modificationDate': '2022-10-22T12:02:06.000Z' }, '00194953243086': { 'value': '00194953243086', 'stock': 'OOS', 'modificationDate': '2022-09-30T10:55:45.000Z' }, '00194953243093': { 'value': '00194953243093', 'stock': 'OOS', 'modificationDate': '2022-10-22T11:05:54.000Z' }, '00194953243130': { 'value': '00194953243130', 'stock': 'OOS', 'modificationDate': '2022-10-22T08:55:48.000Z' } } print(&quot;All values are OOS!&quot;) **************************************************************************************************** Second request { '00194953243062': { 'value': '00194953243062', 'stock': 'OOS', 'modificationDate': '2022-10-22T12:02:06.000Z' }, '00194953243086': { 'value': '00194953243086', 'stock': 'OOS', 'modificationDate': '2022-09-30T10:55:45.000Z' }, '00194953243093': { 'value': '00194953243093', 'stock': 'OOS', 'modificationDate': '2022-10-22T11:05:54.000Z' }, '00194953243130': { 'value': '00194953243130', 'stock': 'LOW', 'modificationDate': '2022-10-22T08:55:48.000Z' } } print(&quot;New value has been found!&quot;) **************************************************************************************************** Third request { '00194953243062': { 'value': '00194953243062', 'stock': 'LOW', 'modificationDate': '2022-10-22T12:02:06.000Z' }, '00194953243086': { 'value': '00194953243086', 'stock': 'OOS', 'modificationDate': '2022-09-30T10:55:45.000Z' }, '00194953243093': { 'value': '00194953243093', 'stock': 'OOS', 'modificationDate': '2022-10-22T11:05:54.000Z' }, '00194953243130': { 'value': '00194953243130', 'stock': 'OOS', 'modificationDate': '2022-10-22T08:55:48.000Z' } } print(&quot;New value has been found!&quot;) **************************************************************************************************** Forth request { '00194953243062': { 'value': '00194953243062', 'stock': 'OOS', 'modificationDate': '2022-10-22T12:02:06.000Z' }, '00194953243086': { 'value': '00194953243086', 'stock': 'OOS', 'modificationDate': '2022-09-30T10:55:45.000Z' }, '00194953243093': { 'value': '00194953243093', 'stock': 'OOS', 'modificationDate': '2022-10-22T11:05:54.000Z' }, '00194953243130': { 'value': '00194953243130', 'stock': 'OOS', 'modificationDate': '2022-10-22T08:55:48.000Z' } } print(&quot;All values are OOS!&quot;) </code></pre> <p>and the problem that I currently have is that I do not know how to print out whenever a stock value goes from OOS -&gt; LOW -&gt; then I should print out that there has been a restock and whenever the sizes goes from LOW -&gt; OOS then I want to check if ALL stock values has the OOS then we should print out that &quot;All values are OOS&quot;.</p> <p>I have done something like this:</p> <pre><code>previous_data = {} gtin = # Is the example I have given above if previous_data.keys() != gtin.keys(): if all(value['stock'].casefold() == 'oos' for att, value in gtin.items()): print(&quot;All values are OOS!&quot;) else: print(&quot;New value has been found!&quot;) previous_data = gtin </code></pre> <p>but I noticed that I am missing where I check whenever a value goes from OOS -&gt; LOW, I seem to only check the key of each key-value and therefore I seem to miss the &quot;stock&quot; value changes, I wonder how can I notify myself whenever a stock goes from OOS -&gt; LOW/Whatever else besides OOS and NOT printing if it goes back to LOW -&gt; OOS besides if all stock values are OOS?</p>
[ { "answer_id": 74211523, "author": "AshSmith88", "author_id": 20281564, "author_profile": "https://Stackoverflow.com/users/20281564", "pm_score": 1, "selected": false, "text": "elif" }, { "answer_id": 74212234, "author": "Alejandro Aristizábal", "author_id": 7275142, ...
2022/10/26
[ "https://Stackoverflow.com/questions/74211221", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13019246/" ]
74,211,225
<p>I have this dataset on an R/SQL Server:</p> <pre><code> name year 1 john 2010 2 john 2011 3 john 2013 4 jack 2015 5 jack 2018 6 henry 2010 7 henry 2011 8 henry 2012 </code></pre> <p>I am trying to add two columns that:</p> <ul> <li>Column 1: Looks at the &quot;number of missing years between successive rows&quot; for each person.</li> <li>Column 2: Sum the cumulative &quot;number of missing years&quot; for each person</li> </ul> <p>For example - the first instance of each person will be 0, and then:</p> <pre><code># note: in this specific example that I have created, &quot;missing_ years&quot; is the same as the &quot;cumulative_missing_years&quot; name year missing_years cumulative_missing_years 1 john 2010 0 0 2 john 2011 0 0 3 john 2013 1 1 4 jack 2015 0 0 5 jack 2018 3 3 6 henry 2010 0 0 7 henry 2011 0 0 8 henry 2012 0 0 </code></pre> <p>I think this can be done with a &quot;grouped cumulative difference&quot; and &quot;grouped cumulative sums&quot;:</p> <pre><code> library(dplyr) library(DBI) con &lt;- dbConnect(RSQLite::SQLite(), &quot;:memory:&quot;) # https://stackoverflow.com/questions/30606360/subtract-value-from-previous-row-by-group final = my_data %&gt;% group_by(name) %&gt;% arrange(year) %&gt;% mutate(missing_year) = year- lag(year, default = first(year)) %&gt;% mutate(cumulative_missing_years) = mutate( cumulative_missing_years = cumsum(cs)) </code></pre> <p>But I am not sure if I am doing this correctly.</p> <p>Ideally, I am looking for an SQL approach or an R approach (e.g. via DBPLYR) that can be used to interact with the dataset.</p> <p>Can someone please suggest an approach for doing this?</p> <p>Thank you!</p>
[ { "answer_id": 74212063, "author": "G. Grothendieck", "author_id": 516548, "author_profile": "https://Stackoverflow.com/users/516548", "pm_score": 2, "selected": false, "text": "library(sqldf)\n\nsqldf(\"select a.*, \n coalesce(min(b.year) - a.year - 1, 0) as missing,\n sum(coalesc...
2022/10/26
[ "https://Stackoverflow.com/questions/74211225", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13203841/" ]
74,211,226
<p>This is very weird I tried using pandas udf on a spark df and it works only if i do select and return one value which is the average of the column</p> <p>but if i try to fill the whole column with this value then it doesnt work</p> <p>the following works:</p> <pre><code>@pandas_udf(DoubleType()) def avg(col ) : cl = np.average(col) return cl df.select(avg('col' )) </code></pre> <p>this works and returns a df of one row containing the value average of column.</p> <p>but the following doesnt work</p> <pre><code>df.withColumn('avg', F.lit( avg(col)) </code></pre> <p>why? if avg(col) is a value then why cant i use that to fill the column with a lit()?</p> <p>like the following example which does work. This does work when i return a constant number</p> <pre><code>@pandas_udf(DoubleType()) def avg(col ) : return 5 df.withColumn('avg', avg(col) </code></pre> <p>I also tried returning a series and didnt work either</p> <pre><code>@pandas_udf(DoubleType()) def avg(col ) : cl = np.average(col) return pd.Series([cl]* col.size()) df.withColumn('avg', avg(col)) </code></pre> <p>doesnt work. But does work if i use a constant instead of cl</p> <p>So basically how could i return a full column containing the same value of the average to fill up the whole column with that value?</p>
[ { "answer_id": 74212063, "author": "G. Grothendieck", "author_id": 516548, "author_profile": "https://Stackoverflow.com/users/516548", "pm_score": 2, "selected": false, "text": "library(sqldf)\n\nsqldf(\"select a.*, \n coalesce(min(b.year) - a.year - 1, 0) as missing,\n sum(coalesc...
2022/10/26
[ "https://Stackoverflow.com/questions/74211226", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11531487/" ]
74,211,259
<p>I have a pagination. I need to style the current link in my pagination. For that I need to add a class &quot;active&quot; to the current link so that I can style it with css</p> <p>Here is the javascript I have:</p> <pre><code>var itemsNumber = 6, $items, pages = 1, current = 1; function makePages(){ $items = $(&quot;.filtered-div:visible&quot;); pages = Math.ceil($items.length / itemsNumber); $(&quot;#pages&quot;).empty(); for(var p=1;p&lt;=pages;p++){ $(&quot;#pages&quot;).append($('&lt;a href=&quot;#&quot;&gt;'+p+'&lt;/a&gt;')); } showPage(1); } function showPage(page){ $items.hide().slice((page - 1) * itemsNumber, page * itemsNumber).show(); current = page; $(&quot;div.ctrl-nav a&quot;).show(); if(current == 1){ $(&quot;div.ctrl-nav a:first&quot;).hide(); }else if(current == pages){ $(&quot;div.ctrl-nav a:last&quot;).hide(); } } makePages(); $(&quot;div.ctrl-nav&quot;).on('click', 'a', function(){ var action = $(this).text(); if(action == 'Précédent'){ current--; }else if(action == 'Suivant'){ current++; }else if(+action &gt; 0){ current = +action; } if(current &lt;= 1){ current = 1; }else if(current &gt;= pages){ current = pages; } showPage(current); }); </code></pre> <p>And this is my HTML:</p> <pre><code>&lt;div id=&quot;item-wrapper&quot;&gt; &lt;div class=&quot;filtered-div&quot; data-tag=&quot;['category-1']&quot;&gt;item 1&lt;/div&gt; &lt;div class=&quot;filtered-div&quot; data-tag=&quot;['category-1']&quot;&gt;item 2&lt;/div&gt; &lt;div class=&quot;filtered-div&quot; data-tag=&quot;['category-2']&quot;&gt;item 8&lt;/div&gt; &lt;div class=&quot;filtered-div&quot; data-tag=&quot;['category-2']&quot;&gt;item 9&lt;/div&gt; &lt;div class=&quot;filtered-div&quot; data-tag=&quot;['category-2']&quot;&gt;item 10&lt;/div&gt; &lt;div class=&quot;filtered-div&quot; data-tag=&quot;['category-2']&quot;&gt;item 11&lt;/div&gt; &lt;div class=&quot;filtered-div&quot; data-tag=&quot;['category-2']&quot;&gt;item 12&lt;/div&gt; &lt;div class=&quot;ctrl-nav&quot;&gt; &lt;a href=&quot;#&quot;&gt;Précédent&lt;/a&gt;&lt;span id=&quot;pages&quot;&gt;&lt;/span&gt;&lt;a href=&quot;#&quot;&gt;Suivant&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Here is a codepen: <a href="https://codepen.io/sofia-lazrak/pen/RwJNRBE" rel="nofollow noreferrer">Codepen</a></p> <p>Any suggestions? Thanks for your help</p>
[ { "answer_id": 74211305, "author": "Fralle", "author_id": 3155183, "author_profile": "https://Stackoverflow.com/users/3155183", "pm_score": 0, "selected": false, "text": "active" }, { "answer_id": 74217307, "author": "freedomn-m", "author_id": 2181514, "author_profile...
2022/10/26
[ "https://Stackoverflow.com/questions/74211259", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13099741/" ]
74,211,290
<p>Coding Challenge:</p> <p>Write a function, unzip, which accepts a matrix of nRows rows and nCol columns. It should return a new array, of numCol rows and numRows columns, which regroups elements.</p> <pre><code>unzip([ [1, 2], [3, 4], ]); // [[1,3],[2,4]] unzip([ [1, 2, 3], [4, 5, 6], ]); // [[1,4],[2,5],[3,6]] unzip([[&quot;a&quot;], [&quot;b&quot;], [&quot;c&quot;]]); // [['a','b','c']] </code></pre> <p>I'm not sure how to implement the inner forloop logic.</p> <p>My thought process:</p> <pre><code>results[0][0] = arr[0][0] // outer results[0][1] = arr[1][0] // inner (flipped) results[1][0] = arr[0][1] // inner (flipped) results[1][1] = arr[1][1] // outer </code></pre> <p>Attempt:</p> <p>Prepopulate the results array with 0s and then insert the correct values</p> <pre><code>unzip([[1, 2], [3, 4]]); function unzip(arr) { const results = []; const row = arr[0].length; const col = arr.length; for (let i = 0; i &lt; row; i++) { results.push([0, 0]); } for (let i = 0; i &lt; results.length; i++) { results[i][i] = arr[i][i]; for (let j = results.length - 1; j &gt; i; j--) { results[i][j] = arr[j][i]; } } return results; } // [ [1, 3], [0, 4]], correct: [[1, 3], [2, 4]] </code></pre> <p>Where in the world is this &quot;0&quot; coming from in my return? There is no 0 in the original array</p>
[ { "answer_id": 74211305, "author": "Fralle", "author_id": 3155183, "author_profile": "https://Stackoverflow.com/users/3155183", "pm_score": 0, "selected": false, "text": "active" }, { "answer_id": 74217307, "author": "freedomn-m", "author_id": 2181514, "author_profile...
2022/10/26
[ "https://Stackoverflow.com/questions/74211290", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
74,211,294
<p>Given <em>df1</em>, I need to expand the same amount of rows according to the value given by the TRIP column. As an example I put two columns but in real life it is a dataframe with more than 15 columns. How do I expand all records from the value recorded in the Trip column?</p> <pre><code> *df1* Id Trip 1 3 2 2 3 2 4 4 Expected Result *df1* Id Trip 1 1 1 2 1 3 2 1 2 2 3 1 3 2 4 1 4 2 4 3 4 4 </code></pre>
[ { "answer_id": 74211303, "author": "akrun", "author_id": 3732271, "author_profile": "https://Stackoverflow.com/users/3732271", "pm_score": 3, "selected": true, "text": "uncount" }, { "answer_id": 74211400, "author": "TarJae", "author_id": 13321647, "author_profile": "...
2022/10/26
[ "https://Stackoverflow.com/questions/74211294", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18729535/" ]
74,211,298
<p>Good morning, I have a problem for some time that i don't know how to solve.</p> <p>From a Spring application i am trying to upload a file to the server. Everything is fine, except when the file is larger than 200MB. There, the application returns a 413 .. sometimes simply connection timeout.. The server is Centos 7 and there is Nginx underneath. I tried running the client_max_body_size but it doesn't matter. Anyone know what the problem might be?</p> <p>These are my configuration's files</p> <p><strong>application.properties:</strong></p> <pre><code>spring.servlet.multipart.maxFileSize=-1 spring.servlet.multipart.maxRequestSize=-1 spring.servlet.multipart.enabled=true spring.servlet.multipart.max-file-size=-1 spring.servlet.multipart.max-request-size=-1 </code></pre> <p><strong>/etc/nginx/nginx.conf:</strong></p> <pre><code>http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] &quot;$request&quot; ' '$status $body_bytes_sent &quot;$http_referer&quot; ' '&quot;$http_user_agent&quot; &quot;$http_x_forwarded_for&quot;'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 3000; gzip on; include /etc/nginx/conf.d/*.conf; client_max_body_size 500M; server{ client_max_body_size 0; location /upload { client_max_body_size 500M; return 201 $request_body_file; } location / { client_max_body_size 500M; } } } </code></pre> <p><strong>/etc/php.ini:</strong></p> <pre><code> max_input_time = 24000 max_execution_time = 24000 upload_max_filesize = 500M post_max_size = 500M memory_limit = 12000 </code></pre>
[ { "answer_id": 74221307, "author": "Sebastiàn Garcìa", "author_id": 11641055, "author_profile": "https://Stackoverflow.com/users/11641055", "pm_score": -1, "selected": false, "text": " drwxr-xr-x 2 root root 4096 Oct 26 16:05 conf.d\n -rw-r--r-- 1 root root 1007 Oct 29 2020 fastcgi_pa...
2022/10/26
[ "https://Stackoverflow.com/questions/74211298", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11641055/" ]
74,211,302
<p>i need to count string and Find the percentage of presence of some characters in string But My code doesn't work properly and shows the percentage line by line when I want the final result this is my code :</p> <pre><code>from os import cpu_count import re with open('ros_gc_948_1_dataset.txt', 'r') as fp: # read all lines in a list lines = fp.readlines() c_count=0 g_count=0 a_count=0 t_count=0 for line in lines: # check if string present on a current line if re.findall(r&quot;\bRos_[0-9][0-9][0-9][0-9]&quot; , line): line.write() line.replace(&quot;&gt;&quot;,&quot;&quot;) print(line) c_count=0 g_count=0 a_count=0 t_count=0 else: c_count+=line.count(&quot;C&quot;) g_count+=line.count(&quot;G&quot;) a_count+=line.count(&quot;A&quot;) t_count+=line.count(&quot;T&quot;) tocag=c_count+g_count toac=c_count + g_count + a_count + t_count if toac !=0: avrg=float(tocag/toac * 100) print(avrg) </code></pre> <p>and the result :</p> <pre><code>&gt;Ros_7657 53.333333333333336 43.333333333333336 47.22222222222222 48.333333333333336 49.0 49.72222222222222 49.76190476190476 48.541666666666664 48.333333333333336 48.833333333333336 49.24242424242424 49.30555555555556 48.717948717948715 49.25925925925926 &gt;Ros_3487 53.333333333333336 47.5 46.666666666666664 48.333333333333336 47.0 46.94444444444444 48.095238095238095 47.291666666666664 46.111111111111114 47.333333333333336 46.96969696969697 46.52777777777778 46.666666666666664 46.785714285714285 47.368421052631575 </code></pre> <p>My expected result :</p> <pre><code>Ros_7657 49.25925925925926` Ros_3487 47.368421052631575 </code></pre> <p>I have a text file containing several lines of these entries that I just want their names and percentages</p> <blockquote> <p>ex input :</p> </blockquote> <pre><code>&gt;Ros_2115 GAGGCAATGGTTATCAACCCCTGATTTACGAATGACCTAACAACTCCTTAGAATTTAATC GTTATGTGAATTAAGCAACGCTCGCGAATTGCTATGTTAATTCGCACTGTAAGGTGTCGA ACGAAATCCACTGTTCCTTTTCTAATTTCTTTCA </code></pre> <p>thanks for help me</p>
[ { "answer_id": 74211328, "author": "JustLearning", "author_id": 19962393, "author_profile": "https://Stackoverflow.com/users/19962393", "pm_score": 0, "selected": false, "text": "print" }, { "answer_id": 74211862, "author": "Swifty", "author_id": 20267366, "author_pro...
2022/10/26
[ "https://Stackoverflow.com/questions/74211302", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10356618/" ]
74,211,314
<p>I have a database where four of its columns are: score_home, score_away, home_id and away_id.</p> <p>I expect to get a variable whose rows contain the winning ID in each game.</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Index</th> <th>gRes</th> </tr> </thead> <tbody> <tr> <td>0</td> <td>GB</td> </tr> <tr> <td>1</td> <td>GB</td> </tr> </tbody> </table> </div> <p>For that, I tried with the following code</p> <pre><code>team_f['gRes'] = 0 if team_f['score_home'] &gt; team_f['score_away']: team_f['gRes'] = team_f['home_id'] else: team_f['gRes'] = team_f['away_id'] </code></pre> <p>and i get the following error</p> <pre><code>The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all(). </code></pre> <p>Could you suggest how to correct the error or, failing that, any alternatives to build the variable?</p>
[ { "answer_id": 74211328, "author": "JustLearning", "author_id": 19962393, "author_profile": "https://Stackoverflow.com/users/19962393", "pm_score": 0, "selected": false, "text": "print" }, { "answer_id": 74211862, "author": "Swifty", "author_id": 20267366, "author_pro...
2022/10/26
[ "https://Stackoverflow.com/questions/74211314", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19778814/" ]
74,211,340
<p>I have Abstract Class with two abstract methods. I also have 4 classes that extend that class and also override those methods.</p> <p>The task is to &quot;if possible optimize code&quot; in those 4 classes.</p> <p>There are two types of same override method</p> <p>First</p> <pre><code> protected boolean canApprove(int id, double cost, Type type) { boolean result = false; if (type == Type.CONSUMABLES &amp;&amp; cost &lt; 300) { result = true; return result; } else if (type == Type.CLERICAL &amp;&amp; cost &lt; 500) { result = false; return result; } else if (type == Type.GADGETS &amp;&amp; cost &lt; 1000) { result = true; return result; } else if (type == Type.GAMING &amp;&amp; cost &lt; 2000) { result = true; return result; } else if (type == Type.PC &amp;&amp; cost &lt; 5000) { result = true; return result; } else { result = false; return result; } } </code></pre> <p>Second</p> <pre><code>protected boolean canApprove(int id, double cost, Type type) { boolean result = false; switch (type) { case CONSUMABLES: if (cost &lt; 300) { result = true; return result; } else { break; } case CLERICAL: if (cost &lt; 500) { result = true; return result; } else { break; } case GADGETS: if (cost &lt; 1000) { result = true; return result; } else { break; } case GAMING: if (cost &lt; 2000) { result = true; return result; } else { break; } case PC: if (cost &lt; 5000) { result = true; return result; } else { break; } default: result = false; return result; } return result; } </code></pre> <p>My Question is which i should use or if there is a better way?</p> <p>I dont know what method is the best to use?</p>
[ { "answer_id": 74211387, "author": "Michael", "author_id": 1898563, "author_profile": "https://Stackoverflow.com/users/1898563", "pm_score": 1, "selected": false, "text": "return (type == Type.CONSUMABLES && cost < 300)\n || (type == Type.CLERICAL && cost < 500)\n || (type == Type....
2022/10/26
[ "https://Stackoverflow.com/questions/74211340", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20341414/" ]
74,211,353
<p>EDIT/UPDATE: I finally found a solution - the following worked:</p> <pre><code>df=df.replace(r'^\s*$', np.nan, regex=True) </code></pre> <p>I am trying to replace ' ' values with null values in python. Essentially, I am converting an text file to Python using substrings. In the file, all rows have the same number of characters but only one column - I need to convert this to distinct columns each with row values - example below:</p> <pre><code>df['column1'] = df['data'].str[0:2] df['column2'] = df['data'].str[5:14] </code></pre> <p>In cases where a column's row value should be null, it is instead a space or a series of spaces (' '). I have tried the following:</p> <pre><code>df=df.replace(' ', &quot;Null&quot;) df=df.replace(' ', None) df=df.replace('', None) df=df.replace(r'\s*', None, regex=True) </code></pre> <p>This has not worked for me (it doesn't even change cases when the entire cell value is ' '); the space values remain, both for cells with spaces in between numbers (like ' 1' rather than '1') and for cells which should be empty. How can I solve this?</p> <p>Example of data is below. Where there appears to be a blank value, it is actually one or two spaces (depending on the number of spaces of the cell):\</p> <p><a href="https://i.stack.imgur.com/HNUkT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HNUkT.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74211387, "author": "Michael", "author_id": 1898563, "author_profile": "https://Stackoverflow.com/users/1898563", "pm_score": 1, "selected": false, "text": "return (type == Type.CONSUMABLES && cost < 300)\n || (type == Type.CLERICAL && cost < 500)\n || (type == Type....
2022/10/26
[ "https://Stackoverflow.com/questions/74211353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17706204/" ]
74,211,381
<p>You used to be able to do <code>require('library/a/b/c.js')</code> and it would just work.</p> <p>But in newer node.js versions, there is an <code>exports</code> list in <code>package.json</code>. And if you try to require anything outside of those paths, you get error &quot;<code>ERR_PACKAGE_PATH_NOT_EXPORTED</code>&quot;.</p> <p>Is there a way to require those private files anyway?</p> <p>(I don't need a lecture, please, just a solution)</p>
[ { "answer_id": 74211564, "author": "Heiko Theißen", "author_id": 16462950, "author_profile": "https://Stackoverflow.com/users/16462950", "pm_score": 3, "selected": true, "text": "require('./node_modules/library/a/b/c.js')" }, { "answer_id": 74211601, "author": "panta82", ...
2022/10/26
[ "https://Stackoverflow.com/questions/74211381", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2405595/" ]
74,211,455
<p>I have a list of questions, and I want to know how many rows have non-NA values using summarize. I want to use summarize because I'm already using that to calculate the average, which works in the below code. Why does the below code not work and how can I fix it?</p> <pre><code>library(dplyr) test &lt;- tibble(student = c(&quot;j&quot;, &quot;c&quot;, &quot;s&quot;), q1 = c(1, 2, 3), q2 = c(NA_real_, NA_real_, 4), q3 = c(43, NA_real_, 232)) test %&gt;% dplyr::summarise(n = across(starts_with(&quot;q&quot;), ~n(.x)), avg = across(contains(&quot;q&quot;), ~ round(mean(.x, na.rm = T), 2))) expected_outcome &lt;- tibble(n_q1 = 3, n_q2 = 1, n_q3 = 2, avg_q1 = 2, avg_q2 = 4, avg_q3 = 138) </code></pre>
[ { "answer_id": 74211537, "author": "LMc", "author_id": 6382434, "author_profile": "https://Stackoverflow.com/users/6382434", "pm_score": 2, "selected": false, "text": "library(dplyr)\n\ntest %>% \n summarize(across(starts_with(\"q\"), list(n = ~sum(!is.na(.)),\n ...
2022/10/26
[ "https://Stackoverflow.com/questions/74211455", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9877445/" ]
74,211,468
<p>I am trying to provide the value for auto increment value through the subquery in mysql</p> <p>I tried with this command</p> <pre><code>alter table xxx auto_increment = (select max(id) from xxx) ; </code></pre> <p>But am getting the syntax error as</p> <blockquote> <p>You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(select max(id) from xxx)' at line 1</p> </blockquote> <p>Please anyone help me on this issue....Thanks in advance</p>
[ { "answer_id": 74211537, "author": "LMc", "author_id": 6382434, "author_profile": "https://Stackoverflow.com/users/6382434", "pm_score": 2, "selected": false, "text": "library(dplyr)\n\ntest %>% \n summarize(across(starts_with(\"q\"), list(n = ~sum(!is.na(.)),\n ...
2022/10/26
[ "https://Stackoverflow.com/questions/74211468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17635219/" ]
74,211,472
<p>I'm trying to implement @HostListener in my project Angular 10, but it doesn't work.</p> <p>Follow my code below:</p> <p>home.ts</p> <pre><code>import { HostListener, Directive } from '@angular/core'; export class EnumComponent { @Directive({ selector: 'input[ListManual]'}) @HostListener('mouseenter', ['$event.target']) onClick() { console.log(&quot;hereeee&quot;) //this.newTypeButtonClick(); } } </code></pre> <p>home.html</p> <pre><code>&lt;ng-template pTemplate=&quot;body&quot; let-data&gt; &lt;tr&gt; &lt;td&gt; &lt;input ... ListManual /&gt; &lt;/td&gt; &lt;td&gt; &lt;input ... ListManual /&gt; &lt;/td&gt; &lt;td&gt; &lt;input ... ListManual /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/ng-template&gt; </code></pre> <p>I want it does work when I click on input and show me log.</p> <p>Any help will be appreciated.</p>
[ { "answer_id": 74211537, "author": "LMc", "author_id": 6382434, "author_profile": "https://Stackoverflow.com/users/6382434", "pm_score": 2, "selected": false, "text": "library(dplyr)\n\ntest %>% \n summarize(across(starts_with(\"q\"), list(n = ~sum(!is.na(.)),\n ...
2022/10/26
[ "https://Stackoverflow.com/questions/74211472", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18238656/" ]
74,211,485
<p>I have two pandas DataFrames. The first one, <code>df1</code>, contains a column of file paths and a column of lists containing what users have read access to these file paths. The second DataFrame, <code>df2</code>, contains a list of all possible users. I've created an example below:</p> <pre><code>df1 = pd.DataFrame() df1['path'] = ['C:/pathA', 'C:/pathB', 'C:/pathC', 'C:/pathD'] df1['read'] = [['userA', 'userC', 'userD'], ['userA', 'userB'], ['userB', 'userD'], ['userA', 'userB', 'userC', 'userD']] print(df1) path read 0 C:/pathA [userA, userC, userD] 1 C:/pathB [userA, userB] 2 C:/pathC [userB, userD] 3 C:/pathD [userA, userB, userC, userD] </code></pre> <pre><code>df2 = pd.DataFrame(data=['userA', 'userB', 'userC', 'userD'], columns=['user']) print(df2) user 0 userA 1 userB 2 userC 3 userD </code></pre> <p>The end goal is to create a new column <code>df2['read_count']</code>, which should take each user string from <code>df2['user']</code> and find the total number of matches in the column <code>df1['read']</code>.</p> <p>The expected output would be exactly that - a count of matches of each user string in the column of lists in <code>df1['read']</code>. Here is what I am expecting based on the example:</p> <pre><code>df2 user read_count 0 userA 3 1 userB 3 2 userC 2 3 userD 3 </code></pre> <p>I tried putting something together using another question and list comprehension, but no luck. Here is what I currently have:</p> <pre><code>df2['read_count'] = [sum(all(val in cell for val in row) for cell in df1['read']) for row in df2['user']] print(df2) user read_count 0 userA 0 1 userB 0 2 userC 0 3 userD 0 </code></pre> <p>What is wrong with the code I currently have? I've tried actually following through the loops but it all seemed right, but it seems like my code can't detect the matches I want.</p>
[ { "answer_id": 74211537, "author": "LMc", "author_id": 6382434, "author_profile": "https://Stackoverflow.com/users/6382434", "pm_score": 2, "selected": false, "text": "library(dplyr)\n\ntest %>% \n summarize(across(starts_with(\"q\"), list(n = ~sum(!is.na(.)),\n ...
2022/10/26
[ "https://Stackoverflow.com/questions/74211485", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20296072/" ]
74,211,505
<p>In my typescript/node.js code, I have a function with two optional parameters as follows:</p> <pre><code>export const func1 = (num: Number, name: string, obj?: Params, credentials?: Credentials) =&gt; { </code></pre> <p>where <code>Params</code> is something user-defined, and <code>Credentials</code> is from <code>import { Credentials } from '@aws-sdk/types';</code></p> <p>However, when I call <code>func1</code> as follows:</p> <pre><code>func1( 1, 'Stack', { name: 'Stack', age: 14, }, credentials ); </code></pre> <p>where <code>credentials</code> is of type <code>Credentials</code> I get an error saying that <code>func1 expected 2-3 arguments, but got 4</code> - I can understand why this would happen if only one optional argument was allowed, but does anyone know how I can include 2 optional arguments for <code>func1</code>?</p>
[ { "answer_id": 74211537, "author": "LMc", "author_id": 6382434, "author_profile": "https://Stackoverflow.com/users/6382434", "pm_score": 2, "selected": false, "text": "library(dplyr)\n\ntest %>% \n summarize(across(starts_with(\"q\"), list(n = ~sum(!is.na(.)),\n ...
2022/10/26
[ "https://Stackoverflow.com/questions/74211505", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14917411/" ]
74,211,551
<p>The dataset is shows a transaction id and multiple binary flags of which department the product is associated with. Transaction is not necessarily a unique id because one transaction can have multiple items from different departments.</p> <ul> <li>Example</li> </ul> <pre><code>import pandas as pd d = {'Trans_ID': [149857724, 149857724, 394875934, 16544562, 16544562], 'Item': ['Windex','Car Horn', 'Steering Wheel', 'Horse Feed', 'Bleech' ],'Cleaning_Supplies_Dept_Flag': [1, 0, 0, 0, 1], 'Automobile_Parts_Dept_Flag': [0, 1, 1, 0, 0], 'Horse_Supplies_Dept_Flag': [0, 0, 0, 1, 0]} ex = pd.DataFrame(data=d) ex </code></pre> <p>Essentially, My goal is drop the Item name but keep the flags</p> <ul> <li>Final Product</li> </ul> <pre><code>d = {'Trans_ID': [149857724, 394875934, 16544562], 'Cleaning_Supplies_Dept_Flag': [1, 0, 1], 'Automobile_Parts_Dept_Flag': [1, 0,1], 'Horse_Supplies_Dept_Flag': [0,0,1]} result = pd.DataFrame(data=d) result </code></pre> <p>I have tried transposing, squeezing, stacking, and melting the dataframe; however, I am unable to get it the result format below.</p>
[ { "answer_id": 74211537, "author": "LMc", "author_id": 6382434, "author_profile": "https://Stackoverflow.com/users/6382434", "pm_score": 2, "selected": false, "text": "library(dplyr)\n\ntest %>% \n summarize(across(starts_with(\"q\"), list(n = ~sum(!is.na(.)),\n ...
2022/10/26
[ "https://Stackoverflow.com/questions/74211551", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19959428/" ]
74,211,579
<p>I have a data set that has Report Date with some fields. I would like to add a column (ex. Status) using excel power query that determines the most recent date (ex. 3/1/2022) and assigns &quot;Current&quot;, and the second most recent (ex. 2/1/2022) and assigns &quot;Prior&quot;. Any help would be greatly appreciated. Thanks!</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Report Date</th> <th>Company</th> <th>Number</th> <th><em>Status</em></th> </tr> </thead> <tbody> <tr> <td>1/1/2022</td> <td>Apple</td> <td>7</td> <td></td> </tr> <tr> <td>1/1/2022</td> <td>HP</td> <td>4</td> <td></td> </tr> <tr> <td>2/1/2022</td> <td>Apple</td> <td>8</td> <td><em>Prior</em></td> </tr> <tr> <td>2/1/2022</td> <td>HP</td> <td>9</td> <td><em>Prior</em></td> </tr> <tr> <td>3/1/2022</td> <td>Apple</td> <td>10</td> <td><em>Current</em></td> </tr> <tr> <td>3/1/2022</td> <td>HP</td> <td>10</td> <td><em>Current</em></td> </tr> </tbody> </table> </div>
[ { "answer_id": 74211537, "author": "LMc", "author_id": 6382434, "author_profile": "https://Stackoverflow.com/users/6382434", "pm_score": 2, "selected": false, "text": "library(dplyr)\n\ntest %>% \n summarize(across(starts_with(\"q\"), list(n = ~sum(!is.na(.)),\n ...
2022/10/26
[ "https://Stackoverflow.com/questions/74211579", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12954974/" ]
74,211,590
<p>First this is my parent component :</p> <pre class="lang-js prettyprint-override"><code>import React from 'react' import logo from '../Assets/LOGO.png' import EmailInput from '../Components/LoginPage/EmailInput' import PasswordInput from '../Components/LoginPage/PasswordInput' import Rememberme from '../Components/LoginPage/Rememberme' import SigninInput from '../Components/LoginPage/SigninInput' import '../Styles/Login/login.css' function Login() { return ( &lt;main&gt; &lt;div className='top'&gt; &lt;img src={logo} alt='Netflix' /&gt; &lt;/div&gt; &lt;section&gt; &lt;div className='si-card'&gt; &lt;h2&gt;Sign In&lt;/h2&gt; &lt;EmailInput /&gt; &lt;PasswordInput /&gt; &lt;SigninInput /&gt; &lt;Rememberme /&gt; &lt;/div&gt; &lt;/section&gt; &lt;/main&gt; ) } export default Login </code></pre> <h4><code>PasswordInput</code>:</h4> <pre class="lang-js prettyprint-override"><code>import React from 'react' function PasswordInput() { const passwordRef = React.useRef() function passwordValidation() { let value = passwordRef.current.value if (value.length &lt;= 6) { console.log('Password must be smaller than 4 charectar') } } return ( &lt;div className='input-co'&gt; &lt;input type='password' id='password' placeholder=' ' onChange={passwordValidation} ref={passwordRef} /&gt; &lt;label htmlFor='password'&gt;Password&lt;/label&gt; &lt;/div&gt; ) } export default PasswordInput </code></pre> <h4><code>EmailInput</code>:</h4> <pre class="lang-js prettyprint-override"><code> import React from 'react' function EmailInput() { const reg = /^\w+([\\.-]?\w+)*@\w+([\\.-]?\w+)*(\.\w{2,3})+$/ const emailRef = React.useRef() function emailValidation() { let value = emailRef.current.value if (!reg.test(value)) { console.log('Enter a valid email') } } return ( &lt;div className='input-co'&gt; &lt;input type='email' id='email' placeholder=' ' onChange={emailValidation} ref={emailRef} /&gt; &lt;label htmlFor='email'&gt;Email or phone number&lt;/label&gt; &lt;/div&gt; ) } export default EmailInput </code></pre> <h4><code>SigninInput</code>:</h4> <pre class="lang-js prettyprint-override"><code>import React from 'react' function SigninInput() { return &lt;button className='signin'&gt;Sign in&lt;/button&gt; } export default SigninInput </code></pre> <p><strong>How can I pass ref from <code>EmailInput</code> and <code>passwordInput</code> to <code>SigninInput</code>?</strong></p> <p>I want access to a value of two input when user is clicked on sign in button</p>
[ { "answer_id": 74211537, "author": "LMc", "author_id": 6382434, "author_profile": "https://Stackoverflow.com/users/6382434", "pm_score": 2, "selected": false, "text": "library(dplyr)\n\ntest %>% \n summarize(across(starts_with(\"q\"), list(n = ~sum(!is.na(.)),\n ...
2022/10/26
[ "https://Stackoverflow.com/questions/74211590", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19441482/" ]
74,211,596
<p>I am using vue 3 template refs, in a nuxt project, with composition API as I have done with other components which seem to work fine. However, in this instance, they are returning null.</p> <p>Here is my template:</p> <pre><code>&lt;template&gt; &lt;div class=&quot;horizontal-scroll-fix&quot; ref=&quot;container&quot;&gt; &lt;div class=&quot;horizontal-scroll-fix__scroll-fix&quot;&gt; &lt;container class=&quot;horizontal-scroll-fix__container&quot;&gt; &lt;div class=&quot;horizontal-scroll-fix__viewport&quot; ref=&quot;viewport&quot;&gt; &lt;div class=&quot;horizontal-scroll-fix__wrapper&quot; ref=&quot;wrapper&quot;&gt; &lt;slot&gt;&lt;/slot&gt; &lt;/div&gt; &lt;/div&gt; &lt;/container&gt; &lt;/div&gt; &lt;/div&gt; &lt;/template&gt; &lt;script&gt; import { ref, computed, onMounted, onBeforeUnmount, useSlots } from 'vue'; export default { // tried also to use shorthand &lt;script setup&gt; but no luck either setup() { const container = ref(null); const wrapper = ref(null); const viewport = ref(null); onMounted(() =&gt; { if (process.client) { console.log(container?.value) // returns undefined } }); } } &lt;/script&gt; </code></pre> <p>console.logging the ref object returns the following:</p> <pre><code>RefImpl {__v_isShallow: false, dep: undefined, __v_isRef: true, _rawValue: undefined, _value: undefined} </code></pre> <p>UDPDATE</p> <p>I have since been informed that I need to return the refs at the end of the set up script. so <code>return { container, wrapper, viewport }</code> However, what is confusing is that all other components I have in my project, don't do this, but work fine. so what is different about this one that I am not seeing? Here is an example of another component that has template refs that works perfectly fine, and doesn't return the values:</p> <pre><code>&lt;template&gt; &lt;container&gt; &lt;div :class=&quot;'sequence sequence--'+section.displayAs&quot;&gt; &lt;div class=&quot;sequence__content&quot; ref=&quot;content&quot;&gt; // removed inner content for the purpose of demonstrating &lt;/div&gt; &lt;/div&gt; &lt;/container&gt; &lt;/template&gt; &lt;script setup&gt; import { ref, computed, onMounted, onUnmounted } from 'vue'; const props = defineProps({ section: { required:true, type:Object } }); const isDesktop = ref(false); const currentSectionIndex = ref(0); const fixedVisual = ref(null); const content = ref(null); function initMediaQuery() { const mediaQuery = window.matchMedia('(min-width:1024px)'); checkDeviceSize(mediaQuery); mediaQuery.addListener(checkDeviceSize); }; function checkDeviceSize(query) { if (query &amp;&amp; query.matches) { isDesktop.value = true } else { isDesktop.value = false } }; function initObserver() { if (props.section?.displayAs === 'timeline' &amp;&amp; isDesktop) { console.log(isDesktop); const target = fixedVisual; const sections = content?.value.querySelectorAll('.sequence__section'); if (target &amp;&amp; sections?.length) { let callback = (entries, observer) =&gt; { entries.forEach((entry,index) =&gt; { if (entry.isIntersecting) { currentSectionIndex.value = parseInt(entry.target.getAttribute('data-index')); } }) } let options = { rootMargin: '0px', threshold:1.0 } let observer = new IntersectionObserver(callback,options); sections.forEach(section =&gt; { observer.observe(section); }); } } } onMounted(() =&gt; { if (process.client) { initMediaQuery(); initObserver(); window.addEventListener(&quot;resize&quot;, initObserver); } }); onUnmounted(()=&gt; { if (process.client) { window.removeEventListener(&quot;resize&quot;, initObserver); } }); &lt;/script&gt; </code></pre>
[ { "answer_id": 74211711, "author": "Gabriel", "author_id": 15978727, "author_profile": "https://Stackoverflow.com/users/15978727", "pm_score": 2, "selected": false, "text": "setup()" }, { "answer_id": 74211882, "author": "whiskeyo", "author_id": 10714380, "author_prof...
2022/10/26
[ "https://Stackoverflow.com/questions/74211596", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9067927/" ]
74,211,613
<p>I have the below drawing, made of random shapes with various number of points, to which I can add, through the following XSLT, textboxes. The solution proposed in <a href="https://stackoverflow.com/questions/5546346/how-to-place-and-center-text-in-an-svg-rectangle/31522006#31522006">this thread</a> (i.e. <code>x=&quot;50%&quot; y =&quot;50%&quot;</code> and <code>dominant-baseline=&quot;middle&quot;</code> <code>text-anchor=&quot;middle&quot;</code>) does not work, as all such textboxes end up in the same position of the drawing, overlapping. I would actually like them to be in the center of each path they are named after. <a href="https://martin-honnen.github.io/xslt3fiddle/?xslt=%3C%3Fxml+version%3D%221.0%22+encoding%3D%22utf-8%22%3F%3E%0A%3Cxsl%3Astylesheet+xmlns%3Axsl%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2FXSL%2FTransform%22%0A++++xmlns%3Asvg%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%0A++++xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%0A++++exclude-result-prefixes%3D%22svg%22%0A++++version%3D%221.0%22%3E%0A%3Cxsl%3Aoutput+method%3D%22xml%22+encoding%3D%22utf-8%22+omit-xml-declaration%3D%22yes%22+indent%3D%22yes%22%2F%3E%0A++%0A++%3Cxsl%3Astrip-space+elements%3D%22*%22%2F%3E%0A++%0A++%3Cxsl%3Atemplate+match%3D%22svg%3Ag%5B%40id%5Bstarts-with%28.%2C+%27Item%27%29%5D%5D%22%3E%0A++++%3Cxsl%3Acopy%3E%0A++++++%3Cxsl%3Aapply-templates+select%3D%22%40*+%7C+node%28%29%22%2F%3E%0A++++++%3Cxsl%3Avariable+name%3D%22id%22+select%3D%22substring-before%28%40id%2C+%27-%27%29%22%2F%3E%0A++++++%3Ctext+x%3D%2250%25%22+y%3D%2250%25%22+id%3D%22%7B%24id%7D-text%22+style%3D%22-inkscape-font-specification%3A%27Calibri%2C+Normal%27%3Bfont-family%3ACalibri%3Bfont-weight%3Anormal%3Bfont-style%3Anormal%3Bfont-stretch%3Anormal%3Bfont-variant%3Anormal%3Bfont-size%3A20px%3Bfont-variant-ligatures%3Anormal%3Bfont-variant-caps%3Anormal%3Bfont-variant-numeric%3Anormal%3Bfont-variant-east-asian%3Anormal%3Bfill%3A%23000000+%22+dominant-baseline%3D%22middle%22+text-anchor%3D%22middle%22%3E%0A++++++++%3Ctspan+id%3D%22%7B%24id%7D-tspan%22+x%3D%2250%25%22+y%3D%2250%25%22%3E%0A++++++++++%3Cxsl%3Avalue-of+select%3D%22%24id%22%2F%3E%0A++++++++%3C%2Ftspan%3E%0A++++++%3C%2Ftext%3E%0A++++%3C%2Fxsl%3Acopy%3E%0A++%3C%2Fxsl%3Atemplate%3E%0A++%0A%0A++%0A++%0A+%3Cxsl%3Atemplate+match%3D%22processing-instruction%28%27xml-stylesheet%27%29%22%2F%3E%0A+%0A++%3Cxsl%3Atemplate+match%3D%22%40*+%7C+node%28%29%22%3E%0A++++%3Cxsl%3Acopy%3E%0A++++++%3Cxsl%3Aapply-templates+select%3D%22%40*+%7C+node%28%29%22%2F%3E%0A++++%3C%2Fxsl%3Acopy%3E%0A++%3C%2Fxsl%3Atemplate%3E%0A%0A%3C%2Fxsl%3Astylesheet%3E%0A%0A%0A&amp;input=%3Csvg+xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22+xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22+id%3D%22exportSvg%22+width%3D%22400%22+height%3D%22400%22%3E%0A%09%3Cdefs%2F%3E%0A%09%3Crect+width%3D%22400%22+height%3D%22400%22+transform%3D%22translate%280%2C+0%29%22+fill%3D%22rgb%28255%2C+255%2C+255%29%22+style%3D%22fill%3Argb%28255%2C+255%2C+255%29%3B%22%2F%3E%0A%09%3Cg%3E%0A%09%09%3Cg+id%3D%22Drawing-svg%22+clip-path%3D%22url%28%23rect-mask-Drawing%29%22%3E%0A%09%09%09%3CclipPath+id%3D%22rect-mask-Drawing%22%3E%0A%09%09%09%09%3Crect+x%3D%220%22+y%3D%220%22+width%3D%22400%22+height%3D%22400%22%2F%3E%0A%09%09%09%3C%2FclipPath%3E%0A%09%09%09%3Cg+id%3D%22chart-svg%22%3E%0A%09%09%09%09%3Cg+id%3D%22svg-main%22+clip-path%3D%22url%28%23rect-mask-Main%29%22%3E%0A%09%09%09%09%09%3CclipPath+id%3D%22rect-mask-Main%22%3E%0A%09%09%09%09%09%09%3Crect+x%3D%220%22+y%3D%220%22+width%3D%22400%22+height%3D%22400%22%2F%3E%0A%09%09%09%09%09%3C%2FclipPath%3E%0A%09%09%09%09%09%3Cg+id%3D%22Drawing-svg%22%3E%0A%09%09%09%09%09%09%3Cg+id%3D%22Parts-svg%22%3E%0A%09%09%09%09%09%09%09%3Cg+id%3D%22Section-svg%22%3E%0A%09%09%09%09%09%09%09%09%3Cg+id%3D%22Item1-svg%22%3E%0A%09%09%09%09%09%09%09%09%09%3Cpath+d%3D%22M+155.09357%2C45.542471+104.77897%2C86.931934+75%2C200+152.79121%2C141.87343+200%2C84.246354+Z%22+stroke%3D%22%23000000%22+style%3D%22fill%3A%23e6e6e6%3Bstroke-width%3A0.3%3Bstroke-linecap%3Around%3Bstroke-linejoin%3Around%22+id%3D%22Item1%22%2F%3E%0A%09%09%09%09%09%09%09%09%3C%2Fg%3E%0A%09%09%09%09%09%09%09%09%3Cg+id%3D%22Item2-svg%22%3E%0A%09%09%09%09%09%09%09%09%09%3Cpath+d%3D%22M+198.06872%2C89.614437+-9.21291%2C31.643703+-23.42303%2C34.67823+51.52002%2C20.68699+47.20879%2C-57.62707+z%22+stroke%3D%22%23000000%22+style%3D%22fill%3A%23e6e6e6%3Bstroke-width%3A0.3%3Bstroke-linecap%3Around%3Bstroke-linejoin%3Around%22+id%3D%22Item2%22%2F%3E%0A%09%09%09%09%09%09%09%09%3C%2Fg%3E%0A%09%09%09%09%09%09%09%09%3Cg+id%3D%22Item3-svg%22%3E%0A%09%09%09%09%09%09%09%09%09%3Cpath+d%3D%22M+161.0455%2C182.56778+-41.68122%2C-5.64443+15.98375%2C27.05111+67.62172%2C3.73783+32.80201%2C-13.55927+z%22+stroke%3D%22%23000000%22+style%3D%22fill%3A%23e6e6e6%3Bstroke-width%3A0.3%3Bstroke-linecap%3Around%3Bstroke-linejoin%3Around%22+id%3D%22Item3%22%2F%3E%0A%09%09%09%09%09%09%09%09%3C%2Fg%3E%0A%09%09%09%09%09%09%09%3C%2Fg%3E%0A%09%09%09%09%09%09%3C%2Fg%3E%0A%09%09%09%09%09%3C%2Fg%3E%0A%09%09%09%09%3C%2Fg%3E%0A%09%09%09%3C%2Fg%3E%0A%09%09%3C%2Fg%3E%0A%09%3C%2Fg%3E%0A%3C%2Fsvg%3E%0A%0A&amp;input-type=XML" rel="nofollow noreferrer">Here is the fiddle</a> that shows the behaviour. I have already asked if this could be achieved through Javascript but, since the transformation would be made through a VBA macro, I have been advised that would not be the correct solution. Basically, I would need to populate the fields <em>x</em> and <em>y</em> with the average height and width of the paths each textbox should fit into, those text holders are created in this part of the code:</p> <pre><code> &lt;text x=&quot;&quot; y=&quot;&quot; id=&quot;{$id}-text&quot; style=&quot;-inkscape-font-specification:'Calibri, Normal';font-family:Calibri;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;font-size:20px;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;fill:#000000 &quot; dominant-baseline=&quot;middle&quot; text-anchor=&quot;middle&quot;&gt; &lt;tspan id=&quot;{$id}-tspan&quot; x=&quot;&quot; y=&quot;&quot;&gt; &lt;xsl:value-of select=&quot;$id&quot;/&gt; &lt;/tspan&gt; &lt;/text&gt; </code></pre> <p><strong>SVG</strong></p> <pre><code>&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot; id=&quot;exportSvg&quot; width=&quot;400&quot; height=&quot;400&quot;&gt; &lt;defs/&gt; &lt;rect width=&quot;400&quot; height=&quot;400&quot; transform=&quot;translate(0, 0)&quot; fill=&quot;rgb(255, 255, 255)&quot; style=&quot;fill:rgb(255, 255, 255);&quot;/&gt; &lt;g&gt; &lt;g id=&quot;Drawing-svg&quot; clip-path=&quot;url(#rect-mask-Drawing)&quot;&gt; &lt;clipPath id=&quot;rect-mask-Drawing&quot;&gt; &lt;rect x=&quot;0&quot; y=&quot;0&quot; width=&quot;400&quot; height=&quot;400&quot;/&gt; &lt;/clipPath&gt; &lt;g id=&quot;chart-svg&quot;&gt; &lt;g id=&quot;svg-main&quot; clip-path=&quot;url(#rect-mask-Main)&quot;&gt; &lt;clipPath id=&quot;rect-mask-Main&quot;&gt; &lt;rect x=&quot;0&quot; y=&quot;0&quot; width=&quot;400&quot; height=&quot;400&quot;/&gt; &lt;/clipPath&gt; &lt;g id=&quot;Drawing-svg&quot;&gt; &lt;g id=&quot;Parts-svg&quot;&gt; &lt;g id=&quot;Section-svg&quot;&gt; &lt;g id=&quot;Item1-svg&quot;&gt; &lt;path d=&quot;M 155.09357,45.542471 104.77897,86.931934 75,200 152.79121,141.87343 200,84.246354 Z&quot; stroke=&quot;#000000&quot; style=&quot;fill:#e6e6e6;stroke-width:0.3;stroke-linecap:round;stroke-linejoin:round&quot; id=&quot;Item1&quot;/&gt; &lt;/g&gt; &lt;g id=&quot;Item2-svg&quot;&gt; &lt;path d=&quot;M 198.06872,89.614437 -9.21291,31.643703 -23.42303,34.67823 51.52002,20.68699 47.20879,-57.62707 z&quot; stroke=&quot;#000000&quot; style=&quot;fill:#e6e6e6;stroke-width:0.3;stroke-linecap:round;stroke-linejoin:round&quot; id=&quot;Item2&quot;/&gt; &lt;/g&gt; &lt;g id=&quot;Item3-svg&quot;&gt; &lt;path d=&quot;M 161.0455,182.56778 -41.68122,-5.64443 15.98375,27.05111 67.62172,3.73783 32.80201,-13.55927 z&quot; stroke=&quot;#000000&quot; style=&quot;fill:#e6e6e6;stroke-width:0.3;stroke-linecap:round;stroke-linejoin:round&quot; id=&quot;Item3&quot;/&gt; &lt;/g&gt; &lt;/g&gt; &lt;/g&gt; &lt;/g&gt; &lt;/g&gt; &lt;/g&gt; &lt;/g&gt; &lt;/g&gt; &lt;/svg&gt; </code></pre> <p><strong>XSLT</strong></p> <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt; &lt;xsl:stylesheet xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot; xmlns:svg=&quot;http://www.w3.org/2000/svg&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; exclude-result-prefixes=&quot;svg&quot; version=&quot;1.0&quot;&gt; &lt;xsl:output method=&quot;xml&quot; encoding=&quot;utf-8&quot; omit-xml-declaration=&quot;yes&quot;/&gt; &lt;xsl:strip-space elements=&quot;*&quot;/&gt; &lt;xsl:template match=&quot;svg:g[@id[starts-with(., 'Item')]]&quot;&gt; &lt;xsl:copy&gt; &lt;xsl:apply-templates select=&quot;@* | node()&quot;/&gt; &lt;xsl:variable name=&quot;id&quot; select=&quot;substring-before(@id, '-')&quot;/&gt; &lt;text x=&quot;&quot; y=&quot;&quot; id=&quot;{$id}-text&quot; style=&quot;-inkscape-font-specification:'Calibri, Normal';font-family:Calibri;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;font-size:20px;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;fill:#000000 &quot; dominant-baseline=&quot;middle&quot; text-anchor=&quot;middle&quot;&gt; &lt;tspan id=&quot;{$id}-tspan&quot; x=&quot;&quot; y=&quot;&quot;&gt; &lt;xsl:value-of select=&quot;$id&quot;/&gt; &lt;/tspan&gt; &lt;/text&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; &lt;xsl:template match=&quot;processing-instruction('xml-stylesheet')&quot;/&gt; &lt;xsl:template match=&quot;@* | node()&quot;&gt; &lt;xsl:copy&gt; &lt;xsl:apply-templates select=&quot;@* | node()&quot;/&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre>
[ { "answer_id": 74212257, "author": "Heiko Theißen", "author_id": 16462950, "author_profile": "https://Stackoverflow.com/users/16462950", "pm_score": 0, "selected": false, "text": "<path d=\"M 155.09357,45.542471 104.77897,86.931934 75,200 152.79121,141.87343 200,84.246354 Z\"/>\n" }, ...
2022/10/26
[ "https://Stackoverflow.com/questions/74211613", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18247317/" ]
74,211,621
<p>I am in a big problem. I have to calculate age and add a new column in the following table. I tried eeptools but can not deal with NA value</p> <pre><code>id DOB 1 5/22/1951 2 NA 3 8/18/1984 4 5/1/1994 5 NA </code></pre> <p>I tried the following code btw and it comes with an error. I want to deal with this NA value</p> <pre><code>Age= age_calc(as.Date(na.omit(Merged_data$DOB),&quot;%m/%d/%Y&quot;),units = &quot;years&quot;) Error in if (any(enddate &lt; dob)) { : missing value where TRUE/FALSE needed </code></pre> <p>Please help, I have a deadline today :(</p>
[ { "answer_id": 74211714, "author": "TarJae", "author_id": 13321647, "author_profile": "https://Stackoverflow.com/users/13321647", "pm_score": 2, "selected": false, "text": "%–%" }, { "answer_id": 74211717, "author": "jpsmith", "author_id": 12109788, "author_profile": ...
2022/10/26
[ "https://Stackoverflow.com/questions/74211621", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8964336/" ]
74,211,639
<p>Here is my problem:</p> <pre><code>const data : [ {labelSlug: 'cola', category: 'catering', subCategory: 'drinks', provider: 'coca cola'}, {labelSlug: 'cola', category: 'catering', subCategory: 'drinks', provider: 'coca cola'}, {labelSlug: 'fanta', category: 'catering', subCategory: 'drinks', provider: 'coca cola'},{labelSlug: 'activities1', category: 'activities', subCategory: 'activitiesSub1', provider: 'blabla'}, {labelSlug: 'activities2', category: 'activities', subCategory: 'activitiesSub1', provider: 'blabla'}, {labelSlug: 'equipments1', category: 'equipments', subCategory: 'equipmentsSub1', provider: 'blabla'}, {labelSlug: 'equipments2', category: 'equipments', subCategory: 'equipmentsSub2', provider: 'blabla'} {labelSlug: 'cola', category: 'catering', subCategory: 'drinks', provider: 'coca cola'}, ] </code></pre> <p>I'm trying to get something like this for each category and subCategory:</p> <pre><code>{ catering : [ drinks : [ { labelSlug: cola, provider: coca cola, count: 3 }, { labelSlug: fanta, provider: coca cola, count: 1 } ] ] } </code></pre> <p>The problem is I don't know how to set up this, I've tried all I could do:</p> <pre><code>const array = data.map((elem) =&gt; { const item = {}; const sub = elem.subCategory; const cat = elem.category; // i've tried many things like that just to get everything in the right place (I didnt try to get the count part yet) // item[cat[sub]].labelSlug = elem.labelSlug; // item[cat][sub].labelSlug = elem.labelSlug; // item[cat[sub.labelSlug]] = elem.labelSlug; // const item = { // [`${cat}`] : { // [`${sub}`] : { // labelSlug: elem.labelSlug // } // } // } return item; }) </code></pre>
[ { "answer_id": 74211714, "author": "TarJae", "author_id": 13321647, "author_profile": "https://Stackoverflow.com/users/13321647", "pm_score": 2, "selected": false, "text": "%–%" }, { "answer_id": 74211717, "author": "jpsmith", "author_id": 12109788, "author_profile": ...
2022/10/26
[ "https://Stackoverflow.com/questions/74211639", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20293008/" ]
74,211,648
<p>My data looks like this as a <code>kable</code>:</p> <pre><code>pdtable %&gt;% kbl(caption = &quot;This is the caption&quot;) %&gt;% kable_classic_2() </code></pre> <p>However, I want to make some cells bold. Is there a way to do it without editing the input dataframe? I tried to integrate <code>cell_spec</code> in the pipes but I can't get it to work. Does anyone have a solution?</p> <p><strong>EDIT:</strong> here is some example data. I want to make all cells bold, that are below a value of 0.05 in the brackets. Using a conditional <code>row_spec</code> however, does not seem to work because there are two values in the cells.</p> <pre><code>structure(list(`2012` = c(&quot;4.16 (0.02)&quot;, &quot;1.39 (0.043)&quot;, &quot;-3.65 (0.213)&quot;, &quot;4.35 (0.248)&quot;, &quot;3.16 (0.036)&quot;, &quot;8.84 (0.002)&quot;, &quot;15.13 (0)&quot;, &quot;13.03 (0)&quot;, &quot;11.16 (0.002)&quot;, &quot;4.35 (0.047)&quot;, &quot;-2.39 (0.6)&quot;, &quot;-1.45 (0.531)&quot;), `2013` = c(&quot;-5.97 (0.24)&quot;, &quot;-2.45 (0.73)&quot;, &quot;1.58 (0.002)&quot;, &quot;17.77 (0)&quot;, &quot;24.23 (0)&quot;, &quot;17.29 (0)&quot;, &quot;24.62 (0)&quot;, &quot;26.95 (0)&quot;, &quot;16.92 (0)&quot;, &quot;2.53 (0.13)&quot;, &quot;3.79 (0.019)&quot;, &quot;4.37 (0)&quot; ), `2014` = c(&quot;-22.53 (0.04)&quot;, &quot;-14.01 (0.899)&quot;, &quot;-3.06 (0.079)&quot;, &quot;12.06 (0.072)&quot;, &quot;20.32 (0.011)&quot;, &quot;13.86 (0.009)&quot;, &quot;34.91 (0)&quot;, &quot;32.15 (0)&quot;, &quot;27.33 (0)&quot;, &quot;2.53 (0.412)&quot;, &quot;3.79 (0.158)&quot;, &quot;-6.35 (0)&quot; ), `2012-2014` = c(&quot;-26.36 (0.002)&quot;, &quot;-13.62 (0.028)&quot;, &quot;-4.05 (0)&quot;, &quot;34.98 (0)&quot;, &quot;46.65 (0)&quot;, &quot;37.45 (0)&quot;, &quot;76.91 (0)&quot;, &quot;77.23 (0)&quot;, &quot;60.26 (0)&quot;, &quot;-14.44 (0.004)&quot;, &quot;-15.67 (0)&quot;, &quot;-6.71 (0)&quot;)), class = &quot;data.frame&quot;, row.names = c(&quot;test 3&quot;, &quot;test 7&quot;, &quot;test 15&quot;, &quot;test1 3&quot;, &quot;test1 7&quot;, &quot;test1 15&quot;, &quot;test3 3&quot;, &quot;test 3&quot;, &quot;test 4&quot;, &quot;test 4&quot;, &quot;test 4&quot;, &quot;test 4&quot;)) </code></pre>
[ { "answer_id": 74211714, "author": "TarJae", "author_id": 13321647, "author_profile": "https://Stackoverflow.com/users/13321647", "pm_score": 2, "selected": false, "text": "%–%" }, { "answer_id": 74211717, "author": "jpsmith", "author_id": 12109788, "author_profile": ...
2022/10/26
[ "https://Stackoverflow.com/questions/74211648", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19989317/" ]
74,211,657
<p>I have a JSON_TEXT column in my PostgreSQL DB such as this {'a':'one', 'b':'two', 'c':'three'} I would like to create a function that would loop through all of the DISTINCT JSON_object_keys and create a column for each of the keys, and populate all of the values into their new columns. psuedo code example:</p> <pre><code>create or replace function myFunction (input json_text) returns //not sure as $$// BEGIN // foreach(key in input) // make and return a column populated with its values somehow idk END; $$ </code></pre> <p>I understand you can hard code the names of each key and create attributes for them but I have hundreds of keys so this wont be feasible for me.</p>
[ { "answer_id": 74211714, "author": "TarJae", "author_id": 13321647, "author_profile": "https://Stackoverflow.com/users/13321647", "pm_score": 2, "selected": false, "text": "%–%" }, { "answer_id": 74211717, "author": "jpsmith", "author_id": 12109788, "author_profile": ...
2022/10/26
[ "https://Stackoverflow.com/questions/74211657", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10426495/" ]
74,211,661
<p>I'm using Azure.Data.Tables (12.6.1) and I need to query a single record from multiple partitions of a single table (so the result would be multiple records, 1 from each partition). Each entity needs to be looked up by its partition key and row key - for a single <a href="https://learn.microsoft.com/en-us/dotnet/api/azure.data.tables.tableclient.getentityasync?view=azure-dotnet" rel="nofollow noreferrer"><code>TableClient.GetEntity()</code></a> call this would be a point query.</p> <p>After reading the documentation I'm confused if it's efficient or not to call <a href="https://learn.microsoft.com/en-us/dotnet/api/azure.data.tables.tableclient.queryasync?view=azure-dotnet#azure-data-tables-tableclient-queryasync-1(system-string-system-nullable((system-int32))-system-collections-generic-ienumerable((system-string))-system-threading-cancellationtoken)" rel="nofollow noreferrer"><code>TableClient.QueryAsync()</code></a> with multiple partition key / row key pairs and the search results I found provide contradicting suggestions.</p> <p>Is it efficient to do this (for a number of partition key / row key combinations, up to ~50) or is it just better to call <code>GetEntity()</code> one by one, for each entity?</p> <pre><code>var filter = &quot;(PartitionKey eq 'p1' And RowKey eq 'r1') Or &quot; + &quot;(PartitionKey eq 'p2' And RowKey eq 'r2') Or ...&quot;; var results = await tableClient.QueryAsync(filter, 500, null, cancelToken); </code></pre>
[ { "answer_id": 74211714, "author": "TarJae", "author_id": 13321647, "author_profile": "https://Stackoverflow.com/users/13321647", "pm_score": 2, "selected": false, "text": "%–%" }, { "answer_id": 74211717, "author": "jpsmith", "author_id": 12109788, "author_profile": ...
2022/10/26
[ "https://Stackoverflow.com/questions/74211661", "https://Stackoverflow.com", "https://Stackoverflow.com/users/682404/" ]
74,211,719
<p>I'm trying to create a simple modal with this CSS code</p> <pre><code>.modal { max-width: 700px; position: fixed; margin: auto; background: #000; color: #eee; top: 5%; left: 0; right: 0; bottom: 5%; padding: 20px; overflow-x: hidden; overflow-y: auto; } </code></pre> <p>This is fully responsive but I want use <code>bottom: auto</code> instead of <code>bottom: 5%</code><br/> Because that way if I don't have a lot of content in it, the height will adjust based on the content.</p> <p><strong>The problem is when I have lot of content in it, I can no longer scroll down.</strong></p>
[ { "answer_id": 74211929, "author": "Mr.Lister", "author_id": 6931232, "author_profile": "https://Stackoverflow.com/users/6931232", "pm_score": 1, "selected": false, "text": ".modal { \n max-width: 700px;\n position: fixed; \n margin: auto;\n background: #000;\n ...
2022/10/26
[ "https://Stackoverflow.com/questions/74211719", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12458459/" ]
74,211,752
<p><a href="https://i.stack.imgur.com/EAiyP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EAiyP.png" alt="image provided on google api page" /></a></p> <p>I would like to know if there is a nuget package or if google provides this API for xamarin.forms?</p> <p>I saw that it had only for kotlin and native java</p> <p>reference: <a href="https://developer.android.com/guide/playcore/in-app-updates?hl=pt-br" rel="nofollow noreferrer">https://developer.android.com/guide/playcore/in-app-updates?hl=pt-br</a></p>
[ { "answer_id": 74211929, "author": "Mr.Lister", "author_id": 6931232, "author_profile": "https://Stackoverflow.com/users/6931232", "pm_score": 1, "selected": false, "text": ".modal { \n max-width: 700px;\n position: fixed; \n margin: auto;\n background: #000;\n ...
2022/10/26
[ "https://Stackoverflow.com/questions/74211752", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19668441/" ]
74,211,768
<p>I have the following function::</p> <pre><code>def f123(): lista = range(2) print(&quot;2: before yields&quot;) yield [lista, &quot;A: yield&quot;] print(&quot;- after yield A&quot;) yield [lista, &quot;B: yield&quot;] print(&quot;- after yield B&quot;) yield [lista, &quot;C: yield&quot;] print(&quot;- after yield C&quot;) </code></pre> <p>From what I've researched, I can take advantage of my <code>generator</code> by iterating over it or using the <code>next()</code> function to move the cursor. So, I tried to implement two different ways in order to get the same answer, but without success!</p> <p><strong>Example 1</strong>:</p> <pre><code>print(&quot;0: -----&quot;) print(&quot;1: start&quot;) list_gener = f123() example = list() example.append(next(list_gener)) example.append(next(list_gener)) example.append(next(list_gener)) print(&quot;3: end&quot;) print(example) </code></pre> <p><strong>Example 2</strong>:</p> <pre><code>print(&quot;0: -----&quot;) print(&quot;1: start&quot;) example = [item for item in f123()] print(&quot;3: end&quot;) print(example) </code></pre> <p><strong>Contents</strong> of the <code>example</code> variable:</p> <pre><code>[ [range(0, 2), 'A: yield'], [range(0, 2), 'B: yield'], [range(0, 2), 'C: yield'] ] </code></pre> <p><strong>Respective Answers</strong>:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Answer example 1</th> <th>Answer example 2</th> </tr> </thead> <tbody> <tr> <td>0: -----</td> <td>0: -----</td> </tr> <tr> <td>1: start</td> <td>1: start</td> </tr> <tr> <td>2: before yields</td> <td>2: before yields</td> </tr> <tr> <td>after yield A</td> <td>after yield A</td> </tr> <tr> <td>after yield B</td> <td>after yield B</td> </tr> <tr> <td>3: end</td> <td>after yield C</td> </tr> <tr> <td></td> <td>3: end</td> </tr> </tbody> </table> </div> <p><strong>MY DOUBT IS:</strong> What causes <code>after yield C</code> to be printed during <code>loop</code> iteration?</p> <p>I know that in the <code>next</code> example (example 1) it will never be printed because there is no more <code>yield</code> after that C, but how do I make example 1 behave the same as example 2?</p>
[ { "answer_id": 74211836, "author": "Barmar", "author_id": 1491895, "author_profile": "https://Stackoverflow.com/users/1491895", "pm_score": 3, "selected": true, "text": "After yield C" }, { "answer_id": 74211849, "author": "Ahmed AEK", "author_id": 15649230, "author_p...
2022/10/26
[ "https://Stackoverflow.com/questions/74211768", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8401294/" ]
74,211,867
<p>I want to compare the effect of different fertilizer doses on multiple crop cultivars at various locations. My dataset is similar to the one generated below:</p> <pre><code>locs &lt;- rep(c(&quot;loc1&quot;,&quot;loc2&quot;,&quot;loc3&quot;), length.out=180) cults &lt;- rep(c(&quot;cult1&quot;,&quot;cult2&quot;,&quot;cult3&quot;,&quot;cult4&quot;,&quot;cult5&quot;), length.out=180) doses &lt;- rep(c(&quot;no_fert&quot;,&quot;40kg&quot;,&quot;50kg&quot;,&quot;60kg&quot;), length.out=180) set.seed(123); yld &lt;- runif(3*length(unique(locs))*length(unique(cults))*length(unique(doses)), min=3, max=15) dat &lt;- data.frame(location=locs,                   cultivar=cults,                   fert_dose=doses,                   yield=yld) </code></pre> <p>Note there are three repetitions of each fertilizer dosage (but there are more in my actual dataset).</p> <p>The first thing I need to do is to calculate the average for the three repetitions of each location-cultivar-fertilizer combination.</p> <p>I can do it - in a probably not so efficient way - like this:</p> <pre><code>d1 &lt;- d2 &lt;- d3 &lt;- list() for (i in 1:length(unique(locs))){   for (j in 1:length(unique(cults))){     for (k in 1:length(unique(doses))){       d1[[k]] &lt;- data.frame(location=locs[i],                             cultivar=cults[j],                             fert_dose=doses[k],                             mean_yield=mean(dat[dat$location==locs[i]&amp;dat$cultivar==cults[j]&amp;dat$fert_dose==doses[k],]$yield))     }     d2[[j]] &lt;- do.call(rbind,d1)   }   d3[[i]] &lt;- do.call(rbind,d2) } (mean_dat &lt;- do.call(rbind, d3)) </code></pre> <p>Next, what I need to do is: for each location, find the yield difference among all combinations of cultivar and fertilizer doses.</p> <p>For example, considering only <code>loc1</code> and <code>cult1</code>, the expected result would be:</p> <pre><code>res &lt;- &quot; location cultivar dose dose_mean other_cultivar other_dose other_mean diff loc1 cult1 no_fert 9.402345 cult1 40kg 9.251377 0.150968 loc1 cult1 no_fert 9.402345 cult1 50kg 10.764692 -1.362347 loc1 cult1 no_fert 9.402345 cult1 60kg 10.119129 -0.716784 loc1 cult1 40kg 9.251377 cult1 no_fert 9.402345 -0.150968 loc1 cult1 40kg 9.251377 cult1 50kg 10.764692 -1.513315 loc1 cult1 40kg 9.251377 cult1 60kg 10.119129 -0.867752 loc1 cult1 50kg 10.764692 cult1 no_fert 9.402345 1.362347 loc1 cult1 50kg 10.764692 cult1 40kg 9.251377 1.513315 loc1 cult1 50kg 10.764692 cult1 60kg 10.119129 0.645563 loc1 cult1 60kg 10.119129 cult1 no_fert 9.402345 0.716784 loc1 cult1 60kg 10.119129 cult1 40kg 9.251377 0.867752 loc1 cult1 60kg 10.119129 cult1 50kg 10.764692 -0.645563 &quot; (res &lt;- read.table(textConnection(res), sep=&quot; &quot;, header=T, stringsAsFactors=F)) </code></pre> <p>In this table, I am repeating the yield values for each dose obtained in the previous step (<code>mean_dat</code> table) and calculating a simple the difference between them. The resulting table would continue this analysis, including the other cultivars in the <code>other_cultivar</code> column.</p> <p>I reckon the expected table does not look very good, but it will be used to feed an interactive dashboard, and this is the format it requires, so I don't think I have much choice here.</p> <p>Is there any programmatic way to achieve these two results in just one step?</p>
[ { "answer_id": 74212168, "author": "Ric Villalba", "author_id": 6912817, "author_profile": "https://Stackoverflow.com/users/6912817", "pm_score": 1, "selected": false, "text": "data.table" }, { "answer_id": 74212182, "author": "dcsuka", "author_id": 19512611, "author_...
2022/10/26
[ "https://Stackoverflow.com/questions/74211867", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4272937/" ]
74,211,875
<p>I am building an excel sheet that returns the three highest values from a column in another sheet (sheet2, column B) along with their corresponding company (sheet2, column a). Ultimately, in sheet 1, I want to have a table that will display the company with those values.</p> <p>This is what I am trying to achieve: AWS ($280.9m), Google ($241.9m), Meta ($168.7m)</p> <p>I was trying to use the large formula, but this does not help me with referencing the corresponding company so I’m unsure how to return both.</p>
[ { "answer_id": 74212168, "author": "Ric Villalba", "author_id": 6912817, "author_profile": "https://Stackoverflow.com/users/6912817", "pm_score": 1, "selected": false, "text": "data.table" }, { "answer_id": 74212182, "author": "dcsuka", "author_id": 19512611, "author_...
2022/10/26
[ "https://Stackoverflow.com/questions/74211875", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9216885/" ]
74,211,892
<p>I have these rows in my table with <code>start</code> and <code>end</code> column in database like these are of datatype datetime</p> <pre><code> start | end 1 2022-10-27 11:59:00 2022-10-27 01:00:00 2 2022-10-28 01:59:00 2022-10-28 05:00:00 3 2022-11-22 11:59:00 2022-11-22 07:00:00 4 2022-11-25 01:59:00 2022-11-25 06:00:00 </code></pre> <p>using this query to retrieve the number of rows which lies between the given date time combinations</p> <pre><code>$this-&gt;db-&gt;query(&quot;SELECT * FROM booking WHERE (TIMEDIFF('$start_time', TIME(start)) &gt;=0 AND TIMEDIFF('$start_time', TIME(end)) &lt;= 0) AND (TIMEDIFF('$end_time', TIME(start)) &gt;=0 AND TIMEDIFF('$end_time', TIME(end)) &lt;= 0) AND user_id=$user_id&quot;)-&gt;num_rows(); </code></pre> <p>where <code>start_time</code> and <code>end_time</code> values are like</p> <pre><code> $start_time=13:00:00 $end_time=22:59:00 $start_time=date('Y-m-d H:i:s', strtotime($fromDate.$start_time)); $end_time=date('Y-m-d H:i:s', strtotime($toDate.$end_time)); </code></pre> <p>tried this query also but not working</p> <pre><code>select * from booking where (start between '2022-10-27 12:20:00' and '2022-10-27 14:50:00') AND (end between '2022-10-27 12:20:00' and '2022-10-27 14:50:00') </code></pre> <p>Any solution. Thanks</p>
[ { "answer_id": 74212168, "author": "Ric Villalba", "author_id": 6912817, "author_profile": "https://Stackoverflow.com/users/6912817", "pm_score": 1, "selected": false, "text": "data.table" }, { "answer_id": 74212182, "author": "dcsuka", "author_id": 19512611, "author_...
2022/10/26
[ "https://Stackoverflow.com/questions/74211892", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3653474/" ]
74,211,946
<p>I'm having an issue with my application. I am trying to toggle one switch, and when this switch is toggled, all the other switched get toggled to off. I have tried using the onChange method. This method works for 2 of the switches on and off, but not for 3 or more?</p> <p>Here is my attempted code:</p> <pre><code>import SwiftUI import ToastUI struct ContentView: View { @State var generatedNumber : Int = 0 @State var allNumbers : Bool = true @State var evensOnly : Bool = false @State var oddsOnly : Bool = false var body: some View { VStack { Text(&quot;Your genenerated number:&quot;) .font(.bold(.title)()) Text(&quot;\(generatedNumber)&quot;) .font(.bold(.custom(&quot;Generated Number Size&quot;, size: 60))()) .foregroundColor(.cyan) VStack{ Toggle(&quot;All numbers&quot;, isOn: $allNumbers) .tint(.cyan) .onChange(of: allNumbers) { newValue in //When toggled, turn other switches off, but leave this one on evensOnly = !newValue oddsOnly = !newValue } Toggle(&quot;Even numbers only&quot;, isOn: $evensOnly) .tint(.cyan) .onChange(of: evensOnly) { newValue in allNumbers = !newValue oddsOnly = !newValue } Toggle(&quot;Odd numbers only&quot;, isOn: $oddsOnly) .tint(.cyan) .onChange(of: oddsOnly) { newValue in allNumbers = !newValue evensOnly = !newValue } }.padding(30) .toggleStyle(.switch) } } } </code></pre> <p>This is what I am getting:</p> <p><a href="https://i.stack.imgur.com/fJutu.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fJutu.gif" alt="enter image description here" /></a></p> <p>Only one switch should be on at a time, and if a different one is toggled, to turn the other 2 off. The onChange method when doing this states: &quot;action tried to update multiple times per frame.&quot; Does this mean that two @State reloads are trying to occur at execution times too close to each other? Please help me</p>
[ { "answer_id": 74212168, "author": "Ric Villalba", "author_id": 6912817, "author_profile": "https://Stackoverflow.com/users/6912817", "pm_score": 1, "selected": false, "text": "data.table" }, { "answer_id": 74212182, "author": "dcsuka", "author_id": 19512611, "author_...
2022/10/26
[ "https://Stackoverflow.com/questions/74211946", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16020851/" ]
74,211,948
<p>Let say I have below <code>ggplot</code></p> <pre><code>library(ggplot2) library(ggnewscale) data = structure(list(grp1 = c(&quot;X&quot;, &quot;X&quot;, &quot;X&quot;, &quot;X&quot;, &quot;Y&quot;, &quot;Y&quot;, &quot;Y&quot;, &quot;Y&quot; ), grp2 = c(&quot;A&quot;, &quot;B&quot;, &quot;C&quot;, &quot;D&quot;, &quot;A&quot;, &quot;B&quot;, &quot;C&quot;, &quot;D&quot;), val = c(1, 2, 3, 4, 3, 4, 5, 6)), row.names = c(NA, -8L), class = &quot;data.frame&quot;) col_define = c('red', 'orange', 'blue', 'lightblue') names(col_define) = c('A', 'B', 'C', 'D') ggplot(data, aes(x = grp1, group = grp2, y = val)) + geom_col(aes(fill = grp2)) + scale_fill_manual(values = col_define, breaks = c(&quot;A&quot;, &quot;B&quot;), name = &quot;1&quot;) + new_scale_fill() + geom_col(aes(fill = grp2)) + scale_fill_manual(values = col_define, breaks = c(&quot;C&quot;, &quot;D&quot;), name = &quot;2&quot;) + theme(legend.position=&quot;top&quot;, legend.direction = 'vertical', legend.box.margin = margin(), legend.box.background = element_rect(fill = alpha('#e5e5e5', 0.60), size = 0.1, linetype = 'solid', color = '#333333')) </code></pre> <p>As we can seen I tried to add background transparency in my plot using <code>element_rect(fill = alpha('#e5e5e5', 0.60)</code>, however is not working. Is there any alternate way to add transparency in the background for this plot?</p> <p>I also want to change the order in <em>label of legend</em> like <code>2, 1</code>, instead <code>1, 2</code>. Basically I want to apply some custom ordering in case there are many levels.</p> <p>Any pointer will be very helpful.</p>
[ { "answer_id": 74212115, "author": "stefan", "author_id": 12993861, "author_profile": "https://Stackoverflow.com/users/12993861", "pm_score": 3, "selected": true, "text": "legend.background" }, { "answer_id": 74212426, "author": "TarJae", "author_id": 13321647, "autho...
2022/10/26
[ "https://Stackoverflow.com/questions/74211948", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1867328/" ]
74,211,954
<p>In our store, I wrote a script that if a customer buys 1 out of 13 total valid items, another item (y) would be automatically added to their cart and be made free. The issue I am running into is that every time the customer removes that free item from their cart, the cart-template page reloads and reruns my script, which automatically adds that free item back to the customers cart.</p> <p>My goal is that although we automate the processing of adding the &quot;free item&quot; to the cart, the customer still has the ability to remove it if they chose, and even increase its quantity, though only one will remain free.</p> <p>Attached is my JS that executes the above code :</p> <pre><code>{% assign liveCode = &quot;yes&quot; %} {% assign bootmodeList = &quot;3932518121587,6631396442197,3957106442355,2017147617395,1658735951987,1561223331955,1561223430259,4810721853525,1658760495219,1561223397491,4698621739093,1658762166387,4760306810965&quot; | split : ',' %} {% assign product_to_add_auto = all_products['test-test-test-enet-cable-bootmod3-flashing-and-f-series-and-g-series-coding-cable'] %} {% assign start = &quot;2022-10-18&quot; | date: '%s' %} {% assign end = &quot;2022-10-19&quot; | date: '%s' %} {% assign today = &quot;now&quot; | date: '%s' %} {% if start &lt;= today and today &lt;= end %} {% unless cart.item_count == 0 or product_to_add_auto.empty? or product_to_add_auto.variants.first.available == false %} {% assign variant_id = product_to_add_auto.variants.first.id %} {% if liveCode == &quot;yes&quot; %} {% if product_to_add_auto.available == true %} {% assign isProduct = false %} {% for item in cart.items %} {% assign product_id = item.product_id | append:&quot;&quot; %} {% if bootmodeList contains product_id %} {% assign isProduct = true %} {% endif %} {% endfor %} {% if isProduct == true %} {{ product_to_add_auto | json }} &lt;script&gt; (function(jquery) { let cartItems = {{ cart.items | json }}, qtyInTheCart = 0, cartUpdates = {}; console.log(cartItems); for (let i = 0; i &lt; cartItems.length; i++) { if (cartItems[i].id === {{ variant_id }}) { qtyInTheCart = cartItems[i].quantity; break; // this checks the cart to prevent double addition of wifi adapter } } if ((cartItems.length === 1) &amp;&amp; (qtyInTheCart &gt; 0)) { cartUpdates = { {{ variant_id }}: 0 } // if wifi adapter is already in cart by itself without bootmode, remove it. } else if ((cartItems.length &gt;= 1) &amp;&amp; (qtyInTheCart !== 1)) { cartUpdates = { {{ variant_id }}: 1 } // adds wifi adapter to cart if bootmode is in cart and theres not one already } else { return; // if none are true, code doesnt run &quot;catch all&quot; } // http response object const params = { type: 'POST', url: '/cart/update.js', data: { updates: cartUpdates }, dataType: 'json', success: function(stuff) { window.location.href = '/cart'; // reloads to cart on successful post request } }; jquery.ajax(params); // fires ajax request using jquery })(jQuery); &lt;/script&gt; {% endif %} {% endif %} {% endif %} {% endunless %} {% endif %} </code></pre> <p>My first attempt at solving this involved creating a unique ID on the &quot;remove&quot; button of the shopping cart and adding an event listener to it with a &quot;.preventDefault()&quot; function attached to it, but it prevented the entire code from working and removed the ability to auto add the free item.</p>
[ { "answer_id": 74437138, "author": "Ryan Meza", "author_id": 17626033, "author_profile": "https://Stackoverflow.com/users/17626033", "pm_score": 1, "selected": true, "text": " if(sessionStorage.getItem('itemInCart') === null ) {\n jquery.ajax(params);\n }\n ...
2022/10/26
[ "https://Stackoverflow.com/questions/74211954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17626033/" ]
74,211,956
<p>I am new into web development, I am learning <code>CSS</code> right now. I have chosen as project for beginning my personal portfolio.</p> <p>I am creating an easy navigation bar, I wanted to add hamburger Icon, but when I have added Icon to <code>navbar</code> the icon is stack at the bottom of the navbar and the animation(the lines are crossed like X, when button is toggled). I want the Icon in the left corner of the navbar.</p> <p>I have tried to add the Icon outside the list, to nav but it overflow <code>&lt;h1&gt;</code> tag, so I have tried to add to <code>&lt;aside&gt;</code> parent, but it overflows the <code>&lt;h1&gt;</code> tag as well.</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>body { background: linear-gradient(180deg, rgb(70, 65, 70), rgb(172, 34, 32)); } .menu { border: 2px solid white; position: sticky; display: flex; flex-direction: row; height: 95vh; width: 17%; background: linear-gradient(180deg, #241023ff, #6b0504ff); /*linear-gradient(180deg, #2274a5ff, #f75c03ff);*/ border-top-right-radius: 10px; border-bottom-right-radius: 10px; transition: 0.5s; } .wrapper { width: 100%; margin: auto; display: flex; justify-content: flex-start; } .container { margin-top: 10px; width: 100%; height: 25px; margin-bottom: 10px; display: flex; flex-direction: column; justify-content: space-between; cursor: pointer; } .menu-logo { height: 3px; width: 30px; background-color: white; } .showmenu { width: 25%; } /* #endregion Toggle button animation*/ /* #region Hover effect*/ nav:hover, nav:active { border-top-right-radius: 10px; border-bottom-right-radius: 10px; } li a:hover, li a:active { font-weight: bold; border: 1px solid white; border-radius: 10px; background: rgb(246, 246, 246); transition: 0.5s; } li a:hover svg, li a:active svg { fill: #f75c03ff; } li a:hover span, li a:active span { color: #f75c03ff; stroke: #f75c03ff; } /* #endregion Hover effect*/ nav { width: 100%; display: list-item; text-align: center; justify-content: center; } /* #region Welcome text*/ nav .welcome-text { width: 100%; margin-left: auto; display: flex; justify-content: center; font-size: 3.5vw; margin-bottom: 60px; color: white; text-align: center; } /* #endregion Welcome text*/ /* #region Main content*/ /* #region Wave animation*/ .wave { width: 50%; animation-name: wave-animation; /* Refers to the name of your @keyframes element below */ animation-duration: 2.5s; /* Change to speed up or slow down */ animation-iteration-count: infinite; /* Never stop waving :) */ transform-origin: 70% 70%; /* Pivot around the bottom-left palm */ display: inline-block; } @keyframes wave-animation { 0% { transform: rotate( 0.0deg) } 10% { transform: rotate(14.0deg) } /* The following five values can be played with to make the waving more or less extreme */ 20% { transform: rotate(-8.0deg) } 30% { transform: rotate(14.0deg) } 40% { transform: rotate(-4.0deg) } 50% { transform: rotate(10.0deg) } 60% { transform: rotate( 0.0deg) } /* Reset for the last half to pause */ 100% { transform: rotate( 0.0deg) } } /* #endregion Wave animation*/ nav ul { width: 100%; height: 100%; display: list-item; } nav ul li { width: 100%; display: flex; flex-direction: row; align-items: center; } li a { width: 100%; height: 7%; text-decoration: none; display: flex; text-align: left; font-size: 100%; justify-content: center; margin-bottom: 10px; } li a span { width: 100%; font-size: 2.7vw; align-self: center; color: white; margin-left: 10px; } li a svg { width: 20%; height: 20%; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;aside class="menu"&gt; &lt;div class="container nav-container"&gt; &lt;input class="checkbox" type="checkbox" name="" id="" /&gt; &lt;div class="hamburger-lines"&gt; &lt;span class="line line1"&gt;&lt;/span&gt; &lt;span class="line line2"&gt;&lt;/span&gt; &lt;span class="line line3"&gt;&lt;/span&gt; &lt;/div&gt; &lt;/div&gt; &lt;nav&gt; &lt;ul&gt; &lt;li&gt; &lt;h1 class="welcome-text"&gt;Welcome &lt;span class="wave"&gt;&lt;/span&gt;&lt;/h1&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="#"&gt; &lt;svg viewBox="0 0 24 24" fill="transparent" stroke="white" xmlns="http://www.w3.org/2000/svg"&gt; &lt;path d="M21 8.77217L14.0208 1.79299C12.8492 0.621414 10.9497 0.621413 9.77817 1.79299L3 8.57116V23.0858H10V17.0858C10 15.9812 10.8954 15.0858 12 15.0858C13.1046 15.0858 14 15.9812 14 17.0858V23.0858H21V8.77217ZM11.1924 3.2072L5 9.39959V21.0858H8V17.0858C8 14.8767 9.79086 13.0858 12 13.0858C14.2091 13.0858 16 14.8767 16 17.0858V21.0858H19V9.6006L12.6066 3.2072C12.2161 2.81668 11.5829 2.81668 11.1924 3.2072Z" /&gt; &lt;/svg&gt; &lt;span&gt;Home&lt;/span&gt; &lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/nav&gt; &lt;/aside&gt;</code></pre> </div> </div> </p> <p>Full code here: <a href="https://jsfiddle.net/Lhawck59/" rel="nofollow noreferrer">https://jsfiddle.net/Lhawck59/</a></p>
[ { "answer_id": 74437138, "author": "Ryan Meza", "author_id": 17626033, "author_profile": "https://Stackoverflow.com/users/17626033", "pm_score": 1, "selected": true, "text": " if(sessionStorage.getItem('itemInCart') === null ) {\n jquery.ajax(params);\n }\n ...
2022/10/26
[ "https://Stackoverflow.com/questions/74211956", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19819759/" ]
74,211,961
<p>So here is my code so far that isn't faring to well:</p> <pre><code>url = 'https://americanbarbell.com/products/american-barbell-cast-kettlebell' path = &quot;C:\Program Files (x86)\msedgedriver.exe&quot; driver = webdriver.Edge(path) driver.get(url) time.sleep(5) driver.find_element(By.XPATH,'//*[@id=&quot;closeIconSvg&quot;]').click() </code></pre> <p>But I keep getting this back:</p> <pre><code>Message: no such element: Unable to locate element: {&quot;method&quot;:&quot;xpath&quot;,&quot;selector&quot;:&quot;//*[@id=&quot;closeIconSvg&quot;]&quot;} </code></pre> <p>I'm not seeing anything about an iFrame? I saw a lot of other people with this problem but have yet to find a working solution.</p> <p>Thanks in advance</p>
[ { "answer_id": 74212631, "author": "Qvch", "author_id": 15576385, "author_profile": "https://Stackoverflow.com/users/15576385", "pm_score": 0, "selected": false, "text": "url = 'https://americanbarbell.com/products/american-barbell-cast-kettlebell'\npath = \"C:\\Program Files (x86)\\msed...
2022/10/26
[ "https://Stackoverflow.com/questions/74211961", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16548375/" ]
74,211,970
<p>How can I use one css code snipped for more ids? The code I tried doesn´t work. My goal is that when the user hovers over the text with the id &quot;txtBurgerista&quot;, all the texts with the other ids should be white. But only when the user hovers id &quot;txtBurgerista&quot;.</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>#txtBurgerista:hover ~ #txtFitGreen, #txtMore { color:white }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="bigDiv2"&gt; &lt;h2 id="txtBurgerista" class="txtBurgerista"&gt;Burgerista&lt;/h2&gt; &lt;h2 id="txtFitGreen"&gt;Fit Green Mind&lt;/h2&gt; &lt;h2 id="txtNinjas"&gt;Ninjas&lt;/h2&gt; &lt;h2 id="txtReinhartshuber"&gt;Reinhartshuber&lt;/h2&gt; &lt;h2 id="txtLakhis"&gt;Lakhi´s&lt;/h2&gt; &lt;h2 id="txtIndigo"&gt;my Indigo&lt;/h2&gt; &lt;h2 id="txtMore"&gt;And more&lt;/h2&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74212021, "author": "Mr.Lister", "author_id": 6931232, "author_profile": "https://Stackoverflow.com/users/6931232", "pm_score": 1, "selected": false, "text": "#txtBurgerista:hover, \n#txtFitGreen, \n#txtMore {\n color:white\n}\n" }, { "answer_id": 74212113, "a...
2022/10/26
[ "https://Stackoverflow.com/questions/74211970", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20332178/" ]
74,211,972
<p>How to make hover effects for an image?</p> <p>code sample:</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>img:hover { background: X; color: X }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;li class="navDash"&gt; &lt;img class="dashImg" width="200" src="https://openclipart.org/image/800px/170531" alt=""&gt; Dashboard &lt;/li&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74212012, "author": "Mohammed", "author_id": 8973254, "author_profile": "https://Stackoverflow.com/users/8973254", "pm_score": 0, "selected": false, "text": "img:hover {\n border: 3px solid black;\n}\n" }, { "answer_id": 74212122, "author": "Ansh", "auth...
2022/10/26
[ "https://Stackoverflow.com/questions/74211972", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19699302/" ]
74,211,985
<pre><code>var url = &quot;{{ route('order-detail',':slug') }}&quot;; console.log(url); </code></pre> <p>I want to add one more parameter <code>id</code> after <code>slug</code>:</p> <pre><code>var url = &quot;{{ route('order-detail',':slug',':id') }}&quot;; console.log(url); </code></pre> <p>This is the error:</p> <blockquote> <p>Missing required parameter for [Route: order-detail] [URI: orders/detail/{slug}/{id}] [Missing parameter: id]. (View: /var/www/html/projectname/Modules/Orders/Resources/views/new-orders.blade.php)</p> </blockquote>
[ { "answer_id": 74212124, "author": "jef", "author_id": 12958413, "author_profile": "https://Stackoverflow.com/users/12958413", "pm_score": 0, "selected": false, "text": "var url = \"{{ route('order-detail', [':slug', ':id']) }}\";\n" }, { "answer_id": 74212980, "author": "Inn...
2022/10/26
[ "https://Stackoverflow.com/questions/74211985", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13997631/" ]
74,212,017
<p>Given two almost identical lists of worker IDs x and y where one of the lists contains an additional ID, write a function solution(x, y) that compares the lists and returns the additional ID.</p> <p>For example, given the lists x = [13, 5, 6, 2, 5] and y = [5, 2, 5, 13], the function solution(x, y) would return 6 because the list x contains the integer 6 and the list y doesn't. Given the lists x = [14, 27, 1, 4, 2, 50, 3, 1] and y = [2, 4, -4, 3, 1, 1, 14, 27, 50], the function solution(x, y) would return -4 because the list y contains the integer -4 and the list x doesn't.</p> <p>In each test case, the lists x and y will always contain n non-unique integers where n is at least 1 but never more than 99, and one of the lists will contain an additional unique integer which should be returned by the function. The same n non-unique integers will be present on both lists, but they might appear in a different order like in the examples above. Commander Lambda likes to keep the numbers short, so every worker ID will be between -1000 and 1000.</p> <p>Here is the code I have tried to come up with - which doesnt work any help would be appreciated</p> <pre><code>def solution(x,y): non_match_a = set(x)-set(y) non_match_b = set(y)-set(x) non_match = list(non_match_a) + list(non_match_b) return non_match input = solution([x],[y]) non_match = solution(y, x) </code></pre>
[ { "answer_id": 74212226, "author": "Cobra", "author_id": 17580381, "author_profile": "https://Stackoverflow.com/users/17580381", "pm_score": -1, "selected": false, "text": "from itertools import zip_longest\n\ndef solution(x, y):\n for _x, _y in zip_longest(sorted(x), sorted(y)):\n ...
2022/10/26
[ "https://Stackoverflow.com/questions/74212017", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15494148/" ]
74,212,026
<p>I have a BQ table X with a field named output which is of repeated float type with length=10. so, the column is sth like: [v0,... ,v9] for each row. I'd like to transform the table in a way to add 10 new columns to the table with new col_names. Basically, I'd like to have this new table:</p> <p>row0: v00, ..., v09, rest of column values for row0 row1: v10, ..., v19, rest of column values for row1 ... rown: vn1, ..., vn9, rest of column values for rown</p> <p>Thanks for your help in advance!</p> <p>I am aware of UNNEST function but I don't think that would be relevant here.</p>
[ { "answer_id": 74212226, "author": "Cobra", "author_id": 17580381, "author_profile": "https://Stackoverflow.com/users/17580381", "pm_score": -1, "selected": false, "text": "from itertools import zip_longest\n\ndef solution(x, y):\n for _x, _y in zip_longest(sorted(x), sorted(y)):\n ...
2022/10/26
[ "https://Stackoverflow.com/questions/74212026", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20341892/" ]
74,212,057
<p>I have a mariadb server running on debian. (version: 10.3.34-MariaDB-0+deb10u1-log Debian 10)</p> <p>I have used the package from the repository, so it was compiled with YaSSL (version 2.4.4). <br> Therefore the newest SSL version of the server is TLS1.1.</p> <p>On the client I use Ubuntu 22.04 (5.15.0-52-generic). <br> The mariadb client seems to use the locally installed openssl (3.0.2 15 Mar 2022)</p> <p>When I try to connect to the mariadb-server<br> with this command:</p> <blockquote> <p>mysql --tls-version=TLSv1.1 -v -v -v --ssl-cert=&quot;/home/leon/certs/client-cert.pem&quot; --ssl-key=&quot;/home/leon/certs/client-key.pem&quot; -umyuser -hmaria.example.de -p</p> </blockquote> <p>I get this error:<br> ERROR 2026 (HY000): SSL connection error: no protocols available</p> <p>Ok, it seems, I have to manually activate TLSv1.1 in the client. <br></p> <p>So I created an extra cnf-file with these lines:</p> <blockquote> <p>openssl_conf = default_conf</p> <p>[default_conf] ssl_conf = ssl_sect</p> <p>[ssl_sect] system_default = system_default_sect</p> <p>[system_default_sect] MinProtocol = TLSv1.1 CipherString = DEFAULT@SECLEVEL=1</p> </blockquote> <p>And then activated it with:<br> export OPENSSL_CONF=/etc/ssl/unsafe.cnf</p> <p>When I try to connect again I get this error:<br> ERROR 2026 (HY000): SSL connection error: unsafe legacy renegotiation disabled</p> <p>Ok, I need to activate the unsafe legacy renegotiation. <br> So I have added the following line to the [system_default_sect] in the cnf-file:</p> <blockquote> <p>Options = UnsafeLegacyRenegotiation</p> </blockquote> <p>But when I try to connect again, I get this error:<br> ERROR 2026 (HY000): SSL connection error: internal error</p> <p>Is there something wrong in the cnf-file?<br> Or is it not possible to activate &quot;UnsafeLegacyRenegotiation&quot; and &quot;TLSv1.1&quot; at the same time?</p> <p>Thank you for any help or hints!</p> <p>EDIT: Added the output of this command:<br> openssl s_client -tls1_1 --starttls mysql python.fairtragen.de:3306</p> <pre><code>CONNECTED(00000003) depth=0 CN = python.fairtragen.de, L = Bremen, O = fairtragen GmbH, OU = &quot; &quot;, emailAddress = python@fairtragen.de, C = DE verify error:num=20:unable to get local issuer certificate verify return:1 depth=0 CN = python.fairtragen.de, L = Bremen, O = fairtragen GmbH, OU = &quot; &quot;, emailAddress = python@fairtragen.de, C = DE verify error:num=21:unable to verify the first certificate verify return:1 depth=0 CN = python.fairtragen.de, L = Bremen, O = fairtragen GmbH, OU = &quot; &quot;, emailAddress = python@fairtragen.de, C = DE verify return:1 40F70087447F0000:error:0A0C0103:SSL routines:tls_process_key_exchange:internal error:../ssl/statem/statem_clnt.c:2248: --- Certificate chain 0 s:CN = python.fairtragen.de, L = Bremen, O = fairtragen GmbH, OU = &quot; &quot;, emailAddress = python@fairtragen.de, C = DE i:C = DE, ST = Some-State, O = fairtragen GmbH, CN = fairCA, emailAddress = fellows@fairtragen.de a:PKEY: rsaEncryption, 2048 (bit); sigalg: RSA-SHA256 v:NotBefore: Apr 20 00:00:00 2021 GMT; NotAfter: Apr 20 00:00:00 2031 GMT --- Server certificate -----BEGIN CERTIFICATE----- MIIEdDCCAlwCAQAwDQYJKoZIhvcNAQELBQAwczELMAkGA1UEBhMCREUxEzARBgNV BAgMClNvbWUtU3RhdGUxGDAWBgNVBAoMD2ZhaXJ0cmFnZW4gR21iSDEPMA0GA1UE AwwGZmFpckNBMSQwIgYJKoZIhvcNAQkBFhVmZWxsb3dzQGZhaXJ0cmFnZW4uZGUw IhgPMjAyMTA0MjAwMDAwMDBaGA8yMDMxMDQyMDAwMDAwMFowgYgxHTAbBgNVBAMM FHB5dGhvbi5mYWlydHJhZ2VuLmRlMQ8wDQYDVQQHDAZCcmVtZW4xGDAWBgNVBAoM D2ZhaXJ0cmFnZW4gR21iSDEKMAgGA1UECwwBIDEjMCEGCSqGSIb3DQEJARYUcHl0 aG9uQGZhaXJ0cmFnZW4uZGUxCzAJBgNVBAYTAkRFMIIBIjANBgkqhkiG9w0BAQEF AAOCAQ8AMIIBCgKCAQEAtvTsn5+GCuhFztfyzLG8T3YQNf3/jmMIP/rZKCTC6D+K neKeXBUBkWyPT7398h8lJtfZhfK6TRPR4VmrCnxYuWJL2LdwSACcRcyA0rRgE9SC 8Y7LJulcyetl/JjQAXY6/wFdMcEHRqlCzyTEqumsJsImcE2hHbnNIHd9OukmB8Qq oS1/e6fKQTjvR90huIyRhHtCMFYiAglCMbmPRuFflzFZ6cULdL0Se7oiLIbsdamV oFUXk3crcZP3EAR0UMqZ/hQN8vTphDHOngOuss/ORBo0ezxTOXC2Gpmz5RmJKWbN Ch5tUgIgPEK/cdiz7LnA/CbDXKsWlnEfhoVfL00shwIDAQABMA0GCSqGSIb3DQEB CwUAA4ICAQAJtzQxuGNHlS5LYJkx2CTJTm44PmbuKOfuR8qwjAnsfDHuevADjwCf aeH9D5pxpdYFdH8Ll9RzynxTAIHQQLcBzIrTCbouQwOZqpNXszbJhrKjEJ+yOJjM +LnYfnQRttC6G7gjTHIOixLwOeaRuMCwaZXCYitwPR+6PCfQG+4AFZlOvNIOQDlD arDJJoAXgE0RH+YlVfyNcSZUMaxOJYK4awN8/5lCLsCk8CZ2/mfOz9DdCKirou5U Z+Sbu4zPLF49F1xXVK7+omdys57dCXto6ykWahXtrMH/A4JjIsf4GBv2s/im9PTK 9tXPBjk6VT6ZsSCBHa62hzvTiZMzRRBLNlPMldbQerO6/Q/18DueoYT1+e6/Aw3k /nXgnB7Ztjbemuj1D22MNSHyclRt5ifUskGGLc0nl54rJQCnhTdZW6UwDyCpSDU8 n82Omclgfndyt71I3ecxsCduhHjd+5Nn7e2sIyttPhHLeP6hTbjgDwgSAeHjrjD+ VeKBoahnyXqhWMNQPhkgqPQH6VEQjAaB7NwewfiNziWy3Nd+ThgHJFNP9vHYyeju 2IaE+JBegGgxus0/IQeFTkGuZat7cEMoHE9TQEeGJ6fpqTyeEuqVG/ulAm5qT6zy ZGOI/RjKGo68AqISogpA2vcWel/h//qyYDQ/683MtPDwef2uKbcH6g== -----END CERTIFICATE----- subject=CN = python.fairtragen.de, L = Bremen, O = fairtragen GmbH, OU = &quot; &quot;, emailAddress = python@fairtragen.de, C = DE issuer=C = DE, ST = Some-State, O = fairtragen GmbH, CN = fairCA, emailAddress = fellows@fairtragen.de --- No client certificate CA names sent Server Temp Key: DH, 2048 bits --- SSL handshake has read 2131 bytes and written 176 bytes Verification error: unable to verify the first certificate --- New, (NONE), Cipher is (NONE) Server public key is 2048 bit Secure Renegotiation IS NOT supported Compression: NONE Expansion: NONE No ALPN negotiated SSL-Session: Protocol : TLSv1.1 Cipher : 0000 Session-ID: E81DDD60800D1F4505F5A5D0A273E776EAEDDAF205BD2195092D7132EAAC0F53 Session-ID-ctx: Master-Key: PSK identity: None PSK identity hint: None SRP username: None Start Time: 1666861958 Timeout : 7200 (sec) Verify return code: 21 (unable to verify the first certificate) Extended master secret: no --- </code></pre>
[ { "answer_id": 74244262, "author": "Leon", "author_id": 2002797, "author_profile": "https://Stackoverflow.com/users/2002797", "pm_score": 1, "selected": false, "text": "cmake ../mariadb-server -DCMAKE_INSTALL_PREFIX=/usr/local/mariadb-server-10.9_ssl-3.0 -DOPENSSL_ROOT_DIR=/usr/local/ssl...
2022/10/26
[ "https://Stackoverflow.com/questions/74212057", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2002797/" ]
74,212,076
<p>I'm trying to make my code display an extra input if a certain condition is met (in this case, selecting &quot;Y&quot;)</p> <p>This is what I've tried:</p> <pre><code> if RandomNum != UserGuess: print(&quot;Sorry, you guessed wrong. The number was: &quot;, RandomNum) KeepGuess = input(&quot;Would you like to continue guessing? (Y/N): &quot;).upper() elif KeepGuess == &quot;Y&quot;: continue else: break </code></pre> <p>When I do this, I get the following error:</p> <pre><code> elif KeepGuess == &quot;Y&quot;: UnboundLocalError: local variable 'KeepGuess' referenced before assignment </code></pre>
[ { "answer_id": 74212145, "author": "amirali mollaei", "author_id": 13897386, "author_profile": "https://Stackoverflow.com/users/13897386", "pm_score": 3, "selected": true, "text": "if RandomNum != UserGuess:\n print(\"Sorry, you guessed wrong. The number was: \", RandomNum)\n KeepG...
2022/10/26
[ "https://Stackoverflow.com/questions/74212076", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20258403/" ]
74,212,086
<p>I am getting the error <code>Could not resolve type of column &quot;id&quot; of class &quot;App\Entity\Officecurrencymax&quot;</code> from my installation. Have checked similar questions but I can't seem to get the Doctrine annotations right.</p> <p>I have 2 entities with a ManyToOne relationship, Office and OfficeCurrencyMax. One Office can have many OfficeCurrencyMax's.</p> <pre><code>/** * Office * * @ORM\Table(name=&quot;Office&quot;) * @ORM\Entity(repositoryClass=&quot;App\Repository\OfficeRepository&quot;) */ class Office { // ... /** * @ORM\ManyToOne(targetEntity=&quot;Officecurrencymax&quot;, inversedBy=&quot;offices&quot;) */ private $officeCurrencyMaxes; // ... public function getOfficeCurrencyMaxes(): ?Officecurrencymax { return $this-&gt;officeCurrencyMaxes; } public function setOfficeCurrencyMaxes(?Officecurrencymax $officeCurrencyMaxes): self { $this-&gt;officeCurrencyMaxes = $officeCurrencyMaxes; return $this; } } </code></pre> <p>Then there is the Officecurrencymax entity:</p> <pre><code>/** * Officecurrencymax * * @ORM\Table(name=&quot;OfficeCurrencyMax&quot;, indexes={@ORM\Index(name=&quot;IDX_6F39111B73FD6E34&quot;, columns={&quot;Office&quot;})}) * @ORM\Entity(repositoryClass=&quot;App\Repository\OfficeCurrencyMaxRepository&quot;) */ class Officecurrencymax { // ... /** * @var integer * * @ORM\Column(name=&quot;Id&quot;, type=&quot;integer&quot;, nullable=false) * @ORM\Id * @ORM\GeneratedValue(strategy=&quot;IDENTITY&quot;) */ private $id; /** * @var \Office * * @ORM\ManyToOne(targetEntity=&quot;Office&quot;, inversedBy=&quot;offices&quot;) * @ORM\JoinColumns({ * @ORM\JoinColumn(name=&quot;Office&quot;, referencedColumnName=&quot;OfficeId&quot;) * }) */ private $office; // ... public function getId(): ?int { return $this-&gt;id; } // ... } </code></pre> <p>I had to cut down the code a lot since StackOverflow wouldn't let me post since <code>it looks like your post is mainly code, please add some more details</code>.</p>
[ { "answer_id": 74212145, "author": "amirali mollaei", "author_id": 13897386, "author_profile": "https://Stackoverflow.com/users/13897386", "pm_score": 3, "selected": true, "text": "if RandomNum != UserGuess:\n print(\"Sorry, you guessed wrong. The number was: \", RandomNum)\n KeepG...
2022/10/26
[ "https://Stackoverflow.com/questions/74212086", "https://Stackoverflow.com", "https://Stackoverflow.com/users/206852/" ]
74,212,133
<p>Here's my code:</p> <pre><code>const names = [ {name:'Finn',age: 23}, {name:'Presten',age: 24}, {name:'Pearl',age: 21}, {name:'Tim',age: 22}, {name:'Jade',age: 25}, {name:'Princess',age: 23}, ] const filterName = names.filter(function(nameWithOutC: {name: string, age: number}): boolean { return nameWithOutP.book !== 'P' }) console.log('Filtering out a name starting with letter P') console.log(filterName) </code></pre> <p>I am trying to figure out how can able to filter out the names starting with the letter &quot;P&quot;.</p>
[ { "answer_id": 74212167, "author": "Fexo", "author_id": 14125846, "author_profile": "https://Stackoverflow.com/users/14125846", "pm_score": 1, "selected": false, "text": "bookstore.filter((name, age) => !name.startsWith(\"P\"))\n" }, { "answer_id": 74212385, "author": "Jackso...
2022/10/26
[ "https://Stackoverflow.com/questions/74212133", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17483611/" ]
74,212,134
<p>in my Angular project I'm getting data from an API using a service. Is there a way to show this data on the UI without firing an event? I saw a lot of examples which do this by clicking on a button, however I do not want to click on a button to show the data. I want this to be done whenever my page is loaded. Thanks.</p>
[ { "answer_id": 74212167, "author": "Fexo", "author_id": 14125846, "author_profile": "https://Stackoverflow.com/users/14125846", "pm_score": 1, "selected": false, "text": "bookstore.filter((name, age) => !name.startsWith(\"P\"))\n" }, { "answer_id": 74212385, "author": "Jackso...
2022/10/26
[ "https://Stackoverflow.com/questions/74212134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13486705/" ]
74,212,149
<p>I'm currently trying to build code using gcc / g++ like this:</p> <pre><code>g++-10 -std=c++2a -Wall -Wextra -c -o hw01.o hw01.cpp </code></pre> <p>(Also the same outcome with gcc-10, gcc, g++) And I have a static check in my Code:</p> <pre><code>static_assert(__cplusplus &gt;= 202002L); </code></pre> <p>which sadly fails every time. As far as I've reserched, the used C++ version depends on gcc and it's version. gcc-10 has version 10.3.0 and the normal gcc command uses version 9.4.0, so both should be able to use C++20 as specified in the build command. Yet when looking in VsCode, the variable <code>__cplusplus</code> evaluates to <code>201402L</code>, therefore making the assertion fail.</p> <p>Even when uninstalling / reinstalling the compilers (or sudo apt remove cpp) this problem persists.</p> <p>Any help? How do I get my system to use a newer C++ version?</p> <p>PS: I'm working on a Ubuntu WSL (host system is Windows 10)</p> <p>Edit: Since most recommondations are to neglect the static test and f.e. test for a different value of __cplusplus or simply throw out the test, i'm doing this for a university assignment. The satic test is non-negotiable, can not be changed and also not altered. I have to make the test pass by changing the build value of my local C++ version, I just don't know how.</p>
[ { "answer_id": 74212167, "author": "Fexo", "author_id": 14125846, "author_profile": "https://Stackoverflow.com/users/14125846", "pm_score": 1, "selected": false, "text": "bookstore.filter((name, age) => !name.startsWith(\"P\"))\n" }, { "answer_id": 74212385, "author": "Jackso...
2022/10/26
[ "https://Stackoverflow.com/questions/74212149", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12079819/" ]
74,212,170
<p>how should the following code be structured in order for the correct statements to be printed when the user has input an integer?</p> <p>What am i doing wrong? i have tried to change the code in so many ways with no luck.</p> <pre><code>x = int(input(&quot;Please enter a number:\n&quot;)) if x % 3 == 0 and x % 5 == 0: print(&quot;Your number is divisible by 3 and 5.&quot;) if x % 3 == 0 and x % 5 == 1: print(&quot;Your number is divisible by 3 and NOT 5.&quot;) elif x % 3 == 1 and x % 5 == 0: print(&quot;Your number is NOT divisible by 3 and is divisible by 5.&quot;) else: print(&quot;Your number is NOT divisible by 3 and 5.&quot;) </code></pre> <p>or</p> <pre><code>x = int(input(&quot;Please enter a number:\n&quot;)) if ((x % 3 == 0) &amp; (x % 5 == 0)): print(&quot;Your number is divisible by 3 and 5.&quot;) if ((x % 3 == 0) &amp; (x % 5 == 1)): print(&quot;Your number is divisible by 3 and NOT 5.&quot;) elif ((x % 3 == 1) &amp; (x % 5 == 0)): print(&quot;Your number is NOT divisible by 3 and is divisible by 5.&quot;) else: print(&quot;Your number is NOT divisible by 3 and 5.&quot;) </code></pre> <p>I want the correct phrase to be displayed once the user has input their chosen integer.</p>
[ { "answer_id": 74212214, "author": "Byron", "author_id": 4187337, "author_profile": "https://Stackoverflow.com/users/4187337", "pm_score": 1, "selected": true, "text": "if x % 3 == 0:\n if x % 5 == 0:\n print(\"Your number is divisible by 3 & 5\")\n else:\n print(\"Yo...
2022/10/26
[ "https://Stackoverflow.com/questions/74212170", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20328893/" ]
74,212,173
<p>I have a parent component with the following template:</p> <pre><code>&lt;app-sidebar&gt;&lt;/app-sidebar&gt; &lt;router-outlet&gt;&lt;/router-outlet&gt; &lt;app-footer&gt;&lt;/app-footer&gt; </code></pre> <p>How can I show or hide the <code>app-sidebar</code> or <code>app-footer</code> component based on the component routing through the router outlet? I have a boolean <code>showSidebar</code> I'd like to use, with it's value set to true or false on each child component.</p> <pre><code>&lt;app-sidebar *ngIf=showSidebar&gt;&lt;/app-sidebar&gt; </code></pre>
[ { "answer_id": 74212214, "author": "Byron", "author_id": 4187337, "author_profile": "https://Stackoverflow.com/users/4187337", "pm_score": 1, "selected": true, "text": "if x % 3 == 0:\n if x % 5 == 0:\n print(\"Your number is divisible by 3 & 5\")\n else:\n print(\"Yo...
2022/10/26
[ "https://Stackoverflow.com/questions/74212173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1819315/" ]
74,212,178
<p>I am trying to change the data structure of an array of objects in JS. I have an array of objects that contain the same keys that I would like to merge to one for example <code>route</code>. And then would like to add <code>query</code> and <code>time</code> in a new array. Example below:</p> <p>How do I change this data structure:</p> <pre><code>const array = [ { query: &quot;query1&quot;, route: &quot;home&quot;, time: 1234 }, { query: &quot;query2&quot;, route: &quot;dashboard&quot;, time: 4324 }, { query: &quot;query3&quot;, route: &quot;home&quot;, time: 1200 }, { query: &quot;query4&quot;, route: &quot;admin&quot;, time: 3333 }, { query: &quot;query5&quot;, route: &quot;admin&quot;, time: 5435 }, ] </code></pre> <p>to become this:</p> <pre><code>const array = [ { route: &quot;home&quot;, calls: [ { query: &quot;query1&quot;, time: 1234 }, { query: &quot;query3&quot;, time: 1200 }, ] }, { route: &quot;dashboard&quot;, calls: [ { query: &quot;query2&quot;, time: 4324 }, ] }, { route: &quot;admin&quot;, calls: [ { query: &quot;query4&quot;, time: 3333 }, { query: &quot;query5&quot;, time: 5435 }, ] } ] </code></pre> <p>Thanks in advance</p>
[ { "answer_id": 74212338, "author": "Mina", "author_id": 11887902, "author_profile": "https://Stackoverflow.com/users/11887902", "pm_score": 2, "selected": true, "text": "reduce" }, { "answer_id": 74213402, "author": "trincot", "author_id": 5459839, "author_profile": "...
2022/10/26
[ "https://Stackoverflow.com/questions/74212178", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13238502/" ]