qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,199,011
<p>I have a database called player.db</p> <p>These database has two tables.</p> <p>The tables called person and the other is called match.</p> <p>person table is</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Player_ID</th> <th>Player</th> <th>Country</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>Lionel Messi</td> <td>Argentina</td> </tr> <tr> <td>2</td> <td>Luis Suarez</td> <td>Uruguay</td> </tr> <tr> <td>3</td> <td>Neymar</td> <td>Brazil</td> </tr> </tbody> </table> </div> <p>match table is</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Match _ID</th> <th>Game</th> <th>Player_ID</th> <th>Date</th> <th>Season</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>Uruguay-Paraguay</td> <td>2</td> <td>5/3/2019</td> <td>1</td> </tr> <tr> <td>2</td> <td>Uruguay-Chile</td> <td>2</td> <td>19/3/2019</td> <td>1</td> </tr> <tr> <td>3</td> <td>Argentina-Chile</td> <td>1</td> <td>22/3/2019</td> <td>1</td> </tr> <tr> <td>4</td> <td>Brazil-Guyana</td> <td>3</td> <td>3/4/2019</td> <td>1</td> </tr> <tr> <td>5</td> <td>Brazil-USA</td> <td>3</td> <td>1/6/2020</td> <td>2</td> </tr> <tr> <td>6</td> <td>Brazil-Belize</td> <td>3</td> <td>3/7/2020</td> <td>2</td> </tr> <tr> <td>7</td> <td>Brazil-Suriname</td> <td>3</td> <td>5/7/2020</td> <td>2</td> </tr> <tr> <td>8</td> <td>Argentina-USA</td> <td>1</td> <td>8/8/2020</td> <td>2</td> </tr> <tr> <td>9</td> <td>Argentina-Canada</td> <td>1</td> <td>3/3/2021</td> <td>3</td> </tr> <tr> <td>10</td> <td>Argentina-Grenada</td> <td>1</td> <td>8/3/2021</td> <td>3</td> </tr> <tr> <td>11</td> <td>Uruguay-Suriname</td> <td>2</td> <td>7/4/2021</td> <td>3</td> </tr> <tr> <td>12</td> <td>Uruguay-Mexico</td> <td>2</td> <td>2/2/2022</td> <td>4</td> </tr> <tr> <td>13</td> <td>Uruguay-Jamaica</td> <td>2</td> <td>4/2/2022</td> <td>4</td> </tr> <tr> <td>14</td> <td>Brazil-Ecuador</td> <td>3</td> <td>5/2/2022</td> <td>4</td> </tr> </tbody> </table> </div> <p>My pivot table should look like these:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Season</th> <th>Player</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>Luis Suarez</td> </tr> <tr> <td>2</td> <td>Neymar</td> </tr> <tr> <td>3</td> <td>Lionel Messi</td> </tr> <tr> <td>4</td> <td>Luis Suarez</td> </tr> </tbody> </table> </div> <p>I want a sql code which create a pivot table which shows which player played most with topscore in which season year. For example Luis Suarez occured most in season 1.</p> <p>I started coding in sql, but got not the desired solution</p> <pre><code>SELECT Player_ID, COUNT(*)FROM match GROUP BY Player_ID HAVING COUNT(*) max </code></pre> <p>The problem is I got an error and it doesn't create a pivot table which show which player played most in which season.</p>
[ { "answer_id": 74199231, "author": "Gus", "author_id": 535515, "author_profile": "https://Stackoverflow.com/users/535515", "pm_score": 0, "selected": false, "text": "invalidInputs" }, { "answer_id": 74199290, "author": "IamGroot", "author_id": 8327330, "author_profile...
2022/10/25
[ "https://Stackoverflow.com/questions/74199011", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
74,199,016
<p>I tried to implement merge sort using C++, however, something went wrong. I have no idea what is wrong.</p> <p>The following code is what I wrote based on CLRS. I think it is quite easy to understand the meaning.</p> <pre><code>#include &lt;iostream&gt; #include &lt;vector&gt; using namespace std; void merge(vector&lt;int&gt;&amp; nums, int p, int q, int r); void mergeSort(vector&lt;int&gt;&amp; nums, int p, int r){ if (p &lt; r) { int q = (p + r) / 2; mergeSort(nums, p, q); mergeSort(nums, q + 1, r); merge(nums, p, q, r); } } void merge(vector&lt;int&gt;&amp; nums, int p, int q, int r) { int s1 = p, s2 = q + 1; vector&lt;int&gt; l1, l2; for (int i = s1; i &lt;= q; i++) { l1.push_back(nums[i]); } for (int i = s2; i &lt;= r; i++) { l2.push_back(nums[i]); } int left = 0, right = 0; int idx = 0; while (left &lt; l1.size() &amp;&amp; right &lt; l2.size()) { if (l1[left] &lt; l2[right]) { nums[idx] = l1[left++]; } else { nums[idx] = l2[right++]; } idx++; } while (left &lt; l1.size()) { nums[idx++] = l1[left++]; } while (right &lt; l2.size()) { nums[idx++] = l2[right++]; } } int main() { vector&lt;int&gt; vect; vect.push_back(1); vect.push_back(3); vect.push_back(12); vect.push_back(23); vect.push_back(4); vect.push_back(11); vect.push_back(44); vect.push_back(322); mergeSort(vect, 0, vect.size() - 1); for (int i = 0; i &lt; vect.size(); i++) { cout &lt;&lt; vect[i] &lt;&lt; endl; } return 0; } </code></pre> <p>I want to use the program to sort some integers, however, it only shows many duplicate numbers. What's going on? I don't think there is a problem of the merge function.</p>
[ { "answer_id": 74199231, "author": "Gus", "author_id": 535515, "author_profile": "https://Stackoverflow.com/users/535515", "pm_score": 0, "selected": false, "text": "invalidInputs" }, { "answer_id": 74199290, "author": "IamGroot", "author_id": 8327330, "author_profile...
2022/10/25
[ "https://Stackoverflow.com/questions/74199016", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12248990/" ]
74,199,050
<p>Matrix is like</p> <pre><code>[0, 1, 2] [1, 2, 3] [2, 3, 4] </code></pre> <p>For clarification, it's not just to create one such matrix but many other different matrices like this.</p> <pre><code>[0, 1, 2, 3] [1, 2, 3, 4] [2, 3, 4, 5] </code></pre>
[ { "answer_id": 74199112, "author": "Andrey", "author_id": 283676, "author_profile": "https://Stackoverflow.com/users/283676", "pm_score": 0, "selected": false, "text": "L = 3\nnp.array([\n np.array(range(L)) + j\n for j in range(L)\n])\n" }, { "answer_id": 74199261, "auth...
2022/10/25
[ "https://Stackoverflow.com/questions/74199050", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20326376/" ]
74,199,055
<p>I want to be able to show 2 lines of captions/subtitles on a youtube video using the youtube timed text (.ytt) format</p> <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt; &lt;timedtext format=&quot;3&quot;&gt; &lt;head&gt; &lt;wp id=&quot;0&quot; ap=&quot;0&quot; ah=&quot;0&quot; av=&quot;0&quot; /&gt; &lt;ws id=&quot;0&quot; ju=&quot;0&quot; pd=&quot;0&quot; sd=&quot;0&quot; /&gt; &lt;pen id=&quot;0&quot; sz=&quot;100&quot; fs=&quot;0&quot; /&gt; &lt;/head&gt; &lt;body&gt; &lt;p t=&quot;1&quot; d=&quot;4988&quot; wp=&quot;0&quot; ws=&quot;0&quot;&gt;&lt;s&gt;&lt;/s&gt;&lt;s p=&quot;0&quot;&gt;​ ROW 1: XXXXXXXXXX &lt;/s&gt; &lt;s p=&quot;0&quot;&gt; ​​ROW 2: XXXXXXXXXX &lt;/s&gt;&lt;/p&gt; &lt;/body&gt;&lt;/timedtext&gt; </code></pre> <p>The caption shows correctly with the background box aligned: <a href="https://i.stack.imgur.com/UKLdY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UKLdY.png" alt="enter image description here" /></a></p> <p>However, as soon as I change the font to fs=&quot;1&quot; (mono space) or add a color fc=&quot;#FF0000&quot; the background boxes shift. <a href="https://i.stack.imgur.com/Hs921.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Hs921.png" alt="enter image description here" /></a></p> <p>Is there another way to add the 2 lines of paragraphs to keep the background box aligned? Btw, I'm using the ytt format instead of the ttml format because I need to be able to set the font to monospace and add a font color.</p>
[ { "answer_id": 74199112, "author": "Andrey", "author_id": 283676, "author_profile": "https://Stackoverflow.com/users/283676", "pm_score": 0, "selected": false, "text": "L = 3\nnp.array([\n np.array(range(L)) + j\n for j in range(L)\n])\n" }, { "answer_id": 74199261, "auth...
2022/10/25
[ "https://Stackoverflow.com/questions/74199055", "https://Stackoverflow.com", "https://Stackoverflow.com/users/686654/" ]
74,199,058
<p>I have this sample logs data in a list</p> <pre><code>data = [&quot;[2022-08-15 17:42:32,436: INFO/MainProces] lorqw q addadasdasdasdad&quot;, &quot;2022-10-24T13:29:50.579Z dasdadasdasdadadadadaddada&quot;, &quot;asdadadad adasdas3453 454234 fsdf53&quot;, &quot;Mon, 24 Oct 2022 13:29:48 GMT express:router expressInit : /health&quot;, 'time=&quot;2022-10-24T13:29:12Z&quot; level=error msg=&quot;checking config status failed: sdadasd&quot;', &quot;2022/10/24 13:29:15 [error] 234 ssdfsd 435345&quot;] </code></pre> <p>what I tried so far to print the item if the date is exist along with it's index</p> <pre><code>for index, elem in enumerate(data): if ']' and '[' in elem: print(f'Date found at index: {index}') </code></pre> <p>current output:</p> <pre><code>Date found at index: 0 Date found at index: 5 </code></pre> <p>Expected Output:</p> <pre><code>Date found at index: 0 Date found at index: 1 Date found at index: 3 Date found at index: 4 Date found at index: 5 </code></pre>
[ { "answer_id": 74199112, "author": "Andrey", "author_id": 283676, "author_profile": "https://Stackoverflow.com/users/283676", "pm_score": 0, "selected": false, "text": "L = 3\nnp.array([\n np.array(range(L)) + j\n for j in range(L)\n])\n" }, { "answer_id": 74199261, "auth...
2022/10/25
[ "https://Stackoverflow.com/questions/74199058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15749060/" ]
74,199,062
<p>I guess this can be a pretty good question, however I have a feeling that the answer can be also pretty much simple.</p> <p>So, let's suppose I have a HTTP POST endpoint which receives from an external source a <strong>form</strong> in the payload.</p> <pre><code>[HttpPost] public ActionResult MyExample([FromForm] ExampleModel formModel) </code></pre> <p>My external source does not follow any standard naming convention, therefore, I can't rely on a simple equivalent &quot;SerializerOptions&quot;. So, the solution now would be manually set the property name I'm receiving.</p> <p>If I have a record <strong>ExampleModel</strong>, how could I set the property tag so that <strong>MVC [FromForm]</strong> magic mapping could handle it?</p> <pre><code>public record ExampleModel([property: ????] string MyProperty) </code></pre> <p>I can create a specific record or class with the exact name from the payload. That would be the easiest solution, but I'm trying to see if there is another way to not force my property to be wrongly named also.</p>
[ { "answer_id": 74199112, "author": "Andrey", "author_id": 283676, "author_profile": "https://Stackoverflow.com/users/283676", "pm_score": 0, "selected": false, "text": "L = 3\nnp.array([\n np.array(range(L)) + j\n for j in range(L)\n])\n" }, { "answer_id": 74199261, "auth...
2022/10/25
[ "https://Stackoverflow.com/questions/74199062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8846001/" ]
74,199,082
<p>I was trying to iterate over a list of values, craft a dictionary to save each value in a structured way, and then append the dictionary to a new list of results, but I found an unexpected behavior.</p> <p>Below is an example:</p> <pre class="lang-py prettyprint-override"><code>values_list = [1,2,3] # Basic dict result_dict = { 'my_value': '' } # Iterate, craft a dictionary, and append result dicts_list = [] for value in values_list: result_dict.update({'my_value': value}) dicts_list.append(result_dict) print(dicts_list) </code></pre> <p>As you can see, first I create a basic dictionary, then I'm iterating over the list of values and updating the dictionary, at the end I'm appending the crafted dictionary to a separate list of results (<em>dicts_list</em>).</p> <p>As a result I was expecting:</p> <pre class="lang-py prettyprint-override"><code>[{'my_value': 1}, {'my_value': 2}, {'my_value': 3}] </code></pre> <p>but instead I was getting:</p> <pre class="lang-py prettyprint-override"><code>[{'my_value': 3}, {'my_value': 3}, {'my_value': 3}] </code></pre> <p>It looks like every iteration is not only updating the basic dictionary – which is expected – but also the dictionaries already appended to the list of results on the previous iteration.</p> <p>To fix the issue, I nested the basic dictionary under the for loop:</p> <pre class="lang-py prettyprint-override"><code>values_list = [1,2,3] # Iterate, craft a dictionary, and append result dicts_list = [] for value in values_list: result_dict = {'my_value': ''} result_dict.update({'my_value': value}) dicts_list.append(result_dict) print(dicts_list) </code></pre> <p>Can anyone explain what is wrong with the first approach? How is the loop causing the list of appended dictionaries to be updated?</p> <p>Thanks for any advice! :)</p> <p>Franz</p>
[ { "answer_id": 74199252, "author": "isCzech", "author_id": 20188124, "author_profile": "https://Stackoverflow.com/users/20188124", "pm_score": 1, "selected": false, "text": "update()" } ]
2022/10/25
[ "https://Stackoverflow.com/questions/74199082", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11188096/" ]
74,199,117
<p>I am a novice at this, but I've been trying to scrape data on a website (<a href="https://awards.decanter.com/DWWA/2022/search/wines?competitionType=DWWA" rel="nofollow noreferrer">https://awards.decanter.com/DWWA/2022/search/wines?competitionType=DWWA</a>) but I keep coming up empty. I've tried BeautifulSoup and Scrapy but I can't get the text out.</p> <p>Eventually I want to get the row of each individual wine in the table into a dataframe/csv (from all pages) but currently I can't even get the first wine producer name.</p> <p>If you inspect the webpage all the details are in tags with no id or class.</p> <p>My BeautifulSoup attempt</p> <pre><code>URL = 'https://awards.decanter.com/DWWA/2022/search/wines?competitionType=DWWA' headers = {&quot;User-Agent&quot;: &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) \ Chrome/106.0.0.0 Safari/537.36 Edg/106.0.1370.52&quot;} page = requests.get(URL, headers=headers) soup = BeautifulSoup(page.content, &quot;html.parser&quot;) soup2 = soup.prettify() producer = soup2.find_all('td').get_text() print(producer) </code></pre> <p>Which is throwing the error:</p> <pre><code>producer = soup2.find_all('td').get_text() AttributeError: 'str' object has no attribute 'find_all' </code></pre> <p>My Scrapy attempt</p> <pre><code>winedf = pd.DataFrame() class WineSpider(scrapy.Spider): name = 'wine_spider' def start_requests(self): dwwa_url = &quot;https://awards.decanter.com/DWWA/2022/search/wines?competitionType=DWWA&quot; yield scrapy.Request(url=dwwa_url, callback=self.parse_front) def parse_front(self, response): table = response.xpath('//*[@id=&quot;root&quot;]/div/div[2]/div[4]/div[2]/table') page_links = table.xpath('//*[@id=&quot;root&quot;]/div/div[2]/div[4]/div[2]/div[2]/div[1]/ul/li[3]/a(@class,\ &quot;dwwa-page-link&quot;) @href') links_to_follow = page_links.extract() for url in links_to_follow: yield response.follow(url=url, callback=self.parse_pages) def parse_pages(self, response): wine_name = Selector(response=response).xpath('//*[@id=&quot;root&quot;]/div/div[2]/div[4]/div[2]/table/tbody/\ tr[1]/td[1]/text()').get() wine_name_ext = wine_name.extract().strip() winedf.append(wine_name_ext) medal = Selector(response=response).xpath('//*[@id=&quot;root&quot;]/div/div[2]/div[4]/div[2]/table/tbody/tr[1]/\ td[4]/text()').get() medal_ext = medal.extract().strip() winedf.append(medal_ext) </code></pre> <p>Which produces and empty df.</p> <p>Any help would be greatly appreciated.</p> <p>Thank you!</p>
[ { "answer_id": 74199232, "author": "Andrej Kesely", "author_id": 10035985, "author_profile": "https://Stackoverflow.com/users/10035985", "pm_score": 2, "selected": true, "text": "import pandas as pd\n\nurl = \"https://decanterresultsapi.decanter.com/api/DWWA/2022/wines/search?competition...
2022/10/25
[ "https://Stackoverflow.com/questions/74199117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20031026/" ]
74,199,145
<p>I am trying to do a formula for:</p> <ul> <li><strong>NUMBER OF SHARES</strong> per sector - should count all shares from column <strong>E:E</strong> in column <strong>I:I</strong> based on <strong>sector</strong></li> </ul> <p><a href="https://i.stack.imgur.com/LmhPD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LmhPD.png" alt="enter image description here" /></a></p> <p><strong>TABLE:</strong></p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>SYMBOL</th> <th>NAME</th> <th>TYPE</th> <th>SECTOR</th> <th>OWNED SHARES</th> <th>SHARES PRICE</th> <th></th> <th>SECTOR</th> <th>NUMBER OF SHARES</th> <th>TOTAL PER SECTOR</th> <th></th> <th>TYPE</th> <th>TOTAL PER STOCK TYPE</th> </tr> </thead> <tbody> <tr> <td>ABML</td> <td>American Battery Technology Co</td> <td>Growth</td> <td>-</td> <td>100</td> <td>79</td> <td></td> <td>-</td> <td></td> <td></td> <td></td> <td>Growth</td> <td></td> </tr> <tr> <td>BABA</td> <td>Alibaba Group Holding Ltd - ADR</td> <td>Growth</td> <td>Consumer Cyclical</td> <td>200</td> <td>12574</td> <td></td> <td>Consumer Cyclical</td> <td></td> <td></td> <td></td> <td>Dividend</td> <td></td> </tr> <tr> <td>BAC</td> <td>Alibaba Group Holding Ltd - ADR</td> <td>Dividend</td> <td>Financial</td> <td>1000</td> <td>35460</td> <td></td> <td>Financial</td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>LI</td> <td>Li Auto Inc</td> <td>Growth</td> <td>Consumer Cyclical</td> <td>300</td> <td>4791</td> <td></td> <td>Energy</td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>MMP</td> <td>Magellan Midstream Partners, L.P.</td> <td>Dividend</td> <td>Energy</td> <td>10000</td> <td>515700</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>MPLX</td> <td>MPLX LP</td> <td>Dividend</td> <td>Energy</td> <td>20000</td> <td>662000</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> </tbody> </table> </div> <p><strong>DEMO</strong></p> <p><a href="https://docs.google.com/spreadsheets/d/1sBVb29p0yYcn3-CI3TvG6noN8AQPE2zxDCKojUcb2Nw/edit?usp=sharing" rel="nofollow noreferrer">https://docs.google.com/spreadsheets/d/1sBVb29p0yYcn3-CI3TvG6noN8AQPE2zxDCKojUcb2Nw/edit?usp=sharing</a></p> <p>Thank you</p> <p>I tried <code>=sumif(D:D; H2; F:F)</code> it works, but I wanted this function to be repeated for every value in column <strong>H</strong> once there is a new value.</p>
[ { "answer_id": 74199232, "author": "Andrej Kesely", "author_id": 10035985, "author_profile": "https://Stackoverflow.com/users/10035985", "pm_score": 2, "selected": true, "text": "import pandas as pd\n\nurl = \"https://decanterresultsapi.decanter.com/api/DWWA/2022/wines/search?competition...
2022/10/25
[ "https://Stackoverflow.com/questions/74199145", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6416833/" ]
74,199,158
<p>So on desktop I want 4 columns with an image above the text like the first image (so col-3), very easy. (I have the image and text in the same col)</p> <p><a href="https://i.stack.imgur.com/JFida.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JFida.png" alt="enter image description here" /></a></p> <p>but on mobile I want the icon appear on the left and the text on the right as per the second image.</p> <p><a href="https://i.stack.imgur.com/lxTfR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lxTfR.png" alt="enter image description here" /></a></p> <p>i have tried floating the image lleft and the text right but that doesnt work I tried splitting the image and the text but they won't line up properly on all screen sizes if i do. This feels like it should be so easy but my brain is stuck.</p>
[ { "answer_id": 74207595, "author": "satira", "author_id": 6165223, "author_profile": "https://Stackoverflow.com/users/6165223", "pm_score": 2, "selected": true, "text": "col" } ]
2022/10/25
[ "https://Stackoverflow.com/questions/74199158", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2820910/" ]
74,199,165
<p>I have an object called _test shaped in the below form where the first element is id and the second is name:</p> <pre><code>&quot;_test&quot;: [ {id:1, name:andy},{id:2, name:james}, {id:3, name:mike} ] </code></pre> <p>I then have another field called key. the values that key takes on can equal values of id in the subs</p> <pre><code>key </code></pre> <p>I currently use</p> <pre><code>_test.flatMap( c =&gt; c.id).find(elem =&gt; elem == key) || null </code></pre> <p>How can I get this to return the name? I'm at a loss and having a major brain fart.</p>
[ { "answer_id": 74199218, "author": "Mr. Polywhirl", "author_id": 1762224, "author_profile": "https://Stackoverflow.com/users/1762224", "pm_score": 0, "selected": false, "text": "id" }, { "answer_id": 74199230, "author": "Prince Hernandez", "author_id": 6476488, "autho...
2022/10/25
[ "https://Stackoverflow.com/questions/74199165", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16470370/" ]
74,199,173
<p>I have two dictionaries:</p> <pre><code>dict1 = { 'Argentina': ['Buenos Aires'], 'Bangladesh': ['Dhaka'], 'Brazil': ['São Paulo', 'Rio de Janeiro'] dict2 = { 1392685764: 'Tokyo', 1356226629: 'Mumbai', 1156073548: 'Shanghai', 1484247881: 'Mexico City', 1156237133: 'Guangzhou', 1818253931: 'Cairo', 1156228865: 'Beijing', 1840034016: 'New York', 1643318494: 'Moscow', 1764068610: 'Bangkok', 1050529279: 'Dhaka', 1032717330: 'Buenos Aires'} </code></pre> <p>I would like to check that the nested values in dict1 have any elements in common with values in dict2. I've been doing this <a href="https://stackoverflow.com/questions/3210832/pythonic-way-to-check-if-two-dictionaries-have-the-identical-set-of-keys">source</a>:</p> <pre><code>def f(d1, d2, id, country): return set(d1.values()) == set(d2.values()) </code></pre> <p>So, when the function is called with arguments dict1, dict2, country=Argentina and id=1032717330 returns True.</p> <p>But the result is always an TypeError. Any help will be appreciate.</p>
[ { "answer_id": 74199246, "author": "ShlomiF", "author_id": 5024514, "author_profile": "https://Stackoverflow.com/users/5024514", "pm_score": 1, "selected": false, "text": "dict1" }, { "answer_id": 74199250, "author": "trisha", "author_id": 15185160, "author_profile": ...
2022/10/25
[ "https://Stackoverflow.com/questions/74199173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15204667/" ]
74,199,174
<p>I would like to know if there is a way to negate a random fraction of the values in a single column based on the values in another column in R. In the example dataframe below, I'd like to be able to randomly select 10% of the exposure values to be the same magnitude, but negative values, but only for the rows that have &quot;Toy&quot; listed as an object.</p> <pre><code>df &lt;- data.frame(ChildID=c(&quot;M1&quot;, &quot;F1&quot;, &quot;F1&quot;, &quot;F2&quot;, &quot;M2&quot;, &quot;M3&quot;, &quot;M3&quot;, &quot;M3&quot;, &quot;M3&quot;, &quot;F3&quot;, &quot;F1&quot;, &quot;F2&quot;, &quot;M2&quot;, &quot;M3&quot;), object=c(&quot;Mouth&quot;, &quot;Toy&quot;, &quot;Mouth&quot;, &quot;Toy&quot;, &quot;Toy&quot;, &quot;Toy&quot;, &quot;Mouth&quot;, &quot;Toy&quot;, &quot;Toy&quot;, &quot;Mouth&quot;, &quot;Toy&quot;, &quot;Toy&quot;, &quot;Toy&quot;, &quot;Toy&quot;), exposure=c(0.1, 0.2, 0.1, 0.05, 0.6, 0.1, 0.4, 0.1, 1.0, 0.5, 0.1, 0.4, 0.1, 1.0)) </code></pre> <p>Here's what I would like the result to look like, for example.</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Child ID</th> <th>object</th> <th>exposure</th> </tr> </thead> <tbody> <tr> <td>M1</td> <td>Mouth</td> <td>0.1</td> </tr> <tr> <td>F1</td> <td>Toy</td> <td>0.2</td> </tr> <tr> <td>F1</td> <td>Mouth</td> <td>0.1</td> </tr> <tr> <td>F2</td> <td>Toy</td> <td>0.05</td> </tr> <tr> <td>M2</td> <td>Toy</td> <td>-0.6</td> </tr> <tr> <td>M3</td> <td>Toy</td> <td>0.1</td> </tr> <tr> <td>M3</td> <td>Mouth</td> <td>0.4</td> </tr> <tr> <td>M3</td> <td>Toy</td> <td>0.1</td> </tr> <tr> <td>M3</td> <td>Toy</td> <td>1.0</td> </tr> <tr> <td>F3</td> <td>Mouth</td> <td>0.5</td> </tr> <tr> <td>F1</td> <td>Toy</td> <td>0.1</td> </tr> <tr> <td>F2</td> <td>Toy</td> <td>0.4</td> </tr> <tr> <td>M2</td> <td>Toy</td> <td>0.1</td> </tr> <tr> <td>M3</td> <td>Toy</td> <td>1.0</td> </tr> </tbody> </table> </div> <p>I tried using dplyr, but I can't filter it because that removes the other rows that I don't want to mutate. I realize this is a basic question, but I'm pulling my hair out trying to find the right work around. Thanks so much!</p>
[ { "answer_id": 74199333, "author": "AndS.", "author_id": 9778513, "author_profile": "https://Stackoverflow.com/users/9778513", "pm_score": 1, "selected": false, "text": "filter" }, { "answer_id": 74199418, "author": "tmfmnk", "author_id": 5964557, "author_profile": "h...
2022/10/25
[ "https://Stackoverflow.com/questions/74199174", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19981418/" ]
74,199,207
<p>I have a list of nodes for which I need to compute a total then sum said total as a group. I have created the appropriate variables but when I use a sum() as my final output, it produces a concatenated string as opposed to a total value.</p> <p>Here is the input XML:</p> <pre class="lang-xml prettyprint-override"><code>&lt;LineItems&gt; &lt;LineItem&gt; &lt;OrderLine&gt; &lt;OrderQty&gt;1&lt;/OrderQty&gt; &lt;UnitPrice&gt;105.28&lt;/UnitPrice&gt; &lt;UnitPriceBasis&gt;UM&lt;/UnitPriceBasis&gt; &lt;/OrderLine&gt; &lt;LineItem&gt; &lt;OrderLine&gt; &lt;OrderQty&gt;75&lt;/OrderQty&gt; &lt;UnitPrice&gt;2.88&lt;/UnitPrice&gt; &lt;UnitPriceBasis&gt;UM&lt;/UnitPriceBasis&gt; &lt;/OrderLine&gt; &lt;/LineItem&gt; &lt;LineItem&gt; &lt;OrderLine&gt; &lt;OrderQty&gt;3&lt;/OrderQty&gt; &lt;UnitPrice&gt;155.36&lt;/UnitPrice&gt; &lt;UnitPriceBasis&gt;UM&lt;/UnitPriceBasis&gt; &lt;/OrderLine&gt; &lt;/LineItem&gt; &lt;LineItem&gt; &lt;OrderLine&gt; &lt;OrderQty&gt;12&lt;/OrderQty&gt; &lt;UnitPrice&gt;1.64&lt;/UnitPrice&gt; &lt;UnitPriceBasis&gt;UM&lt;/UnitPriceBasis&gt; &lt;/OrderLine&gt; &lt;/LineItem&gt; &lt;LineItem&gt; &lt;OrderLine&gt; &lt;OrderQty&gt;2&lt;/OrderQty&gt; &lt;UnitPrice&gt;2.28&lt;/UnitPrice&gt; &lt;UnitPriceBasis&gt;UM&lt;/UnitPriceBasis&gt; &lt;/OrderLine&gt; &lt;/LineItem&gt; &lt;LineItem&gt; &lt;OrderLine&gt; &lt;OrderQty&gt;5&lt;/OrderQty&gt; &lt;UnitPrice&gt;3.6&lt;/UnitPrice&gt; &lt;UnitPriceBasis&gt;UM&lt;/UnitPriceBasis&gt; &lt;/OrderLine&gt; &lt;/LineItem&gt; &lt;LineItem&gt; &lt;OrderLine&gt; &lt;OrderQty&gt;1&lt;/OrderQty&gt; &lt;UnitPrice&gt;405.24&lt;/UnitPrice&gt; &lt;UnitPriceBasis&gt;UM&lt;/UnitPriceBasis&gt; &lt;/OrderLine&gt; &lt;/LineItem&gt; &lt;LineItem&gt; &lt;OrderLine&gt; &lt;OrderQty&gt;5&lt;/OrderQty&gt; &lt;UnitPrice&gt;79.04&lt;/UnitPrice&gt; &lt;UnitPriceBasis&gt;UM&lt;/UnitPriceBasis&gt; &lt;/OrderLine&gt; &lt;/LineItem&gt; &lt;LineItem&gt; &lt;OrderLine&gt; &lt;OrderQty&gt;1&lt;/OrderQty&gt; &lt;UnitPrice&gt;2.15&lt;/UnitPrice&gt; &lt;UnitPriceBasis&gt;UM&lt;/UnitPriceBasis&gt; &lt;/OrderLine&gt; &lt;/LineItem&gt; &lt;LineItem&gt; &lt;OrderLine&gt; &lt;OrderQty&gt;9&lt;/OrderQty&gt; &lt;UnitPrice&gt;2.15&lt;/UnitPrice&gt; &lt;UnitPriceBasis&gt;UM&lt;/UnitPriceBasis&gt; &lt;/OrderLine&gt; &lt;/LineItem&gt; &lt;/LineItems&gt; </code></pre> <p>And here is what I have been using thus far:</p> <pre class="lang-xml prettyprint-override"><code>&lt;tpi:Fact name=&quot;TotalLinePrice&quot; factType=&quot;Virtual&quot;&gt; &lt;xsl:for-each-group select=&quot;/PurchaseOrder/LineItems/LineItem/OrderLine&quot; group-starting-with=&quot;OrderLine[normalize-space(OrderQty)]&quot;&gt; &lt;xsl:variable name=&quot;uPrice&quot; as=&quot;node()*&quot;&gt; &lt;xsl:for-each select=&quot;current-group()&quot;&gt; &lt;xsl:variable name=&quot;unitPrice&quot;&gt; &lt;xsl:copy-of select=&quot;xs:decimal(current-group()/UnitPrice)&quot;/&gt; &lt;/xsl:variable&gt; &lt;xsl:variable name=&quot;orderQty&quot;&gt; &lt;xsl:copy-of select=&quot;xs:decimal(current-group()/OrderQty)&quot;/&gt; &lt;/xsl:variable&gt; &lt;xsl:variable name=&quot;calcPriceBasis&quot;&gt; &lt;xsl:choose&gt; &lt;xsl:when test=&quot;current-group()[UnitPriceBasis='TP']&quot;&gt; &lt;xsl:copy-of select=&quot;round(($unitPrice div 1000))&quot;/&gt; &lt;/xsl:when&gt; &lt;xsl:when test=&quot;current-group()[UnitPriceBasis='HT']&quot;&gt; &lt;xsl:copy-of select=&quot;round(($unitPrice div 1000))&quot;/&gt; &lt;/xsl:when&gt; &lt;xsl:when test=&quot;current-group()[UnitPriceBasis='HP']&quot;&gt; &lt;xsl:copy-of select=&quot;round(($unitPrice div 100))&quot;/&gt; &lt;/xsl:when&gt; &lt;xsl:when test=&quot;current-group()[UnitPriceBasis='HTH']&quot;&gt; &lt;xsl:copy-of select=&quot;round(($unitPrice div 100000))&quot;/&gt; &lt;/xsl:when&gt; &lt;xsl:when test=&quot;current-group()[UnitPriceBasis='PD']&quot;&gt; &lt;xsl:copy-of select=&quot;round(($unitPrice div 12))&quot;/&gt; &lt;/xsl:when&gt; &lt;xsl:when test=&quot;current-group()[UnitPriceBasis='PN']&quot;&gt; &lt;xsl:copy-of select=&quot;round(($unitPrice div 10))&quot;/&gt; &lt;/xsl:when&gt; &lt;xsl:when test=&quot;current-group()[UnitPriceBasis='TT']&quot;&gt; &lt;xsl:copy-of select=&quot;round(($unitPrice div 10000))&quot;/&gt; &lt;/xsl:when&gt; &lt;xsl:otherwise&gt; &lt;xsl:copy-of select=&quot;$unitPrice&quot;/&gt; &lt;/xsl:otherwise&gt; &lt;/xsl:choose&gt; &lt;/xsl:variable&gt; &lt;total&gt; &lt;xsl:sequence select=&quot;format-number($calcPriceBasis * $orderQty, '0.00')&quot;/&gt; &lt;/total&gt; &lt;/xsl:for-each&gt; &lt;/xsl:variable&gt; &lt;xsl:value-of select=&quot;sum($uPrice)&quot;/&gt; &lt;/xsl:for-each-group&gt; &lt;/tpi:Fact&gt; </code></pre> <p>The output I am getting is:</p> <pre><code>&quot;TOTALLINEPRICE&quot;:&quot;105.28216466.0819.684.5618405.24395.22.1519.35&quot; </code></pre> <p>which is each node of this calculation</p> <pre><code>&lt;xsl:sequence select=&quot;format-number($calcPriceBasis * $orderQty, '0.00')&quot;/&gt; </code></pre> <p>appended to itself as a concatenated string. But I would hope to see</p> <pre><code>&quot;TOTALLINEPRICE&quot;: &quot;1456.84&quot; </code></pre> <p>which would be the sum total of each calculated value.</p> <p>TOTALLINEPRICE is a new node created inside of the XML much like adding</p> <pre><code>&lt;TOTALLINEPRICE&gt; &lt;/TOTALLINEPRICE&gt; </code></pre> <p>As you can see, I need to compute a different price basis based on an input code (UnitPriceBasis) within each nodes itself. I know that xslt is not a programmatic language and variables are technically immutable. But there has to be a way to do this.</p> <p>For reference, I am using:</p> <pre class="lang-xml prettyprint-override"><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt; &lt;xsl:stylesheet version=&quot;2.0&quot; xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot; xmlns:fo=&quot;http://www.w3.org/1999/XSL/Format&quot; xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot; xmlns:fn=&quot;http://www.w3.org/2005/xpath-functions&quot; xmlns:tpi=&quot;http://www.spscommerce.net/tpi&quot;&gt; </code></pre> <p>Where have I gone wrong?</p>
[ { "answer_id": 74200281, "author": "michael.hor257k", "author_id": 3016153, "author_profile": "https://Stackoverflow.com/users/3016153", "pm_score": 1, "selected": false, "text": "<items>\n <item>\n <qty>2</qty>\n <price>10.00</price>\n <group>A</group>\n </ite...
2022/10/25
[ "https://Stackoverflow.com/questions/74199207", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2081925/" ]
74,199,216
<p>I've done the HTML as well as the pdf blank file for my web framework, but when it comes to the submission POST, I cannot seem to get it to work. Its supposed that once you press the submit it will save the user input to the blank pdf created, to later through a button (which is already created and functional, but downloads blank) download a pdf with the users inputed data. PDF should have the input data</p> <p>Home1.html</p> <pre><code>{% extends &quot;users/base.html&quot; %} {% block title%} Home2 {%endblock title%} {%block Formulario%} form id=&quot;survey-form&quot;&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;name-label&quot; for=&quot;name&quot;&gt;Nombres y Apellidos&lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;name&quot; id=&quot;name&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese su nombre:&quot; required/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;fecha-label&quot; for=&quot;Fecha&quot;&gt;Fecha&lt;/label&gt; &lt;input type=&quot;date&quot; name=&quot;fecha&quot; id=&quot;fecha&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese la fecha actual&quot; required/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;cargo-label&quot; for=&quot;cargo&quot;&gt;Cargo Actual&lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;cargo_actual&quot; id=&quot;cargo_actual&quot; class=&quot;form-control&quot; placeholder=&quot;Cargo Actual&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;Nac-label&quot; for=&quot;cargo&quot;&gt;Lugar y Fecha de Nacimiento &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;FechaNac&quot; id=&quot;FechaNac&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese Lugar y Fecha de Nacimiento&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;Discapacidad-label&quot; for=&quot;Discapacidad&quot;&gt;Discapacidad &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;Discapacidad&quot; id=&quot;Discapacidad&quot; class=&quot;form-control&quot; placeholder=&quot;En caso de tener discapacidad ingrese el grado,caso contrario deje vacio&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;Edad-label&quot; for=&quot;Edad&quot;&gt;Edad &lt;/label&gt; &lt;input type=&quot;number&quot; name=&quot;Edad&quot; id=&quot;Edad&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese su Edad&quot; min=&quot;18&quot; max=&quot;90&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;Tipo_Sangre-label&quot; for=&quot;Tipo_Sangre&quot;&gt;Tipo de Sangre &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;Tipo_Sangre&quot; id=&quot;Tipo_Sangre&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese su tipo de Sangre&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;Estatura-label&quot; for=&quot;Estatura&quot;&gt;Estatura: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;Estatura&quot; id=&quot;Estatura&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese su Estatura&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;Direccion_Domicilio-label&quot; for=&quot;Direccion_Domicilio_actual&quot;&gt;Direccion de Domicilio Actual &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;Direccion_Domicilio_actual&quot; id=&quot;Direccion_Domicilio_actual&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese su direccion de domicilio actual&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;Manzana-label&quot; for=&quot;Manzana&quot;&gt;Manzana &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;Manzana&quot; id=&quot;Manzana&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese la Manzana de la vivienda&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;Parroquia-label&quot; for=&quot;Parroquia&quot;&gt;Parroquia &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;Parroquia&quot; id=&quot;Parroquia&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese la Parroquia&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;Telefono_Domicilio-label&quot; for=&quot;Telefono_Domicilio&quot;&gt;Telefono Domicilio: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;Telefono_Domicilio&quot; id=&quot;Telefono_Domicilio&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese su telefono domiciliario&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;Telefono_Celular-label&quot; for=&quot;Telefono_Celular&quot;&gt;Telefono Celular &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;Telefono_Celular&quot; id=&quot;Telefono_Celular&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese su telefono celular&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;Telefono_Familiar-label&quot; for=&quot;Telefono_Familiar&quot;&gt;Telefono Familiar &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;Telefono_Familiar&quot; id=&quot;Telefono_Familiar&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese su telefono familiar&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;Cedula-label&quot; for=&quot;Cedula&quot;&gt;Cedula &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;Cedula&quot; id=&quot;Cedula&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese su cedula&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;p&gt;Cual es su estado civil?&lt;/p&gt; &lt;select id=&quot;dropdown&quot; name=&quot;estado_civil&quot; class=&quot;form-control&quot; required/&gt; &lt;option disabled selected value&gt;Seleccione alguna opcion&lt;/option&gt; &lt;option value=&quot;chat&quot;&gt;Soltero&lt;/option&gt; &lt;option value=&quot;photo&quot;&gt;Union Libre&lt;/option&gt; &lt;option value=&quot;live&quot;&gt; Casadio &lt;/option&gt; &lt;option value=&quot;story&quot;&gt;Viudo&lt;/option&gt; &lt;option value=&quot;story&quot;&gt;Divorciado&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;h2&gt; Informacion del Conyuge o Esposo &lt;span class=&quot;clue&quot;&gt;(En caso de no tener, dejar vacio)&lt;/span&gt;&lt;/h2&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;Nombre_del_Conyuge-label&quot; for=&quot;Nombre_del_Conyuge&quot;&gt;Nombre Completo del Conyuge &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;Nombre_del_Conyuge&quot; id=&quot;Nombre_del_Conyuge&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese nombre de su esposo/a&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;Dirrecion_Domicilio_Conyuge-label&quot; for=&quot;Dirrecion_Domicilio_Conyuge&quot;&gt;Direccion Domicilio: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;Dirrecion_Domicilio_Conyuge&quot; id=&quot;Dirrecion_Domicilio_Conyuge&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese direccion del domicilio:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;Telefono_Conyuge-label&quot; for=&quot;Telefono_Conyuge&quot;&gt;Telefono: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;Telefono_Conyuge&quot; id=&quot;Telefono_Conyuge&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese telefono:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;Cedula_Conyuge-label&quot; for=&quot;Cedula_Conyuge&quot;&gt;Cedula: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;Cedula_Conyuge&quot; id=&quot;Cedula_Conyuge&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese cedula:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;FechaNac_Conyuge-label&quot; for=&quot;FechaNac_Conyuge&quot;&gt;Fecha de Nacimiento: &lt;/label&gt; &lt;input type=&quot;date&quot; name=&quot;FechaNac_Conyuge&quot; id=&quot;FechaNac_Conyuge&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese fecha de Nacimiento:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;Lugar_Trabajo_Conyuge-label&quot; for=&quot;Lugar_Trabajo_Conyuge&quot;&gt;Lugar de trabajo: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;Lugar_Trabajo_Conyuge&quot; id=&quot;Lugar_Trabajo_Conyuge&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese el lugar de trabajo:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;Dirrecion_Domicilio_Conyuge-label&quot; for=&quot;Dirrecion_Domicilio_Conyuge&quot;&gt;Direccion Domicilio: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;Dirrecion_Domicilio_Conyuge&quot; id=&quot;Dirrecion_Domicilio_Conyuge&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese direccion del domicilio:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;Telefono_Trabajo-label&quot; for=&quot;Telefono_Trabajo&quot;&gt;Telefono del Trabajo: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;Telefono_Trabajo&quot; id=&quot;Telefono_Trabajo&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese telefono del trabajo&quot;/&gt; &lt;/div&gt; &lt;h2&gt; Informacion de los Hijos &lt;span class=&quot;clue&quot;&gt;(En caso de no tener hijos, dejar vacio)&lt;/span&gt;&lt;/h2&gt; &lt;small&gt; Hijo 1 &lt;/small&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;NombreK1-label&quot; for=&quot;NombreK1&quot;&gt;Nombre: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;NombreK1&quot; id=&quot;NombreK1&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese Nombre:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;NacK1-label&quot; for=&quot;NacK1&quot;&gt;Fecha y Lugar de Nacimiento: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;NacK1&quot; id=&quot;NacK1&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese fecha y lugar de nacimiento:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;EdadK1-label&quot; for=&quot;EdadK1&quot;&gt; Edad: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;EdadK1&quot; id=&quot;EdadK1&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese la edad:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;CedulaK1-label&quot; for=&quot;CedulaK1&quot;&gt;Cedula: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;CedulaK1&quot; id=&quot;CedulaK1&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese cedula:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;DireccionK1-label&quot; for=&quot;DireccionK1&quot;&gt;Direccion Domicilio: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;DireccionK1&quot; id=&quot;DireccionK1&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese direccion del domicilio:&quot;/&gt; &lt;/div&gt; &lt;small&gt; Hijo 2 &lt;/small&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;NombreK2-label&quot; for=&quot;NombreK2&quot;&gt;Nombre: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;NombreK2&quot; id=&quot;NombreK2&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese Nombre:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;NacK2-label&quot; for=&quot;NacK2&quot;&gt;Fecha y Lugar de Nacimiento: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;NacK2&quot; id=&quot;NacK2&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese fecha y lugar de nacimiento:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;EdadK2-label&quot; for=&quot;EdadK2&quot;&gt; Edad: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;EdadK2&quot; id=&quot;EdadK2&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese la edad:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;CedulaK2-label&quot; for=&quot;CedulaK2&quot;&gt;Cedula: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;CedulaK2&quot; id=&quot;CedulaK2&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese cedula:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;DireccionK2-label&quot; for=&quot;DireccionK2&quot;&gt;Direccion Domicilio: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;DireccionK2&quot; id=&quot;DireccionK2&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese direccion del domicilio:&quot;/&gt; &lt;/div&gt; &lt;small&gt; Hijo 3 &lt;/small&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;NombreK3-label&quot; for=&quot;NombreK3&quot;&gt;Nombre: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;NombreK3&quot; id=&quot;NombreK3&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese Nombre:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;NacK3-label&quot; for=&quot;NacK3&quot;&gt;Fecha y Lugar de Nacimiento: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;NacK3&quot; id=&quot;NacK3&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese fecha y lugar de nacimiento:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;EdadK3-label&quot; for=&quot;EdadK3&quot;&gt; Edad: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;EdadK3&quot; id=&quot;EdadK3&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese la edad:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;CedulaK3-label&quot; for=&quot;CedulaK3&quot;&gt;Cedula: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;CedulaK3&quot; id=&quot;CedulaK3&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese cedula:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;DireccionK3-label&quot; for=&quot;DireccionK3&quot;&gt;Direccion Domicilio: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;DireccionK3&quot; id=&quot;DireccionK3&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese direccion del domicilio:&quot;/&gt; &lt;/div&gt; &lt;small&gt; Hijo 1 &lt;/small&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;NombreK4-label&quot; for=&quot;NombreK4&quot;&gt;Nombre: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;NombreK4&quot; id=&quot;NombreK4&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese Nombre:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;NacK4-label&quot; for=&quot;NacK4&quot;&gt;Fecha y Lugar de Nacimiento: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;NacK4&quot; id=&quot;NacK4&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese fecha y lugar de nacimiento:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;EdadK4-label&quot; for=&quot;EdadK4&quot;&gt; Edad: &lt;/label&gt; &lt;input type=&quot;tex4&quot; name=&quot;EdadK4&quot; id=&quot;EdadK4&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese la edad:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;CedulaK4-label&quot; for=&quot;CedulaK4&quot;&gt;Cedula: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;CedulaK4&quot; id=&quot;CedulaK4&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese cedula:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;DireccionK4-label&quot; for=&quot;DireccionK4&quot;&gt;Direccion Domicilio: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;DireccionK4&quot; id=&quot;DireccionK4&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese direccion del domicilio:&quot;/&gt; &lt;/div&gt; &lt;h2&gt; Informacion Familiares &lt;span class=&quot;clue&quot;&gt; (Padres y hermanos) &lt;/span&gt;&lt;/h2&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;Apellidos_Nombres-label&quot; for=&quot;Apellidos_Nombres&quot;&gt;Apellidos y Nombres completos: &lt;/label&gt; &lt;small&gt; Hijo 1 &lt;/small&gt; &lt;input type=&quot;text&quot; name=&quot;Apellidos_NombresF1&quot; id=&quot;Apellidos_NombresF1&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese Apellidos y Nombres:&quot;/&gt; &lt;small&gt; Hijo 2 &lt;/small&gt; &lt;input type=&quot;text&quot; name=&quot;Apellidos_NombresF2&quot; id=&quot;Apellidos_NombresF2&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese Apellidos y Nombres:&quot;/&gt; &lt;small&gt; Hijo 3 &lt;/small&gt; &lt;input type=&quot;text&quot; name=&quot;Apellidos_NombresF3&quot; id=&quot;Apellidos_NombresF3&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese Apellidos y Nombres:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;Telefono_Familiares-label&quot; for=&quot;Telefono_Familiares&quot;&gt;Telefono: &lt;/label&gt; &lt;small&gt; Hijo 1 &lt;/small&gt; &lt;input type=&quot;text&quot; name=&quot;Telefono_Familiares1&quot; id=&quot;Telefono_Familiares1&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese Apellidos y Nombres:&quot;/&gt; &lt;small&gt; Hijo 2 &lt;/small&gt; &lt;input type=&quot;text&quot; name=&quot;Telefono_Familiares2&quot; id=&quot;Telefono_Familiares2&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese Apellidos y Nombres:&quot;/&gt; &lt;small&gt; Hijo 3 &lt;/small&gt; &lt;input type=&quot;text&quot; name=&quot;Telefono_Familiares3&quot; id=&quot;Telefono_Familiares3&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese Apellidos y Nombres:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;Fecha_NacimientoFam-label&quot; for=&quot;Apellidos_Nombres&quot;&gt;Fecha de Nacimiento: &lt;/label&gt; &lt;small&gt; Hijo 1 &lt;/small&gt; &lt;input type=&quot;text&quot; name=&quot;Fecha_NacimientoFam1&quot; id=&quot;Fecha_NacimientoFam1&quot; class=&quot;form-control&quot; placeholder=&quot;Telefono&quot;/&gt; &lt;small&gt; Hijo 2 &lt;/small&gt; &lt;input type=&quot;text&quot; name=&quot;Fecha_NacimientoFam2&quot; id=&quot;Fecha_NacimientoFam2&quot; class=&quot;form-control&quot; placeholder=&quot; Telefono:&quot;/&gt; &lt;small&gt; Hijo 3 &lt;/small&gt; &lt;input type=&quot;text&quot; name=&quot;Fecha_NacimientoFam3&quot; id=&quot;Fecha_NacimientoFam3&quot; class=&quot;form-control&quot; placeholder=&quot;Telefono:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;Relacion_Parentesco-label&quot; for=&quot;Relacion_Parentesco&quot;&gt;Relacion de Parentesco &lt;/label&gt; &lt;small&gt; Hijo 1 &lt;/small&gt; &lt;input type=&quot;text&quot; name=&quot;Relacion_ParentescoF1&quot; id=&quot;Relacion_ParentescoF1&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese Apellidos y Nombres:&quot;/&gt; &lt;small&gt; Hijo 2 &lt;/small&gt; &lt;input type=&quot;text&quot; name=&quot;Relacion_ParentescoF2&quot; id=&quot;Relacion_ParentescoF2&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese Apellidos y Nombres:&quot;/&gt; &lt;small&gt; Hijo 3 &lt;/small&gt; &lt;input type=&quot;text&quot; name=&quot;Relacion_ParentescoF3&quot; id=&quot;Relacion_ParentescoF3&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese Apellidos y Nombres:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;Direccion_Familiares-label&quot; for=&quot;Direccion_Familiares&quot;&gt;Apellidos y Nombres completos: &lt;/label&gt; &lt;small&gt; Hijo 1 &lt;/small&gt; &lt;input type=&quot;text&quot; name=&quot;Direccion_FamiliaresF1&quot; id=&quot;Direccion_FamiliaresF1&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese Apellidos y Nombres:&quot;/&gt; &lt;small&gt; Hijo 2 &lt;/small&gt; &lt;input type=&quot;text&quot; name=&quot;Direccion_FamiliaresF2&quot; id=&quot;Direccion_FamiliaresF2&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese Apellidos y Nombres:&quot;/&gt; &lt;small&gt; Hijo 3 &lt;/small&gt; &lt;input type=&quot;text&quot; name=&quot;Direccion_FamiliaresF3&quot; id=&quot;Direccion_FamiliaresF3&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese Apellidos y Nombres:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id='inp_3-label' for=&quot;inp_3&quot;&gt; Trabajan en esta empresa familiares? &lt;input type=&quot;checkbox&quot; name=&quot;inp_Si&quot; id= &quot;inp_3&quot; class='form-control'&gt;Si &lt;/input&gt; &lt;input type=&quot;checkbox&quot; name=&quot;inp_No&quot; id='inp_3' class='form-control'&gt;No &lt;/input&gt; &lt;/label&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id='inp_4-label' for=&quot;inp_4&quot;&gt; Trabajan en esta empresa amistades? &lt;input type=&quot;checkbox&quot; name=&quot;inp_Si&quot; id= &quot;inp_4&quot; class='form-control'&gt;Si &lt;/input&gt; &lt;input type=&quot;checkbox&quot; name=&quot;inp_No&quot; id='inp_4' class='form-control'&gt;No &lt;/input&gt; &lt;/label&gt; &lt;/div&gt; &lt;h2&gt; Referencias Personales&lt;span class=&quot;clue&quot;&gt; (diferentes a familiares) &lt;/span&gt;&lt;/h2&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;Apellidos_NombresRef-label&quot; for=&quot;Apellidos_NombresRef&quot;&gt;Apellidos y Nombres completos: &lt;/label&gt; &lt;small&gt; Referencia 1 &lt;/small&gt; &lt;input type=&quot;text&quot; name=&quot;Apellidos_NombresRef1&quot; id=&quot;Apellidos_NombresRef1&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese Apellidos y Nombres:&quot;/&gt; &lt;small&gt; Referencia 2 &lt;/small&gt; &lt;input type=&quot;text&quot; name=&quot;Apellidos_NombresREf2&quot; id=&quot;Apellidos_NombresRef2&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese Apellidos y Nombres:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;Direccion_DomicilioRef-label&quot; for=&quot;Direccion_DomicilioRef&quot;&gt;Apellidos y Nombres completos: &lt;/label&gt; &lt;small&gt; Referencia 1 &lt;/small&gt; &lt;input type=&quot;text&quot; name=&quot;Direccion_DomicilioRef1&quot; id=&quot;Direccion_DomicilioRef1&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese Domicilio:&quot;/&gt; &lt;small&gt; Referencia 2 &lt;/small&gt; &lt;input type=&quot;text&quot; name=&quot;Direccion_DomicilioRef2&quot; id=&quot;Direccion_DomicilioRef2&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese Apellidos:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;TelefonoRef-label&quot; for=&quot;TelefonoRef&quot;&gt;Telefono: &lt;/label&gt; &lt;small&gt; Referencia 1 &lt;/small&gt; &lt;input type=&quot;text&quot; name=&quot;TelefonoRef1&quot; id=&quot;TelefonoRef1&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese Telefono:&quot;/&gt; &lt;small&gt; Referencia 2 &lt;/small&gt; &lt;input type=&quot;text&quot; name=&quot;TelefonoRef2&quot; id=&quot;TelefonoRef2&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese Telefono:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;Ocupacion-label&quot; for=&quot;Ocupacion&quot;&gt;Ocupacion: &lt;/label&gt; &lt;small&gt; Referencia 1 &lt;/small&gt; &lt;input type=&quot;text&quot; name=&quot;OcupacionRef1&quot; id=&quot;OcupacionRef1&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese Ocupacion:&quot;/&gt; &lt;small&gt; Referencia 2 &lt;/small&gt; &lt;input type=&quot;text&quot; name=&quot;OcupacionRef2&quot; id=&quot;OcupacionRef2&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese Ocupacion:&quot;/&gt; &lt;/div&gt; &lt;h2&gt; Experiencia Laboral &lt;span class=&quot;clue&quot;&gt; (si tiene menos de tres anos en la empresa) &lt;/span&gt;&lt;/h2&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;NombreEmpresa-label&quot; for=&quot;NombreEmpresa&quot;&gt; Nombre de la Empresa: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;NombreEmpresa&quot; id=&quot;NombreEmpresa&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese la Empresa:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;DireccionEmpresa-label&quot; for=&quot;DireccionEmpresa&quot;&gt; Direccion de la Empresa: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;DireccionEmpresa&quot; id=&quot;DireccionEmpresa&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese la Direccion de la Empresa:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;TelefonoEmpresa-label&quot; for=&quot;TelefonoEmpresa&quot;&gt; Telefono de la Empresa: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;TelefonoEmpresa&quot; id=&quot;TelefonoEmpresa&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese el telefono:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;FechaIngreso-label&quot; for=&quot;FechaIngreso&quot;&gt; Fecha de Ingreso: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;FechaIngreso&quot; id=&quot;FechaIngreso&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese la fecha en la cual inicio:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;FechaSalida-label&quot; for=&quot;FechaSalida&quot;&gt; Fecha de Salida: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;FechaSalida&quot; id=&quot;FechaSalida&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese la fehca de salida:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;Sueldo-label&quot; for=&quot;Sueldo&quot;&gt; Sueldo Final: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;Sueldo&quot; id=&quot;Sueldo&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese su Sueldo:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;Cargo-label&quot; for=&quot;Cargo&quot;&gt; Cargo que llevaba: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;Cargo&quot; id=&quot;Cargo&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese su cargo:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;Tiempo_Servicio-label&quot; for=&quot;Tiempo_Servicio&quot;&gt; Tiempo de Servicio: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;Tiempo_Servicio&quot; id=&quot;Tiempo_Servicio&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese el tiempo que estuvo en la empresa:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;Jefe_Inmediato-label&quot; for=&quot;Jefe_Inmediato&quot;&gt; Jefe Inmediato: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;Jefe_Inmediato&quot; id=&quot;Jefe_Inmediato&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese su Jefe:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;NombreEmpresa-label&quot; for=&quot;NombreEmpresa&quot;&gt; Nombre de la Empresa: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;NombreEmpresa&quot; id=&quot;NombreEmpresa&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese la Empresa:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id='Vehiculo-label' for=&quot;inp_3&quot;&gt; Usted posee un vehiculo? &lt;input type=&quot;checkbox&quot; name=&quot;inp_SiVehiculo&quot; id= &quot;inp_4Vehiculo&quot; class='form-control'&gt;Si &lt;/input&gt; &lt;input type=&quot;checkbox&quot; name=&quot;inp_NoVehiculo&quot; id='inp_4Vehiculo' class='form-control'&gt;No &lt;/input&gt; &lt;/label&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;ModeloV-label&quot; for=&quot;ModeloV&quot;&gt; Vehiculo: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;ModeloV&quot; id=&quot;ModeloV&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese el modelo del Vehiculo:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;MarcaV-label&quot; for=&quot;MarcaV&quot;&gt; Marca: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;MarcaV&quot; id=&quot;MarcaV&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese la marca del Vehiculo:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;PlacaV-label&quot; for=&quot;PlacaV&quot;&gt; Placa: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;PlacaV&quot; id=&quot;PlacaV&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese la placa de su vehiculo:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;AnoV-label&quot; for=&quot;AnoV&quot;&gt; Año del Vehiculo: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;AnoV&quot; id=&quot;AnoV&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese el año del vehiculo :&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id=&quot;ColorV-label&quot; for=&quot;ColorV&quot;&gt; Color: &lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;ColorV&quot; id=&quot;ColorV&quot; class=&quot;form-control&quot; placeholder=&quot;Ingrese el color del vehiculo:&quot;/&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;p&gt;Su vivienda actual es?&lt;/p&gt; &lt;select id=&quot;dropdown&quot; name=&quot;Vivienda&quot; class=&quot;form-control&quot; required/&gt; &lt;option disabled selected value&gt;Seleccione alguna opcion&lt;/option&gt; &lt;option value=&quot;Propia&quot;&gt;Propia&lt;/option&gt; &lt;option value=&quot;Alquilada&quot;&gt;Alquilada&lt;/option&gt; &lt;option value=&quot;Familiar&quot;&gt; Familiar &lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;p&gt;Cual es el tipo de vivienda?&lt;/p&gt; &lt;select id=&quot;dropdown&quot; name=&quot;TipoVivienda&quot; class=&quot;form-control&quot; required/&gt; &lt;option disabled selected value&gt;Seleccione alguna opcion&lt;/option&gt; &lt;option value=&quot;Hormigon&quot;&gt;Hormigon&lt;/option&gt; &lt;option value=&quot;Mixta&quot;&gt; Mixta &lt;/option&gt; &lt;option value=&quot;Madera&quot;&gt;Madera&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;label id='Terrenos-label' for=&quot;inp_5&quot;&gt; Usted posee Terrenos? &lt;input type=&quot;checkbox&quot; name=&quot;inp_SiTerreno&quot; id= &quot;inp_5Vehiculo&quot; class='form-control'&gt;Si &lt;/input&gt; &lt;input type=&quot;checkbox&quot; name=&quot;inp_NoTerreno&quot; id='inp_5Vehiculo' class='form-control'&gt;No &lt;/input&gt; &lt;/label&gt; &lt;/div&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;button type=&quot;submit&quot; id=&quot;submit&quot; class=&quot;submit-button&quot;&gt;Submit&lt;/button&gt; &lt;/div&gt; &lt;/form&gt; &lt;style&gt; body{ background-color: #05c4c4; font-family: Verdana; text-align:center; } form{ background-color:fff; max-width:100px margin= 10px auto; padding=30px 20px; box-shadow:2px 5px 10px rgba(0,0,0,0.5); } .form-control { text-align: left; margin-bottom: 25px; } .form-control label { display: block; margin-bottom: 10px; } .form-control input, .form-control select, .form-control textarea { border: 1px solid #777; border-radius: 2px; font-family: inherit; padding: 10px; display: block; width: 95%; } .form-control input[type=&quot;radio&quot;], .form-control input[type=&quot;checkbox&quot;] { display: inline-block; width: auto; } button { background-color: #05c4c4; border: 1px solid #777; border-radius: 2px; font-family: inherit; font-size: 21px; display: block; width: 100%; margin-top: 50px; margin-bottom: 20px; } h4 { background-color: #05c4c4; font-family: Verdana; text-align:left; margin: 10px } &lt;/style&gt; {% endblock Formulario%} </code></pre> <p>views.py</p> <pre><code>def home2_pdf(request): buf = io.BytesIO() c = canvas.Canvas(buf, pagesize=letter, bottomup=0) textob= c.beginText() textob.setTextOrigin(inch,inch) textob.setFont(&quot;Helvetica&quot;, 14) lines =[ request.POST['name'], request.POST['fecha'], request.POST['cargp_actual'], request.POST['FechaNac'], request.POST['Discapacidad'], request.POST['Edad'], request.POST['Tipo_Sangre'], request.POST['Estatura'], request.POST['Direccion_Domicilio_actual'], request.POST['Manzana'], request.POST['Parroquia'], request.POST['Telefono_Domicilio'], request.POST['Telefono_Celular'], request.POST['Telefono_Familiar'], request.POST['Cedula'], request.POST['estado_civil'], request.POST['Nombre_del_Conyuge'], ] for line in lines: textob.textLine(line) c.drawText(textob) c.showPage() c.save() buf.seek(0) return FileResponse(buf, as_attachment=True, filename=&quot;formulario.pdf&quot;) </code></pre> <p>urls.py snip</p> <pre><code>path('home2_pdf', home2_pdf, name='home2_pdf'), </code></pre>
[ { "answer_id": 74200281, "author": "michael.hor257k", "author_id": 3016153, "author_profile": "https://Stackoverflow.com/users/3016153", "pm_score": 1, "selected": false, "text": "<items>\n <item>\n <qty>2</qty>\n <price>10.00</price>\n <group>A</group>\n </ite...
2022/10/25
[ "https://Stackoverflow.com/questions/74199216", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20302684/" ]
74,199,217
<p><a href="https://i.stack.imgur.com/xQLFr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xQLFr.png" alt="enter image description here" /></a></p> <p>I have two divs and want to display the content of both divs in the same location. Since the text in the first div is longer and has an impact on where the body content is positioned, the two divs do not look alike.I want the position of second div body content like first div body content. Please see the SS that I have attached.</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;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="utf-8" /&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1" /&gt; &lt;title&gt;Bootstrap demo&lt;/title&gt; &lt;link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous" /&gt; &lt;/head&gt; &lt;body style="padding: 40px"&gt; &lt;div class="d-flex flex-column border border-primary " style="max-width: 400px ; height: 130px "&gt; &lt;div class="w-100 bg-warning text-center p-2"&gt; &lt;a href=""&gt;Somecontent from a map function here dsdsadsadsffffffff&lt;/a&gt; &lt;/div&gt; &lt;div class="h-100"&gt; &lt;div class="d-flex align-items-stretch justify-content-between pt-4 pb-2 px-2" onclick="alert('hey')" &gt; &lt;text class="bg-warning"&gt; discussed &lt;/text&gt; &lt;div onclick="alert('hey click me')"&gt;icons here&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="d-flex flex-column border border-primary mt-2 " style="max-width: 400px ; height: 130px;"&gt; &lt;div class="w-100 bg-warning text-center p-2"&gt; &lt;a href=""&gt;Somecontent from a map&lt;/a&gt; &lt;/div&gt; &lt;div class="h-100" onclick="alert('hey')"&gt; &lt;div class="d-flex align-items-stretch justify-content-between pt-4 pb-2 px-2" &gt; &lt;text class="bg-warning"&gt; discussed &lt;/text&gt; &lt;div onclick="alert('hey click me')"&gt;icons here&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-OERcA2EqjJCMA+/3y+gxIOqMEjwtxJY7qPCqsdltbNJuaOe923+mo//f6V8Qbsw3" crossorigin="anonymous" &gt;&lt;/script&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74200281, "author": "michael.hor257k", "author_id": 3016153, "author_profile": "https://Stackoverflow.com/users/3016153", "pm_score": 1, "selected": false, "text": "<items>\n <item>\n <qty>2</qty>\n <price>10.00</price>\n <group>A</group>\n </ite...
2022/10/25
[ "https://Stackoverflow.com/questions/74199217", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11961514/" ]
74,199,223
<p>If I have a table like this:</p> <pre><code>CREATE TABLE mytable ( id SERIAL, content TEXT, copyofid INTEGER ); </code></pre> <p>Is there a way to copy <code>id</code> into <code>copyofid</code> in a single insert statement?</p> <p>I tried: <code>INSERT INTO mytable(content, copyofid) VALUES(&quot;test&quot;, id);</code></p> <p>But that doesn't seem to work.</p>
[ { "answer_id": 74200281, "author": "michael.hor257k", "author_id": 3016153, "author_profile": "https://Stackoverflow.com/users/3016153", "pm_score": 1, "selected": false, "text": "<items>\n <item>\n <qty>2</qty>\n <price>10.00</price>\n <group>A</group>\n </ite...
2022/10/25
[ "https://Stackoverflow.com/questions/74199223", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7299313/" ]
74,199,264
<p>I have a chrome extension, that changes the appereance of the wikipedia page. Now I want to change the image there. I want to replace it with one stored local in my chrome-extension. I want to change some HTML code to display my image. My <strong>manifest.json</strong> looks like this</p> <pre><code>{ &quot;name&quot; : &quot;name&quot;, &quot;version&quot;: &quot;0.0.1&quot;, &quot;manifest_version&quot;: 2, &quot;description&quot; : &quot;some desc&quot;, &quot;web_accessible_resources&quot; : [ &quot;images/*.png&quot; ], &quot;content_scripts&quot; : [ { &quot;css&quot;: [&quot;style.css&quot;], &quot;js&quot;: [&quot;imgreplace.js&quot;], &quot;matches&quot; : [&quot;*://www.wikipedia.de/&quot;] } ] } </code></pre> <p><strong>imgreplace.js</strong></p> <pre><code>document.getElementsByClassName(&quot;wikipedia-logo&quot;).innerHTML = this.innerHTML + '&lt;a href=&quot;https://www.wikipedia.org/&quot;&gt;&lt;img src=&quot;chrome-extension://__MSG_@@extension_id__/images/wikipedia_logo.png&quot; title=&quot;Wikipedia&quot; alt=&quot;Wikipedia&quot;/&gt;&lt;/a&gt;' </code></pre> <p>If I refresh the page nothing happens. No Error.</p> <p>I've also tried it with the function <code>injectAdjacentHTML</code>, but I get the error <code>injectAdjacentHTML is not a function</code>.</p> <p><em>How can I replace it?</em></p> <p>Tell me, if you need anything of my code.</p>
[ { "answer_id": 74200138, "author": "Norio Yamamoto", "author_id": 20074043, "author_profile": "https://Stackoverflow.com/users/20074043", "pm_score": 2, "selected": true, "text": "const path = chrome.runtime.getURL(\"images/wikipedia_logo.png\");\n\ndocument.getElementsByClassName(\"wiki...
2022/10/25
[ "https://Stackoverflow.com/questions/74199264", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16968665/" ]
74,199,283
<p>I have the following two extension methods. (I have a lot more, but I'll use these for this discussion.)</p> <pre><code>public static MyExtensions { public static int IndexOf(this string s, Func&lt;char, bool&gt; predicate, int startIndex) { for (int i = startIndex; i &lt; s.Length; i++) { if (predicate(s[i])) return i; } return -1; } public static int IndexOf(this StringEditor s, Func&lt;char, bool&gt; predicate, int startIndex) { for (int i = startIndex; i &lt; s.Length; i++) { if (predicate(s[i])) return i; } return -1; } } </code></pre> <p>They both do the same thing. One works with type <code>string</code>. And the other works with type <code>StringEditor</code>, which is a class I created.</p> <p>My question is if anyone can think of a way to implement both in a single method using generics.</p> <p>I cannot modify <code>string</code>, but I can make any changes needed to <code>StringEditor</code>.</p> <p>I cannot derive <code>StringEditor</code> from <code>string</code> because <code>string</code> is sealed.</p> <p>I couldn't find any interface implemented by <code>string</code> for accessing individual characters that I could implement in <code>StringEditor</code>. <code>IEnumerable&lt;T&gt;</code> is available but does not support accessing individual characters directly like an array.</p> <p>And it isn't valid to make a type argument for both <code>string</code> and <code>StringEditor</code>.</p> <pre><code>public static int IndexOf&lt;T&gt;(this T s, Func&lt;char, bool&gt; predicate, int startIndex) where T : string, StringEditor </code></pre> <p>I don't think this can be done. But maybe someone is more clever than me?</p> <h3>Update</h3> <p>Where I described that I needed to directly access individual characters, I meant using the <code>s[i]</code> syntax. In addition to generally being less performant, <code>IEnumerable&lt;T&gt;</code> does not support this.</p> <p>While <code>IEnumerable&lt;T&gt;</code> could be used to perform the results of my two methods here, it does not allow direct character access.</p>
[ { "answer_id": 74200138, "author": "Norio Yamamoto", "author_id": 20074043, "author_profile": "https://Stackoverflow.com/users/20074043", "pm_score": 2, "selected": true, "text": "const path = chrome.runtime.getURL(\"images/wikipedia_logo.png\");\n\ndocument.getElementsByClassName(\"wiki...
2022/10/25
[ "https://Stackoverflow.com/questions/74199283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/522663/" ]
74,199,326
<h3>Context</h3> <p>In our project, we need to represent resources defined by the users. That is, every user can have different resources, with different fields, different validations, etc. So we have two different things to represent in our API:</p> <ul> <li>Resource definition: this is just a really similar thing to a json schema, it contains the fields definitions of the resource and its limitations (like min and max value for numeric fields). For instance, this could be the resource definition for a <code>Person</code>:</li> </ul> <pre class="lang-json prettyprint-override"><code>{ &quot;$id&quot;: &quot;https://example.com/person.schema.json&quot;, &quot;$schema&quot;: &quot;https://json-schema.org/draft/2020-12/schema&quot;, &quot;title&quot;: &quot;Person&quot;, &quot;type&quot;: &quot;object&quot;, &quot;properties&quot;: { &quot;firstName&quot;: { &quot;type&quot;: &quot;string&quot;, &quot;description&quot;: &quot;The person's first name.&quot; }, &quot;lastName&quot;: { &quot;type&quot;: &quot;string&quot;, &quot;description&quot;: &quot;The person's last name.&quot; }, &quot;age&quot;: { &quot;description&quot;: &quot;Age in years which must be equal to or greater than zero.&quot;, &quot;type&quot;: &quot;integer&quot;, &quot;minimum&quot;: 0 } } } </code></pre> <ul> <li>Resource instance: this is just an instance of the specified resource. For instance, for the <code>Person</code> resource definition, we can have the following instances:</li> </ul> <pre class="lang-json prettyprint-override"><code>[ { &quot;firstName&quot;: &quot;Elena&quot;, &quot;lastName&quot;: &quot;Gomez&quot;, }, { &quot;firstName&quot;: &quot;Elena2&quot;, &quot;lastName&quot;: &quot;Gomez2&quot;, }, ] </code></pre> <h3>First opinion</h3> <p>So, it seems this kind of presents some conflicts with the Restful API approach. In particular, I think it has some problems with the <strong>Uniform Interface</strong>. When you get a resource, you should be able to handle the resource without any additional information. With this design, you need to make an additional request to first get the resource definition. Let's see this with an example:</p> <p>Suppose you are our web client. And you are logged in as an user with the <code>Person</code> resource. To show a person in the UI, you first need to know the structure of the <code>Person</code> resource, that is, you to do the following request: <code>GET /resource_definitions/person</code>. And then, you need to request the person object: <code>GET /resource/person/123</code>.</p> <h3>Second opinion</h3> <p>Others seem to think that this is not a problem and that the design is still RESTful. Every time you ask for something to an API, you need to know the format previously, is not self-documented in the API, so it makes sense for this endpoint to behave the same as the others.</p> <h3>Question</h3> <p>So what do you think? Is the proposed solution compliance with the RESTful approach to API design?</p>
[ { "answer_id": 74199502, "author": "inf3rno", "author_id": 607033, "author_profile": "https://Stackoverflow.com/users/607033", "pm_score": 1, "selected": false, "text": "type: \"https://example.com/person.schema.json\"" }, { "answer_id": 74199647, "author": "Evert", "auth...
2022/10/25
[ "https://Stackoverflow.com/questions/74199326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8849071/" ]
74,199,341
<p>I need to transform from one schema to another. Is there any way of achieving this without doing a <em>for</em> loop?</p> <p><strong>Original data</strong></p> <pre><code>[ { &quot;browser&quot;: &quot;Chrome&quot;, &quot;count&quot;: 73, &quot;verdict&quot;: &quot;detected&quot; }, { &quot;browser&quot;: &quot;Opera&quot;, &quot;count&quot;: 3, &quot;verdict&quot;: &quot;detected&quot; }, { &quot;browser&quot;: &quot;Chrome&quot;, &quot;count&quot;: 3, &quot;verdict&quot;: &quot;blocked&quot; }, { &quot;browser&quot;: &quot;Edge&quot;, &quot;count&quot;: 1, &quot;verdict&quot;: &quot;detected&quot; } ] </code></pre> <p><strong>Transformed data</strong></p> <pre><code>[ { &quot;browser&quot;: &quot;Chrome&quot;, &quot;detected&quot;:73, &quot;blocked&quot;:3 }, { &quot;browser&quot;: &quot;Opera&quot;, &quot;detected&quot;: 3, &quot;blocked&quot;: 0 }, { &quot;browser&quot;: &quot;Edge&quot;, &quot;detected&quot;: 1, &quot;blocked&quot;: 0 } ] </code></pre>
[ { "answer_id": 74199502, "author": "inf3rno", "author_id": 607033, "author_profile": "https://Stackoverflow.com/users/607033", "pm_score": 1, "selected": false, "text": "type: \"https://example.com/person.schema.json\"" }, { "answer_id": 74199647, "author": "Evert", "auth...
2022/10/25
[ "https://Stackoverflow.com/questions/74199341", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1155216/" ]
74,199,357
<p>On every <code>react-router</code> v6 documentation page which mentions <code>HashRouter</code> there is a short warning text stating that this kind of routing is not recommended. There is no explanation why.</p> <p>Are there any <strong>major</strong> disadvantages? Does it break any api somehow?</p>
[ { "answer_id": 74199502, "author": "inf3rno", "author_id": 607033, "author_profile": "https://Stackoverflow.com/users/607033", "pm_score": 1, "selected": false, "text": "type: \"https://example.com/person.schema.json\"" }, { "answer_id": 74199647, "author": "Evert", "auth...
2022/10/25
[ "https://Stackoverflow.com/questions/74199357", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2035825/" ]
74,199,431
<p>Basically all I wanna do is display some data according to the item I clicked on the component before.</p> <p>I created a component similar to a HousesComponent, which has a list of houses and their names. In order to display that information on that component, I have an interface called Houses which looks like the following:</p> <pre><code>export interface Houses { id: number name: string } </code></pre> <p>Also, I have an array called housesArray which contains all the houses names and their ids:</p> <pre><code>export var housesArray = [ {name: 'pink house', id: 1},{name: 'blue house', id: 2} ] </code></pre> <p>In order to change the route parameters, I followed some tips and put this subscribe function inside the ngOnInit of my HousesTemplateComponent (which is the one that is going to recieve and display the data selected).</p> <pre><code>this.route.params.subscribe(params =&gt; this.getHouseById(params['id'])) </code></pre> <p>My app-routing.module has 'house/id' as the path for the HousesTemplateComponent. The url changes perfectly according to each house I click on. Athough, when I try to bind the house name, it comes as undefined.</p> <p>The way I looked up to do it was by creating a get function that requires an id as the parameter. Then, I get the house's id try to subscribe the house variable the information into it.</p> <pre><code> getHouseById(id: number){ this.houseService.getHouseById(id).subscribe((data: IHouses) =&gt; this.house= data) } </code></pre> <p>The example I followed was made consuming a backend response, so they have an api for that. In my case, instead of using apis and a database (since I do not need one to show simple information), I am trying to access data from the housesArray.</p> <p>The houseService has this get function:</p> <pre><code>house$ = new Subject(); getHouseById(id: number): Observable&lt;IHouses&gt;{ return this.house$.asObservable(); } </code></pre> <p>I am new at creating these type of routes without consuming an api, so I think the problem could be on the getHouseById function on my HouseService. I would appreaciate any help! Thanks in advance.</p> <p><strong>Edit (solution):</strong></p> <p>Thanks to @Michael Ziluck, here is the outcome of the help I got from them. <a href="https://stackblitz.com/edit/angular-ivy-j1djof?file=src/app/houses-template/houses-template.component.ts" rel="nofollow noreferrer">Stackblitz Example</a></p>
[ { "answer_id": 74199683, "author": "Michael Ziluck", "author_id": 3962524, "author_profile": "https://Stackoverflow.com/users/3962524", "pm_score": 2, "selected": true, "text": "housesArray" }, { "answer_id": 74199959, "author": "Chris Hamilton", "author_id": 12914833, ...
2022/10/25
[ "https://Stackoverflow.com/questions/74199431", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14801612/" ]
74,199,437
<p><code>jax.numpy.split</code> can be used to segment an array into equal-length segments with a remainder in the last element. e.g. splitting an array of 5000 elements into segments of 10:</p> <pre class="lang-py prettyprint-override"><code>array = jnp.ones(5000) segment_size = 10 split_indices = jnp.arange(segment_size, array.shape[0], segment_size) segments = jnp.split(array, split_indices) </code></pre> <p>This takes around 10 seconds to execute on Google Colab and on my local machine. <strong>This seems unreasonable for such a simple task on a small array. Am I doing something wrong to make this slow?</strong></p> <hr /> <h3>Further Details (JIT caching, maybe?)</h3> <p>Subsequent calls to <code>.split</code> are very fast, provided an array of the same shape and the same split indices. e.g. the first iteration of the following loop is extremely slow, but all others fast. (11 seconds vs 40 milliseconds)</p> <pre class="lang-py prettyprint-override"><code>from timeit import default_timer as timer import jax.numpy as jnp array = jnp.ones(5000) segment_size = 10 split_indices = jnp.arange(segment_size, array.shape[0], segment_size) for k in range(5): start = timer() segments = jnp.split(array, split_indices) end = timer() print(f'call {k}: {end - start:0.2f} s') </code></pre> <p>Output:</p> <pre><code>call 0: 11.79 s call 1: 0.04 s call 2: 0.04 s call 3: 0.05 s call 4: 0.04 s </code></pre> <p>I assume that the subsequent calls are faster because JAX is caching jitted versions of <code>split</code> for each combination of arguments. If that's the case, then I assume <code>split</code> is slow (on its first such call) because of compilation overhead.</p> <p>Is that true? If yes, how <em>should</em> I split a JAX array without incurring the performance hit?</p>
[ { "answer_id": 74199669, "author": "Tom McLean", "author_id": 14720380, "author_profile": "https://Stackoverflow.com/users/14720380", "pm_score": 2, "selected": false, "text": "jnp.split" }, { "answer_id": 74200855, "author": "jakevdp", "author_id": 2937831, "author_p...
2022/10/25
[ "https://Stackoverflow.com/questions/74199437", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3367144/" ]
74,199,473
<p>RxJS <code>combineLatest</code> is deprecated and replaced with <code>combineLatestWith</code>.</p> <p>How do we use it when we have 3 or more streams to combine?</p> <p>I've developed this example for what I thought would work.</p> <pre><code>const hello$: Observable&lt;string&gt; = of('hello').pipe( combineLatestWith(of('world')), combineLatestWith(of('!')), map((arr) =&gt; { const greeting = arr[0]; const subject = arr[1]; const punctuation = arr[2]; return greeting + ' - ' + subject + punctuation; }) ); </code></pre> <p><a href="https://stackblitz.com/edit/rxjs-cmna8r?file=index.ts" rel="nofollow noreferrer">And this is the Stackblitz</a></p> <p>Thoughts?</p>
[ { "answer_id": 74199669, "author": "Tom McLean", "author_id": 14720380, "author_profile": "https://Stackoverflow.com/users/14720380", "pm_score": 2, "selected": false, "text": "jnp.split" }, { "answer_id": 74200855, "author": "jakevdp", "author_id": 2937831, "author_p...
2022/10/25
[ "https://Stackoverflow.com/questions/74199473", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1684269/" ]
74,199,490
<p>If there is an array that contains random integers in ascending order, how can I tell if this array contains a arithmetic sequence (length&gt;3) with the common differece x?</p> <p>Example: <strong>Input:</strong> Array=[1,2,4,5,8,10,17,19,20,23,30,36,40,50] x=10 <strong>Output:</strong> True</p> <p>Explanation of the Example: the array contains [10,20,30,40,50], which is a arithmetic sequence (length=5) with the common differece 10.</p> <p>Thanks!</p> <p>I apologize that I have not try any code to solve this since I have no clue yet.</p> <p>After reading the answers, I tried it in python. Here are my codes:</p> <pre class="lang-py prettyprint-override"><code>df = [1,10,11,20,21,30,40] i=0 common_differene=10 df_len=len(df) for position_1 in range(df_len): for position_2 in range(df_len): if df[position_1] + common_differene == df[position_2]: position_1=position_2 i=i+1 print(i) </code></pre> <p>However, it returns 9 instead of 4.</p> <p>Is there anyway to prevent the repetitive counting in one sequence [10,20,30,40] and also prevent accumulating i from other sequences [1,11,21]?</p>
[ { "answer_id": 74199669, "author": "Tom McLean", "author_id": 14720380, "author_profile": "https://Stackoverflow.com/users/14720380", "pm_score": 2, "selected": false, "text": "jnp.split" }, { "answer_id": 74200855, "author": "jakevdp", "author_id": 2937831, "author_p...
2022/10/25
[ "https://Stackoverflow.com/questions/74199490", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20333526/" ]
74,199,497
<p>I want to compare the value in one column to a list of values in another column. If the value is there I would like to put a 1 in a 3rd column indicating it found a match. Below is what I'm looking for</p> <pre><code>library(tidyverse) df_original &lt;- tribble( ~record_num, ~filedate, ~filedate_list, 1, 1998, c(1998, 1999, 2000, 2001), 2, 1999, c(1998, 1999, 2000, 2001), 3, 2005, c(1998, 1999, 2000, 2001), 4, 2006, c(1998, 1999, 2000, 2001), ) </code></pre> <p>I would like the output to look like this</p> <pre><code>df_solution&lt;- tribble( ~record_num, ~filedate, ~filedate_list, ~match_found, 1, 1998, c(1998, 1999, 2000, 2001), 1, 2, 1999, c(1998, 1999, 2000, 2001), 1, 3, 2005, c(1998, 1999, 2000, 2001), 0, 4, 2006, c(1998, 1999, 2000, 2001), 0 ) </code></pre> <p>Below is what I've already attempted (this results in a &quot;match_found&quot; column of all 0s</p> <pre><code>incorrect_solution &lt;- df %&gt;% mutate(match_found = if_else(filedate %in% filedate_list, 1, 0) ) </code></pre> <p>Any ideas?</p>
[ { "answer_id": 74199544, "author": "Ric Villalba", "author_id": 6912817, "author_profile": "https://Stackoverflow.com/users/6912817", "pm_score": 1, "selected": false, "text": "library(tidyverse)\n\ndf_original <- tribble(\n~record_num, ~filedate, ~filedate_list, \n1, 1998, c(1998, 1999,...
2022/10/25
[ "https://Stackoverflow.com/questions/74199497", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10453595/" ]
74,199,513
<p>I have panda dataframe indexed by ID and sorted by <code>value</code>. I want to create a sample size of n=20000 where there are 40000 rows in total and 2 rows are consecutive/paired. I want to perform additional calculations on these 2 consecutive / paired rows</p> <p>e.g. If I say sample size n=2 I want to randomly pick and find the difference in distance of each of the following picks.</p> <p>Additional condition: value difference can't exceed 4000.</p> <pre><code>index value distance cg13869341 15865 1.635450 cg14008030 18827 4.161332 </code></pre> <p>Then distance of the following etc</p> <pre><code>cg20826792 29425 0.657369 cg33045430 29407 1.708055 </code></pre> <p>Sample original dataframe</p> <pre><code>index value distance cg13869341 15865 1.635450 cg14008030 18827 4.161332 cg12045430 29407 0.708055 cg20826792 29425 0.657369 cg33045430 69407 1.708055 cg40826792 59425 0.857369 cg47454306 88407 0.708055 cg60826792 96425 2.857369 </code></pre> <p>I tried using <code>df_sample = df.sample(n=20000)</code> Then i got bit lost trying to figure out how to get the next row for each value in <code>df_sample</code></p> <p>original shape is <code>(480136, 14)</code></p>
[ { "answer_id": 74199751, "author": "mozway", "author_id": 16343464, "author_profile": "https://Stackoverflow.com/users/16343464", "pm_score": 3, "selected": true, "text": "N = 20000\n# get the indices of N random ODD rows\nidx = df.loc[::2].sample(n=N).index\n\n# create a boolean mask to...
2022/10/25
[ "https://Stackoverflow.com/questions/74199513", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1044326/" ]
74,199,538
<p>I want to call the <code>binomial</code> Clojure function from Java. One problem I encounter is that it returns different data types, either <code>long</code> (e. g., n=5, k=3) or <code>BigInt</code> (e. g., n=20, k=10). On Java side, it should be a BigInteger.</p> <p>There are at least two options to overcome this, which is preferable?</p> <ol> <li>Force Clojure function to return BigInt (I don't know if this is possible. I tried type hints, but it still returns either <code>long</code> or <code>BigInt</code>).</li> <li>In Java, use Pattern match on return value and check type, then convert appropriate.</li> </ol> <p><strong>Clojure</strong></p> <pre><code>(ns sample.hello (:import (clojure.lang BigInt))) (defn binomial &quot;Calculate the binomial coefficient.&quot; ^BigInt [^Integer n ^Integer k] (let [a (inc n)] (loop [b 1 c 1] (if (&gt; b k) c (recur (inc b) (* (/ (- a b) b) c)))))) </code></pre> <p><strong>Java</strong></p> <pre><code>public class Hello { public static final IFn binomial; static { Clojure.var(&quot;clojure.core&quot;, &quot;require&quot;).invoke(Clojure.read(&quot;sample.hello&quot;)); binomial = Clojure.var(&quot;sample.hello&quot;, &quot;binomial&quot;); } public static BigInteger binomial(int n, int k) { Object a = binomial.invoke(n, k); return ((BigInt) a).toBigInteger(); } } </code></pre>
[ { "answer_id": 74199736, "author": "Martin Půda", "author_id": 13590263, "author_profile": "https://Stackoverflow.com/users/13590263", "pm_score": 3, "selected": false, "text": "biginteger" }, { "answer_id": 74206491, "author": "Alan Thompson", "author_id": 1822379, "...
2022/10/25
[ "https://Stackoverflow.com/questions/74199538", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1091344/" ]
74,199,567
<p>good evening, im quite a long lurker here but i have ran into an issue i cant seem to find a solution for. i have no idea if i post this correctly as i dont have any base code to provide because im not sure if it is possible at all in VBA.</p> <p>i have a list with values that is variable in size and the induvidual values range from 1 to 33. (this is based on pallet amounts in trucks) what i would like to be able to do is select that range and have a vba code sort out the best way to sum up my values to 33 (But never ever over 33!) and create an array with the values and move on to the next &quot;set&quot; and put the next values that add to 33 in a new array. i know how to do it chronically (thanks to another user here on stackoverflow) but that would mean that it isnt the most efficient option.</p> <p>lets say i have a list of 5 different values:</p> <p>10 15 8 22 19</p> <p>this would create the following &quot;sets&quot;:</p> <p>25 30 19</p> <p>but if the order of the 5 values would change to:</p> <p>19 22 15 10 8</p> <p>it would create the following sets:</p> <p>19 22 15 18</p> <p>now i have found a way to define a variable to the optimal number of trucks the code should create, but with the second list it would result in an error if the code i have now goes through that list chronically.</p> <p>so to summarize, is it possible to create a code that would look at a selection of values and decide what the best most efficient way is of combining values the closest to 33.</p> <p>ill provide the code i have now, please note it is not at all finished yet and very basic as its just the start of my project and pretty much the core feature of what i want to achieve. if i need to provide more info or details please let me know</p> <p>thanks in advance. and many thanks to a huge group of people here who unbeknownst to themselves have already helped me save hours upon hours of work by providing their solutions to problems i had but didnt need to ask</p> <p>here is my code:</p> <pre><code>Sub test() Dim ref, b As Range Dim volume, i As Integer Dim test1(), check, total As Double Dim c As Long Set ref = Selection volume = ref.Cells.Count c = ref.Column ReDim test1(1 To volume) 'this creates a total of all the values i select For Each b In ref total = total + b Next b 'this determines when to round up or down check = total / 33 - Application.WorksheetFunction.RoundDown(total / 33, 0) If check &lt; 0.6 Then total = Application.WorksheetFunction.RoundDown(total / 33, 0) Else total = Application.WorksheetFunction.RoundUp(total / 33, 0) End If 'this creates an array with all the values i = 1 Do Until i = volume + 1 test1(i) = Cells(i, c).Value i = i + 1 Loop 'this is just a way for me to check and verify my current part of the code MsgBox (Round(test1(8), 2)) MsgBox (total) End Sub </code></pre>
[ { "answer_id": 74205203, "author": "Zohir Emon", "author_id": 5596143, "author_profile": "https://Stackoverflow.com/users/5596143", "pm_score": 1, "selected": false, "text": "Sub test()\nDim CellsCount As Integer\n\nCellsCount = Selection.Cells.Count\n\nDim i, j As Long\nDim x, y As Long...
2022/10/25
[ "https://Stackoverflow.com/questions/74199567", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20333002/" ]
74,199,573
<p>React redux not overiding similar object in an array. <a href="https://i.stack.imgur.com/JM7ud.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JM7ud.png" alt="enter image description here" /></a></p> <p>I was expecting arrray of object with different properties. Also If there was any similar property in array than the count will increase from 1 to onwards</p>
[ { "answer_id": 74205203, "author": "Zohir Emon", "author_id": 5596143, "author_profile": "https://Stackoverflow.com/users/5596143", "pm_score": 1, "selected": false, "text": "Sub test()\nDim CellsCount As Integer\n\nCellsCount = Selection.Cells.Count\n\nDim i, j As Long\nDim x, y As Long...
2022/10/25
[ "https://Stackoverflow.com/questions/74199573", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19847686/" ]
74,199,579
<p>I have done some research over information related to below question, but couldn't get right information.</p> <p>I have a scenario where a user creates some data using a create rest API and saves it in backend. Then, the user retrieves the saved data using a get API later to validate the data that's saved in the backend as part of create API.</p> <p>Now, can creating the data in backend and retrieving the data be combined as a feature? or should there be two features – one for creating the data and other for retrieving the data? If it can be done in both ways – what are advantages of one over other?</p>
[ { "answer_id": 74205203, "author": "Zohir Emon", "author_id": 5596143, "author_profile": "https://Stackoverflow.com/users/5596143", "pm_score": 1, "selected": false, "text": "Sub test()\nDim CellsCount As Integer\n\nCellsCount = Selection.Cells.Count\n\nDim i, j As Long\nDim x, y As Long...
2022/10/25
[ "https://Stackoverflow.com/questions/74199579", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1901761/" ]
74,199,593
<p>Much like the problem with the transposing of data in <a href="https://stackoverflow.com/questions/68426024/google-sheets-transpose-column-data-in-groups-into-rows">transpose column data</a> I am stuck trying to transpose a set of data with multiple variables. The biggest issue I face is trying to remove useless data. Table 1 is how the data is received</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Column N</th> </tr> </thead> <tbody> <tr> <td>Sep 07 2022</td> </tr> <tr> <td><em><strong>Alert</strong></em></td> </tr> <tr> <td><em><strong>Something went wrong</strong></em></td> </tr> <tr> <td>fish company</td> </tr> <tr> <td>70000123456</td> </tr> <tr> <td>1234567</td> </tr> <tr> <td>231.03</td> </tr> <tr> <td><em><strong>View Details</strong></em></td> </tr> <tr> <td>Sep 07 2022</td> </tr> <tr> <td><em><strong>---</strong></em></td> </tr> <tr> <td>meat company</td> </tr> <tr> <td>70000987654</td> </tr> <tr> <td>688773</td> </tr> <tr> <td><em><strong>View Details</strong></em></td> </tr> <tr> <td>Sep 07 2022</td> </tr> <tr> <td><em><strong>Success</strong></em></td> </tr> <tr> <td>produce company</td> </tr> <tr> <td>70000192837</td> </tr> <tr> <td><em><strong>View Details</strong></em></td> </tr> </tbody> </table> </div> <p>Table 2 is the desired output</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Column A</th> <th>Column B</th> <th>Column C</th> <th>Column D</th> <th>Column E</th> </tr> </thead> <tbody> <tr> <td>date</td> <td>vendor</td> <td>po</td> <td>Invoice</td> <td>cost</td> </tr> <tr> <td>Sep 07 2022</td> <td>fish company</td> <td>70000123456</td> <td>1234567</td> <td>231.03</td> </tr> <tr> <td>Sep 08 2022</td> <td>meat company</td> <td>70000987654</td> <td>D688773B</td> <td></td> </tr> <tr> <td>Sep 07 2022</td> <td>produce company</td> <td>70000192837</td> <td></td> <td></td> </tr> </tbody> </table> </div> <p>I was unable to trim cells <em>Alert</em> and <em>Something went wrong</em> due to nesting errors.</p>
[ { "answer_id": 74200147, "author": "pgSystemTester", "author_id": 11732320, "author_profile": "https://Stackoverflow.com/users/11732320", "pm_score": 1, "selected": false, "text": "A2" }, { "answer_id": 74200739, "author": "TheMaster", "author_id": 8404453, "author_pr...
2022/10/25
[ "https://Stackoverflow.com/questions/74199593", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20275293/" ]
74,199,612
<blockquote> <p>Write a public static method called &quot;ArrayMax&quot; that returns the largest number in an ArrayList of Double. (1 mark)</p> <p>If the input ArrayList is empty then the method should return <code>Double.MIN_VALUE. (1 mark)</code></p> <p>Use the following function prototype when writing the method:</p> </blockquote> <pre><code> public static double ArrayMax(ArrayList&lt;Double&gt; array) { } </code></pre> <p>This is what I have done so far but its wrong. I tried making an array list, but that wasn't correct either.</p> <pre><code>public static double ArrayMax(ArrayList&lt;Double&gt; array) { if (array.isEmpty()) { return Double.MIN_VALUE; } } </code></pre> <p>How can I the largest number in an arraylist of a double?</p>
[ { "answer_id": 74200147, "author": "pgSystemTester", "author_id": 11732320, "author_profile": "https://Stackoverflow.com/users/11732320", "pm_score": 1, "selected": false, "text": "A2" }, { "answer_id": 74200739, "author": "TheMaster", "author_id": 8404453, "author_pr...
2022/10/25
[ "https://Stackoverflow.com/questions/74199612", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19121360/" ]
74,199,615
<p>I tried to make a kick command, everything works except when the command is run, the user specified will not be kicked.</p> <pre><code>@bot.tree.command(name='kick', description='Kicks a user from the server [S]') async def embed(interaction : discord.Interaction, user : discord.Member, reason : str = None): permissions = interaction.user.guild_permissions is_admin = permissions.kick_members kick = user.guild.kick if is_admin == True: embed = discord.Embed(title='Kick Command', color=discord.Color.blurple(), description='Kicks a user.') embed.set_author( name = f'{interaction.user}', icon_url= f'{interaction.user.display_avatar}') await kick embed.add_field(name = 'Username', value=str(user.mention), inline=True) embed.add_field(name = 'Reason', value=str(reason), inline=True) embed.add_field(name = 'Moderation', value='User kicked successfully.', inline=True) embed.set_footer(text=&quot;Command called by: {}&quot;.format(interaction.user)) embed.set_image(url='image') await interaction.response.send_message(embed = embed) </code></pre> <p>I tried the code above and it didn't work, all the code works as expected except that.</p>
[ { "answer_id": 74203319, "author": "Sean Gilbert", "author_id": 12210888, "author_profile": "https://Stackoverflow.com/users/12210888", "pm_score": 0, "selected": false, "text": "import discord\nfrom discord.ext.commands import Bot\nfrom discord.ext import commands\nbot= commands.Bot(com...
2022/10/25
[ "https://Stackoverflow.com/questions/74199615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19959652/" ]
74,199,627
<p>I've searched StackOverflow and the DNN forums for this answer but did not find a working answer or explanation.</p> <p>I need to lock a user account in DNN programmatically. We're using DNN version 8 and coding in C#.</p> <p>UPDATE:</p> <p>I was looking at the &quot;User Accounts\Edit User Accounts&quot; page and realized that there is no button to Lock an account. The account can only be Locked through multiple failed login attempts.</p> <p>But once an account is Locked, I can now see a button to Unlock the account. So there has to be a way to call this programmatically no?</p> <p>I tried setting:</p> <p>User.Membership.LockedOut = false;</p> <p>but that didn't work. No error just didn't Unlock the account.</p> <p>Is there not some way to programmatically Unlock an locked account?</p>
[ { "answer_id": 74203319, "author": "Sean Gilbert", "author_id": 12210888, "author_profile": "https://Stackoverflow.com/users/12210888", "pm_score": 0, "selected": false, "text": "import discord\nfrom discord.ext.commands import Bot\nfrom discord.ext import commands\nbot= commands.Bot(com...
2022/10/25
[ "https://Stackoverflow.com/questions/74199627", "https://Stackoverflow.com", "https://Stackoverflow.com/users/323425/" ]
74,199,666
<p>We have a build.yml which builds on a push to master and publishes the artifacts to a nuget feed on AzureDevops Artifacts. (not pipeline artifacts)</p> <p><a href="https://i.stack.imgur.com/9oWkr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9oWkr.png" alt="enter image description here" /></a></p> <p>I also have a working deployApp.yml pipeline where the nuget package version is a parameter input and it deploys the app.</p> <p>We want a scheduledDeploy.yml pipeline which gets triggered on a schedule and it should take the latest release(nuget package) and deploy it into an Azure app service container.</p> <p>Should i write some custom tasks inside the scheduledDeploy.yml to fetch the list of packages and deploy it or is there a better way to do this?</p>
[ { "answer_id": 74223269, "author": "RoyWang-MSFT", "author_id": 18359635, "author_profile": "https://Stackoverflow.com/users/18359635", "pm_score": 2, "selected": true, "text": "steps:\n- powershell: |\n $url = \" https://feeds.dev.azure.com/{organization}/{project}/_apis/packaging/Fee...
2022/10/25
[ "https://Stackoverflow.com/questions/74199666", "https://Stackoverflow.com", "https://Stackoverflow.com/users/339070/" ]
74,199,711
<p>I can do this</p> <pre><code>fruits=['mango','fig','apple'] for fruit in fruits: print (fruit , end=&quot; &quot;) </code></pre> <p>OUTPUT:</p> <pre><code>mango fig apple </code></pre> <hr /> <p>How to rewrite this using a loop?</p> <pre><code>fruits=['mango','fig','apple'] print(f&quot;i have {fruits[0]},{fruits[1]} and {fruits[2]}&quot;) </code></pre> <p>expectation :</p> <pre><code>i have mango,fig and apple </code></pre>
[ { "answer_id": 74223269, "author": "RoyWang-MSFT", "author_id": 18359635, "author_profile": "https://Stackoverflow.com/users/18359635", "pm_score": 2, "selected": true, "text": "steps:\n- powershell: |\n $url = \" https://feeds.dev.azure.com/{organization}/{project}/_apis/packaging/Fee...
2022/10/25
[ "https://Stackoverflow.com/questions/74199711", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14204372/" ]
74,199,725
<p>I'm hoping to implement a static class with nested classes which can be viewed and modified in the Unity Inspector.</p> <p>Any recommendations on how to achieve this?</p> <p>I've tried using nested static classes successfully, but I can't add them as a component in order to view in the inspector.</p> <p>Any recommendations on how to achieve this?</p> <p>Here's my example code. Without Monobehaviour I can't add it as a component to get it in the inspector.</p> <pre><code>using UnityEngine; public static class Parameters { [System.Serializable] public static class GroupA { public static float varA = 1f; } [System.Serializable] public static class GroupB { public static float varB = 2f; } } </code></pre> <p>I can then call this with, e.g.</p> <p><code>Parameters.GroupA.varA;</code></p> <p>Thanks in advance and sorry for my code stinks.</p> <p>best, Rob</p>
[ { "answer_id": 74223269, "author": "RoyWang-MSFT", "author_id": 18359635, "author_profile": "https://Stackoverflow.com/users/18359635", "pm_score": 2, "selected": true, "text": "steps:\n- powershell: |\n $url = \" https://feeds.dev.azure.com/{organization}/{project}/_apis/packaging/Fee...
2022/10/25
[ "https://Stackoverflow.com/questions/74199725", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20333743/" ]
74,199,734
<p>I could obtain the correct AudioTracks.length through a button click; however, I cannot obtain it without such an action. Please see my code below. I could obtain it at line (B) but cannot at (A). Why? How can I obtain it at (A)? I have a faint awareness that I don't understand something fundamental, but I'm in trouble because I don't know what it is. Please help me. Thank you so much for your kindness.</p> <p><strong>[My code]</strong></p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;body&gt; &lt;h3&gt;Please use a browser supporting AudioTracks property. See [Note] for details.&lt;/h3&gt; &lt;video id=&quot;video&quot; controls&gt; &lt;source src=&quot;https://www.w3schools.com/tags/mov_bbb.mp4&quot;&gt;&lt;/source &gt; &lt;/video&gt; &lt;button onclick=&quot;myFunction()&quot;&gt;Click (myFunction)&lt;/button&gt; &lt;script&gt; console.log(&quot;(A) = &quot; + video.audioTracks.length );// (A) = 0 function myFunction() { console.log(&quot;(B) = &quot; + video.audioTracks.length );// (B) = 2 } &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p><strong>[Note]</strong> The audioTracks property is not supported in any major browsers. It is supported in Chrome beta by enabling &quot;enable-experimental-web-platform-features&quot; in chrome:flags.</p> <ol> <li>Download <em><strong>Chrome beta Version 107</strong></em>.</li> <li>Type &quot;chrome://flags/&quot; in the address bar to see &quot;Experiments&quot; page.</li> <li>Enable &quot;#enable-experimental-web-platform-features&quot;.</li> </ol> <p><strong>[Reference]</strong> <a href="https://caniuse.com/audiotracks" rel="nofollow noreferrer">https://caniuse.com/audiotracks</a></p>
[ { "answer_id": 74200992, "author": "Jacob Malland", "author_id": 17160379, "author_profile": "https://Stackoverflow.com/users/17160379", "pm_score": 1, "selected": false, "text": "<!DOCTYPE html>\n<html>\n <body>\n <h3>Please use a browser supporting AudioTracks property. See [...
2022/10/25
[ "https://Stackoverflow.com/questions/74199734", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13450939/" ]
74,199,783
<p>I can not get a token.I am using <code>import { JwtService } from '@nestjs/jwt';</code>.The package version is <code>&quot;@nestjs/jwt&quot;: &quot;^9.0.0&quot;</code>.The this.jwtService.sign(payload) function takes only one parameter. It shows error that I have been giving below.</p> <pre><code>Error: secretOrPrivateKey must have a value at Object.module.exports [as sign] (D:\nextjs-projects\shopping-app\server_v2\node_modules\jsonwebtoken\sign.js:107:20) at JwtService.sign (D:\nextjs-projects\shopping-app\server_v2\node_modules\@nestjs\jwt\dist\jwt.service.js:28:20) at AuthService.login (D:\nextjs-projects\shopping-app\server_v2\src\auth\auth.service.ts:28:35) at AppController.login (D:\nextjs-projects\shopping-app\server_v2\src\app.controller.ts:16:35) at D:\nextjs-projects\shopping-app\server_v2\node_modules\@nestjs\core\router\router-execution-context.js:38:29 at D:\nextjs-projects\shopping-app\server_v2\node_modules\@nestjs\core\router\router-execution-context.js:46:28 at D:\nextjs-projects\shopping-app\server_v2\node_modules\@nestjs\core\router\router-proxy.js:9:17 </code></pre> <p>My Code: 1.AuthModule code is given bellow:</p> <pre><code>@Module({ imports: [ UsersModule, PassportModule, JwtModule.register({ secret: 'ndUdggLVxTccGBJmr1BoFvAQnSEt+Osx5pgdGTOL9XwajAn4fe40Q41NbBTa9wNekjKuTLdhWBJQhi71JShvi7rFoayh3QIuEA3e4Eq8mU7lwArngzFWdSiIJgMplTLboFOeR7q8pv7MoDcl2dBmuZI4NQ5GglznC8Ebl20Sa41cg4EDkuppblXa+bqvZeSQRg0d/AL9f8NIBC3N6sEyc1nM0MWeWc1CxKuljTVQm1g2RVLG1cSNU/a5vpmy/9UwYiDiIr2aCbD60EWkQMR2vDvW/0LsVun72xEqUTdY5UuczofpmhtCxm+yw9R7iFsNcNuJAyAQN0T9OtMyt9wzPA==', signOptions: { expiresIn: '1h' }, }), MongooseModule.forFeature([{ name: User.name, schema: UserSchema }]), ], providers: [AuthService, LocalStrategy], exports: [AuthService], }) export class AuthModule {} </code></pre> <p>2.AuthService code is given bellow:</p> <pre><code>@Injectable() export class AuthService { constructor( private readonly jwtService: JwtService, ) {} async login(user: any) { const payload = { name: user.email, sub: user.phone, }; const token = this.jwtService.sign(payload); return { accessToken: token, }; } } </code></pre> <p>3.AppModule code is given bellow:</p> <pre><code>@Module({ imports: [ AuthModule, UsersModule, MongooseModule.forRoot( `mongodb+srv://${dbConstant.username}:${dbConstant.password}@cluster0.34saife.mongodb.net/users?retryWrites=true&amp;w=majority`, ), ], controllers: [AppController], providers: [AppService, AuthService, JwtService], }) export class AppModule {} </code></pre> <p>4.AppController code is given bellow:</p> <pre><code>export class AppController { constructor( private readonly authService: AuthService, ) {} @UseGuards(AuthGuard('local')) @Post('auth/login') async login(@Request() req: any) { return await this.authService.login(req.user); } } </code></pre>
[ { "answer_id": 74201474, "author": "Brahim Mahioussi", "author_id": 7595543, "author_profile": "https://Stackoverflow.com/users/7595543", "pm_score": 1, "selected": false, "text": "async login(user: any) {\n const payload = {\n name: user.email,\n sub: user.phone...
2022/10/25
[ "https://Stackoverflow.com/questions/74199783", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8446581/" ]
74,199,790
<p>I had an issue validating the inputted word from the list before proceeding to the next function for the text to be created.</p> <pre><code>while True: try: services = ['Conference','Dinner','Lodging','Membership Renewal'] for i in range(0,4): print(f&quot;{services[i] : &lt;14}&quot;) hotel_services = str(input(&quot;Enter the hotel services: &quot;)) if hotel_services == services: print(&quot;Valid&quot;) except ValueError: print(&quot;Invalid&quot;) else: break print(&quot;Try Again&quot;) </code></pre> <p>I would like to have it said &quot;Invalid&quot; when the user types a wrong services. Thank you!</p>
[ { "answer_id": 74201474, "author": "Brahim Mahioussi", "author_id": 7595543, "author_profile": "https://Stackoverflow.com/users/7595543", "pm_score": 1, "selected": false, "text": "async login(user: any) {\n const payload = {\n name: user.email,\n sub: user.phone...
2022/10/25
[ "https://Stackoverflow.com/questions/74199790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19788227/" ]
74,199,811
<p>when i create new project the project run successfully but after that when i exit android studio and reopen the project comes up with this error</p> <p><a href="https://i.stack.imgur.com/OQlAi.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OQlAi.jpg" alt="enter image description here" /></a></p> <pre><code>Execution failed for task ':app:processDebugResources'. &gt; Could not resolve all files for configuration ':app:debugRuntimeClasspath'. &gt; Failed to transform material-1.7.0.aar (com.google.android.material:material:1.7.0) to match attributes {artifactType=android-compiled-dependencies-resources, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-runtime}. &gt; Could not isolate parameters com.android.build.gradle.internal.dependency.AarResourcesCompilerTransform$Parameters_Decorated@8d32791 of artifact transform AarResourcesCompilerTransform &gt; Could not isolate value com.android.build.gradle.internal.dependency.AarResourcesCompilerTransform$Parameters_Decorated@8d32791 of type AarResourcesCompilerTransform.Parameters &gt; Could not resolve all files for configuration ':app:detachedConfiguration2'. &gt; Could not find com.android.tools.build:aapt2:7.3.1-8691043. Searched in the following locations: - https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2/7.3.1-8691043/aapt2-7.3.1-8691043.pom - https://repo.maven.apache.org/maven2/com/android/tools/build/aapt2/7.3.1-8691043/aapt2-7.3.1-8691043.pom Required by: project :app </code></pre> <ul> <li>android studio dolphin</li> <li>android gradle plugin version 7.3.1</li> <li>gradle version 7.4</li> </ul>
[ { "answer_id": 74201474, "author": "Brahim Mahioussi", "author_id": 7595543, "author_profile": "https://Stackoverflow.com/users/7595543", "pm_score": 1, "selected": false, "text": "async login(user: any) {\n const payload = {\n name: user.email,\n sub: user.phone...
2022/10/25
[ "https://Stackoverflow.com/questions/74199811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17788290/" ]
74,199,818
<p>My question is related to another post here <a href="https://stackoverflow.com/questions/39922986/how-do-i-pandas-group-by-to-get-sum">How do I Pandas group-by to get sum?</a> but it does not answer my question.</p> <p>I have this dataframe:</p> <pre><code>Fruit Name Number Apples Bob 7 Apples Bob 8 Apples Mike 9 Apples Steve 10 Apples Bob 1 Oranges Bob 2 Oranges Tom 15 Oranges Mike 57 Oranges Bob 65 Oranges Tony 1 Grapes Bob 1 Grapes Tom 87 Grapes Bob 22 Grapes Bob 12 Grapes Tony 15 Melons Mike 10 </code></pre> <p>I want to get a dataframe where the first column should have all the unique values from 'Fruit' column above; second column should have the sum of values from 'Number' column but only for one person, say Bob from above. If this person does not have the particular fruit, the second column should have 0. Here is the desired output:</p> <pre><code>Fruit NumberForBob Apples 7+8+1=16 Oranges 2+65=67 Grapes 1+22+12=35 Melons 0 </code></pre> <p>I think I need to use a mix of if-statement and groupby function, but I am not able to get the desired output. How can I do this?</p>
[ { "answer_id": 74201474, "author": "Brahim Mahioussi", "author_id": 7595543, "author_profile": "https://Stackoverflow.com/users/7595543", "pm_score": 1, "selected": false, "text": "async login(user: any) {\n const payload = {\n name: user.email,\n sub: user.phone...
2022/10/25
[ "https://Stackoverflow.com/questions/74199818", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20326575/" ]
74,199,850
<p>There is a directory inside the stain/jena-fuseki:4.0.0 image that cannot be copied while other directories can be. I have the following Dockerfile</p> <pre><code>FROM python:3.8.15-slim COPY --from=stain/jena-fuseki:4.0.0 /fuseki /fuseki </code></pre> <p>If I run <code>docker image build .</code> I get the following response</p> <pre><code>Sending build context to Docker daemon 435.9MB Step 1/2 : FROM python:3.8.15-slim ---&gt; f0fe0cb74bac Step 2/2 : COPY --from=stain/jena-fuseki:4.0.0 /fuseki /fuseki COPY failed: stat fuseki: file does not exist </code></pre> <p>However, I looked into the image with <code>docker run -it stain/jena-fuseki:4.0.0</code> and the directory does exist at the root level along with other directories which are copyable. E.g. following Dockerfile builds perfectly without any errors.</p> <pre><code>FROM python:3.8.15-slim COPY --from=stain/jena-fuseki:4.0.0 /jena-fuseki /jena-fuseki </code></pre> <p>I have tried many things like changing the working directory with <code>WORKDIR /</code> and also things like <code>COPY --from=stain/jena-fuseki:4.0.0 /fuseki/. /fuseki</code>. However, none of them are working. I have also not excluded anything with <code>.dockerignore</code></p>
[ { "answer_id": 74200127, "author": "Zacx", "author_id": 5282725, "author_profile": "https://Stackoverflow.com/users/5282725", "pm_score": -1, "selected": false, "text": "FROM stain/jena-fuseki:4.0.0 AS jena\nFROM python:3.8.15-slim\nCOPY --from=jena /jena-fuseki /jena-fuseki\n" } ]
2022/10/25
[ "https://Stackoverflow.com/questions/74199850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5445329/" ]
74,199,869
<p>I found a memory leak in my spring batch code. Just when I run the code below. Some people seem to say that jobexplorer causes a memory leak. Should I not use jobexplorer? thanks for the help.</p> <p>At boot : <a href="https://i.stack.imgur.com/xIqUf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xIqUf.png" alt="enter image description here" /></a></p> <p>Just 5 min later : 5gb more memory consumption</p> <p><a href="https://i.stack.imgur.com/b8dtO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/b8dtO.png" alt="enter image description here" /></a></p> <p>And 1 hour later, It's kills some process by oom kill.</p> <p>I use</p> <pre><code>java 11 spring boot 2.7.1 spring-boot-starter-batch 2.4.0 </code></pre> <p>This is my code. spring-batch processConfiguration and some class. -BlockProcessConfiguration -jobValidator</p> <pre><code>BlockProcessConfiguration </code></pre> <pre><code>@Configuration @RequiredArgsConstructor @Slf4j @Profile(&quot;block&quot;) public class BlockProcessConfiguration { @Value(&quot;${isStanby:false}&quot;) private Boolean isStanby; @Scheduled(fixedDelay = 500) public String launch() throws JobInstanceAlreadyCompleteException, JobExecutionAlreadyRunningException, JobParametersInvalidException, JobRestartException { if (isStanby != null &amp;&amp; isStanby) { Boolean isRunningJob = jobValidator.isExistLatestRunningJob(JOB_NAME, 5000); if (isRunningJob) { return &quot;skip&quot;; } } return &quot;completed&quot;; } </code></pre> <pre><code>jobValidator </code></pre> <pre><code> import java.util.*; @RequiredArgsConstructor @Slf4j @Component public class JobValidator { public enum batchMode { RECOVER, FORWARD } private final JobExplorer jobExplorer; public Boolean isExistLatestRunningJob(String jobName, long jobTTL) { List&lt;JobInstance&gt; jobInstances = jobExplorer.findJobInstancesByJobName(jobName, 0, 10000); if (jobInstances.size() &gt; 0) { List&lt;JobExecution&gt; jobExecutions = jobExplorer.getJobExecutions(jobInstances.get(0)); jobInstances.clear(); if (jobExecutions.size() &gt; 0) { JobExecution jobExecution = jobExecutions.get(0); jobExecutions.clear(); // boolean isRunning = jobExecution.isRunning(); Date createTime = jobExecution.getCreateTime(); long now = new Date().getTime(); long timeFrame = now - createTime.getTime(); log.info(&quot;createTime.getTime() : {}&quot;, createTime.getTime()); log.info(&quot;isExistLatestRunningJob found jobExecution : id, status, timeFrame, jobTTL : {}, {}, {}, {}&quot;, jobExecution.getJobId(), jobExecution.getStatus(), timeFrame, jobTTL); // if (jobExecution.isRunning() &amp;&amp; (now.getTime() - createTime.getTime()) &lt; jobTTL) { if ( timeFrame &lt; jobTTL ) { log.info(&quot;isExistLatestRunningJob result : {}&quot;, true); log.info(&quot;Job is already running, skip this job, job name : {}&quot;, jobName); return true; } } } return false; } public Boolean isExecutableJob(String jobName, String paramKey, Long paramValue) { List&lt;JobInstance&gt; jobInstances = jobExplorer.findJobInstancesByJobName(jobName, 0, 1); if (jobInstances.size() &gt; 0) { List&lt;JobExecution&gt; jobExecutions = jobExplorer.getJobExecutions(jobInstances.get(0)); if (jobExecutions.size() &gt; 0) { JobExecution jobExecution = jobExecutions.get(0); JobParameters jobParameters = jobExecution.getJobParameters(); Optional&lt;Long&gt; blockNumber = Optional.ofNullable(jobParameters.getLong(paramKey)); if (blockNumber.isPresent() &amp;&amp; blockNumber.get().equals(paramValue)) { if (jobExecution.getStatus().equals(BatchStatus.STARTED)) { // throw new RuntimeException(&quot;waiting until previous job done&quot;); log.info(&quot;waiting until previous job done ... : {}&quot;, jobName); return false; } } } } return true; } public Long getStartNumberFromBatch(String jobName, String batchMode, String paramKey1, String paramKey2, long defaultValue) { List&lt;JobInstance&gt; jobInstances = jobExplorer.findJobInstancesByJobName(jobName, 0, 20); ArrayList&lt;Long&gt; failExecutionNumbers = new ArrayList&lt;&gt;(); ArrayList&lt;Long&gt; successExecutionNumbers = new ArrayList&lt;&gt;(); ArrayList&lt;Long&gt; successEndExecutionNumbers = new ArrayList&lt;&gt;(); ArrayList&lt;JobExecution&gt; executions = new ArrayList&lt;&gt;(); jobInstances.stream().map(jobInstance -&gt; jobExplorer.getJobExecutions(jobInstance)).forEach(jobExecution -&gt; { JobParameters jobParameters = jobExecution.get(0).getJobParameters(); Optional&lt;Long&gt; param1 = Optional.ofNullable(jobParameters.getLong(paramKey1)); Optional&lt;Long&gt; param2 = Optional.ofNullable(jobParameters.getLong(paramKey2)); if (param1.isPresent() &amp;&amp; param2.isPresent()) { if (jobExecution.get(0).getExitStatus().getExitCode().equals(&quot;FAILED&quot;)) { failExecutionNumbers.add(param1.get()); } else { successExecutionNumbers.add(param1.get()); successEndExecutionNumbers.add(param2.get()); } } }); if (failExecutionNumbers.size() == 0 &amp;&amp; successExecutionNumbers.size() == 0) { return defaultValue; } long successMax = defaultValue; long failMin = defaultValue; if (successEndExecutionNumbers.size() &gt; 0) { successMax = Collections.max(successEndExecutionNumbers); } if (failExecutionNumbers.size() &gt; 0) { failExecutionNumbers.removeIf(successExecutionNumbers::contains); if (failExecutionNumbers.size() &gt; 0) { failMin = Collections.min(failExecutionNumbers); } else { return successMax; } } if (Objects.equals(batchMode, JobValidator.batchMode.RECOVER.toString())) { return Math.min(failMin, successMax); } else { return Math.max(failMin, successMax); } } } </code></pre>
[ { "answer_id": 74217713, "author": "Mahmoud Ben Hassine", "author_id": 5019386, "author_profile": "https://Stackoverflow.com/users/5019386", "pm_score": 1, "selected": false, "text": "isExistLatestRunningJob " } ]
2022/10/25
[ "https://Stackoverflow.com/questions/74199869", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20333813/" ]
74,199,880
<p>Is it possible to pass a value when using a custom annotated validation? The logic is different depending on the param value. In the example below, the chill room may require the key-value pairs to include &quot;snack&quot; : &quot;&quot; with max length 10, min length 1 <strong>similar to the @Size(min = 1, max = 10).</strong> I'm implementing the ConstraintValidator and set up the interface.</p> <p>i.e.</p> <pre><code>@ConcertValidation(dressingRoom = &quot;chill&quot;) private List&lt;Map&lt;String, String&gt;&gt; json; </code></pre>
[ { "answer_id": 74217713, "author": "Mahmoud Ben Hassine", "author_id": 5019386, "author_profile": "https://Stackoverflow.com/users/5019386", "pm_score": 1, "selected": false, "text": "isExistLatestRunningJob " } ]
2022/10/25
[ "https://Stackoverflow.com/questions/74199880", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19853034/" ]
74,199,907
<p>i am trying to get the data from this api <a href="https://js.cexplorer.io/api-static/basic/global.json" rel="nofollow noreferrer">https://js.cexplorer.io/api-static/basic/global.json</a></p> <p>here is my code</p> <pre><code>&lt;script&gt; fetch('https://js.cexplorer.io/api-static/basic/global.json').then((data)=&gt;{ return data.json(); }).then ((completedata)=&gt;{ let data1=&quot;&quot;; completedata.map((values)=&gt;{ data1=` &lt;div class=&quot;output&quot;&gt; &lt;h3&gt;Epoch&lt;/h3&gt; &lt;p&gt;${values.epochNo}&lt;/p&gt; &lt;/div&gt;` }); document.getElementById(&quot;live1&quot;).innerHTML=data1; }).catch((err)=&gt;{ console.log(err); }) &lt;/script&gt; </code></pre> <p>on google console i see this error: TypeError: completedata.map is not a function i don't understand where is the problem.. because with the same code but this api <a href="https://api.coinlore.net/api/ticker/?id=257" rel="nofollow noreferrer">https://api.coinlore.net/api/ticker/?id=257</a> works fine, where is the differece? thanks for any reply!</p>
[ { "answer_id": 74217713, "author": "Mahmoud Ben Hassine", "author_id": 5019386, "author_profile": "https://Stackoverflow.com/users/5019386", "pm_score": 1, "selected": false, "text": "isExistLatestRunningJob " } ]
2022/10/25
[ "https://Stackoverflow.com/questions/74199907", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20333909/" ]
74,199,977
<p>Lets say I have an IP address of <code>123.456.789.01</code></p> <p>I want to remove the last octet 123.456.789.<strong>01</strong> but not the period.</p> <p>So what I have left is <code>123.456.789.</code></p> <p>Any help is appreciated. Thank you.</p> <p>Linux Terminal</p> <p>I tried isolating the final octet but that just gives me the last octet <code>01</code> not <code>123.456.789.</code>:</p> <pre><code>$ address=123.456.789.01 $ oct=&quot;${address##*.}&quot; $ echo &quot;$oct&quot; 01 </code></pre>
[ { "answer_id": 74200218, "author": "Wiktor Stribiżew", "author_id": 3832970, "author_profile": "https://Stackoverflow.com/users/3832970", "pm_score": 3, "selected": true, "text": "#!/bin/bash\ns='123.456.789.01'\ns=\"${s%.*}.\"\necho \"$s\"\n# => 123.456.789.\n" }, { "answer_id":...
2022/10/25
[ "https://Stackoverflow.com/questions/74199977", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20333989/" ]
74,199,979
<p>I have been working on this and looking for a solution but can't find anything that gets me exactly what I want. I have two data frames. The first data frame is structured like this</p> <pre><code>Name &lt;- c(&quot;Doe, John&quot;, &quot;Doe, John&quot;, &quot;Smith, John&quot;) ID &lt;- c(&quot;123456&quot;, &quot;123456&quot;, &quot;345678&quot;) Collection &lt;- c(&quot;2021-01-03&quot;, &quot;2022-05-01&quot;, &quot;2022-06-14&quot;) df1&lt;-data.frame(Name, ID, Collection) </code></pre> <p>My second dataframe is structed like this</p> <pre><code>Number&lt;- c(&quot;M123&quot;, &quot;M456&quot;, &quot;M367&quot;) ID &lt;- c(&quot;123456&quot;, &quot;123456&quot;, &quot;345678&quot;) Complete_Date &lt;- c(&quot;2021-01-05&quot;, &quot;2022-06-01&quot;, &quot;2022-06-12&quot;) </code></pre> <p>I would like to remove observations in df1 that based on &quot;ID&quot; and &quot;Collection&quot; do not occur within 7 days (+/-) from any observation matching the same &quot;ID&quot; in df2</p> <p>So ideally my output from the two examples would be in a new dataframe (df3) and look like this since my second observation (ID: 123456) in df1 is not within 7 days of of either Complete_Date with that ID in df2</p> <pre><code>Name ID Collection Doe, John 123456 2021-01-03 Smith, John 345678 2022-06-14 </code></pre>
[ { "answer_id": 74200218, "author": "Wiktor Stribiżew", "author_id": 3832970, "author_profile": "https://Stackoverflow.com/users/3832970", "pm_score": 3, "selected": true, "text": "#!/bin/bash\ns='123.456.789.01'\ns=\"${s%.*}.\"\necho \"$s\"\n# => 123.456.789.\n" }, { "answer_id":...
2022/10/25
[ "https://Stackoverflow.com/questions/74199979", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11072536/" ]
74,200,007
<p>I have some issues with css image background, will only display if i use the live server extension from VS Code but when I try to open it by double clicking it or upload it on my hosting won't show up...and I am a bit stuck..</p> <p>the image is located in C:\Users\new01\OneDrive\Desktop\Site constructor\EcoFarm\img the index.html is located in EcoFarm</p> <p>here is the code</p> <pre><code> &lt;div class=&quot;banner&quot;&gt; &lt;div class=&quot;banner-content&quot;&gt; &lt;h1&gt;Eco Farm - Home&lt;/h1&gt; &lt;p&gt;Lorem ipsum dolor sit&lt;/p&gt; &lt;button class=&quot;discover&quot;&gt;Discover&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <pre><code>.banner{ background: url(/img/banner.jpg); background-position: center; background-repeat: no-repeat; background-size: cover; height: calc(80vh - 80px); text-align: center; } .banner-content{ width: 90%; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; } .banner h1{ color: #fff; font-size: 44px; padding: 20px 0px 30px 0px; } .banner p{ color: #fff; font-size: 16px; } .discover{ color: #fff; background-color: transparent; margin: 40px 0px; height: 50px; width: 180px; border-radius: 20px; border-color:#75D442; border-style: solid; font-weight: bold; font-size: 20px; cursor: pointer; } .discover:hover{ background-color: rgba(0, 0, 0, 0.2); } </code></pre>
[ { "answer_id": 74200218, "author": "Wiktor Stribiżew", "author_id": 3832970, "author_profile": "https://Stackoverflow.com/users/3832970", "pm_score": 3, "selected": true, "text": "#!/bin/bash\ns='123.456.789.01'\ns=\"${s%.*}.\"\necho \"$s\"\n# => 123.456.789.\n" }, { "answer_id":...
2022/10/25
[ "https://Stackoverflow.com/questions/74200007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20334001/" ]
74,200,015
<p>I am searching for an elegant solution for multiplying each i-th row of the matrix by the corresponding i-th value of the vector (element-wise). This can be done by iterating the rows of the matrix and the vector of scalars at the same time (as illustrated in the code snippet below) - but I am wondering whether there is a more elegant solution to that (perhaps using NDArray methods).</p> <pre><code>def normalise(matrix): norm_c = 1.00 / matrix.sum(axis=1) for i in range(len(matrix)): matrix[i] = matrix[i] * norm_c[i] return matrix </code></pre> <p>The problem popped out when I was writing a code to check if values in each row are summing up to 1. If they don't, we can simply obtain a scalar which would allow us to rescale each row correspondingly by one-liner:</p> <pre><code>norm_c = 1.00 / matrix.sum(axis=1) </code></pre> <p>Which will return an array of length equal to the number of rows in the original matrix. However, to rescale the original matrix, we must perform a scalar * array multiplication:</p> <pre><code>for i in range(len(matrix)): matrix[i] = matrix[i] * norm_c[i] </code></pre> <p>However, I feel that there must be a more elegant solution to that problem - one which does not require employing a basic for a loop - but I can't just fine one.</p>
[ { "answer_id": 74200150, "author": "flawr", "author_id": 2913106, "author_profile": "https://Stackoverflow.com/users/2913106", "pm_score": 2, "selected": false, "text": "matrix / matrix.sum(axis=1)[:, None]\n" } ]
2022/10/25
[ "https://Stackoverflow.com/questions/74200015", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15108155/" ]
74,200,031
<p>I have 2 JSON structures one is an object the other one is an array though it will always have either no objects or just 1 JSON object.</p> <p>The First JSON object is like:</p> <pre><code>var var1={ &quot;orgID&quot;: &quot;1234&quot;, &quot;apiID&quot;: 100, &quot;envID&quot;: &quot;45678&quot;, &quot;apiName&quot;: &quot;logging-system-api&quot;, &quot;exchangeAsset&quot;: &quot;Logging System API&quot; } </code></pre> <p>the JSON array looks like:</p> <pre><code>var var2=[{ &quot;apiID&quot;: 100, &quot;policyName1&quot;: &quot;client-id-enforcement&quot;, &quot;policyName2&quot;: null, &quot;policyName3&quot;: null, &quot;policyName4&quot;: null, &quot;policyName5&quot;: null, &quot;policyName6&quot;: null }] </code></pre> <p>or it could be</p> <pre><code>var var2=[] </code></pre> <p>the desired output always is a JSON Object like:</p> <pre><code>{ &quot;orgID&quot;: &quot;1234&quot;, &quot;apiID&quot;: 100, &quot;envID&quot;: &quot;45678&quot;, &quot;apiName&quot;: &quot;logging-system-api&quot;, &quot;exchangeAsset&quot;: &quot;Logging System API&quot; &quot;policyName1&quot;: &quot;client-id-enforcement&quot;, &quot;policyName2&quot;: null, &quot;policyName3&quot;: null, &quot;policyName4&quot;: null, &quot;policyName5&quot;: null, &quot;policyName6&quot;: null } </code></pre> <p>Note: first JSON structure is an object second JSON structure is an array though it has 0 or 1 element always. policyName1 to policyName6 always needs to be in the output irrespective of whether the second JSON array contains something or not.</p>
[ { "answer_id": 74200210, "author": "aled", "author_id": 721855, "author_profile": "https://Stackoverflow.com/users/721855", "pm_score": 3, "selected": true, "text": "var1" }, { "answer_id": 74200321, "author": "machaval", "author_id": 1472690, "author_profile": "https...
2022/10/25
[ "https://Stackoverflow.com/questions/74200031", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4771802/" ]
74,200,040
<p>I have a df with some NaN values and I want to replace them with the mean of the values on the adjacents columns (at the same line).</p> <p>How can I do it?</p> <p>I'm trying to iterate over all the elements of the dataframe but I'm not going anywhere. Can someone please help me?</p> <p>Example: in this df, I would like to replace the NaN value with the mean of adjacent columns, the mean between 0 and -2. How can I do that?</p> <pre><code>import pandas as pd import numpy as np d = {'col1': [4, 0, 2], 'col2': [1, np.nan, 4], 'col3': [12, -2, 4]} df = pd.DataFrame(data=d) df.head() </code></pre>
[ { "answer_id": 74200210, "author": "aled", "author_id": 721855, "author_profile": "https://Stackoverflow.com/users/721855", "pm_score": 3, "selected": true, "text": "var1" }, { "answer_id": 74200321, "author": "machaval", "author_id": 1472690, "author_profile": "https...
2022/10/25
[ "https://Stackoverflow.com/questions/74200040", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12926016/" ]
74,200,047
<p>I'm currently working on ASP.Net Core MVC app with <a href="https://www.telerik.com/aspnet-core-ui/grid" rel="nofollow noreferrer">Telerik Kendo Grid</a></p> <p>On the grid I have columns like:</p> <pre><code> .Columns(columns =&gt; { columns.Bound(x =&gt; x.PrimaryContact.EmailAddress) }) </code></pre> <p>But this is throwing an error:</p> <blockquote> <p>Uncaught TypeError: Cannot read properties of null</p> </blockquote> <p>Because PrimaryContact property can be null</p> <p>To solve this I try:</p> <pre><code>columns.Bound(x =&gt; x.PrimaryContact != null ? x.PrimaryContact.EmailAddress : string.Empty) </code></pre> <p>But now is returning the error:</p> <blockquote> <p>InvalidOperationException: Bound columns require a field or property access expression.</p> </blockquote> <p>How can I support nullable in kendo columns?</p>
[ { "answer_id": 74200348, "author": "Dimitris Maragkos", "author_id": 10839134, "author_profile": "https://Stackoverflow.com/users/10839134", "pm_score": 2, "selected": true, "text": "ClientTemplate" }, { "answer_id": 74200658, "author": "NigelK", "author_id": 1871207, ...
2022/10/25
[ "https://Stackoverflow.com/questions/74200047", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20286048/" ]
74,200,051
<p>I have a navbar containing two divs for 'nav-left' and 'nav-right'. I want to float them left and right plus have the sticky position.</p> <p>The elements in the navbar are not of the same height. The left elements are up and the right elements are down. I need them to be vertically centered.</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> nav { position: sticky; width: 100%; background: green; margin: 0; padding: 0; } nav ul { list-style-type: none; margin: 0; padding: 0; overflow: hidden; position: relative; } nav a { display: inline-block; width: 60px; text-decoration: none; } .nav-left li { float: left; } .nav-right li { float: right; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;header class="header"&gt; &lt;nav class="nav"&gt; &lt;div class="nav-left"&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#"&gt;Blah&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Blah&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Blah&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;div class="nav-right"&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#"&gt;Bloh&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Bloh&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/nav&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74200164, "author": "Johannes", "author_id": 5641669, "author_profile": "https://Stackoverflow.com/users/5641669", "pm_score": 1, "selected": false, "text": "display: flex;" }, { "answer_id": 74200311, "author": "Christian", "author_id": 3842598, "autho...
2022/10/25
[ "https://Stackoverflow.com/questions/74200051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12227954/" ]
74,200,055
<p>have now tried in 2 days to show the tables from the database (service_types) With now luck, im new to laravel but i have manage to fix mulltiple problems, but this is giving me a headache.</p> <p>in the index i have this code:</p> <pre><code>&lt;h3 class=&quot;elementor-heading-title elementor-size-default&quot;&gt;{{ trans('index.header_3') }}&lt;/h3&gt; &lt;div class=&quot;col-md-12 text-center&quot; style=&quot;width: 100% !important&quot;&gt; @foreach($service_type as $index =&gt; $service) &lt;div class=&quot;col-md-3&quot; style=&quot;margin-left: 00px; margin-right: 00px width: 30%&quot;&gt; @if($service-&gt;image) &lt;img src=&quot;{{$service-&gt;image}}&quot; style=&quot;height: 50px&quot; &gt; @else N/A @endif&lt;br&gt;{{ $service-&gt;name }} &lt;/div&gt; @endforeach &lt;/div&gt; &lt;/div&gt; </code></pre> <p>but nothing is shown. Please help.</p> <p>UPPDATE. I create one ServiceTypeController.php and add it in the controller folder.</p> <p>i add this code:</p> <pre><code>&lt;?php namespace App\Http\Controllers; use Illuminate\Http\Request; use DB; use App\Http\Requests; use App\ServiceType; use App\Http\Controllers\Controller; class ServiceTypeController extends Controller { public function index(){ $service_type = DB::select('select * from service_type'); return view('index',['service_type'=&gt;$service_type]); } } </code></pre> <p>And in the web.php in routes:</p> <pre><code>Route::get('/','ServiceTypeController@index'); </code></pre> <p>Still dont get any data on the page :(</p>
[ { "answer_id": 74200342, "author": "Dimitrije Drakulic", "author_id": 16803819, "author_profile": "https://Stackoverflow.com/users/16803819", "pm_score": -1, "selected": false, "text": "{{ dd($service_type) }}\n" }, { "answer_id": 74200384, "author": "kaann.gunerr", "auth...
2022/10/25
[ "https://Stackoverflow.com/questions/74200055", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3551443/" ]
74,200,062
<p>I am trying build a basic currency converter and having issues binding the selected option and displaying its value in the input</p> <pre class="lang-html prettyprint-override"><code>&lt;template&gt; &lt;div class=&quot;mx-auto flex flex-col justify-center items-center h-screen&quot;&gt; &lt;h1 class=&quot;text-3xl font-bold underline&quot;&gt; Currency Converter &lt;/h1&gt; &lt;div class=&quot;inline-block py-5&quot;&gt; &lt;input v-model=&quot;currencyValue&quot; class=&quot;bg-gray-400&quot; type=&quot;number&quot;&gt; &lt;select&gt; &lt;option v-for=&quot;Currency in currencyName&quot; :key=&quot;Currency&quot;&gt; {{ Currency }} &lt;/option&gt; &lt;/select&gt; &lt;/div&gt; = &lt;div class=&quot;inline-block py-5&quot;&gt; &lt;input v-model=&quot;currencyValue&quot; class=&quot;bg-gray-400&quot; type=&quot;number&quot;&gt; &lt;select&gt; &lt;option v-for=&quot;Currency in currencyName&quot; :key=&quot;Currency&quot;&gt; {{ Currency }} &lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;/div&gt; &lt;/template&gt; </code></pre> <pre class="lang-js prettyprint-override"><code>&lt;script&gt; export default { data() { return { listItems: [], currencyName: [], currencyValue: [] } }, methods: { async getData() { const res = await fetch(&quot;https://api.exchangerate.host/latest&quot;); const finalRes = await res.json(); this.listItems = finalRes.rates; this.currencyName = Object.keys(this.listItems) this.currencyValue = Object.values(this.listItems) console.log(this.currencyName); console.log(this.currencyValue); console.log(this.listItems); } }, mounted() { this.getData() } } &lt;/script&gt; </code></pre> <p>I tried using a v-model on the input however I still seem to be needing more to loop through the values in the object from the API</p>
[ { "answer_id": 74200342, "author": "Dimitrije Drakulic", "author_id": 16803819, "author_profile": "https://Stackoverflow.com/users/16803819", "pm_score": -1, "selected": false, "text": "{{ dd($service_type) }}\n" }, { "answer_id": 74200384, "author": "kaann.gunerr", "auth...
2022/10/25
[ "https://Stackoverflow.com/questions/74200062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20333900/" ]
74,200,079
<p>I want to share memory between a program in C and another in python.</p> <p>The c program uses the following structure to define the data.</p> <pre><code>struct Memory_LaserFrontal { char Data[372]; // original data float Med[181]; // Measurements in [m] charD; // 'I': Invalid -- 'V': Valid charS; // 'L': Clean -- 'S': Dirty char LaserStatus[2]; }; </code></pre> <p>From python I have managed to read the variable in memory using sysv_ipc but they have no structure and is seen as a data array. How can I restructure them?</p> <p>python code:</p> <pre><code>from time import sleep import sysv_ipc # Create shared memory object memory = sysv_ipc.SharedMemory(1234) # Read value from shared memory memory_value = memory.read() print (memory_value) print (len(memory_value)) while True: memory_value = memory.read() print (float(memory_value[800])) sleep(0.1) </code></pre> <p>I have captured and printed the data in python, I have modified the sensor reading and the read data is also modified, confirming that the read data corresponds to the data in the sensor's shared memory. But without the proper structure y cant use the data.</p>
[ { "answer_id": 74201305, "author": "JimmyNJ", "author_id": 6016071, "author_profile": "https://Stackoverflow.com/users/6016071", "pm_score": 0, "selected": false, "text": "struct" }, { "answer_id": 74214295, "author": "PBocca", "author_id": 11804757, "author_profile":...
2022/10/25
[ "https://Stackoverflow.com/questions/74200079", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11804757/" ]
74,200,095
<p>I have a simple java program that when run is supposed to traverse through the whole directory on a Unix server and log all files on the fileserver that contain Norwegian letters &quot;å,ø,æ&quot;.</p> <p>This is how it looks on the fileserver using winSCP: <a href="https://i.stack.imgur.com/zhwCZ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zhwCZ.jpg" alt="enter image description here" /></a></p> <p>In the end the logs.log file should look like this:</p> <pre><code>2022-10-25 14:27:02 INFO Logger:99 - File: 'DN_Oppmålings.pdf' 2022-10-25 14:27:02 INFO Logger:99 - File: 'Salg_av_gærden.pdf' </code></pre> <p>However, this is how it ends up in the log file, all Norwegian letters are represented with a square. <a href="https://i.stack.imgur.com/hrLxs.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hrLxs.jpg" alt="enter image description here" /></a></p> <p>I can't seem to figure out why it happens. It probably has something to do with the encodings. Because when I run it on windows locally, everything runs as expected and I get the result I need. But when I build the project as an executable jar and run on the server it gets wrong.</p> <p>Here is the code I am using.</p> <pre><code>public static void renameFiles3(File[] files) throws IOException { for (File filename : files) { if (filename.isDirectory()) { renameFiles3(filename.listFiles()); } else { String fileNameString = filename.getName(); if (fileNameString.contains(&quot;å&quot;) || fileNameString.contains(&quot;ø&quot;) || fileNameString.contains(&quot;æ&quot;)){ logger.info(&quot;File: '&quot; + filename.getName()); } } } } public static void main(String[] args) { File[] files = new File(path).listFiles(); try { renamer.renameFiles3(files); } catch catch(IOException ex){ logger.error(ex.toString()); } } </code></pre> <p>Someone pointed out that the encoding should be specified, but I am not sure how that is done. If I run &quot;locale&quot; command on the Unix server this is what I get as output.</p> <pre><code>[e1111111@ilt repository]$ locale LANG=en_US.UTF-8 LC_CTYPE=&quot;en_US.UTF-8&quot; LC_NUMERIC=&quot;en_US.UTF-8&quot; LC_TIME=&quot;en_US.UTF-8&quot; LC_COLLATE=&quot;en_US.UTF-8&quot; LC_MONETARY=&quot;en_US.UTF-8&quot; LC_MESSAGES=&quot;en_US.UTF-8&quot; LC_PAPER=&quot;en_US.UTF-8&quot; LC_NAME=&quot;en_US.UTF-8&quot; LC_ADDRESS=&quot;en_US.UTF-8&quot; LC_TELEPHONE=&quot;en_US.UTF-8&quot; LC_MEASUREMENT=&quot;en_US.UTF-8&quot; LC_IDENTIFICATION=&quot;en_US.UTF-8&quot; LC_ALL= </code></pre> <p>I use Putty to run the jar file. Here are the configs. <a href="https://i.stack.imgur.com/YYcSo.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YYcSo.jpg" alt="enter image description here" /></a></p> <p>Stacktrace of the error I get when running the jar:</p> <pre><code>java.nio.file.NoSuchFileException: ./documentRepository/DN_Oppm�lings.pdf at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92) at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111) at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116) at java.base/sun.nio.fs.UnixCopyFile.move(UnixCopyFile.java:430) at java.base/sun.nio.fs.UnixFileSystemProvider.move(UnixFileSystemProvider.java:267) at java.base/java.nio.file.Files.move(Files.java:1422) at com.example.fixfilenamesonfileserver.Renamer.renameFiles2(Renamer.java:105) at com.example.fixfilenamesonfileserver.Renamer.renameFiles2(Renamer.java:89) at com.example.fixfilenamesonfileserver.Renamer.renameFiles2(Renamer.java:89) at com.example.fixfilenamesonfileserver.Renamer.renameFiles2(Renamer.java:89) at com.example.fixfilenamesonfileserver.Renamer.renameFiles2(Renamer.java:89) at com.example.fixfilenamesonfileserver.Renamer.renameFiles2(Renamer.java:89) at com.example.fixfilenamesonfileserver.Renamer.renameFiles2(Renamer.java:89) at com.example.fixfilenamesonfileserver.Renamer.main(Renamer.java:154) </code></pre> <p>What makes it even more strange, is that I can create for instance a folder with mkdir containing Norwegian letters in the name and it would be displayed correctly and also logged correctly if I create a file with Norwegian letters.</p>
[ { "answer_id": 74247119, "author": "jccampanero", "author_id": 13942448, "author_profile": "https://Stackoverflow.com/users/13942448", "pm_score": 2, "selected": false, "text": "cp-1252" }, { "answer_id": 74322014, "author": "hidden_machine", "author_id": 16348170, "a...
2022/10/25
[ "https://Stackoverflow.com/questions/74200095", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10149027/" ]
74,200,111
<p>I've seen many similar questions like this asked, but I'm still stumped.</p> <p>I want an onEdit script to only work on a specific tab. I've tried several things but none of them are working correctly.</p> <p>The tab on my sheet is called 'WEB Graffiti'. I want to run this script on other tabs on my sheet, but the columns are in different orders. I know how to edit the script to edit different columns but I don't know how to make it only work on the specified tab.</p> <p>Here is the script I'm using.</p> <pre><code>function onEdit(e) { if (!e) { throw new Error( ); } indirectTimestamp_(e); } /** * Inserts a timestamp in column T when column B is edited * and column C contains the value TRUE. * * @param {testing} e The onEdit() event object. */ function indirectTimestamp_(e) { if (e.range.columnStart !== 2 || e.range.offset(0, 1).getDisplayValue() !== 'TRUE') { return; } const timestampCell = e.range.offset(0, 18); timestampCell.setValue(new Date()).setNumberFormat('mmm&quot; &quot;d&quot; &quot;yyyy'); }; </code></pre> <p>I tried adding</p> <pre><code> var spreadsheet = SpreadsheetApp.getActive(); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('WEB Graffiti'), true); </code></pre> <p>I tried this and several variations in various locations of the script and it was not working properly.</p>
[ { "answer_id": 74247119, "author": "jccampanero", "author_id": 13942448, "author_profile": "https://Stackoverflow.com/users/13942448", "pm_score": 2, "selected": false, "text": "cp-1252" }, { "answer_id": 74322014, "author": "hidden_machine", "author_id": 16348170, "a...
2022/10/25
[ "https://Stackoverflow.com/questions/74200111", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20333998/" ]
74,200,131
<p>I have a problem in which i need to use @media in html. You use @media in css but now i need to use it in html but i cannot find a way on how to do so.</p> <p>I expect to change some styling</p>
[ { "answer_id": 74200175, "author": "Quentin", "author_id": 19068, "author_profile": "https://Stackoverflow.com/users/19068", "pm_score": 2, "selected": true, "text": "style" }, { "answer_id": 74200948, "author": "Mou Niir", "author_id": 17405262, "author_profile": "ht...
2022/10/25
[ "https://Stackoverflow.com/questions/74200131", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17741933/" ]
74,200,159
<p>The situation is as follows. I have a parent array which looks like the following:</p> <pre><code>$parent = [ 1 =&gt; ['test1', 'test2'], 2 =&gt; ['test1_1', 'test2_2'], ]; </code></pre> <p>I would like to group the data by column.</p> <p>Desired result:</p> <pre><code>[ 1 =&gt; ['test1', 'test1_1'], 2 =&gt; ['test2', 'test2_2'], ] </code></pre> <p>1 parent array called parent contains 2 arrays inside. I want to combine these two so that they have the same values as stated above. So this would mean that the arrays should be combined based on index number.</p> <p>Since I do not make use of string keys, how would I accomplish this? I believe that there is no build in function available for this situation.</p> <p>I would imagine that I could start beginning to create a new array and use a for loop through the parent array.</p> <p>I tried the <a href="https://www.php.net/manual/en/function.array-combine.php" rel="nofollow noreferrer">array-combine</a> function however, this is NOT displaying the results I want.</p> <pre><code>[ 1 =&gt; ['test1' =&gt; 'test1_1', 'test2' =&gt; 'test2_2' ] </code></pre>
[ { "answer_id": 74200175, "author": "Quentin", "author_id": 19068, "author_profile": "https://Stackoverflow.com/users/19068", "pm_score": 2, "selected": true, "text": "style" }, { "answer_id": 74200948, "author": "Mou Niir", "author_id": 17405262, "author_profile": "ht...
2022/10/25
[ "https://Stackoverflow.com/questions/74200159", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20333984/" ]
74,200,300
<p>I'm using the code below to import the data, but it takes a very long time, knowing that the size of the data is not large only (3.3 megabytes). Is it possible to modify the code or use another method to speed up the data import process?</p> <p>code: <code>LOAD CSV WITH HEADERS FROM 'file:///Musae-Github.csv' as line</code> <code>WITH toInteger(line.source) AS Source, toInteger(line.destination) AS Destination </code> <code>MERGE (a:person {name:Source})</code> <code>MERGE (b:person {name:Destination})</code> <code>MERGE (a)-[:Freind ]-(b)</code> <code>RETURN *</code></p>
[ { "answer_id": 74200871, "author": "Vincent Rupp", "author_id": 4024409, "author_profile": "https://Stackoverflow.com/users/4024409", "pm_score": 0, "selected": false, "text": "LOAD CSV FROM \"yourpathhere\" as line\nreturn linenumber(), datetime(), line\n" }, { "answer_id": 7420...
2022/10/25
[ "https://Stackoverflow.com/questions/74200300", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19469447/" ]
74,200,331
<p>I have to create a list of tuples without using the tuple() function. The input is a list of lists where each list contains a profile ID and the calendar date on which the user went of a date. The output is a list of tuples showing the profile ID and the number of dates the user went on.</p> <p>The final output should be a list of tuples, but my code outputs each element individually. Below is the code I wrote to try to convert the list elements to tuples.</p> <pre class="lang-py prettyprint-override"><code>for stuff in datingTrack: for smallerStuff in stuff: tuplesList = (smallerStuff) datingTrack2.append(tuplesList) </code></pre> <pre><code>input: [[&quot;B111&quot;, &quot;10/2/2022&quot;], [&quot;B222&quot;, &quot;9/25/2022&quot;], [&quot;B333&quot;, &quot;8/1/2022&quot;], [&quot;B222&quot;, &quot;9/2/2022&quot;]] my output: ['B111', 1, 'B222', 2, 'B333', 1] Expected output: [('B111', 1,) ('B222', 2), ('B333', 1)] </code></pre>
[ { "answer_id": 74200380, "author": "Andrej Kesely", "author_id": 10035985, "author_profile": "https://Stackoverflow.com/users/10035985", "pm_score": 2, "selected": false, "text": "collections.Counter" }, { "answer_id": 74200410, "author": "MoonMist", "author_id": 8669256,...
2022/10/25
[ "https://Stackoverflow.com/questions/74200331", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20334210/" ]
74,200,339
<p>I tried the code below, but unfortunately, it only names the last cell in the range as opposed to each cell in the range.</p> <p>I am trying to run this loop so that starting from cell A1, any non empty cells are named &quot;Guidance 1&quot;, &quot;Guidance2&quot;, and so on and so forth.</p> <p>Below is the code I have so far:</p> <pre><code>Sub GiveAllCellsNames() Dim wb As Workbook Set wb = ActiveWorkbook Dim R As Range Dim NameX As String Static I As Long I = I + 1 NameX = &quot;Guidance&quot; &amp; I For Each R In Range(&quot;A1:A390&quot;).Cells If R.Value &lt;&gt; &quot;&quot; Then With R wb.Names.Add NameX, RefersTo:=R End With End If Next R End Sub </code></pre> <p>I have tried this loop without using the &quot;with statement&quot; on the &quot;R&quot; range variable and still seem to get the same result. I have also tried to find articles relating to this **naming **topic in conjunction with loop guidance, but have only been able to find guidance available on naming entire ranges rather than looping through.</p> <p>Any help would be appreciated.</p> <p>Thank you in advance.</p>
[ { "answer_id": 74200380, "author": "Andrej Kesely", "author_id": 10035985, "author_profile": "https://Stackoverflow.com/users/10035985", "pm_score": 2, "selected": false, "text": "collections.Counter" }, { "answer_id": 74200410, "author": "MoonMist", "author_id": 8669256,...
2022/10/25
[ "https://Stackoverflow.com/questions/74200339", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10301382/" ]
74,200,376
<p>I am getting this problem in C programming. I'm new to C so I would like some help.</p> <p>Anyine know why this is happening?</p> <p>I'm trying to get the dir path using getcwd and I'm not even formatting so I don't get why I'm getting this warning? My code is below:</p> <pre class="lang-none prettyprint-override"><code>replace.c: In function ‘main’: replace.c:49:8: warning: too many arguments for format [-Wformat-extra-args] </code></pre> <pre><code>printf(&quot;Search begins in current folder: &quot;, getcwd(currDir, sizeof(currDir)), &quot;\n&quot;); </code></pre>
[ { "answer_id": 74200380, "author": "Andrej Kesely", "author_id": 10035985, "author_profile": "https://Stackoverflow.com/users/10035985", "pm_score": 2, "selected": false, "text": "collections.Counter" }, { "answer_id": 74200410, "author": "MoonMist", "author_id": 8669256,...
2022/10/25
[ "https://Stackoverflow.com/questions/74200376", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18081953/" ]
74,200,390
<ol> <li><p>I am trying to get data from a Power Bi table. There are some elements that appear when hovering over a table. When I right click on <code>...</code> I don't see <code>Inspect Element</code>. However, when I left click on this element, I can see a menu, and if I right click on any items, I can see <code>Inspect element</code>. My first question, is why I don't see <code>Inspect Element</code> in the right click menu for all elements in the browser. Am I somehow able to open this <code>...</code> menu programmatically in Selenium?</p> </li> <li><p>the Export Data element only appears in HTML after the first left click. I'm assuming this is created using Javascript and in order to export data with Selenium I would have to programmatically instantiate this by clicking on the <code>...</code> menu. Is selenium capable of triggering javascript functions that generate more html code in a dynamic webpage? Or do I need to somehow click on the <code>...</code> element.</p> </li> <li><p>If I can execute a javascript function, how can I find out in Edge the javascript function that gets executed and how can I replicate this function in Selenium</p> </li> </ol> <p>Essentially, if I try to find the <code>Export data</code> element in Selenium, it is not able to find it, unless I set a breakpoint before search, then in EdgeDriver I open this menu, and then I can find it and click it through Python</p> <ol start="4"> <li>If all else fails, can I programmatically open the left click menu by automating a mouse click at certain coordinates in Selenium?</li> </ol> <p><a href="https://i.stack.imgur.com/hX1SX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hX1SX.png" alt="... right click doesn't have Inspect Element" /></a></p> <p><a href="https://i.stack.imgur.com/URVYx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/URVYx.png" alt="The left click menu does have inspect element" /></a></p>
[ { "answer_id": 74313328, "author": "r000bin", "author_id": 12914172, "author_profile": "https://Stackoverflow.com/users/12914172", "pm_score": 2, "selected": false, "text": "Inspect Element" }, { "answer_id": 74319186, "author": "Wouter", "author_id": 6421290, "author...
2022/10/25
[ "https://Stackoverflow.com/questions/74200390", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7375877/" ]
74,200,395
<p>I was sent a Git repository (the .git folder) from an untrusted source.</p> <p>I want to take a look at it with GitHub Desktop that I have installed, but I don't know enough about the inner workings of Git to know if this is dangerous. Is it safe like opening a text file with notepad, or potentially more dangerous?</p>
[ { "answer_id": 74209310, "author": "TTT", "author_id": 184546, "author_profile": "https://Stackoverflow.com/users/184546", "pm_score": 2, "selected": false, "text": ".git" } ]
2022/10/25
[ "https://Stackoverflow.com/questions/74200395", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6571814/" ]
74,200,406
<p>I'm following a unity tutorial and made a very basic top-down 2D scene using tilemaps. Starting up the game the rendering seems fine, but as soon the camera moves along the Y axis, the tiles seems to &quot;move apart&quot;. Also, the sprites I use seems to get an offset for the tile-map, as if they were cut incorrectly. (1 pixel dilation on the y axis.)</p> <p>Before moving: <a href="https://i.stack.imgur.com/w2ACU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/w2ACU.png" alt="Before moving" /></a></p> <p>After moving: <a href="https://i.stack.imgur.com/yb4Yx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yb4Yx.png" alt="After moving" /></a></p> <p>Any ideas why this happens and how to deal with it?</p> <p>My issue seems to be something like <a href="https://stackoverflow.com/questions/67287236/unity-2d-problem-tilemap-tearing-in-only-scene-view">this one</a>, but there were no answers here. <a href="https://stackoverflow.com/questions/60131313/experiencing-a-strange-tile-rendering-bug-in-unitys-scene-view">Another thread</a> found a solution to a similar issue, however I couldn't make this work, as Unity does not allow me to directly change the Pixel Snap property of the shader, but says &quot;MaterialPropertyBlock is used to modify these values&quot;.</p>
[ { "answer_id": 74209310, "author": "TTT", "author_id": 184546, "author_profile": "https://Stackoverflow.com/users/184546", "pm_score": 2, "selected": false, "text": ".git" } ]
2022/10/25
[ "https://Stackoverflow.com/questions/74200406", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4541502/" ]
74,200,426
<p>I've got a class which contains the following:</p> <pre><code>while (true) { // if minimum element in the queue is greater than required sweetness // then we are done if (queue.peek() &gt;= minSweetness) { solutionPossible = true; break; } else { // if there are more than or equal to 2 elements, // then only solution is possible // because we have already checked queue.peek() for the single element // present, and that is less than minSweetness if (queue.size() &gt;= 2) { // remove minimum and 2nd minimum values int a1 = queue.poll(); int a2 = queue.poll(); // again push the value to the queue // after calculating the combined sweetness queue.offer(a1 + 2 * a2); } else { // for single element that is less than required sweetness // no solution is possible solutionPossible = false; break; } // increase total number of operations operations++; } } </code></pre> <blockquote> </blockquote> <p>Here is a screenshot: <a href="https://i.stack.imgur.com/8XXXe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8XXXe.png" alt="enter image description here" /></a></p> <p>VScode tells me to reduce the total number of break and continue statements in this loop to use at most one, so I am not as experienced as to what other method I can think of, I tried to used quick fix and It didn't work, anybody has any idea how to write this class differently...?</p> <p>I tried to use quick fix and it didn't show other options though...</p>
[ { "answer_id": 74200557, "author": "Old Dog Programmer", "author_id": 5103317, "author_profile": "https://Stackoverflow.com/users/5103317", "pm_score": 1, "selected": true, "text": "while" }, { "answer_id": 74201058, "author": "67af7af3-67f3-48bf-98c5-d9155c", "author_id"...
2022/10/25
[ "https://Stackoverflow.com/questions/74200426", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14890496/" ]
74,200,429
<p>To succinctly generate the json string <code>{&quot;limit&quot;: 1}</code> in C#, I can serialize an equivalent anonymous object like so:</p> <pre><code>var s = JsonSerializer.Serialize(new { limit = 1 }); </code></pre> <p>What if I want to to generate <code>{&quot;$limit&quot;: 1}</code> instead? Is there any way of doing that with an anonymous object, or do I have to bring out the big guns?</p>
[ { "answer_id": 74200520, "author": "Serge", "author_id": 11392290, "author_profile": "https://Stackoverflow.com/users/11392290", "pm_score": 1, "selected": false, "text": "var json = System.Text.Json.JsonSerializer.Serialize(new Dictionary<string, int> { { \"$limit\", 1 } });\n" }, {...
2022/10/25
[ "https://Stackoverflow.com/questions/74200429", "https://Stackoverflow.com", "https://Stackoverflow.com/users/68602/" ]
74,200,509
<p>I am trying to add a Week # Column to df1. I want to assign week numbers based on date ranges found in df2.</p> <pre><code>df1 WorkDate 2022-05-03 2022-05-16 2022-05-24 </code></pre> <pre><code>df2 Week # Week Start Week End 1 2022-05-01 2022-05-07 2 2022-05-08 2022-05-14 3 2022-05-15 2022-05-21 4 2022-05-22 2022-05-28 5 2022-05-29 2022-06-04 </code></pre> <p>Expected Results</p> <pre><code>final_df WorkDate Week # 2022-05-03 1 2022-05-16 3 2022-05-24 4 </code></pre>
[ { "answer_id": 74200555, "author": "Andrej Kesely", "author_id": 10035985, "author_profile": "https://Stackoverflow.com/users/10035985", "pm_score": 2, "selected": false, "text": "pd.merge_asof" }, { "answer_id": 74201057, "author": "sammywemmy", "author_id": 7175713, ...
2022/10/25
[ "https://Stackoverflow.com/questions/74200509", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15411312/" ]
74,200,528
<p>When I run this I can't seem to get the rest of the values. Write a function <code>mergingTripletsAndQuints</code> which takes in two arrays as arguments. This function will return a new array replacing the elements in <code>array1</code> if they are divisible by 3 or 5. The number should be replaced with the sum of itself added to the element at the corresponding index in <code>array2</code>.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>function mergingTripletsAndQuints(array1, array2) { let result = []; let ctr = 0; let x = 0; for (let i = 0; i &lt; array1.length; i++) { for (let j = 0; j &lt; array2.length; j++) { ctr = array1[i] + array2[j]; if (ctr % 3 === 0 || ctr % 5 === 0) { result.push(ctr); } else { return array1[i]; } } } return result; } console.log(mergingTripletsAndQuints([1, 2, 3, 4, 5, 15], [1, 3, 6, 7, 8, 9])); // expected log [1, 2, 9, 4, 13, 24] console.log(mergingTripletsAndQuints([1, 1, 3, 9, 5, 15], [1, 2, 3, 4, 5, 6])); // expected log [1, 1, 6, 13, 10, 21]</code></pre> </div> </div> </p> <p>It is only logging <code>[1], [1]</code></p>
[ { "answer_id": 74200581, "author": "rib", "author_id": 3928418, "author_profile": "https://Stackoverflow.com/users/3928418", "pm_score": 1, "selected": false, "text": "array1[i]" }, { "answer_id": 74201043, "author": "Yohan Olmedo", "author_id": 20334400, "author_prof...
2022/10/25
[ "https://Stackoverflow.com/questions/74200528", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20334332/" ]
74,200,529
<p>I'm not very experienced with git but set up a public mirror of a private repository a few months ago and now want to update it to the current status of the private repository.</p> <p>I'm following the instructions here and pretty sure this is what I followed when initially creating the mirror:</p> <ul> <li><a href="https://docs.github.com/en/repositories/creating-and-managing-repositories/duplicating-a-repository#mirroring-a-repository" rel="nofollow noreferrer">Mirroring a repository</a></li> </ul> <p>However, this time when I execute the following:</p> <pre><code>git clone --mirror https://github.com/billtubbs/process-observers.git cd process-observers.git/ git push --mirror https://github.com/billtubbs/ml-obs.git </code></pre> <p>I get</p> <pre><code>Enumerating objects: 991, done. Counting objects: 100% (991/991), done. Delta compression using up to 8 threads Compressing objects: 100% (261/261), done. Writing objects: 100% (938/938), 2.27 MiB | 2.67 MiB/s, done. Total 938 (delta 724), reused 889 (delta 677) remote: Resolving deltas: 100% (724/724), completed with 40 local objects. To https://github.com/billtubbs/ml-obs.git + 74c80ea...9ff3e6b main -&gt; main (forced update) dce6fcc..9ff3e6b origin/main -&gt; origin/main * [new branch] origin/HEAD -&gt; origin/HEAD ! [remote rejected] refs/pull/1/head -&gt; refs/pull/1/head (deny updating a hidden ref) ! [remote rejected] refs/pull/2/head -&gt; refs/pull/2/head (deny updating a hidden ref) error: failed to push some refs to 'https://github.com/billtubbs/ml-obs.git' </code></pre> <p>What does this mean &quot;failed to push some refs to ...&quot;?</p> <p>All the files seem to be updated.</p>
[ { "answer_id": 74200581, "author": "rib", "author_id": 3928418, "author_profile": "https://Stackoverflow.com/users/3928418", "pm_score": 1, "selected": false, "text": "array1[i]" }, { "answer_id": 74201043, "author": "Yohan Olmedo", "author_id": 20334400, "author_prof...
2022/10/25
[ "https://Stackoverflow.com/questions/74200529", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1609514/" ]
74,200,542
<p>I am trying to convert this PHP code to Ruby but the result is not the same. What am I doing wrong?</p> <h3>PHP</h3> <pre class="lang-php prettyprint-override"><code>$iv = str_repeat('0', 16); $passphrase = str_repeat('0', 32); $encrypted = openssl_encrypt('Hello', 'AES-256-CBC', $passphrase, 0, $iv); echo $encrypted; // =&gt; lfbW8JcPq6dkEnmY0hG7Vw== </code></pre> <h3>Ruby</h3> <pre class="lang-rb prettyprint-override"><code>cipher = OpenSSL::Cipher.new('AES-256-CBC').encrypt cipher.iv = '0' * 16 cipher.key = '0' * 32 encrypted = cipher.update('Hello') + cipher.final puts encrypted # =&gt; \x95\xF6\xD6\xF0\x97\x0F\xAB\xA7d\x12y\x98\xD2\x11\xBBW </code></pre>
[ { "answer_id": 74201071, "author": "Maxence", "author_id": 957185, "author_profile": "https://Stackoverflow.com/users/957185", "pm_score": 2, "selected": false, "text": "95f6d6f0970faba764127998d211bb57" }, { "answer_id": 74201280, "author": "Charbel Tabet", "author_id": ...
2022/10/25
[ "https://Stackoverflow.com/questions/74200542", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3359291/" ]
74,200,554
<p>I am working on a personal website as a beginner and I have the font available to me. When I add it with a font face on my hero banner, it shows up weirdly. I don't know if that's because the font just won't work with the site or not.</p> <p>Here is what I currently get:</p> <p><img src="https://i.stack.imgur.com/kHOoH.png" alt="Result of the above code" /></p> <p>The font should be in the middle and left of the banner, and the text should be white. I tried different variations of font-face and I tried adding styles to space out the letters. I tried another response from <a href="https://stackoverflow.com/questions/15587488/custom-font-is-displayed-weird?newreg=0ca82aacc0bd4e83bcc7a9ba109c42d7">this post</a>.</p> <p>However, that didn't work. Any suggestions?</p> <p>My hero code and CSS:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>body { margin: 0; padding: 0; height: 100vh; font-family: Arial, Helvetica, sans-serif; color: black;`enter code here` } img{ opacity: 50%; } .croppedbanner { width: 100%; height: 200px; object-position: 0% 39%; object-fit: cover; } .container{ background-position: center; background-repeat: no-repeat; background-size: cover; position: relative; } div.hero-text{ font-family: khFont; letter-spacing: 5px; font-size: 55px; position: absolute; overflow: hidden; font-weight: normal; line-height: 58px; transform: translate(0px, -200px); margin-left: 10px; color: transparent; -webkit-text-stroke-width: 1px; -webkit-text-stroke-color: blue; -webkit-text-fill-color: red; } @font-face { font-family: khFont; src: url(/fonts/khFont.ttf) format('truetype'); font-weight: normal; font-style: normal; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="container"&gt; &lt;img class="croppedbanner" src="/img/SiteBanner.png" alt="Hero Banner"&gt; &lt;div class="hero-text"&gt; &lt;h1&gt; Welcome to the site &lt;/h1&gt; &lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <p>EDIT 1: Ok so I managed to get different colors that aren't black and white. But I kind of need those two colors. The colors are also different between browsers. Google Chrome - is in Light Mode and Opera GX - is in Dark Mode. The dark mode one I can't turn off.</p> <p>Here's a screenshot of the website with both browsers.</p> <p>Opera: <a href="https://i.stack.imgur.com/pg65C.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pg65C.png" alt="webkit stroke is blue and fill is red" /></a> Chrome: <a href="https://i.stack.imgur.com/9LKV6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9LKV6.png" alt="webkit stroke is blue and fill is red" /></a></p> <p>I (think) I am holding the site locally on my pc, as I only see an IP address at the bar. So I can't share the site.</p> <p>Additionally, the code was edited to show in its entirety. This is just for the hero banner, so the HTML will be small, and I did some extra steps for the banner too. If you want to throw in suggestions for that, feel free :)</p>
[ { "answer_id": 74201071, "author": "Maxence", "author_id": 957185, "author_profile": "https://Stackoverflow.com/users/957185", "pm_score": 2, "selected": false, "text": "95f6d6f0970faba764127998d211bb57" }, { "answer_id": 74201280, "author": "Charbel Tabet", "author_id": ...
2022/10/25
[ "https://Stackoverflow.com/questions/74200554", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20334322/" ]
74,200,622
<p>I have the following function whose function is to return a list with the indices of the neighbors of each element in a list.</p> <p>example: in the following list l = [1, 2, 3, 4, 5] the indices of the neighbors of the element in position 0 would be 1, the indices of the neighbors of the element in position 1 would be 0 and 2 and so on...In addition, the list of indices includes the index of the element itself.</p> <p>Implement the function as follows:</p> <pre><code> &quot;&quot;&quot;Returns the list of neighbor indices. It is included in the element itself &quot;&quot;&quot; indices = [] if index == 0: # first indices.append(index + 1) elif index == len(elements) - 1: # latest indices.append(index - 1) else: indices.append(index + 1) indices.append(index - 1) # include the element itself as a neighbor of itself indices.append(index) return indices </code></pre> <p>However now I want to implement the function using filter to remove the conditionals, however it doesn't work for me the way I wrote it and it's hard to see the error...</p> <pre><code>def get_neighbour_indices(index, elements): &quot;&quot;&quot;Returns the list of neighbor indices. It is included in the element itself &quot;&quot;&quot; indices = [] indices.append(index + 1) indices.append(index - 1) # include the element itself as a neighbor of itself indices.append(index) # remove impossible indices (less than zero and greater than or equal to the length of the list) indices_delete = list(filter(lambda index : (indices[index]) &lt; 0 and (indices[index]) &gt;= len(elements), indices)) for index in indices: indices.remove(indices_delete) return indices </code></pre> <p>I try to implement the filter function in my function to remove the conditionals but the code doesn't work</p>
[ { "answer_id": 74201071, "author": "Maxence", "author_id": 957185, "author_profile": "https://Stackoverflow.com/users/957185", "pm_score": 2, "selected": false, "text": "95f6d6f0970faba764127998d211bb57" }, { "answer_id": 74201280, "author": "Charbel Tabet", "author_id": ...
2022/10/25
[ "https://Stackoverflow.com/questions/74200622", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19650265/" ]
74,200,623
<p>I’m new to Swift. Currently trying to build a test app.</p> <p>My tab nav bar won't appear when i preview the app. When in preview, i can click it and switch between pages, but i can't see it. Created a storyboard with a tab bar controller and view controllers.</p> <p>Code below. Can't upload images sadly due to being new.</p> <p>`</p> <pre><code>import SwiftUI @main struct Login_PageApp: App { var body: some Scene { WindowGroup { TabView { WTF_Home() WTF_Guides() WTF_Guides2() WTF_Book() WTF_Help() } } } } </code></pre> <p>I've tried looking up solutions but have had no success. Must guides on navigation fixes are from years ago. Ideally i need guides / fixes from 2022.</p> <p>I've even tried using the 'Navigation Controller' in the storyboard because people suggested it, no success there either.</p> <p>Any help would be much appreciated!</p>
[ { "answer_id": 74201071, "author": "Maxence", "author_id": 957185, "author_profile": "https://Stackoverflow.com/users/957185", "pm_score": 2, "selected": false, "text": "95f6d6f0970faba764127998d211bb57" }, { "answer_id": 74201280, "author": "Charbel Tabet", "author_id": ...
2022/10/25
[ "https://Stackoverflow.com/questions/74200623", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20274860/" ]
74,200,687
<p>I have a table (&quot;my_table&quot;) located on a SQL database server.</p> <p>This table has 1000 rows - I am trying to select 100 rows of this table at a time (making sure that no row is selected twice and all rows are selected), and then append all these mini tables into a single table.</p> <p>For example:</p> <ul> <li>result_1: rows 0 - 100</li> <li>result_2: rows 101-200</li> <li>etc.</li> </ul> <p>I tried to do this with the falling code:</p> <pre><code> library(dplyr) library(DBI) con &lt;- dbConnect(RSQLite::SQLite(), &quot;:memory:&quot;) sequence = seq(from = 1, to = 1000, by = 100) the_list = list() for (i in 1:10) { for (j in 1:sequence) { result_i = DBI::dbGetQuery(con, &quot;select * from my_table ORDER BY ID limit 100 OFFSET J;&quot;) the_list[[i]] = result_i } } final = do.call(rbind.data.frame, the_list) </code></pre> <p>I thought I could do this with a loop, but I don't think that SQL is recognizing my loop index.</p> <p>Can someone show me how to fix this?</p> <p>Thank you!</p>
[ { "answer_id": 74201169, "author": "br00t", "author_id": 4028717, "author_profile": "https://Stackoverflow.com/users/4028717", "pm_score": 1, "selected": false, "text": "library(dplyr)\nlibrary(DBI)\nlibrary(data.table)\ncon <- dbConnect(RSQLite::SQLite(), \":memory:\")\nsequence <- seq(...
2022/10/25
[ "https://Stackoverflow.com/questions/74200687", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13203841/" ]
74,200,718
<p>I trying to create a dictionary of dictionaries. Each item in the dictionary is assigned asynchronously. I would like to wait until all items are assigned before printing the result to the console.</p> <h1>Program</h1> <pre><code>const dict = {}; async function placeholder (letter, number) { await new Promise(r =&gt; setTimeout(r, 2000)); return 'test'; } async function secondMethod (letter, number) { try { dict[letter][number] = await placeholder (letter, number); } catch (err) { console.error(err) } } async function firstMethod (letter) { dict[letter] = {}; const numbers = ['1', '2', '3', '4']; await numbers.forEach (number =&gt; secondMethod (letter, number)); } async function main () { const letters = ['a', 'b', 'c', 'd']; await letters.forEach (letter =&gt; firstMethod (letter)); console.log (dict) }; main (); </code></pre> <h1>Result</h1> <pre><code>{ a: {}, b: {}, c: {}, d: {} } </code></pre> <h1>Desired Result</h1> <pre><code>{ a: { '1': 'test', '2': 'test', '3': 'test', '4': 'test' }, b: { '1': 'test', '2': 'test', '3': 'test', '4': 'test' }, c: { '1': 'test', '2': 'test', '3': 'test', '4': 'test' }, d: { '1': 'test', '2': 'test', '3': 'test', '4': 'test' } } </code></pre>
[ { "answer_id": 74200815, "author": "Chris Ferdinandi", "author_id": 1293256, "author_profile": "https://Stackoverflow.com/users/1293256", "pm_score": -1, "selected": false, "text": "async function firstMethod (letter) {\n dict[letter] = {};\n const numbers = ['1', '2', '3', '4'];\n...
2022/10/25
[ "https://Stackoverflow.com/questions/74200718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6331353/" ]
74,200,742
<p>i'm trying to retrieve each item (composed of an image, a word and its translation) from this page</p> <p>Link of the website: <a href="https://livingdictionaries.app/hazaragi/entries/gallery?entries_prod%5Btoggle%5D%5BhasImage%5D=true%22" rel="nofollow noreferrer">https://livingdictionaries.app/hazaragi/entries/gallery?entries_prod%5Btoggle%5D%5BhasImage%5D=true&quot;</a></p> <p><a href="https://i.stack.imgur.com/Ss57F.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ss57F.jpg" alt="enter image description here" /></a></p> <p>I used JsDom and Got. Here is the code</p> <pre><code> const jsdom = require(&quot;jsdom&quot;); const { JSDOM } = jsdom; const got = require('got'); (async () =&gt; { const response = await got(&quot;https://livingdictionaries.app/hazaragi/entries/gallery?entries_prod%5Btoggle%5D%5BhasImage%5D=true&quot;); console.log(response.body); const dom = new JSDOM(response.body); console.log(dom.window.document.querySelectorAll(&quot;.ld-egdn1r&quot;)) })(); </code></pre> <p>when I display the html code that is returned to me it does not correspond to what I open the site with my browser.There are no html tags that contain the items.</p> <p>When I look at the Network tab, other resources are loaded, but again I can't find the query that retrieves the words.</p> <p><a href="https://i.stack.imgur.com/QW1ge.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QW1ge.png" alt="enter image description here" /></a></p> <p>I think that what I am looking for is loaded in several queries but I don't know which one</p>
[ { "answer_id": 74200815, "author": "Chris Ferdinandi", "author_id": 1293256, "author_profile": "https://Stackoverflow.com/users/1293256", "pm_score": -1, "selected": false, "text": "async function firstMethod (letter) {\n dict[letter] = {};\n const numbers = ['1', '2', '3', '4'];\n...
2022/10/25
[ "https://Stackoverflow.com/questions/74200742", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13872089/" ]
74,200,762
<p>I have</p> <pre><code>print(list_games) array([[77, 63], [94, 49], [58, 98], ..., [ 7, 0], [68, 22], [ 1, 32]], dtype=int64) </code></pre> <p>I need to print the first pair and their index, which satisfy the condition, but my code print all pairs. How can I fix it?</p> <pre><code>for i in range(len(list_games)): for j in range(len(list_games)): if list_games[i][0] + list_games[j][1] == 131: print(list_games[i][0], list_games[j][1]) break </code></pre> <p>And I get:</p> <pre><code>77 54 94 37 58 73 51 80 80 51 74 57 66 65 61 70 87 44 40 91 </code></pre>
[ { "answer_id": 74200794, "author": "Rahul K P", "author_id": 4407666, "author_profile": "https://Stackoverflow.com/users/4407666", "pm_score": 0, "selected": false, "text": "return" }, { "answer_id": 74200809, "author": "BehRouz", "author_id": 2500257, "author_profile...
2022/10/25
[ "https://Stackoverflow.com/questions/74200762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15152033/" ]
74,200,820
<p>I have this DataFrame.</p> <pre><code> High Close Close Time 2022-10-23 21:41:59.999 19466.02 19461.29 2022-10-23 21:42:59.999 19462.48 19457.83 2022-10-23 21:43:59.999 19463.13 19460.09 2022-10-23 21:44:59.999 19465.15 19463.76 </code></pre> <p>I'm attempting to check if <code>Close</code> at a later date (up to 600 rows later but no more) goes above the close of an earlier date <code>&amp; High</code> is lower than the High of the same earlier date then I want to get the location of both the earlier and later date and make new columns in the Dataframe with those locations.</p> <p>Expected output:</p> <pre><code> High Close LC HC HH LH Close Time 2022-10-23 21:41:59.999 19466.02 19461.29 19461.29 NaN 19466.02 NaN 2022-10-23 21:42:59.999 19462.48 19457.83 NaN NaN NaN NaN 2022-10-23 21:43:59.999 19463.13 19460.09 NaN NaN NaN NaN 2022-10-23 21:44:59.999 19465.15 19463.76 NaN 19463.76 NaN 19465.15 </code></pre> <p>This is the code I have tried</p> <pre><code> # Checking if conditions are met for i in range(len(df)): for a in range(i,600): if (df.iloc[i:, 1] &lt; df.iloc[a, 1]) &amp; (df.iloc[i:, 0] &gt; df.iloc[a, 0]): # Creating new DataFrame columns df['LC'] = df.iloc[i, 1] df['HC'] = df.get_loc[i,1] df['HH'] = df.get_loc[a, 0] df['LH'] = df.get_loc[a, 0] else: continue </code></pre> <p>This line: <code>if (df.iloc[i:, 1] &lt; df.iloc[a, 1]) &amp; (df.iloc[i:, 0] &gt; df.iloc[a, 0]):</code> Is causing error: <code>ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().</code></p> <p>I believe I should be using <code>any()</code> instead of an if statement but I am unsure of how to apply it. I also think that there many be an issue with the way I am using the <code>df.get_loc[]</code> but I am unsure. I'm a pandas beginner so if it is obvious I apologize</p> <p>Here is an image to help visualise what I am attempting to do using a candlestick chart <a href="https://i.stack.imgur.com/wQABH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wQABH.png" alt="enter image description here" /></a></p> <p>what I want to do is check if HC is higher than LC <em>and</em> LH is lower than HH then add that data to new columns in the DataFrame</p> <p>Here is an additional way I tried to achieve the desired output</p> <pre><code>idx_close, idx_high = map(df.columns.get_loc, [&quot;Close&quot;, &quot;High&quot;]) # Check Conditions for i in range(len(df)): bool_l = [((df.iloc[i, idx_close] &lt; df.iloc[a, idx_close]) &amp; (df.iloc[i, idx_high] &gt; df.iloc[a, idx_high]) ).any() for a in range(i, 600)] # Creating new DataFrame columns df.loc[i, 'LC'] = df.iloc[i,1] df.loc[bool_l, 'HC'] = df.iloc[bool_l, 1] # Creating new DataFrame columns df.loc[i, 'HH'] = df.iloc[i, 0] df.loc[bool_l, 'LH'] = df.iloc[bool_l, 0] </code></pre> <p>And I get an error <code>IndexError: Boolean index has wrong length: 600 instead of 2867</code> On the line <code>df.loc[bool_l, 'HC'] = df.iloc[bool_l, 1]</code> I assume the error comes from the <code>range(i,600)</code> but I don't know how to get around it</p>
[ { "answer_id": 74200794, "author": "Rahul K P", "author_id": 4407666, "author_profile": "https://Stackoverflow.com/users/4407666", "pm_score": 0, "selected": false, "text": "return" }, { "answer_id": 74200809, "author": "BehRouz", "author_id": 2500257, "author_profile...
2022/10/25
[ "https://Stackoverflow.com/questions/74200820", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19142056/" ]
74,200,822
<pre class="lang-py prettyprint-override"><code>&gt;&gt; A = tf.Tensor([4135047. 1193752.], shape=(2,), dtype=float32) &gt;&gt; B = tf.Tensor( [1226019. 4135047. 4135047. 4169911. 1193752. 4135047. 4135047. 4135047.], shape=(8,), dtype=float32 ) &gt;&gt; compare_1 = tf.math.equal(B, A[0]) tf.Tensor([False True True False False True True True], shape=(8,), dtype=bool) &gt;&gt; compare_2 = tf.math.equal(B, A[1]) tf.Tensor([False False False False True False False False], shape=(8,), dtype=bool) # final results &gt;&gt; tf.math.logical_or(compare_1, compare_2) tf.Tensor([False True True False True True True True], shape=(8,), dtype=bool) </code></pre> <p>What I want is to compare two tensors of different shape in one pass without using <code>tf.map()</code> function.</p> <p>More precisely, I would like to compare each element of <code>tensor B</code> with all elements of <code>tensor A</code>. Result should be set to True if any element from <code>tensor A</code> matches with the element that we are comparing from <code>tensor B</code></p> <p>Expected outcome:</p> <pre class="lang-py prettyprint-override"><code>&gt;&gt; compare(B, A) tf.Tensor([False True True False True True True True]) # logic: - 1st element from B, 1226019 doesn't match with any elements of A =&gt; False - 2nd element from B, 4135047 match with an element in A =&gt; True ... ... ... </code></pre> <p>It looks like <a href="https://www.tensorflow.org/api_docs/python/tf/math/equal" rel="nofollow noreferrer">tf.math.equal</a> can't compare two tensors of different shapes so right now I have to compare it in n-pass (for each element of tensor A) with tensor B and then apply the <code>logical_or()</code> on those results.</p>
[ { "answer_id": 74200794, "author": "Rahul K P", "author_id": 4407666, "author_profile": "https://Stackoverflow.com/users/4407666", "pm_score": 0, "selected": false, "text": "return" }, { "answer_id": 74200809, "author": "BehRouz", "author_id": 2500257, "author_profile...
2022/10/25
[ "https://Stackoverflow.com/questions/74200822", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4496896/" ]
74,200,841
<p>I am attempting to edit a bootstrap button and add a 10px margin-bottom to the class .btn. However, my edits are loading. If I do it via inline-html (EX. style=&quot;margin-bottom: 10px&quot;) it works, but I'd prefer to stick to best coding practices and not do that. Help would be greatly appreciated </p> <p>CSS</p> <pre><code>.no-gutters { margin-right: 0; margin-left: 0; } .btn { margin-bottom: 10px; } </code></pre> <p>HTML</p> <pre><code> {% block styles %} {{ super() }} &lt;link rel=&quot;stylesheet&quot; href=&quot;{{ url_for('static', filename='css/styles.css') }}&quot;&gt; &lt;link rel=&quot;stylesheet&quot; href=&quot;{{ url_for('static', filename='font-awesome-4.7.0/css/font-awesome.min.css') }}&quot;&gt; {% endblock %} &lt;h3&gt;Productivity&lt;/h3&gt; &lt;div class=&quot;row no-gutters&quot;&gt; &lt;div class=&quot;col-3 col-xl-3 col-lg-4 py-1&quot;&gt; &lt;button class=&quot;btn btn-warning&quot; data-criteria=&quot;wifi&quot; data-toggle=&quot;button&quot;&gt; &lt;i class=&quot;fa fa-fw fa-wifi&quot;&gt;&lt;/i&gt; &lt;br&gt; &lt;span title=&quot;Stable Wi-Fi&quot;&gt; Wi-Fi &lt;/span&gt; &lt;/button&gt; &lt;/div&gt; </code></pre> <p><a href="https://i.stack.imgur.com/6bEir.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6bEir.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74201152, "author": "James Waziwenyi", "author_id": 14820268, "author_profile": "https://Stackoverflow.com/users/14820268", "pm_score": 2, "selected": true, "text": "mb-0" }, { "answer_id": 74201469, "author": "Denis Juarez", "author_id": 20188144, "aut...
2022/10/25
[ "https://Stackoverflow.com/questions/74200841", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20162506/" ]
74,200,875
<p>What I want is to be able to click on the words I specify and when I click it, it shows a callout with Easy Loading.</p> <pre><code>class MyHomePage extends StatelessWidget { const MyHomePage({ Key? key }) : super(key: key); @override Widget build(BuildContext context) { return Scaffold(t appBar: AppBar(title: Text(&quot;Risale-i Nur&quot;),), body: Column( children: [ Text(&quot;İhlas Risalesi - 1. Düstur&quot;, style: Theme.of(context).textTheme.headlineLarge), Text(&quot;&quot;&quot;Eğer o razı olsa bütün dünya küsse ehemmiyeti yok. O razı olduktan ve kabul ettikten sonra, isterse ve hikmeti iktiza ederse sizler istemek talebinde olmadığınız halde, halklara da kabul ettirir, onları da razı eder. Onun için bu hizmette doğrudan doğruya yalnız Cenab-ı Hakk’ın rızasını esas maksat yapmak gerektir.&quot;&quot;&quot;, style: Theme.of(context).textTheme.bodyMedium,), ], ), ); } } class Strings{ static const Map&lt;String, String&gt; words = {&quot;iktiza&quot;:&quot;mecburiyet&quot;, &quot;ehemmiyeti&quot;:&quot;kıymeti&quot;, &quot;tesir&quot;:&quot;etki&quot;}; /* onPressed/onTap(){ EasyLoading.showToast(words[KEY], dismissOnTap: true); } */ } </code></pre> <p>//I tried this but of course I can't write a widget in text</p> <pre><code>Widget mean(String key){ return GestureDetector( child: Text(key), onTap: (){ EasyLoading.showToast(words[key], dismissOnTap: true); } ); } </code></pre>
[ { "answer_id": 74201162, "author": "Alberto Tedoldi", "author_id": 20334784, "author_profile": "https://Stackoverflow.com/users/20334784", "pm_score": 0, "selected": false, "text": "import 'package:flutter/gestures.dart'; ...\n\nRichText(\n text: TextSpan(text: 'Non touchable. ', ch...
2022/10/25
[ "https://Stackoverflow.com/questions/74200875", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20334485/" ]
74,200,878
<p>The <a href="https://perldoc.perl.org/perlpod" rel="nofollow noreferrer">perlpod</a> documentation says you can <code>L&lt;link to something&gt;</code> but it does not indicate the proper way to reference a Perl-core function (or if it does, it wasn't obvious to me).</p> <p>Specifically, I want to link to what is shown by <code>perldoc -f wantarray</code>. What is the proper way to <code>L&lt;...&gt;</code> link to it so it will take you to the <code>wantarray</code> documentation when you click on the link from MetaCPAN and other POD viewers that follow links?</p> <p>(Note that <code>wantarray</code> is just a built-in Perl function like <code>print</code> or <code>open</code>.)</p>
[ { "answer_id": 74201392, "author": "toolic", "author_id": 197758, "author_profile": "https://Stackoverflow.com/users/197758", "pm_score": 1, "selected": false, "text": "L<wantarray|https://perldoc.perl.org/functions/wantarray>\n" }, { "answer_id": 74202083, "author": "zdim", ...
2022/10/25
[ "https://Stackoverflow.com/questions/74200878", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14055985/" ]
74,200,894
<p>I have a dataframe where I have a series of repeating columns. How can I just combine them so that they are just one set of individual columns? I have tried using df.melt but I need to specify columns in one of the parameters. The dataframe has an a lot of columns so typing them out individually would not work. It seems like this is a simple fix but I just cannot figure it out. Can anyone help? A sample dataframe is below, I added a period before or after the ch in the column name so it can let me recreate the smaller version of my dataframe.</p> <pre><code>df3= pd.DataFrame({ 'Label': {'1':'E10_1_nucleus' ,'2':'E10_1_cytoplasm','3':'E11_1_nucleus' ,'4':'E11_1_cytoplasm'}, 'Area_ch1.': {'1': 435,'2':635,'3': 105,'4':850}, 'Area_ch1': {'1': 135,'2':605,'3': 158,'4':970}, 'Mean_ch2': {'1': 313,'2':847,'3': 315,'4':850}, 'Mean_ch2.': {'1': 150,'2':331,'3': 195,'4':130}}) </code></pre> <p>Desired output:</p> <pre><code>df4= pd.DataFrame({ 'Label': {'1':'E10_1_nucleus' ,'2':'E10_1_cytoplasm','3':'E11_1_nucleus' ,'4':'E11_1_cytoplasm','5':'E10_1_nucleus' ,'6':'E10_1_cytoplasm','7':'E11_1_nucleus' ,'8':'E11_1_cytoplasm'}, 'Area_ch1': {'1': 435,'2':635,'3': 105,'4':850,'5': 135,'6':605,'7': 158,'8':970}, 'Mean_ch2': {'1': 313,'2':847,'3': 315,'4':850,'5': 150,'6':331,'7': 195,'8':130}}) </code></pre>
[ { "answer_id": 74201392, "author": "toolic", "author_id": 197758, "author_profile": "https://Stackoverflow.com/users/197758", "pm_score": 1, "selected": false, "text": "L<wantarray|https://perldoc.perl.org/functions/wantarray>\n" }, { "answer_id": 74202083, "author": "zdim", ...
2022/10/25
[ "https://Stackoverflow.com/questions/74200894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14146065/" ]
74,200,924
<p>I have been struggling with a task in R for some time, which seems to be easy.</p> <p>suppose this is my sample data:</p> <pre><code>df &lt;- data.frame(a=c(2,2,7),b=c(1,4,3),c=c(9,5,3)) v &lt;- c(1,2,3) </code></pre> <p>now I would like to multiply each column by the corresponding vector element e.g. first column by <code>v[1]</code>, second column by <code>v[2]</code>etc..</p> <p>expected output:</p> <pre><code> a b c 1 2 2 27 2 2 8 15 3 7 6 9 </code></pre> <p>The target data is much larger and consists of integers and floating point numbers. Thank you in advance!</p>
[ { "answer_id": 74200934, "author": "KacZdr", "author_id": 12382064, "author_profile": "https://Stackoverflow.com/users/12382064", "pm_score": 4, "selected": true, "text": "sweep" }, { "answer_id": 74200974, "author": "br00t", "author_id": 4028717, "author_profile": "h...
2022/10/25
[ "https://Stackoverflow.com/questions/74200924", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20334608/" ]
74,200,925
<p>I'm new to python and having problems with summing up the numbers inside an element and then adding them together to get a total value.</p> <p>Example of what I'm trying to do:</p> <pre><code>list = {'area1': [395.0, 212.0], 'area2': [165.0, 110.0]} 'area1': [395.0 * 212.0], 'area2': [165.0 * 110.0] 'area1': [83740], 'area2': [18150] total value = 101890 </code></pre> <p>Main.py:</p> <pre><code>def cubicMeterCalculator(): floorAreaList = {} print(&quot;Example of how this would look like 'area1 395 212' 'area2 165 110'&quot;) n = int(input(&quot;\nHow many walls? &quot;)) for i in range(n): print(&quot;\nEnter name of the wall first and 'Space' to separate the name and numbers before hitting enter.&quot;) name, *lengths = input().split(&quot; &quot;) l_lengths = list(map(float,lengths)) floorAreaList[name] = l_lengths print(floorAreaList) total = sum(float, floorAreaList) print(total) </code></pre>
[ { "answer_id": 74200969, "author": "Nick", "author_id": 9473764, "author_profile": "https://Stackoverflow.com/users/9473764", "pm_score": 2, "selected": true, "text": "sum" }, { "answer_id": 74200972, "author": "Rahul K P", "author_id": 4407666, "author_profile": "htt...
2022/10/25
[ "https://Stackoverflow.com/questions/74200925", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20248393/" ]
74,200,939
<p>I want to create a Quartz job which reads .csv files and moves them when file is processed. I tried this:</p> <pre><code>@Override public void execute(JobExecutionContext context) { File directoryPath = new File(&quot;C:\\csv\\nov&quot;); // Create a new subfolder called &quot;processed&quot; into source directory try { Files.createDirectory(Path.of(directoryPath.getAbsolutePath() + &quot;/processed&quot;)); } catch (IOException e) { throw new RuntimeException(e); } FilenameFilter textFileFilter = (dir, name) -&gt; { String lowercaseName = name.toLowerCase(); if (lowercaseName.endsWith(&quot;.csv&quot;)) { return true; } else { return false; } }; // List of all the csv files File filesList[] = directoryPath.listFiles(textFileFilter); System.out.println(&quot;List of the text files in the specified directory:&quot;); Optional&lt;File&gt; csvFile = Arrays.stream(filesList).findFirst(); File file = csvFile.get(); for(File file : filesList) { try { List&lt;CsvLine&gt; beans = new CsvToBeanBuilder(new FileReader(file.getAbsolutePath(), StandardCharsets.UTF_16)) ..... .build() .parse(); for(CsvLine item: beans){ ....... sql queries Optional&lt;ProcessedWords&gt; isFound = processedWordsService.findByKeyword(item.getKeyword()); ...................................... } } catch (Exception e){ e.printStackTrace(); } // Move here file into new subdirectory when file processing is finished Path copied = Paths.get(file.getAbsolutePath() + &quot;/processed&quot;); Path originalPath = file.toPath(); try { Files.move(originalPath, copied, StandardCopyOption.REPLACE_EXISTING); } catch (IOException e) { throw new RuntimeException(e); } } } </code></pre> <p>Folder <code>processed</code> is created when the job is started but I get exception:</p> <pre><code> 2022-11-17 23:12:51.470 ERROR 16512 --- [cessor_Worker-4] org.quartz.core.JobRunShell : Job DEFAULT.keywordPostJobDetail threw an unhandled Exception: java.lang.RuntimeException: java.nio.file.FileSystemException: C:\csv\nov\11_42_33.csv -&gt; C:\csv\nov\processed\11_42_33.csv: The process cannot access the file because it is being used by another process at com.wordscore.engine.processor.ImportCsvFilePostJob.execute(ImportCsvFilePostJob.java:127) ~[main/:na] at org.quartz.core.JobRunShell.run(JobRunShell.java:202) ~[quartz-2.3.2.jar:na] at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573) ~[quartz-2.3.2.jar:na] Caused by: java.nio.file.FileSystemException: C:\csv\nov\11_42_33.csv -&gt; C:\csv\nov\processed\11_42_33.csv: The process cannot access the file because it is being used by another process at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:92) ~[na:na] at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103) ~[na:na] at java.base/sun.nio.fs.WindowsFileCopy.move(WindowsFileCopy.java:403) ~[na:na] at java.base/sun.nio.fs.WindowsFileSystemProvider.move(WindowsFileSystemProvider.java:293) ~[na:na] at java.base/java.nio.file.Files.move(Files.java:1432) ~[na:na] at com.wordscore.engine.processor.ImportCsvFilePostJob.execute(ImportCsvFilePostJob.java:125) ~[main/:na] ... 2 common frames omitted </code></pre> <p>Do you know how I can release the file and move it into a sub directory?</p> <p><em><strong>EDIT: Update code with try-catch</strong></em></p> <pre><code>@Override public void execute(JobExecutionContext context) { File directoryPath = new File(&quot;C:\\csv\\nov&quot;); // Create a new subfolder called &quot;processed&quot; into source directory try { Path path = Path.of(directoryPath.getAbsolutePath() + &quot;/processed&quot;); if (!Files.exists(path) || !Files.isDirectory(path)) { Files.createDirectory(path); } } catch (IOException e) { throw new RuntimeException(e); } FilenameFilter textFileFilter = (dir, name) -&gt; { String lowercaseName = name.toLowerCase(); if (lowercaseName.endsWith(&quot;.csv&quot;)) { return true; } else { return false; } }; // List of all the csv files File filesList[] = directoryPath.listFiles(textFileFilter); System.out.println(&quot;List of the text files in the specified directory:&quot;); Optional&lt;File&gt; csvFile = Arrays.stream(filesList).findFirst(); File file = csvFile.get(); for(File file : filesList) { try { try (var br = new FileReader(file.getAbsolutePath(), StandardCharsets.UTF_16)){ List&lt;CsvLine&gt; beans = new CsvToBeanBuilder(br) ...... .build() .parse(); for (CsvLine item : beans) { ..... if (isFound.isPresent()) { ......... }} } catch (Exception e){ e.printStackTrace(); } // Move here file into new subdirectory when file processing is finished Path copied = Paths.get(file.getAbsolutePath() + &quot;/processed&quot;); Path originalPath = file.toPath(); try { Files.move(originalPath, copied, StandardCopyOption.REPLACE_EXISTING); } catch (IOException e) { throw new RuntimeException(e); } } </code></pre> <p><em>Quartz config:</em></p> <pre><code>@Configuration public class SchedulerConfig { private static final Logger LOG = LoggerFactory.getLogger(SchedulerConfig.class); private ApplicationContext applicationContext; @Autowired public SchedulerConfig(ApplicationContext applicationContext) { this.applicationContext = applicationContext; } @Bean public JobFactory jobFactory() { AutowiringSpringBeanJobFactory jobFactory = new AutowiringSpringBeanJobFactory(); jobFactory.setApplicationContext(applicationContext); return jobFactory; } @Bean public SchedulerFactoryBean schedulerFactoryBean(Trigger simpleJobTrigger) throws IOException { SchedulerFactoryBean schedulerFactory = new SchedulerFactoryBean(); schedulerFactory.setQuartzProperties(quartzProperties()); schedulerFactory.setWaitForJobsToCompleteOnShutdown(true); schedulerFactory.setAutoStartup(true); schedulerFactory.setTriggers(simpleJobTrigger); schedulerFactory.setJobFactory(jobFactory()); return schedulerFactory; } @Bean public SimpleTriggerFactoryBean simpleJobTrigger(@Qualifier(&quot;keywordPostJobDetail&quot;) JobDetail jobDetail, @Value(&quot;${simplejob.frequency}&quot;) long frequency) { LOG.info(&quot;simpleJobTrigger&quot;); SimpleTriggerFactoryBean factoryBean = new SimpleTriggerFactoryBean(); factoryBean.setJobDetail(jobDetail); factoryBean.setStartDelay(1000); factoryBean.setRepeatInterval(frequency); factoryBean.setRepeatCount(4); // factoryBean.setRepeatCount(SimpleTrigger.REPEAT_INDEFINITELY); return factoryBean; } @Bean public JobDetailFactoryBean keywordPostJobDetail() { JobDetailFactoryBean factoryBean = new JobDetailFactoryBean(); factoryBean.setJobClass(ImportCsvFilePostJob.class); factoryBean.setDurability(true); return factoryBean; } public Properties quartzProperties() throws IOException { PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean(); propertiesFactoryBean.setLocation(new ClassPathResource(&quot;/quartz.properties&quot;)); propertiesFactoryBean.afterPropertiesSet(); return propertiesFactoryBean.getObject(); } } </code></pre> <p><em>Quartz config:</em></p> <pre><code>org.quartz.scheduler.instanceName=wordscore-processor org.quartz.scheduler.instanceId=AUTO org.quartz.threadPool.threadCount=5 org.quartz.jobStore.class=org.quartz.simpl.RAMJobStore </code></pre> <p>As you can see I wan to have 5 threads in order to execute 5 parallel jobs. Do you know how I can process the files without this exception?</p>
[ { "answer_id": 74476155, "author": "Reporter", "author_id": 326807, "author_profile": "https://Stackoverflow.com/users/326807", "pm_score": 1, "selected": false, "text": "C:\\csv\\nov" }, { "answer_id": 74541544, "author": "Luke Machowski", "author_id": 231860, "autho...
2022/10/25
[ "https://Stackoverflow.com/questions/74200939", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1103606/" ]
74,200,947
<p>I am creating an app with python and flask. I am getting the following error:</p> <pre><code>Traceback (most recent call last): File &quot;C:\Users\Albert\PycharmProjects\Carro\views_trips.py&quot;, line 10, in &lt;module&gt; def index(): File &quot;C:\Users\Albert\PycharmProjects\Carro\venv\lib\site-packages\flask\scaffold.py&quot;, line 439, in decorator self.add_url_rule(rule, endpoint, f, **options) File &quot;C:\Users\Albert\PycharmProjects\Carro\venv\lib\site-packages\flask\scaffold.py&quot;, line 57, in wrapper_func return f(self, *args, **kwargs) File &quot;C:\Users\Albert\PycharmProjects\Carro\venv\lib\site-packages\flask\app.py&quot;, line 1090, in add_url_rule raise AssertionError( AssertionError: View function mapping is overwriting an existing endpoint function: index </code></pre> <p>I have only one route.</p> <pre><code>from flask import render_template, request, redirect, session, flash, url_for, send_from_directory from app import app from models import Trips, Users, Cars, db import time from helpers import * from flask_bcrypt import check_password_hash @app.route('/') def index(): nickname = 'Bertimaz' trip = Trips.query.filter_by(user_nickname=nickname).order_by(Trips.initialTime.desc()).first() user = Users.query.filter_by(nickname='Bertimaz') # não ta achando usuario print(user.name) car = Cars.query.filter_by(plate=trip.car_plate) return render_template('home.html', titulo='Viagens', trip=trip, user=user, car=car) </code></pre> <p>It was able to run it before I started implementing my SQL alchemy models and I tried changing the index function name</p>
[ { "answer_id": 74476155, "author": "Reporter", "author_id": 326807, "author_profile": "https://Stackoverflow.com/users/326807", "pm_score": 1, "selected": false, "text": "C:\\csv\\nov" }, { "answer_id": 74541544, "author": "Luke Machowski", "author_id": 231860, "autho...
2022/10/25
[ "https://Stackoverflow.com/questions/74200947", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19683891/" ]
74,200,950
<p>I have these elements on my page:</p> <pre class="lang-html prettyprint-override"><code>&lt;div id=&quot;123test&quot;&gt;&lt;p&gt;test&lt;/p&gt;&lt;/div&gt; &lt;div id=&quot;123test&quot;&gt;&lt;p&gt;othertext&lt;/p&gt;&lt;/div&gt; </code></pre> <p>And I am trying to remove the <code>div</code> if it contains &quot;test&quot; text inside, using Java Script, but it does not seem to work.</p> <p>Here is my JS:</p> <pre class="lang-js prettyprint-override"><code>var container = document.getElementById('123test'); if (container.textContent=='test') { container.style.display=&quot;none&quot;; }; </code></pre> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>var container = document.getElementById('123test'); if (container.textContent == 'test') { container.style.display = "none"; };</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="123test"&gt;&lt;p&gt;test&lt;/p&gt;&lt;/div&gt; &lt;div id="123test"&gt;&lt;p&gt;othertext&lt;/p&gt;&lt;/div&gt;</code></pre> </div> </div> </p> <p>I also tried using <code>:contains</code> selector way, but the result was the same. The style of the container does not change at all. What do I do wrong? Is there another approach possible? This code is a simplified version of my project, but neither of these two work. I would be very gratefull if someone would help me to overcome the issue.</p>
[ { "answer_id": 74201018, "author": "connexo", "author_id": 3744304, "author_profile": "https://Stackoverflow.com/users/3744304", "pm_score": 1, "selected": false, "text": "<div id=\"123test\"><p>test</p></div>\n<!-- no whitespace or line breaks before or after <p>test</p> -->\n" }, {...
2022/10/25
[ "https://Stackoverflow.com/questions/74200950", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20334667/" ]
74,200,957
<p>I have this code. The count of values from the first url always displays twice. But the sum is right.</p> <p>So I get</p> <pre><code>4 4 2 6 </code></pre> <p>Instead of</p> <pre><code>4 2 6 </code></pre> <pre><code>def count_blocklist_entries(): urls = ['https://rad.net/Easylist.txt', 'https://rad.net/Admiral.txt'] entry_dict = {} for url in urls: response = requests.get(url) lengthers = len(response.text.splitlines()) entry_dict.update({url: lengthers}) print(lengthers) print(sum(entry_dict.values())) count_blocklist_entries() </code></pre> <p>Expecting to not get the first integer twice.</p>
[ { "answer_id": 74201047, "author": "Cstack2", "author_id": 13955172, "author_profile": "https://Stackoverflow.com/users/13955172", "pm_score": 0, "selected": false, "text": "Iteration 1: {'https://rad.net/Easylist.txt': 4}\nSum of values in dictionary = 4\nIteration2: {'https://rad.net/E...
2022/10/25
[ "https://Stackoverflow.com/questions/74200957", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20334665/" ]
74,200,986
<p>I have a Pandas DataFrame, DF:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Column A</th> <th>Column B</th> <th>Column C</th> </tr> </thead> <tbody> <tr> <td>Apple</td> <td>red</td> <td>Texas</td> </tr> <tr> <td>Apple</td> <td>red</td> <td>California</td> </tr> <tr> <td>Banana</td> <td>yellow</td> <td>Indiana</td> </tr> <tr> <td>Banana</td> <td>yellow</td> <td>Florida</td> </tr> </tbody> </table> </div> <p>I would like to get it in a dictionary in the form:</p> <p><code>{ &quot;Apple red&quot; : ['Texas', 'California'], &quot;Banana yellow&quot; : ['Indiana', 'Florida'] } </code></p> <p>where Key = concatenation of strings in column A and column B (and)</p> <p>Value = all corresponding strings from column C (based on groupby) in a list.</p> <p>I am not sure how to achieve this.</p> <p>Key Note: It should also work if there are more than 3 columns to be grouped for dictionary's key</p>
[ { "answer_id": 74201023, "author": "Andrej Kesely", "author_id": 10035985, "author_profile": "https://Stackoverflow.com/users/10035985", "pm_score": 3, "selected": true, "text": "x = dict(\n df.groupby(df[\"Column A\"] + \" \" + df[\"Column B\"])[\"Column C\"].agg(list)\n)\n\nprint(x)...
2022/10/25
[ "https://Stackoverflow.com/questions/74200986", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15130945/" ]
74,201,007
<p>I would like to render a component on my react-app at a given time eg 6.00PM 27 October 2022. For example, a form would be released for signing up at that from that given time onward. This time stamp would be stored in my database, which will be queried by the react-app. How do I accomplish this in React with JavaScript?</p> <p>I have thought of comparing Date() objects. Eg. get the current time and compare it to a Timestamp converted to Date() queried from the firebase firestore. However, I am unsure how I would use UseEffect to update the current time continuously for the comparison. Is this approach correct? If not, I would appreciate some suggestions.</p>
[ { "answer_id": 74201078, "author": "John Fish", "author_id": 1020383, "author_profile": "https://Stackoverflow.com/users/1020383", "pm_score": 0, "selected": false, "text": "useEffect" }, { "answer_id": 74201096, "author": "Phil", "author_id": 283366, "author_profile"...
2022/10/25
[ "https://Stackoverflow.com/questions/74201007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17940203/" ]
74,201,038
<p>I am trying to pair my Macbook with Visual Studio 2022 but after entering the credentials I received the following error in the gui dialog: &quot;An error occurred while trying to establish an SSH connection with SSH keys to '192.168.178.27:22'&quot;</p> <p>When checking the logs there is the following error:</p> <pre><code>Xamarin.Messaging.Ssh.SshCommandRunner Warning: 0 : Failed to execute 'grep &quot;ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDRpqma2f+6ghu6P2/Jxx2Aj6+4kY/1tFpkvM1CdlscbvESZFsYakl90P9YvXQhHTXhK6QUHgj4E9s+Ze4PxmXSfYd7b3imWpbSOIqWrlC4rfMn31F3EyJ60Cpc9DO15MtiVS9ctTWBKXzRU8NbUlek8LppEID5Xv0nEroryNHEzINXSvyhmTyUHAOklTjm3NVpqLrbGbFw9d6+F8pVskWtYyfFVl9PuW0EhbVox9inWGQIzbCMdVzjGb5M3ua/taNtTz8W6hsUQm8SB7UANR36klHUIWYmSQ5ZgyIkCZ7x6pNyRL2sr6UtFAfsp+vnGsIzakKHvZDXz7uBnRl6/Z7f steve@Stefans-MacBook-Pro.local&quot; &quot;/Users/steve/.ssh/authorized_keys&quot;': ExitStatus = 1: 10.25.2022 22:41:25Z DateTime=2022-10-25T22:41:25.3448659Z: 10.25.2022 22:41:25Z </code></pre> <p>Complete log:</p> <pre><code>Xamarin.Messaging.Integration.State.ServerStateContext Error: 0 : !An error occurred while trying to establish an SSH connection with SSH keys to '192.168.178.27:22': 10.25.2022 22:36:36Z DateTime=2022-10-25T22:36:36.5456548Z: 10.25.2022 22:36:36Z Xamarin.Messaging.Integration.State.ServerStateContext Information: 0 : Server State transition from DisconnectedState to ConfiguringState on macbook.lan (192.168.178.27): 10.25.2022 22:41:20Z DateTime=2022-10-25T22:41:20.2772963Z: 10.25.2022 22:41:20Z Xamarin.Messaging.Integration.State.ServerStateContext Information: 0 : Checking host configuration for connecting to 'macbook.lan'...: 10.25.2022 22:41:20Z DateTime=2022-10-25T22:41:20.3057061Z: 10.25.2022 22:41:20Z Xamarin.Messaging.Integration.State.ServerStateContext Information: 0 : !Checking host configuration for connecting to 'macbook.lan'...: 10.25.2022 22:41:20Z DateTime=2022-10-25T22:41:20.3057061Z: 10.25.2022 22:41:20Z Xamarin.Messaging.Integration.State.ServerStateContext Information: 0 : Checking SSH configuration...: 10.25.2022 22:41:20Z DateTime=2022-10-25T22:41:20.3487326Z: 10.25.2022 22:41:20Z Xamarin.Messaging.Integration.State.ServerStateContext Information: 0 : !Checking SSH configuration...: 10.25.2022 22:41:20Z DateTime=2022-10-25T22:41:20.3487326Z: 10.25.2022 22:41:20Z Xamarin.Messaging.Ssh.SshCommandRunner Warning: 0 : Failed to execute 'grep &quot;ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDRpqma2f+6ghu6P2/Jxx2Aj6+4kY/1tFpkvM1CdlscbvESZFsYakl90P9YvXQhHTXhK6QUHgj4E9s+Ze4PxmXSfYd7b3imWpbSOIqWrlC4rfMn31F3EyJ60Cpc9DO15MtiVS9ctTWBKXzRU8NbUlek8LppEID5Xv0nEroryNHEzINXSvyhmTyUHAOklTjm3NVpqLrbGbFw9d6+F8pVskWtYyfFVl9PuW0EhbVox9inWGQIzbCMdVzjGb5M3ua/taNtTz8W6hsUQm8SB7UANR36klHUIWYmSQ5ZgyIkCZ7x6pNyRL2sr6UtFAfsp+vnGsIzakKHvZDXz7uBnRl6/Z7f steve@Stefans-MacBook-Pro.local&quot; &quot;/Users/steve/.ssh/authorized_keys&quot;': ExitStatus = 1: 10.25.2022 22:41:25Z DateTime=2022-10-25T22:41:25.3448659Z: 10.25.2022 22:41:25Z Xamarin.Messaging.Integration.State.ServerStateContext Information: 0 : Checking host configuration for connecting to 'macbook.lan'...: 10.25.2022 22:41:25Z DateTime=2022-10-25T22:41:25.4160488Z: 10.25.2022 22:41:25Z Xamarin.Messaging.Integration.State.ServerStateContext Information: 0 : !Checking host configuration for connecting to 'macbook.lan'...: 10.25.2022 22:41:25Z DateTime=2022-10-25T22:41:25.4160488Z: 10.25.2022 22:41:25Z Xamarin.Messaging.Integration.State.ServerStateContext Information: 0 : Server State transition from ConfiguringState to DisconnectingState on macbook.lan (192.168.178.27): 10.25.2022 22:41:25Z DateTime=2022-10-25T22:41:25.4275618Z: 10.25.2022 22:41:25Z Xamarin.Messaging.Integration.State.ServerStateContext Information: 0 : Starting disconnection from macbook.lan...: 10.25.2022 22:41:25Z DateTime=2022-10-25T22:41:25.4315733Z: 10.25.2022 22:41:25Z Xamarin.Messaging.Integration.State.ServerStateContext Information: 0 : !Starting disconnection from macbook.lan...: 10.25.2022 22:41:25Z DateTime=2022-10-25T22:41:25.4315733Z: 10.25.2022 22:41:25Z Xamarin.Messaging.Integration.State.ServerStateContext Information: 0 : Server State transition from DisconnectingState to DisconnectedState on macbook.lan (192.168.178.27): 10.25.2022 22:41:25Z DateTime=2022-10-25T22:41:25.4591158Z: 10.25.2022 22:41:25Z Xamarin.Messaging.Integration.State.ServerStateContext Information: 0 : Starting disconnection from macbook.lan...: 10.25.2022 22:41:25Z DateTime=2022-10-25T22:41:25.4631158Z: 10.25.2022 22:41:25Z Xamarin.Messaging.Integration.State.ServerStateContext Information: 0 : !Starting disconnection from macbook.lan...: 10.25.2022 22:41:25Z DateTime=2022-10-25T22:41:25.4631158Z: 10.25.2022 22:41:25Z Xamarin.Messaging.Integration.State.ServerStateContext Information: 0 : The connection to 'macbook.lan' has been finished: 10.25.2022 22:41:25Z DateTime=2022-10-25T22:41:25.4641170Z: 10.25.2022 22:41:25Z Xamarin.Messaging.Integration.State.ServerStateContext Information: 0 : !The connection to 'macbook.lan' has been finished: 10.25.2022 22:41:25Z DateTime=2022-10-25T22:41:25.4641170Z: 10.25.2022 22:41:25Z Xamarin.Messaging.Integration.State.ServerStateContext Error: 0 : An error occurred while trying to establish an SSH connection with SSH keys to '192.168.178.27:22' Xamarin.Messaging.Integration.MessagingConfigurationException: An error occurred while trying to establish an SSH connection with SSH keys to '192.168.178.27:22' ---&gt; System.IO.FileNotFoundException: Could not find file 'C:\Users\Stefan\AppData\Local\Xamarin\MonoTouch\id_rsa'. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) at Renci.SshNet.PrivateKeyFile..ctor(String fileName, String passPhrase) at Xamarin.Messaging.Ssh.MessagingAuthenticationMethod.InitializePrivateKeyAuthentication(String username, ISshInformationProvider sshInformationProvider) in D:\a\_work\1\s\src\Xamarin.Messaging.Ssh\MessagingAuthenticationMethod.cs:line 84 at Xamarin.Messaging.Integration.State.ConfiguringState.&lt;GetSshConnectionAsync&gt;d__17.MoveNext() in D:\a\_work\1\s\src\Xamarin.Messaging.Integration\State\ConfiguringState.cs:line 193 --- End of inner exception stack trace --- at Xamarin.Messaging.Integration.State.ConfiguringState.&lt;GetSshConnectionAsync&gt;d__17.MoveNext() in D:\a\_work\1\s\src\Xamarin.Messaging.Integration\State\ConfiguringState.cs:line 224 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Xamarin.Messaging.Integration.State.ConfiguringState.&lt;GetSshConnectionAsync&gt;d__15.MoveNext() in D:\a\_work\1\s\src\Xamarin.Messaging.Integration\State\ConfiguringState.cs:line 127 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Xamarin.Messaging.Integration.State.ConfiguringState.&lt;OnExecutingAsync&gt;d__14.MoveNext() in D:\a\_work\1\s\src\Xamarin.Messaging.Integration\State\ConfiguringState.cs:line 70: 10.25.2022 22:41:25Z DateTime=2022-10-25T22:41:25.4907201Z: 10.25.2022 22:41:25Z Xamarin.Messaging.Integration.State.ServerStateContext Error: 0 : !An error occurred while trying to establish an SSH connection with SSH keys to '192.168.178.27:22': 10.25.2022 22:41:25Z DateTime=2022-10-25T22:41:25.4917191Z: 10.25.2022 22:41:25Z System.Net.Mqtt.Sdk.ClientPacketListener Error: 0 : Client - An error occurred while listening and dispatching packets System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---&gt; System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult) at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult) --- End of inner exception stack trace --- at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult) at System.Threading.Tasks.TaskFactory`1.FromAsyncTrimPromise`1.Complete(TInstance thisRef, Func`3 endMethod, IAsyncResult asyncResult, Boolean requiresSynchronization): 10.25.2022 22:45:28Z DateTime=2022-10-25T22:45:28.6158613Z: 10.25.2022 22:45:28Z System.Net.Mqtt.Sdk.ClientPacketListener Error: 0 : Client - An error occurred while listening and dispatching packets System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---&gt; System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult) at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult) --- End of inner exception stack trace --- at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult) at System.Threading.Tasks.TaskFactory`1.FromAsyncTrimPromise`1.Complete(TInstance thisRef, Func`3 endMethod, IAsyncResult asyncResult, Boolean requiresSynchronization): 10.25.2022 22:45:28Z DateTime=2022-10-25T22:45:28.6168613Z: 10.25.2022 22:45:28Z System.Net.Mqtt.Sdk.MqttClientImpl Error: 0 : System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---&gt; System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult) at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult) --- End of inner exception stack trace --- at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult) at System.Threading.Tasks.TaskFactory`1.FromAsyncTrimPromise`1.Complete(TInstance thisRef, Func`3 endMethod, IAsyncResult asyncResult, Boolean requiresSynchronization): 10.25.2022 22:45:28Z DateTime=2022-10-25T22:45:28.6188610Z: 10.25.2022 22:45:28Z Xamarin.Messaging.Ssh.MessagingService Error: 0 : An error occurred on the underlying client while executing an operation. Details: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.: 10.25.2022 22:45:28Z DateTime=2022-10-25T22:45:28.6413821Z: 10.25.2022 22:45:28Z </code></pre> <p>The exception about the missing file is misleading. First of it does not exist but if you watch the folder during the connection process it gets created among with other files and when it fails it gets deleted again. So I am assuming that is a different error.</p> <p>And ssh login to the machine and everything works fine. I can ssh into it and if you enable verbose login there are other commands as well as scp which are being executed just fine.</p> <p>Has anyone encountered this problem and has a solution?</p> <p>Visual Studio 2022</p> <p>OSX Ventura with XCode 14.0.1 and Visual Studio 17.3.8 (build5)</p>
[ { "answer_id": 74237578, "author": "Steve", "author_id": 709672, "author_profile": "https://Stackoverflow.com/users/709672", "pm_score": 1, "selected": false, "text": "HostkeyAlgorithms +ssh-rsa\nPubkeyAcceptedAlgorithms +ssh-rsa\n" } ]
2022/10/25
[ "https://Stackoverflow.com/questions/74201038", "https://Stackoverflow.com", "https://Stackoverflow.com/users/709672/" ]
74,201,039
<p>I have a dataframe in the following format (working with sports data):</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Team</th> <th>Player</th> <th>Date</th> <th>GameID</th> </tr> </thead> <tbody> <tr> <td>Bears</td> <td>John</td> <td>2022-10-01</td> <td>A1</td> </tr> <tr> <td>Bears</td> <td>Dave</td> <td>2022-10-01</td> <td>A1</td> </tr> <tr> <td>Bears</td> <td>Steve</td> <td>2022-10-01</td> <td>A1</td> </tr> <tr> <td>Bulls</td> <td>Connor</td> <td>2022-10-01</td> <td>C2</td> </tr> <tr> <td>Bulls</td> <td>Jack</td> <td>2022-10-01</td> <td>C2</td> </tr> <tr> <td>Bears</td> <td>John</td> <td>2022-10-03</td> <td>A3</td> </tr> </tbody> </table> </div> <p>Basically, I want to be able to sort by team name and date, and add a column called <strong>GameNum</strong> that counts from 1 to 82 (82 games in the dataset for each team) based on the game number for the season, like below:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Team</th> <th>Player</th> <th>Date</th> <th>GameID</th> <th>GameNum</th> </tr> </thead> <tbody> <tr> <td>Bears</td> <td>John</td> <td>2022-10-01</td> <td>A1</td> <td>1</td> </tr> <tr> <td>Bears</td> <td>Dave</td> <td>2022-10-01</td> <td>A1</td> <td>1</td> </tr> <tr> <td>Bears</td> <td>Steve</td> <td>2022-10-01</td> <td>A1</td> <td>1</td> </tr> <tr> <td>Bulls</td> <td>Connor</td> <td>2022-10-01</td> <td>C2</td> <td>1</td> </tr> <tr> <td>Bulls</td> <td>Jack</td> <td>2022-10-01</td> <td>C2</td> <td>1</td> </tr> <tr> <td>Bears</td> <td>John</td> <td>2022-10-03</td> <td>A3</td> <td>2</td> </tr> </tbody> </table> </div> <p>I can do this manually by taking a sub-dataframe of each unique team, sorting by game date, and then adding an iterator value from 1 to 82 and then unioning the results for each team, but I was wondering if there was a &quot;cleaner&quot; way to do this without resorting to for-loops and unioning based on teams.</p>
[ { "answer_id": 74201244, "author": "mlokos", "author_id": 19570235, "author_profile": "https://Stackoverflow.com/users/19570235", "pm_score": 1, "selected": false, "text": "import pandas as pd\n\ndata = {'team':[\"bears\", \"bears\", \"bears\", \"bulls\", \"bulls\", \"bears\"], 'value':[...
2022/10/25
[ "https://Stackoverflow.com/questions/74201039", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5361454/" ]
74,201,048
<p>For some reason this one is getting me. I started down the reduce way, then failed. I need to iterate over an array of objects, find a property by name (<code>target</code>), find all the unique values for that property, and create an array of those unique values with the number of times they appear. Here is the data structure.</p> <p>DATA:</p> <pre><code>[ { name: &quot;doesnt matter&quot;, target: &quot;A&quot;, other: &quot;doesnt matter&quot; }, { name: &quot;doesnt matter&quot;, target: &quot;B&quot;, other: &quot;doesnt matter&quot; }, { name: &quot;doesnt matter&quot;, target: &quot;C&quot;, other: &quot;doesnt matter&quot; }, { name: &quot;doesnt matter&quot;, target: &quot;A&quot;, other: &quot;doesnt matter&quot; }, { name: &quot;doesnt matter&quot;, target: &quot;B&quot;, other: &quot;doesnt matter&quot; }, { name: &quot;doesnt matter&quot;, target: &quot;C&quot;, other: &quot;doesnt matter&quot; }, { name: &quot;doesnt matter&quot;, target: &quot;A&quot;, other: &quot;doesnt matter&quot; }, { name: &quot;doesnt matter&quot;, target: &quot;B&quot;, other: &quot;doesnt matter&quot; }, { name: &quot;doesnt matter&quot;, target: &quot;A&quot;, other: &quot;doesnt matter&quot; } ] </code></pre> <p>What I am aiming for is a new array like this:</p> <pre><code>newArray = [['A', 4], ['B', 3], ['C', 2]] </code></pre> <p>What I kind of had, but doesn't fully work:</p> <pre><code>arr.reduce((accumulator: any, currentOrder: any) =&gt; { if ( !accumulator[currentOrder[property] ] ) { accumulator[currentOrder[property]] = []; } accumulator[currentOrder[property]].push(currentOrder); return accumulator; }, []); </code></pre>
[ { "answer_id": 74201093, "author": "Amirhossein Sefati", "author_id": 11856099, "author_profile": "https://Stackoverflow.com/users/11856099", "pm_score": 0, "selected": false, "text": "forEach" }, { "answer_id": 74201189, "author": "Nicholas Carey", "author_id": 467473, ...
2022/10/25
[ "https://Stackoverflow.com/questions/74201048", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1385272/" ]