qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,357,754
<p>I thought it is a simple problem, I searched a lot but nothing suitable found! How to get rid of &quot;Escape Sequences&quot; in the strings when replacing '\' with '/' in python? I need to convert Windows Path to Unix Path but for example 'blahblah\nblahblah' or 'blahblah\bblahblah' make problems!</p> <pre><code>addressURL = &quot;B:\shot_001\cache\nt_02.abc&quot; addressURL = addressURL.replace('\\','/') print(addressURL) # Result: B:/shot_001/cache t_02.abc # </code></pre> <p>I also used os.path module but the results were the same!</p> <p>Anyway I need to convert &quot;B:\shot_001\cache\nt_02.abc&quot; to &quot;B:/shot_001/cache/nt_02.abc&quot;</p> <p>Thanks</p>
[ { "answer_id": 74357997, "author": "Vin", "author_id": 7955271, "author_profile": "https://Stackoverflow.com/users/7955271", "pm_score": 1, "selected": false, "text": "\"B:\\shot_001\\cache\\nt_02.abc\"\n" }, { "answer_id": 74367008, "author": "Milad Hatam", "author_id": 5143433, "author_profile": "https://Stackoverflow.com/users/5143433", "pm_score": 1, "selected": true, "text": "import os\nimport re\n\n\ndef slashPath(path):\n\n \"\"\"\n\n param: str file path\n\n return: str file path with \"\\\\\" replaced by '/' \n\n \"\"\"\n\n path = rawString(path)\n\n raw_path = r\"{}\".format(path)\n\n separator = os.path.normpath(\"/\")\n\n changeSlash = lambda x: '/'.join(x.split(separator))\n\n if raw_path.startswith('\\\\'):\n\n return '/' + changeSlash(raw_path)\n\n else:\n\n return changeSlash(raw_path)\n\ndef rawString(strVar):\n\n \"\"\"Returns a raw string representation of strVar.\n\n Will replace '\\\\' with '/'\n\n :param: str String to change to raw\n\n \"\"\"\n\n if type(strVar) is str:\n\n strVarRaw = r'%s' % strVar\n\n new_string=''\n\n escape_dict={'\\a':r'\\a', '\\b':r'\\b', '\\c':r'\\c', '\\f':r'\\f', '\\n':r'\\n',\n\n '\\r':r'\\r', '\\t':r'\\t', '\\v':r'\\v', '\\'':r'\\'', '\\\"':r'\\\"',\n\n '\\0':r'\\0', '\\1':r'\\1', '\\2':r'\\2', '\\3':r'\\3', '\\4':r'\\4',\n\n '\\5':r'\\5', '\\6':r'\\6', '\\7':r'\\7', '\\8':r'\\8', '\\9':r'\\9'}\n\n for char in strVarRaw:\n\n try: new_string+=escape_dict[char]\n\n except KeyError: new_string+=char\n\n return new_string\n\n else:\n\n return strVar\n\n#--------- JUST FOR RUN -----------\ns1 = 'cache\\bt_02.abc'\nprint(slashPath(s1))\n#result = cache/bt_02.abc\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74357754", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5143433/" ]
74,357,780
<p>i already create the code and the result like this <a href="https://i.stack.imgur.com/sEsjQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sEsjQ.png" alt="enter image description here" /></a></p> <p>and i want when i press the other accordion, the right side image will change like this <a href="https://i.stack.imgur.com/PCNXY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PCNXY.png" alt="enter image description here" /></a></p> <p>i already try to create, but what i got is the image stacking and not changing in the same place like this <a href="https://i.stack.imgur.com/FLAtt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FLAtt.png" alt="enter image description here" /></a></p> <p>i use this code, and i need help to fix this problem</p> <pre><code> &lt;section class=&quot;various__sect&quot;&gt; &lt;div class=&quot;container&quot;&gt; &lt;div class=&quot;row&quot;&gt; &lt;div class=&quot;col-6 various__left__group&quot;&gt; &lt;div class=&quot;various__title&quot;&gt; Various Kinds of Finances Products &lt;/div&gt; &lt;div class=&quot;various__accordion&quot;&gt; &lt;div class=&quot;accordion accordion-flush&quot; id=&quot;accordionFlushExample&quot;&gt; &lt;div class=&quot;accordion-item&quot;&gt; &lt;h2 class=&quot;accordion-header&quot; id=&quot;flush-headingOne&quot;&gt; &lt;button id=&quot;collapseOne&quot; class=&quot;accordion-button collapsed&quot; type=&quot;button&quot; data-bs-toggle=&quot;collapse&quot; data-bs-target=&quot;#flush-collapseOne&quot; aria-expanded=&quot;false&quot; aria-controls=&quot;flush-collapseOne&quot;&gt; 1. We have features that help your finances &lt;/button&gt; &lt;/h2&gt; &lt;div id=&quot;flush-collapseOne&quot; class=&quot;accordion-collapse collapse show&quot; aria-labelledby=&quot;flush-headingOne&quot; data-bs-parent=&quot;#accordionFlushExample&quot;&gt; &lt;div class=&quot;accordion-body&quot;&gt; With this scan features, it can make transactions faster and safer, of course &lt;div class=&quot;mt-3&quot;&gt; &lt;a href=&quot;&quot;&gt;Learn More &lt;span class=&quot;bi bi-arrow-right-short&quot;&gt;&lt;/span&gt;&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class=&quot;accordion-item&quot;&gt; &lt;h2 class=&quot;accordion-header&quot; id=&quot;flush-headingTwo&quot;&gt; &lt;button id=&quot;collapseTwo&quot; class=&quot;accordion-button collapsed&quot; type=&quot;button&quot; data-bs-toggle=&quot;collapse&quot; data-bs-target=&quot;#flush-collapseTwo&quot; aria-expanded=&quot;false&quot; aria-controls=&quot;flush-collapseTwo&quot;&gt; 2. All kinds of activities regarding finances &lt;/button&gt; &lt;/h2&gt; &lt;div id=&quot;flush-collapseTwo&quot; class=&quot;accordion-collapse collapse&quot; aria-labelledby=&quot;flush-headingTwo&quot; data-bs-parent=&quot;#accordionFlushExample&quot;&gt; &lt;div class=&quot;accordion-body&quot;&gt; With this scan features, it can make transactions faster and safer, of course &lt;div class=&quot;mt-3&quot;&gt; &lt;a href=&quot;&quot;&gt;Learn More &lt;span class=&quot;bi bi-arrow-right-short&quot;&gt;&lt;/span&gt;&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class=&quot;accordion-item&quot;&gt; &lt;h2 class=&quot;accordion-header&quot; id=&quot;flush-headingThree&quot;&gt; &lt;button id=&quot;collapseThree&quot; class=&quot;accordion-button collapsed&quot; type=&quot;button&quot; data-bs-toggle=&quot;collapse&quot; data-bs-target=&quot;#flush-collapseThree&quot; aria-expanded=&quot;false&quot; aria-controls=&quot;flush-collapseThree&quot;&gt; 3. Various of needs regarding finance here &lt;/button&gt; &lt;/h2&gt; &lt;div id=&quot;flush-collapseThree&quot; class=&quot;accordion-collapse collapse&quot; aria-labelledby=&quot;flush-headingThree&quot; data-bs-parent=&quot;#accordionFlushExample&quot;&gt; &lt;div class=&quot;accordion-body&quot;&gt; With this scan features, it can make transactions faster and safer, of course &lt;div class=&quot;mt-3&quot;&gt; &lt;a href=&quot;&quot;&gt;Learn More &lt;span class=&quot;bi bi-arrow-right-short&quot;&gt;&lt;/span&gt;&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class=&quot;accordion-item&quot;&gt; &lt;h2 class=&quot;accordion-header&quot; id=&quot;flush-headingFour&quot;&gt; &lt;button id=&quot;collapseFour&quot; class=&quot;accordion-button collapsed&quot; type=&quot;button&quot; data-bs-toggle=&quot;collapse&quot; data-bs-target=&quot;#flush-collapseFour&quot; aria-expanded=&quot;false&quot; aria-controls=&quot;flush-collapseFour&quot;&gt; 4. Only here you will get various benefits &lt;/button&gt; &lt;/h2&gt; &lt;div id=&quot;flush-collapseFour&quot; class=&quot;accordion-collapse collapse&quot; aria-labelledby=&quot;flush-headingFour&quot; data-bs-parent=&quot;#accordionFlushExample&quot;&gt; &lt;div class=&quot;accordion-body&quot;&gt; With this scan features, it can make transactions faster and safer, of course &lt;div class=&quot;mt-3&quot;&gt; &lt;a href=&quot;&quot;&gt;Learn More &lt;span class=&quot;bi bi-arrow-right-short&quot;&gt;&lt;/span&gt;&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class=&quot;offset-1 col-5&quot;&gt; &lt;div class=&quot;collapse show multi-collapse&quot; id=&quot;flush-collapseOne&quot;&gt; &lt;div class=&quot;img__collapse&quot;&gt; &lt;img src=&quot;assets/img/img-various.webp&quot; alt=&quot;&quot;&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class=&quot;collapse multi-collapse&quot; id=&quot;flush-collapseTwo&quot;&gt; &lt;div class=&quot;img__collapse&quot;&gt; &lt;img src=&quot;assets/img/img-various.webp&quot; alt=&quot;&quot;&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class=&quot;collapse multi-collapse&quot; id=&quot;flush-collapseThree&quot;&gt; &lt;div class=&quot;img__collapse&quot;&gt; &lt;img src=&quot;assets/img/img-various.webp&quot; alt=&quot;&quot;&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class=&quot;collapse multi-collapse&quot; id=&quot;flush-collapseFour&quot;&gt; &lt;div class=&quot;img__collapse&quot;&gt; &lt;img src=&quot;assets/img/img-various.webp&quot; alt=&quot;&quot;&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/section&gt; </code></pre> <p>I'm using bootstrap 5 to create this</p>
[ { "answer_id": 74357997, "author": "Vin", "author_id": 7955271, "author_profile": "https://Stackoverflow.com/users/7955271", "pm_score": 1, "selected": false, "text": "\"B:\\shot_001\\cache\\nt_02.abc\"\n" }, { "answer_id": 74367008, "author": "Milad Hatam", "author_id": 5143433, "author_profile": "https://Stackoverflow.com/users/5143433", "pm_score": 1, "selected": true, "text": "import os\nimport re\n\n\ndef slashPath(path):\n\n \"\"\"\n\n param: str file path\n\n return: str file path with \"\\\\\" replaced by '/' \n\n \"\"\"\n\n path = rawString(path)\n\n raw_path = r\"{}\".format(path)\n\n separator = os.path.normpath(\"/\")\n\n changeSlash = lambda x: '/'.join(x.split(separator))\n\n if raw_path.startswith('\\\\'):\n\n return '/' + changeSlash(raw_path)\n\n else:\n\n return changeSlash(raw_path)\n\ndef rawString(strVar):\n\n \"\"\"Returns a raw string representation of strVar.\n\n Will replace '\\\\' with '/'\n\n :param: str String to change to raw\n\n \"\"\"\n\n if type(strVar) is str:\n\n strVarRaw = r'%s' % strVar\n\n new_string=''\n\n escape_dict={'\\a':r'\\a', '\\b':r'\\b', '\\c':r'\\c', '\\f':r'\\f', '\\n':r'\\n',\n\n '\\r':r'\\r', '\\t':r'\\t', '\\v':r'\\v', '\\'':r'\\'', '\\\"':r'\\\"',\n\n '\\0':r'\\0', '\\1':r'\\1', '\\2':r'\\2', '\\3':r'\\3', '\\4':r'\\4',\n\n '\\5':r'\\5', '\\6':r'\\6', '\\7':r'\\7', '\\8':r'\\8', '\\9':r'\\9'}\n\n for char in strVarRaw:\n\n try: new_string+=escape_dict[char]\n\n except KeyError: new_string+=char\n\n return new_string\n\n else:\n\n return strVar\n\n#--------- JUST FOR RUN -----------\ns1 = 'cache\\bt_02.abc'\nprint(slashPath(s1))\n#result = cache/bt_02.abc\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74357780", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20212075/" ]
74,357,783
<p>I have a textbox bound to a string property, containing numeric values</p> <pre><code>&lt;TextBox Name=&quot;txtInvAmount&quot; Text=&quot;{Binding Path=InvAmount,UpdateSourceTrigger=PropertyChanged, StringFormat=\{0:F\}}&quot;/&gt; Private _invAmount as String Public Property InvAmount As String Get _invAmount = _objInvoice.AMOUNT.ToString Return _invAmount End Get Set(ByVal value As String) _invAmount = value If IsNumeric(_invAmount) Then _objInvoice.AMOUNT = value Else _objInvoice.AMOUNT = Nothing End If NotifyPropertyChange(&quot;InvAmount&quot;) End Set End Property </code></pre> <p>how can I get my string to be formatted as a number, using &quot;.&quot; as thousands separator and &quot;,&quot; as decimal separator (eg: &quot;1000&quot; should be formatted as &quot;1.000,00&quot;)?</p> <p>PS: I also tried to set</p> <pre><code>Public Property InvAmount As Double? </code></pre> <p>that made text value to be displayed with trailing zeros, but not with thousands separator (ie: &quot;1000&quot; is displayed as &quot;1000,00&quot;, but not as &quot;1.000,00&quot;)</p>
[ { "answer_id": 74357997, "author": "Vin", "author_id": 7955271, "author_profile": "https://Stackoverflow.com/users/7955271", "pm_score": 1, "selected": false, "text": "\"B:\\shot_001\\cache\\nt_02.abc\"\n" }, { "answer_id": 74367008, "author": "Milad Hatam", "author_id": 5143433, "author_profile": "https://Stackoverflow.com/users/5143433", "pm_score": 1, "selected": true, "text": "import os\nimport re\n\n\ndef slashPath(path):\n\n \"\"\"\n\n param: str file path\n\n return: str file path with \"\\\\\" replaced by '/' \n\n \"\"\"\n\n path = rawString(path)\n\n raw_path = r\"{}\".format(path)\n\n separator = os.path.normpath(\"/\")\n\n changeSlash = lambda x: '/'.join(x.split(separator))\n\n if raw_path.startswith('\\\\'):\n\n return '/' + changeSlash(raw_path)\n\n else:\n\n return changeSlash(raw_path)\n\ndef rawString(strVar):\n\n \"\"\"Returns a raw string representation of strVar.\n\n Will replace '\\\\' with '/'\n\n :param: str String to change to raw\n\n \"\"\"\n\n if type(strVar) is str:\n\n strVarRaw = r'%s' % strVar\n\n new_string=''\n\n escape_dict={'\\a':r'\\a', '\\b':r'\\b', '\\c':r'\\c', '\\f':r'\\f', '\\n':r'\\n',\n\n '\\r':r'\\r', '\\t':r'\\t', '\\v':r'\\v', '\\'':r'\\'', '\\\"':r'\\\"',\n\n '\\0':r'\\0', '\\1':r'\\1', '\\2':r'\\2', '\\3':r'\\3', '\\4':r'\\4',\n\n '\\5':r'\\5', '\\6':r'\\6', '\\7':r'\\7', '\\8':r'\\8', '\\9':r'\\9'}\n\n for char in strVarRaw:\n\n try: new_string+=escape_dict[char]\n\n except KeyError: new_string+=char\n\n return new_string\n\n else:\n\n return strVar\n\n#--------- JUST FOR RUN -----------\ns1 = 'cache\\bt_02.abc'\nprint(slashPath(s1))\n#result = cache/bt_02.abc\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74357783", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5974140/" ]
74,357,798
<p>The for loop is not working to expand the image.</p> <p>When I place an index at the end, it works. So I know indirectly that there is nothing wrong with HTML and CSS, and that the function works.</p> <pre><code>const expandImage = document.getElementsByClassName('website_image')[0]; expandImage.addEventListener('mouseover', expand); function expand(event){ expandImage.style.padding='11%'; } </code></pre> <p>However, when I attempt to do a for loop:</p> <pre><code>const expandImage = document.getElementsByClassName('website_image'); for(let i=0; i&lt;expandImage.length; i++) { expandImage.addEventListener('mouseover', expand); function expand(event){ expandImage.style.padding='11%'; } } </code></pre> <p>Nothing happens.</p> <p>What am I doing wrong?</p>
[ { "answer_id": 74357846, "author": "Elvin", "author_id": 11743253, "author_profile": "https://Stackoverflow.com/users/11743253", "pm_score": 0, "selected": false, "text": "expandImage[i]" }, { "answer_id": 74357866, "author": "Benjamin Penney", "author_id": 6545526, "author_profile": "https://Stackoverflow.com/users/6545526", "pm_score": 2, "selected": true, "text": "[0]" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74357798", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20002701/" ]
74,357,815
<p>I am testing <a href="https://github.com/RxSwiftCommunity/RxDataSources" rel="nofollow noreferrer">RxDataSources</a> which requires the models to conform to the <code>Equatable</code> and <code>IdentifiableType</code>(similar to <code>Identifiable</code> protocols.</p> <p>I am using a unidirectional data flow to drive the UI and my model is the following enum:</p> <pre class="lang-swift prettyprint-override"><code>enum ViewModelType: Equatable, IdentifiableType { case loading case post(Post) var identity: String { switch self { case .loading: return &quot;???&quot; // &lt;-- What to choose here? case let .post(post): return String(post.id) } } static func == (lhs: ViewModel.ViewModelType, rhs: ViewModel.ViewModelType) -&gt; Bool { switch (lhs, rhs) { case (.loading, .loading): return true case let (.post(l), .post(r)): return l == r default: return false } } } } </code></pre> <p>Concerning the <code>.loading</code> ViewModelType, I have to find a possible stable unique identifier if I want to use multiple ViewModelType of this type at once like <code>[.loading, .loading, .loading]</code> or the diffing breaks from <code>identical identifier</code>.</p> <p>I prepared a sample project to reproduce the issue: <a href="https://github.com/florianldt/RxDataSourcesIdentifiableType" rel="nofollow noreferrer">https://github.com/florianldt/RxDataSourcesIdentifiableType</a></p> <p>Any ideas of possible stable unique identifiers I can find for this use case.</p>
[ { "answer_id": 74358769, "author": "Vym", "author_id": 14251124, "author_profile": "https://Stackoverflow.com/users/14251124", "pm_score": 0, "selected": false, "text": "UUID" }, { "answer_id": 74361540, "author": "Daniel T.", "author_id": 506441, "author_profile": "https://Stackoverflow.com/users/506441", "pm_score": 2, "selected": true, "text": "SingleSectionModel" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74357815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5127193/" ]
74,357,826
<p>I'm making an Arduino robot, which is a simple line-following robot, but if I press a button on an IR remote, it continues to line follow, but at a different speed. Here's the code that I've written:</p> <pre><code>#include &lt;IRremote.h&gt; const int RECV_PIN = A5; IRrecv irrecv(RECV_PIN); decode_results results; int cs; // CENTER SENSOR int lmt1 = 5; // LEFT MOTOR 1 int lmt2 = 3; // LEFT MOTOR 2 int rmt1 = 6; // RIGHT MOTOR 1 int rmt2 = 11; // RIGHT MOTOR 2 void setup() { pinMode(8, INPUT); pinMode(lmt1, OUTPUT); pinMode(lmt2, OUTPUT); pinMode(rmt1, OUTPUT); pinMode(rmt2, OUTPUT); Serial.begin(9600); irrecv.enableIRIn(); } void loop() { { if (irrecv.decode(&amp;results)) { Serial.println(results.value, HEX); irrecv.resume(); } } cs = digitalRead(8); if (cs == LOW) { analogWrite(lmt1, 0); analogWrite(lmt2, 175); analogWrite(rmt1, 175); analogWrite(rmt2, 0); } if (cs == HIGH) { analogWrite(lmt1, 175); analogWrite(lmt2, 0); analogWrite(rmt1, 0); analogWrite(rmt2, 175); } if ((results.value == 0xFE58A7) &amp;&amp; (cs == HIGH)) { analogWrite(lmt1, 0); analogWrite(lmt2, 0); analogWrite(rmt1, 100); analogWrite(rmt2, 0); } if ((results.value == 0xFE58A7) &amp;&amp; (cs == LOW)) { analogWrite(lmt1, 0); analogWrite(lmt2, 0); analogWrite(rmt1, 100); analogWrite(rmt2, 0); } } </code></pre> <p>The robot follows the line, but already at a lower speed and the IR remote has no effect on the speed of the robot. I appreciate any help. (I've used an Arduino board and an L298N motor driver)</p>
[ { "answer_id": 74358769, "author": "Vym", "author_id": 14251124, "author_profile": "https://Stackoverflow.com/users/14251124", "pm_score": 0, "selected": false, "text": "UUID" }, { "answer_id": 74361540, "author": "Daniel T.", "author_id": 506441, "author_profile": "https://Stackoverflow.com/users/506441", "pm_score": 2, "selected": true, "text": "SingleSectionModel" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74357826", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20447560/" ]
74,357,842
<p>I am newbie to sql, and this is my first time posting question here.</p> <p>I created a table with 4 column. <strong>Item</strong> (which is Item no.) <strong>Description</strong> (the menu name) <strong>unit_price</strong> (price) and <strong>Qty</strong> (which is the order that has been made for that day). I want the qty of every item so i write this query:</p> <pre><code>select distinct(Item),description,unit_price,qty from cdsitem order by item </code></pre> <p>but the problem is it doesn't add all the qty in the specific item, it looks like this.</p> <p><a href="https://i.stack.imgur.com/dkqG3.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dkqG3.jpg" alt="p1" /></a></p> <p>I want my output to become like this. the sum of quantity in every item no. and description</p> <p><a href="https://i.stack.imgur.com/q5TDh.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/q5TDh.jpg" alt="p2" /></a></p> <p>I hope someone can help me. Thanks</p>
[ { "answer_id": 74357883, "author": "Tim Biegeleisen", "author_id": 1863229, "author_profile": "https://Stackoverflow.com/users/1863229", "pm_score": 0, "selected": false, "text": "SELECT item, description, unit_price, SUM(qty) AS qty\nFROM cdsitem\nGROUP BY 1, 2, 3;\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74357842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16796599/" ]
74,357,894
<p>We have a strange error in Angular 14.<br /> We have made an angular app. If we use the &quot;ng serve&quot; version all work fine.<br /> If we build the production version &quot;ng build&quot; all work fine.<br /> I publish the &quot;dist&quot; to our server and the application cause an error ERROR Error: NG02100 without any explanation.<br /> After investigation we know the problem is the use of pipe | for format date and number on html components (ex. {{ MyDate | &quot;shortDate&quot;}}).<br /> We have removed all the pipe used to format field and in production all &quot;work well&quot;.</p>
[ { "answer_id": 74357883, "author": "Tim Biegeleisen", "author_id": 1863229, "author_profile": "https://Stackoverflow.com/users/1863229", "pm_score": 0, "selected": false, "text": "SELECT item, description, unit_price, SUM(qty) AS qty\nFROM cdsitem\nGROUP BY 1, 2, 3;\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74357894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5884195/" ]
74,357,899
<pre><code>import &quot;dart:math&quot;; import &quot;dart:io&quot;; void main(){ print(&quot;enter first number&quot;); double num1 = double.parse(stdin.readLineSync()); print(&quot;enter second number&quot;); double num2 = double.parse((stdin.readLineSync()); print ( num1 + num2 ); } </code></pre> <p>Why it doesnt compile</p> <p>Enter two numbers from the user add them and the program returns their sum.</p>
[ { "answer_id": 74358031, "author": "Ivo", "author_id": 1514861, "author_profile": "https://Stackoverflow.com/users/1514861", "pm_score": 0, "selected": false, "text": "double.parse" }, { "answer_id": 74358044, "author": "Yeasin Sheikh", "author_id": 10157127, "author_profile": "https://Stackoverflow.com/users/10157127", "pm_score": 1, "selected": false, "text": "double.parse" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74357899", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18175764/" ]
74,357,909
<p>For a simple log reading application, I need to allow a form authentication based on user/password match. The check is done against data stored inside the app settings file so I don't have a DB connected that stores the user data.</p> <p>Googling around I've seen I should inject the <code>private readonly SignInManager&lt;IdentityUser&gt; _signInManager;</code> then use the ``` await _signInManager.SignInAsync(new IdentityUser { UserName = &quot;xxx&quot; }, false);````</p> <p>But I'm not able to configure the service's dependencies...</p> <p>did anyone get an example?</p> <p>Thanks</p> <p>#update #1</p> <pre><code> public class LoginViewModel { #region Properties /// &lt;summary&gt; /// Gets or sets to username address. /// &lt;/summary&gt; [Required] [Display(Name = &quot;Username&quot;)] public string Username { get; set; } /// &lt;summary&gt; /// Gets or sets to password address. /// &lt;/summary&gt; [Required] [DataType(DataType.Password)] [Display(Name = &quot;Password&quot;)] public string Password { get; set; } #endregion } </code></pre>
[ { "answer_id": 74358031, "author": "Ivo", "author_id": 1514861, "author_profile": "https://Stackoverflow.com/users/1514861", "pm_score": 0, "selected": false, "text": "double.parse" }, { "answer_id": 74358044, "author": "Yeasin Sheikh", "author_id": 10157127, "author_profile": "https://Stackoverflow.com/users/10157127", "pm_score": 1, "selected": false, "text": "double.parse" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74357909", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1278204/" ]
74,357,920
<p>I'm learning @media query and I've seen some codes with min-width and some codes with max-width.</p> <p>What is the difference?</p> <p>Which is better for the usage in @media query.</p> <p>Thanks</p> <p>I've tried both (min-width and max-width) but I was unable to see a difference.</p> <p>Thanks in advance</p>
[ { "answer_id": 74358031, "author": "Ivo", "author_id": 1514861, "author_profile": "https://Stackoverflow.com/users/1514861", "pm_score": 0, "selected": false, "text": "double.parse" }, { "answer_id": 74358044, "author": "Yeasin Sheikh", "author_id": 10157127, "author_profile": "https://Stackoverflow.com/users/10157127", "pm_score": 1, "selected": false, "text": "double.parse" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74357920", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20270042/" ]
74,357,925
<p>readFromFile() function is used at the start of the program.</p> <p>When the user writes a name of a file the program should read data from that file if the file exists, if the file with that name does not exist it should keep the name entered by the user and before closing the program write it to that file with the writeToFile() function.</p> <p>The issue is in fp=fopen(a,&quot;w&quot;); the writeTofile() function does not recognize a, so it does not know what name the user entered at the begining of the program. My thinking is that since I have FILE *fp in both it should recognize that &quot;a&quot;. But it does not I cannot figure out how to do it.</p> <p>to summ it up. writeTofile() function needs to know what filename user wrote in readFromFile().</p> <pre><code>void readFromFile(Car reg[], int *pNrOfCars){ FILE *fp; char a[100]; printf(&quot;filename: &quot;); fscanf(stdin,&quot;%s&quot;,a); strcat(a,&quot;.txt&quot;); fp=fopen(a,&quot;r&quot;); if(fp!=NULL){ char model[WORDLENGTH]; int year,milage; while(fscanf(fp,&quot;%s %d %d&quot;,model,&amp;year,&amp;milage)==3){ reg[*pNrOfCars]=createCar(model,year,milage); (*pNrOfCars)++; } fclose(fp); } } </code></pre> <pre><code>void writeToFile(Car reg[], int nrOfCars){ FILE *fp; fp=fopen(a,&quot;w&quot;); if(fp!=NULL){ for (int i = 0; i &lt; nrOfCars; i++){ fprintf(fp,&quot;%s %d %d\n&quot;, reg[i].model, reg[i].year, reg[i].milage); } fclose(fp); } } </code></pre>
[ { "answer_id": 74357975, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": " char a[100];\n printf(\"filename: \");\n fscanf(stdin,\"%s\",a);\n strcat(a,\".txt\");\n" }, { "answer_id": 74357982, "author": "unwind", "author_id": 28169, "author_profile": "https://Stackoverflow.com/users/28169", "pm_score": 1, "selected": true, "text": "a" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74357925", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12818887/" ]
74,357,940
<p>In a large dataset, I need to replace the territory names by their corresponding code.</p> <p>Here below a small replicable example:</p> <pre class="lang-r prettyprint-override"><code>library(tidyverse) library(stringr) library(dplyr) library(tidyr) library(purrr) library(stringi) adrs_data &lt;- data.frame (adress = c(&quot;6 Frien Street, Paris&quot;, &quot;Toulouse, 7 Hospital street&quot;, &quot;10 market avenue (Bordeaux)&quot;) ) dep_code &lt;- data.frame (code = c(&quot;75&quot;, &quot;31&quot;, &quot;33&quot;), names = c(&quot;Paris&quot;, &quot;Toulouse&quot;, &quot;Bordeaux&quot;)) </code></pre> <p>This is what I have tried:</p> <pre class="lang-r prettyprint-override"><code>d_search&lt;-c(dep_code$names) d_search &lt;- paste(paste0(d_search[order(-nchar(d_search))]), collapse = &quot;|&quot;) c_search&lt;-c(dep_code $code) df&lt;-adrs_data %&gt;% dplyr::mutate(c_adress = case_when(adress %in% d_search ~ str_replace_all(adress, d_search, c_search), TRUE ~ adress)) </code></pre> <p>But it does not produce the wanted output which is:</p> <pre class="lang-r prettyprint-override"><code>df &lt;- data.frame (adress = c(&quot;6 Frien Street, 75&quot;, &quot;31, 7 Hospital street&quot;, &quot;10 market avenue (33)&quot;) </code></pre> <p>Thank you for your help, Best regards</p>
[ { "answer_id": 74358440, "author": "Maël", "author_id": 13460602, "author_profile": "https://Stackoverflow.com/users/13460602", "pm_score": 3, "selected": true, "text": "pmap" }, { "answer_id": 74358616, "author": "D.J", "author_id": 12440276, "author_profile": "https://Stackoverflow.com/users/12440276", "pm_score": 0, "selected": false, "text": "adrs_data" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74357940", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16495989/" ]
74,357,961
<p>Not sure what is the issue in my flow:</p> <p>This is sample df:</p> <pre><code>df = pd.DataFrame({'customer':['A','B','C','D','E','F'], 'Traveled':[1,1,1,0,1,0], 'Travel_count':[2,3,5,0,1,0], 'country1':['UK','Italy','CA', '0','UK','0'], 'country2':['JP','IN','CO','0','EG','0'], 'shopping':['High','High','High','High','Medium','Medium'] }) </code></pre> <p>gives:</p> <pre><code> customer Traveled Travel_count country1 country2 shopping 0 A 1 2 UK JP High 1 B 1 3 Italy IN High 2 C 1 5 CA CO High 3 D 0 0 0 0 High 4 E 1 1 UK EG Medium 5 F 0 0 0 0 Medium </code></pre> <p>I want to create some functions that automate filtering and then create a custom made df, so here are two functions that check customers on columns: <code>Traveled ==</code> 1 and <code>shopping == High</code> :</p> <pre><code>def travel(): if (df['Traveled'] == 1): return True else: return False def shop_high(): if (df['shopping'] == 'High'): return True else: return False </code></pre> <p>Here is a nested ifs code if the above conditions are True, it will check those who traveled more or less than 3 times:</p> <pre><code>def select(df): if(travel and shop_high): if (df['Travel_count'] &gt; 3): return (df['customer'], df['shopping'], ('Customer {} traveled more than 3 times').format(df['customer'])) elif (df['Travel_count'] &lt; 3): return (df['customer'], df['shopping'], ('Customer {} traveled less than 3 times').format(df['customer'])) </code></pre> <p>If I apply this function to the original df to automate filtration and checking travel count, I got wrong results:</p> <pre><code>pd.DataFrame(list(df.apply(select, axis = 1).dropna())) </code></pre> <p>results:</p> <pre><code> 0 1 2 0 A High Customer A traveled less than 3 times 1 C High Customer C traveled more than 3 times 2 D High Customer D traveled less than 3 times 3 E Medium Customer E traveled less than 3 times 4 F Medium Customer F traveled less than 3 times </code></pre> <p>Should be:</p> <pre><code> 0 1 2 0 A High Customer A traveled less than 3 times 1 C High Customer C traveled more than 3 times </code></pre>
[ { "answer_id": 74358440, "author": "Maël", "author_id": 13460602, "author_profile": "https://Stackoverflow.com/users/13460602", "pm_score": 3, "selected": true, "text": "pmap" }, { "answer_id": 74358616, "author": "D.J", "author_id": 12440276, "author_profile": "https://Stackoverflow.com/users/12440276", "pm_score": 0, "selected": false, "text": "adrs_data" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74357961", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3135025/" ]
74,357,971
<p>I have a table where there are more columns in the table rows than there are in the header:</p> <p><a href="https://i.stack.imgur.com/9fLph.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9fLph.png" alt="enter image description here" /></a></p> <p>How is it possible to make the header stretch to full width, with html/css, but without adding an empty header column ?</p> <p>My code:</p> <p>HTML:</p> <pre><code>&lt;div id=&quot;thirdTable&quot;&gt; &lt;table&gt; &lt;tbody&gt; &lt;tr&gt; &lt;th&gt;First&lt;/th&gt; &lt;th&gt;Second&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;data goes here&lt;/td&gt; &lt;td&gt;data goes here&lt;/td&gt; &lt;td&gt;data goes here&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;more data here&lt;/td&gt; &lt;td&gt;more data here&lt;/td&gt; &lt;td&gt;more data here&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;/div&gt;; </code></pre> <p>CSS:</p> <pre><code>#thirdTable table { border: none; border-collapse: collapse; } #thirdTable tr { background: linear-gradient(to right, #0033FF, #3399FF); } #thirdTable td { color: white; border: none; padding: 15px 8px 15px 8px; } #thirdTable th { color: #FFCC00; border: none; } </code></pre>
[ { "answer_id": 74358440, "author": "Maël", "author_id": 13460602, "author_profile": "https://Stackoverflow.com/users/13460602", "pm_score": 3, "selected": true, "text": "pmap" }, { "answer_id": 74358616, "author": "D.J", "author_id": 12440276, "author_profile": "https://Stackoverflow.com/users/12440276", "pm_score": 0, "selected": false, "text": "adrs_data" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74357971", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9856049/" ]
74,357,973
<p>I am trying to count all tokens given by func1 and print out the result from func2. The problem is that each time func2 gets called the counter does not update for natural reasons because we call the function over and over again. Are there any ways of solving this? <strong>NOTE</strong>: only func2 is supposed to be changed</p> <pre><code>import nltk def func1(tokens): listOfTokens = tokens.split() for token in listOfTokens: func2(token) def func2(token): count = 0 nltk_tokens = nltk.word_tokenize(token) count += len(nltk_tokens) print(count) # expected to be 4 but is printing : 1 1 1 1 func1(&quot;A b c d&quot;) </code></pre>
[ { "answer_id": 74358027, "author": "assume_irrational_is_rational", "author_id": 11622508, "author_profile": "https://Stackoverflow.com/users/11622508", "pm_score": 2, "selected": true, "text": "import nltk\n\ncount = 0\ndef func1(tokens):\n listOfTokens = tokens.split()\n for token in listOfTokens:\n func2(token)\n\ndef func2(token):\n global count\n nltk_tokens = nltk.word_tokenize(token)\n count += len(nltk_tokens)\n print(count) # expected to be 4 but is printing : 1 1 1 1\n\nfunc1(\"A b c d\")\n" }, { "answer_id": 74358177, "author": "GCMeccariello", "author_id": 16175571, "author_profile": "https://Stackoverflow.com/users/16175571", "pm_score": 0, "selected": false, "text": "def func1(tokens):\n listOfTokens = tokens.split()\n func2(listOfTokens)\n\ndef func2(listOfTokens):\n count = 0\n for token in listOfTokens:\n nltk_tokens = nltk.word_tokenize(token)\n count += len(nltk_tokens)\n print(count) # expected to be 4 but is printing : 1 1 1 1\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74357973", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20179855/" ]
74,357,986
<p><a href="https://i.stack.imgur.com/BXlWl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BXlWl.png" alt="enter image description here" /></a>I am new to Python. I am trying to use the Sympy package. I am running Python 3.11 in Pycharm I am using Windows 10.</p> <p>It displays:</p> <blockquote> <p>ModuleNotFoundError: No module named 'sympy'</p> </blockquote> <p>I ran <code>pip install sympy</code>, it installed it. And when I try reinstalling it, it displays:</p> <blockquote> <p>Requirement already satisfied: sympy in c:\users\jrk\appdata\local\programs\python\python311\lib\site-packages (1.11.1)</p> <p>Requirement already satisfied: mpmath&gt;=0.19 in c:\users\jrk\appdata\local\programs\python\python311\lib\site-packages (from sympy) (1.2.1)</p> </blockquote> <p>I tried going through this guide <a href="https://bobbyhadz.com/blog/python-no-module-named-sympy" rel="nofollow noreferrer">https://bobbyhadz.com/blog/python-no-module-named-sympy</a> but it did not work.</p> <p>I tried uninstalling it and reinstalling it both with pip and mpip it unfortunately didnt work</p> <p>at the top you can see which interpreter i am using</p> <p>I can see that there is a file called sympy in my downloads folder, maybe that has to be relocated, but where to?</p>
[ { "answer_id": 74358943, "author": "voneiden", "author_id": 1744706, "author_profile": "https://Stackoverflow.com/users/1744706", "pm_score": 0, "selected": false, "text": "(venv)" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74357986", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19490945/" ]
74,358,067
<p>I want to query by weekday in a given table on a column storing dates. E.g. <code>select * from MY_TABLE where date_column is 'Monday'</code></p> <p>I saw a <code>DAYOFWEEK()</code> function in mysql. But this only seems to manipulate the results of the query.</p> <p>So is such a query even possible?</p>
[ { "answer_id": 74358290, "author": "Akina", "author_id": 10138734, "author_profile": "https://Stackoverflow.com/users/10138734", "pm_score": 3, "selected": true, "text": "SELECT * \nFROM my_table \nWHERE DATE_FORMAT(date_column, '%W') = 'Monday';\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358067", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1291122/" ]
74,358,086
<p>Problem: In the complete column, there is yes button after clicking on it, it show consulted but problem is only one row is working. I don't understand how i defined each row uniquely. Please have a look at this code and let me know what mistake I'm doing here.</p> <pre><code>&lt;div class=&quot;card-body&quot;&gt; &lt;div class=&quot;table-responsive &quot;&gt; &lt;?php $query = &quot;SELECT * FROM book_now&quot;; $query_run = mysqli_query($conn, $query); ?&gt; &lt;table class=&quot;table table-bordered table table-striped&quot; id=&quot;dataTable&quot; cellspacing=&quot;0&quot;&gt; &lt;thead class=&quot;table table-success text-center&quot; style=&quot;width: 80%&quot;&gt; &lt;tr&gt; &lt;th style=&quot;width: 1%&quot;&gt; S.No &lt;/th&gt; &lt;th&gt; Patient Name &lt;/th&gt; &lt;th&gt; UHID &lt;/th&gt; &lt;th style=&quot;width: 12%&quot;&gt; Time Slot &lt;/th&gt; &lt;th&gt; Contact No &lt;/th&gt; &lt;th&gt; Complete &lt;/th&gt; &lt;th&gt; Write Prescription &lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;?php if(mysqli_num_rows($query_run) &gt; 0) { foreach($query_run as $row) { ?&gt; &lt;tr class=&quot;text-center&quot;&gt; &lt;td&gt;&lt;?php echo $row['booking_id']; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $row['name']; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $row['booked_by']; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $row['appointment_time_slot']; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $row['phone']; ?&gt;&lt;/td&gt; &lt;td&gt; &lt;form action=&quot;&quot; method=&quot;post&quot;&gt; &lt;input onclick=&quot;func()&quot; id=&quot;accountDetails&quot; type=&quot;button&quot; value=&quot;Yes&quot;&gt;&lt;/input&gt; &lt;script&gt; function func() { document.getElementById('accountDetails').value = 'Consulted'; } &lt;/script&gt; &lt;/form&gt; </code></pre>
[ { "answer_id": 74358110, "author": "flyingfox", "author_id": 3176419, "author_profile": "https://Stackoverflow.com/users/3176419", "pm_score": 1, "selected": false, "text": "accountDetails" }, { "answer_id": 74358156, "author": "Rory McCrossan", "author_id": 519413, "author_profile": "https://Stackoverflow.com/users/519413", "pm_score": 3, "selected": true, "text": "id" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358086", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19188060/" ]
74,358,113
<pre><code>$maincategory = Category::all(['id', 'category']); $maintable = Category::orderBy('id', 'DESC')-&gt;get(); $subcategory = Subcategory::all(['id', 'subcategory']); $subtable = Subcategory::orderBy('id', 'DESC')-&gt;get(); return view('admin.news.create', compact('maincategory', $maincategory, 'maintable','subcategory',$subcategory,'subtable')); </code></pre> <p>am getting error on this</p> <pre><code>return view('admin.news.create', compact('maincategory', $maincategory, 'maintable','subcategory',$subcategory,'subtable')); </code></pre> <p>how to solve it?</p>
[ { "answer_id": 74358110, "author": "flyingfox", "author_id": 3176419, "author_profile": "https://Stackoverflow.com/users/3176419", "pm_score": 1, "selected": false, "text": "accountDetails" }, { "answer_id": 74358156, "author": "Rory McCrossan", "author_id": 519413, "author_profile": "https://Stackoverflow.com/users/519413", "pm_score": 3, "selected": true, "text": "id" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358113", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9735069/" ]
74,358,270
<p>I'm trying to get the text content of a specific class across the page, then print them out in a different div, separated by a comma.</p> <p>Example:</p> <pre><code>&lt;!-- Within the HTML Page --&gt; &lt;div class=&quot;copyright&quot;&gt;Image one&lt;/div&gt; &lt;div class=&quot;copyright&quot;&gt;Image two&lt;/div&gt; &lt;div class=&quot;copyright&quot;&gt;Image three&lt;/div&gt; &lt;!-- Should output: &quot;Image one, Image two, Image three&quot; --&gt; &lt;div class=&quot;showCopyright&quot;&gt;&lt;/div&gt; </code></pre> <p>How would I achieve this using only pure VanillaJS, not jQuery?</p> <p>Would I use the innerHTML? or innerText?</p> <p>I really appreciate any help you can provide.</p>
[ { "answer_id": 74358314, "author": "mplungjan", "author_id": 295783, "author_profile": "https://Stackoverflow.com/users/295783", "pm_score": 4, "selected": true, "text": "window.addEventListener(\"DOMContentLoaded\", () => { \n\n document.querySelector(\".showCopyright\")\n .textContent = [...document.querySelectorAll(\".copyright\")]\n .map(({ textContent }) => textContent.trim()).join(\", \");\n\n}); " }, { "answer_id": 74358848, "author": "Faezeh Keshmiri", "author_id": 14361493, "author_profile": "https://Stackoverflow.com/users/14361493", "pm_score": 2, "selected": false, "text": "var textArray = [];\nvar elements = document.getElementsByClassName(\"copyright\");\n\nfor (var i = 0; i < elements.length; i++) {\n textArray.push(elements[i].innerText);\n}\n \ndocument.getElementsByClassName(\"showCopyright\")[0].innerText = textArray.join(', ');" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358270", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11966650/" ]
74,358,283
<p>I am currently reading a range into an array to perform a few calculations before outputting into another worksheet. My reason for using the array is speed as I am often dealing with thousands of rows.</p> <p>I have one particular calculation that I am struggling with for some reason.</p> <p>This is the part I am struggling with (rest of sample of this code is further down):</p> <pre><code>For i = non_rev_rows To 2 Step -1. **' Remove Blank Rows from array If data_range(i, 2) = &quot;No WBS/CC&quot; Then If Application.WorksheetFunction.CountA(Range(&quot;C&quot; &amp; i &amp; &quot;:M&quot; &amp; i)) = 0 Then Rows(i).Delete End If </code></pre> <p>So basically when a row in column 2 is equal to &quot;No WBS/CC&quot; then I need to run a CountA or any other method you can recommend to calcuate the total value of columns C to M on that row. I am essentially looking for any row that = &quot;No WBS/CC&quot; and where columns C:M have no value. If so, then delete the entire row. If there is a value in columns C:M then I would not wish to delete the row.</p> <pre><code>'Row Count With Sheets(&quot;array&quot;) non_rev_rows = .Range(&quot;E&quot; &amp; .Rows.Count).End(xlUp).Row End With ' Remove Blank Rows from array ' Replace &quot;NO WBS/CC&quot; with Co Code Over-Ride if supplied ' Set Debit / Credit ' Round to 2 decimal places Set data = array_sheet.Range(&quot;A1:M&quot; &amp; non_rev_rows) data_range = data.Value For i = non_rev_rows To 2 Step -1. **' Remove Blank Rows from array If data_range(i, 2) = &quot;No WBS/CC&quot; Then If Application.WorksheetFunction.CountA(Range(&quot;C&quot; &amp; i &amp; &quot;:M&quot; &amp; i)) = 0 Then Rows(i).Delete End If ' Replace &quot;NO WBS/CC&quot; with Co Code Over-Ride if supplied If data_range(i, 13) &lt;&gt; 0 Then data_range(i, 2) = data_range(i, 13) End If End If** ' Set Debit / Credit data_range(i, 3) = Replace(data_range(i, 3), &quot;Debit&quot;, 41) data_range(i, 3) = Replace(data_range(i, 3), &quot;Credit&quot;, 51) ' Round to 2 decimal places data_range(i, 5) = WorksheetFunction.Round(data_range(i, 5), 2) ' If data_range(i, 3) = &quot;Debit&quot; Then ' data_range(i, 3).Value = 41 ' ElseIf data_range(i, 3) = &quot;Credit&quot; Then ' data_range(i, 3).Value = 51 ' End If 'data_range(i, 5).Value = Application.WorksheetFunction.Round(Range(data_range(i, 5)).Value, 2) 'Range(&quot;E&quot; &amp; i).Value = Application.WorksheetFunction.Round(Range(&quot;E&quot; &amp; i).Value, 2) Next i </code></pre> <pre><code>**' Remove Blank Rows from array If data_range(i, 2) = &quot;No WBS/CC&quot; Then If Application.WorksheetFunction.CountA(Range(&quot;C&quot; &amp; i &amp; &quot;:M&quot; &amp; i)) = 0 Then Rows(i).Delete End If </code></pre> <p>This code does not result in an error but it also does not have the desired impact. I have several rows in my test data that contain &quot;No WBS/CC&quot; in column 2 and zero values in columns C:M but the code is not deleting those rows.</p>
[ { "answer_id": 74360344, "author": "Robert Mearns", "author_id": 5050, "author_profile": "https://Stackoverflow.com/users/5050", "pm_score": 0, "selected": false, "text": "Public Sub Test2()\n\nDim data_range As Variant\nDim lRows As Long\nDim lColumns As Long\nDim lCounter As Long\n\ndata_range = Sheet1.Range(\"A1:M6\")\n' Add the data to an array\n\nFor lRows = UBound(data_range) To LBound(data_range) Step -1\n'Step through the array in reverse\n If data_range(lRows, 2) = \"No WBS/CC\" Then\n'Check for the \"No WBS/CC\" value in the second column of the array\n \n lCounter = 0\n'Reset the counter\n\n For lColumns = 3 To 13\n If Not IsEmpty(data_range(lRows, lColumns)) Then\n lCounter = lCounter + 1\n End If\n Next lColumns\n'Check columns in the array row to see if they have data\n'Add to the counter for each cell having value\n \n If lCounter = 0 Then\n Sheet1.Rows(lRows).EntireRow.Delete\n End If\n'If the counter is zero delete the current row in the Workbook\n\n End If\nNext lRows\n\n\nEnd Sub\n" }, { "answer_id": 74361357, "author": "VBasic2008", "author_id": 9814069, "author_profile": "https://Stackoverflow.com/users/9814069", "pm_score": 0, "selected": false, "text": "Sub DoStuff()\n\n Dim wb As Workbook: Set wb = ThisWorkbook\n Dim ws As Worksheet: Set ws = wb.Worksheets(\"Array\")\n \n Dim LastRow As Long: LastRow = ws.Cells(ws.Rows.Count, \"E\").End(xlUp).Row\n \n Dim rg As Range: Set rg = ws.Range(\"A2\", ws.Cells(LastRow, \"M\"))\n Dim rCount As Long: rCount = rg.Rows.Count\n Dim cCount As Long: cCount = rg.Columns.Count\n \n Dim Data() As Variant: Data = rg.Value\n \n Dim sr As Long\n Dim dr As Long\n Dim c As Long\n \n For sr = 1 To rCount\n If Not IsRowBlank(Data, sr, 3, 13) Then ' is not blank\n ' Replace \"NO WBS/CC\" with Co Code Over-Ride if supplied\n If CStr(Data(sr, 1)) = \"No WBS/CC\" Then\n If Data(sr, 13) <> 0 Then\n Data(sr, 2) = Data(sr, 13)\n End If\n End If\n ' Set Debit / Credit\n Data(sr, 3) = Replace(Data(sr, 3), \"Debit\", 41)\n Data(sr, 3) = Replace(Data(sr, 3), \"Credit\", 51)\n ' Round to 2 decimal places\n Data(sr, 5) = Application.Round(Data(sr, 5), 2)\n ' Copy source row to destination row.\n dr = dr + 1\n For c = 1 To cCount\n Data(dr, c) = Data(sr, c)\n Next c\n 'Else ' is blank; do nothing\n End If\n Next sr\n\n ' Clear bottom source data.\n If dr < rCount Then\n For sr = dr + 1 To rCount\n For c = 1 To cCount\n Data(sr, c) = Empty\n Next c\n Next sr\n End If\n \n rg.Value = dData\n\nEnd Sub\n\nFunction IsRowBlank( _\n Data() As Variant, _\n ByVal DataRow As Long, _\n ByVal StartColumn As Long, _\n ByVal EndColumn As Long) _\nAs Boolean\n Dim c As Long\n For c = StartColumn To EndColumn\n If Len(CStr(Data(DataRow, c))) > 0 Then Exit For\n Next c\n IsRowBlank = c > EndColumn\nEnd Function\n" }, { "answer_id": 74390751, "author": "FaneDuru", "author_id": 2233308, "author_profile": "https://Stackoverflow.com/users/2233308", "pm_score": 1, "selected": false, "text": "Sub DeleteArrayRows()\nDim array_sheet As Worksheet, non_rev_rows As Long, Data As Range, count2 As Long, data_range, arrRow, i As Long\n\nSet array_sheet = ActiveSheet 'worksheets(\"array\")\n non_rev_rows = array_sheet.Range(\"E\" & array_sheet.rows.count).End(xlUp).row\n\nSet Data = array_sheet.Range(\"A1:M\" & non_rev_rows)\ndata_range = Data.Value\n\nFor i = 1 To UBound(data_range)\n count2 = 0\n If data_range(i, 2) = \"No WBS/CC\" Then\n With Application\n arrRow = .Transpose(.Transpose(.Index(data_range, i, 0))) 'extract a slice of the row array\n End With\n Debug.Print Join(arrRow, \"\"): Stop 'just to see the joinned respecitve slice In Immediate Window\n 'comment it after seeing what it represents and press F5\n If data_range(i, 1) <> \"\" Then count2 = Len(data_range(i, 1))\n If Len(Join(arrRow, \"\")) - count2 = Len(data_range(i, 2)) Then\n data_range = DeleteArrayRow_(data_range, i): i = i - 1\n End If\n End If\n If i = UBound(data_range) Then Exit For\nNext i\n'drop the array (without deleted rows) in a range:\narray_sheet.Range(\"O1\").Resize(UBound(data_range), UBound(data_range, 2)).Value = data_range\nEnd Sub\n\nPrivate Function DeleteArrayRow_(arr As Variant, RowToDelete As Long) As Variant 'interesting...\n'It does not work to eliminate the first array row...\nDim Rws As Long, cols As String\nRws = UBound(arr) - LBound(arr)\ncols = \"A:\" & Split(Columns(UBound(arr, 2) - LBound(arr, 2) + 1).address(, 0), \":\")(0)\n\nDeleteArrayRow_ = Application.Index(arr, Application.Transpose(Split(Join(Application.Transpose(Evaluate(\"Row(1:\" & _\n (RowToDelete - 1) & \")\"))) & \" \" & Join(Application.Transpose(Evaluate(\"Row(\" & _\n (RowToDelete + 1) & \":\" & UBound(arr) & \")\"))))), Evaluate(\"COLUMN(\" & cols & \")\"))\nEnd Function\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10029077/" ]
74,358,309
<p>I have a table called deals, it has records like this for example</p> <pre><code>id deal_ref objectname status 1 1234 tom correct 2 1234 tom correct 3 1234 jerry wrong 4 1234 tom correct </code></pre> <p>I need to identify all latest deals where the status is &quot;correct for example, but the last entry(row 4) must meet the following criteria, where the Max ID is equal to the deal_ref and the status is correct</p> <p>I tried this</p> <pre><code>select distinct deal_ref, deal_status from dealv1 d where d.deal_ref = max(id) and d.deal_status = 'Prospect' and date_created between '2022-11-02 00:00:00' and '2022-11-04 00:00:00' </code></pre>
[ { "answer_id": 74360344, "author": "Robert Mearns", "author_id": 5050, "author_profile": "https://Stackoverflow.com/users/5050", "pm_score": 0, "selected": false, "text": "Public Sub Test2()\n\nDim data_range As Variant\nDim lRows As Long\nDim lColumns As Long\nDim lCounter As Long\n\ndata_range = Sheet1.Range(\"A1:M6\")\n' Add the data to an array\n\nFor lRows = UBound(data_range) To LBound(data_range) Step -1\n'Step through the array in reverse\n If data_range(lRows, 2) = \"No WBS/CC\" Then\n'Check for the \"No WBS/CC\" value in the second column of the array\n \n lCounter = 0\n'Reset the counter\n\n For lColumns = 3 To 13\n If Not IsEmpty(data_range(lRows, lColumns)) Then\n lCounter = lCounter + 1\n End If\n Next lColumns\n'Check columns in the array row to see if they have data\n'Add to the counter for each cell having value\n \n If lCounter = 0 Then\n Sheet1.Rows(lRows).EntireRow.Delete\n End If\n'If the counter is zero delete the current row in the Workbook\n\n End If\nNext lRows\n\n\nEnd Sub\n" }, { "answer_id": 74361357, "author": "VBasic2008", "author_id": 9814069, "author_profile": "https://Stackoverflow.com/users/9814069", "pm_score": 0, "selected": false, "text": "Sub DoStuff()\n\n Dim wb As Workbook: Set wb = ThisWorkbook\n Dim ws As Worksheet: Set ws = wb.Worksheets(\"Array\")\n \n Dim LastRow As Long: LastRow = ws.Cells(ws.Rows.Count, \"E\").End(xlUp).Row\n \n Dim rg As Range: Set rg = ws.Range(\"A2\", ws.Cells(LastRow, \"M\"))\n Dim rCount As Long: rCount = rg.Rows.Count\n Dim cCount As Long: cCount = rg.Columns.Count\n \n Dim Data() As Variant: Data = rg.Value\n \n Dim sr As Long\n Dim dr As Long\n Dim c As Long\n \n For sr = 1 To rCount\n If Not IsRowBlank(Data, sr, 3, 13) Then ' is not blank\n ' Replace \"NO WBS/CC\" with Co Code Over-Ride if supplied\n If CStr(Data(sr, 1)) = \"No WBS/CC\" Then\n If Data(sr, 13) <> 0 Then\n Data(sr, 2) = Data(sr, 13)\n End If\n End If\n ' Set Debit / Credit\n Data(sr, 3) = Replace(Data(sr, 3), \"Debit\", 41)\n Data(sr, 3) = Replace(Data(sr, 3), \"Credit\", 51)\n ' Round to 2 decimal places\n Data(sr, 5) = Application.Round(Data(sr, 5), 2)\n ' Copy source row to destination row.\n dr = dr + 1\n For c = 1 To cCount\n Data(dr, c) = Data(sr, c)\n Next c\n 'Else ' is blank; do nothing\n End If\n Next sr\n\n ' Clear bottom source data.\n If dr < rCount Then\n For sr = dr + 1 To rCount\n For c = 1 To cCount\n Data(sr, c) = Empty\n Next c\n Next sr\n End If\n \n rg.Value = dData\n\nEnd Sub\n\nFunction IsRowBlank( _\n Data() As Variant, _\n ByVal DataRow As Long, _\n ByVal StartColumn As Long, _\n ByVal EndColumn As Long) _\nAs Boolean\n Dim c As Long\n For c = StartColumn To EndColumn\n If Len(CStr(Data(DataRow, c))) > 0 Then Exit For\n Next c\n IsRowBlank = c > EndColumn\nEnd Function\n" }, { "answer_id": 74390751, "author": "FaneDuru", "author_id": 2233308, "author_profile": "https://Stackoverflow.com/users/2233308", "pm_score": 1, "selected": false, "text": "Sub DeleteArrayRows()\nDim array_sheet As Worksheet, non_rev_rows As Long, Data As Range, count2 As Long, data_range, arrRow, i As Long\n\nSet array_sheet = ActiveSheet 'worksheets(\"array\")\n non_rev_rows = array_sheet.Range(\"E\" & array_sheet.rows.count).End(xlUp).row\n\nSet Data = array_sheet.Range(\"A1:M\" & non_rev_rows)\ndata_range = Data.Value\n\nFor i = 1 To UBound(data_range)\n count2 = 0\n If data_range(i, 2) = \"No WBS/CC\" Then\n With Application\n arrRow = .Transpose(.Transpose(.Index(data_range, i, 0))) 'extract a slice of the row array\n End With\n Debug.Print Join(arrRow, \"\"): Stop 'just to see the joinned respecitve slice In Immediate Window\n 'comment it after seeing what it represents and press F5\n If data_range(i, 1) <> \"\" Then count2 = Len(data_range(i, 1))\n If Len(Join(arrRow, \"\")) - count2 = Len(data_range(i, 2)) Then\n data_range = DeleteArrayRow_(data_range, i): i = i - 1\n End If\n End If\n If i = UBound(data_range) Then Exit For\nNext i\n'drop the array (without deleted rows) in a range:\narray_sheet.Range(\"O1\").Resize(UBound(data_range), UBound(data_range, 2)).Value = data_range\nEnd Sub\n\nPrivate Function DeleteArrayRow_(arr As Variant, RowToDelete As Long) As Variant 'interesting...\n'It does not work to eliminate the first array row...\nDim Rws As Long, cols As String\nRws = UBound(arr) - LBound(arr)\ncols = \"A:\" & Split(Columns(UBound(arr, 2) - LBound(arr, 2) + 1).address(, 0), \":\")(0)\n\nDeleteArrayRow_ = Application.Index(arr, Application.Transpose(Split(Join(Application.Transpose(Evaluate(\"Row(1:\" & _\n (RowToDelete - 1) & \")\"))) & \" \" & Join(Application.Transpose(Evaluate(\"Row(\" & _\n (RowToDelete + 1) & \":\" & UBound(arr) & \")\"))))), Evaluate(\"COLUMN(\" & cols & \")\"))\nEnd Function\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358309", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20128903/" ]
74,358,319
<p>I've seen this term being used in a couple of places. The <a href="https://git-scm.com/docs" rel="nofollow noreferrer">official documentation</a> doesn't define this explicitly and there's also no Stack Overflow question answering this so I think it's good to have a source defining this.</p> <p>I <em>think</em> the git suite is a collection of commands and tools you get when you install git. Some of the tools in the git suite are: <code>git</code>, <code>git gui</code> and <code>gitk</code>.</p>
[ { "answer_id": 74361195, "author": "matt", "author_id": 341994, "author_profile": "https://Stackoverflow.com/users/341994", "pm_score": 2, "selected": false, "text": "git add" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358319", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61109/" ]
74,358,322
<p>I have this dataframe:</p> <pre><code>vehicles &lt;- tibble(vehicle = c(&quot;Car&quot;, &quot;Car&quot;, &quot;Motorbike&quot;), color = c(&quot;Red&quot;, &quot;Black&quot;, &quot;Blue&quot;), speed = c(&quot;Low&quot;, &quot;High&quot;, &quot;High&quot;)) </code></pre> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: left;">vehicle</th> <th style="text-align: left;">color</th> <th style="text-align: left;">speed</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">Car</td> <td style="text-align: left;">Red</td> <td style="text-align: left;">Low</td> </tr> <tr> <td style="text-align: left;">Car</td> <td style="text-align: left;">Black</td> <td style="text-align: left;">High</td> </tr> <tr> <td style="text-align: left;">Motorbike</td> <td style="text-align: left;">Blue</td> <td style="text-align: left;">High</td> </tr> </tbody> </table> </div> <p>I would like to create a new column that pastes the categorical values of columns that I choose based on a vector.</p> <p>For instance, if I want to create a categorical column based on vehicle and color, I would do:</p> <pre><code>vehicles %&gt;% mutate(category = paste(vehicle, color, sep = &quot;_&quot;)) </code></pre> <p>Which would give me:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: left;">vehicle</th> <th style="text-align: left;">color</th> <th style="text-align: left;">speed</th> <th style="text-align: left;">category</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">Car</td> <td style="text-align: left;">Red</td> <td style="text-align: left;">Low</td> <td style="text-align: left;">Car_Red</td> </tr> <tr> <td style="text-align: left;">Car</td> <td style="text-align: left;">Black</td> <td style="text-align: left;">High</td> <td style="text-align: left;">Car_Black</td> </tr> <tr> <td style="text-align: left;">Motorbike</td> <td style="text-align: left;">Blue</td> <td style="text-align: left;">High</td> <td style="text-align: left;">Motorbike_Blue</td> </tr> </tbody> </table> </div> <p>However, I want to embed this code into a function, so that <strong>the columns to paste are determined by a character vector provided by the user.</strong></p> <p>E.g., user chooses <code>choices = c(&quot;vehicle&quot;, &quot;color&quot;, &quot;speed&quot;)</code>. But dplyr's tidy evaluation does not allow me to do <code>vehicles %&gt;% mutate(category = paste(choices, sep = &quot;_&quot;))</code>, because that would simply create a column vector full of &quot;vehicle_color_speed&quot; values. How would I then create something with the same result as:</p> <pre><code>vehicles %&gt;% mutate(category = paste(vehicle, color, speed, sep = &quot;_&quot;)) </code></pre> <p>but using the choices vector.</p>
[ { "answer_id": 74358553, "author": "Maël", "author_id": 13460602, "author_profile": "https://Stackoverflow.com/users/13460602", "pm_score": 3, "selected": true, "text": "rlang::syms" }, { "answer_id": 74363879, "author": "akrun", "author_id": 3732271, "author_profile": "https://Stackoverflow.com/users/3732271", "pm_score": 0, "selected": false, "text": "unite" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15459665/" ]
74,358,323
<p>Here's a sample of my data :</p> <pre><code>k &lt;- structure(list(Required.field = c(&quot;yes&quot;, &quot;yes&quot;, &quot;yes&quot;), Choices = c(&quot;2, Féminin | 1, Masculin&quot;, &quot;1, Oui | 0, Non | 99, Je ne sais pas&quot;, &quot;1, Oui | 0, Non&quot;)), row.names = c(5L, 10L, 15L), class = &quot;data.frame&quot;) &gt; k Required.field Choices 5 yes 2, Fémenin| 1, Masculin 10 yes 1, Oui | 0, Non | 99, Je ne sais pas 15 yes 1, Oui | 0, Non </code></pre> <p>What i'd like to have is something like this :</p> <pre><code>&gt; result Required.field Number Value 5 yes c(2,1) c(Fémenin, Masculin) 10 yes c(1,0,99) c(Oui, Non, Je ne sais pas) 15 yes c(1,0) c(Oui, Non) </code></pre> <p>here's the code i write which doesn't do the job correctly !</p> <pre><code>k$test = strsplit(k$choice,c(&quot; | &quot;), fixed = T) bbl = k %&gt;% mutate(number = str_extract_all(test, &quot;[0-9]+&quot;)) %&gt;% #get only digits mutate(value = str_extract(test, &quot;[aA-zZ].*&quot;)) #get only letters </code></pre> <p>why is it not working exactly?</p>
[ { "answer_id": 74358677, "author": "Maël", "author_id": 13460602, "author_profile": "https://Stackoverflow.com/users/13460602", "pm_score": 2, "selected": false, "text": "tidyr" }, { "answer_id": 74363905, "author": "akrun", "author_id": 3732271, "author_profile": "https://Stackoverflow.com/users/3732271", "pm_score": 0, "selected": false, "text": "library(dplyr)\nlibrary(stringr)\nk %>% \n mutate(Number = str_extract_all(Choices, \"\\\\d+\"),\n Value = str_extract_all(Choices, \"[^0-9,| ]+\") )\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358323", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19323944/" ]
74,358,329
<p>I'm trying to write a function that is finishing my running Process and afterwards opening a batch file. The batch file is just closing my c# .exe and deleting the contents of the txt file.</p> <p>The function I call is triggered on change in a txt file. So when it's triggered I read the number which is written in the txt file and than calling the .bat. But now the Problem after &quot;opening&quot; the .bat my program is not be closed directly. The function is jumping back to where I'm reading out of the txt file. But as I deleted the content of the .txt there is a Error coming up.</p> <pre><code>private void OnChangedUpdate(object sender, FileSystemEventArgs e) { string[] lines = new string[1]; lines = System.IO.File.ReadAllLines(@&quot;Dateien/DB/Status/CheckUpdate.txt&quot;); if (lines[0] == &quot;1&quot;) // Update um 23:30 ausführen { TimerStartUpdate(); } else if (lines[0] == &quot;2&quot;) // Update direkt ausführen { OnTimedEventUpdateDirect(); return; } else { MessageBox.Show(&quot;Updated failed. Please contact supervisor&quot;); } } </code></pre> <pre><code>private void OnTimedEventUpdateDirect() { // Prozess beenden Processfinish_Update(); // Alles schreiben // Bat Datei öffnen Process P = new Process(); P.StartInfo.FileName = &quot;UpdateBDE.bat&quot;; P.StartInfo.WindowStyle = ProcessWindowStyle.Minimized; P.Start(); // Theorie BDE wieder aufmachen in Batdatei } </code></pre> <p>The batch file:</p> <pre><code>TASKKill /IM BDE.exe echo.&gt;Dateien/DB/Status/CheckUpdate.txt </code></pre>
[ { "answer_id": 74358677, "author": "Maël", "author_id": 13460602, "author_profile": "https://Stackoverflow.com/users/13460602", "pm_score": 2, "selected": false, "text": "tidyr" }, { "answer_id": 74363905, "author": "akrun", "author_id": 3732271, "author_profile": "https://Stackoverflow.com/users/3732271", "pm_score": 0, "selected": false, "text": "library(dplyr)\nlibrary(stringr)\nk %>% \n mutate(Number = str_extract_all(Choices, \"\\\\d+\"),\n Value = str_extract_all(Choices, \"[^0-9,| ]+\") )\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20356767/" ]
74,358,376
<p>I try to implement list which returns wrapped elements when accessing directly (by index) or via FOR IN loop statement. At present I have following code:</p> <pre><code>class ItemWrappedList(list): def __getitem__(self, y): result = super().__getitem__(y) return f'&lt;item&gt;{result}&lt;/item&gt;' lst = ItemWrappedList(['1', '2', '3']) for pos in range(len(lst)): print(lst[pos]) #&gt;&gt;&gt; &lt;item&gt;1&lt;/item&gt; #&gt;&gt;&gt; &lt;item&gt;2&lt;/item&gt; #&gt;&gt;&gt; &lt;item&gt;3&lt;/item&gt; for value in lst: print(value) #&gt;&gt;&gt; 1 #&gt;&gt;&gt; 2 #&gt;&gt;&gt; 3 </code></pre> <p>As you can see first loop works correctly, as intended. But second loop calls list methods that I was unable to override. Are there any possibilities to force ItemWrappedList class to have same behavior in all situations?</p> <p>P.S. I tried different ways with implementing/overriding <code>__next__</code> and <code>__iter__</code> methods, but seems that <code>__next__</code> ever not called.</p>
[ { "answer_id": 74358588, "author": "Tomer Ariel", "author_id": 14004541, "author_profile": "https://Stackoverflow.com/users/14004541", "pm_score": 2, "selected": true, "text": "__iter__" }, { "answer_id": 74358624, "author": "S.B", "author_id": 13944524, "author_profile": "https://Stackoverflow.com/users/13944524", "pm_score": 0, "selected": false, "text": "for i in lst" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358376", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6893978/" ]
74,358,377
<p>I have this codes</p> <pre><code>&lt;video playsinline=&quot;&quot; autoplay=&quot;true&quot; loop=&quot;true&quot; muted=&quot;true&quot; id=&quot;robotVid&quot;&gt; &lt;source src=&quot;video1.mp4#t=25,30&quot; type=&quot;video/mp4&quot; autoplay=&quot;&quot; loop=&quot;&quot; muted=&quot;&quot;&gt; &lt;/video&gt; </code></pre> <p>I can't loop it at the time intervals I set. Can anyone help? thanks.</p> <p>I tried the javascript codes but couldn't. It is enough for it to loop at the time intervals I set.</p>
[ { "answer_id": 74358719, "author": "Señor Lancho", "author_id": 19871890, "author_profile": "https://Stackoverflow.com/users/19871890", "pm_score": 0, "selected": false, "text": "<video width=\"320\" height=\"240\" controls loop>\n" }, { "answer_id": 74368213, "author": "Offbeatmammal", "author_id": 1569675, "author_profile": "https://Stackoverflow.com/users/1569675", "pm_score": 3, "selected": true, "text": "loop" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358377", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20448063/" ]
74,358,443
<p>This project is done with Angular and Tailwind CSS.</p> <p>Issue: My divs do not take up all the space available. Each 'a' is a div with a blue background color. The whitespace is the empty space I would like to get rid of <a href="https://i.stack.imgur.com/rNNAp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rNNAp.png" alt="image of output" /></a></p> <p>My code: Here are the simplified contents of my main html file</p> <pre><code> &lt;div class=&quot;container !mx-0 flex flex-row justify-between&quot;&gt; &lt;app-photo-card *ngFor=&quot;let photo_card of photo_cards&quot; [photo_card]=&quot;photo_card&quot; [class]=&quot;'w-full'&quot; &gt;&lt;/app-photo-card&gt; &lt;/div&gt; </code></pre> <p>simplified contents of main ts file</p> <pre><code> photo_cards = [ { title: 'a', content: &quot;&quot;, img_src: '', }, ]; </code></pre> <p>and here are the contents of my photo card component html file</p> <pre><code>&lt;div class=&quot;w-full&quot;&gt; &lt;div class=&quot;w-full bg-blue-500&quot;&gt;a&lt;/div&gt; &lt;/div&gt; </code></pre> <p>Tried a similar version of this code with vanilla html and css and it seemed to work as expected. Really unsure on what I'm doing wrong here.</p> <p>Expected output would be the 4 'a' divs with the blue background spanning across the screen which would result in no whitespace.</p>
[ { "answer_id": 74358517, "author": "Fabian Strathaus", "author_id": 17298437, "author_profile": "https://Stackoverflow.com/users/17298437", "pm_score": 0, "selected": false, "text": "display: inline" }, { "answer_id": 74358620, "author": "Alexis", "author_id": 13986485, "author_profile": "https://Stackoverflow.com/users/13986485", "pm_score": 0, "selected": false, "text": "flex-grow" }, { "answer_id": 74361225, "author": "MrPatel2021", "author_id": 19671394, "author_profile": "https://Stackoverflow.com/users/19671394", "pm_score": 1, "selected": false, "text": "flex-grow" }, { "answer_id": 74373464, "author": "jspoh", "author_id": 20255176, "author_profile": "https://Stackoverflow.com/users/20255176", "pm_score": 1, "selected": true, "text": "container" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358443", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20255176/" ]
74,358,488
<p>I am trying to create a path sequence. The following is a sample dataset:</p> <pre><code>df &lt;- structure(list( sess_id = c(4, 4, 4, 4, 4, 4, 4, 7, 7, 7, 7, 7), Page = c(&quot;A&quot;, &quot;B&quot;, &quot;C&quot;, &quot;D&quot;, &quot;A&quot;, &quot;C&quot;, &quot;B&quot;, &quot;B&quot;, &quot;C&quot;, &quot;D&quot;, &quot;A&quot;, &quot;D&quot;)), .Names = c(&quot;sess_id&quot;, &quot;Page&quot;), row.names = c(NA, -12L), class = &quot;data.frame&quot;) </code></pre> <p>This is the table:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>sess_id</th> <th>Page</th> </tr> </thead> <tbody> <tr> <td>4</td> <td>A</td> </tr> <tr> <td>4</td> <td>B</td> </tr> <tr> <td>4</td> <td>C</td> </tr> <tr> <td>4</td> <td>D</td> </tr> <tr> <td>4</td> <td>A</td> </tr> <tr> <td>4</td> <td>C</td> </tr> <tr> <td>4</td> <td>B</td> </tr> <tr> <td>7</td> <td>B</td> </tr> <tr> <td>7</td> <td>C</td> </tr> <tr> <td>7</td> <td>D</td> </tr> <tr> <td>7</td> <td>A</td> </tr> <tr> <td>7</td> <td>D</td> </tr> </tbody> </table> </div> <p>I would like to add three columns like so:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>sess_id</th> <th>Page</th> <th>Path</th> <th>Start</th> <th>End</th> </tr> </thead> <tbody> <tr> <td>4</td> <td>A</td> <td></td> <td></td> <td></td> </tr> <tr> <td>4</td> <td>B</td> <td>AB</td> <td>A</td> <td>B</td> </tr> <tr> <td>4</td> <td>C</td> <td>ABC</td> <td>A</td> <td>C</td> </tr> <tr> <td>4</td> <td>D</td> <td>ABCD</td> <td>A</td> <td>D</td> </tr> <tr> <td>4</td> <td>A</td> <td>ABCDA</td> <td>A</td> <td>A</td> </tr> <tr> <td>4</td> <td>C</td> <td>BCDAC</td> <td>B</td> <td>C</td> </tr> <tr> <td>4</td> <td>B</td> <td>CDACB</td> <td>C</td> <td>B</td> </tr> <tr> <td>7</td> <td>B</td> <td></td> <td></td> <td></td> </tr> <tr> <td>7</td> <td>C</td> <td>BC</td> <td>B</td> <td>C</td> </tr> <tr> <td>7</td> <td>D</td> <td>BCD</td> <td>B</td> <td>D</td> </tr> <tr> <td>7</td> <td>A</td> <td>BCDA</td> <td>B</td> <td>A</td> </tr> <tr> <td>7</td> <td>D</td> <td>BCDAD</td> <td>B</td> <td>D</td> </tr> </tbody> </table> </div> <p>I am trying to create a path sequence of five pages in each session. And map the start and end of that five-page sequence.</p>
[ { "answer_id": 74358847, "author": "Rui Barradas", "author_id": 8245406, "author_profile": "https://Stackoverflow.com/users/8245406", "pm_score": 2, "selected": false, "text": "rollapplyr" }, { "answer_id": 74358880, "author": "Brendan", "author_id": 15703221, "author_profile": "https://Stackoverflow.com/users/15703221", "pm_score": 2, "selected": false, "text": "Path" }, { "answer_id": 74358977, "author": "ThomasIsCoding", "author_id": 12158757, "author_profile": "https://Stackoverflow.com/users/12158757", "pm_score": 3, "selected": false, "text": "Path" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358488", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2845095/" ]
74,358,500
<p>I am using following code to remove currency symbol and comma from number. This is deceimal number so . is expected</p> <pre><code>private string CleanCurrencyAmount(string no) { no = &quot;£67609.787&quot;; string returnVal = string.Empty; string rgxPattern = @&quot;(\p{Sc})?&quot;; // this doesn't remove comma Regex rgx = new Regex(rgxPattern); string x = rgx.Replace(no, &quot;&quot;); string clean = Regex.Replace(no, &quot;[^A-Za-z0-9 ]&quot;, &quot;&quot;); // this remove . too return returnVal; } </code></pre>
[ { "answer_id": 74358564, "author": "Marvin Klein", "author_id": 13440841, "author_profile": "https://Stackoverflow.com/users/13440841", "pm_score": 0, "selected": false, "text": "string rgxPattern = @\"(\\p{Sc})?(\\.)?\";\n" }, { "answer_id": 74358596, "author": "Poul Bak", "author_id": 5741643, "author_profile": "https://Stackoverflow.com/users/5741643", "pm_score": 3, "selected": true, "text": "character class" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358500", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1892256/" ]
74,358,515
<p>I have vertices(x,y,z) of a polygon as input. How can I render a polygon having these vertices in three.js? THREE.Geometry() is removed from three js. how to draw plane polygon with bufferGeometry or any other method ? now when i draw polygon with vertices it drawing incomplete mesh (polygon). following code is used to draw polygon.</p> <pre><code>const verticesGeometry = new THREE.BufferGeometry().setFromPoints(measurement.coordinates.map((coord) =&gt; new THREE.Vector3(coord.x, coord.y, coord.elevation))) const polygon = new THREE.Mesh(verticesGeometry , new THREE.MeshBasicMaterial({ color: measurement.color, side: THREE.DoubleSide})) scene.add(polygon) </code></pre> <p>screenshots attached of issue, which is i am facing right now, (3 points polygon working perfectly, more than it, rendering incomplete.) thanks in advance. <a href="https://i.stack.imgur.com/hj3RE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hj3RE.png" alt="enter image description here" /></a></p> <p>i also tried THREE.ShapeGeometry() but polygon are rendering to the bottom because THREE.shape() is accepting only VECTOR2 points.i am passing vector3 but it neglecting 3rd (z) point.</p> <pre><code> let polyShape = new THREE.Shape(measurement.coordinates.map((coord) =&gt; new THREE.Vector3(coord.x, coord.y, coord.elevation))) const geometry = new THREE.ShapeGeometry( polyShape ) let polygon = new THREE.Mesh(geometry, new THREE.MeshBasicMaterial({ color: measurement.color, side: THREE.DoubleSide })) </code></pre> <p>see the below image for reference. <a href="https://i.stack.imgur.com/WvT3R.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WvT3R.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74358564, "author": "Marvin Klein", "author_id": 13440841, "author_profile": "https://Stackoverflow.com/users/13440841", "pm_score": 0, "selected": false, "text": "string rgxPattern = @\"(\\p{Sc})?(\\.)?\";\n" }, { "answer_id": 74358596, "author": "Poul Bak", "author_id": 5741643, "author_profile": "https://Stackoverflow.com/users/5741643", "pm_score": 3, "selected": true, "text": "character class" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358515", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17251507/" ]
74,358,524
<p><strong>The build error looks something like this:</strong></p> <p>Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081</p> <p>FAILURE: Build failed with an exception.</p> <ul> <li>What went wrong: A problem occurred configuring root project 'My Project'. Could not determine the dependencies of null. Could not resolve all task dependencies for configuration ':classpath'. <blockquote> <p>Could not resolve com.facebook.react:react-native:+. Required by: project : No matching variant of com.facebook.react:react-native:0.71.0-rc.0 was found. The consumer was configured to find a runtime of a library compatible with Java 11, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '7.3.3'</p> </blockquote> </li> </ul>
[ { "answer_id": 74358580, "author": "Pankaj bhalala", "author_id": 6786766, "author_profile": "https://Stackoverflow.com/users/6786766", "pm_score": 2, "selected": false, "text": "allprojects {\n repositories {\n exclusiveContent {\n filter {\n includeGroup \"com.facebook.react\"\n }\n forRepository {\n maven {\n url \"$rootDir/../node_modules/react-native/android\"\n }\n }\n }\n // ...\n }\n}\n" }, { "answer_id": 74364229, "author": "HarshitMadhav", "author_id": 6243553, "author_profile": "https://Stackoverflow.com/users/6243553", "pm_score": 0, "selected": false, "text": " exclusiveContent {\n // We get React Native's Android binaries exclusively through npm,\n // from a local Maven repo inside node_modules/react-native/.\n // (The use of exclusiveContent prevents looking elsewhere like Maven Central\n // and potentially getting a wrong version.)\n filter {\n includeGroup \"com.facebook.react\"\n }\n forRepository {\n maven {\n url \"$rootDir/../node_modules/react-native/android\"\n }\n }\n }\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358524", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12785681/" ]
74,358,526
<p>This happens when I run <code>npx react-native init AwesomeProject</code>.</p> <p>When I check the system ruby version with <code>ruby -v</code>, it is already 2.7.5. <code>ruby 2.7.5p203 (2021-11-24 revision f69aeb8314) [x86_64-darwin21]</code>. Anyone has any idea for this problem?</p>
[ { "answer_id": 74358580, "author": "Pankaj bhalala", "author_id": 6786766, "author_profile": "https://Stackoverflow.com/users/6786766", "pm_score": 2, "selected": false, "text": "allprojects {\n repositories {\n exclusiveContent {\n filter {\n includeGroup \"com.facebook.react\"\n }\n forRepository {\n maven {\n url \"$rootDir/../node_modules/react-native/android\"\n }\n }\n }\n // ...\n }\n}\n" }, { "answer_id": 74364229, "author": "HarshitMadhav", "author_id": 6243553, "author_profile": "https://Stackoverflow.com/users/6243553", "pm_score": 0, "selected": false, "text": " exclusiveContent {\n // We get React Native's Android binaries exclusively through npm,\n // from a local Maven repo inside node_modules/react-native/.\n // (The use of exclusiveContent prevents looking elsewhere like Maven Central\n // and potentially getting a wrong version.)\n filter {\n includeGroup \"com.facebook.react\"\n }\n forRepository {\n maven {\n url \"$rootDir/../node_modules/react-native/android\"\n }\n }\n }\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13758889/" ]
74,358,559
<p>I want to have an sql update query statement that will update the number of items of a table called people that has more than 400 items and set them to 400.</p> <p>the logic will look like this:</p> <p>Given a org id</p> <p>Find people with claps &gt; 400</p> <p>Update number to 400.</p> <p>I tried this but did not work, because i need also need to check the org id.</p> <pre><code>update people set &quot;availableClaps&quot; = 400 where &quot;availableClaps&quot; &gt; 400 in (select id from people) </code></pre>
[ { "answer_id": 74358580, "author": "Pankaj bhalala", "author_id": 6786766, "author_profile": "https://Stackoverflow.com/users/6786766", "pm_score": 2, "selected": false, "text": "allprojects {\n repositories {\n exclusiveContent {\n filter {\n includeGroup \"com.facebook.react\"\n }\n forRepository {\n maven {\n url \"$rootDir/../node_modules/react-native/android\"\n }\n }\n }\n // ...\n }\n}\n" }, { "answer_id": 74364229, "author": "HarshitMadhav", "author_id": 6243553, "author_profile": "https://Stackoverflow.com/users/6243553", "pm_score": 0, "selected": false, "text": " exclusiveContent {\n // We get React Native's Android binaries exclusively through npm,\n // from a local Maven repo inside node_modules/react-native/.\n // (The use of exclusiveContent prevents looking elsewhere like Maven Central\n // and potentially getting a wrong version.)\n filter {\n includeGroup \"com.facebook.react\"\n }\n forRepository {\n maven {\n url \"$rootDir/../node_modules/react-native/android\"\n }\n }\n }\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20283825/" ]
74,358,563
<p>we have found two error messages when I Upload the same name file. But I want to be only one error message.</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 checkFileName=(name)=&gt;{ // for(let i=0; i&lt;blobs.length;i++ ){ let status=0; blobs.map(function(element){ // console.log(element.name.split("/")[1]); if(element.name.split("/")[1]==name){ // console.log(element.name.split("/")[1]); status=1; } }) // } if(status==1){ return true; } else{ return false; }</code></pre> </div> </div> </p>
[ { "answer_id": 74358580, "author": "Pankaj bhalala", "author_id": 6786766, "author_profile": "https://Stackoverflow.com/users/6786766", "pm_score": 2, "selected": false, "text": "allprojects {\n repositories {\n exclusiveContent {\n filter {\n includeGroup \"com.facebook.react\"\n }\n forRepository {\n maven {\n url \"$rootDir/../node_modules/react-native/android\"\n }\n }\n }\n // ...\n }\n}\n" }, { "answer_id": 74364229, "author": "HarshitMadhav", "author_id": 6243553, "author_profile": "https://Stackoverflow.com/users/6243553", "pm_score": 0, "selected": false, "text": " exclusiveContent {\n // We get React Native's Android binaries exclusively through npm,\n // from a local Maven repo inside node_modules/react-native/.\n // (The use of exclusiveContent prevents looking elsewhere like Maven Central\n // and potentially getting a wrong version.)\n filter {\n includeGroup \"com.facebook.react\"\n }\n forRepository {\n maven {\n url \"$rootDir/../node_modules/react-native/android\"\n }\n }\n }\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20448053/" ]
74,358,591
<p>I'm trying to execute a postgres select query using <code>cursor.execute</code>. How can I write the query if the number of parameters change dynamically.</p> <p>E.g</p> <p>One instance the query can be</p> <pre><code>cursor.execute('SELECT name FROM personal_details WHERE id IN (%s, %s)', (3, 4)) </code></pre> <p>an in some other instance the query can be</p> <pre><code>cursor.execute('SELECT name FROM personal_details WHERE id IN (%s, %s, %s)', (3, 4, 5)) </code></pre> <p>If the parameters are available in a list as <code>ids = [3, 4]</code> or <code>ids = [3, 4, 5]</code> what is the proper way of writing this query</p> <p>I tried with the following code</p> <pre><code>cursor.execute(&quot;SELECT name FROM personal_details WHERE id IN param = %s&quot;, [ids['param']]) </code></pre> <p>But it returned with an error saying <em>TypeError: list indices must be integers or slices, not str</em></p>
[ { "answer_id": 74358686, "author": "Mike Scotty", "author_id": 4349415, "author_profile": "https://Stackoverflow.com/users/4349415", "pm_score": 2, "selected": false, "text": "params = (1, 2, 3, 4, 5)\nsql = f\"SELECT x FROM tbl WHERE id IN ({', '.join(['%s']*len(params))})\"\nprint(sql)\ncursor.execute(sql, params)\n" }, { "answer_id": 74363378, "author": "Adrian Klaver", "author_id": 7070613, "author_profile": "https://Stackoverflow.com/users/7070613", "pm_score": 2, "selected": false, "text": "\ncursor.execute(\"SELECT name FROM personal_details WHERE id IN param = ANY(%s)\", [ids])\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358591", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11496645/" ]
74,358,609
<p>I want to know whether a list content is in a long string. such as:</p> <pre><code>aa=[&quot;column&quot;,&quot;is&quot;,&quot;the&quot;,&quot;word&quot;,&quot;others&quot;, &quot;excludition&quot;] # the list content bb=&quot;from the long text&quot; #the long string cc=[wd in bb for wd in aa] </code></pre> <p>but the <code>cc</code> is <code>[False, False, True, False, False, False]</code>. I want to need the True. if one of the items is true.</p> <p>How to do?</p>
[ { "answer_id": 74358686, "author": "Mike Scotty", "author_id": 4349415, "author_profile": "https://Stackoverflow.com/users/4349415", "pm_score": 2, "selected": false, "text": "params = (1, 2, 3, 4, 5)\nsql = f\"SELECT x FROM tbl WHERE id IN ({', '.join(['%s']*len(params))})\"\nprint(sql)\ncursor.execute(sql, params)\n" }, { "answer_id": 74363378, "author": "Adrian Klaver", "author_id": 7070613, "author_profile": "https://Stackoverflow.com/users/7070613", "pm_score": 2, "selected": false, "text": "\ncursor.execute(\"SELECT name FROM personal_details WHERE id IN param = ANY(%s)\", [ids])\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358609", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3373877/" ]
74,358,639
<p>While using PyCaret's ML capabilities I am facing the following error. The ML Code I am using:</p> <pre class="lang-py prettyprint-override"><code>if choice == &quot;ML&quot;: st.title(&quot;Your Machine Learning Process Starts Here!&quot;) target = st.selectbox(&quot;Select Your Target&quot;, df.columns) setup(df, target=target, silent=True) setup_df = pull() st.info(&quot;This is the ML Experiment Settings&quot;) st.dataframe(setup_df) best_model = compare_models() compare_df = pull() st.info(&quot;This is the ML Model&quot;) st.dataframe(compare_df) best_model </code></pre> <p>Now while running the code I am getting the error:</p> <pre class="lang-py prettyprint-override"><code>TypeError: setup() got an unexpected keyword argument 'silent' Traceback: File &quot;D:\Python Projects\Machine-Learning-App\mlapp\lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py&quot;, line 563, in _run_script exec(code, module.__dict__) File &quot;D:\Python Projects\Machine-Learning-App\app.py&quot;, line 37, in &lt;module&gt; setup(df, target=target, silent=True) </code></pre> <p>Hence, I removed the <code>silent=True</code> and now am getting the following error:</p> <pre class="lang-py prettyprint-override"><code>ValueError: Cannot cast object dtype to float64 Traceback: File &quot;D:\Python Projects\Machine-Learning-App\mlapp\lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py&quot;, line 563, in _run_script exec(code, module.__dict__) File &quot;D:\Python Projects\Machine-Learning-App\app.py&quot;, line 37, in &lt;module&gt; setup(df, target=target) File &quot;C:\Users\aviparna.biswas\AppData\Roaming\Python\Python39\site-packages\pycaret\classification\functional.py&quot;, line 596, in setup return exp.setup( File &quot;C:\Users\aviparna.biswas\AppData\Roaming\Python\Python39\site-packages\pycaret\classification\oop.py&quot;, line 885, in setup self.pipeline.fit(self.X_train, self.y_train) File &quot;C:\Users\aviparna.biswas\AppData\Roaming\Python\Python39\site-packages\pycaret\internal\pipeline.py&quot;, line 211, in fit X, y, _ = self._fit(X, y, **fit_params_steps) File &quot;C:\Users\aviparna.biswas\AppData\Roaming\Python\Python39\site-packages\pycaret\internal\pipeline.py&quot;, line 192, in _fit X, y, fitted_transformer = self._memory_fit( File &quot;D:\Python Projects\Machine-Learning-App\mlapp\lib\site-packages\joblib\memory.py&quot;, line 594, in __call__ return self._cached_call(args, kwargs)[0] File &quot;D:\Python Projects\Machine-Learning-App\mlapp\lib\site-packages\joblib\memory.py&quot;, line 537, in _cached_call out, metadata = self.call(*args, **kwargs) File &quot;D:\Python Projects\Machine-Learning-App\mlapp\lib\site-packages\joblib\memory.py&quot;, line 779, in call output = self.func(*args, **kwargs) File &quot;C:\Users\aviparna.biswas\AppData\Roaming\Python\Python39\site-packages\pycaret\internal\pipeline.py&quot;, line 87, in _fit_transform_one _fit_one(transformer, X, y, message, **fit_params) File &quot;C:\Users\aviparna.biswas\AppData\Roaming\Python\Python39\site-packages\pycaret\internal\pipeline.py&quot;, line 54, in _fit_one transformer.fit(*args, **fit_params) File &quot;C:\Users\aviparna.biswas\AppData\Roaming\Python\Python39\site-packages\pycaret\internal\preprocess\transformers.py&quot;, line 216, in fit self.transformer.fit(*args, **fit_params) File &quot;D:\Python Projects\Machine-Learning-App\mlapp\lib\site-packages\sklearn\impute\_base.py&quot;, line 364, in fit X = self._validate_input(X, in_fit=True) File &quot;D:\Python Projects\Machine-Learning-App\mlapp\lib\site-packages\sklearn\impute\_base.py&quot;, line 319, in _validate_input raise ve File &quot;D:\Python Projects\Machine-Learning-App\mlapp\lib\site-packages\sklearn\impute\_base.py&quot;, line 302, in _validate_input X = self._validate_data( File &quot;D:\Python Projects\Machine-Learning-App\mlapp\lib\site-packages\sklearn\base.py&quot;, line 577, in _validate_data X = check_array(X, input_name=&quot;X&quot;, **check_params) File &quot;D:\Python Projects\Machine-Learning-App\mlapp\lib\site-packages\sklearn\utils\validation.py&quot;, line 791, in check_array array = array.astype(new_dtype) File &quot;D:\Python Projects\Machine-Learning-App\mlapp\lib\site-packages\pandas\core\generic.py&quot;, line 5912, in astype new_data = self._mgr.astype(dtype=dtype, copy=copy, errors=errors) File &quot;D:\Python Projects\Machine-Learning-App\mlapp\lib\site-packages\pandas\core\internals\managers.py&quot;, line 419, in astype return self.apply(&quot;astype&quot;, dtype=dtype, copy=copy, errors=errors) File &quot;D:\Python Projects\Machine-Learning-App\mlapp\lib\site-packages\pandas\core\internals\managers.py&quot;, line 304, in apply applied = getattr(b, f)(**kwargs) File &quot;D:\Python Projects\Machine-Learning-App\mlapp\lib\site-packages\pandas\core\internals\blocks.py&quot;, line 580, in astype new_values = astype_array_safe(values, dtype, copy=copy, errors=errors) File &quot;D:\Python Projects\Machine-Learning-App\mlapp\lib\site-packages\pandas\core\dtypes\cast.py&quot;, line 1292, in astype_array_safe new_values = astype_array(values, dtype, copy=copy) File &quot;D:\Python Projects\Machine-Learning-App\mlapp\lib\site-packages\pandas\core\dtypes\cast.py&quot;, line 1234, in astype_array values = values.astype(dtype, copy=copy) File &quot;D:\Python Projects\Machine-Learning-App\mlapp\lib\site-packages\pandas\core\arrays\categorical.py&quot;, line 556, in astype raise ValueError(msg) </code></pre> <p>Is there any workaround this error? For installing pycaret I have used the command <code>pip install -U --pre pycaret</code> the latest release 3.0.0rc2 which works in python 3.9.</p>
[ { "answer_id": 74358686, "author": "Mike Scotty", "author_id": 4349415, "author_profile": "https://Stackoverflow.com/users/4349415", "pm_score": 2, "selected": false, "text": "params = (1, 2, 3, 4, 5)\nsql = f\"SELECT x FROM tbl WHERE id IN ({', '.join(['%s']*len(params))})\"\nprint(sql)\ncursor.execute(sql, params)\n" }, { "answer_id": 74363378, "author": "Adrian Klaver", "author_id": 7070613, "author_profile": "https://Stackoverflow.com/users/7070613", "pm_score": 2, "selected": false, "text": "\ncursor.execute(\"SELECT name FROM personal_details WHERE id IN param = ANY(%s)\", [ids])\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358639", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13314132/" ]
74,358,665
<p>Is it possible to transpile C# language version 10 or 11 source code to older versions of the C# language? Just like there are transpilers for Javascript to port code written in newer versions of Javascript to older versions of Javascript.</p>
[ { "answer_id": 74358686, "author": "Mike Scotty", "author_id": 4349415, "author_profile": "https://Stackoverflow.com/users/4349415", "pm_score": 2, "selected": false, "text": "params = (1, 2, 3, 4, 5)\nsql = f\"SELECT x FROM tbl WHERE id IN ({', '.join(['%s']*len(params))})\"\nprint(sql)\ncursor.execute(sql, params)\n" }, { "answer_id": 74363378, "author": "Adrian Klaver", "author_id": 7070613, "author_profile": "https://Stackoverflow.com/users/7070613", "pm_score": 2, "selected": false, "text": "\ncursor.execute(\"SELECT name FROM personal_details WHERE id IN param = ANY(%s)\", [ids])\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358665", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15999380/" ]
74,358,684
<p>I'm building the site for a desktop with the CSS below for an element. . .</p> <pre><code>.give-donation-level-btn { font-size: 16px; </code></pre> <p>When I apply the media query for mobile, it controls the desktop style as well.</p> <pre><code>@media screen and (max-width: 767px) { .give-donation-level-btn { font-size: .9rem !important; } </code></pre> <p>With the !important declaration for the query, I thought that style would be applied only to screens ≤. What am I missing?</p>
[ { "answer_id": 74358686, "author": "Mike Scotty", "author_id": 4349415, "author_profile": "https://Stackoverflow.com/users/4349415", "pm_score": 2, "selected": false, "text": "params = (1, 2, 3, 4, 5)\nsql = f\"SELECT x FROM tbl WHERE id IN ({', '.join(['%s']*len(params))})\"\nprint(sql)\ncursor.execute(sql, params)\n" }, { "answer_id": 74363378, "author": "Adrian Klaver", "author_id": 7070613, "author_profile": "https://Stackoverflow.com/users/7070613", "pm_score": 2, "selected": false, "text": "\ncursor.execute(\"SELECT name FROM personal_details WHERE id IN param = ANY(%s)\", [ids])\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358684", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14842298/" ]
74,358,691
<p>My ELT tools imports my data in bigquery and generates/extends automatically the schema for dynamic nested keys (in the schema below, under <code>properties</code>)</p> <p>It looks like this</p> <p><a href="https://i.stack.imgur.com/gTXVm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gTXVm.png" alt="enter image description here" /></a></p> <p>How can I get the list of nested keys of a repeated record ? so for example I can group by properties when those items have said property non-null ?</p> <p>I have tried</p> <pre><code> select column_name from my_schema.INFORMATION_SCHEMA.COLUMNS where table_name = 'my_table </code></pre> <p>But it will only list first level keys</p> <p>From the picture above, I want, as a first step, a SQL query that returns</p> <pre><code>message user_id seeker liker_id rateable_id rateable_type from_organization likeable_type company existing_attempt ... </code></pre> <p>My real goal through, is to group/count my data based on a non-null value of a 2nd level nested properties <code>properties.filters.[filter_type]</code></p> <p>The schema may evolve when our application adds more filters, so this need to be dynamically generated, I can't just hard-code the list of nested keys.</p> <p>Note: this is very similar to this question <a href="https://stackoverflow.com/questions/34890339/how-to-extract-all-the-keys-in-a-json-object-with-bigquery">How to extract all the keys in a JSON object with BigQuery</a> but in my case my data is already in a shcema and it's not a JSON object</p> <p>EDIT:</p> <p>Suppose I have a list of such records with nested properties, how do I write a SQL query that adds a field &quot;enabled_filters&quot; which aggregates, for each item, the list of properties for wihch said property is not null ?</p> <p>Example input (properties.x are dynamic and not known by the programmer)</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>search_id</th> <th>properties.filters.school</th> <th>properties.filters.type</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>MIT</td> <td>master</td> </tr> <tr> <td>2</td> <td>Princetown</td> <td>null</td> </tr> <tr> <td>3</td> <td>null</td> <td>master</td> </tr> </tbody> </table> </div> <p>Example output</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>search_id</th> <th>enabled_filters</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>[&quot;school&quot;, &quot;type&quot;]</td> </tr> <tr> <td>2</td> <td>[&quot;school&quot;]</td> </tr> <tr> <td>3</td> <td>[&quot;type&quot;]</td> </tr> </tbody> </table> </div>
[ { "answer_id": 74358686, "author": "Mike Scotty", "author_id": 4349415, "author_profile": "https://Stackoverflow.com/users/4349415", "pm_score": 2, "selected": false, "text": "params = (1, 2, 3, 4, 5)\nsql = f\"SELECT x FROM tbl WHERE id IN ({', '.join(['%s']*len(params))})\"\nprint(sql)\ncursor.execute(sql, params)\n" }, { "answer_id": 74363378, "author": "Adrian Klaver", "author_id": 7070613, "author_profile": "https://Stackoverflow.com/users/7070613", "pm_score": 2, "selected": false, "text": "\ncursor.execute(\"SELECT name FROM personal_details WHERE id IN param = ANY(%s)\", [ids])\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358691", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2832282/" ]
74,358,694
<p>This is probably a really simple question but, is there a simple way to go from</p> <pre><code>Double myLongNumber = 50.12345678998658576546 </code></pre> <p>to</p> <pre><code>Double myLongNumber = 50.1234 </code></pre> <p>?</p> <p>I just want to reduce the number of decimal digits, not remove them all.</p>
[ { "answer_id": 74358686, "author": "Mike Scotty", "author_id": 4349415, "author_profile": "https://Stackoverflow.com/users/4349415", "pm_score": 2, "selected": false, "text": "params = (1, 2, 3, 4, 5)\nsql = f\"SELECT x FROM tbl WHERE id IN ({', '.join(['%s']*len(params))})\"\nprint(sql)\ncursor.execute(sql, params)\n" }, { "answer_id": 74363378, "author": "Adrian Klaver", "author_id": 7070613, "author_profile": "https://Stackoverflow.com/users/7070613", "pm_score": 2, "selected": false, "text": "\ncursor.execute(\"SELECT name FROM personal_details WHERE id IN param = ANY(%s)\", [ids])\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15172005/" ]
74,358,699
<p>I try to use in_array function which returns True or False depending on value being present in array list and then I want to delete sheets which names are not in the array, but I get Run-time error'9': Subscript out of range after deleting few spreadsheets when there are only two left which names are Nike and second one is random one. Do you know how to fix this ?</p> <pre><code>Function in_array(my_array, my_value) in_array = False For I = LBound(my_array) To UBound(my_array) If my_array(I) = my_value Then in_array = True Exit For End If Next End Function </code></pre> <pre><code>Dim WS_Count As Integer my_array = Array(&quot;Nike&quot;, &quot;Adidas&quot;) WS_Count = ActiveWorkbook.Worksheets.Count For I = 1 To WS_Count test_value = ActiveWorkbook.Worksheets(I).Name Z = in_array(my_array, test_value) If Z = False Then ActiveWorkbook.Worksheets(I).Delete End If Next I End Sub </code></pre>
[ { "answer_id": 74359623, "author": "Max", "author_id": 2760773, "author_profile": "https://Stackoverflow.com/users/2760773", "pm_score": 2, "selected": false, "text": " sub delete_without_asking()\n Application.DisplayAlerts = False 'this stops from asking for each sheet!!!\n Application.ScreenUpdating = False\n my_array = Array(\"Nike\", \"Adidas\")\n \n For Each blatt In ActiveWorkbook.Sheets\n test_value = blatt.Name\n Z = in_array(my_array, test_value)\n If Z = False Then\n blatt.Delete\n End If\n Next blatt\n \n Application.DisplayAlerts = True\n Application.ScreenUpdating = True\n End Sub\n" }, { "answer_id": 74359913, "author": "Vasily", "author_id": 4230409, "author_profile": "https://Stackoverflow.com/users/4230409", "pm_score": 1, "selected": false, "text": "my_array = Array(\"Nike\", \"Adidas\")\nFor Each sh In ActiveWorkbook.Sheets\n If UBound(Filter(my_array, sh.Name, True, vbTextCompare)) < 0 Then sh.Delete\nNext sh\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358699", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12462059/" ]
74,358,702
<p>I have a very large file of about 900k values. It is a repetition of values like</p> <pre><code>/begin throw COLOR red DESCRIPTION &quot;cashmere sofa throw&quot; 10 10 156876 DIMENSION 140 200 STORE_ADDRESS 59110 /end throw </code></pre> <p>The values keep changing, but I need it like below:</p> <pre><code> /begin throw STORE_ADDRESS 59110 COLOR red DESCRIPTION &quot;cashmere sofa throw&quot; 10 10 156876 DIMENSION 140 200 /end throw </code></pre> <p>Currently, my approach is removing the new line and including space in them:</p> <p>the store address is constant throughout the file so I thought of removing it from the index and inserting it before the description</p> <pre class="lang-py prettyprint-override"><code>text_file = open(filename, 'r') filedata = text_file.readlines(); for num,line in enumerate(filedata,0): if '/begin' in line: for index in range(num, len(filedata)): if &quot;store_address 59110 &quot; in filedata[index]: filedata.remove(filedata[index]) filedata.insert(filedata[index-7]) break if &quot;DESCRIPTION&quot; in filedata[index]: try: filedata[index] = filedata[index].replace(&quot;\n&quot;, &quot; &quot;) filedata[index+1] = filedata[index+1].replace(&quot; &quot;,&quot;&quot;).replace(&quot;\n&quot;, &quot; &quot;) filedata[index+2] = filedata[index+2].replace(&quot; &quot;,&quot;&quot;).replace(&quot;\n&quot;, &quot; &quot;) filedata[index+3] = filedata[index+3].replace(&quot; &quot;,&quot;&quot;).replace(&quot;\n&quot;, &quot; &quot;) filedata[index+4] = filedata[index+4].replace(&quot; &quot;,&quot;&quot;).replace(&quot;\n&quot;, &quot; &quot;) filedata[index+5] = filedata[index+5].replace(&quot; &quot;,&quot;&quot;).replace(&quot;\n&quot;, &quot; &quot;) filedata[index+6] = filedata[index+6].replace(&quot; &quot;,&quot;&quot;).replace(&quot;\n&quot;, &quot; &quot;) filedata[index+7] = filedata[index+7].replace(&quot; &quot;,&quot;&quot;).replace(&quot;\n&quot;, &quot; &quot;) filedata[index+8] = filedata[index+8].replace(&quot; &quot;,&quot;&quot;) except IndexError: print(&quot;Error Index DESCRIPTION:&quot;, index, num) if &quot;DIMENSION&quot; in filedata[index]: try: filedata[index] = filedata[index].replace(&quot;\n&quot;, &quot; &quot;) filedata[index+1] = filedata[index+1].replace(&quot; &quot;,&quot;&quot;).replace(&quot;\n&quot;, &quot; &quot;) filedata[index+2] = filedata[index+2].replace(&quot; &quot;,&quot;&quot;).replace(&quot;\n&quot;, &quot; &quot;) filedata[index+3] = filedata[index+3].replace(&quot; &quot;,&quot;&quot;) except IndexError: print(&quot;Error Index DIMENSION:&quot;, index, num) </code></pre> <p>After which I write <code>filedata</code> into another file.</p> <p>This approach is taking too long to run(almost an hour and a half) because as mentioned earlier it is a large file. I was wondering if there was a faster approach to this issue</p>
[ { "answer_id": 74359623, "author": "Max", "author_id": 2760773, "author_profile": "https://Stackoverflow.com/users/2760773", "pm_score": 2, "selected": false, "text": " sub delete_without_asking()\n Application.DisplayAlerts = False 'this stops from asking for each sheet!!!\n Application.ScreenUpdating = False\n my_array = Array(\"Nike\", \"Adidas\")\n \n For Each blatt In ActiveWorkbook.Sheets\n test_value = blatt.Name\n Z = in_array(my_array, test_value)\n If Z = False Then\n blatt.Delete\n End If\n Next blatt\n \n Application.DisplayAlerts = True\n Application.ScreenUpdating = True\n End Sub\n" }, { "answer_id": 74359913, "author": "Vasily", "author_id": 4230409, "author_profile": "https://Stackoverflow.com/users/4230409", "pm_score": 1, "selected": false, "text": "my_array = Array(\"Nike\", \"Adidas\")\nFor Each sh In ActiveWorkbook.Sheets\n If UBound(Filter(my_array, sh.Name, True, vbTextCompare)) < 0 Then sh.Delete\nNext sh\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358702", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20339396/" ]
74,358,723
<p>I have a scenario, wherein I want to return the Zuora Object name from my log table of MSSQL 2016. It should only return in result if it is not processed even once for the current date.</p> <p>For example, Account object out of 3 runs was not processed in the first, processed in the second and then not processed in the third run then the query should not return Account in the result as it is processed at least once.</p> <p>Similarly, if another object like Subscription has not yet been processed in all 3 runs it should print it.</p> <p>I tried the below query but it is not giving me the expected result.</p> <pre><code> Create table dbo.Zuora_JobStatus_test ( Id bigint identity(1,1) not null, [Name] varchar(100), FileId varchar(100), recordCount bigint, processed bit, [status] varchar(100), [Timestamp] datetime ) INSERT INTO dbo.Zuora_JobStatus_test ([Name], FileId, recordCount, processed, [status], [Timestamp]) VALUES ('Subscription','FS1',10, 0, 'completed','2022-11-08 13:05:00.000'), ('Account','FA1',1000, 0, 'completed','2022-11-08 13:50:00.000'), ('Subscription','FS2',15, 0, 'completed','2022-11-08 15:05:00.000'), ('Account','FA2',1003, 1, 'completed','2022-11-08 15:10:00.000'), ('Account','FA3',1004, 0, 'completed','2022-11-08 16:10:00.000') -- Below query prints input data SELECT * FROM dbo.Zuora_JobStatus_test ORDER BY NAME ASC, timestamp desc -- Below query along with the Subscription also prints the Account row, which is not required as it was processed once for the current date. SELECT fileId, name, status, recordCount,[timestamp],processed FROM ( SELECT fileId, name, status, recordCount,[timestamp],processed,rn FROM ( SELECT fileId, name, status, recordCount, [timestamp], processed , ROW_NUMBER() OVER (PARTITION BY Name ORDER BY [TimeStamp] DESC) rn FROM dbo.Zuora_JobStatus_test WHERE [status] = 'Completed' AND [Name] in ('Account','Subscription') ) x WHERE x.rn = 1 )x2 WHERE x2.processed = 0 </code></pre> <p>Using the above query I am still seeing Account in output which should not be the case as it is processed = 1 once for the current date in the second run.</p> <p><a href="https://dbfiddle.uk/AVUPHKte" rel="nofollow noreferrer">DBFIDDLE</a></p> <p><a href="https://i.stack.imgur.com/sBqJj.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sBqJj.jpg" alt="Actual &amp; Expected Output" /></a></p>
[ { "answer_id": 74359623, "author": "Max", "author_id": 2760773, "author_profile": "https://Stackoverflow.com/users/2760773", "pm_score": 2, "selected": false, "text": " sub delete_without_asking()\n Application.DisplayAlerts = False 'this stops from asking for each sheet!!!\n Application.ScreenUpdating = False\n my_array = Array(\"Nike\", \"Adidas\")\n \n For Each blatt In ActiveWorkbook.Sheets\n test_value = blatt.Name\n Z = in_array(my_array, test_value)\n If Z = False Then\n blatt.Delete\n End If\n Next blatt\n \n Application.DisplayAlerts = True\n Application.ScreenUpdating = True\n End Sub\n" }, { "answer_id": 74359913, "author": "Vasily", "author_id": 4230409, "author_profile": "https://Stackoverflow.com/users/4230409", "pm_score": 1, "selected": false, "text": "my_array = Array(\"Nike\", \"Adidas\")\nFor Each sh In ActiveWorkbook.Sheets\n If UBound(Filter(my_array, sh.Name, True, vbTextCompare)) < 0 Then sh.Delete\nNext sh\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8534089/" ]
74,358,754
<p>I am trying to get a Laravel controller to return to a route after a create function is complete.</p> <p>I have tried the following code in the screenshots, PLEASE HELP!!!</p> <p><a href="https://i.stack.imgur.com/u5pVl.jpg" rel="nofollow noreferrer">laravel error screenshot</a></p> <p><a href="https://i.stack.imgur.com/NN6cX.jpg" rel="nofollow noreferrer">mycode file screenshot</a></p>
[ { "answer_id": 74359623, "author": "Max", "author_id": 2760773, "author_profile": "https://Stackoverflow.com/users/2760773", "pm_score": 2, "selected": false, "text": " sub delete_without_asking()\n Application.DisplayAlerts = False 'this stops from asking for each sheet!!!\n Application.ScreenUpdating = False\n my_array = Array(\"Nike\", \"Adidas\")\n \n For Each blatt In ActiveWorkbook.Sheets\n test_value = blatt.Name\n Z = in_array(my_array, test_value)\n If Z = False Then\n blatt.Delete\n End If\n Next blatt\n \n Application.DisplayAlerts = True\n Application.ScreenUpdating = True\n End Sub\n" }, { "answer_id": 74359913, "author": "Vasily", "author_id": 4230409, "author_profile": "https://Stackoverflow.com/users/4230409", "pm_score": 1, "selected": false, "text": "my_array = Array(\"Nike\", \"Adidas\")\nFor Each sh In ActiveWorkbook.Sheets\n If UBound(Filter(my_array, sh.Name, True, vbTextCompare)) < 0 Then sh.Delete\nNext sh\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358754", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20413406/" ]
74,358,774
<p>I currently only have the regex that matches all numbers. But I also want to exlude numbers that are in dates</p> <p>Exlude numbers that are in dates -&gt; 08/11/2022. But include numbers without date.</p> <p>This is my regex: \d+</p>
[ { "answer_id": 74359623, "author": "Max", "author_id": 2760773, "author_profile": "https://Stackoverflow.com/users/2760773", "pm_score": 2, "selected": false, "text": " sub delete_without_asking()\n Application.DisplayAlerts = False 'this stops from asking for each sheet!!!\n Application.ScreenUpdating = False\n my_array = Array(\"Nike\", \"Adidas\")\n \n For Each blatt In ActiveWorkbook.Sheets\n test_value = blatt.Name\n Z = in_array(my_array, test_value)\n If Z = False Then\n blatt.Delete\n End If\n Next blatt\n \n Application.DisplayAlerts = True\n Application.ScreenUpdating = True\n End Sub\n" }, { "answer_id": 74359913, "author": "Vasily", "author_id": 4230409, "author_profile": "https://Stackoverflow.com/users/4230409", "pm_score": 1, "selected": false, "text": "my_array = Array(\"Nike\", \"Adidas\")\nFor Each sh In ActiveWorkbook.Sheets\n If UBound(Filter(my_array, sh.Name, True, vbTextCompare)) < 0 Then sh.Delete\nNext sh\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358774", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19007732/" ]
74,358,780
<p>Here is the data:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Subject code</th> <th>Name</th> </tr> </thead> <tbody> <tr> <td>401</td> <td>John</td> </tr> <tr> <td>422</td> <td>Mary</td> </tr> <tr> <td>463</td> <td>Peter</td> </tr> </tbody> </table> </div> <p>And I would like to create unique id based on the last two digit of the subject code. For example:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>ID</th> <th>Subject code</th> <th>Name</th> </tr> </thead> <tbody> <tr> <td>S01</td> <td>401</td> <td>John</td> </tr> <tr> <td>S22</td> <td>422</td> <td>Mary</td> </tr> <tr> <td>S63</td> <td>463</td> <td>Peter</td> </tr> </tbody> </table> </div> <p>Which library should I use? Should I use case_when() in this situation?</p>
[ { "answer_id": 74358804, "author": "Maël", "author_id": 13460602, "author_profile": "https://Stackoverflow.com/users/13460602", "pm_score": 0, "selected": false, "text": "substr" }, { "answer_id": 74358886, "author": "Chris Ruehlemann", "author_id": 8039978, "author_profile": "https://Stackoverflow.com/users/8039978", "pm_score": 2, "selected": false, "text": "str_extract" }, { "answer_id": 74359069, "author": "ThomasIsCoding", "author_id": 12158757, "author_profile": "https://Stackoverflow.com/users/12158757", "pm_score": 1, "selected": false, "text": "sub" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358780", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20146656/" ]
74,358,784
<p>I have this 2D-list</p> <pre><code>[[&quot;a1&quot;, &quot;b1&quot;, &quot;c1&quot;], [&quot;a2&quot;, &quot;b2&quot;, &quot;c2&quot;]] </code></pre> <p>That I want to transpose to a column-view. Each inner list has the same size.</p> <p>Expected result :</p> <pre><code>[['a1', 'a2'], ['b1', 'b2'], ['c1', 'c2']] </code></pre> <p>I'm looking for a one-liner answer.</p> <p>I've tried the code below that works but needs one line to initialize the <code>l_col</code> variable and two for the loop.</p> <pre class="lang-py prettyprint-override"><code>l = [[&quot;a1&quot;, &quot;b1&quot;, &quot;c1&quot;], [&quot;a2&quot;, &quot;b2&quot;, &quot;c2&quot;]] l_col = [] for i in range(len(l[0])): l_col.append([x[i] for x in l]) print(l_col) # [['a1', 'a2'], ['b1', 'b2'], ['c1', 'c2']] </code></pre> <p>Thanks for your help.</p>
[ { "answer_id": 74358866, "author": "Talha Tayyab", "author_id": 13086128, "author_profile": "https://Stackoverflow.com/users/13086128", "pm_score": 2, "selected": true, "text": "[[x[i] for x in l] for i in range(len(l[0]))]\n" }, { "answer_id": 74358867, "author": "C-3PO", "author_id": 4667669, "author_profile": "https://Stackoverflow.com/users/4667669", "pm_score": 2, "selected": false, "text": "A = [[\"a1\", \"b1\", \"c1\"], [\"a2\", \"b2\", \"c2\"]]\nA_transpose = list(map(list,zip(*A)))\n\nprint('A_transpose: ', A_transpose)\n\n# output:\n# A_transpose: [['a1', 'a2'], ['b1', 'b2'], ['c1', 'c2']]\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20339407/" ]
74,358,793
<p>I am trying to get specific fields from the array I got after <code>aggregate</code>, <code>lookup</code> and some <code>cond</code></p> <p>Below you can see my query</p> <pre class="lang-js prettyprint-override"><code> const attendanceData = await User.aggregate([ { $match: { lastLocationId: Mongoose.Types.ObjectId(typeId), isActive: true, }, }, { $project: { _id: 1, workerId: 1, workerFirstName: 1, workerSurname: 1, }, }, { $lookup: { from: &quot;attendances&quot;, localField: &quot;_id&quot;, foreignField: &quot;employeeId&quot;, as: &quot;attendances&quot;, }, }, { $set: { attendances: { $filter: { input: &quot;$attendances&quot;, cond: { $and: [ { $gte: [&quot;$$this.Date&quot;, new Date(fromDate)], }, { $lte: [&quot;$$this.Date&quot;, new Date(toDate)], }, { $eq: [&quot;$$this.createdAs&quot;, dataType], }, { $eq: [&quot;$$this.status&quot;, true], }, { $eq: [&quot;$$this.workerType&quot;, workerType], }, ], }, }, }, }, }, { $skip: 0 }, { $limit: 10 }, ]); </code></pre> <p>The data as a response i get below</p> <pre class="lang-js prettyprint-override"><code>{ &quot;attendanceSheet&quot;: [ { &quot;_id&quot;: &quot;60dd77c14524e6c116e16aaa&quot;, &quot;workerFirstName&quot;: &quot;MEGHRAJ&quot;, &quot;workerSurname&quot;: &quot;JADHAV&quot;, &quot;workerId&quot;: &quot;2036&quot;, &quot;attendances&quot;: [ { &quot;_id&quot;: &quot;6130781085b5055a15c32f2u&quot;, &quot;workerId&quot;: &quot;2036&quot;, &quot;workerFullName&quot;: &quot;MEGHRAJ JADHAV&quot;, &quot;workerType&quot;: &quot;Employee&quot;, &quot;Date&quot;: &quot;2022-10-01T00:00:00.000Z&quot;, &quot;createdAs&quot;: &quot;ABSENT&quot; }, { &quot;_id&quot;: &quot;6130781085b5055a15c32f2u&quot;, &quot;workerId&quot;: &quot;2036&quot;, &quot;workerFullName&quot;: &quot;MEGHRAJ JADHAV&quot;, &quot;workerType&quot;: &quot;Employee&quot;, &quot;Date&quot;: &quot;2022-10-02T00:00:00.000Z&quot;, &quot;createdAs&quot;: &quot;ABSENT&quot; } ] }, { &quot;_id&quot;: &quot;60dd77c24524e6c116e16c0f&quot;, &quot;workerFirstName&quot;: &quot;SANJAY&quot;, &quot;workerSurname&quot;: &quot;DUTTA&quot;, &quot;workerId&quot;: &quot;2031&quot;, &quot;attendances&quot;: [ { &quot;_id&quot;: &quot;6130781a85b5055a15c3455y&quot;, &quot;workerId&quot;: &quot;2031&quot;, &quot;workerFullName&quot;: &quot;SANJAY DUTTA&quot;, &quot;workerType&quot;: &quot;Employee&quot;, &quot;Date&quot;: &quot;2022-10-02T00:00:00.000Z&quot;, &quot;createdAs&quot;: &quot;ABSENT&quot; } ] } ] } </code></pre> <p>But I want data something like this below only few fields in not every fields</p> <pre class="lang-js prettyprint-override"><code>{ &quot;attendanceSheet&quot;: [ { &quot;_id&quot;: &quot;60dd77c14524e6c116e16aaa&quot;, &quot;workerFirstName&quot;: &quot;MEGHRAJ&quot;, &quot;workerSurname&quot;: &quot;JADHAV&quot;, &quot;workerId&quot;: &quot;2036&quot;, &quot;attendances&quot;: [ { &quot;_id&quot;: &quot;6130781085b5055a15c32f2u&quot;, &quot;Date&quot;: &quot;2022-10-01T00:00:00.000Z&quot;, &quot;createdAs&quot;: &quot;ABSENT&quot; }, { &quot;_id&quot;: &quot;6130781085b5055a15c32f2u&quot;, &quot;Date&quot;: &quot;2022-10-02T00:00:00.000Z&quot;, &quot;createdAs&quot;: &quot;ABSENT&quot; } ] }, { &quot;_id&quot;: &quot;60dd77c24524e6c116e16c0f&quot;, &quot;workerFirstName&quot;: &quot;SANJAY&quot;, &quot;workerSurname&quot;: &quot;DUTTA&quot;, &quot;workerId&quot;: &quot;2031&quot;, &quot;attendances&quot;: [ { &quot;_id&quot;: &quot;6130781a85b5055a15c3455y&quot;, &quot;Date&quot;: &quot;2022-10-02T00:00:00.000Z&quot;, &quot;createdAs&quot;: &quot;ABSENT&quot; } ] } ] } </code></pre>
[ { "answer_id": 74358949, "author": "nimrod serok", "author_id": 18482310, "author_profile": "https://Stackoverflow.com/users/18482310", "pm_score": 1, "selected": false, "text": "$map" }, { "answer_id": 74359165, "author": "chirag prajapati", "author_id": 9468615, "author_profile": "https://Stackoverflow.com/users/9468615", "pm_score": 0, "selected": false, "text": "const attendanceData = await User.aggregate([\n {\n $match: {\n lastLocationId: Mongoose.Types.ObjectId(typeId),\n isActive: true,\n },\n },\n {\n $project: {\n _id: 1,\n workerId: 1,\n workerFirstName: 1,\n workerSurname: 1,\n },\n },\n {\n $lookup: {\n from: \"attendances\",\n localField: \"_id\",\n foreignField: \"employeeId\",\n as: \"attendances\",\n },\n },\n {\n $set: {\n attendances: {\n $filter: {\n input: \"$attendances\",\n cond: {\n $and: [\n {\n $gte: [\"$$this.Date\", new Date(fromDate)],\n },\n {\n $lte: [\"$$this.Date\", new Date(toDate)],\n },\n {\n $eq: [\"$$this.createdAs\", dataType],\n },\n {\n $eq: [\"$$this.status\", true],\n },\n {\n $eq: [\"$$this.workerType\", workerType],\n },\n ],\n },\n },\n },\n },\n },\n {\n $set: {\n attendances: {\n $reduce: {\n input: \"$attendances\",\n initialValue: [],\n in: {\n $concatArrays: [\n \"$$value\",\n [\n {\n _id: \"$$this._id\",\n createdAs: \"$$this.createdAs\",\n Date: \"$$this.Date\",\n },\n ],\n ],\n },\n },\n },\n },\n },\n { $skip: 0 },\n { $limit: 10 },\n ]);\n" }, { "answer_id": 74359807, "author": "rickhg12hs", "author_id": 1409374, "author_profile": "https://Stackoverflow.com/users/1409374", "pm_score": 2, "selected": true, "text": "\"$lookup\"" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358793", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9468615/" ]
74,358,830
<p>I have the following dataframe</p> <pre><code>data = [[[[[1, 2, 0], [1]],[[1, 2], [4]]], [[[[1, 2], [4]]]], [[[1]]]], [[[[1, 2, 0], [1]],[[1, 2], [4]]], [[[[1, 2], [4]]]], [[[1]]]]] df = pd.DataFrame(data) </code></pre> <p>Also, I have a second dataframe <code>df2</code>:</p> <pre><code>data2 = [[1, 10], [1, 15], [1, 14], [1, 20], [1, 18]] df2 = pd.DataFrame(data2, columns=['dir', 'line']) </code></pre> <p>The values of the nested lists of <code>df</code> represent the <code>Index</code> of <code>df2</code>. I would like to replace the values of the nested lists of <code>df</code> with the values of the column line of <code>df2</code>. The expected output is the following:</p> <pre><code>finalData = [[[[[15, 14, 10], [15]],[[15, 14], [20]]], [[[[15, 14], [20]]]], [[[15]]]], [[[[15, 14, 10], [15]],[[15, 14], [20]]], [[[[15, 14], [29]]]], [[[15]]]]] finaldf = pd.DataFrame(finalData) </code></pre>
[ { "answer_id": 74359111, "author": "assume_irrational_is_rational", "author_id": 11622508, "author_profile": "https://Stackoverflow.com/users/11622508", "pm_score": 2, "selected": false, "text": "data = [[[[[1, 2, 0], [1]],[[1, 2], [4]]],\n [[[[1, 2], [4]]]], [[[1]]]], [[[[1, 2, 0], [1]],[[1, 2], [4]]],\n [[[[1, 2], [4]]]], [[[1]]]]]\ndata2 = [[1, 10], [1, 15], [1, 14], [1, 20], [1, 18]]\ndef new_data(data, data2):\n res = []\n for i in data:\n if isinstance(i, list):\n res.append(new_data(i, data2))\n else:\n res.append(data2[i][1])\n return res\nfinal_data = new_data(data, data2)\nprint(final_data)\n\n# output: \n[[[[[15, 14, 10], [15]], [[15, 14], [18]]], [[[[15, 14], [18]]]], [[[15]]]],\n [[[[15, 14, 10], [15]], [[15, 14], [18]]], [[[[15, 14], [18]]]], [[[15]]]]]\n" }, { "answer_id": 74359241, "author": "ILS", "author_id": 10017662, "author_profile": "https://Stackoverflow.com/users/10017662", "pm_score": 1, "selected": true, "text": "data = [[[[[1, 2, 0], [1]],[[1, 2], [4]]],\n [[[[1, 2], [4]]]], [[[1]]]], [[[[1, 2, 0], [1]],[[1, 2], [4]]],\n [[[[1, 2], [4]]]], [[[1]]]]]\ndf = pd.DataFrame(data)\ndata2 = [[1, 10], [1, 15], [1, 14], [1, 20], [1, 18]]\ndf2 = pd.DataFrame(data2, columns=['dir', 'line'])\n\ndef fn(index):\n if isinstance(index, list):\n return [fn(i) for i in index]\n else:\n return df2['line'][index]\n\nfinal = df.applymap(fn)\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358830", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10331807/" ]
74,358,850
<p>I have a button that, when clicked, sends an object [ Dispatch(ADDS(myObject) ], but my [ Reducer ] does not return the object as the first ( index 0 ), it returns the first item ( empty ) because the ( InitialState ) it is set to ( empty ). How do I return the object as ( Index 0 ) ?</p> <p><strong>Console.log</strong></p> <p><a href="https://i.stack.imgur.com/JO3c8.png" rel="nofollow noreferrer">console.log - Prinscreen</a></p> <p><strong>My UI.js</strong></p> <pre><code>import { createSlice } from '@reduxjs/toolkit'; export const slice = createSlice({ name: 'initial', initialState : { product: [], }, reducers: { ADDS(state, actions) { return { ...state, product: actions.payload, } } } }); export const { ADDS } = slice.actions; export default slice.reducer; </code></pre> <p>Thanks</p>
[ { "answer_id": 74359100, "author": "David Bradshaw", "author_id": 2087070, "author_profile": "https://Stackoverflow.com/users/2087070", "pm_score": 0, "selected": false, "text": "product: state.push(actions.payload),\n" }, { "answer_id": 74371340, "author": "Kanti vekariya", "author_id": 14497778, "author_profile": "https://Stackoverflow.com/users/14497778", "pm_score": 1, "selected": false, "text": "product: [...state.product, actions.payload]" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17016241/" ]
74,358,871
<p>Change for example <strong>10100</strong> to decimal and here is how</p> <pre><code>= (1x2)^4 + (0x2)^3 + (1x2)^2 + (0x2)^1 + (0x2)^ 0 = 16 + 0 + 4 + 0 + 0 = 20 </code></pre> <p>Okay I understand the way to convert yet I want to the output <em>not only showing</em> <code>&quot;20&quot;</code> but like :</p> <blockquote> <p>Enter binary : 10100</p> <p>(1x2)^4 + (0x2)^3 + (1x2)^2 + (0x2)^1 + (0x2)^ 0</p> <p>16 + 0 + 4 + 0 + 0</p> <p>20</p> </blockquote> <p>This is my try and the output is not what i want</p> <pre><code>String input = Console.ReadLine(); char[] array = input.ToCharArray(); int npower = array.Length; npower--; int npower1 = array.Length; npower1--; // Reverse since 16-8-4-2-1 not 1-2-4-8-16. Array.Reverse(array); // Reverse since 16-8-4-2-1 not 1-2-4-8-16. /* * [0] = 1 * [1] = 2 * [2] = 4 * etc */ int sum = 0; int i = 0; for (i=0; i &lt; array.Length; i++) { if (array[i] == '1') { // Method uses raising 2 to the power of the index. if (i == 0) { sum += 1; } else { sum += (int)Math.Pow(2, i); } } Console.Write(&quot;(&quot; + array[i]+&quot;*2)^&quot;+npower); npower--; if (npower &gt; -1) { Console.Write(&quot; + &quot;); } } Console.WriteLine(); for (i = 0; i &lt; array.Length; i++) { Console.Write(&quot; &quot; + array[i] * (int)Math.Pow(2, npower1) + &quot;&quot;); npower1--; if (npower1 &gt; -1 ) { Console.Write(&quot; + &quot;); } } Console.WriteLine(); Console.WriteLine(&quot; = &quot;+sum); Console.ReadLine(); </code></pre> <p>The output from the code:</p> <pre><code>10100 (0*2)^4 + (0*2)^3 + (1*2)^2 + (0*2)^1 + (1*2)^0 768 + 384 + 196 + 96 + 49 = 20 </code></pre> <p>Okay the convert result is correct but the step in reverse</p> <p>The output should be like</p> <pre><code>10100 (1*2)^4 + (0*2)^3 + (1*2)^2 + (0*2)^1 + (0*2)^0 16 + 0 + 4 + 0 + 0 = 20 </code></pre> <p>The question is how to implement the output i want please</p>
[ { "answer_id": 74359212, "author": "izlin", "author_id": 3849158, "author_profile": "https://Stackoverflow.com/users/3849158", "pm_score": 0, "selected": false, "text": "Array.Reverse(array);" }, { "answer_id": 74359361, "author": "ElConrado", "author_id": 4510954, "author_profile": "https://Stackoverflow.com/users/4510954", "pm_score": 0, "selected": false, "text": "void MainProgram()\n{\n string binaryValue = \"10100\";\n char[] binaryChars = binaryValue.ToCharArray();\n int result = 0;\n for (int i = binaryChars.Length-1, j = 0; i >= 0; i--, j++)\n {\n try\n {\n int binaryInt = (int)(binaryChars[j] - '0');\n result += OneFactor(i, binaryInt);\n if(i != 0)\n Console.Write(\" + \");\n }\n catch (Exception)\n {\n throw new ArgumentException(\"Cannot parse binary value\");\n }\n }\n Console.Write($\" = {result}\");\n}\n\nint OneFactor(int facorValue, int selected = 0)\n{\n Console.Write($\"({selected}*2)^{facorValue}\");\n if (facorValue == 0 && selected == 0)\n return 0;\n return (int)Math.Pow((selected * 2), facorValue);\n}\n" }, { "answer_id": 74359512, "author": "Dmitry Bychenko", "author_id": 2319407, "author_profile": "https://Stackoverflow.com/users/2319407", "pm_score": 1, "selected": false, "text": "input" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358871", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20448317/" ]
74,358,873
<p>When i set div position absolute then below div come upon it why this happen? on small screen the button comes upon the div why this happen, and also i want that in small mobile screen the div box width to full browser screen</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>.qa-part-q-view { border-radius:5px; border: solid #EBF2F7; min-height:70px; align-items:left; padding:10px;10px; margin: 10px 10px;} /* On screens that are 992px or less, set the background color to blue */ @media screen and (max-width: 992px) { .qa-part-q-view { content: " "; z-index: -1; border: 2px solid #EBF2F7; } /* On screens that are 600px or less, set the background color to olive */ @media screen and (max-width: 600px) { .qa-part-q-view { content: " "; position: absolute; z-index: -1; left: 0px; right: 0px; border: 0 none #ccc; border-bottom: 5px solid #EBF2F7; border-top: 5px solid #EBF2F7; border-radius: 0; padding:10px;10px; margin: 0; } }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="qa-part-q-view"&gt;&lt;p&gt;jjjjjjjjjj&lt;/p&gt; &lt;/div&gt; &lt;button&gt;kkkfkf&lt;/button&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74358906, "author": "Señor Lancho", "author_id": 19871890, "author_profile": "https://Stackoverflow.com/users/19871890", "pm_score": -1, "selected": false, "text": "width: 100vw;\n" }, { "answer_id": 74359097, "author": "Señor Lancho", "author_id": 19871890, "author_profile": "https://Stackoverflow.com/users/19871890", "pm_score": 0, "selected": false, "text": ".qa-part-q-view {\n border-radius:5px;\nborder: solid #EBF2F7;\nmin-height:70px; \nalign-items:left; \npadding:10px;10px; \nmargin: 10px 10px;} \n\n/* On screens that are 992px or less, set the background color to blue */\n@media screen and (max-width: 992px) {\n.qa-part-q-view {\ncontent: \" \";\n z-index: -1;\n \nborder: 2px solid #EBF2F7; \n }\n}\n\n/* On screens that are 600px or less, set the background color to olive */\n@media screen and (max-width: 600px) {\n.qa-part-q-view {\ncontent: \" \";\nposition: absolute;\nz-index: -1;\nleft: 0px;\nright: 0px;\nborder: 0 none #ccc;\nborder-bottom: 5px solid #EBF2F7;\nborder-top: 5px solid #EBF2F7;\nborder-radius: 0;\npadding:10px;10px; \n margin: 0;\n }\n}\n\nbutton {\nwidth: 100vw;\n}\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358873", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20448299/" ]
74,358,900
<p>I am trying to make a function that goes through a dataframe, this df has a column, let's call it &quot;matched&quot; which is numerical and it's an identifier for rows that I need to merge, so it looks something like this:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Id</th> <th>matched</th> <th>name</th> <th>animals</th> <th>flying</th> <th>hierarchy</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>1</td> <td>peter</td> <td>cow</td> <td>yes</td> <td>1</td> </tr> <tr> <td>2</td> <td>1</td> <td>pedro</td> <td></td> <td>no</td> <td>2</td> </tr> <tr> <td>3</td> <td>2</td> <td>angel</td> <td>dog</td> <td>yes</td> <td>1</td> </tr> <tr> <td>4</td> <td>3</td> <td>joshua</td> <td>cat</td> <td>no</td> <td>3</td> </tr> <tr> <td>5</td> <td>3</td> <td>harry</td> <td></td> <td>no</td> <td>1</td> </tr> <tr> <td>6</td> <td>3</td> <td>senna</td> <td>bird</td> <td></td> <td>2</td> </tr> <tr> <td>7</td> <td>4</td> <td>maria</td> <td></td> <td>no</td> <td>2</td> </tr> <tr> <td>8</td> <td>4</td> <td>juan</td> <td></td> <td>no</td> <td>3</td> </tr> <tr> <td>9</td> <td>4</td> <td>luis</td> <td>lama</td> <td>yes</td> <td>2</td> </tr> </tbody> </table> </div> <p>The most important 2 columns are &quot;matched&quot; and &quot;hierarchy&quot;, we are iterating on matched to create the groups in which we want to merge and hierarchy tells us what the best data is. I would like to have this groups:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Id</th> <th>matched</th> <th>name</th> <th>animals</th> <th>flying</th> <th>hierarchy</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>1</td> <td>peter</td> <td>cow</td> <td>yes</td> <td>1</td> </tr> <tr> <td>2</td> <td>1</td> <td>pedro</td> <td></td> <td>no</td> <td>2</td> </tr> </tbody> </table> </div><div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Id</th> <th>matched</th> <th>name</th> <th>animals</th> <th>flying</th> <th>hierarchy</th> </tr> </thead> <tbody> <tr> <td>3</td> <td>2</td> <td>angel</td> <td>dog</td> <td>yes</td> <td>1</td> </tr> </tbody> </table> </div><div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Id</th> <th>matched</th> <th>name</th> <th>animals</th> <th>flying</th> <th>hierarchy</th> </tr> </thead> <tbody> <tr> <td>4</td> <td>3</td> <td>joshua</td> <td>cat</td> <td>no</td> <td>3</td> </tr> <tr> <td>5</td> <td>3</td> <td>harry</td> <td></td> <td>no</td> <td>1</td> </tr> <tr> <td>6</td> <td>3</td> <td>senna</td> <td>bird</td> <td></td> <td>2</td> </tr> </tbody> </table> </div><div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Id</th> <th>matched</th> <th>name</th> <th>animals</th> <th>flying</th> <th>hierarchy</th> </tr> </thead> <tbody> <tr> <td>7</td> <td>4</td> <td>maria</td> <td></td> <td>no</td> <td>2</td> </tr> <tr> <td>8</td> <td>4</td> <td>juan</td> <td></td> <td>no</td> <td>3</td> </tr> <tr> <td>9</td> <td>4</td> <td>luis</td> <td>lama</td> <td>yes</td> <td>2</td> </tr> </tbody> </table> </div> <p>And in the end I would like this outcome for my data: | Id | matched | name | animals | flying | hierarchy| | -------- | -------- | -------- | -------- | -------- | -------- | | 1 | 1 | peter | cow | yes | 1 |</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Id</th> <th>matched</th> <th>name</th> <th>animals</th> <th>flying</th> <th>hierarchy</th> </tr> </thead> <tbody> <tr> <td>3</td> <td>2</td> <td>angel</td> <td>dog</td> <td>yes</td> <td>1</td> </tr> </tbody> </table> </div><div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Id</th> <th>matched</th> <th>name</th> <th>animals</th> <th>flying</th> <th>hierarchy</th> </tr> </thead> <tbody> <tr> <td>5</td> <td>3</td> <td>harry</td> <td>bird</td> <td>no</td> <td>1</td> </tr> </tbody> </table> </div><div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Id</th> <th>matched</th> <th>name</th> <th>animals</th> <th>flying</th> <th>hierarchy</th> </tr> </thead> <tbody> <tr> <td>7</td> <td>4</td> <td>maria</td> <td></td> <td>no</td> <td>2</td> </tr> <tr> <td>9</td> <td>4</td> <td>luis</td> <td>lama</td> <td>yes</td> <td>2</td> </tr> </tbody> </table> </div> <p>it should end up all in one df so the outcome really should look like this:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Id</th> <th>matched</th> <th>name</th> <th>animals</th> <th>flying</th> <th>hierarchy</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>1</td> <td>peter</td> <td>cow</td> <td>yes</td> <td>1</td> </tr> <tr> <td>3</td> <td>2</td> <td>angel</td> <td>dog</td> <td>yes</td> <td>1</td> </tr> <tr> <td>5</td> <td>3</td> <td>harry</td> <td>bird</td> <td>no</td> <td>1</td> </tr> <tr> <td>7</td> <td>4</td> <td>maria</td> <td></td> <td>no</td> <td>2</td> </tr> <tr> <td>9</td> <td>4</td> <td>luis</td> <td>lama</td> <td>yes</td> <td>2</td> </tr> </tbody> </table> </div> <p>As you can see, I want one row per &quot;matched&quot; group unless there are 2 rows (or more) that share the best possible hierarchy in that group. The hierarchy is an int column and the best is 1, then 2 then 3 that is the worst value, this being the worst doesn't mean I want to remove it, but it means it would be better to replace if something better exists for that group, also keeping empty values is not a problem.</p> <p>I would prefer it if the solution didn't use pandas iterrows() since it is a big dataframe and it would run really slow to go through the links</p> <p>I tried using loops through the columns but it is way too slow or straight up doesn't work as I expected it to.</p>
[ { "answer_id": 74358906, "author": "Señor Lancho", "author_id": 19871890, "author_profile": "https://Stackoverflow.com/users/19871890", "pm_score": -1, "selected": false, "text": "width: 100vw;\n" }, { "answer_id": 74359097, "author": "Señor Lancho", "author_id": 19871890, "author_profile": "https://Stackoverflow.com/users/19871890", "pm_score": 0, "selected": false, "text": ".qa-part-q-view {\n border-radius:5px;\nborder: solid #EBF2F7;\nmin-height:70px; \nalign-items:left; \npadding:10px;10px; \nmargin: 10px 10px;} \n\n/* On screens that are 992px or less, set the background color to blue */\n@media screen and (max-width: 992px) {\n.qa-part-q-view {\ncontent: \" \";\n z-index: -1;\n \nborder: 2px solid #EBF2F7; \n }\n}\n\n/* On screens that are 600px or less, set the background color to olive */\n@media screen and (max-width: 600px) {\n.qa-part-q-view {\ncontent: \" \";\nposition: absolute;\nz-index: -1;\nleft: 0px;\nright: 0px;\nborder: 0 none #ccc;\nborder-bottom: 5px solid #EBF2F7;\nborder-top: 5px solid #EBF2F7;\nborder-radius: 0;\npadding:10px;10px; \n margin: 0;\n }\n}\n\nbutton {\nwidth: 100vw;\n}\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358900", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20447797/" ]
74,358,911
<p>I have a table with sorting arrows in the table header. Each <code>th</code> element has a <code>span</code> for text and a <code>span</code> for the sorting arrows. I want the text in the left <code>span</code> to wrap dynamically and the <code>span</code> with the sorting arrows to stay in the top right of the <code>th</code>.</p> <p>CSS:</p> <pre class="lang-css prettyprint-override"><code>th { border: 1px solid black; } .sort { float: right; } .sort-arrow { width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; } .sort-arrow.asc { border-bottom: 5px solid #1F2B39; margin-bottom: 4px; margin-top: 3px; } .sort-arrow.desc { border-top: 5px solid #1F2B39; margin-top: 4px; margin-bottom: 3px; } </code></pre> <p>HTML:</p> <pre class="lang-html prettyprint-override"><code>&lt;table&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt; &lt;span&gt;A pretty pretty pretty pretty pretty pretty pretty pretty pretty pretty pretty pretty pretty pretty pretty pretty pretty pretty long text.&lt;/span&gt; &lt;span class=&quot;sort&quot;&gt; &lt;div class=&quot;sort-arrow asc&quot;&gt;&lt;/div&gt; &lt;div class=&quot;sort-arrow desc&quot;&gt;&lt;/div&gt; &lt;/span&gt; &lt;/th&gt; &lt;th&gt; &lt;span&gt;Short&lt;/span&gt; &lt;span class=&quot;sort&quot;&gt; &lt;div class=&quot;sort-arrow asc&quot;&gt;&lt;/div&gt; &lt;div class=&quot;sort-arrow desc&quot;&gt;&lt;/div&gt; &lt;/span&gt; &lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr&gt;&lt;td&gt;Test&lt;/td&gt;&lt;td&gt;Test&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Test&lt;/td&gt;&lt;td&gt;Test&lt;/td&gt;&lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; </code></pre>
[ { "answer_id": 74359011, "author": "Alexis", "author_id": 13986485, "author_profile": "https://Stackoverflow.com/users/13986485", "pm_score": 1, "selected": false, "text": "position: relative" }, { "answer_id": 74359074, "author": "jessica-98", "author_id": 20261328, "author_profile": "https://Stackoverflow.com/users/20261328", "pm_score": 2, "selected": true, "text": "th,\ntd {\n border: 1px solid black;\n vertical-align: top;\n text-align:left;\n}\n\nthead,\ntbody {\n background: yellow;\n}\n\n.row {\n display: flex;\n align-items: flex-start;\n}\n\n\n\n.sort-arrow {\n width: 0;\n height: 0;\n border-left: 5px solid transparent;\n border-right: 5px solid transparent;\n}\n\n.sort-arrow.asc {\n border-bottom: 5px solid #1F2B39;\n margin-bottom: 4px;\n margin-top: 3px;\n}\n\n.sort-arrow.desc {\n border-top: 5px solid #1F2B39;\n margin-top: 4px;\n margin-bottom: 3px;\n}" }, { "answer_id": 74359305, "author": "jme11", "author_id": 3577849, "author_profile": "https://Stackoverflow.com/users/3577849", "pm_score": 0, "selected": false, "text": "display: flex" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358911", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4654584/" ]
74,358,991
<p>Excel isDate returns true when I do not want it to be true.</p> <p>For example</p> <pre><code>isDate(DateSerial(Month:=6, Day:=40, Year:=1970)) </code></pre> <p>returns True</p> <p>and inputing</p> <pre><code>DateSerial(Month:=6, Day:=40, Year:=1970)) </code></pre> <p>as a value in a cell results in</p> <p>10/7/1970</p> <p>What I want is the user not to be able to enter 72nd of June but limit him to &quot;real dates&quot;. I do not want Excel to compensate for it.</p> <p>Is there a way?</p>
[ { "answer_id": 74359225, "author": "FunThomas", "author_id": 7599798, "author_profile": "https://Stackoverflow.com/users/7599798", "pm_score": 2, "selected": true, "text": "DateSerial" }, { "answer_id": 74359804, "author": "Gustav", "author_id": 3527297, "author_profile": "https://Stackoverflow.com/users/3527297", "pm_score": 0, "selected": false, "text": "IsDate" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74358991", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9178508/" ]
74,359,032
<p><em>Here is my code:</em></p> <pre><code>from random import randint total = int(input('Enter the number of iterations')) count=0 for i in range(1,total+1): print('i',i) number1=randint(1,5) print('num1',number1) number2=randint(1,5) print('num2',number2) if number1==number2: count+=1 print('The number matched',count) </code></pre> <p><em>Here is the code result:</em></p> <pre><code>Enter the number of iterations &gt;&gt;&gt; 20 i 1 num1 2 num2 1 i 2 num1 5 num2 3 i 3 num1 5 num2 5 i 4 num1 4 num2 5 i 5 num1 1 num2 1 i 6 num1 5 num2 5 i 7 num1 4 num2 1 i 8 num1 5 num2 5 i 9 num1 4 num2 5 i 10 num1 3 num2 3 i 11 num1 5 num2 5 i 12 num1 1 num2 5 i 13 num1 1 num2 5 i 14 num1 2 num2 4 i 15 num1 1 num2 1 i 16 num1 1 num2 5 i 17 num1 3 num2 4 i 18 num1 2 num2 5 i 19 num1 2 num2 5 i 20 num1 1 num2 4 The number matched 7 </code></pre> <p>I write a program that generates two numbers in the range 1 to 5 inclusive and outputs the string 'The numbers matched' if the numbers match. I want the program to not count the same numbers. For example in my program I want the result:</p> <pre><code>The number matched 3 5 5 ; 1 1 ; 3 3 </code></pre>
[ { "answer_id": 74359225, "author": "FunThomas", "author_id": 7599798, "author_profile": "https://Stackoverflow.com/users/7599798", "pm_score": 2, "selected": true, "text": "DateSerial" }, { "answer_id": 74359804, "author": "Gustav", "author_id": 3527297, "author_profile": "https://Stackoverflow.com/users/3527297", "pm_score": 0, "selected": false, "text": "IsDate" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359032", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20448356/" ]
74,359,052
<p>I was under the impression that when calling a new object that new object is built using the classes setters and thus we can put constraints on in the setter property to make sure the object is formated and within the boundries we want them to be.</p> <pre><code> public class Commune{ private string name; private int department; private string country; private string mayor; private int population; public Commune(string n, int d, string c, string m, int p) { name = n; department = d; country = c; mayor = m; population = p; } public string Name { get { return name; } set { name = value.ToUpper(); } } public int Department { get { return department; } set { if(value &lt;= 0){ department = -1; }else{ department = value; } } } public string Country { get { return country; } set { country = value; } } public string Mayor { get { return mayor; } set { mayor = value.ToLower(); } } public int Population{ get{ return population;} set { if(value &lt;= 0){ population = -1; }else{ population = value; } } } } </code></pre> <p>I coded my class &quot;Commune&quot; with certain rules for the properties, Name and Mayors should be formated to be in Upper and Lower respectively and the department number and population should be positive.</p> <p>But when I declare a new object.</p> <pre><code>//string name, int department, string country, string mayor, int population Commune test = new Commune(&quot;name&quot;, -5, &quot;count&quot;, &quot;may&quot;, -5); </code></pre> <p>It creates and object without any of the formating. Is there any way around this or do I have to manually call the setter each time?</p>
[ { "answer_id": 74359087, "author": "Renat", "author_id": 1075282, "author_profile": "https://Stackoverflow.com/users/1075282", "pm_score": 1, "selected": false, "text": " public Commune(string n, int d, string c, string m, int p)\n {\n Name = n;\n Department = d;\n Country = c;\n Mayor = m;\n Population = p;\n }\n" }, { "answer_id": 74359094, "author": "Silviu Preda", "author_id": 1996226, "author_profile": "https://Stackoverflow.com/users/1996226", "pm_score": 1, "selected": false, "text": "public Commune(string n, int d, string c, string m, int p)\n {\n name = n;\n department = d;\n country = c;\n mayor = m;\n population = p;\n }\n" }, { "answer_id": 74359190, "author": "Yeasin Arafat", "author_id": 17086565, "author_profile": "https://Stackoverflow.com/users/17086565", "pm_score": 2, "selected": true, "text": "public Commune(string n, int d, string c, string m, int p)\n {\n name = n.ToUpper();\n department = d <= 0 ? -1 : d;\n country = c;\n mayor = m.ToLower();\n population = p <= 0 ? -1 : p; \n }\n" }, { "answer_id": 74369668, "author": "Brian.Z", "author_id": 20455436, "author_profile": "https://Stackoverflow.com/users/20455436", "pm_score": 0, "selected": false, "text": "public Commune(string n, int d, string c, string m, int p)\n{\n Name = n;\n Department = d;\n Country = c;\n Mayor = m;\n Population = p;\n}\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359052", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17422952/" ]
74,359,054
<p>I have a query like this:</p> <pre><code>select case when sp.provider='prv1' and sp.status_code = 404 then 'failed' when sp.provider='prv1' and sp.status_code = 200 then 'success' when time_taken is null or sp.status_code in (503) or sp.status_code is null then 'unavailable' else 'other' end as result, count(*) from services_serviceprofile sp where service_type = 'type1' and sp.provider = 'prv1' and sp.start_time &gt;= '2022-08-22 00:00' group by case when sp.provider='prv1' and sp.status_code = 404 then 'failed' when sp.provider='prv1' and sp.status_code = 200 then 'success' when time_taken is null or sp.status_code = 503 or sp.status_code is null then 'unavailable' else 'other' end order by count(*) desc; </code></pre> <p>Which gives the result: <a href="https://i.stack.imgur.com/IZ7wa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IZ7wa.png" alt="query result" /></a></p> <p>How can I add a row for 'all' requests in CASES? If we add a <code>when sp.provider='prv1'</code> with no more detailed condition then all cases become one 'all' case because and other cases are ignored.</p>
[ { "answer_id": 74359204, "author": "Giovanni Luisotto", "author_id": 9614903, "author_profile": "https://Stackoverflow.com/users/9614903", "pm_score": 2, "selected": true, "text": "CASE" }, { "answer_id": 74365654, "author": "Prabhakar Anand", "author_id": 19963979, "author_profile": "https://Stackoverflow.com/users/19963979", "pm_score": 0, "selected": false, "text": "select results = ISNULL(result, 'All'), Counts = sum(Counts) from (\nselect\ncase when sp.provider='prv1' and sp.status_code = 404 then 'failed'\n when sp.provider='prv1' and sp.status_code = 200 then 'success'\n when time_taken is null or sp.status_code in (503) or sp.status_code is null then 'unavailable' \n else 'other'\n end as result,\n count(*) as Counts\nfrom services_serviceprofile sp\nwhere \nservice_type = 'type1' and\nsp.provider = 'prv1' and \nsp.start_time >= '2022-08-22 00:00'\ngroup by \n case when sp.provider='prv1' and sp.status_code = 404 then 'failed'\n when sp.provider='prv1' and sp.status_code = 200 then 'success'\n when time_taken is null or sp.status_code = 503 or sp.status_code is null then 'unavailable' \n else 'other'\n end \n) as Final\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359054", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1517307/" ]
74,359,062
<p><strong>$('input[type=text]')</strong></p> <p>How do I convert this to plain javascript</p> <p>I've been trying to figure this out but no luck</p>
[ { "answer_id": 74359098, "author": "shurikation", "author_id": 19407265, "author_profile": "https://Stackoverflow.com/users/19407265", "pm_score": 0, "selected": false, "text": "const el = document.querySelector(\"input[type='text']\");\n" }, { "answer_id": 74359125, "author": "sachinkondana", "author_id": 2753624, "author_profile": "https://Stackoverflow.com/users/2753624", "pm_score": -1, "selected": false, "text": "[...document.getElementsByTagName(\"input\")].filter(d => d.type === 'text')\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15197907/" ]
74,359,067
<p>I have list of Entities which share equal Group number if they belong to the same group</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Start</th> <th>Stop</th> <th>GroupNum</th> </tr> </thead> <tbody> <tr> <td><em><strong>2018-11-13</strong></em></td> <td>2019-01-13</td> <td>1</td> </tr> <tr> <td>2019-01-14</td> <td>2019-03-06</td> <td>1</td> </tr> <tr> <td>2019-03-07</td> <td><em><strong>2019-11-18</strong></em></td> <td>1</td> </tr> <tr> <td><em><strong>2020-08-23</strong></em></td> <td>2020-08-23</td> <td>2</td> </tr> <tr> <td>2021-11-19</td> <td><em><strong>2022-12-23</strong></em></td> <td>2</td> </tr> </tbody> </table> </div> <p>These Entities are saved in an ArrayList</p> <pre><code>List&lt;Entities&gt; baseList = new ArrayList&lt;&gt;(); public static class Entities { private final Date start_dt; private final Date stop_dt; private int groupNum; </code></pre> <p>I want to aggregate objects based on the GroupNum, and take the first <strong>Start</strong> date from the first element of the (this).group and the last <strong>stop</strong> date from the same group.</p> <p>Final result should look something like this:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Start</th> <th>Stop</th> <th>GroupNum</th> </tr> </thead> <tbody> <tr> <td><em><strong>2018-11-13</strong></em></td> <td><em><strong>2019-11-18</strong></em></td> <td>1</td> </tr> <tr> <td><em><strong>2020-08-23</strong></em></td> <td><em><strong>2022-12-23</strong></em></td> <td>2</td> </tr> </tbody> </table> </div> <p>I wanted to share my solution, however I couldn't come up with any ideas.</p> <p>Thanks in advance.</p>
[ { "answer_id": 74360170, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "public static void main(String[] args) throws ParseException {\n List<Entities> baseList = List.of(\n new Entities(\"2018-11-13\", \"2019-01-13\", 1),\n new Entities(\"2019-01-14\", \"2019-03-06\", 1),\n new Entities(\"2019-03-07\", \"2019-11-18\", 1),\n new Entities(\"2020-08-23\", \"2020-08-23\", 2),\n new Entities(\"2021-11-19\", \"2022-12-23\", 2));\n List<Entities> result = baseList.stream()\n .collect(Collectors.groupingBy(Entities::getGroupNum))\n .entrySet().stream()\n .map(e -> new Entities(\n e.getValue().get(0).getStart_dt(),\n e.getValue().get(e.getValue().size() - 1).getStop_dt(),\n e.getKey()))\n .toList();\n result.forEach(System.out::println);\n}\n" }, { "answer_id": 74360410, "author": "Thomas", "author_id": 637853, "author_profile": "https://Stackoverflow.com/users/637853", "pm_score": 1, "selected": true, "text": "Entities" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359067", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9090704/" ]
74,359,072
<p>I want to groupby and calculate the percentage within each respective group over a certain value. I have achieved this by two groupbys into temporary dataframes (group count over a value, and group count), then merging the dataframes before calculating the percentage. I assume there is a more succinct method that doesn't require creating temporary dataframes.</p> <p>e.g.</p> <pre><code>df = pd.DataFrame({'n': ['a', 'b', 'c', 'a', 'c', 'a', 'a', 'c', 'a'], 'm': ['j', 'j', 'j', 'j', 'j', 'j', 'f', 'f', 'f'], 'v': [1, 1, 1, 2, 1, 2, 3, 6, 5]}) </code></pre> <ol> <li>Count groupby on 'n' and 'm' and count</li> </ol> <pre><code>dfcount = df.groupby(['n', 'm'])['v'].agg('count').reset_index().rename(columns={'v': 'count'}) </code></pre> <ol start="2"> <li>Filter values over 1, then groupby 'n' and 'm' and count</li> </ol> <pre><code>dfover1 = df[df['v'] &gt; 1].groupby(['n','m']).count().reset_index().rename(columns={'v': 'over1count'}) </code></pre> <ol start="3"> <li>Merge two new dataframes on the groupby columns 'n' and 'm', then calculate the percentage over 1 for those groupbys.</li> </ol> <pre><code>dfnew = dfcount.merge(dfover1, on=['n', 'm']) dfnew['late%'] = (100 * dfnew['over1count'] / dfnew['count']).round(1) </code></pre> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: left;"></th> <th style="text-align: left;">n</th> <th style="text-align: left;">m</th> <th style="text-align: left;">count</th> <th style="text-align: left;">latecount</th> <th style="text-align: left;">late%</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">0</td> <td style="text-align: left;">a</td> <td style="text-align: left;">f</td> <td style="text-align: left;">2</td> <td style="text-align: left;">2</td> <td style="text-align: left;">100.0</td> </tr> <tr> <td style="text-align: left;">1</td> <td style="text-align: left;">a</td> <td style="text-align: left;">j</td> <td style="text-align: left;">3</td> <td style="text-align: left;">2</td> <td style="text-align: left;">66.7</td> </tr> <tr> <td style="text-align: left;">2</td> <td style="text-align: left;">c</td> <td style="text-align: left;">f</td> <td style="text-align: left;">1</td> <td style="text-align: left;">1</td> <td style="text-align: left;">100.0</td> </tr> </tbody> </table> </div>
[ { "answer_id": 74359116, "author": "mozway", "author_id": 16343464, "author_profile": "https://Stackoverflow.com/users/16343464", "pm_score": 3, "selected": true, "text": "out = (df\n .groupby(['n', 'm'], as_index=False)\n # compute count and latecount\n .agg(**{'count': ('v', 'count'),\n 'latecount': ('v', lambda v: len(v[v>1]))\n })\n # filter rows with latecount > 0\n .query('latecount > 0')\n # compute late%\n .assign(**{'late%': lambda d: d['latecount'].div(d['count']).mul(100).round(2)})\n)\n" }, { "answer_id": 74359386, "author": "jezrael", "author_id": 2901002, "author_profile": "https://Stackoverflow.com/users/2901002", "pm_score": 1, "selected": false, "text": "later" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359072", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16503525/" ]
74,359,120
<h1><strong>Paytm gateway integration in react native</strong></h1> <p>I'm using All-in-One SDK Integration for React Native platform</p> <p>I also tried to upgrade the kotlin version</p> <pre><code>kotlinVersion = &quot;1.4.10&quot; </code></pre> <p>and</p> <pre><code>cd android &amp;&amp; ./gradlew clean </code></pre> <p><a href="https://i.stack.imgur.com/m81ep.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/m81ep.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74359116, "author": "mozway", "author_id": 16343464, "author_profile": "https://Stackoverflow.com/users/16343464", "pm_score": 3, "selected": true, "text": "out = (df\n .groupby(['n', 'm'], as_index=False)\n # compute count and latecount\n .agg(**{'count': ('v', 'count'),\n 'latecount': ('v', lambda v: len(v[v>1]))\n })\n # filter rows with latecount > 0\n .query('latecount > 0')\n # compute late%\n .assign(**{'late%': lambda d: d['latecount'].div(d['count']).mul(100).round(2)})\n)\n" }, { "answer_id": 74359386, "author": "jezrael", "author_id": 2901002, "author_profile": "https://Stackoverflow.com/users/2901002", "pm_score": 1, "selected": false, "text": "later" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359120", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16710738/" ]
74,359,124
<p>when I run the cmd command <code>webpack --mode production --color --progress</code> I get this message :</p> <p><a href="https://i.stack.imgur.com/ZzWPU.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ZzWPU.png" alt="enter image description here" /></a></p> <p>I use <strong>Bootstrap v5.2.2</strong> with <strong>Sass v1.56.0</strong>.</p> <p>There is my full package.json</p> <pre><code>{ &quot;name&quot;: &quot;xx&quot;, &quot;version&quot;: &quot;1.0.0&quot;, &quot;description&quot;: &quot;xx&quot;, &quot;main&quot;: &quot;index.js&quot;, &quot;author&quot;: &quot;xxx&quot;, &quot;private&quot;: true, &quot;scripts&quot;: { &quot;build&quot;: &quot;webpack --mode production --color --progress&quot;, &quot;watch&quot;: &quot;webpack --mode development --color --devtool inline-source-map --hide-modules -w&quot;, &quot;debug&quot;: &quot;webpack --mode development --progress --color --devtool inline-source-map --debug --display-error-details --output-pathinfo --display-chunks -w&quot;, }, &quot;devDependencies&quot;: { &quot;@babel/core&quot;: &quot;^7.20.2&quot;, &quot;@babel/preset-env&quot;: &quot;^7.20.2&quot;, &quot;@popperjs/core&quot;: &quot;^2.11.6&quot;, &quot;acorn&quot;: &quot;^8.8.1&quot;, &quot;ajv&quot;: &quot;^8.11.0&quot;, &quot;autoprefixer&quot;: &quot;^10.4.13&quot;f, &quot;babel-loader&quot;: &quot;^9.1.0&quot;, &quot;babel-polyfill&quot;: &quot;^6.26.0&quot;, &quot;bootstrap&quot;: &quot;^5.2.2&quot;, &quot;bootstrap-input-spinner&quot;: &quot;^3.1.13&quot;, &quot;bourbon&quot;: &quot;^7.2.0&quot;, &quot;browser-sync&quot;: &quot;^2.27.10&quot;, &quot;browser-sync-webpack-plugin&quot;: &quot;^2.3.0&quot;, &quot;bs-custom-file-input&quot;: &quot;^1.3.4&quot;, &quot;clean-webpack-plugin&quot;: &quot;^4.0.0&quot;, &quot;css-loader&quot;: &quot;^6.7.1&quot;, &quot;eslint&quot;: &quot;^8.27.0&quot;, &quot;eslint-config-airbnb-base&quot;: &quot;^15.0.0&quot;, &quot;eslint-plugin-html&quot;: &quot;^7.1.0&quot;, &quot;eslint-plugin-import&quot;: &quot;^2.26.0&quot;, &quot;expose-loader&quot;: &quot;^4.0.0&quot;, &quot;file-loader&quot;: &quot;^6.2.0&quot;, &quot;lighthouse&quot;: &quot;^9.6.8&quot;, &quot;mini-css-extract-plugin&quot;: &quot;^2.6.1&quot;, &quot;npm-run-all&quot;: &quot;^4.1.5&quot;, &quot;postcss-loader&quot;: &quot;^7.0.1&quot;, &quot;sass-loader&quot;: &quot;^13.1.0&quot;, &quot;style-loader&quot;: &quot;^3.3.1&quot;, &quot;stylelint&quot;: &quot;^14.14.1&quot;, &quot;stylelint-checkstyle-formatter&quot;: &quot;^0.1.2&quot;, &quot;stylelint-config-twbs-bootstrap&quot;: &quot;^6.0.0&quot;, &quot;terser-webpack-plugin&quot;: &quot;^5.3.6&quot;, &quot;url-loader&quot;: &quot;^4.1.1&quot;, &quot;webpack&quot;: &quot;^5.74.0&quot;, &quot;webpack-cli&quot;: &quot;^4.10.0&quot;, &quot;webpack-dev-server&quot;: &quot;^4.11.1&quot;, &quot;webpack-remove-empty-scripts&quot;: &quot;^1.0.1&quot; }, &quot;dependencies&quot;: { &quot;axios&quot;: &quot;^1.1.3&quot;, &quot;browserslist&quot;: &quot;^4.21.4&quot;, &quot;caniuse-lite&quot;: &quot;^1.0.30001431&quot;, &quot;card&quot;: &quot;^2.5.4&quot;, &quot;core-js&quot;: &quot;^3.26.0&quot;, &quot;iban&quot;: &quot;0.0.14&quot;, &quot;intl-tel-input&quot;: &quot;^17.0.19&quot;, &quot;js-base64&quot;: &quot;^3.7.2&quot;, &quot;qs&quot;: &quot;^6.11.0&quot;, &quot;sass&quot;: &quot;^1.56.0&quot; }, &quot;old&quot;: { &quot;lighthouse&quot;: &quot;^5.1.0&quot;, &quot;vanilla-lazyload&quot;: &quot;^8.17.0&quot; }, &quot;boutique&quot;: { &quot;jquery.panzoom&quot;: &quot;^3.2.2&quot; } } </code></pre>
[ { "answer_id": 74389744, "author": "Malek Ben el ouafi", "author_id": 6199276, "author_profile": "https://Stackoverflow.com/users/6199276", "pm_score": 4, "selected": false, "text": "node_modules/bootstrap/scss/_functions.scss 201:11" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359124", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6199276/" ]
74,359,156
<p>I am curious if there is a way to make my life easier. In excel I am producing a total value, say 750 and need to find out how many orders of pipe I need from values of 50,100,200,250,500. Is there anyway to have excel take a value and then return how many of each of these numbers I would need, so for the 750 case 1 500 and 1 250?</p> <p>Currently the solution is just worked out in my head</p>
[ { "answer_id": 74389744, "author": "Malek Ben el ouafi", "author_id": 6199276, "author_profile": "https://Stackoverflow.com/users/6199276", "pm_score": 4, "selected": false, "text": "node_modules/bootstrap/scss/_functions.scss 201:11" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359156", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20448527/" ]
74,359,166
<p>I am trying to delete duplicate entries in an <code>xml</code> file based on the value of an attribute.</p> <pre><code>&lt;?xml version='1.0' encoding='UTF-8'?&gt; &lt;root&gt; &lt;entries&gt; &lt;entry name=&quot;entry1&quot;&gt; &lt;value&gt;1&lt;/value&gt; &lt;/entry&gt; &lt;entry name=&quot;entry1&quot;&gt; &lt;-- Duplicate name here &lt;value&gt;2&lt;/value&gt; &lt;/entry&gt; &lt;entry name=&quot;entry2&quot;&gt; &lt;value&gt;3&lt;/value&gt; &lt;/entry&gt; &lt;/entries&gt; &lt;/root&gt; </code></pre> <p>And I want the following</p> <pre><code>&lt;?xml version='1.0' encoding='UTF-8'?&gt; &lt;root&gt; &lt;entries&gt; &lt;entry name=&quot;entry1&quot;&gt; &lt;value&gt;1&lt;/value&gt; &lt;/entry&gt; &lt;entry name=&quot;entry2&quot;&gt; &lt;value&gt;3&lt;/value&gt; &lt;/entry&gt; &lt;/entries&gt; &lt;/root&gt; </code></pre> <p>I have tried</p> <pre><code>xmlstarlet edit --delete '/_:root/_:entries/*[@name = .//preceding-sibling::*/@name]' </code></pre> <p>But the <code>xpath</code> does not match the previous entry with the attribute <code>name=&quot;entry1&quot;</code></p>
[ { "answer_id": 74389744, "author": "Malek Ben el ouafi", "author_id": 6199276, "author_profile": "https://Stackoverflow.com/users/6199276", "pm_score": 4, "selected": false, "text": "node_modules/bootstrap/scss/_functions.scss 201:11" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359166", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9369168/" ]
74,359,171
<p>I have a file &quot;stocks.json&quot; that stores information about stock prices retrieved from an API. I wrote a Python function that takes in each symbol in the &quot;stocks.json&quot; file, adds each symbol to the API URL, and makes an API call with the URL. The function then takes whatever data is on the API and dumps it into the JSON file.</p> <p>The problem right now is that when I add a symbol in the stocks.json file that isn't valid on the API, the API will not return any results for that specific symbol, and the function will overwrite the JSON file with whatever is on the API, thus wiping out that invalid symbol from the file. How do I make it so that the invalid symbol, stays in the JSON file?</p> <p><strong>Function:</strong></p> <pre><code>def updateStocks(api_key): try: f = open('csv/stocks.json', 'r') all_stocks_settings = json.load(f) f.close() stock_info = all_stocks_settings['symbols'] symbols = list(stock_info.keys()) url = 'API URL' for symbol in symbols: url += symbol + ',' url += '&amp;apiKey=' + api_key response = requests.get(url) data = response.json() stock_info = {} if len(data) &gt; 0: for symbol in symbols: for stock in data: if stock['symbol'] == symbol: stock_info[stock['symbol']] = {'current': stock['price'], 'change': stock['change_since'], 'percent_change':stock['percent']} all_stocks_settings['symbols'] = stock_info f = open('csv/stocks.json', 'w+') json.dump(all_stocks_settings, f) f.close() except Exception as e: pass </code></pre> <p><strong>stock_info (symbols inside the stocks.json file)</strong></p> <pre><code>{&quot;CHKP&quot;: {&quot;current&quot;: &quot;127.27&quot;, &quot;change&quot;: &quot;1.68&quot;, &quot;percent_change&quot;: &quot;1.34&quot;}, &quot;MSFT&quot;: {&quot;current&quot;: &quot;227.86&quot;, &quot;change&quot;: &quot;6.37&quot;, &quot;percent_change&quot;: &quot;2.88&quot;}, &quot;WMT&quot;: {&quot;current&quot;: &quot;142.52&quot;, &quot;change&quot;: &quot;1.53&quot;, &quot;percent_change&quot;: &quot;1.09&quot;}, &quot;HTZ&quot;: {&quot;current&quot;: &quot;17.90&quot;, &quot;change&quot;: &quot;0.36&quot;, &quot;percent_change&quot;: &quot;2.05&quot;}, &quot;NFLX&quot;: {&quot;current&quot;: &quot;257.01&quot;, &quot;change&quot;: &quot;-3.84&quot;, &quot;percent_change&quot;: &quot;-1.47&quot;}, &quot;GOOG&quot;: {&quot;current&quot;: &quot;88.69&quot;, &quot;change&quot;: &quot;2.00&quot;, &quot;percent_change&quot;: &quot;2.31&quot;}, &quot;AAPL&quot;: {&quot;current&quot;: &quot;138.25&quot;, &quot;change&quot;: &quot;-0.15&quot;, &quot;percent_change&quot;: &quot;-0.11&quot;}, &quot;ASDF&quot;:{}} </code></pre> <p>At the end of the list of stock_info, you see symbol &quot;ASDF&quot;, which isn't a valid symbol on the API (using this only for example).</p> <p><strong>data (retrieved from the API based on stock_info)</strong></p> <pre><code>[{&quot;symbol&quot;:&quot;CHKP&quot;,&quot;price&quot;:&quot;127.27&quot;,&quot;close_price&quot;:&quot;125.59&quot;,&quot;change_since&quot;:&quot;1.68&quot;,&quot;percent&quot;:&quot;1.34&quot;,&quot;updated&quot;:&quot;11/07/22 15:01:02&quot;},{&quot;symbol&quot;:&quot;MSFT&quot;,&quot;price&quot;:&quot;227.86&quot;,&quot;close_price&quot;:&quot;221.49&quot;,&quot;change_since&quot;:&quot;6.37&quot;,&quot;percent&quot;:&quot;2.88&quot;,&quot;updated&quot;:&quot;11/07/22 15:01:03&quot;},{&quot;symbol&quot;:&quot;WMT&quot;,&quot;price&quot;:&quot;142.52&quot;,&quot;close_price&quot;:&quot;140.99&quot;,&quot;change_since&quot;:&quot;1.53&quot;,&quot;percent&quot;:&quot;1.09&quot;,&quot;updated&quot;:&quot;11/07/22 15:01:03&quot;},{&quot;symbol&quot;:&quot;HTZ&quot;,&quot;price&quot;:&quot;17.90&quot;,&quot;close_price&quot;:&quot;17.54&quot;,&quot;change_since&quot;:&quot;0.36&quot;,&quot;percent&quot;:&quot;2.05&quot;,&quot;updated&quot;:&quot;11/07/22 15:01:03&quot;},{&quot;symbol&quot;:&quot;NFLX&quot;,&quot;price&quot;:&quot;257.01&quot;,&quot;close_price&quot;:&quot;260.85&quot;,&quot;change_since&quot;:&quot;-3.84&quot;,&quot;percent&quot;:&quot;-1.47&quot;,&quot;updated&quot;:&quot;11/07/22 15:01:03&quot;},{&quot;symbol&quot;:&quot;GOOG&quot;,&quot;price&quot;:&quot;88.69&quot;,&quot;close_price&quot;:&quot;86.69&quot;,&quot;change_since&quot;:&quot;2.00&quot;,&quot;percent&quot;:&quot;2.31&quot;,&quot;updated&quot;:&quot;11/07/22 15:01:03&quot;},{&quot;symbol&quot;:&quot;AAPL&quot;,&quot;price&quot;:&quot;138.25&quot;,&quot;close_price&quot;:&quot;138.40&quot;,&quot;change_since&quot;:&quot;-0.15&quot;,&quot;percent&quot;:&quot;-0.11&quot;,&quot;updated&quot;:&quot;11/07/22 15:01:03&quot;}] </code></pre> <p>As you can see, symbol &quot;ASDF&quot; from stock_info doesn't show up on the API's end.</p> <p>When I run this function, it would overwrite and delete the symbol &quot;ASDF&quot; on stocks.json because it just takes the data from the API and dumps it on the JSON file. How do I make it so that symbol &quot;ASDF&quot; would stay in the JSON file? Even if &quot;ASDF&quot; doesn't show up on the API?</p>
[ { "answer_id": 74359249, "author": "Piotr Żak", "author_id": 9455902, "author_profile": "https://Stackoverflow.com/users/9455902", "pm_score": 1, "selected": false, "text": "stocksWithoutKey = [{\"symbol\":\"CHKP\",\"price\":\"127.27\",\"close_price\":\"125.59\",\"change_since\":\"1.68\",\"percent\":\"1.34\",\"updated\":\"11/07/22 15:01:02\"},{\"symbol\":\"MSFT\",\"price\":\"227.86\",\"close_price\":\"221.49\",\"change_since\":\"6.37\",\"percent\":\"2.88\",\"updated\":\"11/07/22 15:01:03\"},{\"symbol\":\"WMT\",\"price\":\"142.52\",\"close_price\":\"140.99\",\"change_since\":\"1.53\",\"percent\":\"1.09\",\"updated\":\"11/07/22 15:01:03\"},{\"symbol\":\"HTZ\",\"price\":\"17.90\",\"close_price\":\"17.54\",\"change_since\":\"0.36\",\"percent\":\"2.05\",\"updated\":\"11/07/22 15:01:03\"},{\"symbol\":\"NFLX\",\"price\":\"257.01\",\"close_price\":\"260.85\",\"change_since\":\"-3.84\",\"percent\":\"-1.47\",\"updated\":\"11/07/22 15:01:03\"},{\"symbol\":\"GOOG\",\"price\":\"88.69\",\"close_price\":\"86.69\",\"change_since\":\"2.00\",\"percent\":\"2.31\",\"updated\":\"11/07/22 15:01:03\"},{\"symbol\":\"AAPL\",\"price\":\"138.25\",\"close_price\":\"138.40\",\"change_since\":\"-0.15\",\"percent\":\"-0.11\",\"updated\":\"11/07/22 15:01:03\"}]\nstocksWithKey=[]\n\nfor stock in stocksWithoutKey:\n vals = {}\n vals[stock['symbol']]=stock\n arr.append(vals)\n" }, { "answer_id": 74372422, "author": "Pissed Off Banker", "author_id": 3241054, "author_profile": "https://Stackoverflow.com/users/3241054", "pm_score": 0, "selected": false, "text": "stock_info = {}" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3241054/" ]
74,359,194
<p>I using vueJS3 and have the following <strong>menu list</strong>:</p> <pre class="lang-js prettyprint-override"><code>const menu = [ {ref: &quot;../#home&quot;, name: &quot;Home&quot;}, {ref: &quot;../areas&quot;, name: &quot;Areas&quot;}, {ref: &quot;../#contact&quot;, name: &quot;Contact&quot;}, ]; </code></pre> <pre class="lang-html prettyprint-override"><code>&lt;nav class=&quot;overlay-menu&quot;&gt; &lt;ul&gt; &lt;li v-for=&quot;(link, index) in menu&quot; :key=&quot;index&quot;&gt; &lt;router-link :to=&quot;link.ref&quot; @click=&quot;clicked&quot;&gt;{{ link.name }}&lt;/router-link&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/nav&gt; </code></pre> <p>Unfortunately, the router-links with hash anchor links do not work. Alternatively I had used <code>&lt;a :href=&quot;link.ref&quot; ...&lt;/a&gt;</code>. But I actually want to avoid that and want to move in the vue router link context. Is there a solution for this?</p>
[ { "answer_id": 74359249, "author": "Piotr Żak", "author_id": 9455902, "author_profile": "https://Stackoverflow.com/users/9455902", "pm_score": 1, "selected": false, "text": "stocksWithoutKey = [{\"symbol\":\"CHKP\",\"price\":\"127.27\",\"close_price\":\"125.59\",\"change_since\":\"1.68\",\"percent\":\"1.34\",\"updated\":\"11/07/22 15:01:02\"},{\"symbol\":\"MSFT\",\"price\":\"227.86\",\"close_price\":\"221.49\",\"change_since\":\"6.37\",\"percent\":\"2.88\",\"updated\":\"11/07/22 15:01:03\"},{\"symbol\":\"WMT\",\"price\":\"142.52\",\"close_price\":\"140.99\",\"change_since\":\"1.53\",\"percent\":\"1.09\",\"updated\":\"11/07/22 15:01:03\"},{\"symbol\":\"HTZ\",\"price\":\"17.90\",\"close_price\":\"17.54\",\"change_since\":\"0.36\",\"percent\":\"2.05\",\"updated\":\"11/07/22 15:01:03\"},{\"symbol\":\"NFLX\",\"price\":\"257.01\",\"close_price\":\"260.85\",\"change_since\":\"-3.84\",\"percent\":\"-1.47\",\"updated\":\"11/07/22 15:01:03\"},{\"symbol\":\"GOOG\",\"price\":\"88.69\",\"close_price\":\"86.69\",\"change_since\":\"2.00\",\"percent\":\"2.31\",\"updated\":\"11/07/22 15:01:03\"},{\"symbol\":\"AAPL\",\"price\":\"138.25\",\"close_price\":\"138.40\",\"change_since\":\"-0.15\",\"percent\":\"-0.11\",\"updated\":\"11/07/22 15:01:03\"}]\nstocksWithKey=[]\n\nfor stock in stocksWithoutKey:\n vals = {}\n vals[stock['symbol']]=stock\n arr.append(vals)\n" }, { "answer_id": 74372422, "author": "Pissed Off Banker", "author_id": 3241054, "author_profile": "https://Stackoverflow.com/users/3241054", "pm_score": 0, "selected": false, "text": "stock_info = {}" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359194", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14807111/" ]
74,359,203
<p>So, I have a grid called &quot;eventGrid&quot;. I added a component column with a down-arrow icon. When a user clicks on a row, addition information is displayed for that row. I want to change the down arrow to an up arrow for the selected row. How can I achieve this?</p> <pre><code> eventGrid.addColumn(Person::getFirst).setHeader(&quot;First Name&quot;); eventGrid.addColumn(Person::getLast).setHeader(&quot;Last Name&quot;); eventGrid.addColumn(Person::getNumber).setHeader(&quot;Phone Number&quot;); eventGrid.addComponentColumn(item -&gt; { Icon icon = new Icon(&quot;lumo&quot;, &quot;angle-down&quot;); return icon; }).setWidth(&quot;6em&quot;).setFlexGrow(0); </code></pre>
[ { "answer_id": 74359697, "author": "ollitietavainen", "author_id": 3608089, "author_profile": "https://Stackoverflow.com/users/3608089", "pm_score": 2, "selected": true, "text": " Grid<Person> eventGrid = new Grid<Person>();\n eventGrid.addColumn(Person::getFirst).setHeader(\"First Name\");\n eventGrid.addColumn(Person::getLast).setHeader(\"Last Name\");\n eventGrid.addColumn(Person::getNumber).setHeader(\"Phone Number\");\n eventGrid.addComponentColumn(item -> {\n Icon icon = new Icon(\"lumo\", \"angle-down\");\n if (item.equals(eventGrid.asSingleSelect().getValue())) {\n icon = new Icon(\"lumo\", \"angle-up\");\n }\n return icon;\n }).setWidth(\"6em\").setFlexGrow(0);\n eventGrid.addSelectionListener(e -> {\n eventGrid.getListDataView().refreshAll();\n });\n" }, { "answer_id": 74359718, "author": "Leif Åstrand", "author_id": 2376954, "author_profile": "https://Stackoverflow.com/users/2376954", "pm_score": 2, "selected": false, "text": "eventGrid.addComponentColumn(item -> {\n String name = eventGrid.getSelectedItems().contains(item) ? \"angle-down\" : \"angle-up\";\n Icon icon = new Icon(\"lumo\", name);\n return icon;\n}).setWidth(\"6em\").setFlexGrow(0);\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359203", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11547578/" ]
74,359,211
<p>I'm trying to change the color but it's stuck at one color. It's didn't happen before.</p> <p>ggplot(data=diamonds, aes(x=color, fill=&quot;cyan&quot;))+geom_bar()</p> <p>Anyone know why it's happening?</p> <p>Thank you!</p>
[ { "answer_id": 74359697, "author": "ollitietavainen", "author_id": 3608089, "author_profile": "https://Stackoverflow.com/users/3608089", "pm_score": 2, "selected": true, "text": " Grid<Person> eventGrid = new Grid<Person>();\n eventGrid.addColumn(Person::getFirst).setHeader(\"First Name\");\n eventGrid.addColumn(Person::getLast).setHeader(\"Last Name\");\n eventGrid.addColumn(Person::getNumber).setHeader(\"Phone Number\");\n eventGrid.addComponentColumn(item -> {\n Icon icon = new Icon(\"lumo\", \"angle-down\");\n if (item.equals(eventGrid.asSingleSelect().getValue())) {\n icon = new Icon(\"lumo\", \"angle-up\");\n }\n return icon;\n }).setWidth(\"6em\").setFlexGrow(0);\n eventGrid.addSelectionListener(e -> {\n eventGrid.getListDataView().refreshAll();\n });\n" }, { "answer_id": 74359718, "author": "Leif Åstrand", "author_id": 2376954, "author_profile": "https://Stackoverflow.com/users/2376954", "pm_score": 2, "selected": false, "text": "eventGrid.addComponentColumn(item -> {\n String name = eventGrid.getSelectedItems().contains(item) ? \"angle-down\" : \"angle-up\";\n Icon icon = new Icon(\"lumo\", name);\n return icon;\n}).setWidth(\"6em\").setFlexGrow(0);\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359211", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20448520/" ]
74,359,220
<p>This code:</p> <pre><code>a = np.array([10], dtype=np.int8) b = np.array([2], dtype=np.int8) print(np.dot(a, b)) a = np.array([10], dtype=np.int8) b = np.array([5], dtype=np.int8) print(np.dot(a, b)) a = np.array([10], dtype=np.int8) b = np.array([20], dtype=np.int8) print(np.dot(a, b)) </code></pre> <p>produces the following output:</p> <pre><code>20 50 -56 </code></pre> <p>It appears that <code>np.dot</code> will attempt to return the result in the same data type object even if it can't fit. Surely this is a bug? Why doesn't it throw an exception?</p>
[ { "answer_id": 74359276, "author": "Will", "author_id": 12829151, "author_profile": "https://Stackoverflow.com/users/12829151", "pm_score": 1, "selected": false, "text": "dtype" }, { "answer_id": 74362284, "author": "Salvatore Daniele Bianco", "author_id": 11728488, "author_profile": "https://Stackoverflow.com/users/11728488", "pm_score": 0, "selected": false, "text": "numpy.int8" }, { "answer_id": 74363945, "author": "hpaulj", "author_id": 901925, "author_profile": "https://Stackoverflow.com/users/901925", "pm_score": 2, "selected": true, "text": "In [89]: np.array([128], 'int8')*2\nOut[89]: array([0], dtype=int8)\n\nIn [90]: np.array([127], 'int8')*2\nOut[90]: array([-2], dtype=int8) # same int8 dtype\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359220", "https://Stackoverflow.com", "https://Stackoverflow.com/users/276093/" ]
74,359,224
<p>I want to get a file from the resource file, and to use it in string.</p> <p><a href="https://i.stack.imgur.com/GgKne.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GgKne.png" alt="My folder" /></a></p> <p>I tried this :</p> <pre><code>ClassLoader classLoader = getClass().getClassLoader(); File file = new File(classLoader.getResource(&quot;/resources/fileC.p12&quot;).getFile()); String data = String.valueOf(file); </code></pre> <p>but doesnt work, thanks for helping</p> <p>I tried this but i had a error, it returns a null value</p>
[ { "answer_id": 74359410, "author": "g00se", "author_id": 16376827, "author_profile": "https://Stackoverflow.com/users/16376827", "pm_score": 0, "selected": false, "text": "String data = new String(getClass().getResourceAsStream(\"/fileC.p12\").readAllBytes());\n" }, { "answer_id": 74359593, "author": "rzwitserloot", "author_id": 768644, "author_profile": "https://Stackoverflow.com/users/768644", "pm_score": 2, "selected": false, "text": "new File" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359224", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17722317/" ]
74,359,250
<p>I have a hashmap as below</p> <pre class="lang-rb prettyprint-override"><code>func_hash = { &quot;update&quot; =&gt; update(), &quot;delete&quot; =&gt; delete(), &quot;get&quot; =&gt; get() } </code></pre> <p>The behaviour that I am observing is , while ruby trying to read this line, its also calling the function update().</p> <p>How can I make it work like, call the function only when I call it with specific key like</p> <pre><code>func_hash[&quot;delete&quot;] </code></pre> <p>Any help, much appreciated.</p> <p>Thank you.</p>
[ { "answer_id": 74359294, "author": "Ursus", "author_id": 3857758, "author_profile": "https://Stackoverflow.com/users/3857758", "pm_score": 2, "selected": false, "text": "func_hash = {\n \"update\" => lambda { update() },\n \"delete\" => lambda { delete() },\n \"get\" => lambda { get() }\n}\n\nfunc_hash[\"delete\"].call\n" }, { "answer_id": 74360286, "author": "spickermann", "author_id": 2483313, "author_profile": "https://Stackoverflow.com/users/2483313", "pm_score": 2, "selected": false, "text": "public_send" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359250", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1293013/" ]
74,359,263
<p>I'm new in DDD/ Clean Architecture I'm trying to implement this architecture in a new from scratch application and I feel confused in some points. I'm trying to make the best choice to not regret it as application will start growing. Probably my question is a bit stupid, but again i'm new in DDD and trying to make the best choices.</p> <p>I'm trying to stick to this example <a href="https://github.com/ardalis/CleanArchitecture" rel="nofollow noreferrer">https://github.com/ardalis/CleanArchitecture</a> from Ardalis</p> <p>Here is my model/problem simplified</p> <blockquote> <p>-ApplicationAggregateRoot</p> <p>---Application</p> <p>---Instance</p> </blockquote> <p>Application has a list of Instance.</p> <p>Now I have to do an HTTPRequest &quot;/operationA&quot; on the Instance, this can be done by my blazor UI or by my API via controllers.</p> <p>The result of this HTTP Request &quot;/operationA&quot; will have to be saved in my repository, and do other stuff, so from what I understood here I need an event when I have the HTPP Response something like &quot;OperationAFinishedEvent&quot;</p> <p>What I don't really know how to figure it out is how should I make this call in my controller/blazor for example.</p> <p>Should I do (pseudo code):</p> <p>A)</p> <pre><code>_repository.GetApplicationById(1).Instances.First(i =&gt; i == id).OperationA() </code></pre> <p>and have some event raised in OperationA() Method of Instance (something like &quot;OperationASentEvent&quot;) which will be wired to a handler that will call _httpClient.OperationA(instance.Url)</p> <p>Or should I pass by a domain service class for doing the call instead of an event like:</p> <p>B)</p> <pre><code>class Controller { OperationA(Instance instance) { _instanceService.OperationA(instance) } } class InstanceService { void OperationA(Instance instance) { _httpClient.OperationA(instance.Url); new OperationAFinishedEvent(instance); } } </code></pre> <p>C) Or call directly</p> <pre><code>_httpClient.OperationA(instance.Url); new OperationAFinishedEvent(instance); </code></pre> <p>from both controller and blazor</p> <p>Or maybe something else ?</p> <p>Thank's</p>
[ { "answer_id": 74359294, "author": "Ursus", "author_id": 3857758, "author_profile": "https://Stackoverflow.com/users/3857758", "pm_score": 2, "selected": false, "text": "func_hash = {\n \"update\" => lambda { update() },\n \"delete\" => lambda { delete() },\n \"get\" => lambda { get() }\n}\n\nfunc_hash[\"delete\"].call\n" }, { "answer_id": 74360286, "author": "spickermann", "author_id": 2483313, "author_profile": "https://Stackoverflow.com/users/2483313", "pm_score": 2, "selected": false, "text": "public_send" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359263", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9333364/" ]
74,359,264
<p>I'd like to bind (row-wise) two dataframes of different column size, but enforce that the columns' formats of the first dataframe be kept.</p> <p>Example:</p> <pre class="lang-r prettyprint-override"><code>d1 &lt;- tibble(x = 1, y = &quot;b&quot;) # before edit: d1 &lt;- tibble(x = 1) d2 &lt;- tibble(x = c(2, &quot;a&quot;)) </code></pre> <p>When employing, say, <code>plyr</code>'s <code>rbind.fill</code>, the combined column will be of the character type. However, I'd like to obtain the (final) result</p> <pre class="lang-r prettyprint-override"><code>str(data.frame(x = c(1, 2, NA))) #&gt; 'data.frame': 3 obs. of 1 variable: #&gt; $ x: num 1 2 NA </code></pre> <p>I suppose for this to work, I'd have to</p> <ul> <li>look up <code>x</code>'s format in <code>d1</code> and then</li> <li>force <code>x</code> in <code>d2</code> to be of the same format, producing <code>NA</code>'s along the way, and</li> <li><code>rbind</code> thereafter.</li> </ul> <p>The problem is, I cannot come up with an elegant solution to this little problem. Any help will be much appreciated!</p> <p><em>Edited to account for data frames of different column size.</em></p>
[ { "answer_id": 74359332, "author": "Allan Cameron", "author_id": 12500315, "author_profile": "https://Stackoverflow.com/users/12500315", "pm_score": 2, "selected": false, "text": "bind_rows(d1, map2_df(d1, d2, ~ `class<-`(.y, class(.x))))\n#> # A tibble: 3 x 1\n#> x\n#> <dbl>\n#> 1 1\n#> 2 2\n#> 3 NA\n" }, { "answer_id": 74359407, "author": "Maël", "author_id": 13460602, "author_profile": "https://Stackoverflow.com/users/13460602", "pm_score": 2, "selected": true, "text": "match.fun" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359264", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8363056/" ]
74,359,283
<p>I have two flatlist consist of 5 and 10 items, i want to drag 1 item from first flatlist to second and vice verse , i have searched for many library but havent found any one yet.</p>
[ { "answer_id": 74359332, "author": "Allan Cameron", "author_id": 12500315, "author_profile": "https://Stackoverflow.com/users/12500315", "pm_score": 2, "selected": false, "text": "bind_rows(d1, map2_df(d1, d2, ~ `class<-`(.y, class(.x))))\n#> # A tibble: 3 x 1\n#> x\n#> <dbl>\n#> 1 1\n#> 2 2\n#> 3 NA\n" }, { "answer_id": 74359407, "author": "Maël", "author_id": 13460602, "author_profile": "https://Stackoverflow.com/users/13460602", "pm_score": 2, "selected": true, "text": "match.fun" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13703014/" ]
74,359,285
<p>Why variable <code>a</code> is undefined?</p> <pre><code>export default function Surah() { let a; const toDo= (id) =&gt; { a = id; console.log(a); }; return ( &lt;div&gt; &lt;div&gt; &lt;button onClick={() =&gt; toDo(1)}&gt;&lt;/button&gt; &lt;div&gt;{a}&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; ) } </code></pre> <p>Can you explain what is wrong with my code ?</p>
[ { "answer_id": 74359367, "author": "Abasaheb Gaware", "author_id": 6127865, "author_profile": "https://Stackoverflow.com/users/6127865", "pm_score": 1, "selected": true, "text": "a" }, { "answer_id": 74359481, "author": "Mohammad Aaqib", "author_id": 18223800, "author_profile": "https://Stackoverflow.com/users/18223800", "pm_score": 1, "selected": false, "text": "useState" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359285", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20066668/" ]
74,359,318
<p>I am comparing 2 Lists. If both list exists in one of the element, it updates the element values. If it is not found, then it will add into the array. But it seems that it adds every time it loops in even with conditions. It seems like i need to add/update the arrayList only after the 2nd loop ends. Not sure if there are any possibility in doing that</p> <p>Below are my codes:</p> <pre><code>for(var bscsEntry : bscsChargeTypemap.entrySet()) { Report report = new Report(); for(int i = 0; i &lt; reportDataList.size(); i++) { if(bscsEntry.getValue().getChargeTypeName().equalsIgnoreCase(reportDataList.get(i).getChargeTypeName())) { reportDataList.get(i).setBscsAmount(bscsEntry.getValue().getAmount()); reportDataList.get(i).setBscsQuantity(bscsEntry.getValue().getQuantity()); }else { report.setChargeTypeName(bscsEntry.getValue().getChargeTypeName()); report.setBscsAmount(bscsEntry.getValue().getAmount()); report.setBscsAmount(bscsEntry.getValue().getQuantity()); reportDataList.add(report); } } } </code></pre> <p>Example of the lists:</p> <p>Existing Report Data List</p> <pre><code>Type : [Name : TypeA, Amount : 10.0 , Quantity : 1] Type : [Name : TypeB, Amount : 5.0 , Quantity : 2] Type : [Name : TypeC, Amount : 55.0 , Quantity : 1] Type : [Name : TypeD, Amount : 10.0 , Quantity : 2] </code></pre> <p>Map Entry Sets</p> <pre><code>Type : [Name : TypeA, Amount : 10.0 , Quantity : 1] Type : [Name : TypeB, Amount : 5.0 , Quantity : 2] Type : [Name : TypeE, Amount : 65.0 , Quantity : 1] Type : [Name : TypeF, Amount : 100.0 , Quantity : 2] </code></pre> <p>Expected outcome of existing Report Data List</p> <pre><code>Type : [Name : TypeA, Amount : 20.0 , Quantity : 2] Type : [Name : TypeB, Amount : 10.0 , Quantity : 4] Type : [Name : TypeC, Amount : 55.0 , Quantity : 1] Type : [Name : TypeD, Amount : 10.0 , Quantity : 2] Type : [Name : TypeE, Amount : 65.0 , Quantity : 1] Type : [Name : TypeF, Amount : 100.0 , Quantity : 2] </code></pre> <p>Updated POJO:</p> <pre><code>public class ChargeType { private String chargeTypeName; private Double amount; private Integer quantity; public ChargeType() { chargeTypeName = &quot;&quot;; amount = Double.parseDouble(&quot;0&quot;); quantity = 0; } public ChargeType(String chargeTypeName, Double amount, Integer quantity) { this.chargeTypeName = chargeTypeName; this.amount = amount; this.quantity = quantity; } public String getChargeTypeName() { return chargeTypeName; } public void setChargeTypeName(String chargeTypeName) { this.chargeTypeName = chargeTypeName; } public Double getAmount() { return amount; } public void setAmount(Double amount) { this.amount = amount; } public Integer getQuantity() { return quantity; } public void setQuantity(Integer quantity) { this.quantity = quantity; } } public class Report { private String chargeTypeName; private Double brmAmount; private Integer brmQuantity; private Double bscsAmount; private Integer bscsQuantity; private String remarks; public Report() { chargeTypeName = &quot;&quot;; brmAmount = Double.parseDouble(&quot;0&quot;); brmQuantity = 0; bscsAmount = Double.parseDouble(&quot;0&quot;); bscsQuantity = 0; remarks = &quot;&quot;; } public String getChargeTypeName() { return chargeTypeName; } public void setChargeTypeName(String chargeTypeName) { this.chargeTypeName = chargeTypeName; } public Double getBrmAmount() { return brmAmount; } public void setBrmAmount(Double brmAmount) { this.brmAmount = brmAmount; } public Integer getBrmQuantity() { return brmQuantity; } public void setBrmQuantity(Integer brmQuantity) { this.brmQuantity = brmQuantity; } public Double getBscsAmount() { return bscsAmount; } public void setBscsAmount(Double bscsAmount) { this.bscsAmount = bscsAmount; } public Integer getBscsQuantity() { return bscsQuantity; } public void setBscsQuantity(Integer bscsQuantity) { this.bscsQuantity = bscsQuantity; } public String getRemarks() { return remarks; } public void setRemarks(String remarks) { this.remarks = remarks; } } </code></pre>
[ { "answer_id": 74359367, "author": "Abasaheb Gaware", "author_id": 6127865, "author_profile": "https://Stackoverflow.com/users/6127865", "pm_score": 1, "selected": true, "text": "a" }, { "answer_id": 74359481, "author": "Mohammad Aaqib", "author_id": 18223800, "author_profile": "https://Stackoverflow.com/users/18223800", "pm_score": 1, "selected": false, "text": "useState" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359318", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7592295/" ]
74,359,319
<p>Is it possible to transform that text of a label in a SwiftUI button to uppercase using a style?</p> <pre><code>struct UppercaseButtonStyle: ButtonStyle { func makeBody(configuration: Configuration) -&gt; some View { configuration.label .makeUppercase() // ? } } </code></pre>
[ { "answer_id": 74359423, "author": "Yodagama", "author_id": 9440709, "author_profile": "https://Stackoverflow.com/users/9440709", "pm_score": 3, "selected": true, "text": "struct UppercaseButtonStyle: ButtonStyle {\n func makeBody(configuration: Configuration) -> some View {\n configuration.label\n .textCase(.uppercase) // <- here\n }\n}\n" }, { "answer_id": 74361190, "author": "ScottM", "author_id": 1326518, "author_profile": "https://Stackoverflow.com/users/1326518", "pm_score": 0, "selected": false, "text": "textCase" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359319", "https://Stackoverflow.com", "https://Stackoverflow.com/users/284714/" ]
74,359,352
<p>I am making a TODO list. I have difficulties with setting the input text on my card. Everything I write in the input, I want to select and to put on the card.</p> <p>I tried to select the <code>innerHTML</code> of an <code>input</code> when I type something in. I don't know how to select the typed input text. I would then create a new element with the text inside, and would append it to the card.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>let btn = document.querySelector('.add'); let textspace = document.querySelector('.todotext'); const input = document.querySelector('input'); // eventlistner by button clicked btn.addEventListener('click', function() { var txt = document.getElementsByClassName('input').innerHTML; });</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="card"&gt; &lt;div class="todoheader"&gt;TODO List&lt;/div&gt; &lt;div class="todotext"&gt;&lt;/div&gt; &lt;ul class="list"&gt;&lt;/ul&gt; &lt;div class="addtodo"&gt; &lt;buton class="add" type="button"&gt; + &lt;/buton&gt; &lt;input type="text" class="input" placeholder="add todo" /&gt; &lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74359425, "author": "Rory McCrossan", "author_id": 519413, "author_profile": "https://Stackoverflow.com/users/519413", "pm_score": 1, "selected": false, "text": "input" }, { "answer_id": 74359441, "author": "Mohammed Shahed", "author_id": 19067773, "author_profile": "https://Stackoverflow.com/users/19067773", "pm_score": 0, "selected": false, "text": "btn.addEventListener('click', function() {\n var txt = document.getElementByClassName('input').value;\n});\n" }, { "answer_id": 74359447, "author": "Mina", "author_id": 11887902, "author_profile": "https://Stackoverflow.com/users/11887902", "pm_score": 1, "selected": true, "text": "getElementsByClassName" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359352", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16850827/" ]
74,359,356
<p>I would like to analyze a dataframe with hourly data for several days, e.g. df:</p> <pre><code> DATE TIME Threshold Value 2022-11-04 02:00:00 10 9 2022-11-04 03:00:00 11 10 2022-11-04 04:00:00 10 11 2022-11-04 06:00:00 12 11 2022-11-04 05:00:00 12 12 2022-11-04 07:00:00 10 11 2022-11-04 08:00:00 11 10 2022-11-04 09:00:00 11 9 2022-11-04 10:00:00 12 9 2022-11-04 11:00:00 10 10 2022-11-04 12:00:00 10 10 ... 2022-11-05 01:00:00 10 9 2022-11-05 02:00:00 11 10 ... </code></pre> <p>Now I would like to examine the data based on threshold/value and time. Let's say I am interested in the Value of time &quot;08:00:00&quot; if the threshold of the preceding time &quot;04:00:00&quot; was 10. To find possible patterns, I might also look at other combinations in the future.</p> <p>My approach was:</p> <ul> <li>Create a new dataframe df_2 with all slices of 04:00:00 and value = 10</li> <li>Create a new dataframe df_3 with all slices of 08:00:00</li> <li>merge df_2 and df_3 and select only rows where a time = 04:00:00 of the same day precedes a time = 8:00:00 entry.</li> </ul> <p>This seems to be a bit cumbersome and I was wondering if there was a more practical way to do this. Maybe someone could suggest a more efficient way?</p>
[ { "answer_id": 74359746, "author": "Panda Kim", "author_id": 20430449, "author_profile": "https://Stackoverflow.com/users/20430449", "pm_score": 2, "selected": true, "text": "date_idx=df.iloc[:, :2].astype('str').apply(lambda x: pd.to_datetime(' '.join(x)), axis=1)\n" }, { "answer_id": 74362816, "author": "Naveed", "author_id": 3494754, "author_profile": "https://Stackoverflow.com/users/3494754", "pm_score": 0, "selected": false, "text": "out=(df.loc[\n (df['TIME'].isin(['04:00:00','08:00:00']) & # choose rows where time is 4:00 or 8:00\n df['DATE'].isin( # and date where \n df.loc[df['TIME'].eq('04:00:00') & # time is 04:00:00\n df['Threshold'].eq(10)]['DATE']) # and Threshold is 10\n)])\nout\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359356", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8518582/" ]
74,359,373
<p>I'm new to Bash scripting, and been writing a script to check different log files if they exist or not, and I'm a bit stuck here.</p> <pre class="lang-bash prettyprint-override"><code>clientlist=/path/to/logfile/which/consists/of/client/names # I grepped only the client name from the logfile, # and piped into awk to add &quot;.log&quot; to each client name clients=$(grep -i 'list of client assets:' $clientlist | cut -d&quot;:&quot; -f1 | awk '{print $NF&quot;.log&quot;}') echo &quot;Clients : $clients&quot; #For example &quot;Clients: Apple.log # Samsung.log # Nokia.log # ....&quot; export alertfiles=&quot;*_$clients&quot; #path/to/each/client/logfiles for file in $alertfiles do # I will test each &quot;.log&quot; file of each client, if it exists or not test -f &quot;$file&quot; &amp;&amp; echo $file exists || { echo Error: $file does not exist &amp;&amp; exit; } done </code></pre> <p>The code above greps the client name from the log file, and using <code>awk</code>, added <code>.log</code> at the end of each client field. From the output, I'm trying to pass <code>eachclientname.log</code> from each field into one variable, i.e. <code>alertfiles</code>, and construct a path to be tested for the file existence.</p> <p>The number of clients is indefinite and may vary from time to time.</p> <p>The code I have returns the client name as a whole:</p> <pre class="lang-bash prettyprint-override"><code>&quot;Clients: Apple.log Samsung.log Nokia.log .....&quot; </code></pre> <p>I'm unsure of how to pass each client name one by one into the loop, so that each client name log file will be tested if it exists or not. How can I do this?</p> <pre class="lang-bash prettyprint-override"><code>export alertfiles=&quot;*_$clients&quot; #path/to/each/client/logfiles </code></pre> <p>I want to have <code>$clients</code> output listed here one by one, so that it returns all client name one by one, and not as a whole thing, and I can pass that into the loop, so the client log filename gets checked one by one.</p>
[ { "answer_id": 74359931, "author": "Jay M", "author_id": 1364242, "author_profile": "https://Stackoverflow.com/users/1364242", "pm_score": 2, "selected": true, "text": "clientlist=/path/to/logfile/which/consists/of/client/names\nlogfilebase=/path/to/where/the/logfiles/should/exist\ndeclare -a clients=($(grep -i 'list of client assets:' $clientlist | cut -d\":\" -f1))\n\nfor item in \"${clients[@]}\"; do\n if [ -e ${logfilebase}/${item}.log ]; then\n echo \"$item exists\"\n else\n echo \"$item does not exist - quit\"\n exit 1\n fi\ndone\n\n" }, { "answer_id": 74360327, "author": "tripleee", "author_id": 874188, "author_profile": "https://Stackoverflow.com/users/874188", "pm_score": 0, "selected": false, "text": "$clients" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359373", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17458112/" ]
74,359,414
<p>I'm developing an app that reads serial numbers using Google MLkit's OCR. I've found out that sometimes the readings are not totally accurate due to this I've created a function that returns true/false whenever the format is not correct. I'm kind of new to Kotlin and I am using a cuestionable way of doing so because I have failed to find any information on how to do this on a more efficient/correct way.</p> <p>Serial numbers always have the same format. L=Letter D=Digit Format: LDDLLDDDDDDL</p> <p>I am sure there is a better way of doing this that does not involve a code pyramid of giza.</p> <pre><code>fun checkFormat(numSerie: String): Boolean { val numSerieArr = numSerie.toCharArray() var isCorrect = false if (numSerieArr[0].isLetter()) { if (numSerieArr[1].isDigit()) { if (numSerieArr[2].isDigit()) { if (numSerieArr[3].isLetter()) { if (numSerieArr[4].isLetter()) { if (numSerieArr[5].isDigit()) { if (numSerieArr[6].isDigit()) { if (numSerieArr[7].isDigit()) { if (numSerieArr[8].isDigit()) { if (numSerieArr[9].isDigit()) { if (numSerieArr[10].isDigit()) { if (numSerieArr[11].isLetter()) { isCorrect = true } } } } } } } } } } } } return isCorrect } </code></pre> <p>Thanks in advance for any replies to this!</p>
[ { "answer_id": 74359931, "author": "Jay M", "author_id": 1364242, "author_profile": "https://Stackoverflow.com/users/1364242", "pm_score": 2, "selected": true, "text": "clientlist=/path/to/logfile/which/consists/of/client/names\nlogfilebase=/path/to/where/the/logfiles/should/exist\ndeclare -a clients=($(grep -i 'list of client assets:' $clientlist | cut -d\":\" -f1))\n\nfor item in \"${clients[@]}\"; do\n if [ -e ${logfilebase}/${item}.log ]; then\n echo \"$item exists\"\n else\n echo \"$item does not exist - quit\"\n exit 1\n fi\ndone\n\n" }, { "answer_id": 74360327, "author": "tripleee", "author_id": 874188, "author_profile": "https://Stackoverflow.com/users/874188", "pm_score": 0, "selected": false, "text": "$clients" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359414", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20448606/" ]
74,359,437
<p>I'm just confused about this function code that kinda acts like a nested for loop but instead of a nested for loop it just calls the function</p> <p>mostly just the line where it says</p> <pre><code> // Draw pyramid of height n - 1 draw(n - 1); </code></pre> <p>would the n not be 0 if you input 1 but it isnt ?? i just dont know the explanation of it</p> <pre><code>#include &lt;iostream&gt; #include &lt;string.h&gt; using namespace std; int i; void draw(int n); int main() { // Get height of pyramid int height; cout &lt;&lt; &quot;Input Height: &quot;; cin &gt;&gt; height; // Draw pyramid draw(height); return 0; } void draw(int n) { // If nothing to draw if (n &lt;= 0) { return; } // Draw pyramid of height n - 1 draw(n - 1); // Draw one more row of width n for (int i = 0; i &lt; n; i++) { printf(&quot;#&quot;); } printf(&quot;\n&quot;); } </code></pre>
[ { "answer_id": 74359931, "author": "Jay M", "author_id": 1364242, "author_profile": "https://Stackoverflow.com/users/1364242", "pm_score": 2, "selected": true, "text": "clientlist=/path/to/logfile/which/consists/of/client/names\nlogfilebase=/path/to/where/the/logfiles/should/exist\ndeclare -a clients=($(grep -i 'list of client assets:' $clientlist | cut -d\":\" -f1))\n\nfor item in \"${clients[@]}\"; do\n if [ -e ${logfilebase}/${item}.log ]; then\n echo \"$item exists\"\n else\n echo \"$item does not exist - quit\"\n exit 1\n fi\ndone\n\n" }, { "answer_id": 74360327, "author": "tripleee", "author_id": 874188, "author_profile": "https://Stackoverflow.com/users/874188", "pm_score": 0, "selected": false, "text": "$clients" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359437", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20394908/" ]
74,359,455
<p>I'm just going over some python basics, and wrote some code that I thought would print every even element inside of a list:</p> <pre><code>def print_evens(numbers): &quot;&quot;&quot;Prints all even numbers in the list &quot;&quot;&quot; length = len(numbers) i = 0 while i &lt; length: if numbers[i] % 2 == 0: print (numbers[i]) i += 1 print_evens([1, 2, 3, 4, 5, 6]) </code></pre> <p>I'm not sure why but the loop doesn't go past the end condition and just keeps cycling back and forth. I feel I'm missing something very simple.</p> <p>If I had to guess where the problem lies, I'd say it's with the if statement, though I'm not sure what would be wrong about it.</p>
[ { "answer_id": 74359503, "author": "Aymen", "author_id": 5165980, "author_profile": "https://Stackoverflow.com/users/5165980", "pm_score": 3, "selected": true, "text": "1" }, { "answer_id": 74359652, "author": "0x0fba", "author_id": 20339407, "author_profile": "https://Stackoverflow.com/users/20339407", "pm_score": 1, "selected": false, "text": "def print_evens(numbers):\n \"\"\"Prints all even numbers in the list\n \"\"\"\n for n in numbers:\n if n % 2 == 0:\n print(n)\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359455", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18964030/" ]
74,359,478
<p>Hi everyone quick c++ question. I have a file that is formatted in a special way. The first line is a person's first and last name, the second line is his phone number and the third is adress. this a peace of the file, it's much larger but it looks like this:</p> <p>Mans Hansson</p> <p>8510309159</p> <p>Bössgränd 90, 373 02 RAMDALA</p> <p>Olliver Lindberg</p> <p>8602024898</p> <p>Sandviken 76, 710 27 DYLTABRUK</p> <p>Eskil Johnsson7901105838</p> <p>Löberöd 29, 521 29 KÄTTLISTORP</p> <p>And basically I want to read the first three lines once at a time. What I mean is I want to read line one and store in a variable called name, line 2 in phone_number and line 3 in adress and then repeat until end of file. this is my code:</p> <pre><code>int main(){ fstream fs; fs.open(&quot;/Users/brah79/Downloads/skola/c++/OOP/uppgift1/personInfo.txt&quot;); string name; string phone_number; string adress; while(!fs.eof()){ for(int i = 0; i &lt; 3; i++){ getline(fs, name); getline(fs, phone_number); getline(fs, adress); } cout &lt;&lt; &quot;first name: &quot; &lt;&lt; name &lt;&lt; endl; cout &lt;&lt; &quot;person nummer: &quot; &lt;&lt; phone_number &lt;&lt; endl; cout &lt;&lt; &quot;adress: &quot; &lt;&lt; adress &lt;&lt; endl; } fs.close(); return 0; } </code></pre> <p>this is the output:</p> <p>first name: Eskil Johnsson</p> <p>phone number: 7901105838</p> <p>adress: Löberöd 29, 521 29 KÄTTLISTORP</p> <p>question 1: my code is only reading the last three lines so basically information about the last person only.</p> <p>question 2: the name of the person consists of first and last name and I could not figure out a way to separate them into 2 variables.</p> <p>Hope my question is clear and someone can help.</p>
[ { "answer_id": 74359503, "author": "Aymen", "author_id": 5165980, "author_profile": "https://Stackoverflow.com/users/5165980", "pm_score": 3, "selected": true, "text": "1" }, { "answer_id": 74359652, "author": "0x0fba", "author_id": 20339407, "author_profile": "https://Stackoverflow.com/users/20339407", "pm_score": 1, "selected": false, "text": "def print_evens(numbers):\n \"\"\"Prints all even numbers in the list\n \"\"\"\n for n in numbers:\n if n % 2 == 0:\n print(n)\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359478", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20431658/" ]
74,359,496
<p>I have a txt file that I read into a list of strings in which each item of the list is a data sample of 3 variables <code>(A,B,C)</code></p> <pre><code>txt = [ '001 0198110', '0020130198110', '0030132198110', ] </code></pre> <p>A separate support dataframe that looks like this</p> <pre><code>df = pd.DataFrame(data=[[1,3,&quot;A&quot;],[4,3,&quot;B&quot;],[7,6,&quot;C&quot;]],columns=[&quot;Position&quot;,&quot;Lenght&quot;,&quot;Name&quot;]) df Position Lenght Name 0 1 3 A 1 4 3 B 2 7 6 C </code></pre> <p>indicates how I should read the txt. For example the variable A starts at position 1 of each record and its length is 3.</p> <p>Taking as an example only the first record</p> <pre><code>'001 0198110' </code></pre> <p>we have that <code>A=001</code> <code>B=empty-&gt;NaN</code> <code>C=0198110</code></p> <p>What would be an efficient way (considering that the txt file is 50k lines and contains +600 variables) to create the expected parsed dataframe</p> <pre><code> A B C 0 1 NaN 198110 1 2 13 198110 2 3 13 2198110 </code></pre> <p>I can use a for loop, but perhaps there is a better way</p>
[ { "answer_id": 74360029, "author": "Andrej Kesely", "author_id": 10035985, "author_profile": "https://Stackoverflow.com/users/10035985", "pm_score": 2, "selected": true, "text": "pd.read_fwf" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359496", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2038360/" ]
74,359,510
<p>For reasons outlined here: <a href="https://community.exasol.com/t5/discussion-forum/performance-on-premise-dropping/td-p/9029" rel="nofollow noreferrer">https://community.exasol.com/t5/discussion-forum/performance-on-premise-dropping/td-p/9029</a> we need to restart a database regularly (at least until al issues are resolved, and this can take some time). So the question arises: Can this be done on a regular bases without human interaction?</p> <p>LUA is not a solution, but perhaps a cron job is possible, but we need OS access for that, which we do not have.</p>
[ { "answer_id": 74359633, "author": "fortnico", "author_id": 19871177, "author_profile": "https://Stackoverflow.com/users/19871177", "pm_score": 0, "selected": false, "text": "shudownDatabase()" }, { "answer_id": 74359663, "author": "GriGrim", "author_id": 1842350, "author_profile": "https://Stackoverflow.com/users/1842350", "pm_score": 1, "selected": false, "text": "xmlrpc" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359510", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14047565/" ]
74,359,531
<p>I have made a very complex solution to something I feel should have a much simpler solution. In short what I want:</p> <ul> <li>I want to compute a new column containing the minimum value across 3 columns</li> <li>I want to ignore zeros and NAs</li> <li>If I only have zeros and NAs I want a zero</li> <li>If I have only NAs I want a NA</li> </ul> <p>Here is my solution, <strong>it works</strong>, but it is very complex and produces a warning.</p> <pre><code>&gt; library(dplyr) &gt; df &lt;- data.frame( + id = c(1, 2, 3, 4), + test1 = c( NA, NA, 2 , 3), + test2 = c( NA, 0, 1 , 1), + test3 = c(NA, NA, 0 , 2) + ) &gt; df2 &lt;- df %&gt;% + mutate(nieuw = apply(across(test1:test3), 1, function(x) min(x[x&gt;0]))) %&gt;% + rowwise() %&gt;% + mutate(nieuw = if_else(is.na(nieuw), max(across(test1:test3), na.rm = TRUE), nieuw)) %&gt;% + mutate(nieuw = ifelse(is.infinite(nieuw), NA, nieuw)) &gt; df id test1 test2 test3 1 1 NA NA NA 2 2 NA 0 NA 3 3 2 1 0 4 4 3 1 2 &gt; df2 # A tibble: 4 x 5 # Rowwise: id test1 test2 test3 nieuw &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; 1 1 NA NA NA NA 2 2 NA 0 NA 0 3 3 2 1 0 1 4 4 3 1 2 1 Warning message: Problem while computing `nieuw = if_else(...)`. i no non-missing arguments to max; returning -Inf i The warning occurred in row 1. </code></pre>
[ { "answer_id": 74359792, "author": "Maël", "author_id": 13460602, "author_profile": "https://Stackoverflow.com/users/13460602", "pm_score": 3, "selected": true, "text": "rowwise" }, { "answer_id": 74360682, "author": "AndS.", "author_id": 9778513, "author_profile": "https://Stackoverflow.com/users/9778513", "pm_score": 1, "selected": false, "text": "library(tidyverse)\n\nget_min <- function(data, cols){\n data[is.na(data)] <- 1e6\n data[data == 0] <- 1e5\n nums <- do.call(pmin, select(data, all_of(cols)))\n recode(nums, `1e+06` = NA_real_, `1e+05` = 0.)\n}\n\ndf %>%\n mutate(nieuw = get_min(., c(\"test1\", \"test2\", \"test3\")))\n#> id test1 test2 test3 nieuw\n#> 1 1 NA NA NA NA\n#> 2 2 NA 0 NA 0\n#> 3 3 2 1 0 1\n#> 4 4 3 1 2 1\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12456198/" ]
74,359,557
<p>I'm trying to find out how to format my json file for my puprose.</p> <p>My json file looks like this (pulled from sql db):</p> <pre><code>[ { &quot;type&quot;: &quot;xy&quot;, &quot;view_code&quot;: &quot;english&quot;, &quot;short&quot;: &quot;xy&quot;, &quot;product&quot;: &quot;simple&quot;, &quot;amount&quot;: &quot;4&quot; }, ] </code></pre> <p>what I am trying to achive is something like this:</p> <pre><code> [ { &quot;products&quot;:** { &quot;type&quot;: &quot;N1001&quot;, &quot;view_code&quot;: &quot;english&quot;, &quot;short&quot;: &quot;xy&quot;, &quot;product&quot;: &quot;simple&quot;, &quot;amount&quot;: &quot;4&quot; } } ] </code></pre> <p>how can I add {&quot;products&quot;: at the beginning and } at the end of my json file? So the main object is &quot;products&quot;:</p> <p>Thanks in advance! Wayx</p> <p>EDIT:</p> <p>I'm trying to achive something like this:</p> <pre><code>[ { &quot;products&quot;: { &quot;type&quot;: &quot;N1001&quot;, &quot;view_code&quot;: &quot;english&quot;, &quot;short&quot;: &quot;xy&quot;, &quot;product&quot;: &quot;simple&quot;, &quot;amount&quot;: &quot;4&quot; }, { &quot;type&quot;: &quot;N1001&quot;, &quot;view_code&quot;: &quot;english&quot;, &quot;short&quot;: &quot;xy&quot;, &quot;product&quot;: &quot;simple&quot;, &quot;amount&quot;: &quot;4&quot; } } ] </code></pre>
[ { "answer_id": 74359792, "author": "Maël", "author_id": 13460602, "author_profile": "https://Stackoverflow.com/users/13460602", "pm_score": 3, "selected": true, "text": "rowwise" }, { "answer_id": 74360682, "author": "AndS.", "author_id": 9778513, "author_profile": "https://Stackoverflow.com/users/9778513", "pm_score": 1, "selected": false, "text": "library(tidyverse)\n\nget_min <- function(data, cols){\n data[is.na(data)] <- 1e6\n data[data == 0] <- 1e5\n nums <- do.call(pmin, select(data, all_of(cols)))\n recode(nums, `1e+06` = NA_real_, `1e+05` = 0.)\n}\n\ndf %>%\n mutate(nieuw = get_min(., c(\"test1\", \"test2\", \"test3\")))\n#> id test1 test2 test3 nieuw\n#> 1 1 NA NA NA NA\n#> 2 2 NA 0 NA 0\n#> 3 3 2 1 0 1\n#> 4 4 3 1 2 1\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20448681/" ]
74,359,575
<p>To display the profile of each item, I need to display the same image (corresponding to the same ID) when the user clicks on each item on the next page (which is called PlayPage.dart here) in the section that is considered as the cover Main Page) How should I add the clickable property to the ListView.builder widget?</p> <p>I use info.json to get and display information</p> <p>I have used two containers to display items (photos) in two columns The right container displays the even indexes and the left container displays the odd indexes</p> <p>info.json file &amp; homepage.dart</p> <pre><code>[ { &quot;title&quot;: &quot;one&quot;, &quot;image&quot;: &quot;assets/pexels1.jpg&quot; }, { &quot;title&quot;: &quot;tow&quot;, &quot;image&quot;: &quot;assets/pexels2.jpg&quot; }, { &quot;title&quot;: &quot;three&quot;, &quot;image&quot;: &quot;assets/pexels3.jpg&quot; }, { &quot;title&quot;: &quot;four&quot;, &quot;image&quot;: &quot;assets/pexels4.jpg&quot; }, { &quot;title&quot;: &quot;five&quot;, &quot;image&quot;: &quot;assets/pexels3.jpg&quot; }, { &quot;title&quot;: &quot;six&quot;, &quot;image&quot;: &quot;assets/pexels1.jpg&quot; } ] List info = []; _initData(){ DefaultAssetBundle.of(context).loadString(&quot;json/info.json&quot;).then((value){ info = json.decode(value); }); } @override void initState(){ super.initState(); _initData(); } </code></pre> <p>You can see the relevant images</p> <p><a href="https://i.stack.imgur.com/bhKmC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bhKmC.png" alt="enter image description here" /></a></p> <p>This is the picture related to the program and its items <a href="https://i.stack.imgur.com/ggLwK.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ggLwK.jpg" alt="enter image description here" /></a></p>
[ { "answer_id": 74359620, "author": "batuhand", "author_id": 10376031, "author_profile": "https://Stackoverflow.com/users/10376031", "pm_score": 1, "selected": false, "text": " InkWell(\n \n onTap:(){\n \n //any logic here\n \n },\n \n child: //any widget here,\n),\n" }, { "answer_id": 74359763, "author": "Himani", "author_id": 18416001, "author_profile": "https://Stackoverflow.com/users/18416001", "pm_score": 0, "selected": false, "text": "ListView.builder(\n itemCount: list.length,\n itemBuilder: (context, index) {\n return `Row(\n children: [\n InkWell(\n onTap: (){\n print(\"Response: ${info[i].title}\");\n },\n child: Container(),\n ),\n InkWell(\n onTap: (){\n print(\"Response: ${info[i].title}\");\n },\n child: Container(),\n )\n ],\n )\n },\n ),\n" }, { "answer_id": 74360285, "author": "Muhammad Qazmouz", "author_id": 19122402, "author_profile": "https://Stackoverflow.com/users/19122402", "pm_score": 0, "selected": false, "text": "onTap()" }, { "answer_id": 74361675, "author": "mehrdad ghadermarzi", "author_id": 18057206, "author_profile": "https://Stackoverflow.com/users/18057206", "pm_score": 0, "selected": false, "text": " class PlayPage extends StatefulWidget {\n \n PlayPage({Key? key}) : super(key: key);\n \n @override\n _PlayPageState createState() => _PlayPageState();\n }\n \n class _PlayPageState extends State<PlayPage> {\n List info = [];\n _initData(){\n DefaultAssetBundle.of(context).\n loadString(\"json/info.json\").then((value){\n widget.info = json.decode(value);\n });\n }\n @override\n void initState(){\n super.initState();\n _initData();\n setupPlaylist();\n }\n return Scaffold(\n body: Stack(\n clipBehavior: Clip.none,\n children: [\n Container(\n decoration: BoxDecoration(\n image: DecorationImage(image:\n\n //get the image using info.json\n AssetImage('assets/pexels1.jpg'),fit: BoxFit.cover)\n ),\n ),\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359575", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18057206/" ]
74,359,588
<p>I need to find the time taken to execute a piece of code, and the method should be independent of system time, ie chrono and all wouldn't work.</p> <p>My usecse looks somewhat like this.</p> <pre><code>int main{ //start function(); //end time_take = end - start; } </code></pre> <p>I am working in an embedded platform that doesn't have the right time at the start-up. In my case, the start of funcion happens before actual time is set from ntp server and end happens after the exact time is obtained. So any method that compares the time difference between two points wouldn't work. Also, number of CPU ticks wouldn't work for me since my programme necessarily be running actively throughout.</p> <p>I tried the conventional methods and they didn't work for me.</p>
[ { "answer_id": 74359620, "author": "batuhand", "author_id": 10376031, "author_profile": "https://Stackoverflow.com/users/10376031", "pm_score": 1, "selected": false, "text": " InkWell(\n \n onTap:(){\n \n //any logic here\n \n },\n \n child: //any widget here,\n),\n" }, { "answer_id": 74359763, "author": "Himani", "author_id": 18416001, "author_profile": "https://Stackoverflow.com/users/18416001", "pm_score": 0, "selected": false, "text": "ListView.builder(\n itemCount: list.length,\n itemBuilder: (context, index) {\n return `Row(\n children: [\n InkWell(\n onTap: (){\n print(\"Response: ${info[i].title}\");\n },\n child: Container(),\n ),\n InkWell(\n onTap: (){\n print(\"Response: ${info[i].title}\");\n },\n child: Container(),\n )\n ],\n )\n },\n ),\n" }, { "answer_id": 74360285, "author": "Muhammad Qazmouz", "author_id": 19122402, "author_profile": "https://Stackoverflow.com/users/19122402", "pm_score": 0, "selected": false, "text": "onTap()" }, { "answer_id": 74361675, "author": "mehrdad ghadermarzi", "author_id": 18057206, "author_profile": "https://Stackoverflow.com/users/18057206", "pm_score": 0, "selected": false, "text": " class PlayPage extends StatefulWidget {\n \n PlayPage({Key? key}) : super(key: key);\n \n @override\n _PlayPageState createState() => _PlayPageState();\n }\n \n class _PlayPageState extends State<PlayPage> {\n List info = [];\n _initData(){\n DefaultAssetBundle.of(context).\n loadString(\"json/info.json\").then((value){\n widget.info = json.decode(value);\n });\n }\n @override\n void initState(){\n super.initState();\n _initData();\n setupPlaylist();\n }\n return Scaffold(\n body: Stack(\n clipBehavior: Clip.none,\n children: [\n Container(\n decoration: BoxDecoration(\n image: DecorationImage(image:\n\n //get the image using info.json\n AssetImage('assets/pexels1.jpg'),fit: BoxFit.cover)\n ),\n ),\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359588", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18726606/" ]
74,359,608
<p>I am a first-time user of Javascript as well as App script and I appreciate your help. In the following query which I manage to write, I want to get a list of <strong>'Activity' numbers</strong> on the email <strong>if the check values are equal to 1</strong>. The missing part at the moment is adding 'Activity' numbers to the email. I will attach a screenshot of my sheet as well. Thank you all in advance.</p> <pre><code>`` function sendEmail() { const ss = SpreadsheetApp.getActive(); const sh = ss.getSheetByName('Comparison'); const data = sh.getRange('I2:I').getValues(); const data2 = sh.getRange('J2:J').getValues(); //const activity = sh.getRange('C2:C').getValues(); var send= false; var send2= false; data.forEach(r=&gt;{ //Logger.log(r) let check = r[0]; if (check === 1){ send= true } }); data2.forEach(r=&gt;{ //Logger.log(r) let check2 = r[0]; if (check2 === 1){ send2= true } }); if (send=== true || send2 === true){ let subject = 'Some dates have changed' let message = &quot;Please look at the dashboard below to find the changes:\n &quot; ; //Logger.log(message) MailApp.sendEmail('zahxx@gmail.com', subject,message); } } `` </code></pre> <p><a href="https://i.stack.imgur.com/nZWaZ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nZWaZ.jpg" alt="enter image description here" /></a></p> <p>I have tried the above code and just need a bit help for one more addition to that code.</p>
[ { "answer_id": 74359620, "author": "batuhand", "author_id": 10376031, "author_profile": "https://Stackoverflow.com/users/10376031", "pm_score": 1, "selected": false, "text": " InkWell(\n \n onTap:(){\n \n //any logic here\n \n },\n \n child: //any widget here,\n),\n" }, { "answer_id": 74359763, "author": "Himani", "author_id": 18416001, "author_profile": "https://Stackoverflow.com/users/18416001", "pm_score": 0, "selected": false, "text": "ListView.builder(\n itemCount: list.length,\n itemBuilder: (context, index) {\n return `Row(\n children: [\n InkWell(\n onTap: (){\n print(\"Response: ${info[i].title}\");\n },\n child: Container(),\n ),\n InkWell(\n onTap: (){\n print(\"Response: ${info[i].title}\");\n },\n child: Container(),\n )\n ],\n )\n },\n ),\n" }, { "answer_id": 74360285, "author": "Muhammad Qazmouz", "author_id": 19122402, "author_profile": "https://Stackoverflow.com/users/19122402", "pm_score": 0, "selected": false, "text": "onTap()" }, { "answer_id": 74361675, "author": "mehrdad ghadermarzi", "author_id": 18057206, "author_profile": "https://Stackoverflow.com/users/18057206", "pm_score": 0, "selected": false, "text": " class PlayPage extends StatefulWidget {\n \n PlayPage({Key? key}) : super(key: key);\n \n @override\n _PlayPageState createState() => _PlayPageState();\n }\n \n class _PlayPageState extends State<PlayPage> {\n List info = [];\n _initData(){\n DefaultAssetBundle.of(context).\n loadString(\"json/info.json\").then((value){\n widget.info = json.decode(value);\n });\n }\n @override\n void initState(){\n super.initState();\n _initData();\n setupPlaylist();\n }\n return Scaffold(\n body: Stack(\n clipBehavior: Clip.none,\n children: [\n Container(\n decoration: BoxDecoration(\n image: DecorationImage(image:\n\n //get the image using info.json\n AssetImage('assets/pexels1.jpg'),fit: BoxFit.cover)\n ),\n ),\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359608", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18109414/" ]
74,359,615
<p>I have been trying to implement a web cache, I wrote a prototype without a library. Really my problem is that I discovered the Boost library. I'm trying to implement it in my web cache. Specially implementing this:</p> <p><a href="https://www.boost.org/doc/libs/1_66_0/libs/multi_index/doc/examples.html#example9" rel="nofollow noreferrer">https://www.boost.org/doc/libs/1_66_0/libs/multi_index/doc/examples.html#example9</a> &quot;This data structure is implemented with multi_index_container by combining a sequenced index and an index of type hashed_unique.&quot;</p> <p>Currently my class looks like this, by unit tests done, it works but my goal will be to implement as precise in question the lib Boost and especially the multi index container.</p> <p>I tried to change the type of the items but it didn't work, like this:</p> <pre><code>typedef multi_index_container&lt;items,indexed_by&lt;sequenced&lt;&gt;,hashed_unique&lt;identity&lt;Item&gt; &gt;&gt;&gt; item_list; </code></pre> <p>I got a message: Invalid use of non-static data member '_items'. This kind of error I can understand it but i not specify it because it is the global implementation that worries me</p> <p>If you find any other error apart from my precise question, I am also a taker.</p> <pre><code> template&lt;typename Tkey, typename Tval&gt; class CacheWeb{ private: unsigned int capacity; std::list&lt;std::pair&lt;Tkey, Tval&gt;&gt; items; std::unordered_map&lt;key, typename std::list&lt;std::pair&lt;Tkey, Tval&gt;&gt;::iterator&gt; lookup; CacheWeb(const CacheWeb&amp;) = delete; CacheWeb&amp; operator=(const CacheWeb&amp;) = delete; int capacityOut(){ if( capacity == 0 || lookup.size() &lt; capacity ) { return 0; } int cnt = 0; while(lookup.size() &gt; capacity) { lookup.erase(items.back().first); items.pop_back(); ++cnt; } return cnt; }; public: CacheWeb(int icapacity) : capacity(icapacity){}; virtual ~CacheWeb() = default; int size(){ return lookup.size(); }; bool empty(){ return lookup.empty(); }; void clear(){ lookup.clear(); items.clear(); }; bool contains(const Tkey&amp; key){ return lookup.find(key) != lookup.end(); }; void remove(const Tkey&amp; key){ auto it = lookup.find(key); items.erase(it-&gt;second); lookup.erase(it); }; void put(const Tkey&amp; key, const Tval&amp; val){ auto it = lookup.find(key); if( it != lookup.end() ) { it-&gt;second-&gt;second = val; items.splice(items.begin(), items, it-&gt;second); return; } items.emplace_front(key, val); lookup[key] = items.begin(); capacityOut(); }; std::list&lt;std::pair&lt;Tkey, Tval&gt;&gt;getItems(){ return items; }; const VAL_T&amp; get(const Tkey&amp; key){ const auto it = lookup.find(key); if( it == lookup.end() ) { throw std::invalid_argument(&quot;Key does not exist&quot;); } items.splice(items.begin(), items, it-&gt;second); return it-&gt;second-&gt;second; }; }; } </code></pre>
[ { "answer_id": 74362100, "author": "Joaquín M López Muñoz", "author_id": 213114, "author_profile": "https://Stackoverflow.com/users/213114", "pm_score": 2, "selected": false, "text": "#include <boost/multi_index_container.hpp>\n#include <boost/multi_index/sequenced_index.hpp>\n#include <boost/multi_index/hashed_index.hpp>\n#include <boost/multi_index/key.hpp>\n\ntemplate<typename Tkey, typename Tval>\nclass CacheWeb{\n private:\n using value_type = std::pair<Tkey, Tval>;\n \n unsigned int capacity;\n boost::multi_index_container<\n value_type,\n boost::multi_index::indexed_by<\n boost::multi_index::sequenced<>,\n boost::multi_index::hashed_unique<boost::multi_index::key<&value_type::first>>\n >\n > container; \n \n CacheWeb(const CacheWeb&) = delete;\n CacheWeb& operator=(const CacheWeb&) = delete;\n\n int capacityOut(){\n if( capacity == 0 || container.size() < capacity ) {\n return 0;\n }\n int cnt = 0;\n while(container.size() > capacity) {\n container.pop_back();\n ++cnt;\n }\n return cnt; \n };\n\n public:\n CacheWeb(int icapacity) : capacity(icapacity){};\n virtual ~CacheWeb() = default;\n \n\n int size(){\n return container.size();\n };\n bool empty(){\n return container.empty(); \n };\n void clear(){\n container.clear(); \n };\n\n bool contains(const Tkey& key){\n const auto& lookup = container.template get<1>();\n return lookup.find(key) != container.template get<1>().end(); \n };\n\n void remove(const Tkey& key){\n container.erase(key);\n };\n\n void put(const Tkey& key, const Tval& val){\n auto& lookup = container.template get<1>();\n auto it = lookup.find(key);\n if( it != lookup.end() ) {\n lookup.modify(it,[&](value_type& x){ x.second = val; });\n }\n else{\n it=lookup.emplace(key, val).first;\n }\n container.relocate(container.begin(),container.template project<0>(it));\n capacityOut();\n };\n\n std::list<std::pair<Tkey, Tval>>getItems(){\n return {container.begin(), container.end()};\n };\n\n const Tval& get(const Tkey& key){\n const auto& lookup = container.template get<1>();\n const auto it = lookup.find(key);\n if( it == lookup.end() ) {\n throw std::invalid_argument(\"Key does not exist\");\n }\n return it->second;\n }\n};\n \n#include <iostream>\n\nint main()\n{\n CacheWeb<int,int> c(10);\n for(int i=0;i<11;++i)c.put(i,i);\n \n for(const auto& x:c.getItems()){\n std::cout<<\"(\"<<x.first<<\",\"<<x.second<<\")\";\n }\n std::cout<<\"\\n\";\n \n for(int i=1;i<11;++i){\n std::cout<<i<<\"->\"<<c.get(i)<<\" \";\n }\n std::cout<<\"\\n\";\n}\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13904076/" ]
74,359,624
<p>I'm trying to use fill_between to fill different regions of a plot, but I get gaps between the regions I'm trying to fill.</p> <p>I've tried using interpolate=True, but this results in non rectangular shapes...</p> <p>`</p> <pre><code>import matplotlib.pyplot as plt import numpy as np fig, ax = plt.subplots() x = np.arange(0, 4 * np.pi, 0.01) y = np.sin(x) ax.plot(x, y, color='black') threshold = 0.75 ax.axhline(threshold, color='green', lw=2, alpha=0.7) ax.fill_between(x, 0, 1, where=y &gt; threshold, facecolor=(0.5,0,0,0.5), ec=None,transform=ax.get_xaxis_transform()) ax.fill_between(x, 0, 1, where=y &lt;= threshold, facecolor=(0,0.5,0,0.5), ec=None, transform=ax.get_xaxis_transform()) </code></pre> <p>` I've attched a zoomed in screenshot of the plot. <a href="https://i.stack.imgur.com/4ILzV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4ILzV.png" alt="plot" /></a></p>
[ { "answer_id": 74362100, "author": "Joaquín M López Muñoz", "author_id": 213114, "author_profile": "https://Stackoverflow.com/users/213114", "pm_score": 2, "selected": false, "text": "#include <boost/multi_index_container.hpp>\n#include <boost/multi_index/sequenced_index.hpp>\n#include <boost/multi_index/hashed_index.hpp>\n#include <boost/multi_index/key.hpp>\n\ntemplate<typename Tkey, typename Tval>\nclass CacheWeb{\n private:\n using value_type = std::pair<Tkey, Tval>;\n \n unsigned int capacity;\n boost::multi_index_container<\n value_type,\n boost::multi_index::indexed_by<\n boost::multi_index::sequenced<>,\n boost::multi_index::hashed_unique<boost::multi_index::key<&value_type::first>>\n >\n > container; \n \n CacheWeb(const CacheWeb&) = delete;\n CacheWeb& operator=(const CacheWeb&) = delete;\n\n int capacityOut(){\n if( capacity == 0 || container.size() < capacity ) {\n return 0;\n }\n int cnt = 0;\n while(container.size() > capacity) {\n container.pop_back();\n ++cnt;\n }\n return cnt; \n };\n\n public:\n CacheWeb(int icapacity) : capacity(icapacity){};\n virtual ~CacheWeb() = default;\n \n\n int size(){\n return container.size();\n };\n bool empty(){\n return container.empty(); \n };\n void clear(){\n container.clear(); \n };\n\n bool contains(const Tkey& key){\n const auto& lookup = container.template get<1>();\n return lookup.find(key) != container.template get<1>().end(); \n };\n\n void remove(const Tkey& key){\n container.erase(key);\n };\n\n void put(const Tkey& key, const Tval& val){\n auto& lookup = container.template get<1>();\n auto it = lookup.find(key);\n if( it != lookup.end() ) {\n lookup.modify(it,[&](value_type& x){ x.second = val; });\n }\n else{\n it=lookup.emplace(key, val).first;\n }\n container.relocate(container.begin(),container.template project<0>(it));\n capacityOut();\n };\n\n std::list<std::pair<Tkey, Tval>>getItems(){\n return {container.begin(), container.end()};\n };\n\n const Tval& get(const Tkey& key){\n const auto& lookup = container.template get<1>();\n const auto it = lookup.find(key);\n if( it == lookup.end() ) {\n throw std::invalid_argument(\"Key does not exist\");\n }\n return it->second;\n }\n};\n \n#include <iostream>\n\nint main()\n{\n CacheWeb<int,int> c(10);\n for(int i=0;i<11;++i)c.put(i,i);\n \n for(const auto& x:c.getItems()){\n std::cout<<\"(\"<<x.first<<\",\"<<x.second<<\")\";\n }\n std::cout<<\"\\n\";\n \n for(int i=1;i<11;++i){\n std::cout<<i<<\"->\"<<c.get(i)<<\" \";\n }\n std::cout<<\"\\n\";\n}\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359624", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19357142/" ]
74,359,625
<p>I just had my first brush with Node. Now I am trying to install some npm packages.</p> <p>Whenever I run the command <code>npm install package-name</code>, it doesn't show any error and it also does not install the package(no <code>node_modules</code> folder, just does nothing). Here is the kind of message I get:</p> <blockquote> <p>up to date, audited 248 packages in 11s</p> <p>8 packages are looking for funding run <code>npm fund</code> for details</p> <p>19 vulnerabilities (6 moderate, 9 high, 4 critical)</p> <p>To address issues that do not require attention, run: npm audit fix</p> <p>To address all issues (including breaking changes), run: npm audit fix --force</p> <p>Run <code>npm audit</code> for details.</p> </blockquote> <p>I have also tried <code>npm i package-name</code> and <code>npm install --save package-name</code>, but all give the same message. I'm currently using Node version <code>18.12.1</code>.</p> <p>What could I be doing wrong and what could be causing this issue?</p>
[ { "answer_id": 74362100, "author": "Joaquín M López Muñoz", "author_id": 213114, "author_profile": "https://Stackoverflow.com/users/213114", "pm_score": 2, "selected": false, "text": "#include <boost/multi_index_container.hpp>\n#include <boost/multi_index/sequenced_index.hpp>\n#include <boost/multi_index/hashed_index.hpp>\n#include <boost/multi_index/key.hpp>\n\ntemplate<typename Tkey, typename Tval>\nclass CacheWeb{\n private:\n using value_type = std::pair<Tkey, Tval>;\n \n unsigned int capacity;\n boost::multi_index_container<\n value_type,\n boost::multi_index::indexed_by<\n boost::multi_index::sequenced<>,\n boost::multi_index::hashed_unique<boost::multi_index::key<&value_type::first>>\n >\n > container; \n \n CacheWeb(const CacheWeb&) = delete;\n CacheWeb& operator=(const CacheWeb&) = delete;\n\n int capacityOut(){\n if( capacity == 0 || container.size() < capacity ) {\n return 0;\n }\n int cnt = 0;\n while(container.size() > capacity) {\n container.pop_back();\n ++cnt;\n }\n return cnt; \n };\n\n public:\n CacheWeb(int icapacity) : capacity(icapacity){};\n virtual ~CacheWeb() = default;\n \n\n int size(){\n return container.size();\n };\n bool empty(){\n return container.empty(); \n };\n void clear(){\n container.clear(); \n };\n\n bool contains(const Tkey& key){\n const auto& lookup = container.template get<1>();\n return lookup.find(key) != container.template get<1>().end(); \n };\n\n void remove(const Tkey& key){\n container.erase(key);\n };\n\n void put(const Tkey& key, const Tval& val){\n auto& lookup = container.template get<1>();\n auto it = lookup.find(key);\n if( it != lookup.end() ) {\n lookup.modify(it,[&](value_type& x){ x.second = val; });\n }\n else{\n it=lookup.emplace(key, val).first;\n }\n container.relocate(container.begin(),container.template project<0>(it));\n capacityOut();\n };\n\n std::list<std::pair<Tkey, Tval>>getItems(){\n return {container.begin(), container.end()};\n };\n\n const Tval& get(const Tkey& key){\n const auto& lookup = container.template get<1>();\n const auto it = lookup.find(key);\n if( it == lookup.end() ) {\n throw std::invalid_argument(\"Key does not exist\");\n }\n return it->second;\n }\n};\n \n#include <iostream>\n\nint main()\n{\n CacheWeb<int,int> c(10);\n for(int i=0;i<11;++i)c.put(i,i);\n \n for(const auto& x:c.getItems()){\n std::cout<<\"(\"<<x.first<<\",\"<<x.second<<\")\";\n }\n std::cout<<\"\\n\";\n \n for(int i=1;i<11;++i){\n std::cout<<i<<\"->\"<<c.get(i)<<\" \";\n }\n std::cout<<\"\\n\";\n}\n" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359625", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14357856/" ]
74,359,626
<p>I don't understand if it is possible to use class methods in another method of the same class. If so, where am I making a mistake</p> <pre><code>class Form { constructor (classForm, name, email, phone, text) { this.form = document.querySelector(`.contactForm`); this.name = document.querySelector(`.contactForm [name=${name}]`); this.email = document.querySelector(`.contactForm [name=${email}]`); this.phone = document.querySelector(`.contactForm [name=${phone}]`); this.text = document.querySelector(`.contactForm [name=${text}]`); this.submit = document.querySelector(`.contactForm [name=submit]`); } checkPhone () { return this.phone.value.length &gt;= 12; } formSubmit (el) { console.log(this.checkPhone()) el.preventDefault(); console.log('not') } } const formContact = new Form(&quot;contactForm&quot;, &quot;nameUser&quot;, &quot;emailUser&quot;, &quot;phoneUser&quot;); formContact.form.addEventListener(&quot;submit&quot;, formContact.formSubmit); </code></pre> <p><strong>&quot;Uncaught TypeError: this.checkPhone is not a function&quot;</strong></p>
[ { "answer_id": 74359671, "author": "ask4you", "author_id": 18309173, "author_profile": "https://Stackoverflow.com/users/18309173", "pm_score": 1, "selected": false, "text": "bind" }, { "answer_id": 74359815, "author": "Boguz", "author_id": 5509709, "author_profile": "https://Stackoverflow.com/users/5509709", "pm_score": 2, "selected": true, "text": "formSubmit" }, { "answer_id": 74359872, "author": "scottwillmoore", "author_id": 7349225, "author_profile": "https://Stackoverflow.com/users/7349225", "pm_score": 2, "selected": false, "text": "this" } ]
2022/11/08
[ "https://Stackoverflow.com/questions/74359626", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20020672/" ]