qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,147,313
<p>I am trying to store headings and paragraphs into different arrays, i can't manage with text between <code>&lt;br&gt;</code>.</p> <p>Here's my HTML code and <code>python</code> below:</p> <pre><code>&lt;p&gt;&lt;strong&gt;W Ognisku&lt;/strong&gt;&lt;br&gt;W londyńskim Ognisku Polskim odbyło się spotkanie z brytyjskim historykiem&lt;br&gt;&lt;br&gt;&lt;strong&gt;10 lat polskiej szkoły sobotniej Copernicus &lt;/strong&gt;&lt;br&gt;W Wielkiej Brytanii &lt;br&gt;&lt;br&gt;&lt;strong&gt;IV Bieg Pamięci Dywizjonu 303 w Londynie&lt;/strong&gt;&lt;br&gt;Już po raz czwarty w dzielnicy&lt;br&gt;&lt;br&gt;&lt;strong&gt;81 Liebermana&lt;/strong&gt;&lt;br&gt;21 majowym przeciwstawił się rządom Piłsudskiego. &lt;br&gt;&lt;strong&gt;&lt;br&gt;Londynem&lt;/strong&gt;&lt;br&gt;Był setki pełnymi garściami.&lt;/p&gt; </code></pre> <p>and soup:</p> <pre><code>from bs4 import BeautifulSoup with open('/Users/milek/Desktop/index.html', 'r') as f: contents = f.read() soup = BeautifulSoup(contents, 'lxml') headings = [] txt = [] for strong_tag in soup.find_all('strong'): headings.append(strong_tag.text) print(headings) </code></pre> <p>I retrieved headings with full success but I have pretty hard time storing the rest - paragraphs.</p> <p>@HedgeHog</p> <p>Here's the code in selenium which relies on this stored data which im trying to achieve. Headings are</p> <pre><code>#++++++++++++++++++++++ ADD VIDEO ++++++++++++++++++++++ def addVideo(titles): add_button = browser.find_element(By.CLASS_NAME, 'object-adder') add_button.click() chooseVIDEO = browser.find_element(By.CSS_SELECTOR, &quot;a[value*='2']&quot;) chooseVIDEO.click() sleep(3) # -------------- ADD HEADING -------------- title = browser.find_element(By.NAME, 'title') title.send_keys(THIS IS THE PLACE FOR EACH HEADING) sleep(4) # -------------- NO RESTRICTIONS ------------ zone_restriction = browser.find_element(By.NAME, 'zoneRestriction') zone_restriction.click() sleep(4) typewrite('b') typewrite('e') press('enter') sleep(2) # -------------- NO ADDS --------------- noAdv = browser.find_element(By.NAME, 'adsEnabled') noAdv.click() # ------------- SAVE ----------- sleep(3) saveGoObj = browser.find_element(By.ID, 'saveButton') saveGoObj.click() #++++++++++++++++++++++ ADD PARAGRAPH +++++++++++++++++++++++ def addTXT(paras): add_button = browser.find_element(By.CLASS_NAME, 'object-adder') add_button.click() chooseParagraph = browser.find_element(By.CSS_SELECTOR, &quot;a[value*='33']&quot;) chooseParagraph.click() sleep(3) # -------------- ADD TITLE -------------- title = browser.find_element(By.NAME, 'title') title.send_keys('txt') # -------------- ADD PARAGRAPH ------------- textPara = browser.find_element(By.XPATH, &quot;//textarea[@name='text']&quot;) textPara.send_keys(THIS IS THE PLACE FOR EACH PARAGRAPH) sleep(6) # ------------- SAVE ----------- saveGoObj = browser.find_element(By.ID, 'saveButton') saveGoObj.click() sleep(6) </code></pre>
[ { "answer_id": 74147310, "author": "Barmar", "author_id": 1491895, "author_profile": "https://Stackoverflow.com/users/1491895", "pm_score": 3, "selected": true, "text": "from collections import defaultdict\n\na = [[1, 'a', 2], [2, 'a', 3], [3, 'b', 4], [4, 'c', 5]]\noutput_dict = default...
2022/10/20
[ "https://Stackoverflow.com/questions/74147313", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20296235/" ]
74,147,320
<p>I have a list: and this list could be very long duplicated of the values can vary because of it.</p> <pre><code>l1 = [[{'node': 'node-3', 'value': 7.5456592756413645},{'node': 'node-5', 'value': 6.988051860579239},{'node': 'node-0', 'value': 11.394453190010722},{'node': 'node-7', 'value': 7.905077155911794}, {'node': 'node-4', 'value': 7.792379308708253}, {'node': 'node-14', 'value': 10.292450756795946}, {'node': 'node-1', 'value': 6.355755419836891}, {'node': 'node-15', 'value': 14.111596406948182}, {'node': 'node-16', 'value': 13.40657800705202}, {'node': 'node-2', 'value': 6.015374411354142}, {'node': 'node-9', 'value': 7.047300820373079}, {'node': 'node-17', 'value': 12.68578754440751}, {'node': 'node-8', 'value': 7.800883809244761}, {'node': 'node-10', 'value': 12.064107712975112}, {'node': 'node-6', 'value': 9.7540013919274}, {'node': 'node-12', 'value': 12.318039154397544}, {'node': 'node-13', 'value': 9.755403652626981}, {'node': 'node-11', 'value': 12.261621612054046}], [{'node': 'node-3', 'value': 6.761078690857657}, {'node': 'node-5', 'value': 8.749145084411227}, {'node': 'node-0', 'value': 12.366653629672784}, {'node': 'node-7', 'value': 9.646920894631135}, {'node': 'node-4', 'value': 6.496804630916606}, {'node': 'node-14', 'value': 13.52834341167122}, {'node': 'node-1', 'value': 6.624804810314409}, {'node': 'node-15', 'value': 16.68569380522415}, {'node': 'node-16', 'value': 15.114235217020076}, {'node': 'node-2', 'value': 6.957799674666696}, {'node': 'node-9', 'value': 11.003732393553822}, {'node': 'node-17', 'value': 14.872999031713572}, {'node': 'node-8', 'value': 6.1783864922581175}, {'node': 'node-10', 'value': 8.761628593039768}, {'node': 'node-6', 'value': 7.151000108866281}, {'node': 'node-12', 'value': 11.369187124409983}, {'node': 'node-13', 'value': 11.13383409022003}, {'node': 'node-11', 'value': 10.450195830323363}]] </code></pre> <p>As you can see, it is several nested lists with same key, but different values, I need to combined into one nested list, something like:</p> <pre><code>[ {'node': 'node-3', 'value': [ 7.5456592756413645 , 6.761078690857657, ...]}, {'node': 'node-5', 'value': [ 6.988051860579239 , 8.749145084411227, ... ]} .... ] </code></pre>
[ { "answer_id": 74147355, "author": "Rahul K P", "author_id": 4407666, "author_profile": "https://Stackoverflow.com/users/4407666", "pm_score": 1, "selected": false, "text": "zip" }, { "answer_id": 74147447, "author": "David Moruzzi", "author_id": 20287283, "author_pro...
2022/10/20
[ "https://Stackoverflow.com/questions/74147320", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3481647/" ]
74,147,338
<pre><code>int remove_whitespace(char* string, int size) /* input parameters: the character array, size of that array */ { int i = 0, j = 0, num = 0; /* i - counter variable | j - counter variable | num - number of white spaces */ for (i; i &lt; size; i++) { if (string[i] == ' ') { for (j = i; j &lt; size - 1; j++) { string[j] = string[j + 1]; } num++; } } return num; /* returns the number of white spaces */ } </code></pre>
[ { "answer_id": 74147418, "author": "Vlad from Moscow", "author_id": 2877241, "author_profile": "https://Stackoverflow.com/users/2877241", "pm_score": -1, "selected": false, "text": "size_t remove_char( char *string, size_t size, char c );\n" }, { "answer_id": 74147656, "autho...
2022/10/20
[ "https://Stackoverflow.com/questions/74147338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20296318/" ]
74,147,378
<p>I have the following code in .net 6 and VS 2022. To hold it easy I comment the warning behind the line. I don't know how to fix this. Hope someone can help me.</p> <pre><code>try { var searcher = new ManagementObjectSearcher(&quot;SELECT * FROM Win32_ComputerSystem&quot;); using (ManagementObjectCollection managementObjectCollection = searcher.Get()) { ManagementObject? managementObject = managementObjectCollection.OfType&lt;ManagementObject&gt;().FirstOrDefault(); hardwareComputerName = managementObject[&quot;name&quot;].ToString().ToLower(); // 'managementObject' may be null here. CS8602 Dereference of a possibly null reference. (2x) hardwareComputerManufacturer = managementObject[&quot;Manufacturer&quot;].ToString(); // 'managementObject' is not null here. CS8601 Possible null reference assignment. hardwareComputerModel = managementObject[&quot;model&quot;].ToString(); // 'managementObject' is not null here. CS8601 Possible null reference assignment. } } catch (Exception) { MessageBox.Show(&quot;Problem im Abschnitt Name, Hersteller und Modell.&quot;); } </code></pre>
[ { "answer_id": 74147585, "author": "Moho", "author_id": 1464084, "author_profile": "https://Stackoverflow.com/users/1464084", "pm_score": 2, "selected": true, "text": "managementObject" }, { "answer_id": 74163618, "author": "TheQuestionmark", "author_id": 16519323, "a...
2022/10/20
[ "https://Stackoverflow.com/questions/74147378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16519323/" ]
74,147,404
<p>My flex row won't work and I don't know why. I've tried everything. I need the images to be three in a row then break and start a new row. How can I overcome this issue?</p> <pre><code> .flex-div &gt; div { display: flex; flex-direction: row; flex-wrap: wrap; align-content: space-between; } /*kitchen hacks*/ #kitchen-hacks { padding-top: 80px; } .row-one { width: 100%; } #kitchen-hacks h2 { text-align: center; margin-bottom: 15px; border: solid black; border-radius: 10px; } #kitchen-hacks p { height: auto; width: 54%; margin-top: 5px; margin-bottom: 50px; border: solid black; } &lt;div class=&quot;flex-div&quot;&gt; &lt;div id=&quot;kitchen-hacks&quot;&gt; &lt;h2 id=&quot;hacks&quot;&gt; Kitchen Hacks&lt;/h2&gt; &lt;div class=&quot;row-one&quot; style=&quot;order: 4&quot;&gt; &lt;img src=&quot;/assets/images/kitchen-hack.one.png&quot; alt=&quot;Chalk board on the inside of a shelf with mesuring cups hanong from it&quot;&gt; &lt;p&gt; Place a chalkboard and hangers on the inside of your kitchen shelf to store measuring cups the fashion way. &lt;/p&gt; &lt;/div&gt; &lt;div class=&quot;row-one&quot; style=&quot;order: 2&quot;&gt;&lt;img src=&quot;/assets/images/kitchen-hack-two.png&quot; alt=&quot;A shelf inside a shelf with plates on it&quot;&gt; &lt;p&gt; Store shelves in your shelves to optimize spacce and to better take advantage of the empty space not used. &lt;/p&gt; &lt;/div&gt; &lt;div class=&quot;row-one&quot; style=&quot;order: 3&quot;&gt;&lt;img src=&quot;/assets/images/kitchen-hack-three.png&quot; alt=&quot;Coffe pouring into an ice tray&quot;&gt; &lt;p&gt;Fill an ice tray with coffee so that you can enjoy your coffee without watering it down. &lt;/p&gt; &lt;/div&gt; &lt;div class=&quot;row-one&quot; style=&quot;order: 1&quot;&gt; &lt;img src=&quot;/assets/images/kitchen-hack-four.png&quot; alt=&quot;Spices attached to the fridge with magnets&quot;&gt; &lt;p&gt; Put magnets under your spices to make them stick to the fridge. That way you can multitask&lt;/p&gt; &lt;/div&gt; &lt;div class=&quot;row-one&quot; style=&quot;order: 5&quot;&gt;&lt;img src=&quot;/assets/images/kitchen-hack-five.png&quot; alt=&quot;Kitchen sink area&quot;&gt; &lt;p&gt; Using your sink as a temporary chopping surface frees the rest of your counter for other cooking steps. &lt;/p&gt; &lt;/div&gt; &lt;div class=&quot;row-one&quot; style=&quot;order: 6&quot;&gt;&lt;img src=&quot;/assets/images/kitchen-hack-six.png&quot; alt=&quot;An egg in a glass of water and two eggs beside the glass&quot;&gt; &lt;p&gt; Fill a tall glass of water and lower an egg in it. If it sinks to the bottom, the egg is fresh. If it floats to the top, it’s time to toss it &lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre>
[ { "answer_id": 74147585, "author": "Moho", "author_id": 1464084, "author_profile": "https://Stackoverflow.com/users/1464084", "pm_score": 2, "selected": true, "text": "managementObject" }, { "answer_id": 74163618, "author": "TheQuestionmark", "author_id": 16519323, "a...
2022/10/20
[ "https://Stackoverflow.com/questions/74147404", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20296333/" ]
74,147,409
<p>How do I search if an Excel cell contains word or words listed in a separate column, please? If a substring is present, then show what that matching substring is. If a second substring is met, then show that in the next column.</p> <p>For example</p> <p>Column A with raw data has these rows:</p> <pre><code>There is a dog A Cat is happy Cat and dog are both animals Elephant is big Happy cAt, dOg, fox, MOUSE Elephant are good Hello dogelephantMOouse Hello Hello </code></pre> <p>Column B contains has the following ordered keys (in decreasing order of importance):</p> <pre><code>Row 1: dog Row 2: cat Row 3: mouse </code></pre> <p>Desired Columns C, D, E ... are as following:</p> <p><a href="https://i.stack.imgur.com/fPnmJ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fPnmJ.jpg" alt="enter image description here" /></a></p> <p>I do not have XLOOK function. I think the functions to use may be a combination of SEARCH, MATCH, COUNTIF, VLOOK. But I do not know exactly how to write it up.</p> <p><strong>QUESTION: How do I check if a list of keywords are present as a substring/substrings in a cell, please? (columns D, E, F .. shown).</strong></p> <p>The keywords have level of important (for example dog and cat are both present in one cell (cell A4), but column B shows dog is more important; therefore cell C4 reports dog first, then D4 reports cat next; even though in cell A4 cat occurred before dog).</p> <p>Thank you</p> <p>PS: I use offline Desktop version Microsoft Excel 2019 on Windows 10 (64 bit).</p> <p>ADDENDUM:</p> <p>This is the output I would like:</p> <p>Showing the actual matched substrings down along the row to the right. First match is placed in column C, next match in column D so on.</p> <p><a href="https://i.stack.imgur.com/eJ3fK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eJ3fK.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74149727, "author": "Ike", "author_id": 16578424, "author_profile": "https://Stackoverflow.com/users/16578424", "pm_score": 2, "selected": false, "text": "=LET(keys,TRANSPOSE($B$2:$B$4),\n result,MAP(keys,LAMBDA(k,IF(ISNUMBER(SEARCH(k,A2)),k,\"\"))),\n FILTER(resul...
2022/10/20
[ "https://Stackoverflow.com/questions/74147409", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7734363/" ]
74,147,428
<p>I'm trying to use <code>purrr::pmap()</code> to map a function over columns of a data frame by name.</p> <p>However, I noticed that with <code>pmap</code>, the data frame must contain columns that match the names in the function <strong>and cannot contain other columns</strong>. For example, the first <code>pmap()</code> call below fails, but the second works, where I filter to the needed columns.</p> <p>Is there a way to have <code>pmap()</code> ignore the extra columns? Or this there a better way to do this type of thing?</p> <pre><code>library(tidyverse) # Test data set.seed(123) # for reproducibility df &lt;- tibble(a = runif(5), b = runif(5), c = runif(5), d = runif(5)) f &lt;- function(a, b, d) a+b+d </code></pre> <pre><code># Doesn't work pmap(df, f) </code></pre> <pre><code>Error in .f(a = .l[[1L]][[i]], b = .l[[2L]][[i]], c = .l[[3L]][[i]], d = .l[[4L]][[i]], : unused argument (c = .l[[3]][[i]]) </code></pre> <pre><code># This works pmap(df[c(&quot;a&quot;, &quot;b&quot;, &quot;d&quot;)], f) </code></pre>
[ { "answer_id": 74147571, "author": "Ric Villalba", "author_id": 6912817, "author_profile": "https://Stackoverflow.com/users/6912817", "pm_score": 0, "selected": false, "text": " library(tidyverse)\n\n# Test data\ndf <- tibble(a = runif(5),\n b = runif(5),\n c = ru...
2022/10/20
[ "https://Stackoverflow.com/questions/74147428", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8072983/" ]
74,147,464
<p>The following fails to compile.</p> <pre class="lang-c++ prettyprint-override"><code>template &lt;typename... U&gt; requires requires(U... x) { (std::to_string(x) &amp;&amp; ...); } auto to_string(const std::variant&lt;U...&gt;&amp; value) { return std::visit([](auto&amp;&amp; value) { return std::to_string(std::forward&lt;decltype(value)&gt;(value)); }, value); } int main() { std::variant&lt;int, float&gt; v = 42; std::cout &lt;&lt; to_string(v) &lt;&lt; std::endl; } </code></pre> <p><a href="https://godbolt.org/z/Wvn6E3PG5" rel="nofollow noreferrer">https://godbolt.org/z/Wvn6E3PG5</a></p> <p>If I convert the direct requires expression into a concept though, it works fine.</p> <pre class="lang-c++ prettyprint-override"><code>template&lt;typename T, typename... U&gt; concept to_stringable = requires(U... u) { (std::to_string(u) &amp;&amp; ...); }; template &lt;to_stringable... U&gt; auto to_string(const std::variant&lt;U...&gt;&amp; value) { return std::visit([](auto&amp;&amp; value) { return std::to_string(std::forward&lt;decltype(value)&gt;(value)); }, value); } int main() { std::variant&lt;int, float&gt; v = 42; std::cout &lt;&lt; to_string(v) &lt;&lt; std::endl; } </code></pre> <p><a href="https://godbolt.org/z/W6znbvTzo" rel="nofollow noreferrer">https://godbolt.org/z/W6znbvTzo</a></p>
[ { "answer_id": 74147567, "author": "Nicol Bolas", "author_id": 734069, "author_profile": "https://Stackoverflow.com/users/734069", "pm_score": 2, "selected": false, "text": "template<typename... U>\nconcept real_to_stringable = requires(U... u) { (std::to_string(u) && ...); };\n\ntemplat...
2022/10/21
[ "https://Stackoverflow.com/questions/74147464", "https://Stackoverflow.com", "https://Stackoverflow.com/users/897778/" ]
74,147,557
<p>I am using a bash script in an azure devops pipeline where a variable is created dynamically from one of the pipeline tasks.</p> <p>I need to use the variable's value in subsequent scripts, I can formulate the string which is used for the variable name, however cannot get the value of the variable using this string. I hope the below example makes it clear on what I need. Thanks in advance for your help.</p> <pre><code>PartAPartB=&quot;This is my text&quot; echo &quot;$PartAPartB&quot; #Shows &quot;This is my text&quot; as expected #HOW DO I GET BELOW TO PRINT &quot;This is my text&quot; #without using the PartAPartB variable and #using VarAB value to become the variable name VarAB=&quot;PartAPartB&quot; VARNAME=&quot;$VarAB&quot; echo $(&quot;$VARNAME&quot;) #INCORRECT </code></pre>
[ { "answer_id": 74147567, "author": "Nicol Bolas", "author_id": 734069, "author_profile": "https://Stackoverflow.com/users/734069", "pm_score": 2, "selected": false, "text": "template<typename... U>\nconcept real_to_stringable = requires(U... u) { (std::to_string(u) && ...); };\n\ntemplat...
2022/10/21
[ "https://Stackoverflow.com/questions/74147557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15368295/" ]
74,147,563
<p>I am currently trying to filter one column in a CSV file by multiple values. For instance, I would like all of the data in the CSV file that is related to departments 104, 105, 106, etc. I have the code below, so far which works for each department individually. However, is there something more dynamic that can utilize the departments array? I was thinking of using a for loop but my attempts have thrown me errors so far. I know that the simple solution would be to use a series of or statements, however, I need to filter by at least 10-15 departments and this seems less efficient than it could be.</p> <pre><code>import pandas as pd report = &quot;file.csv&quot; df = pd.read_csv(report, low_memory=False) departments = [104, 105, 106, 107] df = df[(df['Department'] == departments[0])] df.to_csv('file_filtered.csv') </code></pre>
[ { "answer_id": 74147580, "author": "Naveed", "author_id": 3494754, "author_profile": "https://Stackoverflow.com/users/3494754", "pm_score": 2, "selected": true, "text": "loc" }, { "answer_id": 74147695, "author": "rurgel", "author_id": 20296262, "author_profile": "htt...
2022/10/21
[ "https://Stackoverflow.com/questions/74147563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5334114/" ]
74,147,590
<p>I have seen solutions to the reverse linked lists recursively but I dont understand the head.next.next part. Can someone explain this to me. This is leetcode 206 problem.</p> <pre><code># Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def reverseList(self, head: Optional[ListNode]) -&gt; Optional[ListNode]: if not head or not head.next: return head curr = self.reverseList(head.next) head.next.next = head head.next = None return curr </code></pre> <p>When the recursive function reaches at the end and returns the last value of the list to curr, the next of curr and next of head is None right? So I feel the head.next.next should throw an error. Please explain this solution to me and why it isn't wrong.</p>
[ { "answer_id": 74147580, "author": "Naveed", "author_id": 3494754, "author_profile": "https://Stackoverflow.com/users/3494754", "pm_score": 2, "selected": true, "text": "loc" }, { "answer_id": 74147695, "author": "rurgel", "author_id": 20296262, "author_profile": "htt...
2022/10/21
[ "https://Stackoverflow.com/questions/74147590", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19373251/" ]
74,147,593
<p>I am trying to add some constant values to a data frame.</p> <p>I have successfully done multiplication, but now addition does not work.</p> <p><strong>This works:</strong></p> <pre><code>df_C2H_TT_y1['DURATION_H'] = df_C2H_TT_y1['DURATION_H'] * 0.95 </code></pre> <p><strong>This does not work:</strong></p> <pre><code>TT_Base = pd.DataFrame() TT_Base[&quot;TT&quot;] = (0.05 + A2C_TT_x2['DURATION_H']) + 0.25 + df_C2H_TT_y1['DURATION_H'] + 0.58333333333333333333333333333333) TT_Base </code></pre> <p>Output:</p> <pre><code>5 NaN 10 NaN 23 NaN 31 NaN 44 NaN .. 637842 NaN 638152 NaN 638153 NaN 638199 NaN 638365 NaN Name: Yes, Length: 32819, dtype: float64 </code></pre> <p><strong>What is wrong here?</strong></p>
[ { "answer_id": 74147684, "author": "spramuditha", "author_id": 18809515, "author_profile": "https://Stackoverflow.com/users/18809515", "pm_score": 0, "selected": false, "text": "A2C_TT_x2['DURATION_H']" }, { "answer_id": 74147832, "author": "Oceans", "author_id": 20184312...
2022/10/21
[ "https://Stackoverflow.com/questions/74147593", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13373167/" ]
74,147,599
<p>I have a system that writes its log into the Postgres database. And I want to analyse data after a specific event to tell how this system works.</p> <p>So <code>status 9</code>, in my case, acts like a trigger. After the trigger I need to go through the statuses within the <code>counter</code> interval. <code>Interval</code> equals <code>50</code>:</p> <pre><code>counter &gt; trigger_counter AND counter &lt;= trigger_counter + 50 </code></pre> <p>Having <code>values &lt;= 9</code> within the interval means <code>FAIL</code>. And <code>PASS</code> if there are <code>no such values</code></p> <p>For a better understanding, here is a part of my database:</p> <pre><code> date_time | status | counter ----------------------------+--------+--------- ... 2022-08-11 02:34:55.005362 | 9 | 10450 --| interval = 50 2022-08-11 02:36:15.034973 | 650 | 10452 | 2022-08-11 02:36:23.478429 | 8 | 10459 | value &lt;= 9 -&gt; FAIL 2022-08-11 02:36:25.594843 | 600 | 10461 --| 2022-08-11 02:42:38.348111 | 650 | 10580 ... 2022-08-11 05:15:56.151411 | 9 | 3419 --| 2022-08-11 05:16:34.072692 | 325 | 3419 | 2022-08-11 05:16:38.304485 | 692 | 3456 --| all values &gt; 9 -&gt; PASS 2022-08-11 05:17:50.266063 | 692 | 3676 ... 2022-08-13 13:28:28.400286 | 9 | 13175 --| 2022-08-13 13:34:53.718093 | 325 | 13175 | 2022-08-13 13:36:49.562367 | 692 | 13199 | 2022-08-13 13:36:51.679191 | 9 | 13199 | FAIL --| 2022-08-13 13:37:27.490148 | 650 | 13200 --| | 2022-08-13 14:12:35.345867 | 650 | 13247 ------------| PASS 2022-08-13 14:22:18.601711 | 650 | 13356 ... </code></pre> <p>Result should look like this:</p> <pre><code> date_time | result ----------------------------+-------- 2022-08-11 02:34:55.005362 | FAIL 2022-08-11 05:15:56.151411 | PASS 2022-08-13 13:28:28.400286 | FAIL 2022-08-13 13:36:51.679191 | PASS </code></pre> <p>I can imagine how to do this using for/while loops in C++ or Python. But is it possible to get this result in PostgreSQL?</p>
[ { "answer_id": 74147684, "author": "spramuditha", "author_id": 18809515, "author_profile": "https://Stackoverflow.com/users/18809515", "pm_score": 0, "selected": false, "text": "A2C_TT_x2['DURATION_H']" }, { "answer_id": 74147832, "author": "Oceans", "author_id": 20184312...
2022/10/21
[ "https://Stackoverflow.com/questions/74147599", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13776426/" ]
74,147,612
<p>I'm trying to borrow a hashset inside of a closure of type <code>Filter</code> from the inquire crate Basically, I want to prevent users from selecting the same option more than once Here's my code</p> <pre class="lang-rs prettyprint-override"><code>pub fn getRotors() -&gt; () { let mut selectedrotors: HashSet&lt;Rotors&gt; = HashSet::new(); let options: Vec&lt;Rotors&gt; = Rotors::iter().collect(); let filter: Filter&lt;Rotors&gt; = &amp;|_, cur_option, _, _| match selectedrotors.contains(cur_option) { // Borrow occurs here true =&gt; false, false =&gt; true, }; for i in 0..3 { // Get Rotor from user let r: Rotors = Select::new(&quot;Select a rotor&quot;, options.to_vec()) .with_filter(filter) .prompt() .unwrap(); selectedrotors.insert(r); // immutable borrow occurs here e0502 // Get char from user } () } </code></pre> <p>I would expect that selectedrotors.contains to only require immutable access to itself so i'm at a loss here</p>
[ { "answer_id": 74149553, "author": "Jmb", "author_id": 5397009, "author_profile": "https://Stackoverflow.com/users/5397009", "pm_score": 2, "selected": true, "text": "selectedrotors" }, { "answer_id": 74155060, "author": "Boss Man", "author_id": 818006, "author_profil...
2022/10/21
[ "https://Stackoverflow.com/questions/74147612", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11438666/" ]
74,147,625
<p>I have done some searching on this and everyone is telling how to set a rounded border. But in my case I have a background color for my text boxes that is different from the background of the app screen, that is what I am trying to round, the background color border.</p> <p>Desired Look: <a href="https://i.stack.imgur.com/dHDeX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dHDeX.png" alt="enter image description here" /></a></p> <p>What it looks like now: <a href="https://i.stack.imgur.com/yNC3y.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yNC3y.jpg" alt="enter image description here" /></a></p> <p>from main.dart ThemData...</p> <pre><code>theme: ThemeData( // This is the theme of your application. // // Try running your application with &quot;flutter run&quot;. You'll see the // application has a blue toolbar. Then, without quitting the app, try // changing the primarySwatch below to Colors.green and then invoke // &quot;hot reload&quot; (press &quot;r&quot; in the console where you ran &quot;flutter run&quot;, // or simply save your changes to &quot;hot reload&quot; in a Flutter IDE). // Notice that the counter didn't reset back to zero; the application // is not restarted. primaryColor: Color(0xFF623CEA), fontFamily: 'Manrope', inputDecorationTheme: InputDecorationTheme( focusedBorder: UnderlineInputBorder( borderSide: BorderSide(color: Colors.black) ), border: OutlineInputBorder( borderRadius: BorderRadius.circular(15.0), ), // border: InputBorder.none, labelStyle: TextStyle(color: Colors.black45), iconColor: Colors.grey, ) ), </code></pre>
[ { "answer_id": 74147852, "author": "Chance", "author_id": 5307235, "author_profile": "https://Stackoverflow.com/users/5307235", "pm_score": 0, "selected": false, "text": "Scaffold(\n appBar: AppBar(\n title: const Text('Demo'),\n ),\n backgroundColor: Colors.white,\n body: Theme(\...
2022/10/21
[ "https://Stackoverflow.com/questions/74147625", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18246750/" ]
74,147,639
<p>I am trying to find the postions of the cells which have &quot;Pi&quot;.</p> <p>My dataframe is as follows. As you can see, the cells with &quot;Pi&quot; are in <code>0,2</code>, <code>1,1</code>, <code>1,3</code> in format <code>column,row</code>.</p> <pre><code> Pi Column_B 0 F Kitten 1 L Pippy 2 Pi Lamb 3 K Pikjh 4 K Momo </code></pre> <p>Therefore, the output that I want is <code>[(0,2),(1,1),(1,3)]</code>. My code is as follows.</p> <pre><code>import pandas as pd # My dataframe data = {'Column_A':['F','L','K','K','K'], 'Column_B':['Kitten','Pippy','Lamb','Pikjh','Momo']} df = pd.DataFrame(data) # Search for the cell which includes &quot;Pi&quot; search_for_Pi = df.apply(lambda row: row.astype(str).str.contains('Pi').any(), axis=1) Found_Pi_Position = pd.DataFrame(search_for_Pi) # Print the position of the cells which include &quot;Pi&quot; Print_Pi_Position = list(Found_Pi_Position[Found_Pi_Position == True].index) print(Print_Pi_Position) </code></pre> <p>However, I got the output <code>[0, 1, 2, 3, 4]</code>. Please help me finding the error.</p>
[ { "answer_id": 74147852, "author": "Chance", "author_id": 5307235, "author_profile": "https://Stackoverflow.com/users/5307235", "pm_score": 0, "selected": false, "text": "Scaffold(\n appBar: AppBar(\n title: const Text('Demo'),\n ),\n backgroundColor: Colors.white,\n body: Theme(\...
2022/10/21
[ "https://Stackoverflow.com/questions/74147639", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16277415/" ]
74,147,692
<p>I am attempting to create a data summary table that has three columns. One of which shows the attribute's name, one of which shows the most frequently occurring attribute-value, and the other shows the count of that most frequently occurring value.</p> <p>I have the following data:</p> <pre><code>data = {&quot;Sex&quot;:[&quot;M&quot;, &quot;M&quot;, &quot;F&quot;, &quot;F&quot;, &quot;F&quot;, &quot;F&quot;, &quot;M&quot;, &quot;F&quot;, &quot;F&quot;, &quot;M&quot;], &quot;Product&quot;: [&quot;X&quot;, &quot;Y&quot;, &quot;Y&quot;, &quot;Z&quot;,&quot;Y&quot;, &quot;Y&quot;, &quot;Y&quot;, &quot;X&quot;, &quot;Z&quot;, &quot;Y&quot;], &quot;Answer&quot;:[&quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;No&quot;, &quot;No&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;No&quot;, &quot;Yes&quot;, &quot;Yes&quot;]} df = pd.DataFrame(data) </code></pre> <p>I then do the following:</p> <pre><code>stat = dict([(column, []) for column in df if df[column].dtype == object]) for column in df: stat[column] = df[column].value_counts()[ df[column].value_counts() == df[column].value_counts().max()] print(stat) </code></pre> <p>I get the following output</p> <pre><code>{'Sex': F 6 Name: Sex, dtype: int64, 'Product': Y 6 Name: Product, dtype: int64, 'Answer': Yes 7 Name: Answer, dtype: int64} </code></pre> <p>How can I create a table that looks something like this?</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Attribute</th> <th>Most Frequently Occurring Value</th> <th>Count</th> </tr> </thead> <tbody> <tr> <td>Sex</td> <td>F</td> <td>6</td> </tr> <tr> <td>Product</td> <td>Y</td> <td>6</td> </tr> <tr> <td>Answer</td> <td>Yes</td> <td>7</td> </tr> </tbody> </table> </div> <p>Could I do it using a library like <code>tabulate</code> or <code>plotly</code>?</p>
[ { "answer_id": 74147815, "author": "INGl0R1AM0R1", "author_id": 12845199, "author_profile": "https://Stackoverflow.com/users/12845199", "pm_score": 0, "selected": false, "text": "df2 = df.groupby(level=0,axis=1).apply(lambda x : x.value_counts()[0])\n" }, { "answer_id": 74147816,...
2022/10/21
[ "https://Stackoverflow.com/questions/74147692", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18937753/" ]
74,147,705
<p>I am making an application that automatically enters a number when a photo is selected using UIKit and Swift.</p> <p><a href="https://i.stack.imgur.com/TO6TB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TO6TB.png" alt="enter image description here" /></a></p> <p>The picture above is the most perfect situation and result.</p> <p>The problem arises in a situation like the picture below.</p> <p><a href="https://i.stack.imgur.com/32M9m.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/32M9m.png" alt="enter image description here" /></a></p> <p>The problem arises when working with photos of different resolutions. The text is large in some photos and small in others.</p> <p><a href="https://i.stack.imgur.com/bxOz8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bxOz8.png" alt="enter image description here" /></a></p> <p>The problem I was thinking of is that the font size seems to be different when giving pictures with different resolutions because the font size is given as a fixed value.</p> <pre><code>// add text in photo func textToImage(drawText text: String, inImage image: UIImage, fontSize: CGFloat, atPoint point: CGPoint) -&gt; UIImage { let textStrokeWidth: Double = -4.0 let textStrokeColor: UIColor = UIColor.black let textFillColor: UIColor = UIColor.white let textFont = UIFont(name: &quot;Helvetica Bold&quot;, size: fontSize)! UIGraphicsBeginImageContextWithOptions(image.size, false, 1) let textFontAttributes = [ NSAttributedString.Key.strokeColor: textStrokeColor, NSAttributedString.Key.strokeWidth : textStrokeWidth, NSAttributedString.Key.font: textFont, NSAttributedString.Key.foregroundColor: textFillColor, ] as [NSAttributedString.Key : Any] image.draw(in: CGRect(origin: CGPoint.zero, size: image.size)) let rect = CGRect(origin: point, size: image.size) text.draw(in: rect, withAttributes: textFontAttributes) let newImage = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext() return newImage! } </code></pre> <p><a href="https://stackoverflow.com/questions/28906914/how-do-i-add-text-to-an-image-in-ios-swift">Source of code used</a></p> <p>I modified the code from the above source slightly and tried it. And to solve the scale problem, I am trying ways to calculate the fontsize, but the solution is taking too long than I thought, so I leave a question.</p> <pre><code>let scaleFactor: Float = Float(imageWidth) / 1500.0 let fontSize = CGFloat(150.0 * scaleFactor) </code></pre> <p>The calculation method I tried is as follows. When there is a picture with a width of 1500, font size 150 is the best, and the scale factor is calculated based on that.</p> <p>However, as you can see, it is impossible to cope with all resolutions because only horizontal is used.</p> <p><a href="https://i.stack.imgur.com/20mlK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/20mlK.png" alt="enter image description here" /></a></p> <p>How can I find the scale factor that corresponds to all resolutions and calculate the font size of the same ratio even if different photos are input?</p> <p>You don't necessarily have to create text this way. I would like to know more about how to solve this problem.</p>
[ { "answer_id": 74148859, "author": "abi", "author_id": 1884707, "author_profile": "https://Stackoverflow.com/users/1884707", "pm_score": 0, "selected": false, "text": "let fontSize = (image.size.width/image.size.height) * 50\n" }, { "answer_id": 74164377, "author": "DonMag", ...
2022/10/21
[ "https://Stackoverflow.com/questions/74147705", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14964159/" ]
74,147,781
<p>move data from column2 to column1, if column1 is empty</p> <p>In id 2 and 4 Phone1 is empty so transfer data from phone2 to phone1 <strong>df</strong></p> <pre><code>id Phone1 Phone2 0 9073370404 1 9072765522 1234567890 2 9075611434 3 9073370404 4 9072765522 5 9075611434 </code></pre> <pre><code>id Phone1 Phone2 0 9073370404 1 9072765522 1234567890 2 9075611434 3 9073370404 4 9072765522 5 9075611434 </code></pre>
[ { "answer_id": 74147953, "author": "Lowin Li", "author_id": 19560513, "author_profile": "https://Stackoverflow.com/users/19560513", "pm_score": 2, "selected": false, "text": "import pandas as pd\nimport numpy as np\ndf = pd.DataFrame({\n\"Phone1\":[9073370404, 9072765522, None, 907337040...
2022/10/21
[ "https://Stackoverflow.com/questions/74147781", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18604759/" ]
74,147,782
<p>I'm trying to use multiprocessing to speed up some data labeling that I'm doing, but have noticed that it takes much longer (I actually never saw the program terminate). The original script takes about 7 hours to run, but this morning I came to work and noticed it was still running after I had let it run yesterday evening.</p> <h2>Task Overview</h2> <pre><code>Input: 1) Pandas DataFrame with a column of text 2) Dictionary that looks like {word: label}. (Desired) Output: Same DataFrame but this time with the positions of the words marked in the text. Example: DataFrame: ---------------------------------------------------- | text 0 | I live in the United States. ---------------------------------------------------- Dict: {'United States': 'country'} Output DataFrame: ---------------------------------------------------- | text | labels 0 | I live in the United States. | [14, 26] ---------------------------------------------------- </code></pre> <p>To explain the outcome a bit, the substring <code>'United States'</code> is at position 14-26 within the text. I'm basically iterating over the DataFrame, further iterating over the dictionary, and then marking the positions using regular expressions.</p> <h2>What I Did</h2> <pre><code>&lt;Original Code&gt; def label_data(df, dict): pbar = tqdm(iterable=df.to_dict('records'), total=df.shape[0]) for idx, row in enumerate(pbar): text = row['text'] spans = [] for word, label in label_dict.items(): for match in re.finditer(word, text): start = match.start() end = match.end() spans.append([start, end]) row['labels'] = spans df.iloc[idx] = row return df &lt;Parallelized Code&gt; from itertools import product import multiprocessing as mp import numpy as np def label_data_parallel(df, dict): num_cores = mp.cpu_count() - 1 pool = mp.Pool(num_cores) df_chunks = np.array_split(df, num_cores) labeled_dfs = pool.starmap(label_data, \ product(df_chunks, [dict] * num_cores)) df = pd.concat(labeled_dfs, axis=0) pool.close() pool.join() return df </code></pre> <p>Is there anything wrong with my code? Also, the DataFrame has around 200,000 rows and the dictionary has about 3,000 key-value pairs.</p>
[ { "answer_id": 74147953, "author": "Lowin Li", "author_id": 19560513, "author_profile": "https://Stackoverflow.com/users/19560513", "pm_score": 2, "selected": false, "text": "import pandas as pd\nimport numpy as np\ndf = pd.DataFrame({\n\"Phone1\":[9073370404, 9072765522, None, 907337040...
2022/10/21
[ "https://Stackoverflow.com/questions/74147782", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7766024/" ]
74,147,790
<p>Someone wanted me to convert his bash code into powershell. I thought I could do it until I came across a weird built in variable called <code>$NF</code> which I think reads the lines of the logger? I am not sure how it works but because of it, it stops me from converting this bash script into powershell.</p> <p>The specific two lines I am having a hard time with: bash script</p> <pre><code>curl -c ./cookie -s -L &quot;https://drive.google.com/uc?export=download&amp;id=${fileid}&quot; &gt; /dev/null curl -Lb ./cookie &quot;https://drive.google.com/uc?export=download&amp;confirm=`awk '/download/ {print $NF}' ./cookie`&amp;id=${fileid}&quot; &gt; ${filename} </code></pre> <p>but I am not sure what to write for <code>$NF</code> in powershell. The other variables, I know how to convert, just not this built in $NF variable to download the item from google drive.</p>
[ { "answer_id": 74147946, "author": "Start-Automating", "author_id": 221631, "author_profile": "https://Stackoverflow.com/users/221631", "pm_score": 2, "selected": false, "text": "# Assigning this to a variable for readability\n$curlArg = \"https://drive.google.com/uc?export=download&conf...
2022/10/21
[ "https://Stackoverflow.com/questions/74147790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18192997/" ]
74,147,866
<p>I would like to send callbacks with different signatures for the same function. Somenthing like this:</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdarg.h&gt; void a(int pa) {} void b(int pb1, float pb2) {} // exec implementation int main() { exec(a, 1); exec(b, 1, 2.3); } </code></pre> <p>I thought of using something like:</p> <pre><code>void exec(void (*func)(...), ...) { int arg1; float arg2; va_list valist; va_start(valist, size); arg1 = va_arg(valist, int); if (size == 1) { (*func)(arg1); va_end(valist); return; } arg2 = va_arg(valist, float); if (size == 2) { (*func)(arg1, arg2); va_end(valist); return; } } </code></pre> <p>But obviously it doesn't work :(</p>
[ { "answer_id": 74148060, "author": "dbush", "author_id": 1687119, "author_profile": "https://Stackoverflow.com/users/1687119", "pm_score": 1, "selected": false, "text": "void a(va_list args) \n{\n int pa = va_arg(args,int);\n}\n\nvoid b(va_list args)\n{\n int pb1 = va_arg(args,int)...
2022/10/21
[ "https://Stackoverflow.com/questions/74147866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19093920/" ]
74,147,873
<p>I know how to generate a daterange using this code:</p> <p><code>pd.date_range(start='2022-10-16', end='2022-10-19')</code></p> <p>How do I get the daterange result above and loop through every locations in the below dataframe?</p> <pre><code>+----------+ | Location | +----------+ | A | | B | | C | +----------+ </code></pre> <p>This is the result I want.</p> <pre><code>+----------+------------+ | Location | Date | +----------+------------+ | A | 2022/10/16 | | A | 2022/10/17 | | A | 2022/10/18 | | A | 2022/10/19 | | B | 2022/10/16 | | B | 2022/10/17 | | B | 2022/10/18 | | B | 2022/10/19 | | C | 2022/10/16 | | C | 2022/10/17 | | C | 2022/10/18 | | C | 2022/10/19 | +----------+------------+ </code></pre> <p>I have spent the whole day figuring this out. Any help would be appreciated!</p>
[ { "answer_id": 74147923, "author": "BorrajaX", "author_id": 289011, "author_profile": "https://Stackoverflow.com/users/289011", "pm_score": 2, "selected": true, "text": "import pandas as pd\nfrom itertools import product\n\n# Test data:\ndf = pd.DataFrame(['A', 'B', 'C'], columns=['Locat...
2022/10/21
[ "https://Stackoverflow.com/questions/74147873", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4086715/" ]
74,147,901
<p>Is there any way to calculate the diff between two times without a full date time and not get the wrong answer if the time goes passed midnight? The line below could go from 23:00 - 03:20 which should be 4 hours and 20 minutes. but when I use DATEDIFF without dates in front of the times it always gives me 19 hours and 40 minutes. I've tried to change the order of the time and that doesn't help. I really don't have an option for dates in this one. Any help would be greatly appreciated.</p> <p><code>DATEDIFF(MINUTE, MT.MilTime , MT1.MilTime) AS TotalRun, </code></p>
[ { "answer_id": 74148668, "author": "John Conner", "author_id": 19842211, "author_profile": "https://Stackoverflow.com/users/19842211", "pm_score": 2, "selected": true, "text": "DECLARE @Date1 time = '23:00:00.000';\nDECLARE @Date2 time = '03:20:00.000';\n\nSELECT DATEDIFF(MINUTE,@Date1,@...
2022/10/21
[ "https://Stackoverflow.com/questions/74147901", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3837270/" ]
74,147,908
<p>How can I set the original Python IDLE colors in Visual Studio Code? This could be a very useful question for readers. I read that you need to edit the Json file, but I don't know what to write to it. I would use <a href="https://www.google.com/url?sa=i&amp;url=https%3A%2F%2Fwww.tes.com%2Fteaching-resource%2Fpython-idle-colour-codes-11509268&amp;psig=AOvVaw0qfHlStN46mUSJrw7bxcSP&amp;ust=1666402460615000&amp;source=images&amp;cd=vfe&amp;ved=2ahUKEwjzxYGHl_D6AhVrX_EDHUKpBlAQjRx6BAgAEAw" rel="nofollow noreferrer">this</a> with <strong>white</strong> background theme:</p> <pre><code>Variables &amp; Data: #000000 Strings: #00aa00 Functions (for example len(), list(), print()): #900090 User functions (name functions): #0000ff Command (for example def, if, for, else): #ff7700 Comments: #ff0000 False, True, for, in, global, return(function): #ff7700 Error messages: #ff0000 Output console: #0000ff </code></pre> <p>How can I write in <code>setting.json</code> to get these colors? I don't know how to call function, variable, print, numbers, commands, comment, etc. etc.</p> <p>Thank you</p>
[ { "answer_id": 74148668, "author": "John Conner", "author_id": 19842211, "author_profile": "https://Stackoverflow.com/users/19842211", "pm_score": 2, "selected": true, "text": "DECLARE @Date1 time = '23:00:00.000';\nDECLARE @Date2 time = '03:20:00.000';\n\nSELECT DATEDIFF(MINUTE,@Date1,@...
2022/10/21
[ "https://Stackoverflow.com/questions/74147908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20296788/" ]
74,147,920
<p>I am using dynamic import in next js. The component is rendered when I directly use the path. But it is not rendering when I use the path from a variable.</p> <pre><code>const faq = dynamic(() =&gt; import('../faq/faq')) </code></pre> <p>This works fine. but,</p> <pre><code>const path = '../faq/faq'; const faq = dynamic(() =&gt; import(path )) </code></pre> <p>This is not working. How can I fix this?</p>
[ { "answer_id": 74148668, "author": "John Conner", "author_id": 19842211, "author_profile": "https://Stackoverflow.com/users/19842211", "pm_score": 2, "selected": true, "text": "DECLARE @Date1 time = '23:00:00.000';\nDECLARE @Date2 time = '03:20:00.000';\n\nSELECT DATEDIFF(MINUTE,@Date1,@...
2022/10/21
[ "https://Stackoverflow.com/questions/74147920", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3751731/" ]
74,147,949
<pre><code>grade = float(input(&quot;Input: &quot;)) if grade &lt;= 60 or grade &gt; 100: print (&quot;Invalid Grade&quot;) elif grade &gt; 60 and grade &lt;= 74.9: print (&quot;failing grade&quot;) else: print (&quot;Passed!&quot;) </code></pre>
[ { "answer_id": 74147990, "author": "spramuditha", "author_id": 18809515, "author_profile": "https://Stackoverflow.com/users/18809515", "pm_score": 1, "selected": false, "text": "grade = float(input(\"Input: \"))\ns = \"Invalid Grade\" if grade <= 60 or grade > 100 else (\"failing grade\"...
2022/10/21
[ "https://Stackoverflow.com/questions/74147949", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20132700/" ]
74,147,955
<p>Hello everyone after last time I decided to refactor my code and my question. I am running a React app on localhost 3000 and a node server on port 8000. And for some reason when I try to make request to port 8000 It always hits port 3000 which can be seen on dev tools request headers like - Request URL: http://localhost:3000/. Here is what my simple node app looks like -</p> <pre><code>import dotenv from 'dotenv'; import express from 'express'; import morgan from 'morgan'; import cors from 'cors'; // APP const app = express(); // CORS app.use(cors()); // LOG EVRY REQ app.use(morgan('dev')); app.get('/', (req, res) =&gt; { res.json({ key: 'success' }); }); // CONFIG dotenv.config({ path: './config.env' }); const port = 8000; // STARTING APP app.listen(port, () =&gt; { console.log('Server listening the port 127.0.0.1:' + port + '/'); }); </code></pre> <p>And in react I set proxy property to http://localhost:8000</p> <p>How can I set up node and react in my localhost?</p> <p>You can see all the code in my GitHub - <a href="https://github.com/SalehBal/NodeToDo" rel="nofollow noreferrer">https://github.com/SalehBal/NodeToDo</a></p>
[ { "answer_id": 74148053, "author": "Bikas Lin", "author_id": 17582798, "author_profile": "https://Stackoverflow.com/users/17582798", "pm_score": -1, "selected": false, "text": "/frontend/src/utils/callApi.js" }, { "answer_id": 74148157, "author": "Wyck", "author_id": 1563...
2022/10/21
[ "https://Stackoverflow.com/questions/74147955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17415397/" ]
74,147,965
<div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Confianza</th> </tr> </thead> <tbody> <tr> <td>2.0</td> </tr> <tr> <td>4.0</td> </tr> <tr> <td>7.0</td> </tr> <tr> <td>NaN</td> </tr> </tbody> </table> </div> <p>Expected Output:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Confianza</th> </tr> </thead> <tbody> <tr> <td>Baja</td> </tr> <tr> <td>Media</td> </tr> <tr> <td>Alta</td> </tr> <tr> <td>NaN</td> </tr> </tbody> </table> </div> <p>In a pandas DataFrame, I want to apply this function for a column but skip NaN</p> <pre><code>def condiciones(df5): if ( df5['Confianza'] &gt; 4 ): return &quot;Alta&quot; elif (df5['Confianza'] == 4 ): return &quot;Media&quot; else: return &quot;Baja&quot; df5['Confianza']= df5.apply(condiciones, axis= 1) </code></pre> <p>The actual problem is I dont want to drop NaN rows, I tried this but returns error when apply <em>&quot;The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().&quot;</em></p> <pre><code>elif ( df5['Confianza'] != notnull): return NaN </code></pre>
[ { "answer_id": 74147991, "author": "Lowin Li", "author_id": 19560513, "author_profile": "https://Stackoverflow.com/users/19560513", "pm_score": 3, "selected": true, "text": "import numpy as np\nimport pandas as pd\ndf = pd.DataFrame({\"Confianza\": [2.0, 4.0, 7.0, None]})\n\ndef condicio...
2022/10/21
[ "https://Stackoverflow.com/questions/74147965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18015983/" ]
74,147,976
<p>Everything works as it should until the navbar collapses. After collapse the links disappear. I've gone over the Bootstrap examples and documentation, but can't see where my issue is.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"&gt; &lt;nav class="navbar navbar-expand-lg sticky-top bg-dark navbar-dark py-1"&gt; &lt;div class="container"&gt; &lt;a class="py-2 navbar-brand" href="#"&gt; &lt;svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" class="d-block mx-auto" role="img" viewBox="0 0 24 24" focusable="false"&gt;&lt;title&gt;Product&lt;/title&gt;&lt;circle cx="12" cy="12" r="10"&gt;&lt;/circle&gt;&lt;path d="M14.31 8l5.74 9.94M9.69 8h11.48M7.38 12l5.74-9.94M9.69 16L3.95 6.06M14.31 16H2.83m13.79-4l-5.74 9.94"&gt;&lt;/path&gt;&lt;/svg&gt; &lt;/a&gt; &lt;button class="navbar-toggler ml-auto" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"&gt; &lt;span class="navbar-toggler-icon"&gt;&lt;/span&gt; &lt;/button&gt; &lt;div class="collapse navbar-collapse" id="navbarSupportedContent"&gt; &lt;ul class="navbar-nav ml-auto"&gt; &lt;li class="nav-item active"&gt; &lt;a class="py-2 d-none d-md-inline-block" href="#"&gt;Tour&lt;/a&gt; &lt;/li&gt; &lt;li class="nav-item"&gt; &lt;a class="py-2 d-none d-md-inline-block" href="#"&gt;Product&lt;/a&gt; &lt;/li&gt; &lt;li class="nav-item"&gt; &lt;a class="py-2 d-none d-md-inline-block" href="#"&gt;Features&lt;/a&gt; &lt;/li&gt; &lt;li class="nav-item"&gt; &lt;a class="py-2 d-none d-md-inline-block" href="#"&gt;Enterprise&lt;/a&gt; &lt;/li&gt; &lt;li class="nav-item"&gt; &lt;a class="py-2 d-none d-md-inline-block" href="#"&gt;Support&lt;/a&gt; &lt;/li&gt; &lt;li class="nav-item"&gt; &lt;a class="py-2 d-none d-md-inline-block" href="{% url 'logout' %}"&gt;Logout&lt;/a&gt; &lt;/li&gt; &lt;li class="nav-item"&gt; &lt;a class="py-2 d-none d-md-inline-block" href="{% url 'dashboard' %}"&gt;Dashboard&lt;/a&gt; &lt;/li&gt; &lt;li class="nav-item"&gt; &lt;a class="py-2 d-none d-md-inline-block" href="{% url 'login' %}"&gt;Login&lt;/a&gt; &lt;/li&gt; &lt;li class="nav-item"&gt; &lt;a class="py-2 d-none d-md-inline-block" href="{% url 'landingpage:register' %}"&gt;Sign Up&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; &lt;/nav&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74147991, "author": "Lowin Li", "author_id": 19560513, "author_profile": "https://Stackoverflow.com/users/19560513", "pm_score": 3, "selected": true, "text": "import numpy as np\nimport pandas as pd\ndf = pd.DataFrame({\"Confianza\": [2.0, 4.0, 7.0, None]})\n\ndef condicio...
2022/10/21
[ "https://Stackoverflow.com/questions/74147976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13223820/" ]
74,147,989
<p>I am trying to migrate history for a repo with large files (&gt;100mb) into GitHub with the following command :</p> <pre><code>git lfs migrate import --include=&quot;*.gif&quot; git push origin master --force </code></pre> <p>Uploading LFS objects is successful. I get the following error:</p> <blockquote> <p>remote: fatal: pack exceeds maximum allowed size (2.00 GiB) error: remote unpack failed: index-pack abnormal exit</p> </blockquote> <p>I tried to do pushes in chunks with <code>git push origin &lt;commit&gt;:refs/heads/master -f</code>. But one of the files seems to be in the history which was deleted in a later commit.</p> <blockquote> <p>remote: error: File /World/Maps/map_4.fbx is 337.34 MB; this exceeds GitHub's file size limit of 100.00 MB</p> </blockquote> <p>This file is not getting tracked under: <code>git lfs ls-files</code></p> <p>I have already tried to manually add a line to the <em>.gitattributes</em>. Is there a way to successfully recognise this file or ignore it during push altogether?</p>
[ { "answer_id": 74149609, "author": "Ivan Yuzafatau", "author_id": 1889110, "author_profile": "https://Stackoverflow.com/users/1889110", "pm_score": 1, "selected": false, "text": "git lfs track \"*.fbx\"\n" }, { "answer_id": 74168775, "author": "NotAProgrammer", "author_id...
2022/10/21
[ "https://Stackoverflow.com/questions/74147989", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20160925/" ]
74,147,994
<p>Hi I was trying to extract only the no's from a columns in my df with this code:</p> <pre><code>(df['hello']=='No') </code></pre> <p>But it changes the values from the df and put it like a boolean values, I just want to value_count in that column the No's, but I'm not sure what I'm doing wrong.</p> <p><a href="https://i.stack.imgur.com/XTUYJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XTUYJ.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74148017, "author": "Ligon Liu", "author_id": 1218934, "author_profile": "https://Stackoverflow.com/users/1218934", "pm_score": 1, "selected": false, "text": "df" }, { "answer_id": 74148033, "author": "BENY", "author_id": 7964527, "author_profile": "htt...
2022/10/21
[ "https://Stackoverflow.com/questions/74147994", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16239103/" ]
74,148,008
<p>Using this regular expression, I'm finding a string of numbers starting with 9, followed by 4 or 5 or 6 or 7 or 9, followed by 6 more numbers.</p> <pre><code>9*[45679]( *[0-9]){6} </code></pre> <p>I have a file named content.txt containing 3 columns. The first column is a date, the second a time and the third contains random text and numbers with spaces in it.</p> <pre><code>20/10/2022 19:00 test 1 99 435 18 1 more text 20/10/2022 20:00 test 2 97 123 1 81 more text2 20/10/2022 21:00 test 3 96 4 3 5567 more text3 20/10/2022 22:00 test 4 99 43 5181 more text4 </code></pre> <p>Using my regular expression I want to modify the third column and leave only the results of the regular expression, with no spaces, so the result should be</p> <pre><code>20/10/2022 19:00 99435181 20/10/2022 20:00 97123181 20/10/2022 21:00 96435567 20/10/2022 22:00 99435181 </code></pre> <p>the field separator is a space</p>
[ { "answer_id": 74148118, "author": "jared_mamrot", "author_id": 12957340, "author_profile": "https://Stackoverflow.com/users/12957340", "pm_score": 2, "selected": false, "text": "gensub()" }, { "answer_id": 74148120, "author": "Cyrus", "author_id": 3776858, "author_pr...
2022/10/21
[ "https://Stackoverflow.com/questions/74148008", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5304093/" ]
74,148,012
<p>I am trying to run a query that finds the places near my location, but every time I try to run it, it returns the following error:</p> <blockquote> <p>column &quot;distance&quot; does not exist</p> </blockquote> <p>If I remove distance and only leave up to the <code>FROM posts</code>, it returns the post id and the distance column.</p> <p>But if I leave it in the original way, it returns the error.</p> <pre><code>SELECT id, ( 3959 * acos( cos( radians(-32.63) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(-71.42) ) + sin( radians(-32.63) ) * sin( radians( latitude ) ) ) ) AS distance FROM posts HAVING distance &lt; 25 ORDER BY distance; </code></pre>
[ { "answer_id": 74148069, "author": "Ken White", "author_id": 62576, "author_profile": "https://Stackoverflow.com/users/62576", "pm_score": 3, "selected": true, "text": "SELECT id, distance FROM \n (SELECT id, ( 3959 * acos( cos( radians(-32.63) ) * cos( radians( latitude ) ) * \n cos(...
2022/10/21
[ "https://Stackoverflow.com/questions/74148012", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5106952/" ]
74,148,024
<p>I have a form that has all text elements. How come when I use this change handler function and set the state using the change event listener, it logs what the state was before the change?</p> <pre class="lang-js prettyprint-override"><code>const handleChange = event =&gt; { const { name, value } = event.target setSomeState(prevDateInputs =&gt; ({ ...prevStateInputs, [name]: value, })) console.log(someState) // ← this logs the value of the state before it was changed } </code></pre>
[ { "answer_id": 74148628, "author": "shawn caza", "author_id": 1586014, "author_profile": "https://Stackoverflow.com/users/1586014", "pm_score": 0, "selected": false, "text": "import {useRef} from 'react';\n\nconst App = () => {\n const inputRef = useRef(null);\n\n function handleChange...
2022/10/21
[ "https://Stackoverflow.com/questions/74148024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15267476/" ]
74,148,086
<p>Essentially I have what I call floating rows that come into my table. These are rows that have a <code>type = mod</code> and they are associated with a <code>customer_id</code>, but not another <code>transaction_id</code> in the table. I need them associated with another <code>transaction_id</code> and not just hanging out by themselves. So, I want to create a mapping table that gives the floating <code>transaction_id</code> values and the <code>previous_transaction_id</code> they are associated with. I'm using LAG to get the <code>previous_transaction_id</code> and that works for some scenarios, but not all. Essentially, I'd like to tell LAG - &quot;Hey LAG, if the value you found is one of these floating <code>transaction_id</code> values, keep stepping back until you find one that isn't&quot; But I don't know how to do that.</p> <p>I'm using Snowflake and have jinja and dbt at my disposal if there is a better way to do this.</p> <p>Here is some mock data with the various scenarios I have and my current query:</p> <pre><code>with data as ( select transaction_id, customer_id, transaction_date, amount, type from (values (1, 'a','03/24/2022'::date, 10, 'cat'), (1, 'a','03/24/2022'::date, 15, 'dog'), (1, 'a','03/24/2022'::date, 20, 'mouse'), (1, 'a','03/24/2022'::date, 30, 'rabbit'), (1, 'a','03/24/2022'::date, 5, 'squirrel'), (2, 'a','03/24/2022'::date, 4, 'mod'), -- floater (3, 'b','05/20/2022'::date, 100, 'cat'), (3, 'b','05/20/2022'::date, 150, 'dog'), (3, 'b','05/20/2022'::date, 200, 'mouse'), (3, 'b','05/20/2022'::date, 300, 'rabbit'), (3, 'b','05/20/2022'::date, 50, 'squirrel'), (4, 'b','07/20/2022'::date, 40, 'mod'), -- floater (5, 'c','02/02/2020'::date, 100, 'cat'), (5, 'c','02/02/2020'::date, 150, 'dog'), (5, 'c','02/02/2020'::date, 200, 'mouse'), (5, 'c','02/02/2020'::date, 300, 'rabbit'), (6, 'c','08/01/2020'::date, 50, 'mod'), -- floater (7, 'c','12/25/2020'::date, 40, 'mod'), -- floater (8, 'd','01/15/2021'::date, 10, 'cat'), (8, 'd','01/15/2021'::date, 15, 'dog'), (8, 'd','01/15/2021'::date, 20, 'mouse'), (8, 'd','01/15/2021'::date, 30, 'rabbit'), (8, 'd','01/15/2021'::date, 5, 'squirrel'), (8, 'd','01/15/2021'::date, 4, 'mod'), (9, 'e','02/10/2020'::date, 100, 'cat'), (9, 'e','02/10/2020'::date, 150, 'dog'), (9, 'e','02/10/2020'::date, 200, 'mouse'), (9, 'e','02/10/2020'::date, 300, 'rabbit'), (10, 'e','08/17/2020'::date, 50, 'mod'), -- floater (11, 'e','12/15/2020'::date, 40, 'mod'), -- floater (12, 'e','02/14/2021'::date, 40, 'mod'), -- floater (13, 'c','04/09/2022'::date, 0, 'mouse'), (13, 'c','04/09/2022'::date, 0, 'rabbit'), (13, 'c','04/09/2022'::date, 50, 'mod') -- floater because other values for transaction_id sum to 0 ) as tbl (transaction_id, customer_id, transaction_date, amount, type) ), previous_transaction_id as ( select transaction_id, customer_id, lag(transaction_id, 1, null) over (partition by customer_id order by transaction_date) as previous_transaction_id from data qualify transaction_id != previous_transaction_id ), floating_mods as ( select transaction_id, sum(iff(type = 'mod', amount, 0)) as mod_amount, sum(amount) - mod_amount as non_mod_amount from data group by 1 having non_mod_amount = 0 ) select gp.transaction_id, gp.previous_transaction_id from previous_transaction_id gp inner join floating_mods fm on gp.transaction_id = fm.transaction_id order by gp.transaction_id </code></pre> <p>And here is the output of the query:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>TRANSACTION_ID</th> <th>PREVIOUS_TRANSACTION_ID</th> </tr> </thead> <tbody> <tr> <td>2</td> <td>1</td> </tr> <tr> <td>4</td> <td>3</td> </tr> <tr> <td>6</td> <td>5</td> </tr> <tr> <td>7</td> <td>6</td> </tr> <tr> <td>10</td> <td>9</td> </tr> <tr> <td>11</td> <td>10</td> </tr> <tr> <td>12</td> <td>11</td> </tr> <tr> <td>13</td> <td>7</td> </tr> </tbody> </table> </div> <p>And here is my desired output:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>TRANSACTION_ID</th> <th>PREVIOUS_TRANSACTION_ID</th> </tr> </thead> <tbody> <tr> <td>2</td> <td>1</td> </tr> <tr> <td>4</td> <td>3</td> </tr> <tr> <td>6</td> <td>5</td> </tr> <tr> <td>7</td> <td>5</td> </tr> <tr> <td>10</td> <td>9</td> </tr> <tr> <td>11</td> <td>9</td> </tr> <tr> <td>12</td> <td>9</td> </tr> <tr> <td>13</td> <td>5</td> </tr> </tbody> </table> </div>
[ { "answer_id": 74148446, "author": "Greg Pavlik", "author_id": 12756381, "author_profile": "https://Stackoverflow.com/users/12756381", "pm_score": 1, "selected": true, "text": "with data as (\nselect \n transaction_id,\n customer_id,\n transaction_date,\n amount,\n type\nf...
2022/10/21
[ "https://Stackoverflow.com/questions/74148086", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6669829/" ]
74,148,089
<pre><code>&lt;template&gt; &lt;div&gt; &lt;select ref='select'&gt; &lt;slot&gt;&lt;/slot&gt; &lt;/select&gt; &lt;/div&gt; &lt;/template&gt; &lt;script&gt; import Vue from &quot;vue&quot; export default { name: &quot;VueSelect&quot;, props: ['options', 'value'], mounted: function () { var vm = this; $(this.$refs.select) .select2({ data: this.options, tags: true, theme: &quot;bootstrap&quot;, createTag: function (params) { return { id: params.term, text: params.term, newOption: true } }, templateResult: function (state) { console.log(state) if (!state.id) { return state.text; } var baseUrl = &quot;/dist/peoples&quot;; var imgUrl = baseUrl + '/' + state.element.value.toLowerCase() + '.png' var $state = $( '&lt;span&gt;&lt;img src=&quot;'+imgUrl+'&quot; class=&quot;img-flag&quot; /&gt; ' + state.text + '&lt;/span&gt;' ); return $state; } }) .on('change', function (ev, args) { if (!(args &amp;&amp; &quot;ignore&quot; in args)) { vm.$emit('input', $(this).val()); vm.$emit(&quot;change_value&quot;,$(this).val()) } }); Vue.nextTick(() =&gt; { $(this.$refs.select) .val(this.value) .trigger('change', { ignore: true }) }); }, methods: { getImageUrl: function(src) { return require(&quot;~/assets&quot;+src); } }, watch: { value: function (value, oldValue) { // update value $(this.$refs.select) .val(this.value) .trigger('change', { ignore: true }); }, options: function (options) { // update options $(this.$refs.select).select2({ data: options }) } }, destroyed: function () { $(this.$refs.select).off().select2('destroy') } } &lt;/script&gt; &lt;style&gt; .select2-container--default { min-width: 100%; } &lt;/style&gt; </code></pre> <p>Here's my Vue + Select2 component.</p> <p>The issue is that I can't import image dynamically within jQuery script.</p> <pre><code> var baseUrl = &quot;~/assets/images/peoples&quot;; var imgUrl = baseUrl + '/' + state.element.value.toLowerCase() + '.png' </code></pre> <p>I have tried as follows according to the Nuxt dynamic import guide</p> <pre><code> var baseUrl = &quot;~/assets/images/peoples&quot;; var imgUrl = require(baseUrl + '/' + state.element.value.toLowerCase() + '.png') </code></pre> <p>But it fails.</p> <p>The console says &quot;Cannot find module &quot;~/assets/images/peoples/10.png&quot; &quot;</p> <p>also I can't import using static folder ( I copied them to it) with &quot;var baseUrl = &quot;/static/images/people&quot;</p> <p>The console says &quot;localhost:3000/static/images/people/10.png&quot; cannot found&quot;.</p> <p>Anyone can help me?</p>
[ { "answer_id": 74149751, "author": "Raju KC", "author_id": 1688526, "author_profile": "https://Stackoverflow.com/users/1688526", "pm_score": 3, "selected": true, "text": "var baseUrl = \"/static/images/people\"\n" }, { "answer_id": 74150146, "author": "kissu", "author_id"...
2022/10/21
[ "https://Stackoverflow.com/questions/74148089", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19569143/" ]
74,148,105
<p>I have an list of lists, each have a String (index 0) and a Value(index 1) the string has an number in it, example</p> <pre><code>a = [[&quot;Test 1&quot;, 5],[&quot;Test 2&quot;, 3],[&quot;Test 3&quot;, 1], [&quot;Test 4&quot;,3] </code></pre> <p>I want to sort it based on, firstly, the value, so the higher value goes first and if there is equal value between two arrays, sort with the digit in the string, the lower digit goes first, so it would result in this:</p> <pre><code>[&quot;Test 1&quot;, 5],[&quot;Test 2&quot;, 3], [&quot;Test 4&quot;,3],[&quot;Test 3&quot;, 1] </code></pre>
[ { "answer_id": 74148136, "author": "Tim Biegeleisen", "author_id": 1863229, "author_profile": "https://Stackoverflow.com/users/1863229", "pm_score": 0, "selected": false, "text": "a = [[\"Test 1\", 5],[\"Test 2\", 3],[\"Test 3\", 1], [\"Test 4\",3]]\na.sort(key=lambda row: (row[1], -int(...
2022/10/21
[ "https://Stackoverflow.com/questions/74148105", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17958241/" ]
74,148,114
<p>I'm importing some python files in my colab using from 'xxx ' import 'xxx' , but sometimes it stop being recognized even if I don't do any change in the code</p> <p>Example of the error message: <a href="https://i.stack.imgur.com/1i55Y.png" rel="nofollow noreferrer">enter image description here</a></p>
[ { "answer_id": 74148136, "author": "Tim Biegeleisen", "author_id": 1863229, "author_profile": "https://Stackoverflow.com/users/1863229", "pm_score": 0, "selected": false, "text": "a = [[\"Test 1\", 5],[\"Test 2\", 3],[\"Test 3\", 1], [\"Test 4\",3]]\na.sort(key=lambda row: (row[1], -int(...
2022/10/21
[ "https://Stackoverflow.com/questions/74148114", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20296991/" ]
74,148,139
<p>My current project is passing multiple values to php via ajax and I want to add an array together but I failed to do so.</p> <p>current JS file:</p> <pre><code>var name= 'John'; var age= 21; var gender = 'm'; var postData = 'name='+name+'&amp;age='+age+'&amp;gender=gender'; $.ajax({ type:'POST', dataType:'json', url:baseUrl+'/student', data:postData, }).done(function (data){ alert('success'); } }); </code></pre> <p>What I want to add:</p> <pre><code>var subject = [&quot;math&quot;,&quot;geograph&quot;]; JSON.stringify(subject ); //to encode the array </code></pre> <p>I have tried:</p> <pre><code>var postData = 'name='+name+'&amp;age='+age+'&amp;gender='+gender+'&amp;subject='subject'; </code></pre> <p>and</p> <pre><code>data:{subject : subject , postData : postData}, </code></pre> <p>and I get this array in php:</p> <pre><code>$subject = json_decode($request['subject']),true); </code></pre> <p>But I can't get the array in my php. How can I solve this problem? Thanks</p>
[ { "answer_id": 74148175, "author": "Phil", "author_id": 283366, "author_profile": "https://Stackoverflow.com/users/283366", "pm_score": 2, "selected": false, "text": "application/x-www-form-urlencoded" }, { "answer_id": 74148176, "author": "flyingfox", "author_id": 317641...
2022/10/21
[ "https://Stackoverflow.com/questions/74148139", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18640595/" ]
74,148,140
<p>I have two sets,</p> <pre><code>@ a=(2,5,3)@ B=(3,4,1), I want to get (2,5,4,1) </code></pre> <p>Whether the output is a newline, a space, or a comma is not important</p> <p>My idea is:</p> <pre><code>Intersection @ c=(2,5,3,4,1), union @ d=(3), result: @ c - @ d=(2,5,4,1) </code></pre> <p>Is there a more elegant solution (I don't like to install additional modules)</p>
[ { "answer_id": 74148238, "author": "craigb", "author_id": 20236884, "author_profile": "https://Stackoverflow.com/users/20236884", "pm_score": 3, "selected": false, "text": "undef" }, { "answer_id": 74148416, "author": "ikegami", "author_id": 589924, "author_profile": ...
2022/10/21
[ "https://Stackoverflow.com/questions/74148140", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18845050/" ]
74,148,142
<p>viewmodel:</p> <pre><code>fun getAuthenticationBrieInfo() = liveData { emit(authenticationRepository.getAuthenticationBrieInfo()) } </code></pre> <p>fragment:</p> <pre><code>override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) authenticationViewModel.getAuthenticationBrieInfo().observe(viewLifecycleOwner) { } } </code></pre> <p>When I don't have a network, it will crash. What should I do? I want to handle the crash and return the prompt message of &quot;no network&quot; to the user.</p>
[ { "answer_id": 74148238, "author": "craigb", "author_id": 20236884, "author_profile": "https://Stackoverflow.com/users/20236884", "pm_score": 3, "selected": false, "text": "undef" }, { "answer_id": 74148416, "author": "ikegami", "author_id": 589924, "author_profile": ...
2022/10/21
[ "https://Stackoverflow.com/questions/74148142", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18499869/" ]
74,148,145
<p>how can I customize the file name that uses the &quot;-&quot; sign so that it doesn't disappear after running the code below indeed in the code below it removes after the &quot;-&quot; but there is something that I don't need to remove. So I want the result to be like in the screenshot that I marked in yellow. Can I make an exception? Thanks</p> <p><a href="https://i.stack.imgur.com/IwfyQ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IwfyQ.jpg" alt="Desired result" /></a></p> <pre><code>Sub GetFileName2() Dim lr As Long Dim Rng As Range Dim arr1() As String Dim arr2() As String Dim arr3() As String Application.ScreenUpdating = False ' Find last row in column A with data Sheets(&quot;Master&quot;).Select lr = Cells(Rows.Count, &quot;A&quot;).End(xlUp).Row ' Pre-format column C for text Columns(&quot;C:C&quot;).NumberFormat = &quot;@&quot; ' Loop through every cell in column A starting in row 2 For Each Rng In Range(&quot;A2:A&quot; &amp; lr) arr1 = Split(Rng.Value, &quot;\&quot;) Rng.Offset(0, 1).Value = arr1(UBound(arr1, 1)) arr2 = Split(arr1(UBound(arr1, 1)), &quot;(&quot;) arr3 = Split(arr2(0), &quot;-&quot;) ' If first member of array is blank, choose the second If Left(arr2(0), 1) = &quot;-&quot; Then Rng.Offset(0, 2).Value = Replace(arr2(0), &quot;.jpg&quot;, &quot;&quot;) Else Rng.Offset(0, 2).Value = Replace(arr3(0), &quot;.jpg&quot;, &quot;&quot;) End If Next Rng Application.ScreenUpdating = True End Sub </code></pre>
[ { "answer_id": 74148238, "author": "craigb", "author_id": 20236884, "author_profile": "https://Stackoverflow.com/users/20236884", "pm_score": 3, "selected": false, "text": "undef" }, { "answer_id": 74148416, "author": "ikegami", "author_id": 589924, "author_profile": ...
2022/10/21
[ "https://Stackoverflow.com/questions/74148145", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20268915/" ]
74,148,155
<p>I have an WebAPI to consume the Pokemon public API. I've built it using .NET 5.0 and EF 5.0. Everything went fine until i added my logic to consume the API to the controller and tried to save the changes to the context.</p> <p>When i run _context.SaveChangesAsync() i'm having an error that says:</p> <p>&quot;Cannot insert explicit value for identity column in table 'PokemonDtos' when IDENTITY_INSERT is set to OFF.&quot;</p> <p>The thing is, everything was created by EF. I have not created any Table. The classes for deserializing json i created using json2csharp and jsonformatter so i could understand how to properly deserialize them.</p> <p>What am i doing wrong? Everything seems okay with the code, i'm just lost with this database issue. The database is created also, and tables ar there.</p> <p>PokemonDtoController.cs</p> <pre><code>{ [Route(&quot;api/[controller]&quot;)] [ApiController] public class PokemonDtoesController : ControllerBase { private readonly DataContext _context; private PokemonDto currPoke = null; public PokemonDtoesController(DataContext context) { _context = context; } // GET: api/PokemonDtoes [HttpGet] public async Task&lt;ActionResult&lt;IEnumerable&lt;PokemonDto&gt;&gt;&gt; Get_pokemons() { int limit = 3; string url = $&quot;https://pokeapi.co/api/v2/pokemon/?ffset={limit}&amp;limit={limit}&quot;; string json = string.Empty; using (HttpClient _client = new HttpClient()) { _client.BaseAddress = new Uri(url); _client.DefaultRequestHeaders.Accept.Clear(); _client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(&quot;application/json&quot;)); HttpResponseMessage response = await _client.GetAsync(url); if (response.IsSuccessStatusCode) { json = await response.Content.ReadAsStringAsync(); BaseResults myDeserializedClass = JsonConvert.DeserializeObject&lt;BaseResults&gt;(json); if (myDeserializedClass != null) { foreach (var result in myDeserializedClass.results) { using (HttpClient insideclient = new HttpClient()) { insideclient.BaseAddress = new Uri(result.url); response = await insideclient.GetAsync(result.url); if (response.IsSuccessStatusCode) { json = await response.Content.ReadAsStringAsync(); //AbilitiesRoot currPokeAbilities = JsonConvert.DeserializeObject&lt;AbilitiesRoot&gt;(json); currPoke = JsonConvert.DeserializeObject&lt;PokemonDto&gt;(json); if (currPoke != null) { try { _context.Add(currPoke); await _context.SaveChangesAsync(); // _context.SaveChanges(); } catch(Exception e) { return null; } } } } } } } } return await _context.PokemonDtos.ToListAsync(); } </code></pre> <p>DataContext.cs</p> <pre><code>public class DataContext : DbContext { protected readonly IConfiguration Configuration; public DataContext(IConfiguration configuration) { this.Configuration = configuration; } protected override void OnConfiguring(DbContextOptionsBuilder options) { options.UseSqlServer(Configuration.GetConnectionString(&quot;DefaultConnectionString&quot;)); } public DbSet&lt;PokemonDto&gt; PokemonDtos { get; set; } } </code></pre> <p>Perhaps i should list my steps also. After all code was created, i ran the following commands:</p> <blockquote> <p>dotnet ef migrations add PokeMigrations3 dotnet ef database update</p> </blockquote>
[ { "answer_id": 74148992, "author": "Ibrahim Timimi", "author_id": 8316900, "author_profile": "https://Stackoverflow.com/users/8316900", "pm_score": 0, "selected": false, "text": "Id" }, { "answer_id": 74149689, "author": "sergin", "author_id": 10431768, "author_profil...
2022/10/21
[ "https://Stackoverflow.com/questions/74148155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20022057/" ]
74,148,165
<p>I want to check if particular text already exists in a csv file.</p> <p>Is there any way or function except storing the whole file into variable and comparing each of its contents with the target text?</p>
[ { "answer_id": 74148625, "author": "ProgrammingLlama", "author_id": 3181933, "author_profile": "https://Stackoverflow.com/users/3181933", "pm_score": 2, "selected": true, "text": "File.ReadLines" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74148165", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20297022/" ]
74,148,184
<p>I am facing a problem that use <code>agg</code> function to calculate statistics without outliers for multiple columns. I need to remove 25 percentile and 75 percentile for &quot;each column&quot; and calculate min, max, mean.</p> <p>The input table:</p> <pre><code>df = spark.createDataFrame( [ ('a', 'E1', 'C1', 1, 1, 1), ('a', 'E1', 'C1', 2, 12, 22), ('a', 'E1', 'C1', 3, 13, 23), ('a', 'E1', 'C1', 4, 133, 123), ('b', 'E1', 'C1', 1, 1, 2), ('b', 'E1', 'C1', 2, 15, 25), ('b', 'E1', 'C1', 3, 56, 126), ('b', 'E1', 'C1', 4, 156, 126), ], schema=['sheet', 'equipment', 'chamber', 'time', 'value1', 'value2'] ) df.printSchema() df.show(10, False) +-----+---------+-------+----+------+------+ |sheet|equipment|chamber|time|value1|value2| +-----+---------+-------+----+------+------+ |a |E1 |C1 |1 |1 |1 | |a |E1 |C1 |2 |12 |22 | |a |E1 |C1 |3 |13 |23 | |a |E1 |C1 |4 |133 |123 | |b |E1 |C1 |1 |1 |2 | |b |E1 |C1 |2 |15 |25 | |b |E1 |C1 |3 |16 |26 | |b |E1 |C1 |4 |156 |126 | +-----+---------+-------+----+------+------+ </code></pre> <p>The expected result:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: left;">sheet</th> <th style="text-align: left;">equipment</th> <th style="text-align: left;">chamber</th> <th style="text-align: left;">value1_min</th> <th style="text-align: left;">value1_max</th> <th style="text-align: left;">value1_mean</th> <th style="text-align: left;">value2_min</th> <th style="text-align: left;">value2_max</th> <th style="text-align: left;">value2_mean</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">a</td> <td style="text-align: left;">E1</td> <td style="text-align: left;">C1</td> <td style="text-align: left;">12</td> <td style="text-align: left;">13</td> <td style="text-align: left;">12.5</td> <td style="text-align: left;">22</td> <td style="text-align: left;">23</td> <td style="text-align: left;">23.5</td> </tr> <tr> <td style="text-align: left;">b</td> <td style="text-align: left;">E1</td> <td style="text-align: left;">C1</td> <td style="text-align: left;">15</td> <td style="text-align: left;">16</td> <td style="text-align: left;">15.5</td> <td style="text-align: left;">25</td> <td style="text-align: left;">26</td> <td style="text-align: left;">25.5</td> </tr> </tbody> </table> </div> <p>Here is my code so far,</p> <p>but it takes <code>number of columns</code> times for loops, is there more efficient expression for this problem?</p> <pre><code> groupby_list = [&quot;sheet_id&quot;] dummy_origin = df.select(groupby_list).dropDuplicates(groupby_list) w = W.Window.partitionBy(groupby_list) param_df = df.drop(*groupby_list,'equipment', 'chamber','time') for col_name in param_df.columns: # for each column compute statistics and then join aggregation = [func.mean(col_name).alias(f&quot;{col_name}_mean&quot;), func.stddev(col_name).alias(f&quot;{col_name}_std&quot;), func.min(col_name).alias(f&quot;{col_name}_min&quot;), func.max(col_name).alias(f&quot;{col_name}_max&quot;) ] df_25_75 = (df.select('sheet_id',col_name) .withColumn(&quot;p25&quot;,func.percentile_approx(func.col(col_name), 0.25).over(w)) .withColumn(&quot;p75&quot;,func.percentile_approx(func.col(col_name), 0.75).over(w)) .withColumn(&quot;in_range&quot;, func.when( ((func.col(col_name) &lt;= func.col('p75')) &amp; (func.col(col_name) &gt;= func.col('p25'))),1).otherwise(0)) .where(func.col('in_range') == 1) .groupby(*groupby_list).agg(*aggregation) ) dummy_origin= dummy_origin.join(df_25_75,['sheet_id'],'inner') </code></pre>
[ { "answer_id": 74148625, "author": "ProgrammingLlama", "author_id": 3181933, "author_profile": "https://Stackoverflow.com/users/3181933", "pm_score": 2, "selected": true, "text": "File.ReadLines" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74148184", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19662400/" ]
74,148,308
<p>I am looking for an efficient way to trigger a callback for each item of a <code>LazyColumn</code> as they become visible, but only once.</p> <ul> <li>The callback should happen only once as items become visible. It should not trigger if the user scrolls past the same item several times.</li> <li>The callback should only happen once per each item.</li> </ul> <p>Is there a way Compose-y way of handling this?</p> <p>I tried to use <code>snapshotFlow</code> as below, but no matter which side effect I use, it gets triggered over and over as a user scrolls.</p> <pre><code>val listState = rememberLazyListState() LaunchedEffect(listState) { snapshotFlow { listState.layoutInfo.visibleItemsInfo} .map { it.first() } .collect { MyAnalyticsService.someVisibleItemCallback() } } </code></pre> <p>Another way I can image is baking this into the model state as follows.</p> <pre><code>data class SomeObject( val someStuff: SomeStuff, val isSeen: Boolean = false ) </code></pre> <p>How can I handle this in an efficient way?</p>
[ { "answer_id": 74148409, "author": "Arsh", "author_id": 14700539, "author_profile": "https://Stackoverflow.com/users/14700539", "pm_score": 0, "selected": false, "text": " snapshotFlow { listState.layoutInfo.visibleItemsInfo}\n .map { it.first() }\n .distinctUntilChanged()\n .co...
2022/10/21
[ "https://Stackoverflow.com/questions/74148308", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3034693/" ]
74,148,312
<p>I have a SQL database with 250 rows. I inserted a column filled with 0's. I updated the first rows 11 rows to be 1,2,3,4,5,6,7,8,9,10 &amp; 11. The rest of the rows are still 0's.</p> <p>How would I go about updating rows 11-250 to go from 0 to each of the relevant row value.</p> <p>thank you!</p>
[ { "answer_id": 74148409, "author": "Arsh", "author_id": 14700539, "author_profile": "https://Stackoverflow.com/users/14700539", "pm_score": 0, "selected": false, "text": " snapshotFlow { listState.layoutInfo.visibleItemsInfo}\n .map { it.first() }\n .distinctUntilChanged()\n .co...
2022/10/21
[ "https://Stackoverflow.com/questions/74148312", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19395498/" ]
74,148,315
<p>Thanks to <a href="https://stackoverflow.com/q/74083683/19323948">this answer</a>, I have the following dataframe:</p> <pre><code> START_POINT END_POINT DURATION island Stage 1 SLEEP-S0 00:32:03 00:42:33 630.0 2 SLEEP-S1 00:42:33 00:45:03 150.0 3 SLEEP-S0 00:45:03 00:46:03 60.0 4 SLEEP-S1 00:46:03 00:48:33 150.0 5 SLEEP-S2 00:48:33 00:50:03 90.0 ... ... ... ... ... 127 SLEEP-S2 09:32:03 09:39:03 420.0 128 SLEEP-S0 09:39:03 09:39:33 30.0 129 SLEEP-S1 09:39:33 09:40:03 30.0 130 SLEEP-S2 09:40:03 09:48:03 480.0 131 SLEEP-S0 09:48:03 NaN NaN </code></pre> <p>However, I want to convert the times here into times (in float or int) starting from t = 0. For example, this is what I want:</p> <pre><code> START_POINT END_POINT DURATION island Stage 1 SLEEP-S0 0 630 630.0 2 SLEEP-S1 630 780 150.0 3 SLEEP-S0 780 840 60.0 4 SLEEP-S1 ... ... ... 5 SLEEP-S2 ... ... ... ... ... ... ... ... </code></pre> <p>and so on. Can someone please help?</p>
[ { "answer_id": 74173200, "author": "FObersteiner", "author_id": 10197418, "author_profile": "https://Stackoverflow.com/users/10197418", "pm_score": 2, "selected": true, "text": "df[\"start\"] = df[\"DURATION\"].cumsum().shift().fillna(0)\ndf[\"end\"] = df[\"DURATION\"].cumsum()\n\ndf\nOu...
2022/10/21
[ "https://Stackoverflow.com/questions/74148315", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19323948/" ]
74,148,353
<p>i have a problem here. i want to call an array string in my adapter, but the image not showing at all. and its say class com.bumptech.glide.load.engine.GlideException: Failed to load resource, com.bumptech.glide.Registry$NoModelLoaderAvailableException(Failed to find any ModelLoaders registered for model class: class java.util.ArrayList). Can someone help me?</p> <p>this is the Response</p> <pre><code>data class ProductResponse ( @SerializedName(&quot;status&quot; ) var status : String? = null, @SerializedName(&quot;produk&quot; ) var produk : ArrayList&lt;Produk&gt; = arrayListOf(), @SerializedName(&quot;page&quot; ) var page : Int? = null, @SerializedName(&quot;per_page&quot; ) var perPage : Int? = null, @SerializedName(&quot;totalRows&quot; ) var totalRows : Int? = null, @SerializedName(&quot;totalPages&quot; ) var totalPages : Int? = null ) { data class Produk ( @SerializedName(&quot;id&quot; ) var id : Int? = null, @SerializedName(&quot;name&quot; ) var name : String? = null, @SerializedName(&quot;description&quot; ) var description : String? = null, @SerializedName(&quot;base_price&quot; ) var basePrice : Int? = null, @SerializedName(&quot;image_url&quot; ) var imageUrl : ArrayList&lt;String&gt; = arrayListOf(), @SerializedName(&quot;location&quot; ) var location : String? = null, @SerializedName(&quot;user_id&quot; ) var userId : Int? = null, @SerializedName(&quot;createdAt&quot; ) var createdAt : String? = null, @SerializedName(&quot;updatedAt&quot; ) var updatedAt : String? = null, @SerializedName(&quot;category&quot; ) var category : Category? = Category() ) { data class Category ( @SerializedName(&quot;id&quot; ) var id : Int? = null, @SerializedName(&quot;name&quot; ) var name : String? = null ) } } </code></pre> <p>this is the adapter</p> <pre><code>class ProductAdapter(private val onClick: OnClickListener): RecyclerView.Adapter&lt;ProductAdapter.ViewHolder&gt;() { private val diffCallBack = object: DiffUtil.ItemCallback&lt;ProductResponse.Produk&gt;(){ override fun areItemsTheSame(oldItem: ProductResponse.Produk, newItem: ProductResponse.Produk): Boolean { return oldItem.id == newItem.id } override fun areContentsTheSame(oldItem: ProductResponse.Produk, newItem: ProductResponse.Produk): Boolean { return oldItem.name == newItem.name } } private val differ = AsyncListDiffer(this,diffCallBack) fun submitData(value: List&lt;ProductResponse.Produk&gt;?) = differ.submitList(value) interface OnClickListener { fun onClickItem (data: ProductResponse.Produk) } inner class ViewHolder(private val binding: ListProductHomeBinding): RecyclerView.ViewHolder(binding.root){ @SuppressLint(&quot;SetTextI18n&quot;) var listCategory = &quot;&quot; fun bind (data: ProductResponse.Produk){ Glide.with(binding.root) .load(data.imageUrl) .into(binding.ivProductImg) binding.tvProductName.text = data.name binding.tvProductCategory.text = data.category!!.name.toString() binding.tvProductPrice.text = currency(data.basePrice!!) binding.root.setOnClickListener { onClick.onClickItem(data) } } } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ProductAdapter.ViewHolder { val inflate = LayoutInflater.from(parent.context) return ViewHolder(ListProductHomeBinding.inflate(inflate,parent,false)) } override fun onBindViewHolder(holder: ProductAdapter.ViewHolder, position: Int) { val data = differ.currentList[position] data.let { holder.bind(data) } } override fun getItemCount(): Int { return differ.currentList.size } } </code></pre>
[ { "answer_id": 74148429, "author": "Lawrence Gimenez", "author_id": 1075466, "author_profile": "https://Stackoverflow.com/users/1075466", "pm_score": 2, "selected": true, "text": "data.imageUrl" }, { "answer_id": 74150347, "author": "Begmyrat Mammedov", "author_id": 13877...
2022/10/21
[ "https://Stackoverflow.com/questions/74148353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19090636/" ]
74,148,358
<p>Is there anyway to have a map defined as Map&lt;String, String&gt; that can be added to an array list defined as List&lt;Map&lt;String, String&gt; that has the same key? Ideally we would have an arraylist of maps</p> <pre><code>[{firstName=john}, {firstName=Kelly}, {firstName=Jack}] </code></pre> <p>The reason I need the same key is for react.js ui I will need to map over these items and I need to have the same key in each object so I can call</p> <pre><code>List.map(key, index) = &gt; key.firstName </code></pre> <p>To build the ui component. Is this possible?</p> <pre><code>Map&lt;String,String&gt; names = new HashMap&lt;&gt;(); List&lt;Map&lt;String,String&gt; firstNamesLastNamesList = new ArrayList&lt;&gt;(); while(resultSet.next()){ names.put(&quot;firstName&quot;, resultSet.getString(&quot;firstName&quot;); names.put(&quot;lastName&quot;, resultSet.getString(&quot;lastName&quot;); firstNamesLastNamesList.add(names); } </code></pre> <p>The values to populate each map will come from a database. Currently when I add each object to the List of maps as you might imagine, the previous map is overwritten due to the same key of firstName. I am left with a List like [{firstName=Jack, lastName=Hammer}, {firstName=Jack, lastName=Hammer}, {firstName=Jack, lastName=Hammer}] not [{firstName=John, lastName=Carpenter}, {firstName=Kelly, lastName=Johnson}, {firstName=Jack, lastName=Black}] which is the desired out put. Any help would be greatly appreciated.</p>
[ { "answer_id": 74148429, "author": "Lawrence Gimenez", "author_id": 1075466, "author_profile": "https://Stackoverflow.com/users/1075466", "pm_score": 2, "selected": true, "text": "data.imageUrl" }, { "answer_id": 74150347, "author": "Begmyrat Mammedov", "author_id": 13877...
2022/10/21
[ "https://Stackoverflow.com/questions/74148358", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18197048/" ]
74,148,362
<p>I have this query in Postgres that returns a hash value for every row of my table:</p> <pre><code> SELECT md5(CAST((f.*)AS text)) FROM my_table f; </code></pre> <p>I want to attach each hash to its corresponding row. How would I take the results for each row and add them to a new column?</p>
[ { "answer_id": 74148429, "author": "Lawrence Gimenez", "author_id": 1075466, "author_profile": "https://Stackoverflow.com/users/1075466", "pm_score": 2, "selected": true, "text": "data.imageUrl" }, { "answer_id": 74150347, "author": "Begmyrat Mammedov", "author_id": 13877...
2022/10/21
[ "https://Stackoverflow.com/questions/74148362", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7065700/" ]
74,148,374
<p>I am having trouble understanding what the purpose of the <code>&amp;</code> means in this if statement. Would anyone be willing to point me in the right direction? I thought struct calls go as follows</p> <pre><code>car -&gt; model == &quot;jeep&quot; </code></pre> <p>This is what I am having confusion about:</p> <pre><code>if ((x-&gt;status &amp; 1) == 0){ ... } </code></pre>
[ { "answer_id": 74148429, "author": "Lawrence Gimenez", "author_id": 1075466, "author_profile": "https://Stackoverflow.com/users/1075466", "pm_score": 2, "selected": true, "text": "data.imageUrl" }, { "answer_id": 74150347, "author": "Begmyrat Mammedov", "author_id": 13877...
2022/10/21
[ "https://Stackoverflow.com/questions/74148374", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20297237/" ]
74,148,375
<p>Given this code:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>header { text-align: center; } /* no necessary, only using it to simulate a big table */ p.text { width: 20rem; height: 50rem; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;html&gt; &lt;body&gt; &lt;header&gt; &lt;h1&gt;Page Title&lt;/h1&gt; &lt;details&gt; &lt;summary&gt;Click Me&lt;/summary&gt; &lt;p&gt;More information&lt;/p&gt; &lt;p&gt;Even more stuff&lt;/p&gt; &lt;/details&gt; &lt;/header&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt;&lt;p class="text"&gt;Lorem&lt;/p&gt;&lt;/td&gt; &lt;td&gt;&lt;p class="text"&gt;ipsum&lt;/p&gt;&lt;/td&gt; &lt;td&gt;&lt;p class="text"&gt;dolors&lt;/p&gt;&lt;/td&gt; &lt;td&gt;&lt;p class="text"&gt;itamet&lt;/p&gt;&lt;/td&gt; &lt;td&gt;&lt;p class="text"&gt;consectetura&lt;/p&gt;&lt;/td&gt; &lt;td&gt;&lt;p class="text"&gt;dipiscinge&lt;/p&gt;&lt;/td&gt; &lt;td&gt;&lt;p class="text"&gt;litsed&lt;/p&gt;&lt;/td&gt; &lt;td&gt;&lt;p class="text"&gt;doeiusmod&lt;/p&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;p class="text"&gt;Lorem&lt;/p&gt;&lt;/td&gt; &lt;td&gt;&lt;p class="text"&gt;ipsum&lt;/p&gt;&lt;/td&gt; &lt;td&gt;&lt;p class="text"&gt;dolors&lt;/p&gt;&lt;/td&gt; &lt;td&gt;&lt;p class="text"&gt;itamet&lt;/p&gt;&lt;/td&gt; &lt;td&gt;&lt;p class="text"&gt;consectetura&lt;/p&gt;&lt;/td&gt; &lt;td&gt;&lt;p class="text"&gt;dipiscinge&lt;/p&gt;&lt;/td&gt; &lt;td&gt;&lt;p class="text"&gt;litsed&lt;/p&gt;&lt;/td&gt; &lt;td&gt;&lt;p class="text"&gt;doeiusmod&lt;/p&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> </div> </div> </p> <p>I would like the contents of <code>&lt;header&gt;</code> to stay centered when scrolling horizontally, but scroll out of view when scrolling vertically.</p> <p>I've tried <code>position: sticky; left: 0;</code> with several variations of <code>display</code>, <code>margin</code>, etc, to no avail. The closest I've gotten it to work is this:</p> <pre class="lang-css prettyprint-override"><code> header { text-align: center; position: fixed; top: 0; left: 0; width: 100vw; z-index: -1; } table { margin-top: 7rem; } </code></pre> <p>but that breaks when opening the <code>&lt;details&gt;</code> element <strong>and</strong> doesn't work at all in Firefox Mobile.</p> <p>Trying to stick to a &quot;pure&quot;, semantic solution. Not against a little Javascript, but would rather not use a framework.</p> <p>Thanks in advance for your help.</p>
[ { "answer_id": 74148417, "author": "K i", "author_id": 11196771, "author_profile": "https://Stackoverflow.com/users/11196771", "pm_score": 0, "selected": false, "text": "header {\n text-align: center;\n }\n /* no necessary, only using it to simulate a big table */\n p.text {\n w...
2022/10/21
[ "https://Stackoverflow.com/questions/74148375", "https://Stackoverflow.com", "https://Stackoverflow.com/users/181434/" ]
74,148,390
<p>When I create a new Google Cloud function, the default code given is:</p> <pre><code>const functions = require('@google-cloud/functions-framework'); functions.http('helloHttp', (req, res) =&gt; { res.send(`Hello ${req.query.name || req.body.name || 'World'}!`); }); </code></pre> <p>However, in this <a href="https://codelabs.developers.google.com/codelabs/local-development-with-cloud-functions#3" rel="nofollow noreferrer">tutorial</a>, the function is specified as:</p> <pre><code>exports.validateTemperature = async (req, res) =&gt; { try { if (req.body.temp &lt; 100) { res.status(200).send(&quot;Temperature OK&quot;); } else { res.status(200).send(&quot;Too hot&quot;); } } catch (error) { //return an error console.log(&quot;got error: &quot;, error); res.status(500).send(error); } }; </code></pre> <p>What is the difference between the two? How do they work in the bigger scheme of things?</p> <p>In the second example, the code is listening for a Http POST request. Where is this specified?</p>
[ { "answer_id": 74150044, "author": "程柏硯", "author_id": 6824831, "author_profile": "https://Stackoverflow.com/users/6824831", "pm_score": 1, "selected": true, "text": "validateTemperature" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74148390", "https://Stackoverflow.com", "https://Stackoverflow.com/users/936293/" ]
74,148,412
<p>I have installed Bootstrap icon like this link: <a href="https://icons.getbootstrap.com/#install" rel="nofollow noreferrer">https://icons.getbootstrap.com/#install</a></p> <p><a href="https://i.stack.imgur.com/wb3Js.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wb3Js.png" alt="enter image description here" /></a></p> <p>This is how I import the link and create the CSS file for Bootstrap Icon:</p> <p><a href="https://i.stack.imgur.com/vVL1C.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vVL1C.png" alt="enter image description here" /></a></p> <p>But then it still doesn't work. I still can't use the icon:</p> <p><a href="https://i.stack.imgur.com/hMTEh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hMTEh.png" alt="enter image description here" /></a></p> <p>Did I do something wrong? Hope someone can explain this to me clearly because I am new to ASP.NET Core 6 and am still learning.</p> <p>Thank you very much.</p>
[ { "answer_id": 74150044, "author": "程柏硯", "author_id": 6824831, "author_profile": "https://Stackoverflow.com/users/6824831", "pm_score": 1, "selected": true, "text": "validateTemperature" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74148412", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15597261/" ]
74,148,435
<p>Looking to see which client has the highest price sum for the month of February. 2/1/2022</p> <p><strong>Data</strong></p> <pre><code>client box Price date charles AA 5,000 2/1/2022 charles AA 5,050 2/1/2022 charles AA 5,075 2/1/2022 cara BB 25,116 2/1/2022 cara BB 5,154 2/1/2022 lu CC 0 2/1/2022 max DD 10,000 3/1/2022 </code></pre> <p><strong>Desired</strong></p> <pre><code> client box Price date cara BB 30,270 2/1/2022 </code></pre> <p><strong>Doing</strong></p> <pre><code>df.groupby(['client','date']) \ .agg({'Price':'sum'}).reset_index() \ </code></pre> <p>Any suggestion is helpful.</p>
[ { "answer_id": 74150044, "author": "程柏硯", "author_id": 6824831, "author_profile": "https://Stackoverflow.com/users/6824831", "pm_score": 1, "selected": true, "text": "validateTemperature" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74148435", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5942100/" ]
74,148,439
<p>I made this short code to calculate the chances of a success rolling dice, and it worked very well... but not in big numbers. Se the code, I'll explain better below.</p> <pre><code>def calc_dados(f_sucessos = 1, faces = 6, n_dados = 1): p_max = ((f_sucessos/faces)**n_dados) #chance de todos fator = 1 p_meio = 0 for i in range(n_dados-1): p_meio += (((f_sucessos/faces)**(n_dados-fator) * ((faces-f_sucessos)/faces)**(n_dados-(n_dados-fator))) * n_dados) fator += 1 p = p_max + p_meio return p*100 </code></pre> <p>So, ok, it works, why not see how my chances are better in function of adding dice? More the dice, better the chance. So I made this tiny table with pandas:</p> <pre><code>f_sucessos = 1 # how many faces are success faces = 2 # faces of the dice n_dados = 10 # n de dados lançados suc_list = [] for i in range(0,n_dados): suc_list.append(f_sucessos) fac_list = [] for i in range(0,n_dados): fac_list.append(faces) cha_list = [] for i in range(0,n_dados): cha_list.append(calc_dados(f_sucessos, faces, i+1)) df = pd.DataFrame( { &quot;n_dados&quot; : range(1,n_dados+1), &quot;faces&quot; : fac_list, &quot;sucessos&quot; : suc_list, &quot;chance&quot; : cha_list } ) df </code></pre> <p>The results were very strange... So I wrote an coin probability table and tested as the coin was an 2 faced dice. The right table is this: <a href="https://i.stack.imgur.com/q4vQr.png" rel="nofollow noreferrer">table of right brute force tested results</a></p> <p>But if you use my code to create this table the result will be this: <a href="https://i.stack.imgur.com/7UPiy.png" rel="nofollow noreferrer">table of the results of my code</a></p> <p>Please, anybody can help me to understood why in a certain moment the probabilities just fall when they should be higher? For example:The chance of at least 1 'head' in 4 coins should be 93,75%, but my code says it is 81,25%...</p>
[ { "answer_id": 74150044, "author": "程柏硯", "author_id": 6824831, "author_profile": "https://Stackoverflow.com/users/6824831", "pm_score": 1, "selected": true, "text": "validateTemperature" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74148439", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8447953/" ]
74,148,486
<p>I am doing source code reading for node-fetch, a JavaScript package.</p> <p>I have two questions about the code for the function isRequest below.</p> <pre class="lang-js prettyprint-override"><code>const INTERNALS = Symbol('Request internals'); /** * Check if `obj` is an instance of Request. * * @param {*} object * @return {boolean} */ const isRequest = object =&gt; { return ( typeof object === 'object' &amp;&amp; typeof object[INTERNALS] === 'object' ); }; </code></pre> <p><a href="https://github.com/node-fetch/node-fetch/blob/main/src/request.js" rel="nofollow noreferrer">https://github.com/node-fetch/node-fetch/blob/main/src/request.js</a></p> <ol> <li><p>Am I correct in my understanding that <code>const INTERNALS = Symbol('Request internals');</code> defines a string?</p> </li> <li><p>When I run the same code in local, the result is false, which is not what I expected. Why is this?</p> </li> </ol> <pre class="lang-js prettyprint-override"><code>const INTERNAL = Symbol('Request Internal'); const isRequest = object =&gt; { return ( typeof object === &quot;object&quot; &amp;&amp; typeof object[INTERNAL] === &quot;object&quot; ); } const req = new Request(&quot;https://example.com&quot;); console.log(isRequest(req)); </code></pre> <pre class="lang-bash prettyprint-override"><code>❯ node -v v18.11.0 ❯ node test.js false </code></pre>
[ { "answer_id": 74148538, "author": "Phil", "author_id": 283366, "author_profile": "https://Stackoverflow.com/users/283366", "pm_score": 1, "selected": false, "text": "const INTERNALS = Symbol('Request internals');" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74148486", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15368721/" ]
74,148,531
<p>I got the divs that have the email and password from bootstrap. I have css for the id dropdownlogin, and I did display: none; this is my first post so I hope I have given enough information.</p> <pre><code> &lt;script&gt; document.addEventListener('DOMContentLoaded', function() { document.querySelector(&quot;#dropdownlogin&quot;).addEventListener('click', function() { dropdownlogin.style.display = block; }) }); &lt;/script&gt; &lt;div class=&quot;login&quot;&gt; &lt;a href=&quot;#&quot;&gt;Login&lt;/a&gt; &lt;center&gt; &lt;form id=&quot;dropdownlogin&quot; action=&quot;&quot;&gt; &lt;div class=&quot;form-floating mb-3&quot;&gt; &lt;input type=&quot;email&quot; class=&quot;form-control&quot; id=&quot;floatingInput&quot; placeholder=&quot;name@example.com&quot;&gt; &lt;label for=&quot;floatingInput&quot;&gt;Email address&lt;/label&gt; &lt;/div&gt; &lt;div class=&quot;form-floating&quot;&gt; &lt;input type=&quot;password&quot; class=&quot;form-control&quot; id=&quot;floatingPassword&quot; placeholder=&quot;Password&quot;&gt; &lt;label for=&quot;floatingPassword&quot;&gt;Password&lt;/label&gt; &lt;/div&gt; &lt;div id=&quot;loginbtn&quot;&gt; &lt;button&gt;Login&lt;/button&gt; &lt;button&gt;Forgot Password&lt;/button&gt;&lt;/p&gt; &lt;/div&gt; &lt;/form&gt; &lt;/center&gt; &lt;/div&gt; </code></pre>
[ { "answer_id": 74148596, "author": "brk", "author_id": 2181397, "author_profile": "https://Stackoverflow.com/users/2181397", "pm_score": 3, "selected": true, "text": "Login" }, { "answer_id": 74148613, "author": "Himanshu Gabhane", "author_id": 20291681, "author_profi...
2022/10/21
[ "https://Stackoverflow.com/questions/74148531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20297300/" ]
74,148,553
<p>I have spent several days on google search to find a solution, but no right one. so I post it here.</p> <p>I have 3 VM machines.</p> <p>VM 1:<br> windows server 2012 R2 sp1, 192.168.1.10<br> sql server 2016, port 1432<br> sql server 2017, port 1433</p> <p>VM 2:<br> ubuntu 20.04<br> openssl 1.1.1p<br></p> <p>VM 3:<br> ubuntu 22.04<br> openssl 3.0.2<br></p> <p>on VM2 (ubuntu 20.04):<br> connect to sql server 2016<br> sqlcmd -S 192.168.1.10,1432 -U test -P test<br> successfully connect<br> connect to sql server 2017<br> sqlcmd -S 192.168.1.10,1433 -U test -P test<br> successfully connect<br></p> <p>on VM3 (ubuntu 22.04):<br> connect to sql server 2017<br> sqlcmd -S 192.168.1.10,1433 -U test -P test<br> successfully connect<br> connect to sql server 2016<br> sqlcmd -S 192.168.1.10,1432 -U test -P test<br> get error:<br> Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : TCP Provider: Error code 0x2746.<br> Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Client unable to establish connection.<br></p> <p>then I check sql server 2016's log on VM1, find 2 errors:<br> Event ID: 36888<br> A fatal alert was generated and sent to the remote endpoint. This may result in termination of the connection. The TLS protocol defined fatal error code is 40. The Windows SChannel error state is 1205.<br> Event ID: 36874<br> An TLS 1.2 connection request was received from a remote client application, but none of the cipher suites supported by the client application are supported by the server. The SSL connection request has failed.<br></p> <p>What I have tried:<br> 1, modify /etc/ssl/openssl.cnf<br> MinProtocol = TLSv1.0<br> CipherString = DEFAULT@SECLEVEL=1<br></p> <p>2, downgrade openssl to 1.1.1p<br></p> <p>3, modify win server reg<br> HKLM SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2<br> key: Enabled Value:1<br></p> <p>4, execute windows update</p> <p>I have tried all suggestions that I can find about &quot;TCP Provider: Error code 0x2746.&quot; but none works for my case.</p> <p>This issue happens when we sqlcmd to ms sql server 2016 in ubuntu 22.04 and openssl 3.0.2</p> <p>any idea? any suggestion? any solution?</p>
[ { "answer_id": 74474384, "author": "Dolly Aswin", "author_id": 1136666, "author_profile": "https://Stackoverflow.com/users/1136666", "pm_score": 1, "selected": false, "text": "SECLEVEL" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74148553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13841884/" ]
74,148,587
<p>I am trying to plot two different attributes side by side in a stack bar chart.</p> <p>This is what I have:</p> <ul> <li>Import libraries</li> </ul> <pre class="lang-py prettyprint-override"><code>import pandas as pd from datetime import datetime from dateutil.relativedelta import relativedelta import random import altair as alt </code></pre> <ul> <li>Toy data:</li> </ul> <pre class="lang-py prettyprint-override"><code>df = pd.DataFrame(data={ &quot;date&quot;: [datetime.now()+relativedelta(month=+i) for i in range(5)], &quot;label&quot;: random.choices([&quot;positive&quot;, &quot;negative&quot;], k=5), &quot;prediction&quot;: random.choices([&quot;likely&quot;, &quot;very_likely&quot;, &quot;unlikely&quot;, &quot;very_unlikely&quot;], k=5), &quot;indicator&quot;: random.choices([&quot;0&quot;, &quot;1&quot;], k=5), }) </code></pre> <ul> <li>Altair plot:</li> </ul> <pre class="lang-py prettyprint-override"><code>selection1 = alt.selection_multi(fields=[&quot;prediction&quot;], bind=&quot;legend&quot;) plot1 = ( alt.Chart() .mark_bar() .encode( x=alt.X(&quot;count(prediction):O&quot;, title=&quot;count&quot;, stack=&quot;zero&quot;), y=alt.Y(&quot;month(date):N&quot;, title=None), color=alt.Color(&quot;prediction:N&quot;, scale=alt.Scale(scheme=&quot;tableau10&quot;)), opacity=alt.condition(selection1, alt.value(1), alt.value(0.2)), tooltip=&quot;prediction:N&quot;, ) .add_selection(selection1) ) selection2 = alt.selection_multi(fields=[&quot;label&quot;], bind=&quot;legend&quot;) plot2 = ( alt.Chart() .mark_bar() .encode( x=alt.X(&quot;count(label):O&quot;, title=&quot;count&quot;, stack=&quot;zero&quot;), y=alt.Y(&quot;month(date):N&quot;, title=None), color=alt.Color(&quot;label:N&quot;, scale=alt.Scale(scheme=&quot;tableau10&quot;)), opacity=alt.condition(selection2, alt.value(1), alt.value(0.2)), tooltip=&quot;label:N&quot;, ) .add_selection(selection2) ) text = ( alt.Chart() .mark_text(dx=-15, dy=3, color=&quot;white&quot;) .encode( x=alt.X(&quot;count(prediction):O&quot;, title=&quot;label count&quot;, stack=&quot;zero&quot;), y=alt.Y(&quot;month(date):N&quot;, title=None), detail=&quot;sipredictionte:N&quot;, text=alt.Text(&quot;count(prediction):Q&quot;, format=&quot;.1f&quot;), ) ) plot = alt.layer((plot1+plot2)+text, data=df).facet( column=alt.Column(&quot;indicator&quot;, title=&quot;title&quot;), ) </code></pre> <p>This code generates the following plot:</p> <p><a href="https://i.stack.imgur.com/iWUOX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iWUOX.png" alt="enter image description here" /></a></p> <ul> <li>Expected</li> </ul> <p>This is somewhat what I am trying to plot and I am not sure if it is possible with altair.</p> <p><a href="https://i.stack.imgur.com/ginPP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ginPP.png" alt="enter image description here" /></a></p> <p>Basically, I have two fields that I want to plot side by side for each month in a column based. For each bin, I'd like to know the counts for each legend.</p>
[ { "answer_id": 74149231, "author": "LazyClown", "author_id": 3392461, "author_profile": "https://Stackoverflow.com/users/3392461", "pm_score": 1, "selected": false, "text": "selection1 = alt.selection_multi(fields=[\"prediction\"], bind=\"legend\")\nplot1 = (\n alt.Chart()\n .mark_...
2022/10/21
[ "https://Stackoverflow.com/questions/74148587", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4565682/" ]
74,148,626
<p>As part of a test, I wish to mock a Get() method using Moq such that it returns a popped value from a Stack every time it’s called.</p> <p>Unfortunately, Moq’s Setup() methods are only run once and thus, each Get() within my test returns the same top value from the stack on every call.</p> <p>My test kicks off a process in which multiple Get() methods are called. How would I mock this Get() method such that it pops a new value every time of off a orderedGetOutputs stack?</p>
[ { "answer_id": 74149231, "author": "LazyClown", "author_id": 3392461, "author_profile": "https://Stackoverflow.com/users/3392461", "pm_score": 1, "selected": false, "text": "selection1 = alt.selection_multi(fields=[\"prediction\"], bind=\"legend\")\nplot1 = (\n alt.Chart()\n .mark_...
2022/10/21
[ "https://Stackoverflow.com/questions/74148626", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6566623/" ]
74,148,675
<p>Trying to return this document from a collection by checking if a variable (<code>userId</code>) matches the second element in <code>users</code> array.</p> <p>I created a playground. Expected result is the user document <code>xyz</code> as thats the only user who liked <code>rrr</code> and the user <code>rrr</code> has not liked back - <a href="https://mongoplayground.net/p/WI7hqR7SIMh" rel="nofollow noreferrer">https://mongoplayground.net/p/WI7hqR7SIMh</a></p> <p>Expected result:</p> <pre><code>[ { &quot;count&quot;: 1, &quot;users&quot;: [ { &quot;_id&quot;: &quot;xyz&quot;, &quot;group&quot;: 1, &quot;name&quot;: &quot;xyyy&quot; } ] } ] </code></pre> <p>My query is below where variable <code>userId</code> is xw5vk1s and is the second element in above array. The two conditions I am checking are <code>like: true</code> and <code>userId = second element is users array</code></p> <pre><code> const users = await db .collection('users') .aggregate([ { $lookup: { from: &quot;likes&quot;, let: {userId: &quot;$_id&quot;}, pipeline: [{$match: {$expr: {$and: [{like: true, &quot;users.1&quot;: userId} ]}}}], as: &quot;valid&quot; } }, {$match: { &quot;valid.0&quot;: {$exists: true}, } }, {$unset: [&quot;valid&quot;]}, {$group: {_id: 0, users: {$push: &quot;$$ROOT&quot;}, count: {$sum: 1}}} ]) </code></pre> <p>The query is not working.</p>
[ { "answer_id": 74148902, "author": "Hemant Soni", "author_id": 16419976, "author_profile": "https://Stackoverflow.com/users/16419976", "pm_score": 0, "selected": false, "text": "[\n {\n $addFields: {\n secondItem: {\n $arrayElemAt: [\n \"$users\",\n 1\n ...
2022/10/21
[ "https://Stackoverflow.com/questions/74148675", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3717114/" ]
74,148,702
<p>Need help, I'm making a screen locker app using React Native, and want to get an event when the android power button is pressed...</p> <p>Thanks in advance..</p>
[ { "answer_id": 74148902, "author": "Hemant Soni", "author_id": 16419976, "author_profile": "https://Stackoverflow.com/users/16419976", "pm_score": 0, "selected": false, "text": "[\n {\n $addFields: {\n secondItem: {\n $arrayElemAt: [\n \"$users\",\n 1\n ...
2022/10/21
[ "https://Stackoverflow.com/questions/74148702", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20278389/" ]
74,148,712
<p>this is my first post in Stackoverflow.com</p> <p>This is the process I'm following:</p> <ol> <li>Make a connection to dB</li> <li>Make a query to the dB to check if the register exists</li> <li>If the register does NOT exist iterate over a loop</li> <li>Add the registers in the dB</li> </ol> <p><strong>My code:</strong></p> <pre><code>conn = sqlite3.connect('serps.db') c = conn.cursor() # 1) Make the query c.execute(&quot;SELECT fecha FROM registros WHERE fecha=? AND keyword=?&quot;, (fecha, q)) # 2) Check if exists exists = c.fetchone() conn.commit() if not exists: for data in json: ... c.execute(&quot;INSERT INTO registros VALUES (?, ?, ?, ?, ?, ?)&quot;, (fecha, hora, q, rank, url, title)) conn.commit() </code></pre> <p>I get the following error:</p> <pre><code>---&gt; conn.commit() OperationalError: database is locked </code></pre> <p>I think if I close the database after checking if the register exists, I could open it again and it will work.</p> <p>But should I close and open connections when INSERT after SELECT?</p>
[ { "answer_id": 74148902, "author": "Hemant Soni", "author_id": 16419976, "author_profile": "https://Stackoverflow.com/users/16419976", "pm_score": 0, "selected": false, "text": "[\n {\n $addFields: {\n secondItem: {\n $arrayElemAt: [\n \"$users\",\n 1\n ...
2022/10/21
[ "https://Stackoverflow.com/questions/74148712", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20297476/" ]
74,148,723
<p>I am not getting status message as <code>500</code> eventhough I set. always getting status message as <code>200</code>. how to set the status as 500?</p> <p>here is my code : <code>&quot;express&quot;: &quot;4.17.2&quot;,</code></p> <pre><code> router.post('/register', async (req: Request, res: Response) =&gt; { const { password, email } = req.body; try { const isUserExist = await UserModel.findOne({ email: email }); if (isUserExist) { //status not set. return res.json({ message: 'User already exist', success: false }).status(500); } const hashPassword = bcrypt.hashSync(password, 10); req.body.password = hashPassword; const newUser = new UserModel(req.body); await newUser.save(); res.json({ message: 'user created successfully', success: true }); } catch (error) { res.sendStatus(500).json({ message: 'Error creating user', success: false }); } }); </code></pre> <p>react axios:</p> <p>when i use:</p> <p><code>return res.status(500).json({ message: 'User already exist', success: false });</code> getting <code>something went wrong</code></p> <pre><code>export const registerUser = createAsyncThunk('post/user', async (user: RegisterFormProps) =&gt; { try { const response = await axios.post(environment.BASE_URL + '/user/register', user); console.log('suc', response.data.success); if (response.data.success) { toast.success(response.data.message); } else { toast.error(response.data.message); } } catch (error) { const err = error as AxiosError; console.log('err', err); toast.error('something went wrong'); } }); </code></pre>
[ { "answer_id": 74148756, "author": "DCodeMania", "author_id": 8546303, "author_profile": "https://Stackoverflow.com/users/8546303", "pm_score": 0, "selected": false, "text": "router.post('/register', async (req: Request, res: Response) => {\n const { password, email } = req.body;\n ...
2022/10/21
[ "https://Stackoverflow.com/questions/74148723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/218349/" ]
74,148,730
<p>I have this sample of string <code>Lorem ipsum +12 121 323 454 dolor sit amet</code>. Here is my RegEx <code>([0-9+?\s])</code> but it includes outside spaces.</p> <p><a href="https://i.stack.imgur.com/3TTP3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3TTP3.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74148766, "author": "Amadan", "author_id": 240443, "author_profile": "https://Stackoverflow.com/users/240443", "pm_score": 3, "selected": true, "text": "[0-9+](?:([0-9+?\\s]*[0-9+]))?\n" }, { "answer_id": 74150662, "author": "The fourth bird", "author_id": ...
2022/10/21
[ "https://Stackoverflow.com/questions/74148730", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13492734/" ]
74,148,760
<p>This is my code. My point is to take string input and count how many of each letter occurs</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;ctype.h&gt; int main() { int c1; int a=0, b=0, c=0, d=0, e=0, f=0, g=0, h=0, i=0, j=0, k=0, l=0, m=0, n=0, o=0, p=0, q=0, r=0, s=0, t=0, u=0, v=0, w=0, x=0 , y=0, z=0; while (( c1=getchar()) != EOF) if (isalpha(tolower(c1)) != 0) { if (tolower(c1) == 97) { // Character = 'a' a += 1; } else if (tolower(c1) == 98) { // Character = 'b' b += 1; } else if (tolower(c1) == 99) { // Character = 'c' c += 1; } . . . } return 0; } </code></pre> <p>Next I want to printf result in vertical. Could you give me some hints. For example,</p> <p>input: ABC---Ddhhh</p> <p>output:</p> <pre><code> * * * **** * abcdefghijklmnopqrstuvwxyz </code></pre>
[ { "answer_id": 74148801, "author": "Amadan", "author_id": 240443, "author_profile": "https://Stackoverflow.com/users/240443", "pm_score": 1, "selected": false, "text": "int counts[26];\n" }, { "answer_id": 74148812, "author": "Millar248", "author_id": 3812732, "author...
2022/10/21
[ "https://Stackoverflow.com/questions/74148760", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
74,148,764
<p>I have 3 databases like theses :</p> <pre><code> formations subjects formation_subject | id | name| | id | name | is_optional | | formation_id | subject_id | ___________ _________________________ ____________________________ </code></pre> <p>where in the Models\Subject,</p> <pre><code>public function formations() { return $this-&gt;belongsToMany(Formation::class); } </code></pre> <p>and in the Models\Formation,</p> <pre><code>public function formationsSubjects() { return $this-&gt;belongsToMany(Subject::class); } </code></pre> <p>in my controller, I have :</p> <pre><code>$formations = Formation::get()-&gt;pluck('name','id); $options = Subject::where('is_optional', 1)-&gt;get(); </code></pre> <p>On my blade, I have a dropdown of $formations, and whenever the selected option of that dropdown is changed, I'd like to get a list of dropdown of $options, which are the Subject are optional ('is_optional' == 1) and the Subject belongsTo(Many) the previously selected $formations</p> <p>I've tried like this,</p> <pre><code>$options = Subject::where('is_optional',1)-&gt;whereIn('id', function($query) use ($formations){ $query-&gt;select('formation_id') -&gt;from('formation_subject')-&gt;whereIn('formation_id',$formations); })-&gt;get()-&gt;pluck('code', 'id'); </code></pre> <p>But the results didn't matched with what's supposed to appear, and stay the same no matter the formations dropdown is selected.</p>
[ { "answer_id": 74148801, "author": "Amadan", "author_id": 240443, "author_profile": "https://Stackoverflow.com/users/240443", "pm_score": 1, "selected": false, "text": "int counts[26];\n" }, { "answer_id": 74148812, "author": "Millar248", "author_id": 3812732, "author...
2022/10/21
[ "https://Stackoverflow.com/questions/74148764", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8625196/" ]
74,148,777
<p>My problem is when the fetch response status is 403 the response return HTML not json, but when the code reach the if statment i cant access the response status anymore.</p> <pre><code>const response = await fetch( \\\\\\ Fetch infos \\\\\ ).then( response =&gt; { return response.json().then(data =&gt; ({ status: response.status, data })).catch(err =&gt; console.log(err)) }); if (response.status == 403) { \\\\ Stuf \\\\\ } </code></pre>
[ { "answer_id": 74148801, "author": "Amadan", "author_id": 240443, "author_profile": "https://Stackoverflow.com/users/240443", "pm_score": 1, "selected": false, "text": "int counts[26];\n" }, { "answer_id": 74148812, "author": "Millar248", "author_id": 3812732, "author...
2022/10/21
[ "https://Stackoverflow.com/questions/74148777", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14550534/" ]
74,148,783
<p>I have a Table in PowerBI, and it has a column which I added by <code>New Column</code> in PowerBI and I have a DAX function to compute the value for each row.</p> <p>Then I create a new Measure for the same table. I need to create a <code>Measure</code> instead of <code>Column</code> because I need to use <code>SelectedValue</code>.</p> <p>But for the new measure , I get error saying <code>The value for 'MyColumn' cannot be determined. Either the column does not exist or there is no current row for this column</code>.</p> <p>Can you please tell me how can I solve this issue&gt;?</p> <hr /> <p>I have a slider using the <code>Type</code> of <code>Table 1</code>, so that it has 3 selections &quot;A&quot;, &quot;B&quot;, &quot;C&quot;</p> <p>Table 1</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Type</th> </tr> </thead> <tbody> <tr> <td>A</td> </tr> <tr> <td>B</td> </tr> <tr> <td>C</td> </tr> </tbody> </table> </div> <p>And I have another Table 2 in m PowerBI</p> <p>Table 2</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Name</th> <th>A Count</th> <th>B Count</th> <th>C Count</th> </tr> </thead> <tbody> <tr> <td>Paul</td> <td>1</td> <td></td> <td>1</td> </tr> <tr> <td>Jane</td> <td></td> <td>1</td> <td>2</td> </tr> <tr> <td>John</td> <td></td> <td>3</td> <td></td> </tr> </tbody> </table> </div> <p>I want to build a measure/relationship such that if 'A' of Slider is selected, any row of Table 2 with &quot;A count&quot; has values will be displayed, otherwise, get it hidden.</p> <p>So in this case,</p> <ul> <li>when 'A' is selected, 'Paul' gets displayed,</li> <li>when 'B' is selected, 'Jane', 'John' gets displayed,</li> <li>when 'C' is selected, 'Paul', 'Jane' gets displayed.</li> </ul>
[ { "answer_id": 74148801, "author": "Amadan", "author_id": 240443, "author_profile": "https://Stackoverflow.com/users/240443", "pm_score": 1, "selected": false, "text": "int counts[26];\n" }, { "answer_id": 74148812, "author": "Millar248", "author_id": 3812732, "author...
2022/10/21
[ "https://Stackoverflow.com/questions/74148783", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14396579/" ]
74,148,790
<p>I have the following problem,</p> <p>I want to get the pair of given sum by using higher order functions. I am able to do this using iterative approach. Can someone help me to solve the problem using Swift higher order functions like map, filter etc.</p> <pre><code> let array = [1,2,3,4,5] let givenSum = 9 for i in 0..&lt;array.count { let j = i + 1 for j in j..&lt;array.count { if array[i] + array[j] == givenSum { print(&quot;Pair : \(array[i]),\(array[j])&quot;) } } } </code></pre> <p>The output is [4,5]</p> <p>Any help is appreciated. Thank you</p>
[ { "answer_id": 74148801, "author": "Amadan", "author_id": 240443, "author_profile": "https://Stackoverflow.com/users/240443", "pm_score": 1, "selected": false, "text": "int counts[26];\n" }, { "answer_id": 74148812, "author": "Millar248", "author_id": 3812732, "author...
2022/10/21
[ "https://Stackoverflow.com/questions/74148790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20297616/" ]
74,148,799
<p>Is there a way where I can print out that the domain does not exist instead of giving me an error like this</p> <blockquote> <p>ConnectionError: HTTPSConnectionPool(host='www.enroll.connect.web.co.id', port=443): Max retries exceeded with url: / (Caused by NewConnectionError('&lt;urllib3.connection.HTTPSConnection object at 0x7f4f558003d0&gt;: Failed to establish a new connection: [Errno -2] Name or service not known'))</p> </blockquote> <p>This is the code that i use to check whether the domain exist or not</p> <pre><code>request = requests.get('https://www.enroll.connect.web.co.id') if request.status_code == 200: print('Web site exists') else: print('Web site does not exist') </code></pre> <p>The logic should've been if the status is 200 then that means the website existed, but if it's not 200 it should've print out that the website does not exist.</p> <p>Thx!</p>
[ { "answer_id": 74148833, "author": "Mehmaam", "author_id": 19350100, "author_profile": "https://Stackoverflow.com/users/19350100", "pm_score": 2, "selected": true, "text": "Exception Handling" }, { "answer_id": 74148866, "author": "DrunkLeen", "author_id": 20296584, "...
2022/10/21
[ "https://Stackoverflow.com/questions/74148799", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19027283/" ]
74,148,811
<p>I'm observing some very strange behavior of a for each loop. When the if/else blocks are present, an infinite loop results. However, when they are commented out, and only the print(motif) remains in the loop, the expected behavior results, looping through the list 4 times. I should mention the the motif_seqs list was assigned to this new list at this point in the code, which may somehow influence the behavior.</p> <pre><code>motif_seqs = [&quot;polyA&quot;, &quot;polyT&quot;, &quot;polyG&quot;, &quot;polyC&quot;] for motif in motif_seqs: if motif == &quot;homopolymer&quot;: pass else: motif_seqs.append(motif) print(motif) </code></pre>
[ { "answer_id": 74148833, "author": "Mehmaam", "author_id": 19350100, "author_profile": "https://Stackoverflow.com/users/19350100", "pm_score": 2, "selected": true, "text": "Exception Handling" }, { "answer_id": 74148866, "author": "DrunkLeen", "author_id": 20296584, "...
2022/10/21
[ "https://Stackoverflow.com/questions/74148811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19473239/" ]
74,148,834
<p>I'm trying to return a <code>vector&lt;unique_ptr&gt;</code> from a function, but I'm running into errors. I'm using MSVC 19.33.31630.</p> <p>The comments to <a href="https://stackoverflow.com/questions/66617881/">this question</a> recommend returning by value, but this code:</p> <pre><code>std::vector&lt;std::unique_ptr&lt;int&gt;&gt; test1() { std::vector&lt;std::unique_ptr&lt;int&gt;&gt; ret = { std::make_unique&lt;int&gt;(1) }; return ret; } int main() { std::vector&lt;std::unique_ptr&lt;int&gt;&gt; x = test1(); std::unique_ptr&lt;int&gt;&amp; ptrY = x.at(0); return 0; } </code></pre> <p>yields this error:</p> <blockquote> <p>Error C2280 'std::unique_ptr&lt;int,std::default_delete&lt;int&gt;&gt;::unique_ptr(const std::unique_ptr&lt;int,std::default_delete&lt;int&gt;&gt; &amp;)': attempting to reference a deleted function</p> </blockquote> <p>Returning by reference, as in this code:</p> <pre><code>std::vector&lt;std::unique_ptr&lt;int&gt;&gt;&amp; test2() { std::vector&lt;std::unique_ptr&lt;int&gt;&gt; ret = { std::make_unique&lt;int&gt;(1) }; return ret; } int main() { std::vector&lt;std::unique_ptr&lt;int&gt;&gt;&amp; y = test2(); std::cout &lt;&lt; *(y.at(0)) &lt;&lt; std::endl; return 0; } </code></pre> <p>yields the same error.</p> <p>Why is this happening? Is the ownership of the <code>unique_ptr</code> not transferring properly?</p>
[ { "answer_id": 74148884, "author": "Marcus Müller", "author_id": 4433386, "author_profile": "https://Stackoverflow.com/users/4433386", "pm_score": -1, "selected": false, "text": "std::vector<std::unique_ptr<int>> x = test1();\n" }, { "answer_id": 74149133, "author": "Sciencis...
2022/10/21
[ "https://Stackoverflow.com/questions/74148834", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14734068/" ]
74,148,841
<p>I was wondering on how to properly move a slice element to the last position of a slice in Golang.</p> <p>e.g:</p> <pre class="lang-golang prettyprint-override"><code>func main() { slc := []int{1,2,3,4,5} fmt.Println(shiftEnd(slc,2)) } func shiftEnd(s []int, x int) []int { return append(s[x:],s[:x]...) } </code></pre> <p>This will result in <code>[3,4,5,1,2</code>] I was wondering how to receive <code>[1,3,4,5,2]</code></p> <p><a href="https://play.golang.com/p/X5j87CqGYnb" rel="nofollow noreferrer">Playground</a></p>
[ { "answer_id": 74148842, "author": "isca", "author_id": 7322713, "author_profile": "https://Stackoverflow.com/users/7322713", "pm_score": 0, "selected": false, "text": "func main() {\n s := []int{1, 2, 3, 4, 5}\n fmt.Println(shiftEnd(s, 2))\n\n}\n\nfunc shiftEnd(s []int, x int) []i...
2022/10/21
[ "https://Stackoverflow.com/questions/74148841", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7322713/" ]
74,148,848
<p>My listUserM array looks like this:</p> <pre><code>[ { &quot;Category&quot;: &quot;BREAKFAST&quot;, &quot;Name&quot;: &quot;Sultana Bran Brekky (Single 70g)&quot;, &quot;CategoryValue&quot;: &quot;1breakfast&quot;, &quot;id&quot;: &quot;OoUFdwt6G8cbCJgzit6U&quot;, &quot;Quantity&quot;: &quot;10&quot;, &quot;Foods&quot;: [ { &quot;label&quot;: &quot;Sultana Bran (700g)&quot;, &quot;packingLocation&quot;: &quot;AA&quot;, &quot;Weight&quot;: &quot;.700&quot;, &quot;Quantity&quot;: &quot;0.10&quot;, &quot;value&quot;: &quot;SultanaBran(700g)&quot; }, { &quot;label&quot;: &quot;Chobani Pouch 100g&quot;, &quot;packingLocation&quot;: &quot;BB&quot;, &quot;value&quot;: &quot;ChobaniPouch100g&quot;, &quot;Weight&quot;: &quot;0.100&quot;, &quot;Quantity&quot;: &quot;0.50&quot; } ] }, { &quot;Category&quot;: &quot;BREAKFAST&quot;, &quot;CategoryValue&quot;: &quot;1breakfast&quot;, &quot;Foods&quot;: [ { &quot;Food&quot;: &quot;&quot;, &quot;packingLocation&quot;: &quot;BB&quot;, &quot;value&quot;: &quot;Bacon&quot;, &quot;Weight&quot;: &quot;0.400&quot;, &quot;Quantity&quot;: 1, &quot;label&quot;: &quot;Bacon&quot; }, { &quot;Quantity&quot;: &quot;4.00&quot;, &quot;Weight&quot;: &quot;.060&quot;, &quot;value&quot;: &quot;Eggs&quot;, &quot;packingLocation&quot;: &quot;AA&quot;, &quot;label&quot;: &quot;Eggs&quot; } ], &quot;Name&quot;: &quot;Bacon &amp; Eggs&quot;, &quot;id&quot;: &quot;FD3Lwb5zjZtdJR5gj3VX&quot;, } ] </code></pre> <p>What I am trying to do is loop through and calculate the totals for the Foods sub-array that match the packingLocation of &quot;BB&quot;</p> <p>I have been using this code, but I can't get it working for this sub-array:</p> <pre><code>var resSetCamperM=listUserM.filter(function(options){ return options.packingLocation == &quot;BB&quot;; }).reduce(function(a,b){ return a+parseFloat(b.Weight * b.Quantity); },0); </code></pre> <p>If I change it to:</p> <pre><code>var resSetCamperM=listUserM[0].Foods.filter(function(options){ return options.packingLocation == &quot;Camper&quot;; }).reduce(function(a,b){ return a+parseFloat(b.Weight * b.Quantity); },0); </code></pre> <p>That works - but obviously only for the first array.</p> <p>How can I loop through the Foods array and calculate the totals for packingLocation = &quot;BBB&quot;?</p>
[ { "answer_id": 74148925, "author": "Nick Vu", "author_id": 9201587, "author_profile": "https://Stackoverflow.com/users/9201587", "pm_score": 2, "selected": true, "text": "flatMap" }, { "answer_id": 74148965, "author": "Eric Fortis", "author_id": 529725, "author_profil...
2022/10/21
[ "https://Stackoverflow.com/questions/74148848", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4431969/" ]
74,148,860
<p>Do I need to initialize a git user and email each time I want to work on a new project? What if I want to continue work on an existing project? I am very new to git</p>
[ { "answer_id": 74148881, "author": "Himanshu Gabhane", "author_id": 20291681, "author_profile": "https://Stackoverflow.com/users/20291681", "pm_score": 1, "selected": false, "text": "git config --global user.name \"John Doe\"\ngit config --global user.email johndoe@example.com\n" }, ...
2022/10/21
[ "https://Stackoverflow.com/questions/74148860", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18423415/" ]
74,148,864
<p>I want to scrape a .mhtml file using bash, originally I only use curl+xidel to scrape the html file, but now the web has &quot;something&quot; that prevent me from scraping.</p> <p>this is some of the content:</p> <pre><code>QuoteStrip-watchLiveLink&quot;&gt;LIVE&lt;img src=3D&quot;https://static-redesign.cnbcfm.co= m/dist/4db8932b7ac3e84e3f64.svg&quot; alt=3D&quot;Watch live logo&quot; class=3D&quot;QuoteStri= p-watchLiveLogo&quot;&gt;&lt;/a&gt;&lt;a href=3D&quot;https://www.cnbc.com/live-tv/&quot; style=3D&quot;col= or: rgb(0, 47, 108);&quot;&gt;SHARK TANK&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=3D&quot;QuoteSt= rip-quoteStripSubHeader&quot;&gt;&lt;span&gt;RT Quote&lt;/span&gt;&lt;span&gt; | &lt;!-- --&gt;Exchange&lt;/sp= an&gt;&lt;span&gt; | &lt;!-- --&gt;USD&lt;/span&gt;&lt;/div&gt;&lt;div class=3D&quot;QuoteStrip-dataContainer&quot;= &gt;&lt;div class=3D&quot;QuoteStrip-lastTimeAndPriceContainer&quot;&gt;&lt;div class=3D&quot;QuoteStr= ip-lastTradeTime&quot;&gt;Last | 11:46 PM EDT&lt;/div&gt;&lt;div class=3D&quot;QuoteStrip-lastPri= ceStripContainer&quot;&gt;&lt;span class=3D&quot;QuoteStrip-lastPrice&quot;&gt;1,621.41&lt;/span&gt;&lt;span= class=3D&quot;QuoteStrip-changeDown&quot;&gt;&lt;img class=3D&quot;QuoteStrip-changeIcon&quot; src= =3D&quot;https://static-redesign.cnbcfm.com/dist/4ee243ff052e81044388.svg&quot; alt= =3D&quot;quote price arrow down&quot;&gt;&lt;span&gt;-6.2537&lt;/span&gt;&lt;span&gt; (&lt;!-- --&gt;-0.3842%&lt;!-= - --&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=3D&quot;PhoenixChartWrapp= </code></pre> <p>question: How can I get only <code>1,621.41</code> as output in bash?</p> <p>My regular program:</p> <pre><code>#!/bin/bash curl -s -o ~/Desktop/xau.html -- https://www.cnbc.com/quotes/XAU= gold=$(xidel -se /html/body/div[2]/div/div[1]/div[3]/div/div[2]/div[1]/div[2]/div[3]/div/div[2]/span[1] ~/Desktop/xau.html | sed 's/\,//g') echo $gold exit 0 </code></pre> <p>output: some numbers</p>
[ { "answer_id": 74148944, "author": "Renaud Pacalet", "author_id": 1773798, "author_profile": "https://Stackoverflow.com/users/1773798", "pm_score": 1, "selected": true, "text": "=\\n" }, { "answer_id": 74156614, "author": "Reino", "author_id": 2703456, "author_profile...
2022/10/21
[ "https://Stackoverflow.com/questions/74148864", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20297644/" ]
74,148,867
<p>Im trying to code a 2d game with javascript and I'm working on a position system in which if the user character overlaps the coin, a value changes. Im using .getBoundingClientRect() to get position and the function itself is fine. But anytime I add in an if statement that says if the function is true, (which it is), it gives me this error. Any ways to fix? (Attached code screenshots)</p> <p><a href="https://i.stack.imgur.com/5pTsj.png" rel="nofollow noreferrer">Code</a> <a href="https://i.stack.imgur.com/yxmsT.png" rel="nofollow noreferrer">Chrome Console Error Image</a></p>
[ { "answer_id": 74148944, "author": "Renaud Pacalet", "author_id": 1773798, "author_profile": "https://Stackoverflow.com/users/1773798", "pm_score": 1, "selected": true, "text": "=\\n" }, { "answer_id": 74156614, "author": "Reino", "author_id": 2703456, "author_profile...
2022/10/21
[ "https://Stackoverflow.com/questions/74148867", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20297674/" ]
74,148,891
<p>I use bootstrap Dropdown in React.js and I want to delete red circle area(Toggle) and show pencil icon only which use can click it.</p> <p><a href="https://i.stack.imgur.com/GdFfC.png" rel="nofollow noreferrer">enter image description here</a></p> <p>I use the following Dropdown.</p> <p><a href="https://react-bootstrap.github.io/components/dropdowns/" rel="nofollow noreferrer">https://react-bootstrap.github.io/components/dropdowns/</a></p> <p>React.js</p> <pre><code> return ( &lt;&gt; &lt;div className=&quot;&quot;&gt; &lt;Dropdown className=&quot;room_change_dropdown_top&quot;&gt; &lt;Dropdown.Toggle className='room_change_dropdown_toggle' id=&quot;dropdown-basic&quot;&gt; &lt;img className=&quot;ic_edit_in_table&quot; src={ic_edit} /&gt; &lt;/Dropdown.Toggle&gt; &lt;Dropdown.Menu className=&quot;room_change_dropdown&quot;&gt; &lt;Dropdown.Item className=&quot;room_change_dropdown_item&quot;&gt; {roomNames.map((room_names, i) =&gt; ( &lt;div className=&quot;flex_radio&quot;&gt; &lt;input className=&quot;room_change_radio&quot; type=&quot;radio&quot; value={room_names} onChange={HomeHandleChange } checked={val === room_names} /&gt; &lt;p className=&quot;drop_down_p&quot;&gt;{room_names}&lt;/p&gt; &lt;/div&gt; ))} &lt;/Dropdown.Item&gt; &lt;/Dropdown.Menu&gt; &lt;/Dropdown&gt; &lt;/div&gt; &lt;/&gt; ); } export default DropDownForRoomChange; </code></pre>
[ { "answer_id": 74148944, "author": "Renaud Pacalet", "author_id": 1773798, "author_profile": "https://Stackoverflow.com/users/1773798", "pm_score": 1, "selected": true, "text": "=\\n" }, { "answer_id": 74156614, "author": "Reino", "author_id": 2703456, "author_profile...
2022/10/21
[ "https://Stackoverflow.com/questions/74148891", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20271619/" ]
74,148,895
<p>I'm using python with the 'Spyder IDE'</p> <p>Wrote this code a week ago and when I open the file after a week, the code is giving me an indentation error. The code is meant to take a six-digit number inputted from the user and put it through a few tests using <code>if/else</code> and <code>match statements</code>.</p> <pre><code>import numpy as np code = input('Please enter a code to break: ') code = np.array(list(code),dtype=int) Sum = sum(code[:3]) Sum2 = sum(code[-3:]) # Rule 1, checks whether the user inputted code is six digits long. # if len(code) != 6: #&lt;-- Line 35 print(&quot;Decoy Message: Not a six-digit number&quot;) # Rule 2, performs requested equation and tests whether its even or odd. # else : if (Sum-Sum2) % 2 != 0: print(&quot;Decoy Message: Sum is odd&quot;) </code></pre> <p>The code doesn't ask for input from the user in the console window, but instead immediately gives an indentation error: <code>IndentationError: expected an indented block after 'if' statement on line 35</code></p> <p>Does anyone know what might be the cause? I haven't downloaded anything new since I wrote the code only a week ago.</p>
[ { "answer_id": 74148944, "author": "Renaud Pacalet", "author_id": 1773798, "author_profile": "https://Stackoverflow.com/users/1773798", "pm_score": 1, "selected": true, "text": "=\\n" }, { "answer_id": 74156614, "author": "Reino", "author_id": 2703456, "author_profile...
2022/10/21
[ "https://Stackoverflow.com/questions/74148895", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20145775/" ]
74,148,909
<p>Is there a way to load google-services.json from an API rather than copying it to the project?</p>
[ { "answer_id": 74208319, "author": "Alex Mamo", "author_id": 5246885, "author_profile": "https://Stackoverflow.com/users/5246885", "pm_score": 2, "selected": true, "text": "google-services" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74148909", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6351048/" ]
74,148,922
<p>I wanted to create a cron job that runs on first Tuesday every month and then 5 days later of first Tuesday at Night time cet.</p>
[ { "answer_id": 74148997, "author": "bn_ln", "author_id": 10535824, "author_profile": "https://Stackoverflow.com/users/10535824", "pm_score": 2, "selected": false, "text": "0 20 1-7 * 2 run_some_job\n0 20 6-12 * 0 run_some_job\n" }, { "answer_id": 74150078, "author": "Logan R...
2022/10/21
[ "https://Stackoverflow.com/questions/74148922", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20297725/" ]
74,148,926
<p>I have a Gauge chart created with Apache eCharts.</p> <p>But I am only using it for display purposes to show a &quot;website score&quot;. Therefore I want to make it non-clickable.</p> <p>How do I do that?</p> <p>At the moment the circular axis line is clickable. I want to disable that.</p> <p>Here is my code:</p> <pre class="lang-JavaScript prettyprint-override"><code>const option = { series: [ { data: gaugeData, type: 'gauge', startAngle: 90, endAngle: -270, min: 0, max: 100, progress: { show: true, width: 10, roundCap: true, }, pointer: { show: false, }, axisLine: { lineStyle: { width: 10, }, }, axisTick: { show: false, }, splitLine: { show: false, }, axisLabel: { show: false, }, title: { show: false, }, itemStyle: { color: '#ee6666', }, detail: { formatter: '{value}', color: 'auto', offsetCenter: [0, '-0%'], valueAnimation: true, fontSize: 34, }, }, ], }; </code></pre>
[ { "answer_id": 74149062, "author": "Eric Sun", "author_id": 18286518, "author_profile": "https://Stackoverflow.com/users/18286518", "pm_score": 0, "selected": false, "text": "axisLabel: {\n show: false,\n clickable: false\n},\n" }, { "answer_id": 74182388, "author": "A ...
2022/10/21
[ "https://Stackoverflow.com/questions/74148926", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1526396/" ]
74,148,941
<p>My dataset has about 14 columns which look like this</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: center;">X1</th> <th style="text-align: center;">X2</th> <th style="text-align: center;">X3</th> <th style="text-align: center;">X4</th> </tr> </thead> <tbody> <tr> <td style="text-align: center;">1,2</td> <td style="text-align: center;">1</td> <td style="text-align: center;">2,3</td> <td style="text-align: center;">1,2,3</td> </tr> <tr> <td style="text-align: center;">1</td> <td style="text-align: center;">2</td> <td style="text-align: center;">3</td> <td style="text-align: center;">1,3</td> </tr> </tbody> </table> </div> <p>I want to separate each column and the resulting data will look like this:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: center;">X1_1</th> <th style="text-align: center;">X1_2</th> <th style="text-align: center;">X1_3</th> <th style="text-align: center;">X2_1</th> <th style="text-align: center;">X2_2</th> <th style="text-align: center;">X2_3</th> <th style="text-align: center;">X3_1</th> <th style="text-align: center;">X3_2</th> <th style="text-align: center;">X3_3</th> <th style="text-align: center;">X4_1</th> <th style="text-align: center;">X4_2</th> <th style="text-align: center;">X4_3</th> </tr> </thead> <tbody> <tr> <td style="text-align: center;">1</td> <td style="text-align: center;">2</td> <td style="text-align: center;">NA</td> <td style="text-align: center;">1</td> <td style="text-align: center;">NA</td> <td style="text-align: center;">NA</td> <td style="text-align: center;">2</td> <td style="text-align: center;">3</td> <td style="text-align: center;">NA</td> <td style="text-align: center;">1</td> <td style="text-align: center;">2</td> <td style="text-align: center;">3</td> </tr> <tr> <td style="text-align: center;">1</td> <td style="text-align: center;">NA</td> <td style="text-align: center;">NA</td> <td style="text-align: center;">2</td> <td style="text-align: center;">NA</td> <td style="text-align: center;">NA</td> <td style="text-align: center;">3</td> <td style="text-align: center;">NA</td> <td style="text-align: center;">NA</td> <td style="text-align: center;">1</td> <td style="text-align: center;">3</td> <td style="text-align: center;">NA</td> </tr> </tbody> </table> </div> <p>While I can do this separately for each column one by one, its not the most efficient way. I want to know if it can be done faster for all columns in one go, using loop_if, regex, or mutate_at or any other way.</p>
[ { "answer_id": 74149040, "author": "onyambu", "author_id": 8380272, "author_profile": "https://Stackoverflow.com/users/8380272", "pm_score": 0, "selected": false, "text": "library(tidyverse)\n\ndf %>%\n mutate(across(everything(), str_split, \",\"))%>%\n unnest_wider(everything(), name...
2022/10/21
[ "https://Stackoverflow.com/questions/74148941", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20297701/" ]
74,148,943
<p>Use : nginx,gunicorn,linode for server</p> <p><strong>Debug=False</strong></p> <p>When I keep debug=False in production the css file don't get loaded.I have also build 404.html page.Suppose some one visit mydomain.com/abcd then he/she will get the 404 page which I have designed.Its good.The issue is css file not loaded.</p> <p><strong>Debug True</strong></p> <p>When I keep debug=True in the production the css file get loaded.Everything goes right.But when someone visited the mydomain.com/abcd then he/she will get the django defaualt error page.If I keep debug=True in the production everything goes right but I have heard that keeping debug=True in production is not recommended and may cause the security issues in the sites</p> <p>Currently what I have in my settings.py and nginx cofig are :</p> <p><strong>settings.py :</strong></p> <pre><code>DEBUG =True ALLOWED_HOSTS = ['ip','mydomain.com','www.mydomain.com'] </code></pre> <p><strong>Nginx config file :</strong></p> <pre><code>server { server_name mydomain.com www.mydomain.com; location = /favicon.ico { access_log off; log_not_found off; } location projectdir/static/ { autoindex on ; root /home/user/projectdir; } location / { include proxy_params; proxy_pass http://unix:/run/gunicorn.sock; } </code></pre> <p>Please help me to solve the issue,since I am struggling from past 1 week. Currently the site is live and css is loaded by keeping debug=True.But I don't want to have any security issue later.</p>
[ { "answer_id": 74149040, "author": "onyambu", "author_id": 8380272, "author_profile": "https://Stackoverflow.com/users/8380272", "pm_score": 0, "selected": false, "text": "library(tidyverse)\n\ndf %>%\n mutate(across(everything(), str_split, \",\"))%>%\n unnest_wider(everything(), name...
2022/10/21
[ "https://Stackoverflow.com/questions/74148943", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16745700/" ]
74,148,968
<p>I’ve seen some related questions but failed to find the exact solution for my problem…</p> <p>Anyway, I have an invalid symlink made like this:</p> <pre><code>mklink link path/to/dir </code></pre> <p>Meaning I’m linking to a directory <strong>without the /D flag</strong>.</p> <p>However, when I try to open the target file using the WinApi <code>CreateFile</code> it fails. Do I need to open the symlink as a file or as a directory?</p> <pre><code>CreateFile(path_to_link, 0, 0, NULL, OPEN_EXISTING, [*], NULL) </code></pre> <p>When I specify a directory at [*] the function fails (Access Denied by GetLastError(). I believe that’s because the path itself configured as a file, since I have valid permission to all relevant files).</p> <p>What do I need to put at [*] to handle <code>path/to/dir</code> ?</p> <p>Notes:</p> <ul> <li>I must handle this kind of invalid use of mklink</li> <li>My final goal is to get the absolute path of <code>path/to/dir</code>. If there is another way without <code>CreateFile</code> I’d love to hear about it:)</li> </ul>
[ { "answer_id": 74149040, "author": "onyambu", "author_id": 8380272, "author_profile": "https://Stackoverflow.com/users/8380272", "pm_score": 0, "selected": false, "text": "library(tidyverse)\n\ndf %>%\n mutate(across(everything(), str_split, \",\"))%>%\n unnest_wider(everything(), name...
2022/10/21
[ "https://Stackoverflow.com/questions/74148968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9472541/" ]
74,148,976
<p>Julia has a package for binary decision diagrams called CUDD_jll available from JuliaHub. The package is able to install and compile on the Apple M1 architecture. It does appear to install and compile on macOS v13 running Julia v1.82. But the user interface from an older package CUDD does not appear to be compatible with CUDD_jll.</p> <p>What is needed is a test or examples revealing user commands for initializing cudd, defining logical variables, and the basic operations of AND, OR, NOT.</p> <p>Does anyone have such information they will share?</p>
[ { "answer_id": 74150005, "author": "Sundar R", "author_id": 8127, "author_profile": "https://Stackoverflow.com/users/8127", "pm_score": 1, "selected": false, "text": "_jll" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74148976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4232861/" ]
74,148,988
<p>I have a dataframe &quot;result&quot; and want to create a new column called &quot;type&quot;. The value in &quot;type&quot; will be the item value of a dict if the column &quot;Particulars&quot; in the dataframe contains value of the key.</p> <pre><code>dict_classify={'key1': 'content1', 'key2':'content2' } result['type']=[dict_classify[key] if key.lower() in i.lower() else np.nan for key in dict_classify.keys() for i in result['Particulars']] </code></pre> <p>It returns the error &quot;Length of values (5200) does not match the length of index (1040)&quot;. Any idea what I did wrong?</p> <p>The following is what I want to achieve in a normal for loop. Can I make it into one line?</p> <pre><code>lst_type=[] for i in result['Particulars']: for key in dict_classify: temp=np.nan if key.lower() in i.lower(): temp=dict_classify[key] break lst_type.append(temp) result['type']=lst_type </code></pre>
[ { "answer_id": 74150314, "author": "Stuart", "author_id": 567595, "author_profile": "https://Stackoverflow.com/users/567595", "pm_score": 2, "selected": true, "text": "loc" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74148988", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7990227/" ]
74,149,007
<p>I created an <code>ArrayList</code> of <code>JButton</code>s using a <code>for</code> loop, so I don't have a specific name for each object. In the <code>actionPerformed()</code> method, I want to get the index of the button that was just pressed. Using the <code>this</code> keyword, it refers to the overall class this is defined in, not the object that was pressed.</p> <pre class="lang-java prettyprint-override"><code>public class Game implements ActionListener { public void actionPerformed(ActionEvent event) { int temp = this.buttons.indexOf(this); } } </code></pre>
[ { "answer_id": 74150314, "author": "Stuart", "author_id": 567595, "author_profile": "https://Stackoverflow.com/users/567595", "pm_score": 2, "selected": true, "text": "loc" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74149007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20297779/" ]
74,149,043
<p>I have table with two columns:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Col_1</th> <th>Col_2</th> </tr> </thead> <tbody> <tr> <td>3,4,5</td> <td>3,5</td> </tr> <tr> <td>8,9,12</td> <td>8,9,12</td> </tr> <tr> <td>8,9,12</td> <td></td> </tr> </tbody> </table> </div> <p>I need to check Col_1 with Col_2 and if an element in Col_1 is present in Col_2 then save True, else save False.</p> <p>The output table should be:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Col_1</th> <th>Col_2</th> <th>Check</th> </tr> </thead> <tbody> <tr> <td>3,4,5</td> <td>3,5</td> <td>True,False,True</td> </tr> <tr> <td>8,9,12</td> <td>8,9,12</td> <td>True,True,True</td> </tr> <tr> <td>8,9,12</td> <td></td> <td>False,False,False</td> </tr> </tbody> </table> </div>
[ { "answer_id": 74150314, "author": "Stuart", "author_id": 567595, "author_profile": "https://Stackoverflow.com/users/567595", "pm_score": 2, "selected": true, "text": "loc" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74149043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
74,149,069
<p>I am a postgres newbie and now trying to setup an external database for the application that we're developing.</p> <p>Attempt 1:</p> <p>I used our application to initialize a local postgres db and then immediately ran a pg_dump</p> <p>pg_dump -Fc -h localhost -U postgres postgres</p> <p>there was no error but things were dumped to stdin</p> <p>Attempt 2:</p> <p>I created a database with free Azure account, used our application to initialize the azure postgres db and then immediately ran the same pg_dump command then an error appeared</p> <p>pg_dump: error: query failed: ERROR: query would be affected by row-level security policy for table &quot;job&quot; pg_dump: detail: Query was: COPY cron.job (jobid, schedule, command, nodename, nodeport, database, username, active, jobname) TO stdout</p> <p>Need some input from you how can I solve the row-level security issue? Thanks</p>
[ { "answer_id": 74149437, "author": "Laurenz Albe", "author_id": 6464308, "author_profile": "https://Stackoverflow.com/users/6464308", "pm_score": 2, "selected": false, "text": "postgres" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74149069", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6774710/" ]
74,149,083
<p>I was playing around with the JavaScript objects by mutating the property values and find this observation.</p> <p><strong>Problem statement:</strong> I am mutating an object property value inside a function and returning the object but somehow it preserved the previous value and not giving the updated one.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>const obj = { prop: 5 } const mutatingObjectFunction = () =&gt; { let temp = obj.prop; obj.prop = 10; return temp; } console.log(mutatingObjectFunction()); // 5</code></pre> </div> </div> </p> <p>Why it is returning 5 and not 10?</p> <p>If I will assign directly an object instead of its property to a temp variable, then it is giving me the updated value.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>const obj = { prop: 5 } const mutatingObjectFunction = () =&gt; { let temp = obj; obj.prop = 10; return temp; } console.log(mutatingObjectFunction().prop); // 10</code></pre> </div> </div> </p> <p>Why is this behaving differently while passing a whole <code>object</code> or a object <code>property</code> in a <code>temp</code> variable ?</p>
[ { "answer_id": 74149437, "author": "Laurenz Albe", "author_id": 6464308, "author_profile": "https://Stackoverflow.com/users/6464308", "pm_score": 2, "selected": false, "text": "postgres" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74149083", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4116300/" ]
74,149,108
<p>How can I convert this array to this object?</p> <pre><code>const arr = [ 'key_1', 'text_key_1', 'key_2', 'text_key_2', 'key_3', 'text_key_3', 'key_4', 'text_key_4', ] </code></pre> <pre><code>const object = { key_1: 'text_key_1', key_2: 'text_key_2', key_3: 'text_key_3', key_4: 'text_key_4', } </code></pre> <blockquote> <p>I'm trying with Reduce but without success</p> </blockquote>
[ { "answer_id": 74149190, "author": "Hakier", "author_id": 2193996, "author_profile": "https://Stackoverflow.com/users/2193996", "pm_score": 0, "selected": false, "text": "const arr = [\n 'key_1', 'text_key_1',\n 'key_2', 'text_key_2',\n 'key_3', 'text_key_3',\n 'key_4', 'text_key_4',...
2022/10/21
[ "https://Stackoverflow.com/questions/74149108", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13836000/" ]
74,149,193
<p>I'm trying to use $GITHUB_OUTPUT instead of set-output.</p> <p>I set up a simple GitHub Action with a docker file based on the official tutorial.</p> <pre><code># Container image that runs your code FROM alpine:latest # Copies your code file from your action repository to the filesystem path `/` of the container COPY entrypoint.sh /entrypoint.sh # Code file to execute when the docker container starts up (`entrypoint.sh`) ENTRYPOINT [&quot;/entrypoint.sh&quot;] </code></pre> <p>And the entrypoint.sh is</p> <pre><code>#!/bin/sh -l time=$(date) echo &quot;time=$time&quot; &gt;&gt; $GITHUB_OUTPUT </code></pre> <p>Executing this in a Self hosted Debian runner results into a</p> <pre><code>/entrypoint.sh: 4: cannot create : Directory nonexistent </code></pre> <p>Changing the $GITHUB_OUTPUT with the usual ::set-output works correctly.</p> <p>Any idea on how to solve this?</p>
[ { "answer_id": 74553754, "author": "David Nugent", "author_id": 1956886, "author_profile": "https://Stackoverflow.com/users/1956886", "pm_score": 0, "selected": false, "text": "echo \"::set-output...\"" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74149193", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16459744/" ]
74,149,309
<p>I'm currently trying to monitor the <strong>EKS Node group status</strong>, sometimes my node groups show <strong>degraded</strong> and I want a <strong>CloudWatch</strong> alert whenever the status is in a Degraded state, I checked CloudWatch Metrics there are no standard metrics, and even I'm unable to find the event in Cloud trail,</p> <p><a href="https://i.stack.imgur.com/W02Iw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/W02Iw.png" alt="enter image description here" /></a></p> <p>Is there any possibility's to creating the alarm using <strong>AWS Cloud trail events, Event bridge, or CloudWatch</strong> Kindly help to find the solution for this</p>
[ { "answer_id": 74553754, "author": "David Nugent", "author_id": 1956886, "author_profile": "https://Stackoverflow.com/users/1956886", "pm_score": 0, "selected": false, "text": "echo \"::set-output...\"" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74149309", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9449478/" ]
74,149,319
<p>I have a tree with data structure:</p> <pre><code>root: { children:[ {children: [ {children:[]} ]}, {children: []} ] } </code></pre> <p>Here is example of tree where the result should be 4(maximum width)</p> <pre><code> R / | \ A B X / \ / \ C D E F \ G </code></pre>
[ { "answer_id": 74553754, "author": "David Nugent", "author_id": 1956886, "author_profile": "https://Stackoverflow.com/users/1956886", "pm_score": 0, "selected": false, "text": "echo \"::set-output...\"" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74149319", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10161976/" ]
74,149,330
<pre class="lang-golang prettyprint-override"><code>package main import ( &quot;bufio&quot; &quot;os&quot; ) func main() { bw := bufio.NewWriter(os.Stdin) bw2 := bufio.NewWriter(os.Stdout) bw.WriteString(&quot;Hello, world 1\n&quot;) bw2.WriteString(&quot;Hello, world 2\n&quot;) bw.Flush() bw2.Flush() } </code></pre> <p>This code show both string in a local environment. But why does it work differently in different environments?</p> <p>My local environment OS : macOS 12.6 go : go1.19.2 darwin/amd64 ide : vscode</p> <ul> <li>on my local machine :</li> </ul> <pre><code>$ go run myworkspace/main/main.go Hello, world 1 Hello, world 2 </code></pre> <ul> <li>on the playground :</li> </ul> <pre><code># in the 'Output' section --- Hello, world 2 Program exited. </code></pre>
[ { "answer_id": 74553754, "author": "David Nugent", "author_id": 1956886, "author_profile": "https://Stackoverflow.com/users/1956886", "pm_score": 0, "selected": false, "text": "echo \"::set-output...\"" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74149330", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18607397/" ]