qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,401,209
<p>I've this code in the snippet. It's an intersection Observer that tracks visible headers and adds an &quot;active&quot; class to the corresponding anchor tag in the top nav.</p> <p>I would like to know if it's possible for the 'li' element with class &quot;active&quot; to also be scrolled into view.</p> <p>I have tried a mutationObserver but I can't seem to make it work by any means.</p> <p>Thanks!</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> window.addEventListener('DOMContentLoaded', () =&gt; { const observer = new IntersectionObserver(entries =&gt; { entries.forEach(entry =&gt; { const id = entry.target.getAttribute('id'); if (entry.intersectionRatio &gt; 0) { document.querySelector(`ul li a[href="#${id}"]`).parentElement.classList.add('active'); } else { document.querySelector(`ul li a[href="#${id}"]`).parentElement.classList.remove('active'); } }); }); // Track all sections that have an `id` applied document.querySelectorAll('h2[id]').forEach((h2) =&gt; { observer.observe(h2); }); });</code></pre> <pre class="snippet-code-css lang-css prettyprint-override"><code>.table_of_content li{ display:inline-flex; margin-right: 20px; border-right: 2px solid black; padding-right:15px; } .table_of_content { border-left:none; z-index:1000; position: sticky; background-color:white; top: -1px; overflow-x: auto; overflow-y: hidden; white-space: nowrap; } .table_of_content ul { margin: 0 auto; padding: 15px 0; } .table_of_content li.active &gt; a { color:#ff9900; border-radius:5px; text-decoration:underline; } .section { max-width: 400px; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="section"&gt; &lt;div id="navigation12" class="table_of_content"&gt; &lt;ul&gt; &lt;li&gt;&lt;span&gt;In this article&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#header1"&gt;Heading 1&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#header2"&gt;Heading 2&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#header3"&gt;Heading 3&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#header4"&gt;Heading 4&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#header5"&gt;Heading 5&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#header6"&gt;Heading 6&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#header7"&gt;Heading 7&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#header8"&gt;Heading 8&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;h2 id="header1"&gt;Header 1&lt;/h2&gt; Lorem, ipsum dolor sit amet consectetur adipisicing elit. Culpa, ex. Eaque laboriosam fugiat debitis quisquam maiores ipsa aspernatur quam provident tenetur! Ipsa possimus illum provident. Quam, quaerat cum? Earum, reiciendis! &lt;h2 id="header2"&gt;Header 2&lt;/h2&gt; Lorem ipsum dolor, sit amet consectetur adipisicing elit. Quia neque, repudiandae minus sit ratione expedita debitis hic sequi recusandae repellat? Eligendi, reiciendis voluptatem. Quidem tempore cupiditate obcaecati rem omnis quis commodi, rerum in delectus beatae eius nulla? Harum laborum, obcaecati ipsa officiis velit voluptatibus alias facilis at recusandae dolores molestias, autem quas. Repellendus ducimus soluta culpa dicta vel eveniet recusandae beatae odit id exercitationem ratione, nemo inventore, unde dolores eligendi quasi pariatur rem labore? Labore eum doloremque non illo, autem optio, excepturi ad quis reiciendis exercitationem necessitatibus fugit? Repellendus dolore ea magnam tempora in corporis sed totam et suscipit! Nihil? &lt;h2 id="header3"&gt;Header 3&lt;/h2&gt; Lorem ipsum dolor sit amet consectetur adipisicing elit. Architecto debitis, eligendi odit quam necessitatibus enim alias perferendis ut maxime quod quae ipsam minima voluptates voluptatibus at nobis, esse sequi beatae dolor quis. Quia officiis consequuntur, delectus dolore temporibus reprehenderit reiciendis sunt perspiciatis aspernatur, facere veniam. Ad corporis a voluptate provident soluta eveniet? Sunt est deserunt amet assumenda iste odit ad placeat! Vitae aliquam aliquid, molestiae cum aut unde velit laboriosam, perferendis rem asperiores pariatur quam optio quo nostrum saepe quia id dignissimos, consequatur molestias sed nulla ipsum? Molestias ab sapiente dolores ut. Dolor vero quod, distinctio laborum expedita incidunt repudiandae. &lt;h2 id="header4"&gt;Header 4&lt;/h2&gt; Lorem ipsum dolor sit amet consectetur, adipisicing elit. Illo consequatur, harum doloribus nisi vitae odit non deserunt et veritatis modi maxime repudiandae quasi cum eveniet inventore, fuga similique accusamus ad magnam alias qui optio delectus provident. Asperiores labore molestias quod laborum quasi sequi suscipit, optio tenetur esse soluta debitis eaque, doloribus reiciendis voluptatum iure dolorum quibusdam vel nihil quo ratione cupiditate necessitatibus aliquid obcaecati totam. Deserunt laudantium officiis et? Quas doloribus ipsum nam similique libero velit, tempora, delectus exercitationem cumque autem in iste, perspiciatis repudiandae a aliquid nobis ut voluptate corrupti unde recusandae voluptas rem aut nisi quam. Inventore, dolor. &lt;h2 id="header5"&gt;Header 5&lt;/h2&gt; Lorem ipsum dolor sit amet consectetur adipisicing elit. Animi explicabo, numquam aliquam minus eveniet vero neque ratione quidem voluptatem ipsa officiis soluta beatae dicta eligendi quo, nemo quaerat atque mollitia! Vitae mollitia voluptatum natus iusto eum quis debitis, similique illo, libero necessitatibus illum provident ad inventore sed consectetur molestias ipsa impedit obcaecati cumque et. Eveniet, molestiae deserunt rem earum dolor neque animi dignissimos dolore atque provident at numquam repellendus aliquam adipisci officia maxime fuga unde reiciendis saepe, sint culpa recusandae. At neque sapiente mollitia doloremque, architecto voluptatem delectus nulla laboriosam dicta quo animi magnam nisi in? Voluptatum harum et est! &lt;h2 id="header6"&gt;Header 6&lt;/h2&gt; Lorem, ipsum dolor sit amet consectetur adipisicing elit. Debitis distinctio nesciunt ut similique dicta cum est quis soluta harum quam, dolorem sequi repellat, atque provident eius. Atque ea quibusdam quo! Rem nihil pariatur ex magni odio modi sed unde quidem laboriosam doloremque repellat quo eum nemo eaque mollitia adipisci exercitationem ipsam blanditiis, consectetur atque libero totam quaerat officia soluta? Cum ipsam a incidunt cumque earum quod ea quibusdam vel ratione? Minima, id voluptate! Minima cumque quisquam, quod blanditiis quas et est laudantium placeat explicabo, dolorum velit, facilis cupiditate aspernatur nostrum dicta voluptatem adipisci suscipit debitis enim ullam commodi? Magni, consequatur. &lt;h2 id="header7"&gt;Header 7&lt;/h2&gt; Lorem ipsum dolor sit amet consectetur adipisicing elit. Blanditiis alias soluta qui accusantium in repellendus, doloremque ullam quis esse optio veniam fugit doloribus mollitia ea, dolorum rem. Unde, adipisci. Totam vel harum maiores illo nobis culpa labore corrupti quasi atque consequuntur, minus odio deleniti iure, ab natus aliquam consectetur asperiores quia eveniet dolorem similique dolore eos quisquam. Quis, ipsam corrupti? Atque molestiae omnis asperiores dolores eos obcaecati aspernatur, recusandae eaque numquam consectetur aut corporis vitae dignissimos et ipsum eum odit id incidunt voluptate perferendis! Saepe tempora iste aspernatur enim quidem labore voluptatem id dolor quam esse! Quibusdam reiciendis inventore hic! &lt;h2 id="header8"&gt;Header 8&lt;/h2&gt; Lorem ipsum dolor, sit amet consectetur adipisicing elit. Est amet inventore quae eveniet sequi unde! Consequatur necessitatibus minima molestias quia vero recusandae unde veniam nobis qui saepe minus culpa ab rem aspernatur officiis earum et doloribus, provident eius asperiores. Harum consectetur odio blanditiis, sunt rerum necessitatibus exercitationem vero dolorem rem, cupiditate pariatur officiis repudiandae deserunt modi sequi aspernatur ratione libero perspiciatis illo cum saepe debitis tempora sapiente! Possimus modi nostrum ipsum placeat nam praesentium quos vero in, non dolor debitis dolorum nobis cum natus obcaecati, soluta reprehenderit sapiente. Eius ducimus placeat numquam incidunt magni repudiandae accusantium quasi alias vitae vero! &lt;/div&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74428886, "author": "Jonas Weinhardt", "author_id": 16500604, "author_profile": "https://Stackoverflow.com/users/16500604", "pm_score": 2, "selected": true, "text": "active" }, { "answer_id": 74429174, "author": "Saurav Ghimire", "author_id": 13227171, "author_profile": "https://Stackoverflow.com/users/13227171", "pm_score": 2, "selected": false, "text": "li" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401209", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7346175/" ]
74,401,212
<p>I want to aggregate a <code>pandas.Series</code> with an hourly <code>DatetimeIndex</code> to monthly values - while considering the offset to midnight.</p> <h2>Example</h2> <p>Consider the following (uniform) timeseries that spans about 1.5 months.</p> <pre class="lang-py prettyprint-override"><code>import pandas as pd hours = pd.Series(1, pd.date_range('2020-02-23 06:00', freq = 'H', periods=1008)) hours # 2020-02-23 06:00:00 1 # 2020-02-23 07:00:00 1 # .. # 2020-04-05 04:00:00 1 # 2020-04-05 05:00:00 1 # Freq: H, Length: 1000, dtype: int64 </code></pre> <p>I would like to sum these to months <strong>while considering, that days start at 06:00</strong> in this use-case. The result should be:</p> <pre><code>2020-02-01 06:00:00 168 2020-03-01 06:00:00 744 2020-04-01 06:00:00 96 freq: MS, dtype: int64 </code></pre> <p><strong>How do I do that??</strong></p> <hr /> <h2>What I've tried and what works</h2> <ul> <li><p>I <em>can</em> aggregate to days while considering the offset, using the <code>offset</code> parameter:</p> <pre class="lang-py prettyprint-override"><code>days = hours.resample('D', offset=pd.Timedelta('06:00:00')).sum() days # 2020-02-23 06:00:00 24 # 2020-02-24 06:00:00 24 # .. # 2020-04-03 06:00:00 24 # 2020-04-04 06:00:00 24 # Freq: D, dtype: int64 </code></pre> </li> <li><p>Using the same method to aggregate to months does not work. The timestamps do not have a time component, <strong>and the values are incorrect</strong>:</p> <pre class="lang-py prettyprint-override"><code>months = hours.resample('MS', offset=pd.Timedelta('06:00:00')).sum() months # 2020-02-01 162 # wrong # 2020-03-01 744 # 2020-04-01 102 # wrong # Freq: MS, dtype: int64 </code></pre> </li> <li><p>I could do the aggregation to months as a second step after aggregating to days. In that case, the values are correct, but the time component is still missing from the timestamps:</p> <pre class="lang-py prettyprint-override"><code>days = hours.resample('D', offset=pd.Timedelta('06:00:00')).sum() months = days.resample('MS', offset=pd.Timedelta('06:00:00')).sum() months # 2020-02-01 168 # 2020-03-01 744 # 2020-04-01 96 # Freq: MS, dtype: int64 </code></pre> </li> <li><p>My current workaround is adding the timedelta and resetting the frequency manually.</p> <pre class="lang-py prettyprint-override"><code>months.index += pd.Timedelta('06:00:00') months.index.freq = 'MS' months # 2020-02-01 06:00:00 168 # 2020-03-01 06:00:00 744 # 2020-04-01 06:00:00 96 # freq: MS, dtype: int64 </code></pre> </li> </ul>
[ { "answer_id": 74620786, "author": "Haleemur Ali", "author_id": 2570261, "author_profile": "https://Stackoverflow.com/users/2570261", "pm_score": 1, "selected": false, "text": "months = hours.resample('D', offset='06:00:00').sum().resample('MS').sum()\n" }, { "answer_id": 74646969, "author": "ahmetbulut", "author_id": 1497750, "author_profile": "https://Stackoverflow.com/users/1497750", "pm_score": -1, "selected": false, "text": "import pandas as pd\n\nhours = pd.Series(1, pd.date_range('2020-02-23 06:00', freq = 'H', periods=1008))\n\n# Aggregate the timeseries to monthly values using the offset parameter\nmonths = hours.resample('MS', offset=pd.Timedelta('06:00:00')).sum()\n\n# Print the result\nprint(months)\n\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401212", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2302262/" ]
74,401,221
<p>I am wondering is it possible to do voting for classification tasks. I have seen plenty of blogs explaining how to use voting for regression purposes.As given below.</p> <pre><code># initializing all the model objects with default parameters model_1 = LinearRegression() model_2 = xgb.XGBRegressor() model_3 = RandomForestRegressor() # training all the model on the training dataset model_1.fit(X_train, y_target) model_2.fit(X_train, y_target) model_3.fit(X_train, y_target) # predicting the output on the validation dataset pred_1 = model_1.predict(X_test) pred_2 = model_2.predict(X_test) pred_3 = model_3.predict(X_test) # final prediction after averaging on the prediction of all 3 models pred_final = (pred_1+pred_2+pred_3)/3.0 # printing the mean squared error between real value and predicted value print(mean_squared_error(y_test, pred_final)) </code></pre>
[ { "answer_id": 74410055, "author": "Dulangi_Kanchana", "author_id": 12017769, "author_profile": "https://Stackoverflow.com/users/12017769", "pm_score": 3, "selected": true, "text": "# initializing all the model objects with default parameters\n\nmodel_1= svm.SVC(kernel='rbf')\nmodel_2 = XGBClassifier()\nmodel_3 = RandomForestClassifier()\n \n# Making the final model using voting classifier\nfinal_model = VotingClassifier(estimators=[('svc', model_1), ('xgb', model_2), ('rf', model_3)], voting='hard')\n\n# applying 10 fold cross validation\nscores = cross_val_score(final_model, X_all, y, cv=10, scoring='accuracy')\nprint(scores) \nprint('Model accuracy score : {0:0.4f}'.format(scores.mean()))\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401221", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14372590/" ]
74,401,226
<p>Have a bunch of values from csv file, with column looking like this:</p> <pre><code>shouston cgonzalez bbrown hlader kpesavento jbloom polson bcharlow bcharlow bkalt </code></pre> <p>Need to find duplicates and modify them.</p> <pre><code># Grab CSV file $inputFile = Import-Csv -Path $filePath $text = (Get-Culture).TextInfo $HashSet = [System.Collections.Generic.HashSet[string]]::new([System.StringComparer]::OrdinalIgnoreCase) foreach ($line in $inputFile) { $name = $line.name $line.name = $text.ToTitleCase($name) $firstName = $line.name.split(&quot; &quot;)[0] $lastName = $line.name.split(&quot; &quot;)[1] $newEmail = ($firstName[0] + $lastName).toLower() if (!$HashSet.Add($newEmail)) { $line.email = ($firstName[0] + $lastName + $line.location_id + &quot;@abc.com&quot;).toLower() } else { $line.email = ($firstName[0] + $lastName + &quot;@abc.com&quot;).toLower() } } $inputFile | Export-Csv $fullPath </code></pre> <p>But its not working as I expected - find a duplicate values and modify them. In my case, the location must also be added to the first duplicate email, example bcharlow1 bcharlow2, not it's bcharlow, bcharlow2. Can anyone help me - how I need to modify script?</p>
[ { "answer_id": 74401313, "author": "Vasil Nikolov", "author_id": 4131695, "author_profile": "https://Stackoverflow.com/users/4131695", "pm_score": 2, "selected": false, "text": "Group-Object" }, { "answer_id": 74402033, "author": "iRon", "author_id": 1701026, "author_profile": "https://Stackoverflow.com/users/1701026", "pm_score": 1, "selected": false, "text": "$InputFile = ConvertFrom-Csv @'\nid, location_id, name, title, email, department\n 1, 1, \"Susan houston\", DS, ,\n 2, 1, \"Christina Gonzalez\", D, ,\n 3, 2, \"Brenda brown\", \"Director, Second Career Services\", ,\n 4, 3, \"Howard Lader\", \"Manager, Senior Counseling\", ,\n 5, 4, \"Kimberly Pesavento\", \"Commercial director\", ,\n 6, 5, \"Joe Bloom\", Finance, , 7\n 8, 6, \"Bart charlow\", Director, ,\n 9, 7, \"Bart Charlow\", Director, ,\n'@\n\n$Emails = [System.Collections.Generic.HashSet[string]]::new([System.StringComparer]::OrdinalIgnoreCase)\n\nforeach ($line in $inputFile) {\n $name = $line.name\n $line.name = (Get-Culture).TextInfo.ToTitleCase($name)\n $firstName = $line.name.split(\" \")[0]\n $lastName = $line.name.split(\" \")[1]\n $newEmail = ($firstName[0] + $lastName).toLower()\n\n if (!$Emails.Add($newEmail)) {\n $line.email = ($firstName[0] + $lastName + $line.location_id + \"@abc.com\").toLower()\n }\n else {\n $line.email = ($firstName[0] + $lastName + \"@abc.com\").toLower()\n }\n}\n\n$InputFile |ConvertTo-Csv\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401226", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10009512/" ]
74,401,252
<p>I have an array of objects like this</p> <pre><code>const data = [{ &quot;id&quot;: 1, &quot;content&quot;: { &quot;type&quot;: &quot;img&quot;, &quot;state&quot;: &quot;rejected&quot; }, &quot;entity&quot;: { &quot;type&quot;: &quot;student&quot;, &quot;studentID&quot;: [ 44 ] }, &quot;status&quot;: &quot;rejected&quot; }, { &quot;id&quot;: 2, &quot;content&quot;: { &quot;type&quot;: &quot;img&quot;, &quot;state&quot;: &quot;approved&quot; }, &quot;entity&quot;: { &quot;type&quot;: &quot;student&quot;, &quot;studentID&quot;: [ 45 ] }, &quot;status&quot;: &quot;approved&quot; }, { &quot;id&quot;: 3, &quot;content&quot;: { &quot;type&quot;: &quot;img&quot;, &quot;state&quot;: &quot;approved&quot; }, &quot;entity&quot;: { &quot;type&quot;: &quot;student&quot;, &quot;studentID&quot;: [ 44 ] }, &quot;status&quot;: &quot;approved&quot; } ] </code></pre> <p>As you can see, we have 2 objects of student id 44 (one with status rejected and one with approved) and one of student id 45. I have another array of object with student info like this</p> <pre><code>const students = [{ student_id: 44, fname: 'student 1', lname: '.', school: 'XYZ', }, { student_id: 45, fname: 'student 2', lname: '.', school: 'ABC', } ] </code></pre> <p>Now, i want to create a new array of object with both of them mapped, but each object in data mapped with their corresponding student (relation between <code>entity.studentID[0]</code> in <code>data</code> with <code>student_id</code> in <code>students</code>, so that the resultant array of object is</p> <pre><code>[{ student_id: 44, fname: 'student 1', lname: '.', school: 'XYZ', item: { id: 1, status: &quot;rejected&quot; }, }, { student_id: 45, fname: 'student 2', lname: '.', school: 'ABC', item: { id: 2, status: &quot;approved&quot; }, }, { student_id: 44, fname: 'student 1', lname: '.', school: 'XYZ', item: { id: 3, status: &quot;approved&quot; }, }, ] </code></pre> <p>What i did was i ran a loop on <code>students</code> and tried using <code>map</code> but that returns me an array of objects that qualify the condition instead of the objects themselves.</p> <pre><code>let arr = [] for (let student of students) { let obj = { ...student }; obj[&quot;item&quot;] = data.map((p) =&gt; { if (p.entity.studentId[0] === student.student_id) { return { id: p.id, status: p.status, }; } }); arr.push(obj); } </code></pre> <p>Where am i going wrong and what should i do instead?</p>
[ { "answer_id": 74401464, "author": "flyingfox", "author_id": 3176419, "author_profile": "https://Stackoverflow.com/users/3176419", "pm_score": 3, "selected": true, "text": "let result = data.map(d =>{\n let stu = students.find(i => d.entity.studentID.includes(i.student_id))\n return {...stu,item:{id:d.id,status:d.status}}\n})\nconsole.log(result)\n" }, { "answer_id": 74401661, "author": "Harshil Chudasama", "author_id": 14914810, "author_profile": "https://Stackoverflow.com/users/14914810", "pm_score": 0, "selected": false, "text": "let newStudent = [];\ndata.map((data) => {\n const studentId = data['entity']['studentID'];\n function sts() { return data.status};\n students.map((student) => {\n const std_id = student.student_id;\n if (std_id == studentId) {\n newStudent.push({\n student_id: std_id,\n fname: student.fname,\n lname: student.lname,\n school: student.school,\n id: newStudent.length + 1,\n status: sts()\n });\n }\n })\n})\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401252", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18711972/" ]
74,401,289
<p>We had implemented modern OAuth implementation for reading mails from outlook mail boxes. The code we used is whatever is available on the microsoft offical website. But it throws &quot;The request failed. The remote server returned an error: (403) Forbidden.&quot; . But the authentication token is getting correctly. Here is my code</p> <pre><code> static void Main(string[] args) { MainTask().Wait(); } static async System.Threading.Tasks.Task MainTask() { // Using Microsoft.Identity.Client 4.22.0 var cca = ConfidentialClientApplicationBuilder .Create(ConfigurationManager.AppSettings[&quot;appId&quot;]) .WithClientSecret(ConfigurationManager.AppSettings[&quot;clientSecret&quot;]) .WithTenantId(ConfigurationManager.AppSettings[&quot;tenantId&quot;]) .Build(); ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; var ewsScopes = new string[] { &quot;https://outlook.office365.com/.default&quot; }; try { var authResult = await cca.AcquireTokenForClient(ewsScopes) .ExecuteAsync(); // Configure the ExchangeService with the access token var ewsClient = new ExchangeService(); ewsClient.Url = new Uri(&quot;https://outlook.office365.com/EWS/Exchange.asmx&quot;); ewsClient.Credentials = new OAuthCredentials(authResult.AccessToken); ewsClient.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, &quot;myname@mydomain.com&quot;); //Include x-anchormailbox header ewsClient.HttpHeaders.Add(&quot;X-AnchorMailbox&quot;, &quot;myname@mydomain.com&quot;); // Make an EWS call var folders = ewsClient.FindFolders(WellKnownFolderName.Inbox, new FolderView(10)); foreach (var folder in folders) { Console.WriteLine($&quot;Folder: {folder.DisplayName}&quot;); } } catch (MsalException ex) { Console.WriteLine($&quot;Error acquiring access token: {ex}&quot;); } catch (Exception ex) { Console.WriteLine($&quot;Error: {ex}&quot;); } if (System.Diagnostics.Debugger.IsAttached) { Console.WriteLine(&quot;Hit any key to exit...&quot;); Console.ReadKey(); } } </code></pre> <p>Almost we tried all possible ways. Please anyone support who already successfully implemented this modern OAuth functionality. Thanks in advance</p>
[ { "answer_id": 74401464, "author": "flyingfox", "author_id": 3176419, "author_profile": "https://Stackoverflow.com/users/3176419", "pm_score": 3, "selected": true, "text": "let result = data.map(d =>{\n let stu = students.find(i => d.entity.studentID.includes(i.student_id))\n return {...stu,item:{id:d.id,status:d.status}}\n})\nconsole.log(result)\n" }, { "answer_id": 74401661, "author": "Harshil Chudasama", "author_id": 14914810, "author_profile": "https://Stackoverflow.com/users/14914810", "pm_score": 0, "selected": false, "text": "let newStudent = [];\ndata.map((data) => {\n const studentId = data['entity']['studentID'];\n function sts() { return data.status};\n students.map((student) => {\n const std_id = student.student_id;\n if (std_id == studentId) {\n newStudent.push({\n student_id: std_id,\n fname: student.fname,\n lname: student.lname,\n school: student.school,\n id: newStudent.length + 1,\n status: sts()\n });\n }\n })\n})\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401289", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16487509/" ]
74,401,301
<p>Hi I am trying to extract the surname from a list of initials and names it is ok for one inital but 2 I just cant seem to get it right</p> <pre><code>SELECT NAMES, REGEXP_SUBSTR(NAMES,'(\s.+$)') FROM PEOPLE </code></pre> <p>this gets me this top table. I have faffed about online for hours now trying to get to work with some online testers but just seems to break it. anyone help out with the right <code>'(\s.+$)'</code> ??</p> <p>I tried this <code>\s{2,}.+$</code> but no dice comes back with nothing :( same result as below <code>\s.{2,}+$</code></p> <p>This is what I have</p> <p>TABLE PEOPLE</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: left;">Column A</th> <th style="text-align: right;">Column B</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">A Peat</td> <td style="text-align: right;">Peat</td> </tr> <tr> <td style="text-align: left;">D Jones</td> <td style="text-align: right;">Jones</td> </tr> <tr> <td style="text-align: left;">F Peat</td> <td style="text-align: right;">Peat</td> </tr> <tr> <td style="text-align: left;">D Jones</td> <td style="text-align: right;">Jones</td> </tr> <tr> <td style="text-align: left;">F D Peat</td> <td style="text-align: right;">D Peat</td> </tr> <tr> <td style="text-align: left;">D Jones</td> <td style="text-align: right;">Jones</td> </tr> </tbody> </table> </div> <p>What I am after......</p> <p>TABLE PEOPLE</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: left;">Column A</th> <th style="text-align: right;">Column B</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">A Peat</td> <td style="text-align: right;">Peat</td> </tr> <tr> <td style="text-align: left;">D Jones</td> <td style="text-align: right;">Jones</td> </tr> <tr> <td style="text-align: left;">F Peat</td> <td style="text-align: right;">Peat</td> </tr> <tr> <td style="text-align: left;">D Jones</td> <td style="text-align: right;">Jones</td> </tr> <tr> <td style="text-align: left;">F D Peat</td> <td style="text-align: right;">Peat</td> </tr> <tr> <td style="text-align: left;">D Jones</td> <td style="text-align: right;">Jones</td> </tr> </tbody> </table> </div> <p>hopefully the question is good enough but this box is not long enough for all my disasters I have tried :) <code>(\s.+$)</code></p>
[ { "answer_id": 74401464, "author": "flyingfox", "author_id": 3176419, "author_profile": "https://Stackoverflow.com/users/3176419", "pm_score": 3, "selected": true, "text": "let result = data.map(d =>{\n let stu = students.find(i => d.entity.studentID.includes(i.student_id))\n return {...stu,item:{id:d.id,status:d.status}}\n})\nconsole.log(result)\n" }, { "answer_id": 74401661, "author": "Harshil Chudasama", "author_id": 14914810, "author_profile": "https://Stackoverflow.com/users/14914810", "pm_score": 0, "selected": false, "text": "let newStudent = [];\ndata.map((data) => {\n const studentId = data['entity']['studentID'];\n function sts() { return data.status};\n students.map((student) => {\n const std_id = student.student_id;\n if (std_id == studentId) {\n newStudent.push({\n student_id: std_id,\n fname: student.fname,\n lname: student.lname,\n school: student.school,\n id: newStudent.length + 1,\n status: sts()\n });\n }\n })\n})\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401301", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10001788/" ]
74,401,317
<p>I have a task and I will try to explain it clearly. There is a file with [0; 1000] lines. Each line contains 6 columns.</p> <p>The first two columns contain <em>string</em> with [1; 20] characters. Characters could be <em>letters, numbers, and whitespaces</em>.</p> <p>3-5 columns contain integers in the range <em>[-100; 100]</em>. 6th column contain real numbers in range <em>[-9.99; 9.99]</em> with only two digits after decimal point.</p> <p>Each section I separated by a semicolon ';'.</p> <p><strong>FILE EXAMPLE:</strong></p> <pre><code>helloA;lB;lC;lD;lE;lF A11;bas morning;0;0;5;1.15 B12; Hello WoRlD;-100;11;78;1.33 B11;table;10;0;55;-2.44 C1;OakWood;0;8;17;3.77 </code></pre> <p><strong>TASK:</strong> count how many lines in the first two sections contain the letters 'B' and 'C'. And print that integer number in the other file.</p> <p>I did almost all the task, except one thing. I don't know how to print the decimal number in the file. I store this number in memory as <em>hexadecimal</em>. I need to convert that number to <em>decimal</em> and print it into the other file.</p> <p>I am struggling because there could be 1 good line, but it also could be 1000 good lines. So I need to print 1 character (if the number of good lines is between [0; 9]), but it could be 900 good lines, so then the program has to print 3 characters.</p> <p><strong>MY CODE</strong></p> <pre><code>org 100h %include 'yasmmac.inc' section .text startas: macPutString 'Output file:', crlf, '$' ; Save the writing file's name mov al, 128 mov dx, writingFile call procGetStr macNewLine ; Open reading file mov dx, readingFile call procFOpenForReading jnc .writingFileOpen macPutString 'Error while opening the writing file!', '$' exit ; Open the writing file .writingFileOpen: mov [readingDescriptor], bx mov dx, writingFile call procFCreateOrTruncate jnc .writingFileSuccessfullyOpened macPutString 'Error while opening file for writing!', '$' jmp .writingError ; Sacing writing descriptor .writingFileSuccessfullyOpened: mov [writingDescriptor], bx ; Read first line call procReadLine ; Main loop .untilEndOfFile: call procReadLine ; checking the first two columns ;mov al, ';' ; checking first column .firstColumn: mov al, [di] inc di cmp al, byte 'B' je .skipALine cmp al, byte 'b' je .skipALine cmp al, byte 'C' je .skipALine cmp al, byte 'c' je .skipALine cmp al, byte ';' jne .firstColumn ; checking second column .secondColumn: mov al, [di] inc di cmp al, byte 'B' je .skipALine cmp al, byte 'b' je .skipALine cmp al, byte 'C' je .skipALine cmp al, byte 'c' je .skipALine cmp al, byte ';' jne .secondColumn jmp .addNumber ; Adding number because line corresponds to filter. .addNumber: call procAddNumber ; If it is not the end of file, jump back to main loop .skipALine: cmp [readTheLastLine], byte 0 je .untilEndOfFile ; Writing to file (number, how many good lines) ; **I cant do this part** mov bx, [writingDescriptor] mov cx, 2h mov dx, lineCount mov ah, 40h int 21h ; Closing Files .end: mov bx, [writingDescriptor] call procFClose .writingError: mov bx, [readingDescriptor] call procFClose exit %include 'yasmlib.asm' ; void procReadLine() ; Read line to buffer 'line' procReadLine: push ax push bx push cx push si mov bx, [readingDescriptor] mov si, 0 .loop: call procFGetChar ; End if the end of file or error cmp ax, 0 je .endOfFile jc .endOfFile ; Putting symbol to buffer mov [line+si], cl inc si ; Check if there is \n? cmp cl, 0x0A je .endOfLine jmp .loop .endOfFile: mov [readTheLastLine], byte 1 .endOfLine: mov [line+si], byte '$' mov [lineLength], si pop si pop cx pop bx pop ax ret ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; procAddNumber: push si push ax push bx push cx push dx ;lineCount++ mov ax, [lineCount] inc ax mov [lineCount], ax pop dx pop cx pop bx pop ax pop si ret section .data readingFile: db 'input.dat', 00 readingDescriptor: dw 0000 writingFile: times 128 db 00 writingDescriptor: dw 0000 readTheLastLine: db 00 line: db 64 times 66 db '$' lineLength: dw 0000 lineCount: dw 0000 </code></pre> <p><strong>GitHub link to macroses:</strong> <a href="https://github.com/Kurbamit/YASM/tree/main" rel="nofollow noreferrer">yasmlib.asm/yasmmac.inc</a></p> <p>Any help would be appreciated.</p>
[ { "answer_id": 74401464, "author": "flyingfox", "author_id": 3176419, "author_profile": "https://Stackoverflow.com/users/3176419", "pm_score": 3, "selected": true, "text": "let result = data.map(d =>{\n let stu = students.find(i => d.entity.studentID.includes(i.student_id))\n return {...stu,item:{id:d.id,status:d.status}}\n})\nconsole.log(result)\n" }, { "answer_id": 74401661, "author": "Harshil Chudasama", "author_id": 14914810, "author_profile": "https://Stackoverflow.com/users/14914810", "pm_score": 0, "selected": false, "text": "let newStudent = [];\ndata.map((data) => {\n const studentId = data['entity']['studentID'];\n function sts() { return data.status};\n students.map((student) => {\n const std_id = student.student_id;\n if (std_id == studentId) {\n newStudent.push({\n student_id: std_id,\n fname: student.fname,\n lname: student.lname,\n school: student.school,\n id: newStudent.length + 1,\n status: sts()\n });\n }\n })\n})\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401317", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12652243/" ]
74,401,325
<p>if I may, could you please help me get this sorted out? I created a circle using HTML and CSS, and inside the circle, I added text. I have other texts that need to be placed on the right side of the circle. Right now, the texts are on the right side but they are like right justified. There's too much gap. I was hoping the texts would be floating to the right side of the circle.</p> <p>Please check my codes:</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>.badge { height: 70px; width: 70px; display: table-cell; text-align: center; vertical-align: middle; border-radius: 50%; background: #286aba; color: #ffffff; font-family: Poppins, Constantia, "Lucida Bright", "DejaVu Serif", Georgia, "serif" }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div&gt; &lt;span class="badge"&gt;Step 1&lt;/span&gt;&lt;span style="position: absolute; right : 0px; top: 0px; text-align: left"&gt;The text should be on the right side of the blue circle with less gap.&lt;/span&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <p>Please check this screenshot, <a href="https://prnt.sc/gwQxXPACawjO" rel="nofollow noreferrer">https://prnt.sc/gwQxXPACawjO</a></p> <p>Thanks a lot.</p>
[ { "answer_id": 74401464, "author": "flyingfox", "author_id": 3176419, "author_profile": "https://Stackoverflow.com/users/3176419", "pm_score": 3, "selected": true, "text": "let result = data.map(d =>{\n let stu = students.find(i => d.entity.studentID.includes(i.student_id))\n return {...stu,item:{id:d.id,status:d.status}}\n})\nconsole.log(result)\n" }, { "answer_id": 74401661, "author": "Harshil Chudasama", "author_id": 14914810, "author_profile": "https://Stackoverflow.com/users/14914810", "pm_score": 0, "selected": false, "text": "let newStudent = [];\ndata.map((data) => {\n const studentId = data['entity']['studentID'];\n function sts() { return data.status};\n students.map((student) => {\n const std_id = student.student_id;\n if (std_id == studentId) {\n newStudent.push({\n student_id: std_id,\n fname: student.fname,\n lname: student.lname,\n school: student.school,\n id: newStudent.length + 1,\n status: sts()\n });\n }\n })\n})\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401325", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7270651/" ]
74,401,357
<p>I am a bit puzzled by separating columns using the separate function in tidyr:</p> <p>My data frame looks like this</p> <pre class="lang-r prettyprint-override"><code>library(tidyverse) df=tibble(col1 = c(&quot;2397_A_run379_CTTGTACT_S119_L004_R1_001&quot;, &quot;3779_A_run535_TTATAGCC_S91_L003_R1_001&quot;, &quot;4958_BV_run685_GCGTACGT_S89_L005_R1_001&quot;)) df #&gt; # A tibble: 3 × 1 #&gt; col1 #&gt; &lt;chr&gt; #&gt; 1 2397_A_run379_CTTGTACT_S119_L004_R1_001 #&gt; 2 3779_A_run535_TTATAGCC_S91_L003_R1_001 #&gt; 3 4958_BV_run685_GCGTACGT_S89_L005_R1_001 </code></pre> <p><sup>Created on 2022-11-11 with <a href="https://reprex.tidyverse.org" rel="nofollow noreferrer">reprex v2.0.2</a></sup></p> <p>I want to create three dataframes where I separate everything based on the first &quot;_&quot;, then based on the second &quot;_&quot; and then by the third &quot;_&quot;.</p> <p>I want something like this:</p> <pre><code>&gt; df1 col1 col2 2397 A_run379_CTTGTACT_S119_L004_R1_001 3779 A_run535_TTATAGCC_S91_L003_R1_001 4958 BV_run685_GCGTACGT_S89_L005_R1_001 </code></pre> <pre><code>&gt; df2 col1 col2 2397_A run379_CTTGTACT_S119_L004_R1_001 3779_A run535_TTATAGCC_S91_L003_R1_001 4958_BV run685_GCGTACGT_S89_L005_R1_001 </code></pre> <pre><code>&gt; df3 col1 col2 2397_A_run379 CTTGTACT_S119_L004_R1_001 3779_A_run535 TTATAGCC_S91_L003_R1_001 4958_BV_run685 GCGTACGT_S89_L005_R1_001 </code></pre> <p>Any help or guidance are appreciated.</p>
[ { "answer_id": 74401497, "author": "stefan", "author_id": 12993861, "author_profile": "https://Stackoverflow.com/users/12993861", "pm_score": 2, "selected": true, "text": "tidyr::extract" }, { "answer_id": 74401599, "author": "zx8754", "author_id": 680068, "author_profile": "https://Stackoverflow.com/users/680068", "pm_score": 3, "selected": false, "text": "\"_\"" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401357", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7179299/" ]
74,401,366
<p>I want to select columns from a dataframe,</p> <p>however, I want to get the names and aliases from a config file and keep it variable. The config.json file give me a dict like</p> <pre><code>conf &quot;data&quot;: { &quot;a&quot;:&quot;a&quot;, &quot;b&quot;:&quot;great&quot;, &quot;c&quot;:&quot;example&quot; } </code></pre> <p>Now, I can select my columns like this:</p> <pre><code>from pyspark import functions as F df= df.select ( F.col(&quot;a&quot;).alias(&quot;a&quot;), F.col(&quot;b&quot;).alias(&quot;great&quot;), F.col(&quot;c&quot;).alias(&quot;example) ) </code></pre> <p>But I would rather do it in a loop. like</p> <pre><code> For all data.items(), do df=df.select(F.col(item[0]).alias(item[1])) </code></pre> <p>But I cannot wrap my head around it(maybe I should go to bed earlier) Thanks</p>
[ { "answer_id": 74401497, "author": "stefan", "author_id": 12993861, "author_profile": "https://Stackoverflow.com/users/12993861", "pm_score": 2, "selected": true, "text": "tidyr::extract" }, { "answer_id": 74401599, "author": "zx8754", "author_id": 680068, "author_profile": "https://Stackoverflow.com/users/680068", "pm_score": 3, "selected": false, "text": "\"_\"" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401366", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6510273/" ]
74,401,380
<p>I am sending an HTTP request using XMLHttpRequest (<a href="https://developer.mozilla.org/es/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest" rel="nofollow noreferrer">https://developer.mozilla.org/es/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest</a>).</p> <p>The code is as follows:</p> <pre><code>var xhr = new XMLHttpRequest(); xhr.addEventListener(&quot;readystatechange&quot;, function() { if(this.readyState === 4) { if(this.responseText.length &gt; 0) { console.log(typeof this.responseText); //&quot;string&quot; var textToken = this.responseText; var objToken = JSON.parse(textToken); if(typeof objToken === 'object') { --------- } else if (typeof objToken === 'string') { --------- } } else {---} } }); </code></pre> <p>The response of the HTTP request, this.responseText will always be a string. But it can come in two forms:</p> <p>1: <code>&quot;{&quot;prop&quot;: &quot;value&quot;, &quot;prop&quot;: &quot;value&quot;}&quot;</code></p> <p>2: <code>&quot;akduchkqlpouelqw&quot;</code></p> <p>Currently I get the string converted to an object by JSON.parse(); but there is a possibility that this.responseText is a string like case number 2 above.</p> <p>I would like to have the possibility that if this.responseText is option two, it would go into <code>(typeof objToken === 'string')</code>.</p> <p>I have tried this manually by giving a value to <code>var textToken === 'akduchkqlpouelqw'</code>. In that case, if I change <code>(typeof objToken === 'string')</code> to <code>(typeof textToken === 'string')</code>, it's work.</p> <p>But I have not been able to do it dynamically.</p>
[ { "answer_id": 74401477, "author": "David", "author_id": 4601803, "author_profile": "https://Stackoverflow.com/users/4601803", "pm_score": 2, "selected": true, "text": "const textToken = 'string';\ntry{\n const j = JSON.parse(textToken);\n} catch {\n console.log('Hi! im a string')\n}" }, { "answer_id": 74402120, "author": "Build For Dev", "author_id": 20477335, "author_profile": "https://Stackoverflow.com/users/20477335", "pm_score": 0, "selected": false, "text": "if(typeof textToken === 'object') {\n var objToken = JSON.parse(textToken);\n} else {\n console.log('this is string');\n}\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401380", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19672488/" ]
74,401,389
<p>I'm finally trying to learn templates and I created a template function that will return an <code>std::vector</code> with a generic type.</p> <p>When compiling I get an error:</p> <blockquote> <p>error: no matching function for call to ‘std::vector::push_back(std::string&amp;)’</p> </blockquote> <p>Is there a way to support <code>std::string</code> or a comparable type in the template vector in addition to the primitive types?</p> <p>Here is a 'Minimal, Reproducible Example' that doesn't compile due to this error (this is obviously not my code, it just illustrates the error):</p> <pre><code>#include &lt;iostream&gt; #include &lt;vector&gt; enum types{ TINT = 0, TDOUBLE = 1, TSTRING = 2, }; class TestClass{ public: template&lt;typename T&gt; std::vector&lt;T&gt; getData(types type) { std::vector&lt;T&gt; entries; int i_value; double d_value; std::string st_value; switch (type) { case types::TINT: i_value = 1; entries.push_back(i_value); break; case types::TDOUBLE: d_value = 0.1; entries.push_back(d_value); break; case types::TSTRING: st_value = &quot;foo&quot;; entries.push_back(st_value); //Pushing an std::string causes a compile error break; default: break; } return entries; } }; int main() { TestClass bar; std::vector&lt;int&gt; test = bar.getData&lt;int&gt;(types::TINT); return 0; } </code></pre> <p>Commenting the line <code>entries.push_back(st_value);</code> makes everything compile again.</p>
[ { "answer_id": 74401507, "author": "VLL", "author_id": 2527795, "author_profile": "https://Stackoverflow.com/users/2527795", "pm_score": 3, "selected": true, "text": "std::is_same" }, { "answer_id": 74401509, "author": "Fred", "author_id": 7216302, "author_profile": "https://Stackoverflow.com/users/7216302", "pm_score": 2, "selected": false, "text": "std::vector<int> test = bar.getData<int>(types::TINT); " } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401389", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4296075/" ]
74,401,399
<p>I just wonder if it's possible to print the duplicate values from a dictionary.</p> <p>For exemple I have this dictonary:</p> <pre><code>responses={ 'greet':'Hello! How can I help you?', 'types':'Our coffee types are: light roasted, medium roasted, medium dark roasted, dark roasted.', 'light':'Coffee Bros Paraideli Cup Of Excellence, Lifeboost Coffee, Driftaway Coffee Colombia Antioquia And Burundi Kayanza, Peets Coffee Costa Rica Aurora, Fresh Roasted Coffee Ethiopian Sidamo Guji Coffee.', 'medium':'Volcanica Coffee Kenya AA, Coffee Bros Decaf, Purity Coffee Flow, Out Of The Grey Costa Rica La Minita, Kicking Horse Three Sisters.', 'dark':'Koa Coffee Estate, Atlas Coffee Club, Lifeboost Coffee Organic Dark Roast, Peets House Blend, Coffee Bros Dark Roast, Death Wish Coffee, Kicking Horse Coffee Grizzly Claw.', 'fruit':'Frutis notes coffee: Coffee Bros Paraideli Cup Of Excellence, Peets Coffee Costa Rica Aurora, Fresh Roasted Coffee Ethiopian Sidamo Guji Coffee, Volcanica Coffee Kenya AA, Peets House Blend.', 'vanilla':'Vanilla notes coffee: Lifeboost Coffee, Driftaway Coffee Colombia Antioquia And Burundi Kayanza.', 'chocolate':'Chocolate notes coffee: Coffee Bros Decaf, Purity Coffee Flow, Out Of The Grey Costa Rica La Minita, Lifeboost Coffee Organic Dark Roast, Coffee Bros Dark Roast, Death Wish Coffee, Kicking Horse Coffee Grizzly Claw.', 'timings':'We are open from 9AM to 5PM, Monday to Friday. We are closed on weekends and public holidays.', 'fallback':'I dont quite understand. Could you repeat that?', } </code></pre> <p>So if I pick two different keys like:</p> <pre><code>'chocolate':'Chocolate notes coffee: Coffee Bros Decaf, Purity Coffee Flow, Out Of The Grey Costa Rica La Minita, Lifeboost Coffee Organic Dark Roast, Coffee Bros Dark Roast, Death Wish Coffee, Kicking Horse Coffee Grizzly Claw.', 'medium':'Volcanica Coffee Kenya AA, Coffee Bros Decaf, Purity Coffee Flow, Out Of The Grey Costa Rica La Minita, Kicking Horse Three Sisters.', </code></pre> <p>They have a common coffee name like:</p> <blockquote> <p>Purity Coffee Flow, Out Of The Grey Costa Rica La Minita</p> </blockquote> <p>So if I insert the keys for it like: <strong>chocolate</strong>, <strong>medium</strong>.</p> <p>The program need to print only those two duplicates:</p> <blockquote> <p>Purity Coffee Flow, Out Of The Grey Costa Rica La Minita</p> </blockquote> <p>It's possible to print just those 2 words in console which are duplicates in there?</p> <p>The only thing that I manage to work is to print the duplicates values if values are completly the same, but that's not my use case.</p>
[ { "answer_id": 74401580, "author": "Fra93", "author_id": 4952549, "author_profile": "https://Stackoverflow.com/users/4952549", "pm_score": 3, "selected": true, "text": "import argparse\nparser = argparse.ArgumentParser()\nparser.add_argument(\"key1\",)\nparser.add_argument(\"key2\")\n\ncommand = input() #Input something like \"chocolate medium\"\nargs = parser.parse_args(command.split(\" \"))\n\n\n#If user has input only one key, print values from that key\nif args.key2 == None:\n print(responses[args.key1])\nelse\n # Then use the find common\n print(find_common_values(responses,args.key1,args.key2))\n\n\n" }, { "answer_id": 74401586, "author": "bn_ln", "author_id": 10535824, "author_profile": "https://Stackoverflow.com/users/10535824", "pm_score": 2, "selected": false, "text": "import re\npattern = r'[\\w\\s]+'\npartials = set()\nfor value in responses.values():\n for partial in re.findall(pattern,value):\n if partial in partials:\n print(partial, partials)\n else:\n partials.add(partial)\n" }, { "answer_id": 74401596, "author": "DSD", "author_id": 20470583, "author_profile": "https://Stackoverflow.com/users/20470583", "pm_score": 2, "selected": false, "text": "a = 'Chocolate notes coffee: Coffee Bros Decaf, Purity Coffee Flow, Out Of The Grey Costa Rica La Minita, Lifeboost Coffee Organic Dark Roast, Coffee Bros Dark Roast, Death Wish Coffee, Kicking Horse Coffee Grizzly Claw.'\n\nb = 'Volcanica Coffee Kenya AA, Coffee Bros Decaf, Purity Coffee Flow, Out Of The Grey Costa Rica La Minita, Kicking Horse Three Sisters.'\n\na_list = a.split(\",\")\nb_list = b.split(\",\")\n\na_set = set(a_list)\nb_set = set(b_list)\n\n\nprint(a_set.intersection(b_set))\n" }, { "answer_id": 74401715, "author": "Dan Nagle", "author_id": 2202018, "author_profile": "https://Stackoverflow.com/users/2202018", "pm_score": 2, "selected": false, "text": "import re\n\nresponses={\n 'greet':'Hello! How can I help you?',\n 'types':'Our coffee types are: light roasted, medium roasted, medium dark roasted, dark roasted.',\n 'light':'Coffee Bros Paraideli Cup Of Excellence, Lifeboost Coffee, Driftaway Coffee Colombia Antioquia And Burundi Kayanza, Peets Coffee Costa Rica Aurora, Fresh Roasted Coffee Ethiopian Sidamo Guji Coffee.',\n 'medium':'Volcanica Coffee Kenya AA, Coffee Bros Decaf, Purity Coffee Flow, Out Of The Grey Costa Rica La Minita, Kicking Horse Three Sisters.',\n 'dark':'Koa Coffee Estate, Atlas Coffee Club, Lifeboost Coffee Organic Dark Roast, Peets House Blend, Coffee Bros Dark Roast, Death Wish Coffee, Kicking Horse Coffee Grizzly Claw.',\n 'fruit':'Frutis notes coffee: Coffee Bros Paraideli Cup Of Excellence, Peets Coffee Costa Rica Aurora, Fresh Roasted Coffee Ethiopian Sidamo Guji Coffee, Volcanica Coffee Kenya AA, Peets House Blend.',\n 'vanilla':'Vanilla notes coffee: Lifeboost Coffee, Driftaway Coffee Colombia Antioquia And Burundi Kayanza.',\n 'chocolate':'Chocolate notes coffee: Coffee Bros Decaf, Purity Coffee Flow, Out Of The Grey Costa Rica La Minita, Lifeboost Coffee Organic Dark Roast, Coffee Bros Dark Roast, Death Wish Coffee, Kicking Horse Coffee Grizzly Claw.',\n 'timings':'We are open from 9AM to 5PM, Monday to Friday. We are closed on weekends and public holidays.',\n 'fallback':'I dont quite understand. Could you repeat that?',\n}\n\ndef split_string(str):\n return [s.strip() for s in re.split(r':|,|\\.|!|\\?|;', str) if len(s) > 0]\n\ndef common_strings(str_a, str_b):\n set_a = set(split_string(str_a))\n set_b = set(split_string(str_b))\n return list(set_a.intersection(set_b))\n\ncommon_strings(responses['chocolate'], responses['medium'])\n\n# ['Purity Coffee Flow',\n# 'Out Of The Grey Costa Rica La Minita',\n# 'Coffee Bros Decaf']\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401399", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11236416/" ]
74,401,411
<p>I'm trying to create logic but return #N/A as mentioned in the title, what did I do wrong?</p> <p><code>=IF(AND(I4=B4,I4=B5,I4=B6),CONCATENATE(B4,&quot;;&quot;,B5,&quot;;&quot;,D6),IF(AND(I4=B4,I4=B5),CONCATENATE(D4,&quot;;&quot;,D5)),IF(I4=B4,D4)), but got error. </code></p>
[ { "answer_id": 74401727, "author": "player0", "author_id": 5632629, "author_profile": "https://Stackoverflow.com/users/5632629", "pm_score": 0, "selected": false, "text": "=IF(AND(I4=B4,I4=B5,I4=B6), B4&\";\"&B5&\";\"&D6, \n IF(AND(I4=B4,I4=B5), D4&\";\"&D5, IF(I4=B4, D4, )))\n" }, { "answer_id": 74401882, "author": "Martín", "author_id": 20363318, "author_profile": "https://Stackoverflow.com/users/20363318", "pm_score": 2, "selected": true, "text": "=IF(AND(I4=B4,I4=B5,I4=B6),CONCATENATE(B4,\";\",B5,\";\",D6),IF(AND(I4=B4,I4=B5),CONCATENATE(D4,\";\",D5),IF(I4=B4,D4,\"I4 and B4 are different\")))" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401411", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6050935/" ]
74,401,426
<p>I don't know is there any difference between <strong>CoroutineScope(Dispatchers.Main).launch</strong> and <strong>runOnUiThread</strong>, I think both will run on Main thread.</p> <p>but still confusion is any difference there.?</p> <p>Thanks.</p>
[ { "answer_id": 74405780, "author": "Steyrix", "author_id": 7221362, "author_profile": "https://Stackoverflow.com/users/7221362", "pm_score": 3, "selected": true, "text": "runOnUiThread" }, { "answer_id": 74407508, "author": "cactustictacs", "author_id": 13598222, "author_profile": "https://Stackoverflow.com/users/13598222", "pm_score": 1, "selected": false, "text": "runOnUiThread" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401426", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14682570/" ]
74,401,434
<p>What is the difference between this</p> <pre><code>const authController = require(&quot;../controller/authController&quot;); </code></pre> <p>and this</p> <pre><code>const { authController } = require(&quot;../controller/authController&quot;); </code></pre> <p>my code doesnt work when i call a function like authController.createUser in second one and i wondered thats why?</p> <p>Thanks for helps.</p>
[ { "answer_id": 74405780, "author": "Steyrix", "author_id": 7221362, "author_profile": "https://Stackoverflow.com/users/7221362", "pm_score": 3, "selected": true, "text": "runOnUiThread" }, { "answer_id": 74407508, "author": "cactustictacs", "author_id": 13598222, "author_profile": "https://Stackoverflow.com/users/13598222", "pm_score": 1, "selected": false, "text": "runOnUiThread" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401434", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18609846/" ]
74,401,454
<p>I am practicing with C # Lists in Unity and I have encountered a problem. My test script, instantiates 5 prefabs which are added in a gameobject list. I then wrote a code that generates a random int and from that number moves the prefab instantiated with that index (indexof). Everything works correctly, but the method that moves and deletes the prefab is repeated for all the gameobjects in the scene with an index higher than the one chosen. I enclose the two scripts to better explain the problem. (I would need the unlist method to be done only once.</p> <p>how can i solve this problem and remove one item from the list at a time? (one each time the button is pressed, not all as it is now. Thanks)</p> <p>script:</p> <ul> <li>NpcController: Added in each instantiated prefab</li> <li>ListCOntroller: added in the scene.</li> </ul> <hr /> <pre><code> public class ListCOntroller : MonoBehaviour { public GameObject cubePrefab; private GameObject cubeInstance; public static List&lt;GameObject&gt; cubeList = new List&lt;GameObject&gt; (); public TextMeshProUGUI checkText; public static event Action chooseNpc; public static int randNpcValue; int rand; private void Start() { for(int i =0; i &lt; 5; i++) { cubeInstance = Instantiate(cubePrefab, new Vector3(i, -2, 0), Quaternion.identity); cubeList.Add(cubeInstance); } } public void CheckListText() { checkText.text = &quot;Npc in list: &quot; + cubeList.Count.ToString(); } public static void SelectRandomCube() { randNpcValue = Random.Range(0, cubeList.Count); chooseNpc?.Invoke(); } } </code></pre> <hr /> <p>public class NpcController : MonoBehaviour {</p> <pre><code>void Start() { ListCOntroller.chooseNpc += NpcEvent; } private void NpcEvent() { if (ListCOntroller.cubeList.IndexOf(gameObject) == ListCOntroller.randNpcValue) { transform.localPosition = new Vector3(transform.position.x, 2, 0); DeleteFromList(); } } private void DeleteFromList() { ListCOntroller.cubeList.RemoveAt(ListCOntroller.randNpcValue); Debug.Log($&quot;Delete from list: {ListCOntroller.randNpcValue}&quot;); } </code></pre> <p>}</p> <hr /> <p><strong>the int random number generated in the attached images is: 2</strong></p> <p><a href="https://i.stack.imgur.com/VgmXD.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VgmXD.jpg" alt="enter image description here" /></a></p> <p><a href="https://i.stack.imgur.com/phNuc.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/phNuc.jpg" alt="button pressed once." /></a></p>
[ { "answer_id": 74401790, "author": "shingo", "author_id": 6196568, "author_profile": "https://Stackoverflow.com/users/6196568", "pm_score": 1, "selected": false, "text": "NPC0, NPC1, NPC2" }, { "answer_id": 74403579, "author": "derHugo", "author_id": 7111561, "author_profile": "https://Stackoverflow.com/users/7111561", "pm_score": 1, "selected": true, "text": "public class ListCOntroller : MonoBehaviour\n{\n // Singleton instance\n private static ListCOntroller _instance;\n // Read-only getter\n public static ListCOntroller Instance => _instance;\n\n // pass in the target object reference instead of doing things index based\n public event Action<GameObject> chooseNpc;\n\n public GameObject cubePrefab;\n\n // THIS is the list controller -> nobody else should be able to manipulate this list\n private readonly List<GameObject> cubeList = new ();\n\n public TextMeshProUGUI checkText;\n \n private void Awake()\n {\n if(_instance && _instance != this)\n {\n Destroy(this);\n return;\n }\n\n _instance = this;\n }\n \n private void Start()\n {\n for(int i =0; i < 5; i++)\n {\n cubeInstance = Instantiate(cubePrefab, new Vector3(i, -2, 0), Quaternion.identity);\n cubeList.Add(cubeInstance);\n }\n }\n \n public static void SelectRandomCube()\n {\n if(cubeList.Count == 0)\n {\n Debug.LogWarning(\"Trying to pick item from empty list\");\n return;\n }\n\n var randomIndex = Random.Range(0, cubeList.Count);\n var randomItem = cubeList[randomIndex];\n\n // remove from the list yourself instead of relying on others to work correctly\n cubeList.RemoveAt(randomIndex);\n\n // pass along the target object\n chooseNpc?.Invoke(randomItem);\n }\n}\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401454", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12761431/" ]
74,401,478
<p>I'm trying to split a string by curly brackets but ignore nested brackets. E.g given the following:</p> <pre class="lang-none prettyprint-override"><code>hello {world} this is some text. {split me {but not me} thanks} heaps! </code></pre> <p>split into:</p> <pre class="lang-js prettyprint-override"><code>[ 'hello ', '{world}', 'this is some text. ', '{split me {but not me} thanks}', ' heaps!' ] </code></pre> <p>Any help would be appreciated!</p> <p>This is what I have so far:</p> <pre><code>const result = []; let current = ''; let stack = 0; for (let i = 0; i &lt; str.length; i++) { var ch = str[i]; current += ch; if (ch.trim() === '') { continue; } if (ch === '{') { stack++; } else if (ch === '}') { stack--; } if (ch === '}' &amp;&amp; stack &lt;= 0) { result.push(current); current = ''; } } result.push(current); </code></pre>
[ { "answer_id": 74401750, "author": "pilchard", "author_id": 13762301, "author_profile": "https://Stackoverflow.com/users/13762301", "pm_score": 2, "selected": true, "text": "const str = 'hello {world} this is some text. {split me {but not me} thanks} heaps!';\n\nconst result = [];\nlet current = '';\nlet stack = 0;\n\nfor (let i = 0; i < str.length; i++) {\n if (str[i] === '{') {\n if (!stack) {\n result.push(current);\n current = ''\n }\n stack++;\n }\n\n current += str[i];\n\n if (str[i] === '}') {\n stack--;\n if (!stack) {\n result.push(current);\n current = ''\n }\n }\n}\n\nif (current.length) {\n result.push(current);\n}\n\nconsole.log(result)" }, { "answer_id": 74401765, "author": "Cerbrus", "author_id": 1835379, "author_profile": "https://Stackoverflow.com/users/1835379", "pm_score": 0, "selected": false, "text": "const str = 'hello {world} this is some text. {split me {but not me} thanks} heaps!';\nconst split = str\n .replace(/\\{([^}]+)/g, '|{$1') // Mark the first `{` of a section that does not contain a `}`.\n .replace(/([^{]+)\\}/g, '$1}|') // Mark the last `}` of a section that does not contain a `{`.\n .split('|') // Split the string on the marks.\n\nconsole.log(split);" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401478", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2052581/" ]
74,401,487
<p><code>value_counts</code> can't count values in list.</p> <p>Hi, Some of the <code>columns</code> in my <code>dataframe</code> have a <code>list</code>.</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>X</th> <th>Y</th> </tr> </thead> <tbody> <tr> <td>101</td> <td><code>['A']</code></td> </tr> <tr> <td>200</td> <td><code>['A','O']</code></td> </tr> <tr> <td>32</td> <td><code>['B']</code></td> </tr> <tr> <td>41</td> <td><code>['A','AB,'O']</code></td> </tr> <tr> <td>202</td> <td><code>['A']</code></td> </tr> </tbody> </table> </div> <p>When i use <code>value_counts()</code> ; i get this result:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td><code>['A']</code></td> <td>2</td> </tr> <tr> <td><code>['A' , 'O']</code></td> <td>1</td> </tr> <tr> <td><code>['B']</code></td> <td>1</td> </tr> <tr> <td><code>['A','AB','O']</code></td> <td>1</td> </tr> </tbody> </table> </div> <p>But i want this results:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td><code>['A']</code></td> <td>4</td> </tr> <tr> <td><code>['O']</code></td> <td>2</td> </tr> <tr> <td><code>['B']</code></td> <td>1</td> </tr> <tr> <td><code>['AB']</code></td> <td>1</td> </tr> </tbody> </table> </div> <p>Is there any <code>code</code> for it?</p>
[ { "answer_id": 74401750, "author": "pilchard", "author_id": 13762301, "author_profile": "https://Stackoverflow.com/users/13762301", "pm_score": 2, "selected": true, "text": "const str = 'hello {world} this is some text. {split me {but not me} thanks} heaps!';\n\nconst result = [];\nlet current = '';\nlet stack = 0;\n\nfor (let i = 0; i < str.length; i++) {\n if (str[i] === '{') {\n if (!stack) {\n result.push(current);\n current = ''\n }\n stack++;\n }\n\n current += str[i];\n\n if (str[i] === '}') {\n stack--;\n if (!stack) {\n result.push(current);\n current = ''\n }\n }\n}\n\nif (current.length) {\n result.push(current);\n}\n\nconsole.log(result)" }, { "answer_id": 74401765, "author": "Cerbrus", "author_id": 1835379, "author_profile": "https://Stackoverflow.com/users/1835379", "pm_score": 0, "selected": false, "text": "const str = 'hello {world} this is some text. {split me {but not me} thanks} heaps!';\nconst split = str\n .replace(/\\{([^}]+)/g, '|{$1') // Mark the first `{` of a section that does not contain a `}`.\n .replace(/([^{]+)\\}/g, '$1}|') // Mark the last `}` of a section that does not contain a `{`.\n .split('|') // Split the string on the marks.\n\nconsole.log(split);" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401487", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9903557/" ]
74,401,499
<p>I am writing a driver model using C++ and Python to compare the performance. The simulation gives data like width, position, speed, etc. and the driver model does some calculations to decide if it needs to brake or not. Both models have the same variables and calculations, but after looping over 500 times first divergence surface and in the end, result in different brake responses. I am aware that floating point error is a thing, but shouldn't it be the same for both languages? I checked C++ and Python if they have IEEE 754 and it seems to be the case. I will attach my check at the end of the question.</p> <p>Is there something I don't know about float calculations or I do sth wrong in my codes?</p> <p>What did I expect: That I get the same response for both driver models.</p> <p>C++ Code:</p> <blockquote> </blockquote> <pre><code>void DM::runAccumulator() { // storing values from previous run double prevVTheta = vTheta; double prevVActivation = vActivation; // shorter handle for convinience and to stay true to given Modell double egoSpeed = data.egoSpeed; double egoAcc = data.egoAcc; double egoLength = data.egoLength; double targetSpeed = data.targetSpeed; double targetAcc = data.targetAcc; double targetWidth = data.targetWidth; double targetLength = data.targetLength; // calculate positional data double targetPosRear = data.targetPosX - targetLength/2.0; double egoPosFront = data.egoPosX + egoLength/2.0; double distEgotoTarget = targetPosRear - egoPosFront; // optical size of target vehicle vTheta = 2.0 * std::atan(targetWidth / (2.0 * prevDistEgoToTarget)); prevDistEgoToTarget = distEgotoTarget; vThetaDot = (vTheta - prevVTheta)/timestep; vp = vThetaDot/vTheta; if (log = true) { this -&gt; file &lt;&lt; std::fixed &lt;&lt; std::setprecision(2) &lt;&lt; data.timestamp &lt;&lt; ',' &lt;&lt; std::setprecision(6) &lt;&lt; targetPosRear &lt;&lt; ',' &lt;&lt; egoPosFront &lt;&lt; ',' &lt;&lt; prevDistEgoToTarget &lt;&lt; ',' &lt;&lt; vTheta &lt;&lt; ',' &lt;&lt; vThetaDot &lt;&lt; ',' &lt;&lt; vp &lt;&lt; '\n'; } </code></pre> <p>Python:</p> <blockquote> </blockquote> <pre><code>def runAccumulator(self): #storing values from previous run prevVTheta = self.vTheta prevVActivation = self.vActivation #shorter handle for convinience and to stay true to given Modell egoSpeed = self.data.egoSpeed egoAcc = self.data.egoAcc egoLength = self.data.egoLength targetSpeed = self.data.targetSpeed targetAcc = self.data.targetAcc targetWidth = self.data.targetWidth targetLength = self.data.targetLength # calculate positional data targetPosRear = self.data.targetPosX - targetLength/2.0 egoPosFront = self.data.egoPosX + egoLength/2.0 distEgotoTarget = targetPosRear - egoPosFront # optical size target vehicle and looming self.vTheta = 2.0*arctan(targetWidth/(2.0*self.prevDistEgoToTarget)) self.prevDistEgoToTarget = distEgotoTarget self.vThetaDot = (self.vTheta - prevVTheta)/self.timestep self.vp = self.vThetaDot/self.vTheta # Driver Model update self.vEpsilon = self.vp - self.vpp activationChange = (self.accuK * self.vEpsilon - self.accuM - self.accuC * prevVActivation) * self.timestep self.vActivation = max(0.0, prevVActivation-activationChange) # log some parameters if self.log == True: logString = str(self.data.timestamp) + ',' logString += str(targetPosRear) + ',' #'{:.7f}'.format(targetPosRear) + ',' logString += str(egoPosFront) + ',' #'{:.7f}'.format(egoPosFront) + ',' logString += str(self.prevDistEgoToTarget) + ',' #'{:.7f}'.format(targetPosRear - egoPosFront) + ','; logString += str(self.vTheta) + ',' #'{:.7f}'.format(self.vTheta) + ',' logString +=str(self.vThetaDot) + ',' # '{:.7f}'.format(self.vThetaDot) + ',' logString += str(self.vp) + '\n' #'{:.7f}'.format(self.vp) + '\n' self.file.write(logString) </code></pre> <p>C++ IEEE 754 Check:</p> <blockquote> </blockquote> <pre><code>#include &lt;cfloat&gt; #include &lt;iomanip&gt; #include &lt;iostream&gt; int main() { int w = 16; std::cout &lt;&lt; std::left; // std::cout &lt;&lt; std::setprecision(53); # define COUT(x) std::cout &lt;&lt; std::setw(w) &lt;&lt; #x &lt;&lt; &quot; = &quot; &lt;&lt; x &lt;&lt; '\n' COUT( FLT_RADIX ); COUT( DECIMAL_DIG ); COUT( FLT_DECIMAL_DIG ); COUT( DBL_DECIMAL_DIG ); COUT( LDBL_DECIMAL_DIG ); COUT( FLT_MIN ); COUT( DBL_MIN ); COUT( LDBL_MIN ); COUT( FLT_TRUE_MIN ); COUT( DBL_TRUE_MIN ); COUT( LDBL_TRUE_MIN ); COUT( FLT_MAX ); COUT( DBL_MAX ); COUT( LDBL_MAX ); COUT( FLT_EPSILON ); COUT( DBL_EPSILON ); COUT( LDBL_EPSILON ); COUT( FLT_DIG ); COUT( DBL_DIG ); COUT( LDBL_DIG ); COUT( FLT_MANT_DIG ); COUT( DBL_MANT_DIG ); COUT( LDBL_MANT_DIG ); COUT( FLT_MIN_EXP ); COUT( DBL_MIN_EXP ); COUT( LDBL_MIN_EXP ); COUT( FLT_MIN_10_EXP ); COUT( DBL_MIN_10_EXP ); COUT( LDBL_MIN_10_EXP ); COUT( FLT_MAX_EXP ); COUT( DBL_MAX_EXP ); COUT( LDBL_MAX_EXP ); COUT( FLT_MAX_10_EXP ); COUT( DBL_MAX_10_EXP ); COUT( LDBL_MAX_10_EXP ); COUT( FLT_ROUNDS ); COUT( FLT_EVAL_METHOD ); COUT( FLT_HAS_SUBNORM ); COUT( DBL_HAS_SUBNORM ); COUT( LDBL_HAS_SUBNORM ); } </code></pre> <p>EDIT: Minimal Working examples (Removed the logging but left the parsing, since I believe it is good to have he actual data from the sim)</p> <p>It has been some time, since I tried different ways to work around this issue. Sadly, everything I tried didn't work out, so here I am finally following up with the minimal working example. There is one .csv file with the data from the simulation and a minimal version for both, C++ and Python. To clarify, I have the driver model and would like them to break at the same time. For this, vp, vTheta and vThetaDot should be roughly the same. As it is now, vp is 0.0825 in Pyhton and 0.00054 in C++...</p> <p>Python minimal working example</p> <pre><code>from numpy import nan, arctan2 from csv import DictReader class DM(): def __init__(self): self.vTheta: float = nan self.vThetaDot: float = nan self.prevDistEgoToTarget: float = nan self.timestep: float = 0.01 self.vpp: float = nan def runAccumulator(self, data): #storing values from previous run prevVTheta = self.vTheta length = 5.4 width = 2.0 # calculate positional data targetPosRear = float(data[&quot;targetPosX&quot;]) - length/2.0 # adapt arctan2 input egoPosFront = float(data[&quot;egoPosX&quot;]) + length/2.0 distEgotoTarget = targetPosRear - egoPosFront # optical size target vehicle and looming self.vTheta = 2.0*arctan2(width,2.0*self.prevDistEgoToTarget) self.vThetaDot = (self.vTheta - prevVTheta)/self.timestep self.vp = self.vThetaDot/self.vTheta self.prevDistEgoToTarget = distEgotoTarget def main(): with open(&quot;../log/sample.csv&quot;, 'r') as f: dictReader = DictReader(f) listOfDict = list(dictReader) dm = DM() for i in range(700): dm.runAccumulator(listOfDict[i]) if __name__ == &quot;__main__&quot;: main() </code></pre> <p>C++ minimal working example</p> <pre><code>#include &lt;limits&gt; #include &lt;cmath&gt; #include &lt;fstream&gt; #include &lt;sstream&gt; #include &lt;iostream&gt; #include &lt;vector&gt; class DM { private: /* data */ public: DM(/* args */); ~DM(); double vTheta = std::numeric_limits&lt;double&gt;::quiet_NaN(); double vThetaDot = std::numeric_limits&lt;double&gt;::quiet_NaN(); double prevDistEgoToTarget = std::numeric_limits&lt;double&gt;::quiet_NaN(); double timestep = 0.01; double vp = std::numeric_limits&lt;double&gt;::quiet_NaN(); void runAccumulator(std::vector&lt;std::string&gt; data); std::ifstream sampleCSV; void readFileIntoString(const std::string&amp; path); }; DM::DM(/* args */) { } DM::~DM() { } void DM::runAccumulator(std::vector&lt;std::string&gt; data) { double prevVTheta = vTheta; double length = 5.4; double width = 2.0; // calculate positional data double targetPosX = stod(data[3]) - length/2.0; double egoPosX = stod(data[2]) + length/2.0; double distEgoToTarget = targetPosX - egoPosX; vTheta = 2.0* std::atan2(width,distEgoToTarget); vThetaDot = (vTheta-prevVTheta)/timestep; vp = vThetaDot/vTheta; prevDistEgoToTarget = distEgoToTarget; std::cout &lt;&lt; vp &lt;&lt; std::endl; } void DM::readFileIntoString(const std::string&amp; path) { this -&gt; sampleCSV.open(path); if (!sampleCSV.is_open()) { std::cerr &lt;&lt; &quot;Could not open the file - '&quot; &lt;&lt; path &lt;&lt; &quot;'&quot; &lt;&lt; std::endl; exit(EXIT_FAILURE); } std::string temp; getline(this-&gt;sampleCSV, temp); } std::vector&lt;std::string&gt; split (std::string s, std::string delimiter) { size_t pos_start = 0, pos_end, delim_len = delimiter.length(); std::string token; std::vector&lt;std::string&gt; res; while ((pos_end = s.find (delimiter, pos_start)) != std::string::npos) { token = s.substr (pos_start, pos_end - pos_start); pos_start = pos_end + delim_len; res.push_back(token); } res.push_back(s.substr (pos_start)); return res; } int main(int argc, char const *argv[]) { DM dm; dm.readFileIntoString(&quot;../log/sample.csv&quot;); std::string buffer; std::vector&lt;std::string&gt; linevec; for (size_t i = 0; i &lt; 700; i++) { getline(dm.sampleCSV, buffer); linevec = split(buffer, &quot;,&quot;); dm.runAccumulator(linevec); } return 0; } </code></pre> <p>CSV: <a href="https://pastebin.com/8gBm5z8q" rel="nofollow noreferrer">https://pastebin.com/8gBm5z8q</a></p>
[ { "answer_id": 74601293, "author": "MSalters", "author_id": 15416, "author_profile": "https://Stackoverflow.com/users/15416", "pm_score": 0, "selected": false, "text": "sqrt" }, { "answer_id": 74648566, "author": "joergbrech", "author_id": 12173376, "author_profile": "https://Stackoverflow.com/users/12173376", "pm_score": 1, "selected": false, "text": "targetPosX" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401499", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17129042/" ]
74,401,503
<p>I want to make some basic math stuff like Sum in Diagrams.net (old Draw.io).Is it possible ?</p> <p>Exemple : I create a new parameter on a shape, like &quot;Elec : T16&quot; and make several copy on this shape. Is it possible to have a Text which can give me the total of the shape with this parameter ?</p> <p>Best Regards.</p> <p>I search a lot in the Diagrams.net blog but anything relevent.</p>
[ { "answer_id": 74601293, "author": "MSalters", "author_id": 15416, "author_profile": "https://Stackoverflow.com/users/15416", "pm_score": 0, "selected": false, "text": "sqrt" }, { "answer_id": 74648566, "author": "joergbrech", "author_id": 12173376, "author_profile": "https://Stackoverflow.com/users/12173376", "pm_score": 1, "selected": false, "text": "targetPosX" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401503", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20477068/" ]
74,401,537
<p>I have a Pandas dataframe with the following structure:</p> <pre><code>A B C a b 1 a b 2 a b 3 c d 7 c d 8 c d 5 c d 6 c d 3 e b 4 e b 3 e b 2 e b 1 </code></pre> <p>And I will like to transform it into this:</p> <pre><code>A B C1 C2 C3 C4 C5 a b 1 2 3 NAN NAN c d 7 8 5 6 3 e b 4 3 2 1 NAN </code></pre> <p>In other words, something like groupby A and B and expand C into different columns.</p> <p>Knowing that the length of each group is different.</p> <p>C is already ordered</p> <p>Shorter groups can have NAN or NULL values (empty), it does not matter.</p>
[ { "answer_id": 74401567, "author": "jezrael", "author_id": 2901002, "author_profile": "https://Stackoverflow.com/users/2901002", "pm_score": 5, "selected": true, "text": "GroupBy.cumcount" }, { "answer_id": 74411043, "author": "G.G", "author_id": 20284103, "author_profile": "https://Stackoverflow.com/users/20284103", "pm_score": 0, "selected": false, "text": "df1.astype({'C':str}).groupby([*'AB'])\\\n .agg(','.join).C.str.split(',',expand=True)\\\n .add_prefix('C').reset_index()\n\n\n A B C0 C1 C2 C3 C4\n0 a b 1 2 3 None None\n1 c d 7 8 5 6 3\n2 e b 4 3 2 1 None\n" }, { "answer_id": 74415806, "author": "mirix", "author_id": 903051, "author_profile": "https://Stackoverflow.com/users/903051", "pm_score": 0, "selected": false, "text": "N = 3\ng = df_grouped.groupby(['A','B']).cumcount()\ndf_grouped['g1'], df_grouped['g2'] = g // N, (g % N) + 1\ndf_grouped = (df_grouped.pivot(index=['A','B','g1'], columns='g2', values='C')\n .add_prefix('C_')\n .astype('Int64')\n .droplevel(-1)\n .rename_axis(columns=None)\n .reset_index())\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401537", "https://Stackoverflow.com", "https://Stackoverflow.com/users/903051/" ]
74,401,557
<p>How can I stop a game object box collider triggering underneath a dropdown box UI element?</p> <p>When I select a dropdown list item, it also sends a click through to the game object beneath the dropdown list.</p> <p>Obviously we only want one UI element getting clicked in this case.</p> <p><a href="https://i.stack.imgur.com/m8CeA.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/m8CeA.jpg" alt="enter image description here" /></a></p>
[ { "answer_id": 74403734, "author": "Horothenic", "author_id": 9855648, "author_profile": "https://Stackoverflow.com/users/9855648", "pm_score": 1, "selected": false, "text": "IPointerClick" }, { "answer_id": 74411283, "author": "Ratbyte Boss", "author_id": 10627282, "author_profile": "https://Stackoverflow.com/users/10627282", "pm_score": 1, "selected": true, "text": " if (MyDropBox.transform.childCount != 3 && !MyDropBoxDown) { MyDropBoxDown = true;} // Detect dropbox down and set a bool flag\n if (MyDropBox.transform.childCount == 3 && MyDropBoxDown) { MyDropBoxDown = false;} // detect dropbox up and unset a bool flag\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10627282/" ]
74,401,561
<p>I'm trying to get the dates from the soup that is scraping the google NEWS page</p> <pre><code>date_section = soup.find_all('div', {&quot;class&quot;: &quot;OSrXXb ZE0LJd YsWzw&quot;}) print(date_section) </code></pre> <p>output:</p> <pre><code>[&lt;div class=&quot;OSrXXb ZE0LJd YsWzw&quot; style=&quot;bottom:0px&quot;&gt;&lt;span&gt;30 May 2020&lt;/span&gt;&lt;/div&gt;, &lt;div class=&quot;OSrXXb ZE0LJd YsWzw&quot; style=&quot;bottom:0px&quot;&gt;&lt;span&gt;3 weeks ago&lt;/span&gt;&lt;/div&gt;, &lt;div class=&quot;OSrXXb ZE0LJd YsWzw&quot; style=&quot;bottom:0px&quot;&gt;&lt;span&gt;1 week ago&lt;/span&gt;&lt;/div&gt;, &lt;div class=&quot;OSrXXb ZE0LJd YsWzw&quot; style=&quot;bottom:0px&quot;&gt;&lt;span&gt;2 weeks ago&lt;/span&gt;&lt;/div&gt;, &lt;div class=&quot;OSrXXb ZE0LJd YsWzw&quot; style=&quot;bottom:0px&quot;&gt;&lt;span&gt;22 Nov 2020&lt;/span&gt;&lt;/div&gt;, &lt;div class=&quot;OSrXXb ZE0LJd YsWzw&quot; style=&quot;bottom:0px&quot;&gt;&lt;span&gt;19 Mar 2019&lt;/span&gt;&lt;/div&gt;, &lt;div class=&quot;OSrXXb ZE0LJd YsWzw&quot; style=&quot;bottom:0px&quot;&gt;&lt;span&gt;18 Mar 2019&lt;/span&gt;&lt;/div&gt;, &lt;div class=&quot;OSrXXb ZE0LJd YsWzw&quot; style=&quot;bottom:0px&quot;&gt;&lt;span&gt;11 Aug 2019&lt;/span&gt;&lt;/div&gt;, &lt;div class=&quot;OSrXXb ZE0LJd YsWzw&quot; style=&quot;bottom:0px&quot;&gt;&lt;span&gt;1 Aug 2019&lt;/span&gt;&lt;/div&gt;, &lt;div class=&quot;OSrXXb ZE0LJd YsWzw&quot; style=&quot;bottom:0px&quot;&gt;&lt;span&gt;4 Jun 2009&lt;/span&gt;&lt;/div&gt;] </code></pre> <p>I want to get a <code>list</code> of all the dates from this structure.</p> <p>This is how I'm currently accessing the date and can get a <code>list</code> of dates by looping. I was wondering if there is more elegant way of working with <code>BeautifulSoup</code> to access the dates in such a structure.</p> <pre><code>print(&quot;First date&quot;,date_section[0].text) </code></pre>
[ { "answer_id": 74403734, "author": "Horothenic", "author_id": 9855648, "author_profile": "https://Stackoverflow.com/users/9855648", "pm_score": 1, "selected": false, "text": "IPointerClick" }, { "answer_id": 74411283, "author": "Ratbyte Boss", "author_id": 10627282, "author_profile": "https://Stackoverflow.com/users/10627282", "pm_score": 1, "selected": true, "text": " if (MyDropBox.transform.childCount != 3 && !MyDropBoxDown) { MyDropBoxDown = true;} // Detect dropbox down and set a bool flag\n if (MyDropBox.transform.childCount == 3 && MyDropBoxDown) { MyDropBoxDown = false;} // detect dropbox up and unset a bool flag\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401561", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19102371/" ]
74,401,584
<p>What is &quot;BYTE&quot; and &quot;PBYTE&quot; used for?.I couldn't find any information on the internet.</p> <pre><code>#include &lt;iostream&gt; #include &lt;Windows.h&gt; using namespace std; BYTE by='a'; PBYTE pby= &amp;by; int main(){ cout&lt;&lt;&quot;by : &quot;&lt;&lt;by&lt;&lt;endl; cout&lt;&lt;&quot;&amp;by : &quot;&lt;&lt;&amp;by&lt;&lt;endl; // Why doesn't it return the memory address? cout&lt;&lt;&quot;pby : &quot;&lt;&lt;pby&lt;&lt;endl; cout&lt;&lt;&quot;&amp;pby: &quot;&lt;&lt;&amp;pby; return 0; } The console shows: by : a &amp;by : a pby : a &amp;pby: 00007FF6CC10A008 </code></pre> <p>I just want to know what BYTE and PBYTE are used for. I can not understand. Thanks</p>
[ { "answer_id": 74401878, "author": "imamangoo", "author_id": 16372454, "author_profile": "https://Stackoverflow.com/users/16372454", "pm_score": -1, "selected": false, "text": "BYTE" }, { "answer_id": 74403491, "author": "shy45", "author_id": 20313707, "author_profile": "https://Stackoverflow.com/users/20313707", "pm_score": 2, "selected": true, "text": " unsigned char* img = new unsigned char[1024 * 1024];\n load_image(img, ....);\n conv_image(img, ....);\n" }, { "answer_id": 74411207, "author": "kvr", "author_id": 5923576, "author_profile": "https://Stackoverflow.com/users/5923576", "pm_score": 1, "selected": false, "text": "BYTE A byte (8 bits).\nThis type is declared in WinDef.h as follows:\ntypedef unsigned char BYTE;\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401584", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20448778/" ]
74,401,595
<p>How can I hide the loading spinner after all the data has been fetched from the API? I have a laravel api that outputs paginated data. I am using reactjs to display the data with scroll event. Now I want to hide the spinner when all the data has been fetched. Or add something like <code>No more data</code></p> <p>Here is my code</p> <pre><code>function Training() { let navigate = useNavigate(); const [fruits, setFruits] = useState([]); const [limit, setLimit] = useState(6); const [isLoading, setIsLoading] = useState(true); const [loading, setLoading] = useState(false); useEffect(() =&gt; { let isMounted = true; axios.get(`/api/fruits?page=1&amp;limit=` + limit).then(res =&gt; { if (isMounted) { if (res.data.status === 200) { setFruits(res.data.fruit); setIsLoading(false); setLoading(false); console.warn(res.data.fruit.length) } } }); return () =&gt; { isMounted = false }; }, [limit]); useEffect(() =&gt; { const handleScroll = (e) =&gt; { const scrollHeight = e.target.documentElement.scrollHeight const currentHeight = e.target.documentElement.scrollTop + window.innerHeight if (currentHeight + 1 &gt;= scrollHeight) { setLoading(true); setLimit(limit + 4) } } window.addEventListener(&quot;scroll&quot;, handleScroll) return () =&gt; window.removeEventListener(&quot;scroll&quot;, handleScroll) }, [limit]) </code></pre> <p>To show the data and the loading spinner</p> <pre><code>&lt;div className=&quot;section&quot;&gt; &lt;div className=&quot;row&quot;&gt; {isLoading &amp;&amp; &lt;WidgetSkeleton cards={6} /&gt;} {fruits.map((fruit) =&gt; ( &lt;FruitWidget fruit={fruit} key={fruit.id} /&gt; ))} &lt;/div&gt; {loading ? &lt;&gt;&lt;span className=&quot;spinner-border spinner-center text-primary mb-5&quot; role=&quot;status&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/&gt; : ''} &lt;/div&gt; </code></pre> <p>Please help. Thank you</p>
[ { "answer_id": 74401878, "author": "imamangoo", "author_id": 16372454, "author_profile": "https://Stackoverflow.com/users/16372454", "pm_score": -1, "selected": false, "text": "BYTE" }, { "answer_id": 74403491, "author": "shy45", "author_id": 20313707, "author_profile": "https://Stackoverflow.com/users/20313707", "pm_score": 2, "selected": true, "text": " unsigned char* img = new unsigned char[1024 * 1024];\n load_image(img, ....);\n conv_image(img, ....);\n" }, { "answer_id": 74411207, "author": "kvr", "author_id": 5923576, "author_profile": "https://Stackoverflow.com/users/5923576", "pm_score": 1, "selected": false, "text": "BYTE A byte (8 bits).\nThis type is declared in WinDef.h as follows:\ntypedef unsigned char BYTE;\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401595", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19223350/" ]
74,401,598
<p>I'd like to add a new column to my Options list. The new column would calculate the difference between the last stock price at close and the Option Strike in percentage.</p> <p>Here's my code</p> <p>#Getting Options data and creating an list containing only Puts</p> <pre><code>library(quantmod) Symbols&lt;-c (&quot;AA&quot;,&quot;AAL&quot;,&quot;AAOI&quot;,&quot;ABBV&quot;,&quot;ABC&quot;,&quot;ABNB&quot;) Options.20221111 &lt;- lapply(Symbols, getOptionChain) names(Options.20221111) &lt;- Symbols only_puts_list &lt;- lapply(Options.20221111, function(x) x$puts) </code></pre> <p>#Getting Stock data</p> <pre><code>start_date=as.Date(&quot;2022-06-01&quot;) getSymbols(Symbols,from=start_date) </code></pre> <p>Next, I'd like to add a new column to only_puts_list called &quot;%Strike-StockPrice&quot;, that would calculate the difference between the last Stock(Close.price) price calculated in getSymbols minus the Strike values (all of them in the only_put_list) in percentage.</p> <p>For example, if the last Close price of a stock is 100 and a Strike price is 90, there is a 10% difference. The new column would make the calculation for all Strikes of the only_put_list.</p> <p>Thanks for any input.</p>
[ { "answer_id": 74401878, "author": "imamangoo", "author_id": 16372454, "author_profile": "https://Stackoverflow.com/users/16372454", "pm_score": -1, "selected": false, "text": "BYTE" }, { "answer_id": 74403491, "author": "shy45", "author_id": 20313707, "author_profile": "https://Stackoverflow.com/users/20313707", "pm_score": 2, "selected": true, "text": " unsigned char* img = new unsigned char[1024 * 1024];\n load_image(img, ....);\n conv_image(img, ....);\n" }, { "answer_id": 74411207, "author": "kvr", "author_id": 5923576, "author_profile": "https://Stackoverflow.com/users/5923576", "pm_score": 1, "selected": false, "text": "BYTE A byte (8 bits).\nThis type is declared in WinDef.h as follows:\ntypedef unsigned char BYTE;\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9800710/" ]
74,401,612
<p>I have tried <a href="https://stackoverflow.com/questions/71242297/xml-find-elements-by-tag-using-python-and-print-to-console">this</a> approach but it doesn't work for me.</p> <p>I want to get the releaseDate value from the below xml</p> <pre><code>&lt;Product prodID=&quot;bed&quot; lang=&quot;en&quot;&gt; &lt;ProductState stateType=&quot;Published&quot; stateDateTime=&quot;2019-04&quot; testDate=&quot;2019-04&quot; releaseDate=&quot;2019&quot;/&gt; </code></pre> <p>I have tried the below code:</p> <pre><code>from pathlib import Path import os import tempfile import xml.etree.ElementTree as ET xmlfile = 'path_to_xml' tree = ET.parse(xmlfile) root = tree.getroot() for elm in root.findall(&quot;./Product/ProductStatus/releaseDate&quot;): print(elm.attrib) </code></pre>
[ { "answer_id": 74402043, "author": "CristiFati", "author_id": 4788546, "author_profile": "https://Stackoverflow.com/users/4788546", "pm_score": 1, "selected": false, "text": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Product prodID=\"bed\" lang=\"en\"> \n <ProductState stateType=\"Published\" stateDateTime=\"2019-04\" testDate=\"2019-04\" releaseDate=\"2019\"/>\n <!-- Other nodes -->\n</Product>\n" }, { "answer_id": 74591557, "author": "Hermann12", "author_id": 12621346, "author_profile": "https://Stackoverflow.com/users/12621346", "pm_score": 0, "selected": false, "text": ".get(\"attributeName\")" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401612", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13836950/" ]
74,401,626
<p>I need to declare a &quot;global&quot; constant that can be accessed by another contract. Given a very simple Solidity contract as follows:</p> <pre class="lang-js prettyprint-override"><code>pragma solidity ^0.4.17; uint256 constant MY_CONSTANT = 3; contract MyContract { constructor() public {} } </code></pre> <p>This is my truffle-config.js file:</p> <pre class="lang-js prettyprint-override"><code>module.exports = { networks: { development: { host: &quot;127.0.0.1&quot;, port: 9545, network_id: &quot;*&quot;, }, }, compilers: { solc: { version: &quot;^0.4.17&quot; } } }; </code></pre> <p>When I run <code>truffle develop</code> then <code>truffle compile</code>, I got the following error:</p> <pre class="lang-bash prettyprint-override"><code>Compiling your contracts... =========================== &gt; Compiling ./contracts/MyContract.sol-bin. Attempt #1 CompileError: project:/contracts/MyContract.sol:4:1: ParserError: Expected pragma, import directive or contract/interface/library definition. uint256 constant MY_CONSTANT = 3; ^-----^ Compilation failed. See above. at /home/thaiminhpv/.nvm/versions/node/v16.18.1/lib/node_modules/truffle/build/webpack:/packages/compile-solidity/dist/run.js:95:1 at Generator.next (&lt;anonymous&gt;) at fulfilled (/home/thaiminhpv/.nvm/versions/node/v16.18.1/lib/node_modules/truffle/build/webpack:/packages/compile-solidity/dist/run.js:28:43) Truffle v5.6.4 (core: 5.6.4) Node v16.18.1 </code></pre> <p>Here is my truffle version:</p> <pre class="lang-bash prettyprint-override"><code>$ truffle version Truffle v5.6.4 (core: 5.6.4) Ganache v7.5.0 Solidity - ^0.4.17 (solc-js) Node v16.18.1 Web3.js v1.7.4 </code></pre> <p>However, everything work fine when I change the solidity compiler from <code>^0.4.17</code> to <code>0.8.17</code> in <code>truffle-config.js</code>.</p> <p>How can I declare constant at file level in solidity <code>0.4.17</code>?</p>
[ { "answer_id": 74402043, "author": "CristiFati", "author_id": 4788546, "author_profile": "https://Stackoverflow.com/users/4788546", "pm_score": 1, "selected": false, "text": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Product prodID=\"bed\" lang=\"en\"> \n <ProductState stateType=\"Published\" stateDateTime=\"2019-04\" testDate=\"2019-04\" releaseDate=\"2019\"/>\n <!-- Other nodes -->\n</Product>\n" }, { "answer_id": 74591557, "author": "Hermann12", "author_id": 12621346, "author_profile": "https://Stackoverflow.com/users/12621346", "pm_score": 0, "selected": false, "text": ".get(\"attributeName\")" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401626", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11806050/" ]
74,401,667
<p>I'm in the process of learning WPF and the MVVM design pattern. Currently the code in my ViewModel for a delete customer command looks like this:</p> <pre><code> public class vmCustomers : INotifyPropertyChanged { ... private ICommand _commandDeleteCustomer = null; ... public ICommand CommandDeleteCustomer { get { if (_commandDeleteCustomer == null) _commandDeleteCustomer = new RelayCommand&lt;object&gt;(DeleteCustomerAction, DeleteCustomerPredicate); return _commandDeleteCustomer; } } private void DeleteCustomerAction(object o) { ...stuff... } private bool DeleteCustomerPredicate(object o) { ...stuff... return true; } } </code></pre> <p>I'd like to slim down the declaration of the ICommand to something like this so that I can reduce the coding overhead for each command:</p> <pre><code>public readonly ICommand CommandDeleteCustomer = new RelayCommand((obj) =&gt; DeleteCustomerAction(obj), (obj) =&gt; DeleteCustomerPredicate(obj)); </code></pre> <p>But I get this error:</p> <p><code>A field initializer cannot reference the non-static field, method, or property vmCustomers.DeleteCustomerAction(object)</code></p> <p>Is there a way I can declare the ICommand in a single line of code so that I can simply focus on business-related code rather than repeated infrastructure code.</p>
[ { "answer_id": 74402043, "author": "CristiFati", "author_id": 4788546, "author_profile": "https://Stackoverflow.com/users/4788546", "pm_score": 1, "selected": false, "text": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Product prodID=\"bed\" lang=\"en\"> \n <ProductState stateType=\"Published\" stateDateTime=\"2019-04\" testDate=\"2019-04\" releaseDate=\"2019\"/>\n <!-- Other nodes -->\n</Product>\n" }, { "answer_id": 74591557, "author": "Hermann12", "author_id": 12621346, "author_profile": "https://Stackoverflow.com/users/12621346", "pm_score": 0, "selected": false, "text": ".get(\"attributeName\")" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401667", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6870991/" ]
74,401,676
<p>I setup my django and postgres container on my local machine and all working fine. Local server is running, database running but I am not being able to connect to the created postgres db.</p> <p>docker-compose.yml</p> <pre><code>version: '3' services: web: build: . command: python manage.py runserver 0.0.0.0:8000 volumes: - .:/app ports: - &quot;8000:8000&quot; depends_on: - db db: image: postgres:13.0-alpine volumes: - postgres_data:/var/lib/postgresql/data/ environment: - POSTGRES_USER=my_user - POSTGRES_PASSWORD=my_password - POSTGRES_DB=my_db volumes: postgres_data: </code></pre> <p>I tried this command: <code>docker exec -it container_id psql -U postgres </code> error: <code>psql: error: could not connect to server: FATAL: role &quot;postgres&quot; does not exist</code></p> <p>I am very new to Docker.</p>
[ { "answer_id": 74402144, "author": "scūriolus", "author_id": 12236313, "author_profile": "https://Stackoverflow.com/users/12236313", "pm_score": 2, "selected": true, "text": "my_password" }, { "answer_id": 74410606, "author": "Manoj Tolagekar", "author_id": 17808039, "author_profile": "https://Stackoverflow.com/users/17808039", "pm_score": 0, "selected": false, "text": "environment" }, { "answer_id": 74410639, "author": "Whiteox", "author_id": 16369705, "author_profile": "https://Stackoverflow.com/users/16369705", "pm_score": 0, "selected": false, "text": "- ports: \n \"5432:5432\"\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401676", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12061655/" ]
74,401,695
<p>I want use Firebase Auth in Flutter project. And I am use <code>provider</code>. Everything is okey but I am facing one issue with <code>provider</code>.</p> <p>My IconButtonWidget:</p> <pre><code>class SocialIconButton extends StatelessWidget { final String socialIcon; const SocialIconButton({Key? key, required this.socialIcon}) : super(key: key); @override Widget build(BuildContext context) { return Padding( padding: EdgeInsets.symmetric(horizontal: context.dynamicWidth(20)), child: IconButton( onPressed: (() { final provider = Provider.of&lt;GoogleSignInProvider&gt;(context, listen: false); provider.login(); }), icon: Image.asset(socialIcon)), ); } } </code></pre> <p>When I press button I am facing this issue:</p> <pre><code>ProviderNotFoundException (Error: Could not find the correct Provider&lt;GoogleSignInProvider&gt; above this SocialIconButton Widget. </code></pre>
[ { "answer_id": 74402144, "author": "scūriolus", "author_id": 12236313, "author_profile": "https://Stackoverflow.com/users/12236313", "pm_score": 2, "selected": true, "text": "my_password" }, { "answer_id": 74410606, "author": "Manoj Tolagekar", "author_id": 17808039, "author_profile": "https://Stackoverflow.com/users/17808039", "pm_score": 0, "selected": false, "text": "environment" }, { "answer_id": 74410639, "author": "Whiteox", "author_id": 16369705, "author_profile": "https://Stackoverflow.com/users/16369705", "pm_score": 0, "selected": false, "text": "- ports: \n \"5432:5432\"\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401695", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20477196/" ]
74,401,696
<p>I'm so Newbie in Programming.</p> <p>I'm using Django as backend, React+Typescript as frontend.</p> <p>I'm using Axios to make JWT login function. but stuck in the middle.</p> <p>Because headers/Authorization makes type error.</p> <p><a href="https://i.stack.imgur.com/omJlo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/omJlo.png" alt="enter image description here" /></a></p> <p>as above Authorization does not work. <a href="https://i.stack.imgur.com/pSpGM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pSpGM.png" alt="enter image description here" /></a></p> <p>showing this error.</p> <p>Can anyone help me out of this situation?</p>
[ { "answer_id": 74401767, "author": "Disco", "author_id": 11196441, "author_profile": "https://Stackoverflow.com/users/11196441", "pm_score": 3, "selected": true, "text": "null" }, { "answer_id": 74401959, "author": "Shahzad Khan", "author_id": 3488758, "author_profile": "https://Stackoverflow.com/users/3488758", "pm_score": 0, "selected": false, "text": "const axiosbase = axios.create({\n baseURL: 'Your Base URL',\n timeout: 5000,\n transformRequest: [(data, headers) => { \n return data;\n }]\n});\n\n//default headers\nvar token = 'Your JWT';\naxiosbase.defaults.headers[\"Authorization\"] = 'Bearer ' + token;\naxiosbase.defaults.headers[\"Accept\"] = 'application/json, text/plain, */*';\naxiosbase.defaults.headers[\"Content-Type\"] = 'application/json';\n\n// Add a request interceptor\naxiosbase.interceptors.request.use((config) => { \n return config;\n }, (error) => {\n // Do something with request error\n console.log('Error occured while request');\n return Promise.reject(error);\n });\n\n// Add a response interceptor\naxiosbase.interceptors.response.use(\n (response) => {\n // Do something with response data\n //console.log('Response was received');\n return response;\n },\n);\n\nexport default axiosbase;\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401696", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18641007/" ]
74,401,737
<p>I am stuck with a data in excel having the above form and wish to add all the numbers between brackets and finally give its addition after applying the formula.</p> <p>For ex. abc(200), def(300), gijklmno(5000), pqrstuvwx yz(50000) should give 55500 in another cell</p> <p>Trying: abc(200), def(300), gijklmno(5000), pqrstuvwx yz(50000)</p> <p>Expecting: 55500</p>
[ { "answer_id": 74401798, "author": "Mayukh Bhattacharya", "author_id": 8162520, "author_profile": "https://Stackoverflow.com/users/8162520", "pm_score": 1, "selected": false, "text": "B1" }, { "answer_id": 74402101, "author": "Rory", "author_id": 3611989, "author_profile": "https://Stackoverflow.com/users/3611989", "pm_score": 1, "selected": false, "text": "=SUMPRODUCT(FILTERXML(\"<a><b>\"&SUBSTITUTE(SUBSTITUTE(A1,\")\",\"(\"),\"(\",\"</b><b>\")&\"</b></a>\",\"//b[number()=.]\"))\n" }, { "answer_id": 74402650, "author": "Jos Woolley", "author_id": 17007704, "author_profile": "https://Stackoverflow.com/users/17007704", "pm_score": 2, "selected": false, "text": "=SUM(0+INDEX(TEXTSPLIT(A1,\"(\",\")\",,,0),,2))" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401737", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20477168/" ]
74,401,746
<p>I am new in Python and trying to write a binary-to-decimal converted function like below</p> <pre><code>def decimaltobinary(n): if n &gt; 1: decimaltobinary(n//2) print(n%2,end='') #return n%2 decimaltobinary(4) </code></pre> <p>This works perfectly fine. Now the question is when I am modifying it as below, it doesn't give me correct result -</p> <pre><code>def decimaltobinary(n): if n &gt; 1: decimaltobinary(n//2) #print(n%2,end='') return n%2 a=decimaltobinary(4) print(a) </code></pre> <p>Am I missing something with the return statement? Any pointer will be very helpful.</p>
[ { "answer_id": 74401798, "author": "Mayukh Bhattacharya", "author_id": 8162520, "author_profile": "https://Stackoverflow.com/users/8162520", "pm_score": 1, "selected": false, "text": "B1" }, { "answer_id": 74402101, "author": "Rory", "author_id": 3611989, "author_profile": "https://Stackoverflow.com/users/3611989", "pm_score": 1, "selected": false, "text": "=SUMPRODUCT(FILTERXML(\"<a><b>\"&SUBSTITUTE(SUBSTITUTE(A1,\")\",\"(\"),\"(\",\"</b><b>\")&\"</b></a>\",\"//b[number()=.]\"))\n" }, { "answer_id": 74402650, "author": "Jos Woolley", "author_id": 17007704, "author_profile": "https://Stackoverflow.com/users/17007704", "pm_score": 2, "selected": false, "text": "=SUM(0+INDEX(TEXTSPLIT(A1,\"(\",\")\",,,0),,2))" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401746", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8097395/" ]
74,401,764
<p>I want to collect the associated keys of List of maximum numbers from Map&lt;String,Integer&gt; in Java 8+</p> <p>For example:</p> <pre class="lang-java prettyprint-override"><code>final Map&lt;String, Integer&gt; map = new HashMap&lt;&gt;(); map.put(&quot;first&quot;, 50); map.put(&quot;second&quot;, 10); map.put(&quot;third&quot;, 50); </code></pre> <p>here I want to return the List of keys associated with maximum values.</p> <p>For the above example, expected output is [first,third]. Because these 2 keys having the same max value.</p> <p>I tried with below approach, but able to get single max key only.</p> <pre class="lang-java prettyprint-override"><code>final String maxKey = map.entrySet() .stream() .max(Map.Entry.comparingByValue()) .map(Map.Entry::getKey) .orElse(null); final List&lt;String&gt; keysInDescending = map.entrySet() .stream() .sorted(Map.Entry.&lt;String,Integer&gt;comparingByValue().reversed()) .map(Map.Entry::getKey) .collect(Collectors.toList()); System.out.println(maxKey); // third System.out.println(keysInDescending); //[third, first, second] </code></pre> <p>But my expected output is [first, third]. How can we achieve it in Java 8+ versions?</p>
[ { "answer_id": 74401856, "author": "Ricola", "author_id": 7424948, "author_profile": "https://Stackoverflow.com/users/7424948", "pm_score": 2, "selected": false, "text": "final Integer maxValue = map.values()\n .stream()\n .max(Comparator.naturalOrder())\n .orElse(null);\n" }, { "answer_id": 74401916, "author": "azro", "author_id": 7212686, "author_profile": "https://Stackoverflow.com/users/7212686", "pm_score": 3, "selected": false, "text": "Map<Integer, List<String>>" }, { "answer_id": 74401922, "author": "Joop Eggen", "author_id": 984823, "author_profile": "https://Stackoverflow.com/users/984823", "pm_score": 2, "selected": false, "text": " final Integer maxValue = map.values()\n .stream()\n .max(Function.identity())\n .map(Map.Entry::getKey)\n .orElse(Integer.MIN_VALUE);\n\n final List<String> keysInDescending = map.entrySet()\n .stream()\n .filter(e -> maxValue.equals(e.getValue()))\n .map(e -> e.getKey())\n //.sorted(Comparator.reverseOrder())\n .collect(Collectors.toList());\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401764", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4938849/" ]
74,401,768
<p>I have 3 docker containers running in mac os.</p> <ol> <li>backend - port 5055</li> <li>frontend (next.js) - port 3000</li> <li>nginx - port 80</li> </ol> <p>I am getting <strong>net::ERR_FAILED</strong> for backend api requests when I access from browser (http://localhost:80). I can make a request to backend (http://localhost:5055) in postman and it works well.</p> <p>Sample api request - GET http://backend:5055/api/category/show</p> <p><a href="https://i.stack.imgur.com/QLfd4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QLfd4.png" alt="enter image description here" /></a></p> <p>What is the reason for this behaviour ?</p> <p>Thanks.</p> <p>docker-compose.yml</p> <pre><code>version: '3.9' services: backend: image: backend-image build: context: ./backend dockerfile: Dockerfile.prod ports: - '5055:5055' frontend: image: frontend-image build: context: ./frontend dockerfile: Dockerfile.prod ports: - '3000:3000' depends_on: - backend nginx: image: nginx-image build: context: ./nginx ports: - '80:80' depends_on: - backend - frontend </code></pre> <p>backend - Dockerfile.prod</p> <pre><code>FROM node:19.0.1-slim WORKDIR /app COPY package.json . RUN yarn install COPY . ./ ENV PORT 5055 EXPOSE $PORT CMD [&quot;npm&quot;, &quot;run&quot;, &quot;start&quot;] </code></pre> <p>frontend - Dockerfile.prod</p> <pre><code>FROM node:19-alpine WORKDIR /usr/app RUN npm install --global pm2 COPY ./package*.json ./ RUN npm install COPY ./ ./ RUN npm run build EXPOSE 3000 USER node CMD [ &quot;pm2-runtime&quot;, &quot;start&quot;, &quot;npm&quot;, &quot;--&quot;, &quot;start&quot; ] </code></pre> <p>nginx - Dockerfile</p> <pre><code>FROM public.ecr.aws/nginx/nginx:stable-alpine RUN rm /etc/nginx/conf.d/* COPY ./default.conf /etc/nginx/conf.d/ EXPOSE 80 CMD [ &quot;nginx&quot;, &quot;-g&quot;, &quot;daemon off;&quot; ] </code></pre> <p>nginx - default.conf</p> <pre><code>upstream frontend { server frontend:3000; } upstream backend { server backend:5055; } server { listen 80 default_server; ... location /api { ... proxy_pass http://backend; proxy_redirect off; ... } location /_next/static { proxy_cache STATIC; proxy_pass http://frontend; } location /static { proxy_cache STATIC; proxy_ignore_headers Cache-Control; proxy_cache_valid 60m; proxy_pass http://frontend; } location / { proxy_pass http://frontend; } } </code></pre> <p>frontend - .env.local</p> <pre><code>NEXT_PUBLIC_API_BASE_URL=http://backend:5055/api </code></pre> <p>frontend - httpServices.js</p> <pre><code>import axios from 'axios' import Cookies from 'js-cookie' const instance = axios.create({ baseURL: `${process.env.NEXT_PUBLIC_API_BASE_URL}`, timeout: 500000, headers: { Accept: 'application/json', 'Content-Type': 'application/json', }, }) ... const responseBody = (response) =&gt; response.data const requests = { get: (url, body) =&gt; instance.get(url, body).then(responseBody), post: (url, body, headers) =&gt; instance.post(url, body, headers).then(responseBody), put: (url, body) =&gt; instance.put(url, body).then(responseBody), } export default requests </code></pre> <p><strong>Edit</strong></p> <ol> <li>nginx logs (docker logs -f nginx 2&gt;/dev/null)</li> </ol> <pre><code>172.20.0.1 - - [14/Nov/2022:17:02:39 +0000] &quot;GET /_next/image?url=%2Fslider%2Fslider-1.jpg&amp;w=1080&amp;q=75 HTTP/1.1&quot; 304 0 &quot;http://localhost/&quot; &quot;Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36&quot; &quot;-&quot; 172.20.0.1 - - [14/Nov/2022:17:02:41 +0000] &quot;GET /service-worker.js HTTP/1.1&quot; 304 0 &quot;http://localhost/service-worker.js&quot; &quot;Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36&quot; &quot;-&quot; 172.20.0.1 - - [14/Nov/2022:17:02:41 +0000] &quot;GET /fallback-B639VDPLP_r91l2hRR104.js HTTP/1.1&quot; 304 0 &quot;http://localhost/service-worker.js&quot; &quot;Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36&quot; &quot;-&quot; 172.20.0.1 - - [14/Nov/2022:17:02:41 +0000] &quot;GET /workbox-fbc529db.js HTTP/1.1&quot; 304 0 &quot;http://localhost/service-worker.js&quot; &quot;Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36&quot; &quot;-&quot; </code></pre> <ol start="2"> <li>curl request is working well from nginx container to backend container (curl backend:5055/api/category/show)</li> </ol> <p><strong>Edit 2</strong></p> <pre><code>const CategoryCarousel = () =&gt; { ... const { data, error } = useAsync(() =&gt; CategoryServices.getShowingCategory()) ... } </code></pre> <pre><code>import requests from './httpServices' const CategoryServices = { getShowingCategory() { return requests.get('/category/show') }, } </code></pre> <p><strong>Edit 3</strong></p> <p>When NEXT_PUBLIC_API_BASE_URL=http://localhost:5055/api</p> <pre><code>Error: connect ECONNREFUSED 127.0.0.1:5055 at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1283:16) { errno: -111, code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 5055, config: { ... baseURL: 'http://localhost:5055/api', method: 'get', url: '/products/show', data: undefined }, ... _options: { ... protocol: 'http:', path: '/api/products/show', method: 'GET', ... pathname: '/api/products/show' }, ... }, _currentUrl: 'http://localhost:5055/api/products/show', _timeout: null, }, response: undefined, isAxiosError: true, } </code></pre>
[ { "answer_id": 74437871, "author": "zsolt", "author_id": 4223799, "author_profile": "https://Stackoverflow.com/users/4223799", "pm_score": 0, "selected": false, "text": "location /api {\n ...\n proxy_pass http://backend:5055/api;\n}\n" }, { "answer_id": 74440450, "author": "sungryeol", "author_id": 9292770, "author_profile": "https://Stackoverflow.com/users/9292770", "pm_score": 2, "selected": true, "text": "# docker-compose.yaml\nservice-a:\n ports:\n - 3000:3000 # exposed to outside\n # ...\nservice-b:\n ports:\n - 5000:5000 # exposed to outside\n # ...\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401768", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15557686/" ]
74,401,791
<p>I'm trying to run a datediff. I essentially want to say the number of days between 1st November 2022 and 1st November 2022 is ONE day.</p> <p>When I attempt this, <code>$number_of_days</code> returned is 0. Can someone explain why this is and how to resolve?</p> <pre><code>$end = &quot;2022-11-01&quot;; $start = &quot;2022-11-01&quot;; $datediff = ($end - $start) + 1; // tried to fix echo $datediff; echo '&lt;hr&gt;'; echo ($datediff / (60 * 60 * 24)); $number_of_days = round($datediff / (60 * 60 * 24)); echo '&lt;hr&gt;'; echo $number_of_days; </code></pre>
[ { "answer_id": 74401823, "author": "Henryc17", "author_id": 14595300, "author_profile": "https://Stackoverflow.com/users/14595300", "pm_score": 3, "selected": true, "text": "$end = strtotime(\"2022-11-01\");\n$start = strtotime(\"2022-11-01\");\n\n$datediff = (($end - $start)/60/60/24) + 1;\n" }, { "answer_id": 74401909, "author": "Paul Crozer", "author_id": 6296726, "author_profile": "https://Stackoverflow.com/users/6296726", "pm_score": 1, "selected": false, "text": "DateTime" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/644978/" ]
74,401,793
<p>I'm trying to find a part in multiple strings, that all strings share in common. For example:</p> <pre class="lang-js prettyprint-override"><code>const string1 = '.bold[_ngcontent=&quot;_kjhafh-asda-qw&quot;] {background:black;}'; const string2 = '[_ngcontent=&quot;_kjhafh-asda-qw&quot;] {background-color:hotpink;}'; const string3 = 'div &gt; p &gt; span[_ngcontent=&quot;_kjhafh-asda-qw&quot;] {background:hotpink;}' </code></pre> <p><strong>I don't know in advance what exactly the string is that I'm looking for</strong>, so I have to loop over the strings and find out. In the example above, the pattern would be <code>[_ngcontent=&quot;_kjhafh-asda-qw&quot;]</code>.</p> <p>Is this even possible? Also, it would have to understand that maybe no such pattern exists. And are there methods for that or do I need to implement such an algorithm myself?</p> <p>EDIT (context): We are building a validator, that checks a micro-frontend for global CSS rules (not prefixed and outside a shadow-dom), by loading it in isolation in a headless browser (within a jenkins pipeline) and validate, that it should not break any other stuff by global rules, that might be outside the context of the micro-frontend, on the same page. Using a headless browser, we can make use of the <code>document.styleSheets</code> property and not miss any styles that are being loaded. This will find <code>&lt;style&gt;</code> tags and its contents, aswell as content of external stylesheets.</p>
[ { "answer_id": 74401823, "author": "Henryc17", "author_id": 14595300, "author_profile": "https://Stackoverflow.com/users/14595300", "pm_score": 3, "selected": true, "text": "$end = strtotime(\"2022-11-01\");\n$start = strtotime(\"2022-11-01\");\n\n$datediff = (($end - $start)/60/60/24) + 1;\n" }, { "answer_id": 74401909, "author": "Paul Crozer", "author_id": 6296726, "author_profile": "https://Stackoverflow.com/users/6296726", "pm_score": 1, "selected": false, "text": "DateTime" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401793", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2311557/" ]
74,401,802
<p>My requirement is I have a large dataframe with millions of rows. I encoded all strings to numeric values in order to use <code>numpys</code> vectorization to increase processing speed.</p> <p>So I was looking at a way to quickly check if a number exists in another list column. Previously, I was using list comprehension with string values, but with after converting to <code>np.arrays</code> was looking at similar function.</p> <p>I stumbled across this link: <a href="https://stackoverflow.com/questions/67158284/check-if-values-of-a-column-are-in-values-of-another-numpy-array-column-in-panda">check if values of a column are in values of another numpy array column in pandas</a></p> <p>In order to the <code>numpy.isin</code>, I tried running below code:</p> <pre><code>dt = pd.DataFrame({'id' : ['a', 'a', 'a', 'b', 'b'], 'col_a': [1,2,5,1,2], 'col_b': [2,2,[2,5,4],4,[1,5,6,3,2]]}) dt id col_a col_b 0 a 1 2 1 a 2 2 2 a 5 [2, 5, 4] 3 b 1 4 4 b 2 [1, 5, 6, 3, 2] </code></pre> <p>When I enter:</p> <pre><code>np.isin(dt['col_a'], dt['col_b']) </code></pre> <p>The output is:</p> <pre><code>array([False, True, False, False, True]) </code></pre> <p>Which is incorrect as the 3rd row has 5 in both columns <code>col_a</code> and <code>col_b</code>.</p> <p>Where as if I change the value to 4 as below:</p> <pre><code>dt = pd.DataFrame({'id' : ['a', 'a', 'a', 'b', 'b'], 'col_a': [1,2,4,1,2], 'col_b': [2,2,[2,5,4],4,[1,5,6,3,2]]}) dt id col_a col_b 0 a 1 2 1 a 2 2 2 a 4 [2, 5, 4] 3 b 1 4 4 b 2 [1, 5, 6, 3, 2] </code></pre> <p>and execute same code:</p> <pre><code>np.isin(dt['col_a'], dt['col_b']) </code></pre> <p>I get correct result:</p> <pre><code>array([False, True, True, False, True]) </code></pre> <p>Can someone please let me know why it's giving different results.</p>
[ { "answer_id": 74401841, "author": "Yevhen Kuzmovych", "author_id": 4727702, "author_profile": "https://Stackoverflow.com/users/4727702", "pm_score": 1, "selected": true, "text": "np.isin" }, { "answer_id": 74402059, "author": "Nuri Taş", "author_id": 19255749, "author_profile": "https://Stackoverflow.com/users/19255749", "pm_score": 1, "selected": false, "text": "col_b" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401802", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10722752/" ]
74,401,831
<p>I have created a function to delete multiple records.In our table contain id as type uuid. We get the input is like array of ids.</p> <pre><code> CREATE OR REPLACE FUNCTION public.deletetVersion(item_list uuid[]) RETURNS TABLE(id uuid[]) LANGUAGE 'plpgsql' COST 100 VOLATILE PARALLEL UNSAFE ROWS 1000 AS $BODY$ BEGIN RETURN QUERY DELETE FROM version WHERE id = ANY(item_list); END; $BODY$; </code></pre> <p>SELECT * from deletetVersion(Array['b6ad1912-e4f1-4419-831a-c70df89ffd63','877898f0-2f3f-4890-a658-898e35ffee3a'])</p> <p>But i got an error like:</p> <p>Anyone please help me</p> <blockquote> <pre><code> ERROR: function deletetversion(text[]) does not exist </code></pre> </blockquote>
[ { "answer_id": 74401841, "author": "Yevhen Kuzmovych", "author_id": 4727702, "author_profile": "https://Stackoverflow.com/users/4727702", "pm_score": 1, "selected": true, "text": "np.isin" }, { "answer_id": 74402059, "author": "Nuri Taş", "author_id": 19255749, "author_profile": "https://Stackoverflow.com/users/19255749", "pm_score": 1, "selected": false, "text": "col_b" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401831", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4899166/" ]
74,401,833
<p>In my angular project I have following task to do.</p> <p><a href="https://i.stack.imgur.com/E5biM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/E5biM.png" alt="enter image description here" /></a></p> <p>This is just a design template, not my actual code.</p> <p>So far I have made the right picture by having a <code>div</code> and setting the background image.</p> <p>But now I dont know how to put a dark layer on the page (like on the left side). The logic is no problem, but I dont know how to achieve it with CSS.</p> <p>How do I do it?</p>
[ { "answer_id": 74401919, "author": "Noman Yousaf", "author_id": 6547177, "author_profile": "https://Stackoverflow.com/users/6547177", "pm_score": 2, "selected": false, "text": "div{\n position:relative;\n}\n\ndiv:after {\n position: absolute;\n background: rgba(0,0,0,0.3);\n content: \"\";\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n}\n" }, { "answer_id": 74402095, "author": "Spyr0", "author_id": 16905893, "author_profile": "https://Stackoverflow.com/users/16905893", "pm_score": 1, "selected": false, "text": "div" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401833", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14287016/" ]
74,401,839
<p>I am making use of matching a url from a tab to the window.location, but am using secure routes. How do I remove the a part of a string from a selected character, In my case the char is '?' I want to remove everything from the ? to the end of the string. How can this be done with jquery?</p> <pre><code>document.querySelectorAll('.nav-link').forEach(link =&gt; { console.log(link); if(link.href === window.location.href){ link.setAttribute('aria-current', 'page') } }) </code></pre>
[ { "answer_id": 74401970, "author": "M.Haris", "author_id": 11509626, "author_profile": "https://Stackoverflow.com/users/11509626", "pm_score": 1, "selected": false, "text": "let link = link.split('?');\nlet required_link = link[0];\n" }, { "answer_id": 74402028, "author": "bradley Rice", "author_id": 17975884, "author_profile": "https://Stackoverflow.com/users/17975884", "pm_score": 0, "selected": false, "text": "document.querySelectorAll('.nav-link').forEach(link => {\n if(link.pathname === window.location.pathname){\n link.setAttribute('aria-current', 'page')\n }\n})\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401839", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17975884/" ]
74,401,852
<p>Here is the code:</p> <pre class="lang-hs prettyprint-override"><code>import qualified View.TreeWidget as TreeWidget main :: IO () main = do print $ bla &quot;sdfsd&quot; bla someString = case someString of TreeWidget.name -&gt; True &quot;sdfsd&quot; -&gt; False _ -&gt; True </code></pre> <p><code>TreeWidget.name</code> is a function defined in a file <code>TreeWidget.hs</code> like this:</p> <pre class="lang-hs prettyprint-override"><code>name :: String name = &quot;tree_list_name&quot; </code></pre> <p>Here is the error:</p> <pre><code>src/View/Main.hs:8:3: error: Qualified name in binding position: TreeWidget.name | 8 | TreeWidget.name -&gt; True | ^^^^^^^^^^^^^^^ </code></pre> <ol> <li>Why is this happening?</li> <li>What can be done?</li> </ol> <p>Thanks.</p>
[ { "answer_id": 74402110, "author": "Iceland_jack", "author_id": 165806, "author_profile": "https://Stackoverflow.com/users/165806", "pm_score": 3, "selected": true, "text": "_" }, { "answer_id": 74402641, "author": "leftaroundabout", "author_id": 745903, "author_profile": "https://Stackoverflow.com/users/745903", "pm_score": 2, "selected": false, "text": "name" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401852", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5201222/" ]
74,401,865
<p>i have created a htaccess url rewrite to geht my urls webseite.com/dashboard.php to webseite.com/dashboard.</p> <p>My Problem is, that I am giving parameters (for database data) over my url when I visit certain sites of my website like <code>https://example.com/detail_user.php?id=1</code>.</p> <p>With my rewrite rules it ignores the parameters added to the url.</p> <p>Is there any htaccess rule to give parameters to an url but when visiting the normal site remove the .php ending?</p> <pre><code>RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^([^/]+)/$ $1.php </code></pre>
[ { "answer_id": 74403392, "author": "Richard Leishman", "author_id": 17473064, "author_profile": "https://Stackoverflow.com/users/17473064", "pm_score": 0, "selected": false, "text": "RewriteEngine on\nRewriteCond %{REQUEST_FILENAME} !-d\nRewriteCond %{REQUEST_FILENAME}.php -f\nRewriteRule ^([^/]+)/$ $1.php [QSA]\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401865", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20477309/" ]
74,401,891
<p>In my case, I have a components '1,2,3,....' imported in another main component 'A'. In component 'A' some operation is done and among the components '1,2,3...' one filtered component is returned.</p> <p>I have to send some props to this filtered components and render this filtered component. Am posting my code please have a look. Thank you.</p> <pre class="lang-js prettyprint-override"><code>const LineItemViewComponent = [{ lineItem: &quot;AR008&quot;, component: &lt;AR008Users /&gt;, },{ lineItem: &quot;AR009&quot;, component: &lt;AR009Users /&gt;, },{ lineItem: &quot;AR010&quot;, component: &lt;AR010Users /&gt;, },]; const filterData = LineItemViewComponent.filter((eh) =&gt; eh.lineItem === this.props.each.lineItem); const viewDataFunction = () =&gt; { const {component} = filterData return &lt;&gt; &lt;component assessClicked={assessClicked} count={this.state.count} setAssessApi={this.setAssessApi} /&gt; &lt;/&gt;; }; </code></pre> <p><code>AR008Users</code> and <code>AR009Users</code> are the exported components.</p> <p>What I am expecting is to use the filtered component to render JSX data and want to send props to that component, like this:</p> <pre class="lang-html prettyprint-override"><code>&lt;component assessClicked={assessClicked} count={this.state.count} setAssessApi={this.setAssessApi} /&gt; </code></pre>
[ { "answer_id": 74401966, "author": "Gabriele Petrioli", "author_id": 128165, "author_profile": "https://Stackoverflow.com/users/128165", "pm_score": 3, "selected": true, "text": "find" }, { "answer_id": 74401991, "author": "DimitarM", "author_id": 9719646, "author_profile": "https://Stackoverflow.com/users/9719646", "pm_score": 0, "selected": false, "text": "const LineItemViewComponent = [{\n lineItem: \"AR008\",\n component: AR008Users, \n},{\n lineItem: \"AR009\",\n component: AR009Users,\n},{\n lineItem: \"AR010\",\n component: AR010Users,\n},];\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401891", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18497734/" ]
74,401,910
<p>why it wrong `</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;string.h&gt; void func(char* dest, const char* src) { dest = malloc(strlen(src) + 1); strcpy(dest, src); } int main() { char* name0; char* name1 = &quot;Jam&quot;; func(name0, name1); puts(name0); free(name0); return 0; } </code></pre> <p><code>but</code></p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;string.h&gt; struct st { char* name; }; void func(struct st* st1, const struct st* st2); int main(void) { struct st name0, name1; name1.name = &quot;Jam&quot;; func(&amp;name0, &amp;name1); puts(name0.name); free(name0.name); name0.name = NULL; exit(0); } void changename(struct st* st1, const struct st* st2) { st1-&gt;name = malloc(strlen(st2-&gt;name) + 1); if(st1-&gt;name == NULL) exit(1); strcpy(st1-&gt;name, st2-&gt;name); } </code></pre> <p>` is right</p> <p>#I tried to use the first method to explain why the second method makes sense and why the second method solves the problem, but the first one reports an error and doesn't give me the answer I want. #Why can't I malloc request memory and assign a value in a function using a string, but a string in a struct can?</p>
[ { "answer_id": 74401966, "author": "Gabriele Petrioli", "author_id": 128165, "author_profile": "https://Stackoverflow.com/users/128165", "pm_score": 3, "selected": true, "text": "find" }, { "answer_id": 74401991, "author": "DimitarM", "author_id": 9719646, "author_profile": "https://Stackoverflow.com/users/9719646", "pm_score": 0, "selected": false, "text": "const LineItemViewComponent = [{\n lineItem: \"AR008\",\n component: AR008Users, \n},{\n lineItem: \"AR009\",\n component: AR009Users,\n},{\n lineItem: \"AR010\",\n component: AR010Users,\n},];\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20210785/" ]
74,401,914
<p>Consider:</p> <pre><code>const obj = { w: true, a: true, s: true, d: true }; </code></pre> <p>Can we set all properties at once <strong>without</strong> repeating <code>true</code> every line ?</p> <p>And not something like this:</p> <pre><code>let obj = {}; obj.a = obj.w = obj.d = obj.w = true; </code></pre>
[ { "answer_id": 74402007, "author": "Ben Aston", "author_id": 38522, "author_profile": "https://Stackoverflow.com/users/38522", "pm_score": 2, "selected": true, "text": "Object.fromEntries" }, { "answer_id": 74402017, "author": "Tushar Shahi", "author_id": 10140124, "author_profile": "https://Stackoverflow.com/users/10140124", "pm_score": -1, "selected": false, "text": "const addMultipleSameProperties = (obj,keys = [],val = undefined) => {\nkeys.forEach((x) => {\n obj[x] = val \n});\n};\n\nlet obj = {};\naddMultipleSameProperties(obj,['a','w','d'],true);\nconsole.log(obj);" }, { "answer_id": 74402024, "author": "Andrew Parks", "author_id": 5898421, "author_profile": "https://Stackoverflow.com/users/5898421", "pm_score": 1, "selected": false, "text": "const obj = Object.fromEntries([...'wasd'].map(i=>[i,true]));\nconsole.log(obj);" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401914", "https://Stackoverflow.com", "https://Stackoverflow.com/users/779111/" ]
74,401,915
<p>I notice there is a macro <code>uint4korr</code> in the MySQL/MariaDB source code.</p> <blockquote> <p>include/byte_order_generic.h</p> </blockquote> <p>I merely understand this macro is correlated with byte order. But I looked for the comments about this macro, found nothing. I don't know the meaning of the suffix <code>korr</code>. What does the abbreviation express?</p> <p>I want to know why the code implements like this? What are the effects on different platforms?</p>
[ { "answer_id": 74427774, "author": "Marko Mäkelä", "author_id": 7365572, "author_profile": "https://Stackoverflow.com/users/7365572", "pm_score": 1, "selected": false, "text": "uint4korr()" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401915", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7210223/" ]
74,401,986
<p>I have two tables. First table is</p> <pre><code>Category Date Sales_1 Extra Soft Chew Bottle 67g 2022-02-09 2091847.8100 Eclipse Mint Pocket 17g 2022-02-09 1.6000 Wrigleys Eclipse Gum S/F 4pk 56g 2022-02-09 597003.4900 Eclipse Chewy Mints Bottle 93g 2022-02-09 1533084.3100 WRIGLEYS EXTRA S/F PRO 3 PACK 2022-02-09 3.5000 Eclipse Chewy Mint Pouch 70g 2022-02-09 3.0000 </code></pre> <p>2nd table is</p> <pre><code>Category Date Sales_2 Eclipse Mint Pocket 17g 2022-02-09 0.8000 Wrigleys Eclipse Gum S/F 4pk 56g 2022-02-09 131965.9200 Eclipse Chewy Mints Bottle 93g 2022-02-09 1890319.4700 Extra Active 28 pc 54g 2022-02-09 2.1600 Extra Soft Chew Bottle 67g 2022-02-09 2371403.1900 </code></pre> <p>If i do full outer join on category from table 1 and table 2 on category. i.e.</p> <pre><code> Category Date Sales_1 Sales_2 Extra Soft Chew Bottle 67g 2022-02-09 2091847.8100 2371403.1900 Eclipse Mint Pocket 17g 2022-02-09 1.6000 0.8000 Wrigleys Eclipse Gum S/F 4pk 56g 2022-02-09 597003.4900 131965.9200 Eclipse Chewy Mint Pouch 70g 2022-02-09 3.0000 WRIGLEYS EXTRA S/F PRO 3 PACK 2022-02-09 3.5000 Null Null Null 2.1600 Eclipse Chewy Mints Bottle 93g 2022-02-09 1533084.3100 1890319.4700 </code></pre> <p>Eclipse Chewy Mints Bottle 93g,2022-02-09,1533084.3100,1890319.4700</p> <p>It's not including below value in the about output</p> <pre><code>Category Date Sales_2 Extra Active 28 pc 54g 2022-02-09 2.1600 </code></pre> <p>Can anyone help me with this?</p>
[ { "answer_id": 74427774, "author": "Marko Mäkelä", "author_id": 7365572, "author_profile": "https://Stackoverflow.com/users/7365572", "pm_score": 1, "selected": false, "text": "uint4korr()" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74401986", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18158837/" ]
74,402,004
<p>We are using the Azure DevOps server 2019 and we created agent pool and configure two agents in single server. Now my problem is when am trying to run the two pipelines on this pool parallel, anyone of them cancelling after few minutes with error: The operation was cancelled without any logs. I don't know why it is happening. Single job is running successfully but on parallel jobs, anyone pipeline failing with above error. Is this cause because of running two agents in single server, building on single msbuild. Please someone help me on this. Attaching few pipeline screenshots. Thank you.<a href="https://i.stack.imgur.com/x4jF5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/x4jF5.png" alt="enter image description here" /></a></p> <p><a href="https://i.stack.imgur.com/VJ3W5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VJ3W5.png" alt="enter image description here" /></a></p> <p><a href="https://i.stack.imgur.com/U4efe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/U4efe.png" alt="enter image description here" /></a></p> <p><strong>Please find the below system.debug logs of two different pipelines failed with same error:</strong></p> <pre><code>##[debug]Re-evaluate condition on job cancellation for step: 'Build solution **/*.sln'. ##[debug]Leaving Get-SolutionFiles. ##[debug]Leaving C:\agents\w1\_tasks\MSBuild_c6c4c611-aa2e-4a33-b606-5eaba2196824\1.166.2\MSBuild.ps1. ##[error]The operation was canceled. ##[debug]System.OperationCanceledException: The operation was canceled. at System.Threading.CancellationToken.ThrowOperationCanceledException() at Microsoft.VisualStudio.Services.Agent.Util.ProcessInvoker.ExecuteAsync(String workingDirectory, String fileName, String arguments, IDictionary`2 environment, Boolean requireExitCodeZero, Encoding outputEncoding, Boolean killProcessOnCancel, InputQueue`1 redirectStandardIn, Boolean inheritConsoleHandler, Boolean keepStandardInOpen, Boolean highPriorityProcess, CancellationToken cancellationToken) at Microsoft.VisualStudio.Services.Agent.ProcessInvokerWrapper.ExecuteAsync(String workingDirectory, String fileName, String arguments, IDictionary`2 environment, Boolean requireExitCodeZero, Encoding outputEncoding, Boolean killProcessOnCancel, InputQueue`1 redirectStandardIn, Boolean inheritConsoleHandler, Boolean keepStandardInOpen, Boolean highPriorityProcess, CancellationToken cancellationToken) at Microsoft.VisualStudio.Services.Agent.Worker.Handlers.DefaultStepHost.ExecuteAsync(String workingDirectory, String fileName, String arguments, IDictionary`2 environment, Boolean requireExitCodeZero, Encoding outputEncoding, Boolean killProcessOnCancel, Boolean inheritConsoleHandler, CancellationToken cancellationToken) at Microsoft.VisualStudio.Services.Agent.Worker.Handlers.PowerShell3Handler.RunAsync() at Microsoft.VisualStudio.Services.Agent.Worker.TaskRunner.RunAsync() at Microsoft.VisualStudio.Services.Agent.Worker.StepsRunner.RunStepAsync(IStep step, CancellationToken jobCancellationToken) Finishing: Build solution **/*.sln </code></pre> <pre><code>##[debug] C:\agents\w1\106\s\ClientApp\node_modules\faker\lib\locales\de_CH\name (directory) ##[error]The operation was canceled. ##[debug]System.OperationCanceledException: The operation was canceled. at System.Threading.CancellationToken.ThrowOperationCanceledException() at Microsoft.VisualStudio.Services.Agent.Util.ProcessInvoker.ExecuteAsync(String workingDirectory, String fileName, String arguments, IDictionary`2 environment, Boolean requireExitCodeZero, Encoding outputEncoding, Boolean killProcessOnCancel, InputQueue`1 redirectStandardIn, Boolean inheritConsoleHandler, Boolean keepStandardInOpen, Boolean highPriorityProcess, CancellationToken cancellationToken) at Microsoft.VisualStudio.Services.Agent.ProcessInvokerWrapper.ExecuteAsync(String workingDirectory, String fileName, String arguments, IDictionary`2 environment, Boolean requireExitCodeZero, Encoding outputEncoding, Boolean killProcessOnCancel, InputQueue`1 redirectStandardIn, Boolean inheritConsoleHandler, Boolean keepStandardInOpen, Boolean highPriorityProcess, CancellationToken cancellationToken) at Microsoft.VisualStudio.Services.Agent.Worker.Handlers.DefaultStepHost.ExecuteAsync(String workingDirectory, String fileName, String arguments, IDictionary`2 environment, Boolean requireExitCodeZero, Encoding outputEncoding, Boolean killProcessOnCancel, Boolean inheritConsoleHandler, CancellationToken cancellationToken) at Microsoft.VisualStudio.Services.Agent.Worker.Handlers.NodeHandler.RunAsync() at Microsoft.VisualStudio.Services.Agent.Worker.TaskRunner.RunAsync() at Microsoft.VisualStudio.Services.Agent.Worker.StepsRunner.RunStepAsync(IStep step, CancellationToken jobCancellationToken) Finishing: NuGet restore </code></pre>
[ { "answer_id": 74429298, "author": "Dou Xu-MSFT", "author_id": 20288521, "author_profile": "https://Stackoverflow.com/users/20288521", "pm_score": -1, "selected": false, "text": "System.Debug" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402004", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18153277/" ]
74,402,008
<p>I'm looking to name my menu options, it currently looks like this -</p> <pre><code>1) Option 1 2) Option 2 3) Option 3 4) Quit </code></pre> <p>I tried adding menu descriptions by editing the following but it returns no results when you enter a menu number</p> <pre><code>options=(&quot;Option 1 - Search with no date filter. SLOW!!&quot; &quot;Option 2 - Search via year&quot; &quot;Option 3 - Full date search&quot; &quot;Quit&quot;) </code></pre> <p>I would like it to look like this -</p> <pre><code>1) Option 1 - Search with no date filter. SLOW!! 2) Option 2 - Search via year 3) Option 3 - Full date search 4) Quit </code></pre> <p>Full script -</p> <pre><code>#!/bin/bash echo &quot;&quot; PS3='Please enter your choice: ' echo &quot;&quot; #options=(&quot;Option 1 - Search with no date filter. SLOW!!&quot; &quot;Option 2 - Search via year&quot; &quot;Option 3 - Full date search&quot; &quot;Quit&quot;) options=(&quot;Option 1&quot; &quot;Option 2&quot; &quot;Option 3&quot; &quot;Quit&quot;) echo &quot;&quot; select opt in &quot;${options[@]}&quot; do case $opt in &quot;Option 1&quot;) echo &quot;&quot; echo Please enter the telephone number? echo &quot;&quot; read vartel echo &quot;&quot; grep -e $vartel /root/hourly/cdr_export-hourly-*.csv echo &quot;&quot; ;; &quot;Option 2&quot;) echo &quot;&quot; echo Please enter the telephone number? echo &quot;&quot; read vartel echo &quot;&quot; echo Please enter the last two year digits? echo &quot;&quot; read varyear echo &quot;&quot; grep -e $vartel /root/hourly/cdr_export-hourly-$varyear*.csv echo &quot;&quot; ;; &quot;Option 3&quot;) echo &quot;&quot; echo Please enter the telephone number? echo &quot;&quot; read vartel echo &quot;&quot; echo Please enter the last two year digits? echo &quot;&quot; read varyear echo &quot;&quot; echo Please enter the month? echo &quot;&quot; read varmonth echo &quot;&quot; echo Please enter the day? echo &quot;&quot; read varday echo &quot;&quot; grep -e $vartel /root/hourly/cdr_export-hourly-$varyear-$varmonth-$varday*.csv echo &quot;&quot; ;; &quot;Quit&quot;) break ;; *) echo &quot;invalid option $REPLY&quot;;; esac done </code></pre>
[ { "answer_id": 74403729, "author": "user8811698", "author_id": 8811698, "author_profile": "https://Stackoverflow.com/users/8811698", "pm_score": 0, "selected": false, "text": "case" }, { "answer_id": 74404518, "author": "Bach Lien", "author_id": 3973676, "author_profile": "https://Stackoverflow.com/users/3973676", "pm_score": 2, "selected": true, "text": "case \"$opt\" in\n \"Option 1\"*)\n ...\n ;;\n \"Option 2\"*)\n ...\n ;;\n \"Quit\")\n break\n ;;\n *)\n ...\n ;;\nesac\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402008", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18485470/" ]
74,402,019
<p><a href="https://i.stack.imgur.com/XzVQZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XzVQZ.png" alt="enter image description here" /></a></p> <p>I created a <code>TextFormField</code> forms and not all of them get validated.</p> <p>My code:</p> <pre><code>Form( key: _formKey, child: TextFormField( key: ValueKey('email'), decoration: InputDecoration( hintText: 'Email Address', enabledBorder: OutlineInputBorder( borderSide: BorderSide(color: Colors.white38, width: 2), ), contentPadding: EdgeInsets.fromLTRB(20, 10.0, 20, 10.0), hintStyle: const TextStyle( fontSize: 18, color: Colors.white, ), focusedBorder: OutlineInputBorder( borderSide: BorderSide(color: Colors.white, width: 2) ), </code></pre>
[ { "answer_id": 74403729, "author": "user8811698", "author_id": 8811698, "author_profile": "https://Stackoverflow.com/users/8811698", "pm_score": 0, "selected": false, "text": "case" }, { "answer_id": 74404518, "author": "Bach Lien", "author_id": 3973676, "author_profile": "https://Stackoverflow.com/users/3973676", "pm_score": 2, "selected": true, "text": "case \"$opt\" in\n \"Option 1\"*)\n ...\n ;;\n \"Option 2\"*)\n ...\n ;;\n \"Quit\")\n break\n ;;\n *)\n ...\n ;;\nesac\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16243078/" ]
74,402,070
<pre><code>&gt; library(zoo) Attaching package: ‘zoo’ The following objects are masked from ‘package:base’: as.Date, as.Date.numeric &gt; z =c(NA,NA,1,2,3) &gt; rollapply(z,width=2,max,fill=NA,align=&quot;r&quot;,na.rm=T) [1] NA -Inf 1 2 3 Warning message: In FUN(data[posns], ...) : no non-missing arguments to max; returning -Inf &gt; </code></pre> <p>I do understand that the max of an empty set is -Inf. This is mentioned in ?max.</p> <p>That explains why the rollapply at the <em><strong>second</strong></em> position is -Inf. I think that at the second position, we remove the 2 NA's on position 1 and 2, and we are left with an empty set and hence the max is -Inf.</p> <p>My query is : Why is the rollapply at the first position NA?</p> <p>Should it also not be -Inf? Can someone please explain? What is the rationale behind it ?</p>
[ { "answer_id": 74403729, "author": "user8811698", "author_id": 8811698, "author_profile": "https://Stackoverflow.com/users/8811698", "pm_score": 0, "selected": false, "text": "case" }, { "answer_id": 74404518, "author": "Bach Lien", "author_id": 3973676, "author_profile": "https://Stackoverflow.com/users/3973676", "pm_score": 2, "selected": true, "text": "case \"$opt\" in\n \"Option 1\"*)\n ...\n ;;\n \"Option 2\"*)\n ...\n ;;\n \"Quit\")\n break\n ;;\n *)\n ...\n ;;\nesac\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402070", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2338823/" ]
74,402,072
<p><em>I want to know how can I make An Entry Accept Decimal Numbers ONLY</em></p> <p>python tkinter programming</p>
[ { "answer_id": 74403729, "author": "user8811698", "author_id": 8811698, "author_profile": "https://Stackoverflow.com/users/8811698", "pm_score": 0, "selected": false, "text": "case" }, { "answer_id": 74404518, "author": "Bach Lien", "author_id": 3973676, "author_profile": "https://Stackoverflow.com/users/3973676", "pm_score": 2, "selected": true, "text": "case \"$opt\" in\n \"Option 1\"*)\n ...\n ;;\n \"Option 2\"*)\n ...\n ;;\n \"Quit\")\n break\n ;;\n *)\n ...\n ;;\nesac\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402072", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17273618/" ]
74,402,087
<p>i am trying to remove the 5th and sixth item of each line of my csv file each line is a list but when i am trying to run it i am getting a (DataFrame constructor not properly called!) error please help <a href="https://i.stack.imgur.com/pu5r2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pu5r2.png" alt="this is my csv file " /></a><a href="https://i.stack.imgur.com/yURrq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yURrq.png" alt="this is my code" /></a></p> <p>i have tried everything i can but i cant find a simple way to remove the last 2 items of every list and then after this i want to add 2 items onto every list with a random int between diffent numbers .</p>
[ { "answer_id": 74403729, "author": "user8811698", "author_id": 8811698, "author_profile": "https://Stackoverflow.com/users/8811698", "pm_score": 0, "selected": false, "text": "case" }, { "answer_id": 74404518, "author": "Bach Lien", "author_id": 3973676, "author_profile": "https://Stackoverflow.com/users/3973676", "pm_score": 2, "selected": true, "text": "case \"$opt\" in\n \"Option 1\"*)\n ...\n ;;\n \"Option 2\"*)\n ...\n ;;\n \"Quit\")\n break\n ;;\n *)\n ...\n ;;\nesac\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402087", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20477424/" ]
74,402,092
<p>I have the following table (ID column exists but not shown below) :</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Email</th> <th>Course</th> <th>DateComplete</th> </tr> </thead> <tbody> <tr> <td>1@1.com</td> <td>Running</td> <td>01/01/2021</td> </tr> <tr> <td>1@1.com</td> <td>Running</td> <td></td> </tr> <tr> <td>1@1.com</td> <td>Running</td> <td></td> </tr> <tr> <td>2@2.com</td> <td>Walking</td> <td></td> </tr> <tr> <td>2@2.com</td> <td>Walking</td> <td></td> </tr> <tr> <td>2@2.com</td> <td>Walking</td> <td></td> </tr> </tbody> </table> </div> <p>I'd like to know if it is possible to delete all duplicate (of Email&amp;Course) records from my table, but also ensuring that no records with a value in DateComplete are deleted.</p> <p>So after running the query I would have :</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Email</th> <th>Course</th> <th>DateComplete</th> </tr> </thead> <tbody> <tr> <td>1@1.com</td> <td>Running</td> <td>01/01/2021</td> </tr> <tr> <td>2@2.com</td> <td>Walking</td> <td></td> </tr> </tbody> </table> </div>
[ { "answer_id": 74402196, "author": "Barbaros Özhan", "author_id": 5841306, "author_profile": "https://Stackoverflow.com/users/5841306", "pm_score": 2, "selected": true, "text": "SELECT Email, Course, MAX(DateComplete) AS DateComplete\n INTO [dbo].[new_table]\n FROM [dbo].[current_table]\n GROUP BY Email, Course \n" }, { "answer_id": 74402652, "author": "Gustav", "author_id": 3527297, "author_profile": "https://Stackoverflow.com/users/3527297", "pm_score": 0, "selected": false, "text": "Public Function DeleteDupes()\n\n Const Sql As String = \"Select * From Course Order By Email, Course, DateComplete Desc\"\n \n Dim Records As DAO.Recordset\n Dim Values As String\n \n Set Records = CurrentDb.OpenRecordset(Sql)\n \n While Not Records.EOF\n If Values <> Records!Email.Value & Records!Course.Value Then\n Values = Records!Email.Value & Records!Course.Value\n Else\n Records.Delete\n End If\n Records.MoveNext\n Wend\n Records.Close\n \nEnd Function\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402092", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1936588/" ]
74,402,097
<p>I am trying to download some plots as images and these are being downloaded as blank images. The direct download works but the download through the drive shows blank images. ANY HELP WOULD BE HIGHLY APPRECIATED PLEASE.</p> <p>If I try to directly download the image, it is as expected, however, if I try through collab, it downloads the blank image. The concern is, I must try this method, I need to create a dataset and direct download is useless in this scenario. This is my code:</p> <p>''' # MTF transformation, CONVERSION PROCESS mtf = MarkovTransitionField(image_size =24) X_mtf = mtf.fit_transform(df_sittingcolAx)</p> <pre><code># Show the image for the first time series plt.figure(figsize =(5, 5)) plt.imshow(X_mtf[0], CMap ='rainbow') plt.title('Markov Transition Field', fontsize =18) plt.colorbar(fraction =0.0457, pad =0.04) plt.tight_layout() plt.savefig(&quot;eee.png&quot;) plt.show() from google.colab import drive drive.mount('/content/gdrive') !touch &quot;/content/gdrive/MyDrive/eee.png&quot; from google.colab import files files.download('/content/sample_data/eee.png') </code></pre> <pre><code></code></pre>
[ { "answer_id": 74408523, "author": "Nilesh Kumar", "author_id": 4572293, "author_profile": "https://Stackoverflow.com/users/4572293", "pm_score": 0, "selected": false, "text": "plt.show()" }, { "answer_id": 74416177, "author": "Sehr Malik", "author_id": 12493432, "author_profile": "https://Stackoverflow.com/users/12493432", "pm_score": 1, "selected": false, "text": "plt.savefig(\"eee.png\") \ndrive.mount('/content/gdrive')\n!touch \"/content/gdrive/MyDrive/eee.png\"\nfrom google.colab import files\nfiles.download('/content/sample_data/eee.png')\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402097", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12493432/" ]
74,402,102
<pre><code>double timespec_delta2milliseconds(struct timespec *last, struct timespec *previous) { return (last-&gt;tv_sec - previous-&gt;tv_sec) + (last-&gt;tv_nsec - previous-&gt;tv_nsec)*pow(10,-3); } </code></pre> <p>This function computes the difference (last - previous) and returns the result expressed in milliseconds as a double. I tried a lot of different ways but if I don't do like this i receve in output segmentation fault. I think that this solution works but it's wrong, someone can help me ?</p>
[ { "answer_id": 74402174, "author": "Some programmer dude", "author_id": 440558, "author_profile": "https://Stackoverflow.com/users/440558", "pm_score": 2, "selected": false, "text": "timespec" }, { "answer_id": 74404612, "author": "Jonathan Leffler", "author_id": 15168, "author_profile": "https://Stackoverflow.com/users/15168", "pm_score": 1, "selected": true, "text": "sub_timespec()" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402102", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14444540/" ]
74,402,108
<p>I have many snowflake table which multiple columns with datatype TEXT or varchar having NULL values. I wanted to replace all the NULL values to empty string or blank at table level. I am looking for a way apart from NULLIF and COALESCE as they will work at column level and it is not feasible to specify 100's of columns.</p> <p>Sample data :</p> <pre><code> A B C D 1 test NULL NULL 99 NULL test test </code></pre> <p>Desired output :</p> <pre><code> A B C D 1 test 99 test test </code></pre>
[ { "answer_id": 74402174, "author": "Some programmer dude", "author_id": 440558, "author_profile": "https://Stackoverflow.com/users/440558", "pm_score": 2, "selected": false, "text": "timespec" }, { "answer_id": 74404612, "author": "Jonathan Leffler", "author_id": 15168, "author_profile": "https://Stackoverflow.com/users/15168", "pm_score": 1, "selected": true, "text": "sub_timespec()" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402108", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10974358/" ]
74,402,113
<p>I want to get middle of the users screen while in activity and I tried to convert DisplayMetrics to Float. The error says &quot;Unresolved reference.&quot; How do I get Float from DisplayPixels? Heres my code:</p> <pre><code>val dpFloat = dp.toFloat() </code></pre> <p>I wanted to get Float from DisplayMetrics.</p>
[ { "answer_id": 74402404, "author": "Ignacio E. Loyola", "author_id": 12893649, "author_profile": "https://Stackoverflow.com/users/12893649", "pm_score": 1, "selected": false, "text": "val scale = resources.displayMetrics.density\nval dpToFloat = (sizeInDp * scale)\n" }, { "answer_id": 74404417, "author": "Masoud Karimi", "author_id": 11055151, "author_profile": "https://Stackoverflow.com/users/11055151", "pm_score": 0, "selected": false, "text": "import android.content.res.Resources\nimport kotlin.math.ceil\n\nval Int.dpf: Float\n get() {\n return dp.toFloat()\n }\n\n\nval Float.dpf: Float\n get() {\n return dp.toFloat()\n }\n\nval Int.dp: Int\n get() {\n return if (this == 0) {\n 0\n } else ceil((Resources.getSystem().displayMetrics.density * this).toDouble()).toInt()\n }\n\nval Float.dp: Int\n get() {\n return if (this == 0f) {\n 0\n } else ceil((Resources.getSystem().displayMetrics.density * this).toDouble()).toInt()\n }\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402113", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20477469/" ]
74,402,123
<p>I am trying to parse a dataframe column called <code>'tags'</code> that contains a list of dicts and as an output create a list of the values of the key <code>var1</code>:</p> <p>Dataframe column 'tags' example value:</p> <pre><code>[{'var1': 'blue','var2': 123,'var3': 888},{'var1': 'red','var2': 123,'var3': 888},{'var1': 'green','var2': 123,'var3': 888}] </code></pre> <p>desired output:</p> <pre><code>['blue', 'red', 'green'] </code></pre> <p>code:</p> <pre><code>d = [{f'{k}{i}': v for i, y in enumerate(x, 1) for k, v in y.items() if k == 'var1'} for x in df['tags']] df = pd.DataFrame(d, index=df.index).sort_index(axis=1) </code></pre> <p>However this produces the following error:</p> <pre><code>Type Error: 'float' object is not iterable </code></pre> <p>I have tried converting both <code>i</code> and <code>v</code> to a string using <code>str(i)</code> and <code>str(v)</code>, however I am still getting the same error.</p> <p>What am I doing wrong?</p>
[ { "answer_id": 74402277, "author": "jezrael", "author_id": 2901002, "author_profile": "https://Stackoverflow.com/users/2901002", "pm_score": 3, "selected": true, "text": "if-else" }, { "answer_id": 74410923, "author": "G.G", "author_id": 20284103, "author_profile": "https://Stackoverflow.com/users/20284103", "pm_score": 0, "selected": false, "text": "df.tag.apply(lambda x:x['var1']).tolist()\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402123", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3045351/" ]
74,402,173
<p>I am implementing a checkout page using Laravel and Vue.js. Test cards that don't require 3D Secure work well (e.g. 4242 4242 4242 4242). Test cards that require the customer to complete 3D Secure 2 authentication (e.g. 4000000000003220) also work(The pop up shows up after I call the confirmCardSetup method).</p> <p>However, test cards that require the customer to complete 3D Secure (not 3D Secure 2) authentication (e.g. 4000000000003063) don't bring the pop up after calling the confirmCardSetup method. They are then subsequently declined on my backend with error</p> <pre><code>Your card was declined. This transaction requires authentication. </code></pre> <p>Here is my confirmCardSetup method which is supposed to bring up the pop up.</p> <pre class="lang-js prettyprint-override"><code>const result = await this.stripe.confirmCardSetup( this.intentToken.client_secret, { payment_method: { card: this.cardElement, billing_details: { name: this.frontUser.name, }, } } ); </code></pre> <p>I have tried adding off_session to false. I have also tried setting request_three_d_secure to 'any' with no luck.</p>
[ { "answer_id": 74402277, "author": "jezrael", "author_id": 2901002, "author_profile": "https://Stackoverflow.com/users/2901002", "pm_score": 3, "selected": true, "text": "if-else" }, { "answer_id": 74410923, "author": "G.G", "author_id": 20284103, "author_profile": "https://Stackoverflow.com/users/20284103", "pm_score": 0, "selected": false, "text": "df.tag.apply(lambda x:x['var1']).tolist()\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7063248/" ]
74,402,175
<p>Here is the Python code:</p> <pre class="lang-py prettyprint-override"><code>def _get_handler_by_topic_arn(topic_arn: str, event_name: str, event_message: dict): if topic_arn == CONFIG.get(&quot;MT_MAIN_SNS_TOPIC_ARN&quot;): return MT_MAIN_TOPIC_HANDLERS.get(event_name) if topic_arn == CONFIG.get(&quot;FOX_REQUEST_SNS_TOPIC_ARN&quot;): return FOX_REQUEST_TOPIC_HANDLERS.get(event_name) if topic_arn == CONFIG.get(&quot;FOX_ORDER_RESULTS_SNS_TOPIC_ARN&quot;): if event_message.get(&quot;status&quot;) and event_message.get(&quot;status&quot;) != &quot;CANCELLED&quot;: return None return FOX_ORDER_RESULTS_TOPIC_HANDLERS.get(event_name) return None </code></pre> <p>It works but I'm searching for a more efficient / elegant / simplest way to do the same. If you have any idea, I'll take it :).</p>
[ { "answer_id": 74402246, "author": "Fra93", "author_id": 4952549, "author_profile": "https://Stackoverflow.com/users/4952549", "pm_score": 1, "selected": false, "text": "def _get_handler_by_topic_arn(topic_arn: str, event_name: str, event_message: dict):\n ret_value = None\n \n # Give a better name to conds\n cond1 = topic_arn == CONFIG.get(\"MT_MAIN_SNS_TOPIC_ARN\")\n cond2 = topic_arn == CONFIG.get(\"FOX_REQUEST_SNS_TOPIC_ARN\")\n cond3 = topic_arn == CONFIG.get(\"FOX_ORDER_RESULTS_SNS_TOPIC_ARN\")\n cond4 = event_message.get(\"status\") and event_message.get(\"status\") != \"CANCELLED\"\n \n if cond1:\n ret_value = MT_MAIN_TOPIC_HANDLERS.get(event_name)\n elif cond2:\n ret_value = FOX_REQUEST_TOPIC_HANDLERS.get(event_name)\n elif cond3:\n if cond4:\n ret_value = None\n else:\n ret_value = FOX_ORDER_RESULTS_TOPIC_HANDLERS.get(event_name)\n \n return ret_value\n" }, { "answer_id": 74402252, "author": "dotheM", "author_id": 19354546, "author_profile": "https://Stackoverflow.com/users/19354546", "pm_score": 1, "selected": false, "text": "topics = {\n \"MT_MAIN_SNS_TOPIC_ARN\" : MT_MAIN_TOPIC_HANDLERS,\n \"FOX_REQUEST_SNS_TOPIC_ARN\" : FOX_REQUEST_TOPIC_HANDLERS,\n \"FOX_ORDER_RESULTS_SNS_TOPIC_ARN\" : FOX_ORDER_RESULTS_TOPIC_HANDLERS\n}\n\ndef _get_handler_by_topic_arn(topic_arn: str, event_name: str, event_message: dict):\n for k,v in topics.items():\n if topic_arn == CONFIG.get(k):\n return v.get(event_name)\n" }, { "answer_id": 74402350, "author": "Brhaka", "author_id": 11578778, "author_profile": "https://Stackoverflow.com/users/11578778", "pm_score": 3, "selected": true, "text": "if" }, { "answer_id": 74402366, "author": "Tomer Ariel", "author_id": 14004541, "author_profile": "https://Stackoverflow.com/users/14004541", "pm_score": 0, "selected": false, "text": "handler" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402175", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7123717/" ]
74,402,203
<pre><code>void draw(unsigned char *image) { for (int y = 0; y &lt; HEIGHT; y++) { for (int x = 0; x &lt; WIDTH; x++) { if (someCondition) { int red = x * 256 / WIDTH; int green = 255; int blue = y * 256 / HEIGHT; image[0] = (unsigned char)blue; image[1] = (unsigned char)green; image[2] = (unsigned char)red; } else { image[0] = 0; image[1] = 0; image[2] = 0; } image += 3; } } } </code></pre> <p>What does incrementing image+=3; actually do here. I'm trying to convert the same c++ code to C#, but unable to achieve this. I'm using byte[] image in C#, now how should I do image+=3 in C#. Is it scaling the image?</p>
[ { "answer_id": 74402295, "author": "463035818_is_not_a_number", "author_id": 4117728, "author_profile": "https://Stackoverflow.com/users/4117728", "pm_score": 3, "selected": true, "text": "unsigned char" }, { "answer_id": 74402674, "author": "Max", "author_id": 13523921, "author_profile": "https://Stackoverflow.com/users/13523921", "pm_score": 1, "selected": false, "text": "using System;\nusing System.Linq;\nusing System.Drawing;\nusing System.Drawing.Imaging;\n\nnamespace something \n{\n \n void draw(Bitmap bmp) \n {\n BitmapData data = null;\n try {\n // Returns an object of type BitmapData.\n // BitmapData object grants you access \n // to the address of the first pixel.\n data = bmp.UnlockBits(\n new Rectangle(0, 0, bmp.Width, bmp.Height),\n ImageLockMode.ReadWrite,\n bmp.PixelFormat);\n \n unsafe {\n // Byte per pixel.\n // This is really import!\n // By checking how many bytes a pixel consumes\n // you know how to increment your raw pixel data.\n int bpp = Bitmap.GetPixelFormatSize(data.PixelFormat) / 8;\n // Pointer to the first pixel.\n byte* ptFirst = (byte*)data.Scan0;\n // Using a parallel loop here \n // drastically improves performance.\n Parallel.For(0, data.Height, y => \n {\n // Get the pointer of the first pixel\n // in the current stride.\n // If you imagine your image as a table with \n // rows and columns, then this is the 'index'\n // of the row.\n // Images are built from multiple strides (rows).\n byte* pixel = ptFirst + (y * data.Stride);\n // IMPORTANT: Incrementing by byte-per-pixel \n // is crucial here as you need to skip n-bytes \n // to get to the next pixel.\n // The pixel count per stride is the\n // width multiplied by byte-per-pixel.\n for (int x=0; x<data.Stride; x+=bpp) \n {\n if (someCondition) {\n // Calc some colour values.\n byte r = (byte)(x*256/data.Width);\n byte g = byte.MaxValue;\n byte b = (byte)(y*256/data.Height);\n // Assign colour.\n pixel[x+2]=r; \n pixel[x+1]=g;\n pixel[x+0]=b;\n }\n else {\n // Set pixel to black.\n pixel[x+2]=0; \n pixel[x+1]=0;\n pixel[x+0]=0;\n }\n }\n }\n }\n }\n finally {\n if (null != data) {\n bmp.UnlockBits(data);\n }\n } \n }\n}\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402203", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5157600/" ]
74,402,206
<p>What will happen when you execute this code snippet?</p> <pre><code>#include &lt;iostream&gt; int main() { float a = 5.51; int b = static_cast&lt;int&gt;(a); std::cout &lt;&lt; b; } </code></pre> <p>Correct answer is:</p> <blockquote> <p>5 will be printed on standard output, with no compilation warnings generated.</p> </blockquote> <p>But for me would make more sense to generate compilation warning as precision would be lost. Why not?</p>
[ { "answer_id": 74402295, "author": "463035818_is_not_a_number", "author_id": 4117728, "author_profile": "https://Stackoverflow.com/users/4117728", "pm_score": 3, "selected": true, "text": "unsigned char" }, { "answer_id": 74402674, "author": "Max", "author_id": 13523921, "author_profile": "https://Stackoverflow.com/users/13523921", "pm_score": 1, "selected": false, "text": "using System;\nusing System.Linq;\nusing System.Drawing;\nusing System.Drawing.Imaging;\n\nnamespace something \n{\n \n void draw(Bitmap bmp) \n {\n BitmapData data = null;\n try {\n // Returns an object of type BitmapData.\n // BitmapData object grants you access \n // to the address of the first pixel.\n data = bmp.UnlockBits(\n new Rectangle(0, 0, bmp.Width, bmp.Height),\n ImageLockMode.ReadWrite,\n bmp.PixelFormat);\n \n unsafe {\n // Byte per pixel.\n // This is really import!\n // By checking how many bytes a pixel consumes\n // you know how to increment your raw pixel data.\n int bpp = Bitmap.GetPixelFormatSize(data.PixelFormat) / 8;\n // Pointer to the first pixel.\n byte* ptFirst = (byte*)data.Scan0;\n // Using a parallel loop here \n // drastically improves performance.\n Parallel.For(0, data.Height, y => \n {\n // Get the pointer of the first pixel\n // in the current stride.\n // If you imagine your image as a table with \n // rows and columns, then this is the 'index'\n // of the row.\n // Images are built from multiple strides (rows).\n byte* pixel = ptFirst + (y * data.Stride);\n // IMPORTANT: Incrementing by byte-per-pixel \n // is crucial here as you need to skip n-bytes \n // to get to the next pixel.\n // The pixel count per stride is the\n // width multiplied by byte-per-pixel.\n for (int x=0; x<data.Stride; x+=bpp) \n {\n if (someCondition) {\n // Calc some colour values.\n byte r = (byte)(x*256/data.Width);\n byte g = byte.MaxValue;\n byte b = (byte)(y*256/data.Height);\n // Assign colour.\n pixel[x+2]=r; \n pixel[x+1]=g;\n pixel[x+0]=b;\n }\n else {\n // Set pixel to black.\n pixel[x+2]=0; \n pixel[x+1]=0;\n pixel[x+0]=0;\n }\n }\n }\n }\n }\n finally {\n if (null != data) {\n bmp.UnlockBits(data);\n }\n } \n }\n}\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402206", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11381650/" ]
74,402,219
<p>normal intent isn't working in adapter class for action call. how can I make a call from my adapter class for recyclerview?</p> <pre><code> callButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String phoneNo2 = itemNumber.getText().toString(); Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse(&quot;tel:&quot; + phoneNo2)); context.startActivity(intent); } }); </code></pre> <p>I had to add this context to write startactivity..Otherwise startactivity isn't coming.</p>
[ { "answer_id": 74402301, "author": "Egor", "author_id": 543539, "author_profile": "https://Stackoverflow.com/users/543539", "pm_score": 1, "selected": false, "text": "View" }, { "answer_id": 74402427, "author": "MAYUR SANCHETI", "author_id": 12238257, "author_profile": "https://Stackoverflow.com/users/12238257", "pm_score": 0, "selected": false, "text": " // RecyclerView recyclerView; \n public MyAdapter(MyListData[] listdata) { \n\n } \n @Override \n public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { \n LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext()); \n View Itemis= layoutInflater.inflate(R.layout.your_xml_file, parent, false); \n ViewHolder viewHolder = new ViewHolder(Itemis); \n return viewHolder; \n } \n\n @Override \n public void onBindViewHolder(ViewHolder holder, int position) { \n\n } \n\n public static class ViewHolder extends RecyclerView.ViewHolder { \n public Button callbutton; \n\n public ViewHolder(View itemView) { \n super(itemView); \n this.callbutton = itemView.findViewById(R.id.callbutton); \n ///here is button clikc\n\n callButton.setOnClickListener(new View.OnClickListener() {\n @Override\n public void onClick(View v) {\n String phoneNo2 = itemNumber.getText().toString();\n Intent intent = new Intent(Intent.ACTION_CALL, \n Uri.parse(\"tel:\" + phoneNo2));\n v.context.startActivity(intent);\n }\n }); \n } \n }\n" }, { "answer_id": 74402622, "author": "Urvish Shiroya", "author_id": 20015640, "author_profile": "https://Stackoverflow.com/users/20015640", "pm_score": 0, "selected": false, "text": " <uses-permission android:name=\"android.permission.CALL_PHONE\" />\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402219", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20041390/" ]
74,402,229
<p>I'm not sure what is wrong with this mutate function. When using this line of code, it doesn't change the values to the wanted values.</p> <pre><code>dataADstudies_1639_5cols &lt;- dataADstudies_1639_5cols_2D %&gt;% mutate(Activity = if_else(Parameter == grepl('ANT_L', Parameter), &quot;Phot_Ant_TL&quot;, Activity)) </code></pre> <p>My df looks like this:</p> <pre><code> Nr Section Activity Parameter Value 44 1639_1 Day 0 Photo_2D ANT_L_Ery 18.932 45 1639_1 Day 0 Photo_2D ANT_L_EryRat 1.189 46 1639_1 Day 0 Photo_2D ANT_L_Rough 9.552 47 1639_1 Day 0 Photo_2D ANT_NL_Ery 0.583 48 1639_1 Day 0 Photo_2D ANT_NL_EryRa 0.886 49 1639_1 Day 0 Photo_2D ANT_NL_Rough 3.958 </code></pre> <p>I want to recode values in the activity column to Phot_Ant_TL when the parameter value contains ANT_L and subsequently change values in the activity column to Phot_Ant_NL when the parameter value contains ANT_NL but I think I need a separate line of code for that</p> <p>Desired result:</p> <pre><code> Nr Section Activity Parameter Value 44 1639_1 Day 0 Phot_Ant_TL ANT_L_Ery 18.932 45 1639_1 Day 0 Phot_Ant_TL ANT_L_EryRat 1.189 46 1639_1 Day 0 Phot_Ant_TL ANT_L_Rough 9.552 47 1639_1 Day 0 Phot_Ant_NL ANT_NL_Ery 0.583 48 1639_1 Day 0 Phot_Ant_NL ANT_NL_EryRa 0.886 49 1639_1 Day 0 Phot_Ant_NL ANT_NL_Rough 3.958 </code></pre>
[ { "answer_id": 74402475, "author": "C. Sebastian", "author_id": 16363941, "author_profile": "https://Stackoverflow.com/users/16363941", "pm_score": 0, "selected": false, "text": "dataADstudies_1639_5cols <- dataADstudies_1639_5cols_2D %>%\n mutate(Activity = case_when(substr(Parameter, 1 , 6) == \"ANT_NL\" ~ \"Phot_Ant_NL\", \n T ~ \"Phot_Ant_TL\"))`\n" }, { "answer_id": 74402553, "author": "Ronak Shah", "author_id": 3962914, "author_profile": "https://Stackoverflow.com/users/3962914", "pm_score": 3, "selected": true, "text": "grepl" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402229", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20477435/" ]
74,402,231
<p>Help me please.<br /> Tell me how to sum each vector in a two-dimensional vector and write the result into a one-dimensional vector. On C++.<br /> Input:</p> <pre><code>std::vector&lt;std::vector&lt;double&gt;&gt; a = { { 1, 2 }, { 3, 4 }, { 5, 6 } }; </code></pre> <p>Required Output:</p> <blockquote> <p>b = { 9, 12 }</p> </blockquote> <p>I found how to sum all the elements in a 2D vector, but I don't know how to sum the vectors in an existing 2D vector and write the result to a 1D vector</p> <pre><code>#include &lt;iostream&gt; #include &lt;vector&gt; int main() { std::vector&lt;std::vector&lt;double&gt;&gt; a = { { 1, 2 }, { 3, 4 }, { 5, 6 } }; std::vector&lt;double&gt; b; std::vector&lt;int&gt; v; int sum = 0; for (int i = 0; i &lt; a.size(); i++) for (int j = 0; j &lt; a[i].size(); j++) { sum += a[i][j]; } std::cout &lt;&lt; sum; return 0; } </code></pre>
[ { "answer_id": 74402318, "author": "rturrado", "author_id": 260313, "author_profile": "https://Stackoverflow.com/users/260313", "pm_score": 1, "selected": false, "text": "b" }, { "answer_id": 74402348, "author": "wohlstad", "author_id": 18519921, "author_profile": "https://Stackoverflow.com/users/18519921", "pm_score": 3, "selected": true, "text": "i" }, { "answer_id": 74402597, "author": "463035818_is_not_a_number", "author_id": 4117728, "author_profile": "https://Stackoverflow.com/users/4117728", "pm_score": 1, "selected": false, "text": "std::accumulate" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402231", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20477416/" ]
74,402,236
<p>I am new to Programming and got stuck in it. I wanted to calculate the hourly temperature variation of an object throughout the year using some variables, which changes in every hour. The original data contains 60 columns and 8760 rows for the calculation.</p> <p>I got the desired output using the <code>for</code> loop, but the model is taking a lot of time for the calculation. I wonder if there is any way to replace the loop with functions, which I suspect, can also increase the speed of the calculations.</p> <p>Here is a small reproducible example to show what I did.</p> <pre><code>table &lt;- data.table(&quot;A&quot; = c(1), &quot;B&quot; = c(1:5), &quot;C&quot; = c(10)) table </code></pre> <pre><code> A B C 1: 1 1 10 2: 1 2 10 3: 1 3 10 4: 1 4 10 5: 1 5 10 </code></pre> <p>The <code>for</code>loop</p> <pre><code>for (j in (2: nrow(table))) { table$A[j] = (table$A[j-1] + table$B[j-1]) * table$B[j] table$C[j] = table$B[j] * table$A[j] } </code></pre> <p>I got the output as I desired:</p> <pre><code> A B C 1: 1 1 10 2: 4 2 8 3: 18 3 54 4: 84 4 336 5: 440 5 2200 </code></pre> <p>but it took 15 min to run the whole program in my case (not this!)</p> <p>So I tried to use function instead of the <code>for</code> loop.</p> <p>I tried this:</p> <pre><code>table &lt;- data.table(&quot;A&quot; = c(1), &quot;B&quot; = c(1:5), &quot;C&quot; = c(10)) myfun &lt;- function(df){ df = df %&gt;% mutate(A = (lag(A) + lag(B)) * B, C = B * A) return(df) } myfun(table) </code></pre> <p>But the output was</p> <pre><code> A B C 1 NA 1 NA 2 4 2 8 3 9 3 27 4 16 4 64 5 25 5 125 </code></pre> <p>As it seems that the function refers to the rows of the first table not the updated rows after the calculation. Is there any way to obtain the desired output using functions? It is my first R project, any help is very much appreciated. Thank you.</p>
[ { "answer_id": 74402743, "author": "Santiago", "author_id": 13507658, "author_profile": "https://Stackoverflow.com/users/13507658", "pm_score": 1, "selected": false, "text": "purrr::accumulate2" }, { "answer_id": 74403067, "author": "sindri_baldur", "author_id": 4552295, "author_profile": "https://Stackoverflow.com/users/4552295", "pm_score": 2, "selected": false, "text": "data.table" }, { "answer_id": 74403227, "author": "ThomasIsCoding", "author_id": 12158757, "author_profile": "https://Stackoverflow.com/users/12158757", "pm_score": 2, "selected": false, "text": "Reduce" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402236", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20476539/" ]
74,402,244
<pre><code>SELECT '1000000' AS number UNION ALL SELECT '541' AS number UNION ALL SELECT '-500' AS number UNION ALL SELECT '100' AS number UNION ALL SELECT number, 'biggest' AS result WHERE number = 1000000 </code></pre> <p>How to make this work? My task is to find the biggest number from those that I added.</p> <pre><code>SELECT '1000000' AS number UNION ALL SELECT '541' AS number UNION ALL SELECT '-500' AS number UNION ALL SELECT '100' AS number UNION ALL SELECT number, 'biggest' AS result WHERE number = 1000000 </code></pre> <p>How to make this work? My task is to find the biggest number from those that I added.</p>
[ { "answer_id": 74402355, "author": "a_horse_with_no_name", "author_id": 330315, "author_profile": "https://Stackoverflow.com/users/330315", "pm_score": 1, "selected": false, "text": "select *\nfrom (\n SELECT 1000000 AS number\n UNION ALL\n SELECT 541 AS number\n UNION ALL\n SELECT -500 AS number\n UNION ALL\n SELECT 100 AS number\n)\nWHERE number = 1000000 \n" }, { "answer_id": 74402400, "author": "Venkataraman R", "author_id": 634935, "author_profile": "https://Stackoverflow.com/users/634935", "pm_score": 0, "selected": false, "text": "WITH CTE_Number AS (\nSELECT 1000000 AS number\nUNION ALL\nSELECT 541 AS number\nUNION ALL\nSELECT -500 AS number\nUNION ALL\nSELECT 100 AS number\n )\nSELECT Number,'Biggest' as result\nFROM CTE_Number\nORDER BY Number DESC\nFETCH FIRST ROW ONLY;\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402244", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20477575/" ]
74,402,285
<p>I need to loop through a multidimensional array and extract all the data:</p> <p>PHP code:</p> <pre class="lang-php prettyprint-override"><code>//Loads the data and transforms it into an array $json_data = json_decode(file_get_contents('data.json')); //Loops through the array and returns the values echo '&lt;br&gt;'.'Modal: ' .$json_data-&gt;list[0]-&gt;mode; echo '&lt;br&gt;'.'Variation: ' .$json_data-&gt;list[0]-&gt;change; foreach ($json_data-&gt;list[0]-&gt;expiry as $data) { echo '&lt;br&gt;'.'Due date: ' .$data-&gt;cdexpiry; echo '&lt;br&gt;'.'Value: ' .$data-&gt;vlexpiry; } </code></pre> <p>JSON data:</p> <pre class="lang-json prettyprint-override"><code>{ &quot;list&quot;: [ { &quot;expiry&quot;: [ { &quot;cdexpiry&quot;: &quot;v130&quot;, &quot;vlexpiry&quot;: &quot;33528.99&quot; }, { &quot;cdexpiry&quot;: &quot;v230&quot;, &quot;vlexpiry&quot;: &quot;21648.39&quot; }, { &quot;cdexpiry&quot;: &quot;v150&quot;, &quot;vlexpiry&quot;: &quot;185350.30&quot; } ], &quot;mode&quot;: &quot;0401&quot;, &quot;change&quot;: &quot;N&quot; }, { &quot;expiry&quot;: { &quot;cdexpiry&quot;: &quot;v40&quot;, &quot;vlexpiry&quot;: &quot;1091.46&quot; }, &quot;mode&quot;: &quot;1904&quot;, &quot;change&quot;: &quot;N&quot; }, { &quot;expiry&quot;: { &quot;cdexpiry&quot;: &quot;v770&quot;, &quot;vlexpiry&quot;: &quot;1001.56&quot; }, &quot;mode&quot;: &quot;1904&quot;, &quot;change&quot;: &quot;N&quot; }, { &quot;expiry&quot;: [ { &quot;cdexpiry&quot;: &quot;v130&quot;, &quot;vlexpiry&quot;: &quot;2084.08&quot; }, { &quot;cdexpiry&quot;: &quot;v260&quot;, &quot;vlexpiry&quot;: &quot;28362.31&quot; } ], &quot;mode&quot;: &quot;0213&quot;, &quot;change&quot;: &quot;N&quot; }, { &quot;expiry&quot;: { &quot;cdexpiry&quot;: &quot;v210&quot;, &quot;vlexpiry&quot;: &quot;296.78&quot; }, &quot;mode&quot;: &quot;0101&quot;, &quot;change&quot;: &quot;N&quot; }, { &quot;expiry&quot;: [ { &quot;cdexpiry&quot;: &quot;v245&quot;, &quot;vlexpiry&quot;: &quot;1495.37&quot; }, { &quot;cdexpiry&quot;: &quot;v248&quot;, &quot;vlexpiry&quot;: &quot;1440.37&quot; } ], &quot;mode&quot;: &quot;0217&quot;, &quot;change&quot;: &quot;N&quot; } ], &quot;type&quot;: &quot;8&quot; } </code></pre> <p>I've used a few for's and if's - but I'm missing something.</p> <pre><code>for ($i = 0; $i &lt; count($json_data-&gt;list); $i++) { if(isset($json_data-&gt;list[$i]-&gt;expiry)) </code></pre> <p><strong>Desired Outcome</strong></p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th><strong>Type</strong></th> <th>Value</th> </tr> </thead> <tbody> <tr> <td><strong>Modal</strong></td> <td><strong>0401</strong></td> </tr> <tr> <td><strong>Variation</strong></td> <td><strong>N</strong></td> </tr> <tr> <td>Due date</td> <td>v130</td> </tr> <tr> <td>Value</td> <td>33528.99</td> </tr> <tr> <td>Due date</td> <td>v230</td> </tr> <tr> <td>Value</td> <td>21648.39</td> </tr> <tr> <td>Due date</td> <td>v150</td> </tr> <tr> <td>Value</td> <td>185350.30</td> </tr> <tr> <td><strong>---</strong></td> <td><strong>---</strong></td> </tr> <tr> <td><strong>Modal</strong></td> <td><strong>1904</strong></td> </tr> <tr> <td><strong>Variation</strong></td> <td><strong>N</strong></td> </tr> <tr> <td>Due date</td> <td>V40</td> </tr> <tr> <td>Value</td> <td>1091.46</td> </tr> <tr> <td>Due date</td> <td>v770</td> </tr> <tr> <td>Value</td> <td>1001.56</td> </tr> <tr> <td><strong>---</strong></td> <td><strong>---</strong></td> </tr> <tr> <td><strong>Modal</strong></td> <td><strong>0213</strong></td> </tr> <tr> <td><strong>Variation</strong></td> <td><strong>N</strong></td> </tr> <tr> <td>Due date</td> <td>v130</td> </tr> <tr> <td>Value</td> <td>2084.08</td> </tr> <tr> <td>Due date</td> <td>v260</td> </tr> <tr> <td>Value</td> <td>28362.31</td> </tr> <tr> <td><strong>---</strong></td> <td><strong>---</strong></td> </tr> <tr> <td><strong>Modal</strong></td> <td><strong>0101</strong></td> </tr> <tr> <td><strong>Variation</strong></td> <td><strong>N</strong></td> </tr> <tr> <td>Due date</td> <td>V210</td> </tr> <tr> <td>Value</td> <td>296.78</td> </tr> <tr> <td><strong>---</strong></td> <td><strong>---</strong></td> </tr> <tr> <td><strong>Modal</strong></td> <td><strong>0217</strong></td> </tr> <tr> <td><strong>Variation</strong></td> <td><strong>N</strong></td> </tr> <tr> <td>Due date</td> <td>V245</td> </tr> <tr> <td>Value</td> <td>1495.37</td> </tr> <tr> <td>Due date</td> <td>V248</td> </tr> <tr> <td>Value</td> <td>1440.37</td> </tr> </tbody> </table> </div><hr /> <h2>This is the original XML query return file <a href="https://drive.google.com/file/d/1odW2Ctt5d3Z_07VoWkiE2_ltscP7_vRi/view?usp=sharing" rel="nofollow noreferrer">link</a></h2> <p>I need to extract all the data from the array to be able to manipulate it later. I count on the masters' help!</p>
[ { "answer_id": 74402355, "author": "a_horse_with_no_name", "author_id": 330315, "author_profile": "https://Stackoverflow.com/users/330315", "pm_score": 1, "selected": false, "text": "select *\nfrom (\n SELECT 1000000 AS number\n UNION ALL\n SELECT 541 AS number\n UNION ALL\n SELECT -500 AS number\n UNION ALL\n SELECT 100 AS number\n)\nWHERE number = 1000000 \n" }, { "answer_id": 74402400, "author": "Venkataraman R", "author_id": 634935, "author_profile": "https://Stackoverflow.com/users/634935", "pm_score": 0, "selected": false, "text": "WITH CTE_Number AS (\nSELECT 1000000 AS number\nUNION ALL\nSELECT 541 AS number\nUNION ALL\nSELECT -500 AS number\nUNION ALL\nSELECT 100 AS number\n )\nSELECT Number,'Biggest' as result\nFROM CTE_Number\nORDER BY Number DESC\nFETCH FIRST ROW ONLY;\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402285", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20452902/" ]
74,402,306
<p>How can I avoid doing embarrassing stuff like this when trying to apply multiple regular expressions using the <code>gsub()</code> function in jq?</p> <pre><code>.&quot;values&quot; | tostring | gsub(&quot;\&quot;&quot;;&quot;`&quot;) | gsub(&quot;\\[&quot;;&quot;&quot;) | gsub(&quot;\\]&quot;;&quot;&quot;) | gsub(&quot;=\\w*&quot;;&quot;&quot;) </code></pre> <p>I want to convert the array below to a string, keep the values to the left of the equals sign and surround each value in backticks.</p> <p>The jq command above works but something tells me there's a more elegant solution.</p> <p>Input:</p> <pre class="lang-json prettyprint-override"><code>{ &quot;values&quot;: [ &quot;1=foo&quot;, &quot;2=bar&quot;, &quot;3=baz&quot; ] } </code></pre> <p>Output (expected and actual)</p> <pre class="lang-json prettyprint-override"><code>&quot;`1`,`2`,`3`&quot; </code></pre>
[ { "answer_id": 74402394, "author": "0stone0", "author_id": 5625547, "author_profile": "https://Stackoverflow.com/users/5625547", "pm_score": 2, "selected": false, "text": "split()" }, { "answer_id": 74402648, "author": "Barbaros Özhan", "author_id": 5841306, "author_profile": "https://Stackoverflow.com/users/5841306", "pm_score": 2, "selected": true, "text": "gsub()" }, { "answer_id": 74404605, "author": "peak", "author_id": 997358, "author_profile": "https://Stackoverflow.com/users/997358", "pm_score": 0, "selected": false, "text": ".values\n| map(capture( \"(?<key>^[^=]*)=\" ).key | \"`\\(.)`\" ) \n| join(\",\")\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402306", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2409759/" ]
74,402,327
<p>I have created a click event listener then added a function in it which conatin some parameters, according to that parameters i am creating an audio element, which i play in further steps. Problem arises when i wish to pause that same audio after detecting another click, it never happens because it creates a new audio element on every click with same values and pause it, although that new audio element was never played and the first audio element created keeps playing.</p> <pre><code>let check = true; masterPlayButton.addEventListener(&quot;click&quot;, function (i) { minorPlayPause(i); }); </code></pre> <pre><code>function minorPlayPause(x) { let audio = new Audio(&quot;songs/&quot; + x + &quot;.mp3&quot;); if (check == true) { check = false; audio.play(); }; } else { check = true; audio.pause(); } } </code></pre> <p>I tried creating audio element outside the event listener so that everytime a new audio element is not created but it doesnt work because i want to create audio element according to the parameters provided from click data. Also, i tried to put another event listener inside the 'if' (as written in the provided code) to detect the pause on the same audio element, but it didnt worked. I just want to pause the same audio on second click.</p> <p>A helping hand is most appreciable !!</p>
[ { "answer_id": 74402394, "author": "0stone0", "author_id": 5625547, "author_profile": "https://Stackoverflow.com/users/5625547", "pm_score": 2, "selected": false, "text": "split()" }, { "answer_id": 74402648, "author": "Barbaros Özhan", "author_id": 5841306, "author_profile": "https://Stackoverflow.com/users/5841306", "pm_score": 2, "selected": true, "text": "gsub()" }, { "answer_id": 74404605, "author": "peak", "author_id": 997358, "author_profile": "https://Stackoverflow.com/users/997358", "pm_score": 0, "selected": false, "text": ".values\n| map(capture( \"(?<key>^[^=]*)=\" ).key | \"`\\(.)`\" ) \n| join(\",\")\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402327", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20214922/" ]
74,402,329
<p>Lets have 2 models:</p> <pre><code>class A(models.Model): f1 = models.CharField() f2 = models.IntegerField() f3 = models.BooleanField() class B(models.Model): f1 = models.CharField() f2 = models.IntegerField() f3 = models.DecimalField() </code></pre> <p>Lets have this data:</p> <pre><code>A(f1=rat, f2=100, f3=true) A(f1=cat, f2=200, f3=true) A(f1=dog, f2=300, f3=false) </code></pre> <pre><code>B(f1=eagle, f2=100, f3=3.14) B(f1=cat, f2=200, f3=9.81) B(f1=dog, f2=300, f3=100.500) </code></pre> <p>I need to select objects from table B, that does not have similar data for fields f1, f2 in table A.</p> <p>In my case it will be:</p> <pre><code>B(f1=eagle, f2=100, f3=3.14) </code></pre> <p>The following objects are not relevant, because they exist in both tables (f1 and f2 fields)</p> <pre><code>B(f1=cat, f2=200, f3=9.81) B(f1=dog, f2=300, f3=100.500) </code></pre> <p>Is it possible to select this data using Django ORM?</p> <p>I tried to find information about Sub-query, but did not find good example.</p>
[ { "answer_id": 74402394, "author": "0stone0", "author_id": 5625547, "author_profile": "https://Stackoverflow.com/users/5625547", "pm_score": 2, "selected": false, "text": "split()" }, { "answer_id": 74402648, "author": "Barbaros Özhan", "author_id": 5841306, "author_profile": "https://Stackoverflow.com/users/5841306", "pm_score": 2, "selected": true, "text": "gsub()" }, { "answer_id": 74404605, "author": "peak", "author_id": 997358, "author_profile": "https://Stackoverflow.com/users/997358", "pm_score": 0, "selected": false, "text": ".values\n| map(capture( \"(?<key>^[^=]*)=\" ).key | \"`\\(.)`\" ) \n| join(\",\")\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6287581/" ]
74,402,346
<p>I have the following data.</p> <p>The column ['time_fall_asleep-minute'] represents the minute within the hour that one falls asleep.</p> <p>The column ['time_fall_asleep-hour'] represents the hour that one falls asleep.</p> <p>I would like to combine the two columns so that it gives an hour and minute reading.</p> <p>Thus, the row at index 0 should read as follows (i.e, 12.10 am):</p> <pre><code>0 0.10 </code></pre> <p>I would be so grateful if anybody could give me a helping hand!</p> <pre><code>newerdf['time_fall_asleep-minute'] 0 10.0 1 0.0 2 0.0 3 30.0 5 10.0 ... 911 30.0 912 30.0 913 25.0 914 30.0 915 25.0 </code></pre> <pre><code>newerdf['time_fall_asleep-hour'] 0 0.0 1 2.0 2 6.0 3 0.0 5 0.0 ... 911 0.0 912 0.0 913 0.0 914 0.0 915 0.0 </code></pre>
[ { "answer_id": 74402394, "author": "0stone0", "author_id": 5625547, "author_profile": "https://Stackoverflow.com/users/5625547", "pm_score": 2, "selected": false, "text": "split()" }, { "answer_id": 74402648, "author": "Barbaros Özhan", "author_id": 5841306, "author_profile": "https://Stackoverflow.com/users/5841306", "pm_score": 2, "selected": true, "text": "gsub()" }, { "answer_id": 74404605, "author": "peak", "author_id": 997358, "author_profile": "https://Stackoverflow.com/users/997358", "pm_score": 0, "selected": false, "text": ".values\n| map(capture( \"(?<key>^[^=]*)=\" ).key | \"`\\(.)`\" ) \n| join(\",\")\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402346", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12985497/" ]
74,402,347
<p>I have a question about the function &quot;Analyse in Excel&quot; or &quot;Analyse in Excel&quot; in German when a PBI (Power BI) report has been published.</p> <p><a href="https://i.stack.imgur.com/UykvQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UykvQ.png" alt="enter image description here" /></a></p> <p>I read in a flat table in PBI and create some measures in PBI. Basically, it's about account numbers and the limits. A calculation is not necessary or possible here.</p> <p>If I now want to analyse the data in Excel Pivot Table, I can only display the measures as values. An analysis of account numbers and limits is not possible, as limits are not measures.</p> <p>What do I have to do to be able to select original data as values?</p> <p>Thank you very much for your feedback and best regards Andi</p>
[ { "answer_id": 74402394, "author": "0stone0", "author_id": 5625547, "author_profile": "https://Stackoverflow.com/users/5625547", "pm_score": 2, "selected": false, "text": "split()" }, { "answer_id": 74402648, "author": "Barbaros Özhan", "author_id": 5841306, "author_profile": "https://Stackoverflow.com/users/5841306", "pm_score": 2, "selected": true, "text": "gsub()" }, { "answer_id": 74404605, "author": "peak", "author_id": 997358, "author_profile": "https://Stackoverflow.com/users/997358", "pm_score": 0, "selected": false, "text": ".values\n| map(capture( \"(?<key>^[^=]*)=\" ).key | \"`\\(.)`\" ) \n| join(\",\")\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402347", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8119797/" ]
74,402,361
<p>How can I change my SVG path to width: 7.58 and height: 16.62. (7.58x16.62)?</p> <p>My SVG icon is 19x19px but I'm looking to change the SVG PATH to width: 7.58 and height: 16.62.</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>svg { border: 1px solid black; width: 19px; height: 19px; } div { margin-left: 10px; width: 170px; height: 170px; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;svg width="19" height="19" viewBox="0 0 19 19" fill="none" xmlns="http://www.w3.org/2000/svg"&gt; &lt;path d="M1.01099 5.36841L8.42124 12.5263L16.2215 5.36841" stroke="#111111" stroke-linecap="round" stroke-linejoin="round"/&gt; &lt;/svg&gt;</code></pre> </div> </div> </p> <p>Currently my SVG path size is 15.21x7.16 and I need to make the svg path size width: 7.58 and height: 16.62.</p> <p>![jsfiddle svg path incorrect should be the other way around, with the correct values][1]</p> <p><a href="https://i.stack.imgur.com/1InxN.png" rel="nofollow noreferrer">https://i.stack.imgur.com/1InxN.png</a></p>
[ { "answer_id": 74402925, "author": "Dave Pritlove", "author_id": 2005666, "author_profile": "https://Stackoverflow.com/users/2005666", "pm_score": 1, "selected": false, "text": "svg" }, { "answer_id": 74414336, "author": "Frank Z.", "author_id": 8414010, "author_profile": "https://Stackoverflow.com/users/8414010", "pm_score": 0, "selected": false, "text": "scale x factor: 7.58 / 15.21 = 0.4983563445101907" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402361", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
74,402,364
<p>I got this type of sport activity data in excel: <a href="https://i.stack.imgur.com/WQsMv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WQsMv.png" alt="sports data" /></a> I try to pull just a &quot;calorie&quot; value from column D to another cell. Any suggestions how to pull this data?</p> <p>Tried to do it by =MID function, but those strings are different length. Any suggestions how to pull this data?</p>
[ { "answer_id": 74402432, "author": "Mayukh Bhattacharya", "author_id": 8162520, "author_profile": "https://Stackoverflow.com/users/8162520", "pm_score": 1, "selected": false, "text": "E1" }, { "answer_id": 74402481, "author": "Skin", "author_id": 5772095, "author_profile": "https://Stackoverflow.com/users/5772095", "pm_score": 0, "selected": false, "text": "=TEXTBEFORE(TEXTAFTER(A1,\"\"\"calorie\"\":\"),\",\")\n" }, { "answer_id": 74402681, "author": "FaneDuru", "author_id": 2233308, "author_profile": "https://Stackoverflow.com/users/2233308", "pm_score": 0, "selected": false, "text": "Split" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402364", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20477624/" ]
74,402,385
<p>So i am working with classes and if statements. When the if statement is inside the class def, it seems to be ignored and not sure what i am doing wrong. I want it to raise an exception if the criteria is not met.</p> <p>I tried to change name to __name but that did not seem to help. I also tried to remove def get_name(self) to see if that caused the problem but it did not.</p> <pre><code>class Strict: name:str def __init__(self,name): self.name = name def get_name(self): return self.name def set_name(self,name): if len(name) != 5: raise Exception(&quot;Name must be exactly 5 characters&quot;) else: return name try: z = Strict(&quot;ABCDEFGH&quot;) print(z.name) except Exception as e: print(str(e)) </code></pre>
[ { "answer_id": 74402432, "author": "Mayukh Bhattacharya", "author_id": 8162520, "author_profile": "https://Stackoverflow.com/users/8162520", "pm_score": 1, "selected": false, "text": "E1" }, { "answer_id": 74402481, "author": "Skin", "author_id": 5772095, "author_profile": "https://Stackoverflow.com/users/5772095", "pm_score": 0, "selected": false, "text": "=TEXTBEFORE(TEXTAFTER(A1,\"\"\"calorie\"\":\"),\",\")\n" }, { "answer_id": 74402681, "author": "FaneDuru", "author_id": 2233308, "author_profile": "https://Stackoverflow.com/users/2233308", "pm_score": 0, "selected": false, "text": "Split" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402385", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20373321/" ]
74,402,458
<p>How can I get an application list like in get_app_list method in classy AdminSite?</p> <p>I try to do it this way, but then I get an empty list.</p> <pre><code>from django.contrib.admin.sites import AdminSite def change_view(self, request): ... context = { ... 'available_apps': AdminSite().get_app_list(request) } return render(request, 'parts/part_form.html', context=context) </code></pre> <p>I need this to display the admin side menu outside the admin panel.</p>
[ { "answer_id": 74402432, "author": "Mayukh Bhattacharya", "author_id": 8162520, "author_profile": "https://Stackoverflow.com/users/8162520", "pm_score": 1, "selected": false, "text": "E1" }, { "answer_id": 74402481, "author": "Skin", "author_id": 5772095, "author_profile": "https://Stackoverflow.com/users/5772095", "pm_score": 0, "selected": false, "text": "=TEXTBEFORE(TEXTAFTER(A1,\"\"\"calorie\"\":\"),\",\")\n" }, { "answer_id": 74402681, "author": "FaneDuru", "author_id": 2233308, "author_profile": "https://Stackoverflow.com/users/2233308", "pm_score": 0, "selected": false, "text": "Split" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402458", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19451391/" ]
74,402,480
<p>I am working on a python script in which i am trying to delete all the files which are there within the given folder , though few errors like below are acting as a road block due to which the code is not able to complete.</p> <pre><code>PermissionError: The process cannot access the file because it is being used by another process: C: \\users\\dhoni\\AppData\\Local\\Temp\\2735ad90-sfa3-412f-b6b1-54534646ff3.tmp' </code></pre> <p>my question is using shutil library how can i delete all the files from a specific folder or it is possible to delete files from two different folders ?</p> <p>Tried the below code</p> <pre><code>` import shutil import os location = r&quot;C:\Users\dhoni\AppData\Local&quot; dir = &quot;Temp&quot; path = os.path.join(location, dir) shutil.rmtree(path)` </code></pre>
[ { "answer_id": 74402432, "author": "Mayukh Bhattacharya", "author_id": 8162520, "author_profile": "https://Stackoverflow.com/users/8162520", "pm_score": 1, "selected": false, "text": "E1" }, { "answer_id": 74402481, "author": "Skin", "author_id": 5772095, "author_profile": "https://Stackoverflow.com/users/5772095", "pm_score": 0, "selected": false, "text": "=TEXTBEFORE(TEXTAFTER(A1,\"\"\"calorie\"\":\"),\",\")\n" }, { "answer_id": 74402681, "author": "FaneDuru", "author_id": 2233308, "author_profile": "https://Stackoverflow.com/users/2233308", "pm_score": 0, "selected": false, "text": "Split" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402480", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20432746/" ]
74,402,488
<p>I have a question about the 'continue' function in Python. I wolud like to skip 'Antarctic' in the following list:</p> <pre><code>continents = = [&quot;Afrika&quot;, &quot;Antarktic&quot;, &quot;Asien&quot;, &quot;Australia&quot;, &quot;Europe&quot;, &quot;North America&quot;, &quot;South America&quot;] </code></pre> <p>I thought about using the for loop in combination with the 'continue' function but it doesn't work. Maybe I have to transform the list in another format or so.</p> <p>This was my first guess.</p> <pre><code>for i in continents: if i == 1: continue print(i) </code></pre> <p>Thanks in advance.</p>
[ { "answer_id": 74402539, "author": "Maximilian Burszley", "author_id": 8188846, "author_profile": "https://Stackoverflow.com/users/8188846", "pm_score": 0, "selected": false, "text": "continents = [\n \"Afrika\",\n \"Antarktic\",\n \"Asien\",\n \"Australia\",\n \"Europe\",\n \"North America\",\n \"South America\",\n]\n" }, { "answer_id": 74402580, "author": "Brhaka", "author_id": 11578778, "author_profile": "https://Stackoverflow.com/users/11578778", "pm_score": 0, "selected": false, "text": "continents = [\n \"Afrika\",\n \"Antarktic\",\n \"Asien\",\n \"Australia\",\n \"Europe\",\n \"North America\",\n \"South America\",\n]\n" }, { "answer_id": 74402709, "author": "Luicfer Ai", "author_id": 18416403, "author_profile": "https://Stackoverflow.com/users/18416403", "pm_score": 0, "selected": false, "text": "==" }, { "answer_id": 74402804, "author": "Karthik Raja", "author_id": 20449425, "author_profile": "https://Stackoverflow.com/users/20449425", "pm_score": -1, "selected": false, "text": "continents = [\n \"Afrika\",\n \"Antarctica\",\n \"Asien\",\n \"Australia\",\n \"Europe\",\n \"North America\",\n \"South America\",\n]\n\n# If want to skip based on the value, use below code\nfor i in continents:\n if i == \"Antarctica\":\n continue\n else:\n print(i)\n\n# If want to skip based on the index, use below code\nfor i in continents:\n if continents.index(i) == 1 :\n continue\n else:\n print(i)\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402488", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20477656/" ]
74,402,495
<p>Is there any way to lock the excel cell if it has value and unlock it if it has no value contained?</p> <p>e.g. if Persone updates the excel-sheet and sends it to another person, the second person only allows the update blank cells.</p>
[ { "answer_id": 74402732, "author": "Deevise", "author_id": 19478789, "author_profile": "https://Stackoverflow.com/users/19478789", "pm_score": 0, "selected": false, "text": "Private Sub Worksheet_Change(ByVal Target As Range)\n \n If Not Target.Value = \"\" Then\n ActiveSheet.Unprotect\n Target.Locked = True\n ActiveSheet.Protect\n End If\nEnd Sub\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402495", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5820330/" ]
74,402,545
<p>I have the following <code>bytearray</code> in Python:</p> <pre><code>bytearray(b'\x02\xcb\x00\n\x02\xcb\x00\n\x02\xcb\x00\n\x02\xcb\x00\n') </code></pre> <p>I want to convert the hexa values of the <code>bytearray</code> to an array of integer values, by converting <code>\x02\xcb\x00</code> to an integer 183040 for each '\n'.</p> <p>It should look like:</p> <pre><code>[183040, 183040, 183040, 183040] </code></pre> <p>How can I get it?</p> <p>I did a <code>list(bytarray)</code> and it just worked for single values not composite ones.</p>
[ { "answer_id": 74402617, "author": "B. van den Hoek", "author_id": 6125728, "author_profile": "https://Stackoverflow.com/users/6125728", "pm_score": 0, "selected": false, "text": "xs = bytearray(b'\\x02\\xcb\\x00\\n\\x02\\xcb\\x00\\n\\x02\\xcb\\x00\\n\\x02\\xcb\\x00\\n')\n\nresult = []\nfor line in xs.split(b'\\n'):\n result.append(int.from_bytes(line))\n\nresult[:-1]\n" }, { "answer_id": 74402778, "author": "CreepyRaccoon", "author_id": 18342123, "author_profile": "https://Stackoverflow.com/users/18342123", "pm_score": 1, "selected": true, "text": "b = bytearray(b'\\x02\\xcb\\x00\\n\\x02\\xcb\\x00\\n\\x02\\xcb\\x00\\n\\x02\\xcb\\x00\\n')\nint_list = [int.from_bytes(n, \"big\", signed=False) for n in b.split(b'\\n')[:-1]]\nprint(int_list)\n" }, { "answer_id": 74403171, "author": "gre_gor", "author_id": 794749, "author_profile": "https://Stackoverflow.com/users/794749", "pm_score": 1, "selected": false, "text": "b = b\"\\x02\\xcb\\x00\\n\\x02\\xcb\\x00\\n\\x02\\xcb\\x00\\n\\n\\n\\n\\n\"\n\nnumbers = []\nfor i in range(0, len(b), 4):\n if b[i+3] != 10:\n raise ValueError(\"Expected a newline character\")\n numbers.append(int.from_bytes(b[i:i+3], \"big\"))\n \nprint(numbers)\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402545", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15852840/" ]
74,402,546
<p><strong>Requirement:</strong> Is there any optimal or easy way to filtered out the objects from an array which contains a specific property based on its value without <em>recursion</em>.</p> <p><strong>Problem statement:</strong> We can achieve this requirement using recursion but as data set (array of objects) is very large and each object contains <code>n</code> number of nested objects, Recursion approach is causing performance issue.</p> <p>Here is the sample mock data:</p> <pre><code>[{ children: [{ children: [{ children: [], isWorking: 'yes' }] }] }, { children: [], isWorking: 'no' }, { children: [{ children: [{ children: [], isWorking: 'no' }] }] }, { children: [{ children: [], isWorking: 'yes' }] }, ...] </code></pre> <ul> <li>I want to filter out the root objects from an array which contains nested <code>isWorking</code> property with the value as <code>yes</code>.</li> <li><code>isWorking</code> property will only available for the objects which does not contains children. i.e. <code>children: []</code></li> </ul> <p>As I said earlier, I am able to achieve this by recursion but looking for a optimal solution which will not impact the performance.</p> <p>This is what I tried (Working solution):</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>const parent = [{ children: [{ children: [{ children: [], isWorking: 'yes' }] }] }, { children: [], isWorking: 'no' }, { children: [{ children: [{ children: [], isWorking: 'no' }] }] }, { children: [{ children: [], isWorking: 'yes' }] }]; const isWorkingFlagArr = []; function checkForOccupation(arr) { arr.forEach(obj =&gt; { (!obj.children.length) ? isWorkingFlagArr.push(obj.isWorking === 'yes') : checkForOccupation(obj.children) }) } checkForOccupation(parent); const res = parent.filter((obj, index) =&gt; isWorkingFlagArr[index]); console.log(res);</code></pre> </div> </div> </p>
[ { "answer_id": 74403071, "author": "Ben Aston", "author_id": 38522, "author_profile": "https://Stackoverflow.com/users/38522", "pm_score": 2, "selected": true, "text": "for..of" }, { "answer_id": 74408394, "author": "Scott Sauyet", "author_id": 1243641, "author_profile": "https://Stackoverflow.com/users/1243641", "pm_score": 0, "selected": false, "text": "const checkForOccupation = (xs) => xs .flatMap (\n (x, _, __, kids = checkForOccupation (x .children || [])) => \n x .isWorking == 'yes' || kids .length > 0 ? [{...x, children: kids}] : []\n)\n\nconst data = [{children: [{children: [{children: [{children: [], isWorking: 'no'}], isWorking: 'yes'}]}]}, {children: [], isWorking: 'no'}, {children: [{children: [{children: [], isWorking: 'no'}]}]}, {children: [{children: [], isWorking: 'yes'}]}]\n\nconsole .log (checkForOccupation (data))" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402546", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4116300/" ]
74,402,586
<p>Have defined an EventBridge rule, which is disabled by default.</p> <pre><code> new Rule(this, 'EmailRule', { ruleName: 'email-event-rule', description: 'trigger email handler', enabled: false, eventPattern: { detailType: ['email-event-rule-event'] }, targets: [new LambdaFunction(emailHandlerConstruct.getLambda())], schedule: Schedule.rate(Duration.hours(1)) }); </code></pre> <p>In a certain scenario it is enabled. But I assumed it would run after an hour of being enabled. But it triggers the lambda every time its enabled right away.</p> <p>Is that how its designed or am I missing something? I did not see anywhere in the doc regarding the schedule of an event bridge rule when it is enabled.</p>
[ { "answer_id": 74403071, "author": "Ben Aston", "author_id": 38522, "author_profile": "https://Stackoverflow.com/users/38522", "pm_score": 2, "selected": true, "text": "for..of" }, { "answer_id": 74408394, "author": "Scott Sauyet", "author_id": 1243641, "author_profile": "https://Stackoverflow.com/users/1243641", "pm_score": 0, "selected": false, "text": "const checkForOccupation = (xs) => xs .flatMap (\n (x, _, __, kids = checkForOccupation (x .children || [])) => \n x .isWorking == 'yes' || kids .length > 0 ? [{...x, children: kids}] : []\n)\n\nconst data = [{children: [{children: [{children: [{children: [], isWorking: 'no'}], isWorking: 'yes'}]}]}, {children: [], isWorking: 'no'}, {children: [{children: [{children: [], isWorking: 'no'}]}]}, {children: [{children: [], isWorking: 'yes'}]}]\n\nconsole .log (checkForOccupation (data))" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402586", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17513741/" ]
74,402,595
<p>In List component we have this method.</p> <pre><code> List&lt;Widget&gt; generateList(goalList) { return List.generate( goalList.length, (int index) { return GoalCardBase( goalId: goalList.id, child: GoalCardData(goal: goalList[index]), ); }, ); } </code></pre> <p>i am trying to sort them by startDate. I was looking a solution everyone suggest something like that. goalList.sort((a, b)=&gt; a.compareTo(b['objectiveStartDate'])); but from goalList I could not reach the start date. Maybe i am completly wrong. What would you do if you were to solve this problem?</p> <p>The whole code</p> <pre><code> import 'package:app/src/common.dart'; import 'package:app/src/common_widgets/app_buttons.dart'; import 'package:app/src/features/goals/card/goal_card_base.dart'; import 'package:app/src/features/goals/card/goal_card_data.dart'; import 'package:app/src/utils/utils.dart'; import 'package:go_router/go_router.dart'; import 'package:phosphor_flutter/phosphor_flutter.dart'; class GoalsPageBodyGoals extends StatelessWidget { final List&lt;Widget&gt; data; const GoalsPageBodyGoals({Key? key, required this.data}) : super(key: key); List&lt;Widget&gt; generateList(goalList) { return List.generate( goalList.length, (int index) { return GoalCardBase( goalId: goalList.id, child: GoalCardData(goal: goalList[index]), ); }, ); } @override Widget build(BuildContext context) { return Column(children: [ ...data, const SizedBox(height: 24), Column( key: const Key('goals_page_action_buttons'), children: [ AppButtons.button( onPressed: () =&gt; context.go('/add-goal'), child: Text(context.l10n.goalsListPrimaryButtonText)), AppButtons.textButton( onPressed: () =&gt; AppUtils.snackBarNotImplemented(context), phosphorIcon: PhosphorIcons.arrowRight, child: Text(context.l10n.goalsListTextLink)) ], ), ]); } } </code></pre> <p>IN goal Objective (GoalCardData(<em>goal</em>: goalList[index]),) I have attributes(title, startDate, amount, salary etc.) , so when we create a goal it has date. But when i list them its just randomly saving.</p>
[ { "answer_id": 74402737, "author": "Arijeet", "author_id": 15387120, "author_profile": "https://Stackoverflow.com/users/15387120", "pm_score": 2, "selected": false, "text": " goalList.sort((b, a) => a['startDate'].compareTo(b['startDate']);" }, { "answer_id": 74402896, "author": "aoiTenshi", "author_id": 14314892, "author_profile": "https://Stackoverflow.com/users/14314892", "pm_score": 1, "selected": false, "text": "void main(){\n cls _cls = cls(\"title\",DateTime.now());\n cls cls2 = cls(\"title2\",DateTime.now().subtract(Duration(days:1)));\n \n List<cls> clist = [_cls,cls2];\n for(var v in clist){\n print(v.startDate.toString());\n }\n \n clist.sort((a,b) => a.startDate!.compareTo(b.startDate!));\n \n for(var v in clist){\n print(v.startDate.toString());\n }\n}\n\nclass cls{\n String? title;\n DateTime? startDate;\n \n cls(this.title,this.startDate);\n}\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402595", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20459122/" ]
74,402,605
<p>I'm using the <a href="https://mui.com/material-ui/api/text-field/" rel="nofollow noreferrer">TextField</a> and <a href="https://mui.com/material-ui/api/menu-item/" rel="nofollow noreferrer">MenuItem</a> components in a next.js project.</p> <p>I'm passing the &quot;select&quot; prop in the TextField. This makes the text field use the <a href="https://mui.com/material-ui/api/select/" rel="nofollow noreferrer">Select</a> component internally.</p> <p>My problem is: The dropdown is jumping on the screen after clicking (the dropdown appears for 1 sec or so on the top left corner of the screen and eventually moves underneath the select field).</p> <p>Here's my code:</p> <pre><code> &lt;div&gt; &lt;TextField focused sx={{ m: 0.5, width: 130 }} select id=&quot;birthdayD&quot; name=&quot;birthdayD&quot; label=&quot;Geburtstag&quot; type=&quot;Geburtstag&quot; SelectProps={{ MenuProps: { sx: { maxHeight: 200 }, }, variant: &quot;menu&quot;, getContentAnchorEl: null, }} &gt; {day.map((option) =&gt; ( &lt;MenuItem key={option.value} value={option.value}&gt; {option.label} &lt;/MenuItem&gt; ))} &lt;/TextField&gt; &lt;/div&gt; </code></pre> <p><a href="https://stackoverflow.com/questions/59785482/multiselect-box-popover-keeps-jumping-when-scroll-or-select-items">Here's</a> a great post about why I should use <code>variant: &quot;menu&quot;, getContentAnchorEl: null</code>, but in my case the problem isn't solved.</p>
[ { "answer_id": 74402737, "author": "Arijeet", "author_id": 15387120, "author_profile": "https://Stackoverflow.com/users/15387120", "pm_score": 2, "selected": false, "text": " goalList.sort((b, a) => a['startDate'].compareTo(b['startDate']);" }, { "answer_id": 74402896, "author": "aoiTenshi", "author_id": 14314892, "author_profile": "https://Stackoverflow.com/users/14314892", "pm_score": 1, "selected": false, "text": "void main(){\n cls _cls = cls(\"title\",DateTime.now());\n cls cls2 = cls(\"title2\",DateTime.now().subtract(Duration(days:1)));\n \n List<cls> clist = [_cls,cls2];\n for(var v in clist){\n print(v.startDate.toString());\n }\n \n clist.sort((a,b) => a.startDate!.compareTo(b.startDate!));\n \n for(var v in clist){\n print(v.startDate.toString());\n }\n}\n\nclass cls{\n String? title;\n DateTime? startDate;\n \n cls(this.title,this.startDate);\n}\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14432154/" ]
74,402,607
<p>I am trying to create a new worksheet in a Google Sheets doc where I need to filter a Master data set based on values in a specific column.</p> <p>I originally did a VLOOKUP in each specific column that I wanted returned but it brough back blank rows for the corresponding rows that did not match, and eventually it broke for some reason and stopped returning the correct data.</p> <p>I have been trying to find a new way to do it and have most recently been trying XLOOKUP, but it returns duplicate rows of each correct match.</p> <p>The original datasheet is mostly populated itself by VLOOKUPS, drawing in information from other trackers so I feel this must be why it is falling over.</p> <p>The dataset looks roughly like this:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>ID</th> <th>Y/N</th> <th>Last Name</th> <th>First Name</th> <th>col</th> <th>col1</th> <th>col2</th> <th>etc</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>Y</td> <td>SMITH</td> <td>A</td> <td>Cell 1</td> <td>Cell 2</td> <td>Cell 1</td> <td>Cell 2</td> </tr> <tr> <td>2</td> <td>N</td> <td>JONES</td> <td>B</td> <td>Cell 1</td> <td>Cell 2</td> <td>Cell 1</td> <td>Cell 2</td> </tr> </tbody> </table> </div> <p>There are 40+columns in the tracker but I basically want to have a new sheet where I filter and return only the 'Y' values in the Y/N column, and return columns A:N (including the ID column) without leaving blank rows between the matches, and without returning dupllicates.</p> <p>I have tried everything I can think of but I just cannot make it work, so any help on the matter would be GREATLY appreciated.</p> <p>Thanks for reading.</p>
[ { "answer_id": 74402737, "author": "Arijeet", "author_id": 15387120, "author_profile": "https://Stackoverflow.com/users/15387120", "pm_score": 2, "selected": false, "text": " goalList.sort((b, a) => a['startDate'].compareTo(b['startDate']);" }, { "answer_id": 74402896, "author": "aoiTenshi", "author_id": 14314892, "author_profile": "https://Stackoverflow.com/users/14314892", "pm_score": 1, "selected": false, "text": "void main(){\n cls _cls = cls(\"title\",DateTime.now());\n cls cls2 = cls(\"title2\",DateTime.now().subtract(Duration(days:1)));\n \n List<cls> clist = [_cls,cls2];\n for(var v in clist){\n print(v.startDate.toString());\n }\n \n clist.sort((a,b) => a.startDate!.compareTo(b.startDate!));\n \n for(var v in clist){\n print(v.startDate.toString());\n }\n}\n\nclass cls{\n String? title;\n DateTime? startDate;\n \n cls(this.title,this.startDate);\n}\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20477127/" ]
74,402,645
<p>Help me out! I Have a column named N_AIH, and I have another column named IDENT, it contains the values 1 and 5.</p> <p>I need to create A new column 'LP' with the following condition: if the same N_AIH value repeats on IDENT 1 and 5.</p> <p>data:</p> <pre><code>N_AIH IDENT 122010 1 122010 5 123123 1 123412 1 123434 5 </code></pre> <p>NOTE that 122010 repeats, in the case i need it to be identified</p> <pre><code>N_AIH IDENT LP 122010 1 YES 122010 5 YES 123123 1 NO 123412 1 NO 123434 5 NO </code></pre> <p>my csv has 23 milion lines, so I cant use excel.</p> <p>Im trying to use if and sql sintaxes but with no success.</p>
[ { "answer_id": 74402789, "author": "ThomasIsCoding", "author_id": 12158757, "author_profile": "https://Stackoverflow.com/users/12158757", "pm_score": 1, "selected": false, "text": "ave" }, { "answer_id": 74402819, "author": "AndS.", "author_id": 9778513, "author_profile": "https://Stackoverflow.com/users/9778513", "pm_score": 1, "selected": true, "text": "library(tidyverse)\n\ndf |>\n group_by(N_AIH) |>\n mutate(LP = c(\"NO\", \"YES\")[all( c(1,5) %in% IDENT)+1])\n#> # A tibble: 5 x 3\n#> # Groups: N_AIH [4]\n#> N_AIH IDENT LP \n#> <dbl> <dbl> <chr>\n#> 1 122010 1 YES \n#> 2 122010 5 YES \n#> 3 123123 1 NO \n#> 4 123412 1 NO \n#> 5 123434 5 NO\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402645", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20477516/" ]
74,402,671
<p>Try to produce subset of object</p> <pre><code>type person = {name: string, age: number, dob: Date}; type p1 = Pick&lt;person, 'name' | 'dob'&gt; </code></pre> <p>but get error (&quot;error dob is missing&quot;) if</p> <pre><code>person1: p1 = {name: 'test1'} </code></pre> <p>I am wondering what is the best way to create all subsets of type <code>person</code> in Typescript.</p>
[ { "answer_id": 74403212, "author": "Giorgi Moniava", "author_id": 3963067, "author_profile": "https://Stackoverflow.com/users/3963067", "pm_score": 2, "selected": false, "text": "type person = {name: string, age: number, dob: Date};\ntype PickOptional<T, K extends keyof T> = {[k in K]?:T[k]}\n\ntype Test = PickOptional<person,'name' | 'dob'>\nlet person1: Test = {name: 'test1'}\n" }, { "answer_id": 74403952, "author": "Tobias S.", "author_id": 8613630, "author_profile": "https://Stackoverflow.com/users/8613630", "pm_score": 1, "selected": true, "text": "Pick" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402671", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11025517/" ]
74,402,677
<p>I have a single cell that contains several sets of text separated by a semi colon (extracted from another application) for example</p> <p>Cell A1: apple;banana;orange Cell A2: banana;orange;melon</p> <p>I am trying to introduce a formula in an adjacent cell which will return a value for apple if it contains apple, or banana if it contains banana.</p> <p>I am happy to have it only return a single value (the first one perhaps)</p> <p>I tried the IF function using &lt;&gt; as suggested on the internet. I thought this had worked to start with but then it didnt return the value when I moved it! - so it was clearly wrong.</p> <p>=IF(A1&lt;&gt;&quot;apple&quot;,&quot;apple&quot;,&quot;&quot;) - returned apple - but then always returned apple even if there was no apple in the string.</p> <p>I did then try an IFS nested statement - but that didnt work - highly likely because I then realised that even my IF statement didnt work properly. I tried to research ISNUMBER and a couple of other suggestions but cant seem to get it anywhere near working!</p> <p>It seems like it is something relatively straightforward and I am just missing the obvious - would welcome any assistance.</p>
[ { "answer_id": 74403212, "author": "Giorgi Moniava", "author_id": 3963067, "author_profile": "https://Stackoverflow.com/users/3963067", "pm_score": 2, "selected": false, "text": "type person = {name: string, age: number, dob: Date};\ntype PickOptional<T, K extends keyof T> = {[k in K]?:T[k]}\n\ntype Test = PickOptional<person,'name' | 'dob'>\nlet person1: Test = {name: 'test1'}\n" }, { "answer_id": 74403952, "author": "Tobias S.", "author_id": 8613630, "author_profile": "https://Stackoverflow.com/users/8613630", "pm_score": 1, "selected": true, "text": "Pick" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402677", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20477714/" ]
74,402,690
<p>I have two tables in Laravel, one is the <code>comment</code> table, and the second is the <code>users</code> table. In the comment table, I have this type of data.</p> <p><a href="https://i.stack.imgur.com/JKaQg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JKaQg.png" alt="enter image description here" /></a></p> <p>For this comment table, I want to match the <code>tags</code> column's userid in JSON, so how can we join that userid with the user's table? here is what I tried, but that is not working as expected.</p> <pre><code>$messages = TopicComment::where('user_id', $currentUserId) -&gt;join(&quot;users&quot;, &quot;users.id&quot;, &quot;=&quot;, &quot;users.id&quot;) -&gt;(function ($query) { $query-&gt;whereJsonContains('tags.userid', users.id); }) -&gt; -&gt;get()-&gt;toArray(); </code></pre>
[ { "answer_id": 74403212, "author": "Giorgi Moniava", "author_id": 3963067, "author_profile": "https://Stackoverflow.com/users/3963067", "pm_score": 2, "selected": false, "text": "type person = {name: string, age: number, dob: Date};\ntype PickOptional<T, K extends keyof T> = {[k in K]?:T[k]}\n\ntype Test = PickOptional<person,'name' | 'dob'>\nlet person1: Test = {name: 'test1'}\n" }, { "answer_id": 74403952, "author": "Tobias S.", "author_id": 8613630, "author_profile": "https://Stackoverflow.com/users/8613630", "pm_score": 1, "selected": true, "text": "Pick" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402690", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9424000/" ]
74,402,695
<p>I have a multi-line template literal. I want to splice it based on line number and character index in the line. For that, I need the number of characters in a given line. How can I get this number?</p> <p>As for what I have tried, well, I pretty much only put random numbers into <code>slice()</code> to see how much it slices.</p> <p>Thanks.</p>
[ { "answer_id": 74402893, "author": "0stone0", "author_id": 5625547, "author_profile": "https://Stackoverflow.com/users/5625547", "pm_score": 1, "selected": false, "text": "split()" }, { "answer_id": 74402919, "author": "Vivekanand Vishvkarma", "author_id": 19443694, "author_profile": "https://Stackoverflow.com/users/19443694", "pm_score": 1, "selected": false, "text": "let text =\n `The quick\nbrown fox\njumps over\nthe lazy dog`;\nlet res = text.split('\\n');\nres.forEach((element, index)=>{\n console.log(`Line no:${index+1} ${element} length: ${element.length}`);\n})\n" }, { "answer_id": 74405277, "author": "mikwee", "author_id": 15792934, "author_profile": "https://Stackoverflow.com/users/15792934", "pm_score": 0, "selected": false, "text": "split()" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402695", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15792934/" ]
74,402,704
<p>I have written a program like so:</p> <pre><code># Author: Evan Gertis # Date : 11/09 # program: Linear Regression # Resource: https://seaborn.pydata.org/generated/seaborn.scatterplot.html import seaborn as sns import pandas as pd import logging logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') # Step 1: load the data grades = pd.read_csv(&quot;grades.csv&quot;) logging.info(grades.head()) # Step 2: plot the data plot = sns.scatterplot(data=grades, x=&quot;Hours&quot;, y=&quot;GPA&quot;) fig = plot.get_figure() fig.savefig(&quot;out.png&quot;) </code></pre> <p>Using the data set</p> <pre><code>Hours,GPA,Hours,GPA,Hours,GPA 11,2.84,9,2.85,25,1.85 5,3.20,5,3.35,6,3.14 22,2.18,14,2.60,9,2.96 23,2.12,18,2.35,20,2.30 20,2.55,6,3.14,14,2.66 20,2.24,9,3.05,19,2.36 10,2.90,24,2.06,21,2.24 19,2.36,25,2.00,7,3.08 15,2.60,12,2.78,11,2.84 18,2.42,6,2.90,20,2.45 </code></pre> <p>I would like to plot out all of the relationships at this time I just get one plot:</p> <p><a href="https://i.stack.imgur.com/P1E0M.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/P1E0M.png" alt="enter image description here" /></a></p> <p>Expected: all relationships plotted</p> <p>Actual:</p> <p><a href="https://i.stack.imgur.com/P1E0M.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/P1E0M.png" alt="enter image description here" /></a></p> <p>I wrote a basic program and I was expecting all of the relationships to be plotted.</p>
[ { "answer_id": 74402987, "author": "Lucas M. Uriarte", "author_id": 14543462, "author_profile": "https://Stackoverflow.com/users/14543462", "pm_score": 3, "selected": true, "text": "import seaborn as sns\nimport pandas as pd\nimport logging\nlogging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')\n\ngrades = pd.read_csv(\"grades.csv\") \nprint(grades.columns)\n>>> Index(['Hours', 'GPA', 'Hours.1', 'GPA.1', 'Hours.2', 'GPA.2'], dtype='object')\n" }, { "answer_id": 74406385, "author": "Trenton McKinney", "author_id": 7758804, "author_profile": "https://Stackoverflow.com/users/7758804", "pm_score": 1, "selected": false, "text": "pandas" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402704", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3937811/" ]
74,402,717
<p>I am just starting out with OOP and trying to understand the code below. Why is book2 object changing its value even though i am not defining it to something els just using that object to define the values of the objects in books array.</p> <pre><code>Book[] books = new Book[5]; Book book2 = new Book(&quot;test&quot;, &quot;test1&quot;, 800); for (int i = 0; i &lt; books.Length; i++) { books[i] = book2; Console.WriteLine(books[i].pages); books[i].pages += 10; } </code></pre> <p>Is there something fundemental i have missed about objects? In my thinking this code should return 800, 5 times.</p> <p>Just and explination how my thinking is flawed</p>
[ { "answer_id": 74403183, "author": "ThomasB", "author_id": 15107706, "author_profile": "https://Stackoverflow.com/users/15107706", "pm_score": 1, "selected": true, "text": "class Book {...}" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20477876/" ]
74,402,744
<p>For some objects an attribute identifies a special column, for example the geometry column in an <code>sf</code> object. For conducting some calculations in <code>dplyr</code> it would be good to easily identify these columns. I'm searching for a way to create a function that helps identifying this column. In the example below I can make a function that identifies this column but I still need to use the <code>rlang</code> splice operator (<code>!!!</code>).</p> <pre class="lang-r prettyprint-override"><code>require(sf) require(dplyr) n&lt;-4 df = st_as_sf(data.frame(x = 1:n, y = 1:n, cat=gl(2,2)), coords = 1:2, crs = 3857) %&gt;% group_by(cat) # this is the example I start from however the geometry column is not guaranteed to have that name df %&gt;% mutate(d=st_distance(geometry, geometry[row_number()==1])) #&gt; Simple feature collection with 4 features and 2 fields #&gt; Geometry type: POINT #&gt; Dimension: XY #&gt; Bounding box: xmin: 1 ymin: 1 xmax: 4 ymax: 4 #&gt; Projected CRS: WGS 84 / Pseudo-Mercator #&gt; # A tibble: 4 × 3 #&gt; # Groups: cat [2] #&gt; cat geometry d[,1] #&gt; * &lt;fct&gt; &lt;POINT [m]&gt; [m] #&gt; 1 1 (1 1) 0 #&gt; 2 1 (2 2) 1.41 #&gt; 3 2 (3 3) 0 #&gt; 4 2 (4 4) 1.41 # this works, however the code does not get easier to read df %&gt;% mutate(d=st_distance(!!!syms(attr(., &quot;sf_column&quot;)), (!!!syms(attr(., &quot;sf_column&quot;)))[row_number()==1])) #&gt; Simple feature collection with 4 features and 2 fields #&gt; ... #&gt; 4 2 (4 4) 1.41 # this works and is already better: geometry_name&lt;-function(x) syms(attr(x, 'sf_column')) df %&gt;% mutate(d=st_distance(!!!geometry_name(.), (!!!geometry_name(.))[row_number()==1])) #&gt; Simple feature collection with 4 features and 2 fields #&gt; ... #&gt; 4 2 (4 4) 1.41 </code></pre> <p>Ideally I would like to find a function that makes the following code work as this would be easiest for users:</p> <pre class="lang-r prettyprint-override"><code>df %&gt;% mutate(d=st_distance(geometry_name(), geometry_name()[row_number()==1])) </code></pre>
[ { "answer_id": 74403168, "author": "Allan Cameron", "author_id": 12500315, "author_profile": "https://Stackoverflow.com/users/12500315", "pm_score": 4, "selected": true, "text": "." }, { "answer_id": 74403687, "author": "talegari", "author_id": 5638196, "author_profile": "https://Stackoverflow.com/users/5638196", "pm_score": 2, "selected": false, "text": "{{" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7459800/" ]
74,402,746
<p>Say for example, I have the following 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-html lang-html prettyprint-override"><code>&lt;p class="text-content"&gt; "First part of text" &lt;span id="divider"&gt;&lt;/span&gt; "Second part of text" &lt;/p&gt;</code></pre> </div> </div> </p> <p>How do I hide the second part of the text?</p>
[ { "answer_id": 74402783, "author": "Temba", "author_id": 3593621, "author_profile": "https://Stackoverflow.com/users/3593621", "pm_score": 0, "selected": false, "text": "<p class=\"text-content\">\n\"First part of text\"\n<span id=\"divider\"></span>\n</p>\n" }, { "answer_id": 74402818, "author": "Henryc17", "author_id": 14595300, "author_profile": "https://Stackoverflow.com/users/14595300", "pm_score": 2, "selected": false, "text": "document.getElementById(\"divider\").parentNode.removeChild(document.getElementById(\"divider\").nextSibling);" }, { "answer_id": 74402910, "author": "Bowiemtl", "author_id": 13088630, "author_profile": "https://Stackoverflow.com/users/13088630", "pm_score": 0, "selected": false, "text": "<p class=\"text-content\">\n\"First part of text\"\n<span>\"Second part of text\"</span>\n</p>\n" } ]
2022/11/11
[ "https://Stackoverflow.com/questions/74402746", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11861581/" ]