qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,217,318
<p>May be I don't get a basic thing, but I recently discovered this behaviour, and by now I don't understand what's happening:</p> <pre><code>A = [3 NaN .12 NaN NaN 9] A = 3 NaN 0.12 NaN NaN 9 &gt;&gt; nansA = isnan(A) nansA = 0 1 0 1 1 0 &gt;&gt; nnansA = ~isnan(A) nnansA = 1 0 1 0 0 1 &gt;&gt; nnansA1 = ~isnan(A(1:end)) nnansA1 = 1 0 1 0 0 1 &gt;&gt; nnansA2 = ~isnan(A(2:end)) nnansA2 = 0 1 0 0 1 &gt;&gt; AnnansA1 = A(~isnan(A(1:end))) AnnansA1 = 3 0.12 9 &gt;&gt; **AnnansA2 = A(~isnan(A(2:end))) AnnansA2 = NaN NaN </code></pre> <p>What is happening here?</p> <p>Does this happen in Matlab too?</p> <p>I would expect something like <code>... AnnansA2 = 0.12 9 </code></p>
[ { "answer_id": 74217402, "author": "Anthony Evans", "author_id": 4912240, "author_profile": "https://Stackoverflow.com/users/4912240", "pm_score": 0, "selected": false, "text": "AnnansA2 = A(~isnan(A(1:end)))" }, { "answer_id": 74275060, "author": "carandraug", "author_id...
2022/10/27
[ "https://Stackoverflow.com/questions/74217318", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20345661/" ]
74,217,344
<pre><code>marks = [95, 98, 97] i = 0 while i &lt; len(marks): print(marks[i]) i = i + 1 </code></pre> <p>I want to understand this print(marks[i]) and i = i + 1, what is its use here and why can it not be written before print function?</p> <p>I am learning about while loop in list data type and I am not able to understand this code.</p>
[ { "answer_id": 74217407, "author": "Hendrik Wiese", "author_id": 205147, "author_profile": "https://Stackoverflow.com/users/205147", "pm_score": 1, "selected": false, "text": "marks" }, { "answer_id": 74217416, "author": "KillerRebooted", "author_id": 18554284, "autho...
2022/10/27
[ "https://Stackoverflow.com/questions/74217344", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20345724/" ]
74,217,345
<p>For example, Let's say a variable <code>x</code>, <code>x</code> could be anything include <code>0</code>.<br /> Then we got code like:</p> <pre><code>if(x==0) { y = 1; } else { y = x; } </code></pre> <p>Could I do this without producing branches in C/C++?</p> <p>I'm trying to optimize a piece of code. I want to remove branches as much as possible. There are similar judgments, so I want to convert them into statements without branches to make the code as efficient as possible.</p>
[ { "answer_id": 74217616, "author": "wohlstad", "author_id": 18519921, "author_profile": "https://Stackoverflow.com/users/18519921", "pm_score": 4, "selected": true, "text": "y = !x + x;\n" }, { "answer_id": 74225421, "author": "Peter Cordes", "author_id": 224132, "aut...
2022/10/27
[ "https://Stackoverflow.com/questions/74217345", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15295004/" ]
74,217,352
<p>I have a data frame as below.</p> <pre><code>pl.DataFrame({'combine_address':[ [&quot;Yes|#456 Lane|Apt#4|ABC|VA|50566&quot;, &quot;Yes|#456 Lane|Apt#4|ABC|VA|50566&quot;, &quot;No|#456 Lane|Apt#4|ABC|VA|50566&quot;], [&quot;No|#8495|APT#94|SWE|WA|43593&quot;, &quot;No|#8495|APT#94|SWE|WA|43593&quot;, &quot;Yes|#8495|APT#94|SWE|WA|43593&quot;] ]}) </code></pre> <p>Here combine address is a list type column which has elements with about 6 pipe(|) values, Here i would like to apply a split on each element with an separator(|) in a list.</p> <p>Here is the expected output:</p> <p><a href="https://i.stack.imgur.com/gtgFp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gtgFp.png" alt="enter image description here" /></a></p> <p>If a list has 3 elements the splitted columns will be 3*6=18</p> <p>If a list has 5 elements the splitted columns will be 5*6=30 and so on so forth.</p>
[ { "answer_id": 74218200, "author": "Adela Li 2022", "author_id": 20337481, "author_profile": "https://Stackoverflow.com/users/20337481", "pm_score": 0, "selected": false, "text": "import polars as pl\nimport pandas as pd\ndf=pd.DataFrame({'combine_address':[ [\"Yes|#456 Lane|Apt#4|ABC|VA...
2022/10/27
[ "https://Stackoverflow.com/questions/74217352", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9479925/" ]
74,217,368
<p>So I need to remove for example the letter &quot;a&quot; from every word in a string which is an element of array, except the word &quot;an&quot;</p> <pre class="lang-js prettyprint-override"><code>var arr = ['sentence example', 'an element of array', 'smth else'] var removedPuncts = [] for (i = 0; i &lt; arr.length; i++) { if (sentences.indexOf(&quot;an&quot;)) { ... } } console.log(removedPuncts) //expected output: ['sentence exmple', 'an element of rry', 'smth else'] </code></pre> <p>So maximum I thought it'll be needed to find an's index, but don't have an idea what to do next.</p>
[ { "answer_id": 74217378, "author": "CertainPerformance", "author_id": 9515207, "author_profile": "https://Stackoverflow.com/users/9515207", "pm_score": 1, "selected": false, "text": "a" }, { "answer_id": 74217476, "author": "Assorted", "author_id": 16864284, "author_p...
2022/10/27
[ "https://Stackoverflow.com/questions/74217368", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
74,217,404
<p>I get this error form helper.php. I need sale prices of product. but I get this error.And I dont understand when I get this error.</p> <blockquote> <p>helper.php</p> </blockquote> <pre><code>public static function getSalesPriceUsingProductIDCode($id, $customerId) { $data = PosCustomerProducts::valid()-&gt;where('complete_status',0)-&gt;where('customer_id', $customerId)-&gt;where('product_id', $id) -&gt;select('product_id', 'sales_price') -&gt;first()-&gt;sales_price; return $data; } </code></pre> <blockquote> <p>orderSheetExport.php</p> </blockquote> <pre><code>if(isset($results[$product-&gt;id])) { if (Helper::getSalesPriceUsingProductIDCode($product-&gt;id,$results['customer_id'])==0) { $excel_dynamic_data_values[$index][] = $product-&gt;whole_sale_price * $results[$product-&gt;id]; $productArray[$rsm_id][$product-&gt;id] += $results[$product-&gt;id] * $product-&gt;whole_sale_price; $singleProductArray[$rsm_id][$product-&gt;id] = $productArray[$rsm_id][$product-&gt;id]; }else { $excel_dynamic_data_values[$index][] = Helper::getSalesPriceUsingProductIDCode($product-&gt;id,$results['customer_id']) * $results[$product-&gt;id]; $productArray[$rsm_id][$product-&gt;id] += $results[$product-&gt;id] * Helper::getSalesPriceUsingProductIDCode( $product-&gt;id,$results['customer_id']); $singleProductArray[$rsm_id][$product-&gt;id] = $productArray[$rsm_id][$product-&gt;id]; } } </code></pre>
[ { "answer_id": 74217734, "author": "Anika Tabassum", "author_id": 12492468, "author_profile": "https://Stackoverflow.com/users/12492468", "pm_score": 0, "selected": false, "text": "public static function getSalesPriceUsingProductIDCode($id, $customerId)\n{\n $data = PosCustomerProduct...
2022/10/27
[ "https://Stackoverflow.com/questions/74217404", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12492468/" ]
74,217,422
<p>I'm getting some weird white space when I drag the item to reorder it that is defined nowhere. How can I get rid of the white spacing and extend the card to fill this space? That's how the white spacing looks like when reordering the item:</p> <p><a href="https://i.stack.imgur.com/XTXOo.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XTXOo.jpg" alt="enter image description here" /></a></p> <p>And that's my code to build the body of the Scaffold:</p> <pre><code>body: Stack( children: [ Positioned( child: ReorderableListView.builder( buildDefaultDragHandles: false, itemCount: widget.cards.length, itemBuilder: (context, index) { return Dismissible( key: Key(widget.cards[index].name), onDismissed: (direction) { setState(() {}); }, child: Card( child: SizedBox( height: 75, child: ListTile( tileColor: Colors.red.shade200, title: Text(widget.cards[index].name), trailing: ReorderableDragStartListener( index: index, child: const Icon(Icons.drag_handle), ), onTap: (){ }, ), ), ), ); }, ), ) ]) </code></pre>
[ { "answer_id": 74217546, "author": "K K Muhammed Fazil", "author_id": 11922179, "author_profile": "https://Stackoverflow.com/users/11922179", "pm_score": 3, "selected": true, "text": "Card(\n margin: EdgeInsets.all(0),\n child: SizedBox( .......\n" }, { "answer_id": 74217...
2022/10/27
[ "https://Stackoverflow.com/questions/74217422", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9564867/" ]
74,217,460
<p>I'm stuck with this query. I wonder if somebody can give me some idea how to resolve this.</p> <p>Here is my table:</p> <p><img src="https://i.stack.imgur.com/RP0xV.png" alt="enter image description here" /></p> <p>I basically want to group by product with the highest value of quality. But at the same time I also need to grab completed column.</p> <pre><code>select Product, max(Quality) as Quality from [Table] group by Product </code></pre> <p>When I group it, I cannot retrieve completed column.</p> <p><img src="https://i.stack.imgur.com/ogAjj.png" alt="enter image description here" /></p> <p>Any other method to have same result above with completed column? in this case 1, 1 will be displayed.</p> <p>Thanks in advance</p>
[ { "answer_id": 74217546, "author": "K K Muhammed Fazil", "author_id": 11922179, "author_profile": "https://Stackoverflow.com/users/11922179", "pm_score": 3, "selected": true, "text": "Card(\n margin: EdgeInsets.all(0),\n child: SizedBox( .......\n" }, { "answer_id": 74217...
2022/10/27
[ "https://Stackoverflow.com/questions/74217460", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6892025/" ]
74,217,479
<p>I have 70k files all of which look similar to this:</p> <pre><code>{'id': 24, 'name': None, 'city': 'City', 'region_id': 19, 'story_id': 1, 'description': 'text', 'uik': None, 'ustatus': 'status', 'wuiki_tik_name': '', 'reaction': None, 'reaction_official': '', 'created_at': '2011-09-07T07:24:44.420Z', 'lat': 54.7, 'lng': 20.5, 'regions': {'id': 19, 'name': 'name'}, 'stories': {'id': 1, 'name': '2011-12-04'}, 'assets': [], 'taggings': [{'tags': {'id': 6, 'name': 'name', 'tag_groups': {'id': 3, 'name': 'Violation'}}}, {'tags': {'id': 8, 'name': 'name', 'tag_groups': {'id': 5, 'name': 'resource'}}}, {'tags': {'id': 1, 'name': '01. Federal', 'tag_groups': {'id': 1, 'name': 'Level'}}}, {'tags': {'id': 3, 'name': '03. Local', 'tag_groups': {'id': 1, 'name': 'stuff'}}}, {'tags': {'id': 2, 'name': '02. Regional', 'tag_groups': {'id': 1, 'name': 'Level'}}}], 'message_id': None, '_count': {'assets': 0, 'other_messages': 0, 'similars': 0, 'taggings': 5}} </code></pre> <p>The ultimate goal is to export it into a single CSV file. It can be successfully done without flattening. But since it has a lot of nested values, I would like to flatten it, and this is where I began facing problems related to data types. Here's the code:</p> <pre><code>import json from pandas.io.json import json_normalize import glob path = glob.glob(&quot;all_messages/*.json&quot;) for file in path: with open(file, &quot;r&quot;) as filer: content = json.loads(json.dumps(filer.read())) if content != 404: df_main = json_normalize(content) df_regions = json_normalize(content, record_path=['regions'], record_prefix='regions.', meta=['id']) df_stories = json_normalize(content, record_path=['stories'], record_prefix='stories.', meta=['id']) #... More code related to normalization df_out.to_csv('combined_json.csv') </code></pre> <p>This code occasionally throws: <code>AttributeError: 'str' object has no attribute 'values'</code> or <code>ValueError: DataFrame constructor not properly called!</code>. I realise that this is caused by json.dumps() JSON string output. However, I have failed to turn it into anything useable.</p> <p>Any possible solutions to this?</p>
[ { "answer_id": 74217546, "author": "K K Muhammed Fazil", "author_id": 11922179, "author_profile": "https://Stackoverflow.com/users/11922179", "pm_score": 3, "selected": true, "text": "Card(\n margin: EdgeInsets.all(0),\n child: SizedBox( .......\n" }, { "answer_id": 74217...
2022/10/27
[ "https://Stackoverflow.com/questions/74217479", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14574953/" ]
74,217,489
<p>I'm failing to show Font Awesome icons on my app (only this page)! The icons are showing on the other pages but not on this one I don't know why! and yes I'm importing it in my index.html</p> <pre><code>&lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css&quot; integrity=&quot;sha512-KfkfwYDsLkIlwQp6LFnl8zNdLGxu9YAA1QvwINks4PhcElQSvqcyVLLD9aMhXd13uQjoXtEKNosOWaZqXgel0g==&quot; crossorigin=&quot;anonymous&quot; referrerpolicy=&quot;no-referrer&quot; /&gt; </code></pre> <p>A link to <a href="https://codesandbox.io/s/trusting-ives-uv7ocv?file=/Post.jsx" rel="nofollow noreferrer">codesandbox</a> for better viewing</p> <p>Here the code:</p> <pre><code>export default function Post({ post }) { return ( &lt;div className=&quot;coupon-container&quot;&gt; &lt;div className=&quot;coupon&quot;&gt; &lt;div className=&quot;content&quot;&gt; &lt;h2&gt;TITLE GOES HERE&lt;/h2&gt; &lt;h1&gt; TEXT &lt;span&gt;TEXT&lt;/span&gt; &lt;/h1&gt; &lt;/div&gt; &lt;div className=&quot;couponValidity&quot;&gt; &lt;i className=&quot;fa fa-solid fa-timer&quot;&gt;&lt;/i&gt; &lt;p&gt;SOME TEXT GOES HERE&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; ); } </code></pre>
[ { "answer_id": 74217571, "author": "khashaa amaze", "author_id": 11423530, "author_profile": "https://Stackoverflow.com/users/11423530", "pm_score": 0, "selected": false, "text": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"UTF-8\">\n <meta http-equiv=\"X-UA-Compa...
2022/10/27
[ "https://Stackoverflow.com/questions/74217489", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17342280/" ]
74,217,492
<p>I am trying to create a class Matrix which has a method called row_echelon, and I am trying to use recursion, but it's not working.</p> <pre><code>class Matrix: def __init__(self,matrix): self.matrix = matrix def row_echelon(self): r, c = self.matrix.shape if r == 0 or c == 0: return self.matrix for i in range(len(self.matrix)): if self.matrix[i,0] != 0: break else: new_matrix = self.row_echelon(self.matrix[:,1:]) return np.hstack([self.matrix[:,:1], new_matrix]) if i &gt; 0: ith_row = self.matrix[i].copy() self.matrix[i] = self.matrix[0] self.matrix[0] = ith_row self.matrix[0] = self.matrix[0] / self.matrix[0,0] self.matrix[1:] -= self.matrix[0] * self.matrix[1:,0:1] new_matrix = self.row_echelon(self.matrix[1:,1:]) return np.vstack([self.matrix[:1], np.hstack([self.matrix[1:,:1], new_matrix]) ]) </code></pre> <p>Here are my input and ouput: Input:</p> <pre><code>A = np.array([[4, 7, 3, 8], [8, 3, 8, 7], [2, 9, 5, 3]], dtype='float') my_matrix = Matrix(A) print(my_matrix.row_echelon()) </code></pre> <p>Output: `</p> <pre><code>TypeError Traceback (most recent call last) Cell In [43], line 5 1 A = np.array([[4, 7, 3, 8], 2 [8, 3, 8, 7], 3 [2, 9, 5, 3]], dtype='float') 4 my_matrix = Matrix(A) ----&gt; 5 print(my_matrix.row_echelon()) Cell In [42], line 46, in Matrix.row_echelon(self) 41 self.matrix[0] = self.matrix[0] / self.matrix[0,0] 43 self.matrix[1:] -= self.matrix[0] * self.matrix[1:,0:1] ---&gt; 46 new_matrix = self.row_echelon(self.matrix[1:,1:]) 48 return np.vstack([self.matrix[:1], np.hstack([self.matrix[1:,:1], new_matrix]) ]) TypeError: Matrix.row_echelon() takes 1 positional argument but 2 were given </code></pre> <p>` I don't understand which 2 arguements are given?</p>
[ { "answer_id": 74217571, "author": "khashaa amaze", "author_id": 11423530, "author_profile": "https://Stackoverflow.com/users/11423530", "pm_score": 0, "selected": false, "text": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"UTF-8\">\n <meta http-equiv=\"X-UA-Compa...
2022/10/27
[ "https://Stackoverflow.com/questions/74217492", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20287884/" ]
74,217,497
<p>I was creating a 2048 clone from scratch as a project. I have got the game pretty much working only problem is that my animations look janky. I have used css grid to construct my game board and after every move (user input) all the tiles are meant to slide across the board in a direction. That part works fine, it's when they start the slide animation that for whatever reason some of the elements flicker.</p> <p>I'm not the best with css animations but I have tried to look at every resource I could and I couldn't find any solutions suited to my code. I tried switching the animation timing, delaying the animation etc to no avail. I did use a package <a href="https://github.com/aholachek/animate-css-grid/blob/master/src/index.ts" rel="nofollow noreferrer">animate-css-grid</a> (because animating css grid is hard) which only handles the tiles sliding across the grid and I do not suspect that it is causing the issue.</p> <p>I have put the code on js fiddle if anyone is interested to try and see the problem <a href="https://jsfiddle.net/codedjourney/uv1o48L6/3/" rel="nofollow noreferrer">https://jsfiddle.net/codedjourney/uv1o48L6/3/</a> <code>hello</code></p> <p>Also if anyone has a better way of animating css grid let me know the package while helpful is a bit odd to work with. Thanks for the help</p>
[ { "answer_id": 74218441, "author": "K i", "author_id": 11196771, "author_profile": "https://Stackoverflow.com/users/11196771", "pm_score": 1, "selected": false, "text": "hidden" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74217497", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20345387/" ]
74,217,506
<p>I am trying to exclude the rows with zero values from all months showing in the below table.</p> <p>This is sample data; there will be thousand of products with partial or full zero in between 12 months in real scenario. There will also be more months (columns) in real scenario.</p> <p><a href="https://i.stack.imgur.com/SfMd7.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SfMd7.jpg" alt="enter image description here" /></a></p> <p>The expected result will be look like this.</p> <p><a href="https://i.stack.imgur.com/cCJXZ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cCJXZ.jpg" alt="enter image description here" /></a></p>
[ { "answer_id": 74217562, "author": "Littlefoot", "author_id": 9097906, "author_profile": "https://Stackoverflow.com/users/9097906", "pm_score": 1, "selected": false, "text": "where" }, { "answer_id": 74218053, "author": "Jonas Metzler", "author_id": 18794826, "author_...
2022/10/27
[ "https://Stackoverflow.com/questions/74217506", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5171816/" ]
74,217,524
<p>I have a <code>curTime</code> variable that is the current time using <code>new Date()</code> and a <code>pwChangeDate</code> value called from the backend data.</p> <pre><code> let curTime = new Date(); // Thu Oct 27 2022 15:02:34 GMT+0900 const pwDate = new Date(pwChangeDate) // Thu Oct 20 2022 13:51:57 GMT+0900 </code></pre> <p>At this time, when <code>pwDate</code> passes 90 days based on <code>curTime</code>, I want to display an alert saying &quot;90 days have passed.&quot; and when 83 days have passed, &quot;7 days left out of 90 days.&quot; I want to display an alert.</p> <p>but if i use my code it doesn't work how can i fix it?</p> <pre><code> const pwChangeDate = cookie.get('pwChangeDate'); const pwDate = new Date(pwChangeDate) if (curTime.getDate() &gt;= pwDate.getDate() - 90) { alert('90 days have passed.') } if (curTime.getDate() &gt;= pwDate.getDate() - 7) { alert('7 days left out of 90 days..') } </code></pre>
[ { "answer_id": 74217562, "author": "Littlefoot", "author_id": 9097906, "author_profile": "https://Stackoverflow.com/users/9097906", "pm_score": 1, "selected": false, "text": "where" }, { "answer_id": 74218053, "author": "Jonas Metzler", "author_id": 18794826, "author_...
2022/10/27
[ "https://Stackoverflow.com/questions/74217524", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15322469/" ]
74,217,557
<p>From the documentation page of <a href="https://docs.python.org/3/library/decimal.html" rel="noreferrer">Decimal</a>, I thought that once we use decimal to compute, it'll be a correct result without any floating error.</p> <p>But when I try this equation</p> <pre><code>from decimal import Decimal, getcontext getcontext().prec = 250 a = Decimal('6') b = Decimal('500000') b = a ** b print('prec: ' + str(getcontext().prec) + ', ', end='') print(b.ln() / a.ln()) </code></pre> <p>It gives me different result!</p> <p><a href="https://i.stack.imgur.com/cPZDg.png" rel="noreferrer"><img src="https://i.stack.imgur.com/cPZDg.png" alt="enter image description here" /></a></p> <p>I want to calculate the digit of <code>6**500000</code> in base-6 representation, so my expect result would be <code>int(b.ln() / a.ln()) + 1</code>, which should be 500001. However, when I set the prec to 250, it gives me the wrong result. How can I solve this?</p> <p>Also, if I want to output the result without the scientific notation (i.e. <code>5E+5</code>), what should I do?</p>
[ { "answer_id": 74217632, "author": "dranjohn", "author_id": 9746972, "author_profile": "https://Stackoverflow.com/users/9746972", "pm_score": 1, "selected": false, "text": "Decimal.ln()" }, { "answer_id": 74217747, "author": "ti7", "author_id": 4541045, "author_profil...
2022/10/27
[ "https://Stackoverflow.com/questions/74217557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11628833/" ]
74,217,568
<p>I'm having a modal bottom sheet, in which contain some text field. I want the bottom sheet to close when click outside of the sheet but due to isScrollControlled property is true so i cant do that.</p> <p>But if i change it to false my bottom sheet will be covered by keyboard when i focus to my textfield on it. Is there any way to solve it.</p> <p>This is how i create my sheet</p> <pre><code>showModalBottomSheet&lt;dynamic&gt;( backgroundColor: Colors.transparent, isScrollControlled: true, isDismissible: true, shape: const RoundedRectangleBorder( borderRadius: BorderRadius.vertical( top: Radius.circular(12))), context: context, builder: (context) { return const BottomSheetView(); }); </code></pre> <p>here is how my sheet look <a href="https://i.stack.imgur.com/KdsLV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KdsLV.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74217632, "author": "dranjohn", "author_id": 9746972, "author_profile": "https://Stackoverflow.com/users/9746972", "pm_score": 1, "selected": false, "text": "Decimal.ln()" }, { "answer_id": 74217747, "author": "ti7", "author_id": 4541045, "author_profil...
2022/10/27
[ "https://Stackoverflow.com/questions/74217568", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19524396/" ]
74,217,588
<pre><code>1164570 1H45M 1421781 0 458245 7H 2714970 6H 2956491 0 89924 0 580685 3H 1330835 1H45M 599197 6H30M 541245 7H 2257962 0 1418006 1H15M 407282 5H30M 804217 7H30M 1221037 6H30M 1461747 0 148837 3H 168789 2H 2245125 5H 2079324 0 2014516 0 2272373 45M 470768 0 585334 2H45M 163046 2H30M (df.sample) </code></pre> <p>So I have hour and minute data in string format and need to transform it to datetime or to numeral format, (meaning 1h 30min to looking like 1,5 etc.)</p> <p>I tried to use pandas datetime library but as i expected, it doesn't understand this kind of string format.</p> <pre><code>diary_test['test'] = pd.to_datetime(diary_test['time'],format= '%H:%M' ).dt.time </code></pre>
[ { "answer_id": 74217628, "author": "jezrael", "author_id": 2901002, "author_profile": "https://Stackoverflow.com/users/2901002", "pm_score": 2, "selected": true, "text": "H" }, { "answer_id": 74217730, "author": "mozway", "author_id": 16343464, "author_profile": "http...
2022/10/27
[ "https://Stackoverflow.com/questions/74217588", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20339814/" ]
74,217,589
<p>I have the following case: A data table of shipments (dfSysTemp) with fields: AWB, Origin, Route, HubGW.</p> <p><a href="https://i.stack.imgur.com/dWspB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dWspB.png" alt="dfSysTemp" /></a></p> <p>A character vector of standard Hub 3-letter acronyms. <a href="https://i.stack.imgur.com/QgLHF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QgLHF.png" alt="Hubs" /></a></p> <p>The Route consists of multiple 3-letter entities separated by a hyphen (-). I need to update the HubGW field with the first Entity that exists in the list of Hubs as shown in the table.</p> <pre><code>What I have performed: I used 3 functions and a For loop with sapply as shown in the code. This succeeded in getting the expected HubGW but it took around 8 minutes of processing time on 1.2M shipment records. # Get list of standard Hubs from Access DB vHubs &lt;- sqlFetch(dbMaster,&quot;Hubs&quot;) %&gt;% as.data.frame() %&gt;% pull(Hub) # create the Hubs pattern HubsPattern=vHubs[1] for (h in 2:length(vHubs)){ HubsPattern=paste0(HubsPattern,&quot;|&quot;,vHubs[h]) } # Define a function to split the Route into Entities SplitRoute &lt;- function(route){ str_split(route,&quot;-&quot;)}` # Define a function that takes in the split Route and return the first # standard Hub in the Route FetchHub1 &lt;- function(z) {sapply(SplitRoute(z),grep,pattern=HubsPattern,value=TRUE) %&gt;% unlist() %&gt;% .[1]} # Apply the Fetch Hub1 function to the System Temp data to assign # the first hub for each shipment for (i in 1:dfSysTemp[,.N]){ dfSysTemp[i,`:=`(HubGW=FetchHub1(Route))] } I had to loop over all shipments using For loop since using sapply alone did not allocate the correct HubGW for the shipments. It rather allocated the first HubGW value it found to the entire list of shipments regardless of the Route. I believe there is a better way to do it using the ‘apply’ functions that can cut the processing time considerably. Any thoughts on this are highly appreciated. Thanks. </code></pre>
[ { "answer_id": 74217628, "author": "jezrael", "author_id": 2901002, "author_profile": "https://Stackoverflow.com/users/2901002", "pm_score": 2, "selected": true, "text": "H" }, { "answer_id": 74217730, "author": "mozway", "author_id": 16343464, "author_profile": "http...
2022/10/27
[ "https://Stackoverflow.com/questions/74217589", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20344867/" ]
74,217,615
<h2>Problem</h2> <p>Within the Xcode 14 IDE, I have been facing an annoying issue where the lines I am editing tint blue. I have disabled <code>Show Source Control changes</code> within Preferences, yet it does not remove it. I have attached an image to show you what it looks like. I really hope you can help as I am finding the blue tints everywhere in my code very distracting and annoying.</p> <p><a href="https://i.stack.imgur.com/27rBw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/27rBw.png" alt="Xcode 14: Lines where changes have been made tint blue" /></a></p> <p><em>Just ignore the code - it's just to show what happens when changes are made in the editor. </em></p>
[ { "answer_id": 74217628, "author": "jezrael", "author_id": 2901002, "author_profile": "https://Stackoverflow.com/users/2901002", "pm_score": 2, "selected": true, "text": "H" }, { "answer_id": 74217730, "author": "mozway", "author_id": 16343464, "author_profile": "http...
2022/10/27
[ "https://Stackoverflow.com/questions/74217615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18000388/" ]
74,217,631
<p>I haven an endpoint POST /api/marketplace/add that accepts a DTO object as request body. When I send the body below with <strong>platformName</strong> field set , server accepts request and processes it with no problem. But when I only try to change field <strong>platformName</strong> to null I get Http 404 error from server. I debugged the request and found out that it even can not reach controller method. I also got no trace from that error. What might be the cause that makes API respond differently to same request?</p> <p>below</p> <pre><code>{ &quot;platformName&quot;: &quot;Trendyol&quot;, &quot;commissionAmounts&quot;: [ { &quot;amount&quot;: 23.45, &quot;categoryInfos&quot;: [ { &quot;categoryName&quot;: &quot;Game&quot; } ], &quot;isCategoryBasedPricing&quot;: true } ], &quot;shipmentAmounts&quot;: [ { &quot;amount&quot;: 23.45, &quot;scaleInfo&quot;: { &quot;order&quot;: 0, &quot;lowerBound&quot;: 0, &quot;upperBound&quot;: 0 }, &quot;volumeInfo&quot;: { &quot;order&quot;: 0, &quot;lowerBound&quot;: 0, &quot;upperBound&quot;: 0 }, &quot;isVolumeBasedPricing&quot;: true }] } </code></pre> <p>EDIT: dto model is</p> <pre><code>@Generated public class MarketPlaceDTO { @JsonProperty(&quot;platformName&quot;) private String platformName; @JsonProperty(&quot;commissionAmounts&quot;) @Valid private List&lt;CommissionInfoDTO&gt; commissionAmounts = new ArrayList&lt;&gt;(); @JsonProperty(&quot;shipmentAmounts&quot;) @Valid private List&lt;ShipmentInfoDTO&gt; shipmentAmounts = new ArrayList&lt;&gt;(); </code></pre> <p>Controller is implementing swagger generated api interface. with postmapping and requestbody annotations.</p> <pre><code>@RequiredArgsConstructor @RestController public class MarketPlaceApiController implements MarketplaceApi { private final MarketPlaceDAOService marketPlaceDAOService; @Override public ResponseEntity&lt;BaseResponseDTO&gt; addMarketPlace(MarketPlaceDTO marketPlaceDTO) { BaseResponseDTO dto = marketPlaceDAOService.addMarketPlace(marketPlaceDTO); return ResponseEntity.ok(dto); } } </code></pre> <p>Swagger generated api interface</p> <pre><code> @RequestMapping( method = RequestMethod.POST, value = &quot;/marketplace/add&quot;, produces = { &quot;application/json&quot;, &quot;application/xml&quot; }, consumes = { &quot;application/json&quot; }) default ResponseEntity&lt;BaseResponseDTO&gt; _addMarketPlace( @Parameter(name = &quot;MarketPlaceDTO&quot;, description = &quot;Add new marketplace with given request body&quot;, required = true) @Valid @RequestBody MarketPlaceDTO marketPlaceDTO) { return addMarketPlace(marketPlaceDTO); } </code></pre> <p>Response is</p> <pre><code>{ &quot;timestamp&quot;: 1666866382906, &quot;status&quot;: 404, &quot;error&quot;: &quot;Not Found&quot;, &quot;path&quot;: &quot;/marketplace/add&quot; } </code></pre>
[ { "answer_id": 74217628, "author": "jezrael", "author_id": 2901002, "author_profile": "https://Stackoverflow.com/users/2901002", "pm_score": 2, "selected": true, "text": "H" }, { "answer_id": 74217730, "author": "mozway", "author_id": 16343464, "author_profile": "http...
2022/10/27
[ "https://Stackoverflow.com/questions/74217631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
74,217,643
<p>Below is a tuple:</p> <pre><code>import ast data = (('Jeff Celebration', '{&quot;2010-09-02&quot;: {&quot;Possibility&quot;: 3, &quot;Confidence&quot;:93}, &quot;2011-09-01&quot;: {&quot;Possibility&quot;: 3, &quot;Confidence&quot;:86}}'), (&quot;Queens Bday&quot;, '{&quot;2010-02-18&quot;: {&quot;Possibility&quot;: 2, &quot;Confidence&quot;:88}, &quot;2011-02-17&quot;: {&quot;Possibility&quot;: 2, &quot;Confidence&quot;:88}}')) </code></pre> <p>This is where I am :</p> <pre><code>data = {i[0]: {key:val.get('Possibility') for key, val in ast.literal_eval(i[1]).items()} for i in data} </code></pre> <p>How do I use the &quot;Possibility&quot; value to iterate and add to subscript of event name?</p> <p>Expected Output:</p> <pre><code>data = {'event': ['Jeff Celebration_1', 'Jeff Celebration_2', 'Jeff Celebration_3', 'Jeff Celebration_1', 'Jeff Celebration_2', 'Jeff Celebration_3', 'Queens Bday_1', 'Queens Bday_2', 'Queens Bday_1', 'Queens Bday_2'], 'keys': ['2010-09-02', '2010-09-03', '2010-09-04', '2011-09-01', '2011-09-02', '2011-09-03', '2010-02-18', '2010-02-19', '2011-02-17', '2011-02-18']} </code></pre> <p>EDIT: Each event need to be repeated 'Possibility' Time. So, Jeff Celebration has 3 entry in the output.</p>
[ { "answer_id": 74217628, "author": "jezrael", "author_id": 2901002, "author_profile": "https://Stackoverflow.com/users/2901002", "pm_score": 2, "selected": true, "text": "H" }, { "answer_id": 74217730, "author": "mozway", "author_id": 16343464, "author_profile": "http...
2022/10/27
[ "https://Stackoverflow.com/questions/74217643", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19741064/" ]
74,217,658
<p>I have a python visual code which is working when ran in power BI desktop. but when i published the same to power BI service and try to run, its throwing &quot;Modlue Not found&quot; error. What might be the reason and how to overcome this error.</p> <p>I'm importing below modules in my script</p> <pre><code>import pandas as pd import numpy as np import matplotlib.pyplot as plt import json import xml.etree.ElementTree as ET import os import glob import time from time import sleep import requests from itertools import product </code></pre> <p>I tried installing requests again but it says <a href="https://i.stack.imgur.com/LHIx8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LHIx8.png" alt="enter image description here" /></a></p> <p>but still it throwing ModuleNotFoundError: No module named 'requests' error</p>
[ { "answer_id": 74222496, "author": "David Browne - Microsoft", "author_id": 7297700, "author_profile": "https://Stackoverflow.com/users/7297700", "pm_score": 0, "selected": false, "text": "requests" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74217658", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
74,217,669
<p>I've given the automation account a system assigned managed identity. Successfully used these to set the context :</p> <pre><code>$AzureContext = (Connect-AzAccount -Identity).context $AzureContext = Set-AzContext -SubscriptionName $AzureContext.Subscription -DefaultProfile $AzureContext </code></pre> <p>But when I use this inside the runbook to get the jobs :</p> <pre><code>Get-AzAutomationJob -ResourceGroupName $resourceGroupName -AutomationAccountName $automationAccountName -RunbookName $runbookName -DefaultProfile $AzureContext </code></pre> <p>it returns nothing. No error, so command must execute, but doesn't return any results. What I noticed is that the context which returns when connecting with the managed identity, doesn't have values for Name and Subscription. It only has values for Account, Environment and Tenant. Could this be the problem?</p>
[ { "answer_id": 74222496, "author": "David Browne - Microsoft", "author_id": 7297700, "author_profile": "https://Stackoverflow.com/users/7297700", "pm_score": 0, "selected": false, "text": "requests" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74217669", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12503786/" ]
74,217,671
<p>I have a yaml pipeline in azure containing this:</p> <pre><code>pool: vmImage: windows-latest demands: - msbuild - visualstudio </code></pre> <p>When it runs, I get the following output under Jobs/Build</p> <blockquote> <p>Pool: Hosted Windows 2019 with VS2019</p> </blockquote> <p>And then later when it tries to build my .net6 solution I get this error</p> <blockquote> <p>Version 6.0.402 of the .NET SDK requires at least version 17.0.0 of MSBuild. The current available version of MSBuild is 16.11.2.50704. Change the .NET SDK specified in global.json to an older version that requires the MSBuild version currently available.</p> </blockquote> <p>The documentation assures me that windows-latest should have Windows2022 with VS2022 (with MSBuild 17). What am I doing wrong?</p>
[ { "answer_id": 74222496, "author": "David Browne - Microsoft", "author_id": 7297700, "author_profile": "https://Stackoverflow.com/users/7297700", "pm_score": 0, "selected": false, "text": "requests" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74217671", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5256279/" ]
74,217,674
<p>in the bellow query I am receiving the date as '2022-09-06T18:30:00.000Z' I want it as YYYY_MM_DD</p> <pre><code> let sql_of_prime = ` ((SELECT id , collection_date, collection_type FROM bank_book WHERE ledger_num = 'vr15' ) UNION ALL (SELECT id , collection_date, collection_type FROM cash_book WHERE ledger_num = 'vr15' )) ORDER BY collection_date ASC ;` </code></pre> <p>soo that's why i used <code>DATE_FORMAT</code> and now its not working</p> <pre><code> let sql_of_prime = ` ((SELECT id , DATE_FORMAT(collection_date, &quot;%Y-%m-%d&quot;) , collection_type FROM bank_book WHERE ledger_num = 'vr15' ) UNION ALL (SELECT id , DATE_FORMAT(collection_date, &quot;%Y-%m-%d&quot;) , collection_type FROM cash_book WHERE ledger_num = 'vr15' )) ORDER BY collection_date ASC ;` </code></pre> <p>the first query is working but the below one is not I have no idea why can any one suggest a solution</p> <p>console log</p> <pre><code>Error: ER_BAD_FIELD_ERROR: Unknown column 'collection_date' in 'order clause' sqlMessage: &quot;Unknown column 'collection_date' in 'order clause'&quot;, ``` </code></pre>
[ { "answer_id": 74217774, "author": "Tim Biegeleisen", "author_id": 1863229, "author_profile": "https://Stackoverflow.com/users/1863229", "pm_score": 2, "selected": false, "text": "collection_date" }, { "answer_id": 74218471, "author": "Akina", "author_id": 10138734, "...
2022/10/27
[ "https://Stackoverflow.com/questions/74217674", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16928810/" ]
74,217,678
<p>I'm currently developing a node js cli tool to do some random stuff for work. Up until this point, my whole app was designed as a cli without any intention to use its functionality somewhere else.</p> <p>Now some of my collegues like to work with a ui instead of a cli so I decited to build a vue web app around it. SO far so good.</p> <p>Now my problem: I plastered all of my functions with console.logs and packages like cliui, chalk, inquirer, etc. This obviously makes no sense when used as a module in a vue app.</p> <p><strong>My question is: How do I log output from individual functions only when used via cli?</strong></p> <p>One idea I have is to set some kind of falgg in my command function so the process knows I'm in a terminal and check for every console.log if that flag is set. But that seems to be a lot of work and I wonder if there is a better way.</p>
[ { "answer_id": 74217880, "author": "IneptusMechanicus", "author_id": 5257994, "author_profile": "https://Stackoverflow.com/users/5257994", "pm_score": 0, "selected": false, "text": "isCLI" }, { "answer_id": 74217987, "author": "Guy Hagemans", "author_id": 3992665, "au...
2022/10/27
[ "https://Stackoverflow.com/questions/74217678", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7510117/" ]
74,217,694
<p>I try to set Symfony (version 5.4.14 / PHP 7.4 / Wamp) Remember me functionnality. I configured well strictly as indicated in the doc (badge in authenticator etc.).</p> <p>The cookie is created but when I close my browser (Chrome or Firefox, both tested) the cookie is deleted. I tried to set a value (3600) for session.cookie_lifetime in php.ini (and of course restart Wamp) but the problem persists. Any idea?</p> <p>security.yaml:</p> <pre><code>remember_me: secret: '%kernel.secret%' # required lifetime: 604800 # 1 week in seconds # by default, the feature is enabled by checking a # checkbox in the login form (see below), uncomment the # following line to always enable it. always_remember_me: true </code></pre> <p>Authenticator class:</p> <pre><code>&lt;?php namespace App\Security; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Security; use Symfony\Component\Security\Http\Authenticator\AbstractLoginFormAuthenticator; use Symfony\Component\Security\Http\Authenticator\Passport\Badge\CsrfTokenBadge; use Symfony\Component\Security\Http\Authenticator\Passport\Badge\RememberMeBadge; use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge; use Symfony\Component\Security\Http\Authenticator\Passport\Credentials\PasswordCredentials; use Symfony\Component\Security\Http\Authenticator\Passport\Passport; use Symfony\Component\Security\Http\Util\TargetPathTrait; class AppParticipantAuthenticator extends AbstractLoginFormAuthenticator { use TargetPathTrait; public const LOGIN_ROUTE = 'app_login'; private UrlGeneratorInterface $urlGenerator; public function __construct(UrlGeneratorInterface $urlGenerator) { $this-&gt;urlGenerator = $urlGenerator; } public function authenticate(Request $request): Passport { $email = $request-&gt;request-&gt;get('email', ''); $request-&gt;getSession()-&gt;set(Security::LAST_USERNAME, $email); return new Passport( new UserBadge($email), new PasswordCredentials($request-&gt;request-&gt;get('password', '')), [ new RememberMeBadge(), new CsrfTokenBadge('authenticate', $request-&gt;request-&gt;get('_csrf_token')), ] ); } public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $firewallName): ?Response { if ($targetPath = $this-&gt;getTargetPath($request-&gt;getSession(), $firewallName)) { return new RedirectResponse($targetPath); } // For example: return new RedirectResponse($this-&gt;urlGenerator-&gt;generate('app_sortie_index')); // throw new \Exception('TODO: provide a valid redirect inside '.__FILE__); } protected function getLoginUrl(Request $request): string { return $this-&gt;urlGenerator-&gt;generate(self::LOGIN_ROUTE); } public function supports(Request $request) : bool { return self::LOGIN_ROUTE === $request-&gt;attributes-&gt;get('_route') &amp;&amp; $request-&gt;isMethod('POST'); } } </code></pre>
[ { "answer_id": 74217880, "author": "IneptusMechanicus", "author_id": 5257994, "author_profile": "https://Stackoverflow.com/users/5257994", "pm_score": 0, "selected": false, "text": "isCLI" }, { "answer_id": 74217987, "author": "Guy Hagemans", "author_id": 3992665, "au...
2022/10/27
[ "https://Stackoverflow.com/questions/74217694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3049922/" ]
74,217,721
<p>I need to fill a field &quot;description&quot; from other field in a screen Acumatica. The problem is that one of the other field contains the identifier of the DAC but I have to retrieve the description and not the identifier.</p> <p>I tried to do this with a Fluent BQL query in an Event Handler in order to retrieve the single result. var Feurname = PXSelect&lt;BAccount, Where&lt;BAccount.bAccountID, Equal&lt;Current&lt;APInvoice.vendorID&gt;&gt;&gt;&gt;.Select(this, <strong>BAccount.acctName</strong>).First().GetItem();</p> <p>I have the following error when I test the code : \App_RuntimeCode\APInvoiceEntry.cs(97): error CS0119: 'BAccount.acctName' is a type, which is not valid in the given context</p> <p>\App_RuntimeCode\APInvoiceEntry.cs(97): error CS0120: An object reference is required for the non-static field, method, or property 'PXSelectBase.Select(params object[])'</p> <p>Thanks for your help!</p>
[ { "answer_id": 74225042, "author": "Samvel Petrosov", "author_id": 6064728, "author_profile": "https://Stackoverflow.com/users/6064728", "pm_score": 1, "selected": false, "text": "BAccount account = PXSelect<BAccount, Where<BAccount.bAccountID, Equal<Current<APInvoice.vendorID>>>>.Select...
2022/10/27
[ "https://Stackoverflow.com/questions/74217721", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20345699/" ]
74,217,784
<p>Function Name: avg_capacity Parameter: product_list - A list containing a sequence of product descriptions as strings.</p> <p>Return: A floating point number that denotes the average of capacities as given in the list.</p> <p>Description: Given a list of product descriptions where each element in the list is of the format 'product_id-capacity', calculate the average of all capacities and return the value.</p> <p>Let us assume that you are the owner of a store that sells different masks. These masks come in shipments of boxes of a particular capacity. Each box of mask has a unique product ID (no two IDs are the same), and a capacity associated with the box. You want to find all the different capacities of the boxes, and calculate the <strong>average</strong> of these capacities.</p> <p>Ex)</p> <p>product_list = ['A1-10', 'B10-40', 'C403-50', 'D5-10'] return: 27.5</p> <pre><code>def avg_capacity(product_list): for capacity in range(len(product_list)): product_list[capacity] = product_list.split(&quot;-&quot;) average = capacity[&quot;-&quot;:] return average print(avg_capacity(['C12-100', 'A10-400'])) </code></pre> <p>I honestly have no idea how to approach this. I was told to use string methods, so I attempted to use split in order to split the product ID at every instance of a dash. However, I don't know how to manipulate the lists in order to take the numbers on the right side of the dash, and put them code that would take the average of every product ID in product list. Any help is appreciated :D</p>
[ { "answer_id": 74217989, "author": "Omer Dagry", "author_id": 15010874, "author_profile": "https://Stackoverflow.com/users/15010874", "pm_score": 0, "selected": false, "text": "def avg_capacity(product_list):\n capacity_list = []\n for capacity in product_list:\n capacity_li...
2022/10/27
[ "https://Stackoverflow.com/questions/74217784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19753255/" ]
74,217,785
<p>How to declare a currying sum function type in typescript? I need a <code>sum</code> function , it can sum numbers by currying like this</p> <pre><code>console.log(sum(100, 200)(300)()); // 600 console.log(sum(100, 200)()); // 300 console.log(sum()); // 0 </code></pre> <p>I can implementation with javascript but I don't konw how declare type in typescript</p> <pre class="lang-js prettyprint-override"><code>const sum = function sum(...allNumbers: any[]):any { if (allNumbers.length === 0) return 0; const sumValue = (numbers: number[]) =&gt; numbers.reduce((sum, num) =&gt; (sum += num), 0); return function memoFunc(...nums: any[]): any { allNumbers = allNumbers.concat(nums); if (nums.length === 0) { return sumValue(allNumbers); } return memoFunc; }; } console.log(sum(100, 200)(300)()); // 600 console.log(sum(100, 200)()); // 300 console.log(sum()); // 0 </code></pre> <p>This is my code, I dont kown how to declare the type , so I use <code>any</code> to replace. How can I delare it?</p>
[ { "answer_id": 74218236, "author": "Dimava", "author_id": 5734961, "author_profile": "https://Stackoverflow.com/users/5734961", "pm_score": 2, "selected": false, "text": "// It's easier to use a `type` as it's recursive\ntype ChainedAdd = ((...numbers: number[]) => ChainedAdd) & (() => n...
2022/10/27
[ "https://Stackoverflow.com/questions/74217785", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5565913/" ]
74,217,790
<p>I'm trying to click on VR simulation mode in the browser (Will also be used on mobile), and show a yellow ray from the camera (my eyes/center of window) to the mouse cursor, but I can't get the right direction/position.</p> <pre class="lang-js prettyprint-override"><code>public function onMouseDown(e:Event): Void { // The camera in VR was created automatically by the threejs engine. var camera:WebXRArrayCamera = renderer.xr.getCamera(); // x and y will get a value from (-1 to +1) // I have no clear with z must be in -0.5 and not another value. var x:Float = (event.clientX / canvas.parentElement.offsetWidth ) * 2 - 1; var y:Float = -(event.clientY / canvas.parentElement.offsetHeight) * 2 + 1; var z:Float = -0.5; var mouse:Vector3 = new Vector3(x, y, z); var origin:Vector3 = new Vector3(); origin.copy(camera.position); var direction:Vector3 = new Vector3(); direction.copy(mouse); var arrow:ArrowHelper = new ArrowHelper(direction, origin, 5, 0xffff00); scene.add(arrow); } </code></pre> <p>If I click in the center of window, it's more or less correct, but if I move my cursor mouse, for example, to the right, the result is wrong as you can see in the screenshoot <a href="https://ibb.co/TBnNtnb" rel="nofollow noreferrer">https://ibb.co/TBnNtnb</a></p> <p><a href="https://jsfiddle.net/0t2yczh7/" rel="nofollow noreferrer">https://jsfiddle.net/0t2yczh7/</a></p> <p>The yellow arrow shuld be exactly centered under my mouse cursor and it is not. If I go more to the right the offset is bigger.</p> <p>What I am doing wrong?</p> <p>By other hand, the unit of measure in my world is the meter, so the values for x and y (-1 to +1) I'm not sure if is wrong. How I can translate pixels (canvas.parentElement.offsetWidth) to meters?? For example, something like 1920x1080 to 7.55x4.25, depending of the Fov.</p>
[ { "answer_id": 74218236, "author": "Dimava", "author_id": 5734961, "author_profile": "https://Stackoverflow.com/users/5734961", "pm_score": 2, "selected": false, "text": "// It's easier to use a `type` as it's recursive\ntype ChainedAdd = ((...numbers: number[]) => ChainedAdd) & (() => n...
2022/10/27
[ "https://Stackoverflow.com/questions/74217790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9184010/" ]
74,217,803
<p>I am making an API call with URLSession and I am getting the error like: <strong>The data couldn’t be read because it isn’t in the correct format</strong> I don't know why it is happeing. Even I am able to print the response in string format but not getting parsed.</p> <pre><code>API calling method func getDashboardCountReq() { guard let url = URL(string: urlString) else { return } var request = URLRequest(url: url) request.httpMethod = &quot;GET&quot; request.addValue(&quot;application/json&quot;, forHTTPHeaderField: &quot;content-type&quot;) let userDetails = UserInfo.shared.getCurrentUserDetails() if let authToken = userDetails?.authToken { let headers = [&quot;Content-Type&quot;: &quot;application/json&quot;, &quot;Authorization&quot;: &quot;Bearer &quot; + authToken] request.allHTTPHeaderFields = headers } URLSession.shared.dataTask(with: request) { (data,response,error) in do { if let data = data { let responseString = String(data: data, encoding: String.Encoding(rawValue: String.Encoding.utf8.rawValue)) print(&quot;responseString \(responseString)&quot;) do { let f = try JSONDecoder().decode([DashboardResponseData].self, from: data) print(f.count) } catch { print(&quot;1232 \(error.localizedDescription)&quot;) } } else { print(&quot;LoginViewModel-&gt; no data found&quot;) } } catch(let error) { print(&quot;Error A123 \(error.localizedDescription)&quot;) } }.resume() } </code></pre> <p>// Model</p> <pre><code>struct DashboardResponseData: Codable, Identifiable { let id = UUID() var approvedrc: String var pendingpo: String? var assets: String? var approvedprs: String? var pendingrc: String? var approvedpo: String? var pendingprs: String? var tickets: String? enum CodingKeys: String, CodingKey { case approvedrc = &quot;approvedrc&quot; case pendingpo = &quot;pendingpo&quot; case approvedprs = &quot;approvedprs&quot; case pendingrc = &quot;pendingrc&quot; case approvedpo = &quot;approvedpo&quot; case pendingprs = &quot;pendingprs&quot; case tickets = &quot;tickets&quot; } } </code></pre> <p>String Response</p> <pre><code>[{\&quot;approvedrc\&quot;:41,\&quot;pendingpo\&quot;:566,\&quot;assets\&quot;:37956,\&quot;approvedprs\&quot;:1040,\&quot;pendingrc\&quot;:8,\&quot;approvedpo\&quot;:1650,\&quot;pendingprs\&quot;:1709,\&quot;tickets\&quot;:137872}] </code></pre> <p>// Log</p> <p><a href="https://i.stack.imgur.com/1vcig.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1vcig.jpg" alt="enter image description here" /></a></p>
[ { "answer_id": 74218236, "author": "Dimava", "author_id": 5734961, "author_profile": "https://Stackoverflow.com/users/5734961", "pm_score": 2, "selected": false, "text": "// It's easier to use a `type` as it's recursive\ntype ChainedAdd = ((...numbers: number[]) => ChainedAdd) & (() => n...
2022/10/27
[ "https://Stackoverflow.com/questions/74217803", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10469417/" ]
74,217,805
<p>I have a function which return the view with multiple variable. The code is</p> <p><strong>HomeController.php</strong></p> <pre><code>public function profilePage(){ $data = User::all(); $book = Library::all(); return view('page.profile' , compact(array('data', 'book'))); } </code></pre> <p><strong>profile.blade.php</strong></p> <pre><code>@include('layouts.sidebar') . . . @foreach($book as $Library) &lt;tr&gt; &lt;td&gt;{{$Library-&gt;book}}&lt;/td&gt; &lt;td&gt;{{$Library-&gt;name}}&lt;/td&gt; &lt;td&gt;{{$Library-&gt;author}}&lt;/td&gt; &lt;td&gt;{{$Library-&gt;price}}&lt;/td&gt; &lt;/tr&gt; @endforeach </code></pre> <p><strong>sidebar.blade.php</strong></p> <pre><code>&lt;div class=&quot;info&quot;&gt; &lt;a href=&quot;{{ url ('profile' , $data -&gt; first())}}&quot; class=&quot;d-block&quot;&gt;{{Auth::user() -&gt; name }}&lt;/a&gt; &lt;/div&gt; </code></pre> <p>When i try to refresh the browser to see the changes. It'll show error &quot;undefined variable $book&quot;</p> <blockquote> <p>Illuminate\ Foundation\ Bootstrap \ HandleExceptions: 176 handleError</p> </blockquote> <p>on line</p> <blockquote> addLoop($currentLoopData); foreach($currentLoopData as $Library): $env->incrementLoopIndices(); $loop = $env->getLastLoop(); ?> </blockquote> <p>Before i added the module to retrieve the data from <strong>Library</strong>, the code just work fine. So is this the correct approach to pass multiple variable into view?</p>
[ { "answer_id": 74218236, "author": "Dimava", "author_id": 5734961, "author_profile": "https://Stackoverflow.com/users/5734961", "pm_score": 2, "selected": false, "text": "// It's easier to use a `type` as it's recursive\ntype ChainedAdd = ((...numbers: number[]) => ChainedAdd) & (() => n...
2022/10/27
[ "https://Stackoverflow.com/questions/74217805", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17683245/" ]
74,217,809
<p>I know there have been posts about this issue before but reading them I am still unable to find a solution. The weird part about this is my app has been working fine for weeks and then I reset my server and I keep getting this error.</p> <p>I am using Waitress to serve an app that deals with webhooks.</p> <pre><code>@app.route(f'/outbound', methods=[&quot;POST&quot;]) def outbound(): data = request.json.get('data') to_ = data.get('payload').get('to') </code></pre> <p>The issue is in the line <code>to_ = data.get('payload').get('to')</code></p> <p>This exact code has been processing my webhooks for weeks, I can't understand why it just now started throwing this error.</p>
[ { "answer_id": 74218236, "author": "Dimava", "author_id": 5734961, "author_profile": "https://Stackoverflow.com/users/5734961", "pm_score": 2, "selected": false, "text": "// It's easier to use a `type` as it's recursive\ntype ChainedAdd = ((...numbers: number[]) => ChainedAdd) & (() => n...
2022/10/27
[ "https://Stackoverflow.com/questions/74217809", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19424032/" ]
74,217,901
<p>I have the following pipeline step which run a Regex</p> <pre><code>- TICKET_NAME=&quot;$(echo $BRANCH_NAME | sed -E 's~^(.*/){0,1}((ABV|ASD|WSX)-[0-9]{2,6})-.*~\2~I')&quot; </code></pre> <p>Basically, the <code>$BRANCH_NAME</code> can be the following</p> <pre><code>fix/ABV-123-test-version ABV-4233-test-another-thing feature/-ASD-my-feature </code></pre> <p>What I would like is, to always retrieve the ticket number which is always starting with <code>ABV|ASD|WSX</code> and always end after the number.</p> <p>so <code>ABS-123</code> or <code>ASD-3423</code> the number can be any number but it will always be the same pattern.</p> <p>my current regex works, but it also capute the prefix so <code>fix/ABV-123</code></p> <p>I would like only the <code>ABV-123</code></p>
[ { "answer_id": 74218236, "author": "Dimava", "author_id": 5734961, "author_profile": "https://Stackoverflow.com/users/5734961", "pm_score": 2, "selected": false, "text": "// It's easier to use a `type` as it's recursive\ntype ChainedAdd = ((...numbers: number[]) => ChainedAdd) & (() => n...
2022/10/27
[ "https://Stackoverflow.com/questions/74217901", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4618275/" ]
74,217,910
<p>I have such code:</p> <pre><code>for i in range(0,5): try: print(f&quot;opened some_file_{i}&quot;) except Exception as e: print(f&quot;error opening some_file_{i}&quot;) return print(f&quot;i = {i}&quot;) </code></pre> <p>After exception, I need contuinue the loop from the next iteration, but not continue code <code>(print(f&quot;i = {i}&quot;)</code></p> <p>How can I do it?</p> <p>I tried to use a break, continue, pass statements and return</p>
[ { "answer_id": 74218236, "author": "Dimava", "author_id": 5734961, "author_profile": "https://Stackoverflow.com/users/5734961", "pm_score": 2, "selected": false, "text": "// It's easier to use a `type` as it's recursive\ntype ChainedAdd = ((...numbers: number[]) => ChainedAdd) & (() => n...
2022/10/27
[ "https://Stackoverflow.com/questions/74217910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18142290/" ]
74,217,920
<p>I am creating a reaction time game based on f1 theme , the issue I am facing is that when I resize the window my signal lights also gets resized to oval I want to keep then steady and don't want it to resize you can find the relevant image below :- <a href="https://i.stack.imgur.com/lF51z.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lF51z.png" alt="enter image description here" /></a></p> <p>after resizing- <a href="https://i.stack.imgur.com/mFhnR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mFhnR.png" alt="enter image description here" /></a></p> <p>how can this be further solved?</p>
[ { "answer_id": 74218236, "author": "Dimava", "author_id": 5734961, "author_profile": "https://Stackoverflow.com/users/5734961", "pm_score": 2, "selected": false, "text": "// It's easier to use a `type` as it's recursive\ntype ChainedAdd = ((...numbers: number[]) => ChainedAdd) & (() => n...
2022/10/27
[ "https://Stackoverflow.com/questions/74217920", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16116202/" ]
74,217,954
<p>I made up a dataframe to explain my question, my real dataset is much bigger.</p> <pre><code>gene &lt;- c(&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;a&quot;, &quot;b&quot;, &quot;c&quot;) sample &lt;- c(&quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;b&quot;, &quot;b&quot;, &quot;b&quot;, &quot;c&quot;, &quot;c&quot;, &quot;c&quot;) expression &lt;- c(&quot;5&quot;, &quot;6&quot;, &quot;8&quot;, &quot;3&quot;, &quot;5&quot;, &quot;7&quot;, &quot;7&quot;, &quot;8&quot;, &quot;9&quot;) data.frame(gene, sample, expression) gene sample expression 1 a a 5 2 b a 6 3 c a 8 4 a b 3 5 b b 5 6 c b 7 7 a c 7 8 b c 8 9 c c 9 </code></pre> <p>and</p> <pre><code>gene2 &lt;- c(&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;a&quot;, &quot;b&quot;, &quot;c&quot;) sample2 &lt;- c(&quot;1&quot;, &quot;1&quot;, &quot;1&quot;, &quot;2&quot;, &quot;2&quot;, &quot;2&quot;, &quot;3&quot;, &quot;3&quot;, &quot;3&quot;) expression2 &lt;- c(&quot;5.4&quot;, &quot;6.3&quot;, &quot;8&quot;, &quot;3.2&quot;, &quot;5.4&quot;, &quot;7.2&quot;, &quot;7.1&quot;, &quot;8.2&quot;, &quot;9.4&quot;) data.frame(gene2, sample2, expression2) gene2 sample2 expression2 1 a 1 5.4 2 b 1 6.3 3 c 1 8 4 a 2 3.2 5 b 2 5.4 6 c 2 7.2 7 a 3 7.1 8 b 3 8.2 9 c 3 9.4 </code></pre> <p>So I have 2 different dataframes with different sample identifiers. But the expression data (should) be kind of the same. What I want to do is find per sample the closest matching expression values and report back the corresponding sample identifiers. so it could look something like this:</p> <pre><code> gene sample sample2 expression expression2 1 a a 1 5 5.4 2 b a 1 6 6.3 3 c a 1 8 8 4 a b 2 3 3.2 5 b b 2 5 5.4 6 c b 2 7 7.2 7 a c 3 7 7.1 8 b c 3 8 8.2 9 c c 3 9 9.4 </code></pre> <p>I would think maybe a <code>roll join</code> but im kind of lost on this</p>
[ { "answer_id": 74218678, "author": "Maël", "author_id": 13460602, "author_profile": "https://Stackoverflow.com/users/13460602", "pm_score": 2, "selected": true, "text": "data.table" }, { "answer_id": 74218843, "author": "det", "author_id": 12148402, "author_profile": ...
2022/10/27
[ "https://Stackoverflow.com/questions/74217954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19254600/" ]
74,217,957
<p>I am running a script that stores the collected data in csv. It's working like that:</p> <pre><code>$responce = Excel::store(new UsersExport($formatted_data), 'fileName.csv', null, \Maatwebsite\Excel\Excel::CSV); </code></pre> <p>And that's my class:</p> <pre><code>class UsersExport implements FromArray { protected $invoices; public function __construct(array $invoices) { $this-&gt;invoices = $invoices; } public function array(): array { return $this-&gt;invoices; } } </code></pre> <p>So far the filename is hardcoded and I want to make it dynamic. It should be changed with the year and the month every time I run new export (2020-01.csv or something like that) The script is running with two parameters - year and month.</p> <pre><code>protected $signature = 'select:values {--year=} {--month=}'; </code></pre> <p>In the where clause I am filtering like that:</p> <pre><code>-&gt;whereMonth('ut', $this-&gt;option('month')) -&gt;whereYear('ut', $this-&gt;option('year')) </code></pre> <p>Tried with</p> <pre><code>Excel::store(new UsersExport($formatted_data)-&gt;withFilename() </code></pre> <p>But it does not work...I have not found something similar to my solution so far. Any ideas on how to fix that? Thanks!</p>
[ { "answer_id": 74218678, "author": "Maël", "author_id": 13460602, "author_profile": "https://Stackoverflow.com/users/13460602", "pm_score": 2, "selected": true, "text": "data.table" }, { "answer_id": 74218843, "author": "det", "author_id": 12148402, "author_profile": ...
2022/10/27
[ "https://Stackoverflow.com/questions/74217957", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16390253/" ]
74,217,961
<p>I have a table which has ID, FAMILY, ENV_XML_PATH and CREATED_DATE columns. <a href="https://i.stack.imgur.com/WzBm0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WzBm0.png" alt="TABLE IMAGE" /></a></p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>ID</th> <th>FAMILY</th> <th>ENV_XML_PATH</th> <th>CREATED_DATE</th> </tr> </thead> <tbody> <tr> <td>15826841</td> <td>CRM</td> <td>path1.xml</td> <td>03-09-22 6:50:34AM</td> </tr> <tr> <td>15826856</td> <td>SCM</td> <td>path3.xml</td> <td>03-10-22 7:12:20AM</td> </tr> <tr> <td>15826786</td> <td>IC</td> <td>path4.xml</td> <td>02-10-22 12:50:52AM</td> </tr> <tr> <td>15825965</td> <td>CRM</td> <td>path5.xml</td> <td>02-10-22 1:50:52AM</td> </tr> <tr> <td>15653951</td> <td>null</td> <td>path6.xml</td> <td>04-10-22 12:50:52AM</td> </tr> <tr> <td>15826840</td> <td>FIN</td> <td>path7.xml</td> <td>03-10-22 2:34:09AM</td> </tr> <tr> <td>15826841</td> <td>SCM</td> <td>path8.xml</td> <td>02-10-22 8:40:52AM</td> </tr> <tr> <td>15223450</td> <td>IC</td> <td>path9.xml</td> <td>03-09-22 5:34:09AM</td> </tr> <tr> <td>15026853</td> <td>SCM</td> <td>path10.xml</td> <td>05-10-22 4:40:59AM</td> </tr> </tbody> </table> </div> <p>Now there are 18 DISTINCT values in FAMILY column and each value has multiple rows associated (as you can see from the above image). What I want is to get the first row of 3 specific values (CRM, SCM and IC) in FAMILY column.</p> <p>Something like this:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>ID</th> <th>FAMILY</th> <th>ENV_XML_PATH</th> <th>CREATED_DATE</th> </tr> </thead> <tbody> <tr> <td>15826841</td> <td>CRM</td> <td>path1.xml</td> <td>date1</td> </tr> <tr> <td>15826856</td> <td>SCM</td> <td>path3.xml</td> <td>date2</td> </tr> <tr> <td>15826786</td> <td>IC</td> <td>path4.xml</td> <td>date3</td> </tr> </tbody> </table> </div> <p>I am new to this, though I understand the logic but I am not sure how to implement it. Kindly help. Thanks.</p>
[ { "answer_id": 74218678, "author": "Maël", "author_id": 13460602, "author_profile": "https://Stackoverflow.com/users/13460602", "pm_score": 2, "selected": true, "text": "data.table" }, { "answer_id": 74218843, "author": "det", "author_id": 12148402, "author_profile": ...
2022/10/27
[ "https://Stackoverflow.com/questions/74217961", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9235448/" ]
74,217,995
<p>Here simply I am fetching data from mysql DB and storing it in state and in order to fetch this data:</p> <pre><code>const [orders, setOrders] = useState([]); </code></pre> <p>To fetch data I am using different functions and finally I am calling those functions using useEffect simple enough and so for everything is working perfectly but the problem comes whenever I use the state as dependency where I am storing data beacause if I dont do that then I have to manually refresh the page for latest changes and I have tried every given solution on stackoverflow but any of the solution didnt work so someone can please help me how can I use this state as dependencey without causing infinite loop:</p> <pre><code>const [orders, setOrders] = useState([]); const loadData = async () =&gt; { const response = await fetch(&quot;http://localhost/k-shop/load.php&quot;); const result = await response.json(); setOrders(result); }; const loadTotal = async () =&gt; { const response = await fetch(&quot;http://localhost/k-shop/amount.php&quot;); const result = await response.json(); setTotal(result); }; useEffect(() =&gt; { loadData(); loadTotal(); }, [orders]); console.log(orders); </code></pre>
[ { "answer_id": 74218678, "author": "Maël", "author_id": 13460602, "author_profile": "https://Stackoverflow.com/users/13460602", "pm_score": 2, "selected": true, "text": "data.table" }, { "answer_id": 74218843, "author": "det", "author_id": 12148402, "author_profile": ...
2022/10/27
[ "https://Stackoverflow.com/questions/74217995", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16291854/" ]
74,218,060
<p>Hello i am new to regex , i needed to apply a regex to a string of us zip codes , which we got from concatenating rows of pandas columns</p> <p>for example zip being header of the column</p> <pre><code>zip you have some thing 70456 90876 78905 </code></pre> <p>we get the string<code> zip you have some thing 70456 90876 78905</code> as single literal string which should be matched by the regex that has some characters followed by one or more 5 digits separated by empty space so i wrote a simple regex of <code>'.*zip.*(\d{5}|\s)*'</code> a zip followed by any number of 5 digit characters but it gives a match(re.fullmatch) <strong>zip 123456</strong> a zip which is followed by a 6 digit code</p> <p>for that reason i thought of using look ahead assertion in regex, but i am not able to know how to use it exactly it not giving any matches , i used look behind with re.search also but it also seems to fail , can some one give a regex having word zip and also only a 5 digit characters at the end may be a nan</p> <p>here are the codes i have written</p> <p><code> re.match('(?=zip)(\d{5}|\s)*','zip 123456')</code></p> <pre><code>&lt;re.Match object; span=(0, 0), match=''&gt; </code></pre> <p><code> re.search('(?&lt;=zip)(\d{5}|\s)*','zip 123456')</code></p> <pre><code>&lt;re.Match object; span=(3, 9), match=' 12345'&gt; </code></pre> <p>can some one tell me how to write a regex for <strong>if</strong> .<em>zip.</em> follwed by digits having only 5 digits give a <em>match</em> <strong>else</strong> <em>None</em></p> <p><code>re.match('(?=zip)(\d{5}|\s)*','zip 123456')</code> <code>re.search('(?&lt;=zip)(\d{5}|\s)*','zip 123456')</code></p> <p>those are the codes i have tried i need a regex having any alphanumeric charcters that contain zip followed by a 5 digit numeric code</p>
[ { "answer_id": 74218678, "author": "Maël", "author_id": 13460602, "author_profile": "https://Stackoverflow.com/users/13460602", "pm_score": 2, "selected": true, "text": "data.table" }, { "answer_id": 74218843, "author": "det", "author_id": 12148402, "author_profile": ...
2022/10/27
[ "https://Stackoverflow.com/questions/74218060", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19154441/" ]
74,218,100
<pre><code>#Print the user board s = '' for i in range(n): for j in range(n): z = i * n + j s += ' ' if z &lt; 10: s += ' ' s += str(z) s += '\n' print(dedent(s)) queens = list(map(int, input(&quot;Queens: &quot;).split())) </code></pre> <p>I keep getting an error from my testcase environment of a last blank line before proceeding to the queens input below. What can I approach to fix</p> <p>I have tried cleandoc from textwrap and while it works, it disrupts every required spacing and new distinctive lines for z from the &quot;s&quot; string which is a perfect 8 by 8 from 0 to 63.</p>
[ { "answer_id": 74218678, "author": "Maël", "author_id": 13460602, "author_profile": "https://Stackoverflow.com/users/13460602", "pm_score": 2, "selected": true, "text": "data.table" }, { "answer_id": 74218843, "author": "det", "author_id": 12148402, "author_profile": ...
2022/10/27
[ "https://Stackoverflow.com/questions/74218100", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17990967/" ]
74,218,120
<p>I have a makefile that I've changed up a bit here to look more generalized</p> <pre><code>.PHONY: bash hash.sh all: .PHONY lab tests.zip lab: .PHONY lab.cpp g++ -o lab lab.cpp -g -Wall -std=c++11 tests.zip: curl -L -O https://url/tests.zip unzip tests.zip tests: .PHONY lab tests.zip bash scripts/test.bash lab.cpp clean: rm -rf scripts tests bitset-tests.zip </code></pre> <p>I am a TA for an entry level computer science course at my university, and I've created a makefile here for my students to use to compile and test their code seamlessly.</p> <p>One thing I want to do though is to have the makefile update itself every time the remote repository has a new version of it. I know I could just have them update the file themselves, but my job is to make the students focus less on setting things up and more on just coding for now, since it's entry level. So for the purposes of this, I'm sticking with the idea I have.</p> <p>Currently, I'm achieving this with a script <code>hash.sh</code> which fetches a hash of the makefile from the repo, and compares it to a hash of the makefile in the student's directory. If the hashes don't match, then the updated makefile is fetched and replaces the old one. This is done in the <code>.PHONY</code> recipe. I should also mention that I don't want to add a recipe that updates it like <code>make update</code>, because again I want the process to be seamless. You'd be surprised how many students wouldn't utilize that feature, so I want to build it into the ones they will use for sure.</p> <p>Is there a better method for this, or am I doing something wrong with this one?</p>
[ { "answer_id": 74218795, "author": "Thomas", "author_id": 14637, "author_profile": "https://Stackoverflow.com/users/14637", "pm_score": 0, "selected": false, "text": "curl" }, { "answer_id": 74222813, "author": "MadScientist", "author_id": 939557, "author_profile": "h...
2022/10/27
[ "https://Stackoverflow.com/questions/74218120", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14504673/" ]
74,218,125
<p>I try to make an simple profil page for my application but I don't exactly know how to do it.</p> <p>I have an error when I want to call</p> <pre><code>'${widget.user['first_name']}' </code></pre> <p>in my profil widget :</p> <p><code>NoSuchMethodError (NoSuchMethodError: The method '[]' was called on null. Receiver: null Tried calling: [](&quot;first_name&quot;))</code></p> <p>My main page is a PageView that contains 2 widgets.</p> <pre><code>// ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables import 'dart:convert'; import 'package:clic_ads/Login/apiClient.dart'; import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; import '../Composants/appbar.dart'; import '../Login/login.dart'; import 'notifs.dart'; import 'profil.dart'; class MainPage extends StatefulWidget { final dynamic user; const MainPage({super.key, this.user}); @override _MainPageState createState() =&gt; _MainPageState(); } class _MainPageState extends State&lt;MainPage&gt; { final Api _apiClient = Api(); dynamic user; final PageController _controller = PageController( initialPage: 0, ); int activePage = 0; @override Future&lt;void&gt; dispose() async { _controller.dispose(); super.dispose(); } @override void initState() { super.initState(); } void bottomTapped(int index) { setState(() { activePage = index; _controller.animateToPage(index, duration: Duration(milliseconds: 500), curve: Curves.ease); }); } @override Widget build(BuildContext context) { Future&lt;void&gt; getUser() async { SharedPreferences prefs = await SharedPreferences.getInstance(); var token = prefs.getString('token'); this.user = await _apiClient.user(token!); print(user); return user ; } getUser(); return Scaffold( appBar: PreferredSize( preferredSize: Size.fromHeight(MediaQuery.of(context).size.height * 0.07), child: TopAppbar()), bottomNavigationBar: BottomNavigationBar( type: BottomNavigationBarType.fixed, currentIndex: activePage, backgroundColor: const Color(0xffC64C4E), selectedItemColor: Colors.white, unselectedItemColor: Colors.white.withOpacity(.55), selectedFontSize: 14, unselectedFontSize: 14, onTap: (value) { bottomTapped(value); }, items: [ BottomNavigationBarItem( label: 'Notifs', icon: Icon(Icons.view_list), ), BottomNavigationBarItem( label: 'Profil', icon: Icon( Icons.account_circle, ), ), ], ), backgroundColor: const Color(0xffEEEEEE), body: PageView( onPageChanged: (index) { setState(() { activePage = index; }); }, controller: _controller, children: [Notifs(), Profil(user: this.user)], ), ); } } </code></pre> <p>My first widget is an widget to show notifications :</p> <pre><code> // ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables, unnecessary_new import 'package:clic_ads/Login/apiClient.dart'; import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; class Notifs extends StatefulWidget { final dynamic user; const Notifs({super.key, this.user}); @override State\&lt;Notifs\&gt; createState() =\&gt; \_NotifsState(); } class \_NotifsState extends State\&lt;Notifs\&gt; { final Api \_apiClient = Api(); dynamic user; @override Widget build(BuildContext context) { double deviceWidth = MediaQuery.of(context).size.width; double deviceHeight = MediaQuery.of(context).size.height; Future\&lt;void\&gt; getUser() async { SharedPreferences prefs = await SharedPreferences.getInstance(); var token = prefs.getString('token'); this.user = await \_apiClient.user(token!); print(user); return user ; } getUser(); return ListView.builder( itemCount: 10, itemBuilder: (BuildContext context, int index) { return Column( children: [ new Container( decoration: new BoxDecoration( color: Color.fromARGB(255, 255, 255, 255), borderRadius: new BorderRadius.only( topRight: const Radius.circular(15.0), topLeft: const Radius.circular(15.0), )), margin: EdgeInsets.only( top: deviceWidth * 0.03, right: deviceWidth * 0.05, left: deviceWidth * 0.05), height: deviceHeight * 0.148, alignment: Alignment.centerLeft, child: Row( children: [ Container( decoration: new BoxDecoration( color: const Color(0xffC64C4E), borderRadius: new BorderRadius.only( topLeft: const Radius.circular(15.0), )), width: deviceWidth * 0.12, child: Center( child: FittedBox( child: Text( 'CU', style: TextStyle( fontSize: deviceWidth * 0.06, fontWeight: FontWeight.bold, color: Colors.white), ), ), ), ), Padding( padding: EdgeInsets.all(deviceWidth * 0.02), child: SizedBox( width: deviceWidth * 0.73, child: Column( children: [ Row( children: [ Text('17:24', style: TextStyle( fontSize: deviceWidth * 0.04, color: const Color(0xffC64C4E), fontWeight: FontWeight.w600)), Spacer(), Text('20/10/2022', style: TextStyle( fontSize: deviceWidth * 0.04, color: const Color(0xffC64C4E), fontWeight: FontWeight.w600)) ], ), Padding( padding: EdgeInsets.all(deviceWidth * 0.02), child: Row( children: [ Icon(Icons.person), Text('DUPOND Martin (M.)', style: TextStyle( fontSize: deviceWidth * 0.035, fontWeight: FontWeight.w500)) ], ), ), Padding( padding: EdgeInsets.all(deviceWidth * 0.02), child: Row( children: [ Icon( Icons.book, ), Text('CU01201222U0009', style: TextStyle( fontSize: deviceWidth * 0.035, fontWeight: FontWeight.w500)) ], ), ) ], ), ), ) ], ), ), Container( color: const Color(0xffC64C4E), height: 3, width: deviceWidth * 0.90) ], ); }, ); } } </code></pre> <p>And my second widget where I want to show the user details is here :</p> <pre><code> // ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables import 'package:clic_ads/Login/apiClient.dart'; import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; class Profil extends StatefulWidget { final dynamic user; const Profil({super.key, this.user}); @override State\&lt;Profil\&gt; createState() =\&gt; \_ProfilState(); } class \_ProfilState extends State\&lt;Profil\&gt; { // final Api \_apiClient = Api(); @override void initState() { super.initState(); } @override Widget build(BuildContext context) { // Future&lt;void&gt; getUser() async { // SharedPreferences prefs = await SharedPreferences.getInstance(); // var token = prefs.getString('token'); // user = await _apiClient.user(token!); // print(user['data']); // } // getUser(); // print(user); double deviceWidth = MediaQuery.of(context).size.width; double deviceHeight = MediaQuery.of(context).size.height; return Padding( padding: EdgeInsets.all(deviceWidth * 0.05), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text('Profil', style: TextStyle( fontSize: deviceWidth * 0.06, fontWeight: FontWeight.w500)), Padding( padding: EdgeInsets.only(left: deviceWidth * 0.05), child: Row( children: [ Icon( Icons.account_circle, size: deviceWidth * 0.3, ), Padding( padding: EdgeInsets.only(left: deviceWidth * 0.05), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ Text('${widget.user['first_name']}', style: TextStyle( fontSize: deviceWidth * 0.04, fontWeight: FontWeight.w500)), SizedBox(width: 10), Text('${widget.user['last_name']}', style: TextStyle( fontSize: deviceWidth * 0.04, fontWeight: FontWeight.w500)) ], ), SizedBox( height: 15, ), Text('${widget.user['email']}', style: TextStyle( fontSize: deviceWidth * 0.04, fontWeight: FontWeight.w500)) ], ), ) ], ), ), Text('Paramètres', style: TextStyle( fontSize: deviceWidth * 0.06, fontWeight: FontWeight.w500)) ], ), ); } } </code></pre> <p>I expect to show my user informations on my profil page</p>
[ { "answer_id": 74218795, "author": "Thomas", "author_id": 14637, "author_profile": "https://Stackoverflow.com/users/14637", "pm_score": 0, "selected": false, "text": "curl" }, { "answer_id": 74222813, "author": "MadScientist", "author_id": 939557, "author_profile": "h...
2022/10/27
[ "https://Stackoverflow.com/questions/74218125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20228429/" ]
74,218,127
<p>I'm trying to get Tradingview signals to my remote php script using webhook and trading view alerts. I can't succeed . I'm following this way</p> <p>In my trading view strategy I have this</p> <pre><code>strategy.entry(&quot;Long&quot;, strategy.long, alert_message = &quot;entry_long&quot;) strategy.exit(&quot;Exit Long&quot;, &quot;Long&quot;, limit=LONG_take_profit, stop=LONG_stop_loss, alert_message = &quot;exit_long&quot;) </code></pre> <p>then I set the alert as follow</p> <p><a href="https://i.stack.imgur.com/ExlC4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ExlC4.png" alt="trading view alert" /></a></p> <p>Then I set a PHP script as follow to receive the POST curl JSON data from Trading view</p> <pre><code>if ($_SERVER['REQUEST_METHOD'] == 'POST') { // fetch RAW input $json = file_get_contents('php://input'); // decode json $object = json_decode($json); // expecting valid json if (json_last_error() !== JSON_ERROR_NONE) { die(header('HTTP/1.0 415 Unsupported Media Type')); } $servdate2 = time(); $servdate=date('d-M-Y H:i:s',$servdate2); file_put_contents(&quot;/home/user/public_html/data.txt&quot;, &quot;$servdate :&quot;.print_r($object, true),FILE_APPEND); } </code></pre> <p>I receive the alert via email correctly but I do not receive data in /home/user/public_html/data.txt . What am I doing wrong ? How to send the Tradingview JSON data to my remote PHP script ?</p>
[ { "answer_id": 74218795, "author": "Thomas", "author_id": 14637, "author_profile": "https://Stackoverflow.com/users/14637", "pm_score": 0, "selected": false, "text": "curl" }, { "answer_id": 74222813, "author": "MadScientist", "author_id": 939557, "author_profile": "h...
2022/10/27
[ "https://Stackoverflow.com/questions/74218127", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1806799/" ]
74,218,134
<p>Hello everyone I'm uploading file to backend and I want to get upload percentage and display it in progress bar:</p> <p>Adding file ts component:</p> <pre><code> this.updateDokumentSub = this.dokumentiService.insertDokument(obj).pipe(takeUntil(this.destroy$)).subscribe((data: any) =&gt; { this.toastService.showToast('success', 'Novi dokument uspješno dodan', ''); form.resetForm(); this.close(true); this.dokumentiService.emitAddDokument(obj); this.loading = false; this.spinner.hide(); }, err =&gt; { console.error(err); this.loading = false; this.spinner.hide(); }); </code></pre> <p>Service file for uploading:</p> <pre><code> insertDokument(object: any): Observable&lt;Object&gt; { return this.http.post(this.apiRoute + '/insertDok', { }, object); } </code></pre> <p>And here is my progress bar:</p> <pre><code> &lt;nb-progress-bar [value]=&quot;40&quot; status=&quot;primary&quot; [displayValue]=&quot;true&quot;&gt;&lt;/nb-progress-bar&gt; </code></pre> <p>Appreciate if someone can advise. Thank you in advance!</p>
[ { "answer_id": 74218795, "author": "Thomas", "author_id": 14637, "author_profile": "https://Stackoverflow.com/users/14637", "pm_score": 0, "selected": false, "text": "curl" }, { "answer_id": 74222813, "author": "MadScientist", "author_id": 939557, "author_profile": "h...
2022/10/27
[ "https://Stackoverflow.com/questions/74218134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15112905/" ]
74,218,181
<p>Given this example:</p> <pre class="lang-py prettyprint-override"><code>s = &quot;Hi, domain: (foo.bar.com) bye&quot; </code></pre> <p>I'd like to create a regex that matches both word and non-word strings, separately, i.e:</p> <pre class="lang-py prettyprint-override"><code>re.findall(regex, s) # Returns: [&quot;Hi&quot;, &quot;, &quot;, &quot;domain&quot;, &quot;: (&quot;, &quot;foo.bar.com&quot;, &quot;) &quot;, &quot;bye&quot;] </code></pre> <p>My approach was to use the word boundary separator <code>\b</code> to catch any string that is bound by two word-to-non-word switches. From the <code>re</code> module docs:</p> <blockquote> <p><code>\b</code> is defined as the boundary between a <code>\w</code> and a <code>\W</code> character (or vice versa)</p> </blockquote> <p>Therefore I tried as a first step:</p> <pre class="lang-py prettyprint-override"><code>regex = r'(?:^|\b).*?(?=\b|$)' re.findall(regex, s) # Returns: [&quot;Hi&quot;, &quot;,&quot;, &quot;domain&quot;, &quot;: (&quot;, &quot;foo&quot;, &quot;.&quot;, &quot;bar&quot;, &quot;.&quot;, &quot;com&quot;, &quot;) &quot;, &quot;bye&quot;] </code></pre> <p>The problem is that I don't want the dot (<code>.</code>) character to be a separator too, I'd like the regex to see <code>foo.bar.com</code> as a whole word and not as three words separated by dots.</p> <p>I tried to find a way to use a negative lookahead on dot but did not manage to make it work.</p> <p>Is there any way to achieve that?</p> <p>I don't mind that the dot won't be a separator at all in the regex, it doesn't have to be specific to domain names.</p> <hr /> <p>I looked at <a href="https://stackoverflow.com/questions/14074308/regex-word-boundary-alternative">Regex word boundary alternative</a>, <a href="https://stackoverflow.com/questions/48976902/regex-capture-using-word-boundaries-without-stopping-at-dot-and-or-other-char/48978221#comment84959578_48976902">Capture using word boundaries without stopping at &quot;dot&quot; and/or other characters</a> and <a href="https://stackoverflow.com/questions/10196462/regex-word-boundary-excluding-the-hyphen">Regex word boundary excluding the hyphen</a> but it does not fit my case as I cannot use the space as a separator condition.</p> <p><a href="https://stackoverflow.com/questions/43400689/exclude-some-characters-from-word-boundary-in-javascript-regular-expressions">Exclude some characters from word boundary</a> is the only one that got me close, but I didn't manage to reach it.</p>
[ { "answer_id": 74218351, "author": "Nick", "author_id": 9473764, "author_profile": "https://Stackoverflow.com/users/9473764", "pm_score": 1, "selected": false, "text": "[^\\w.]+" }, { "answer_id": 74218399, "author": "anubhava", "author_id": 548225, "author_profile": ...
2022/10/27
[ "https://Stackoverflow.com/questions/74218181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8843390/" ]
74,218,192
<p>I have some dataframes I need to sum, but some of them have missing column. Unfortunately, the result will have NaN values for those columns, which were missing in some of the input dataframes.</p> <p>How to keep the original values for those columns?</p> <p>Here is a small code:</p> <pre><code>#!/usr/bin/env ipython # --------------------- import pandas as pd import numpy as np import datetime # ---------------------------------------- N=10 years = [vv for vv in range(2010,2010+N)] # generate data: data_a = {'years':years,'A':np.random.random(N),'B':np.random.random(N)} data_b = {'years':years,'A':np.random.random(N),'C':np.random.random(N)} # ---------------------------------------- dfa = pd.DataFrame.from_dict(data_a);dfa = dfa.set_index('years') dfb = pd.DataFrame.from_dict(data_b);dfb = dfb.set_index('years') dfc = dfa + dfb # ---------------------------------------- </code></pre> <p>Instead of having dfc as:</p> <pre><code> A B C years 2010 0.830207 NaN NaN 2011 1.237387 NaN NaN 2012 1.386908 NaN NaN 2013 0.949136 NaN NaN 2014 0.897436 NaN NaN 2015 0.375644 NaN NaN 2016 1.134836 NaN NaN 2017 1.125501 NaN NaN 2018 1.140183 NaN NaN 2019 0.522178 NaN NaN </code></pre> <p>I would like to have original values from dfa for column B and from dfb for column C.</p> <p>As the actual tables are large, some automatic solution is preferred.</p>
[ { "answer_id": 74218325, "author": "jezrael", "author_id": 2901002, "author_profile": "https://Stackoverflow.com/users/2901002", "pm_score": 4, "selected": true, "text": "DataFrame.add" }, { "answer_id": 74218344, "author": "thevoiddancer", "author_id": 210388, "autho...
2022/10/27
[ "https://Stackoverflow.com/questions/74218192", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1913367/" ]
74,218,194
<p>I have 2 lists:</p> <pre><code>images = ['ND_row_id_4026.png', 'ND_row_id_7693.png', 'ND_row_id_5285.png', 'ND_row_id_1045.png', 'ND_row_id_2135.png', 'ND_row_id_8155.png', 'ND_row_id_3135.png'] masks = ['MA_row_id_4026.png', 'MA_row_id_7693.png', 'MA_row_id_5285.png', 'MA_row_id_1045.png', 'MA_row_id_2135.png'] </code></pre> <p>I want to keep the <code>masks</code> files. So, I have 2 folders with images and masks and I want to keep all the masks that are in the <code>masks</code> list and the corresponding images. The images list is bigger than the masks.</p> <p>So ,I want to keep from the images list:</p> <pre><code>images = ['ND_row_id_4026.png', 'ND_row_id_7693.png', 'ND_row_id_5285.png', 'ND_row_id_1045.png', 'ND_row_id_2135.png'] </code></pre>
[ { "answer_id": 74218265, "author": "Nick", "author_id": 9473764, "author_profile": "https://Stackoverflow.com/users/9473764", "pm_score": 3, "selected": true, "text": "res = [im for im in images if im.replace('ND', 'MA') in masks]\n" }, { "answer_id": 74218310, "author": "San...
2022/10/27
[ "https://Stackoverflow.com/questions/74218194", "https://Stackoverflow.com", "https://Stackoverflow.com/users/583464/" ]
74,218,240
<p>Example code</p> <pre><code>a = '27-10-80' b = '27-10-22' c = '27-10-50' x = datetime.strptime(a, '%d-%m-%y') print(x) y = datetime.strptime(b, '%d-%m-%y') print(y) z = datetime.strptime(c, '%d-%m-%y') print(z) </code></pre> <p>Output:</p> <blockquote> <p>1980-10-27 00:00:00<br /> 2022-10-27 00:00:00<br /> 2050-10-27 00:00:00</p> </blockquote> <p>How did datetime decide the year generated from string using '%y' format. Why did 80 become 1980 while 50 become 2050?</p>
[ { "answer_id": 74218311, "author": "Abdul Niyas P M", "author_id": 6699447, "author_profile": "https://Stackoverflow.com/users/6699447", "pm_score": 1, "selected": false, "text": "_strptime.py" }, { "answer_id": 74218371, "author": "Masklinn", "author_id": 8182118, "a...
2022/10/27
[ "https://Stackoverflow.com/questions/74218240", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12268127/" ]
74,218,243
<p>I would like to extract the content of a tag without this tag itself and keeping all the tags inside.</p> <pre><code>html_text = &quot;&lt;TD WIDTH=60%&gt;Portsmouth - Cherbourg&lt;BR/&gt;Portsmouth - Santander&lt;BR/&gt;&lt;/TD&gt;&quot; soup = BeautifulSoup(html_text, 'html.parser') soup_list = soup.find_all(&quot;td&quot;) soup_object = soup_list[0] text = soup_object.getText() print(soup_object) </code></pre> <p>I get:</p> <blockquote> <p>&lt;td width=&quot;60%&quot;&gt;Portsmouth - Cherbourg&lt;br/&gt;Portsmouth - Santander&lt;br/&gt;&lt;/td&gt;</p> </blockquote> <p>But I want:</p> <blockquote> <p>Portsmouth - Cherbourg&lt;br/&gt;Portsmouth - Santander&lt;br/&gt;</p> </blockquote> <p>Using :</p> <p><code>soup_object.getText()</code></p> <p>... return:</p> <blockquote> <p>Portsmouth - CherbourgPortsmouth - Santander</p> </blockquote> <p>But it is not what I want.</p> <p>I know I can get the full content of the tag from a regex:</p> <pre><code>re.search(&quot;&lt;td.?&gt;(.)&lt;/td&gt;&quot;, str(soup_object)).group(1) </code></pre> <p>... but I use BeautifulSoup so I don't have to type this kind of code.</p> <p>A last thing:</p> <pre><code>soup_object.contents </code></pre> <p>... does not return what i want:</p> <blockquote> <p>['Portsmouth - Cherbourg', &lt;br/&gt;, 'Portsmouth - Santander', &lt;br/&gt;]</p> </blockquote> <p>Am I missing out on a Beautifulsoup feature?</p>
[ { "answer_id": 74218311, "author": "Abdul Niyas P M", "author_id": 6699447, "author_profile": "https://Stackoverflow.com/users/6699447", "pm_score": 1, "selected": false, "text": "_strptime.py" }, { "answer_id": 74218371, "author": "Masklinn", "author_id": 8182118, "a...
2022/10/27
[ "https://Stackoverflow.com/questions/74218243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17987787/" ]
74,218,278
<p>I want to sum the values that are in the &quot;Time&quot; columns but return 0 <a href="https://i.stack.imgur.com/zzn1G.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zzn1G.png" alt="Please see the photo" /></a></p> <p>I tried the following formula:</p> <p>=SUMIF(C2:H2,&quot;Time*&quot;,C3:H3)</p> <p>=SUMIF(SCRATCH031342[#Headers],&quot;Time*&quot;,C3:H3)</p>
[ { "answer_id": 74218355, "author": "T C Molenaar", "author_id": 8814131, "author_profile": "https://Stackoverflow.com/users/8814131", "pm_score": 0, "selected": false, "text": "=SUM(INDEX(C3:H4,0,MATCH(C6,C2:H2,0)))\n" }, { "answer_id": 74219034, "author": "VBasic2008", "...
2022/10/27
[ "https://Stackoverflow.com/questions/74218278", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14400010/" ]
74,218,291
<p>I have this piece of code</p> <pre><code>// This is onChange event function nameChangeHandler(e, field = 'Name') { const currentName = e.target.value; if (currentName.length &gt;= 10) { if (!errors.some((x) =&gt; x.field == field)) { setErrors((state) =&gt; [ ...state, { field, errorMessage: field + ' should be between 3 and 10 characters long', }, ]); } } else if (currentName.length &lt;= 3) { if (!errors.some((x) =&gt; x.field == field)) { setErrors((state) =&gt; [ ...state, { field, errorMessage: field + ' should be between 3 and 10 characters long', }, ]); } } else { setErrors((state) =&gt; state.filter((x) =&gt; x.field !== field)); } } </code></pre> <p>This part of the code is redundant</p> <pre><code> if (!errors.some((x) =&gt; x.field == field)) { setErrors((state) =&gt; [ ...state, { field, errorMessage: field + ' should be between 3 and 10 characters long', }, ]); } </code></pre> <p>My question is if place it inside an useCallback hook. Will it be a good practice or it's stupid move. Refactored code should be looking something like this:</p> <pre><code>const errorSetter = useCallback((field) =&gt; { if (!errors.some((x) =&gt; x.field == field)) { setErrors((state) =&gt; [ ...state, { field, errorMessage: field + ' should be between 3 and 10 characters long', }, ]); } }, []); function nameChangeHandler(e, field = 'Name') { const currentName = e.target.value; if (currentName.length &gt;= 10) { errorSetter(field) } else if (currentName.length &lt;= 3) { errorSetter(field) } else { setErrors((state) =&gt; state.filter((x) =&gt; x.field !== field)); } } </code></pre> <p>I tried adding it in useCallback and it works fine. All though, I'm new to React and don't yet know the best practices.</p>
[ { "answer_id": 74218404, "author": "T.J. Crowder", "author_id": 157247, "author_profile": "https://Stackoverflow.com/users/157247", "pm_score": 1, "selected": false, "text": "nameChangeHandler" }, { "answer_id": 74218448, "author": "pooyarm", "author_id": 9171495, "au...
2022/10/27
[ "https://Stackoverflow.com/questions/74218291", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13060913/" ]
74,218,312
<p>I have updated Mac Operating system in my MacBook Pro with the new version. After updating Pod init is not working.</p> <p>I am using Version 13.0 (22A380) Ventura [15-inch, 2019] model. Please help me to get it done. Below I am getting the following error</p> <p><code>Ignoring ffi-1.15.3 because its extensions are not built. Try: gem pristine ffi --version 1.15.3</code></p> <pre><code>/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/user_interface/error_report.rb:34:in `force_encoding': can't modify frozen String (FrozenError) from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/user_interface/error_report.rb:34:in `report' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/command.rb:66:in `report_error' from /Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:396:in `handle_exception' from /Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:337:in `rescue in run' from /Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:324:in `run' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/command.rb:52:in `run' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/bin/pod:55:in `&lt;top (required)&gt;' from /usr/local/bin/pod:23:in `load' from /usr/local/bin/pod:23:in `&lt;main&gt;' /Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.21.0/lib/xcodeproj/project.rb:228:in `initialize_from_file': [Xcodeproj] Unknown object version (56). (RuntimeError) from /Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.21.0/lib/xcodeproj/project.rb:113:in `open' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/command/init.rb:41:in `validate!' from /Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:333:in `run' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/command.rb:52:in `run' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/bin/pod:55:in `&lt;top (required)&gt;' from /usr/local/bin/pod:23:in `load' from /usr/local/bin/pod:23:in `&lt;main&gt;' </code></pre> <p>When I am trying to run the above command. Then I am getting the following error.</p> <pre><code>ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory. </code></pre> <p>If I am trying for the permission for the above folder then I am getting the following error.</p> <p>Command : <code>chmod ugo+rwx /Library/Ruby/Gems/2.6.0</code></p> <p>Result</p> <pre><code>chmod: Unable to change file mode on /Library/Ruby/Gems/2.6.0: Operation not permitted </code></pre>
[ { "answer_id": 74218404, "author": "T.J. Crowder", "author_id": 157247, "author_profile": "https://Stackoverflow.com/users/157247", "pm_score": 1, "selected": false, "text": "nameChangeHandler" }, { "answer_id": 74218448, "author": "pooyarm", "author_id": 9171495, "au...
2022/10/27
[ "https://Stackoverflow.com/questions/74218312", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3197468/" ]
74,218,340
<p>I'm trying to learn Scala. I ask for help to understand loop <strong>foreach</strong> I have a function, it reads only last csv from path. But it works when I point only one way:</p> <pre><code>val path = &quot;src/main/resources/historical_novel/&quot; def getLastFile(path: String, spark: SparkSession): String = { val hdfs = ...} </code></pre> <p>but how can I apply this function to the list such as</p> <pre><code>val paths: List[String] = List( &quot;src/main/resources/historical_novel/&quot;, &quot;src/main/resources/detective/&quot;, &quot;src/main/resources/adventure/&quot;, &quot;src/main/resources/horror/&quot;) </code></pre> <p>I want to get such result:</p> <pre><code>src/main/resources/historical_novel/20221027.csv src/main/resources/detective/20221026.csv src/main/resources/adventure/20221026.csv src/main/resources/horror/20221027.csv </code></pre> <p>I create df with column (path), then apply function through WithColumn and it is work, but I want to do it with <strong>foreach</strong>, understand it.</p>
[ { "answer_id": 74218393, "author": "John Joker", "author_id": 14169029, "author_profile": "https://Stackoverflow.com/users/14169029", "pm_score": 1, "selected": false, "text": "def f(s: String): Unit = {}\n" }, { "answer_id": 74224421, "author": "Brian", "author_id": 3907...
2022/10/27
[ "https://Stackoverflow.com/questions/74218340", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20345888/" ]
74,218,346
<p>we are to write a function that takes a single parameter string, and then outputs each 4 letter permutation from the possible combinations of the string. so for example even if it is a 5 letter word you have to return all 4 letter combinations of the string. it can also only be solved iteratively so no recursion.</p> <p>currently i've tried using nested for loops, so for instance</p> <pre><code>for i in word: for x in word: for z in word: for y in word: print(y) print(z) print(x) print(i) </code></pre> <p>However the issue i'm coming across is that firstly, i'm not sure on how I would concatenate these outputs into a single string output given that i cannot use lists or any form of sets/dictionaries/tuples etc. secondly, how exactly would i avoid duplicate strings?</p>
[ { "answer_id": 74218387, "author": "Emi OB", "author_id": 14463396, "author_profile": "https://Stackoverflow.com/users/14463396", "pm_score": 1, "selected": false, "text": "+" }, { "answer_id": 74218602, "author": "frankfalse", "author_id": 18108367, "author_profile":...
2022/10/27
[ "https://Stackoverflow.com/questions/74218346", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20143345/" ]
74,218,356
<p>I'm building a Iceberg tables on the top of a data lake. These tables are used for reporting tools. I'm trying to figure out what is the best way to control a version/deploy changes to these tables in CI/CD process. E.g. I could like to add a column to the Iceberg table. To do that I have to write a <code>ALTER TABLE</code> statement, save it to the git repository and deploy via CI/CD pipeline. Tables are accessible via AWS Glue Catalog. I couldn't find to much info about this in google so if anyone could share some knowledge, it would be much appreciated.</p> <p>Cheers.</p> <p>Version control of Iceberg tables.</p>
[ { "answer_id": 74272556, "author": "liliwei", "author_id": 6385205, "author_profile": "https://Stackoverflow.com/users/6385205", "pm_score": 1, "selected": false, "text": "ALTER TABLE" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74218356", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20346421/" ]
74,218,357
<p>I would like to use some publicly available data from a government website as a source of data in an iOS app. But I am not sure what is the best / most polite / scalable way have a large number of users request data from this website with the least impact on their servers and best reliability for me.</p> <ul> <li>It is 1-50kb of static XML with a fixed URL scheme</li> <li>It updates with a new XML once a day</li> <li>New users would need to download past data</li> <li>It has a Last-Modified header but no caching headers</li> <li>It does not use compression or a CDN</li> <li>It's a government website, so if someone even replies to my email I doubt they are going to change how they host it for me...</li> </ul> <p>I'm thinking I could run a script on a server to download this file once a day and re-host for my app however my heart desires. But I don't <em>currently</em> run a server which I could use for this and it seems like a lot just for this. My knowledge of web development is not great, so am I perhaps missing something obvious and I just don't know what search terms I should be using to find the answer.</p> <ul> <li>Can I point a CDN at this static data somehow and use that?</li> <li>Is there something in CloudKit I could use?</li> <li>Should I run a script on AWS somehow to do the rehosting without needing a full server?</li> <li>Should I just not worry about it and access the data directly??</li> </ul>
[ { "answer_id": 74272556, "author": "liliwei", "author_id": 6385205, "author_profile": "https://Stackoverflow.com/users/6385205", "pm_score": 1, "selected": false, "text": "ALTER TABLE" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74218357", "https://Stackoverflow.com", "https://Stackoverflow.com/users/747669/" ]
74,218,380
<p>i am currently trying to understand some basic concept of Python.</p> <p>Here is my code :</p> <pre><code>class BorgSingleton: _shared_borg_state = {} test = &quot;toto&quot; def __init__(self): self.__dict__ = self._shared_borg_state print(&quot;borg created&quot;) print(self.test) class Point(BorgSingleton) : def __init__(self, lat, long): self.latitude = lat self.longitude = long super().__init__() print (self.latitude) def g(self) : return BorgSingleton.test +&quot; &quot; +str(self.latitude) + &quot; &quot; + str(self.longitude) def main(): point_1 = Point(5,2) point_2 = Point(3,3) print(point_1.g()) print(point_2.g()) point_1.test = &quot;tata&quot; print(point_1.g()) print(point_2.g()) if (__name__ == &quot;__main__&quot;): main() </code></pre> <p>And here my output :</p> <blockquote> <p>borg created<br /> toto<br /> Traceback (most recent call last):<br /> File &quot;file1.py&quot;, line 32, in <br /> main()<br /> File &quot;file1.py&quot;, line 23, in main<br /> point_1 = Point(5,2)<br /> File &quot;file1.py&quot;, line 16, in <strong>init</strong><br /> print (self.latitude)<br /> AttributeError: 'Point' object has no attribute 'latitude'</p> </blockquote> <p>I am surely making a basic mistake un python, but i am not sure of why my &quot;Point&quot; don't have a &quot;latitude&quot; attribute here.</p> <p>I rode about inheritence and Borg conception, but something is missing. I also try the -tt option for indentation mistake.</p>
[ { "answer_id": 74218455, "author": "frankfalse", "author_id": 18108367, "author_profile": "https://Stackoverflow.com/users/18108367", "pm_score": 1, "selected": false, "text": "super().__init__()" }, { "answer_id": 74218853, "author": "Dmitry Novikov", "author_id": 122913...
2022/10/27
[ "https://Stackoverflow.com/questions/74218380", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20346492/" ]
74,218,398
<p>I need to download json data from the internet</p> <pre><code>[ { &quot;day&quot;: &quot;Monday:&quot;, &quot;hours&quot;: [22, 27] }, { &quot;day&quot;: &quot;Tuesday :&quot;, &quot;hours&quot;: [22, 27] }, { &quot;day&quot;: &quot;Wednesday&quot;, &quot;hours&quot;: [22, 27] }, ] </code></pre> <p>I want the data from the &quot;hours&quot; item to be retrieved as separate elements (without square brackets)</p> <p>Could someone please provide an example ?</p> <p>I get an error popping up all the time</p> <p>&quot;flutter _typeerror (type 'string' is not a subtype of type 'map&lt;dynamic, dynamic&gt;'&quot;</p> <pre><code>My current class looks like this class DaysList { final String days; final String hours; const DayList({required this.days, required this.hours}); static DaysList fromJson(json) =&gt; DaysList( days: json['days'], hours: json['hours'] , ); } This returns all data with &quot;hours&quot; but in square brackets </code></pre>
[ { "answer_id": 74218455, "author": "frankfalse", "author_id": 18108367, "author_profile": "https://Stackoverflow.com/users/18108367", "pm_score": 1, "selected": false, "text": "super().__init__()" }, { "answer_id": 74218853, "author": "Dmitry Novikov", "author_id": 122913...
2022/10/27
[ "https://Stackoverflow.com/questions/74218398", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19143572/" ]
74,218,411
<p>I'm very new to VBA and just trying to build a very basic tool but I am a little stuck so hoping someone can help!</p> <p>I have setup as in the image below <a href="https://i.stack.imgur.com/MgEZ3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MgEZ3.png" alt="Data" /></a></p> <p>I'd like to take the string in column B and compress it so that at the click of a button (pre-created) I create a list which contains only the string that varies i.e. Apple, Apple 1, Banana and Banana 2. This list needs to present in the Codes tab where the user can assign an integer to each (1 and 2).</p> <p>Once the codes are assigned the user would click the button and the codes would appear in a third tab (Results) with the itemised number and code next to it.</p> <p>I hope this makes sense. I'm really not sure where to start with this!</p> <p>Thanks in advance!</p> <p>I've attempted various things I've found on the internet to compress the list but couldn't get the code to compile.</p> <p>Please see screenshots of how the tabs will be set out below: <a href="https://i.stack.imgur.com/eKcIe.png" rel="nofollow noreferrer">Input Data</a></p> <p><a href="https://i.stack.imgur.com/l04Gb.png" rel="nofollow noreferrer">Coding Tab</a></p> <p><a href="https://i.stack.imgur.com/Krp7e.png" rel="nofollow noreferrer">Results Tab</a></p>
[ { "answer_id": 74220862, "author": "VBasic2008", "author_id": 9814069, "author_profile": "https://Stackoverflow.com/users/9814069", "pm_score": 1, "selected": false, "text": "Sub WriteCoding()\n\n Dim wb As Workbook: Set wb = ThisWorkbook\n \n ' Write from source range to source...
2022/10/27
[ "https://Stackoverflow.com/questions/74218411", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20343592/" ]
74,218,442
<p>I need to remove the grey rectangle container from the navigation bottom and remain only the navigation bottom with an icon how I can do that, also I need it to show in front of the Grid view list. so that when I scroll the bottom of GridView shows under the bottom navigation bar without the grey container that covers it any help? Here is an image:</p> <p><img src="https://i.stack.imgur.com/4d1Hk.jpg" alt="enter image description here" /></p> <p>and here is my code: `</p> <pre><code>import 'package:flutter/material.dart'; import 'Home.dart'; class MyHomePage extends StatefulWidget { const MyHomePage({super.key}); @override State&lt;MyHomePage&gt; createState() =&gt; _MyHomePageState(); } class _MyHomePageState extends State&lt;MyHomePage&gt; { var currentIndex = 0; List&lt;Widget&gt; body = [Home(), Home(), Home(), Home()]; @override Widget build(BuildContext context) { double screenWidth = MediaQuery.of(context).size.width; return Scaffold( body: body[currentIndex], bottomNavigationBar: Container( margin: EdgeInsets.all(20), height: screenWidth * .155, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(50), ), child: ListView.builder( itemCount: 4, scrollDirection: Axis.horizontal, padding: EdgeInsets.symmetric(horizontal: screenWidth * .024), itemBuilder: (context, index) =&gt; InkWell( onTap: () { setState(() { currentIndex = index; }); }, splashColor: Colors.transparent, highlightColor: Colors.transparent, child: Stack( children: [ </code></pre> <p>` I want it like this : [enter image description here][2]</p>
[ { "answer_id": 74220862, "author": "VBasic2008", "author_id": 9814069, "author_profile": "https://Stackoverflow.com/users/9814069", "pm_score": 1, "selected": false, "text": "Sub WriteCoding()\n\n Dim wb As Workbook: Set wb = ThisWorkbook\n \n ' Write from source range to source...
2022/10/27
[ "https://Stackoverflow.com/questions/74218442", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20059879/" ]
74,218,445
<p>So I want to filter an array of objects according to a few filters I have created:</p> <pre class="lang-js prettyprint-override"><code>items.filter( (obj) =&gt; (!status || (obj.globalId &amp;&amp; obj.globalId !== &quot;&quot;)) &amp;&amp; (!deletedSwitch || obj.deleted === deletedSwitch) &amp;&amp; (!filteredUsername || obj.userId === userId) &amp;&amp; (!filteredType || obj.type === filteredType) &amp;&amp; (!filteredVariety || obj.variety === filteredVariety) &amp;&amp; (!filteredSize || parseInt(obj.size) === filteredSize) ) </code></pre> <p>So as you can see, I filter the items based on a few properties. These properties are selected through a <code>&lt;select&gt;</code> component. <code>status</code> property used to be a <code>boolean</code> state where I want to check if the item has a <code>globalId</code> or not. However, now I want to change it in a way where I check if <code>status</code> is <code>connected</code>, then I want to filter all items that have a <code>globalId</code> each. But if the <code>status</code> is <code>not connected</code>, I want to filter all items that DO NOT have a <code>globalId</code>. How can I modify my code above to achieve this?</p>
[ { "answer_id": 74218527, "author": "mplungjan", "author_id": 295783, "author_profile": "https://Stackoverflow.com/users/295783", "pm_score": 2, "selected": true, "text": "items.filter(obj =>\n ((status === \"connected\" && obj.globalId && obj.globalId !== \"\") ||\n (status === \"...
2022/10/27
[ "https://Stackoverflow.com/questions/74218445", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16170683/" ]
74,218,458
<p>All I need is a function to filter my page based on the text contained in the div class <code>desc</code> that is the word <code>PROD</code> or <code>test</code>. I had thought of something like the one contained in the script tags but I can't get it to work.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code> $(function () { $('input[name="test"]').on("click", function (a, b) { var value = this.value; $("#elenco &gt; .desc").hide(); if (value == "All") { $("#elenco &gt; .desc").show(); } else if (value == "PROD") { $("#elenco &gt; .desc") .filter(function (a, b) { var v = b.value; return this.value; }) .show(); } else if (value == "TEST") { $("#elenco &gt; .desc") .filter(function (a, b) { var v = b.value; return this.value; }) .show(); } }); });</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt; &lt;input type="radio" value="All" checked name="test" /&gt;&lt;label&gt;All&lt;/label&gt; &lt;input type="radio" value="PROD" name="test" /&gt;&lt;label&gt; PROD&lt;/label&gt; &lt;input type="radio" value="TEST" name="test" /&gt;&lt;label&gt;TEST&lt;/label&gt; &lt;div id="elenco"&gt; &lt;div class="cliente"&gt; cliente &lt;div class="desc" value="PROD"&gt; betafrik prod &lt;br /&gt; &lt;img src="" /&gt; &lt;/div&gt; &lt;div class="funzioni"&gt; INDIRIZZI IP &lt;button type="button" onclick="managerBetafrikP()" id="m1"&gt;manager&lt;/button&gt; &lt;button type="button" onclick="reloadmemBetafrikP()" id="r1"&gt;reload&lt;/button&gt; &lt;br /&gt; &lt;ul&gt; &lt;li&gt; &lt;button type="button" onclick="UpVersioneT()" class="rs1"&gt;UpVersione&lt;/button&gt; &lt;div class="resultVersion" id="UpVersioneBetafrikP"&gt;Risultato&lt;/div&gt; &lt;/li&gt; &lt;li&gt; &lt;button type="button" onclick="reloadmem()" class="rs1"&gt;10.13.1.47&lt;/button&gt; &lt;div class="result" id="resultBetafrikP1"&gt;Risultato&lt;/div&gt; &lt;/li&gt; &lt;li&gt; &lt;button type="button" onclick="reloadmem()" class="rs1"&gt;10.13.1.48&lt;/button&gt; &lt;div class="result" id="resultBetafrikP2"&gt;Risultato&lt;/div&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="cliente"&gt; cliente &lt;div class="desc" value="TEST"&gt; betitaly test &lt;br /&gt; &lt;img src="" /&gt; &lt;/div&gt; &lt;div class="funzioni"&gt; INDIRIZZI IP &lt;button type="button" onclick="managerBetitalyT()" id="m1"&gt;manager&lt;/button&gt; &lt;button type="button" onclick="reloadmem()" id="r1"&gt;reload&lt;/button&gt; &lt;br /&gt; &lt;ul&gt; &lt;li&gt; &lt;button type="button" onclick="UpVersioneT()" class="rs1"&gt;UpVersione&lt;/button&gt; &lt;div class="resultVersion" id="UpVersioneBetitalyT"&gt;Risultato&lt;/div&gt; &lt;/li&gt; &lt;li&gt; &lt;button type="button" onclick="reloadmem()" class="rs1"&gt;10.57.0.71&lt;/button&gt; &lt;div class="result" id="resultBetitalyT"&gt;Risultato&lt;/div&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="cliente"&gt; cliente &lt;div class="desc"&gt; vincitù test &lt;br /&gt; &lt;img src="" /&gt; &lt;/div&gt; &lt;div class="funzioni"&gt; INDIRIZZI IP &lt;button type="button" onclick="managerVincituT()" id="m1"&gt;manager&lt;/button&gt; &lt;button type="button" onclick="reloadmem()" id="r1"&gt;reload&lt;/button&gt; &lt;br /&gt; &lt;ul&gt; &lt;li&gt; &lt;button type="button" onclick="UpVersioneT()" class="rs1"&gt;UpVersione&lt;/button&gt; &lt;div class="resultVersion" id="UpVersioneVincituT"&gt;Risultato&lt;/div&gt; &lt;/li&gt; &lt;li&gt; &lt;button type="button" onclick="reloadmem()" class="rs1"&gt;10.55.0.71&lt;/button&gt; &lt;div class="result" id="resultVincituP"&gt;Risultato&lt;/div&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="cliente"&gt; cliente &lt;div class="desc" value="TEST"&gt; betitaly test &lt;br /&gt; &lt;img src=" " /&gt; &lt;/div&gt; &lt;div class="funzioni"&gt; INDIRIZZI IP &lt;button type="button" onclick="managerBetitalyT()" id="m1"&gt;manager&lt;/button&gt; &lt;button type="button" onclick="reloadmem()" id="r1"&gt;reload&lt;/button&gt; &lt;br /&gt; &lt;ul&gt; &lt;li&gt; &lt;button type="button" onclick="UpVersioneT()" class="rs1"&gt;UpVersione&lt;/button&gt; &lt;div class="resultVersion" id="UpVersioneBetitalyT"&gt;Risultato&lt;/div&gt; &lt;/li&gt; &lt;li&gt; &lt;button type="button" onclick="reloadmem()" class="rs1"&gt;10.57.0.71&lt;/button&gt; &lt;div class="result" id="resultBetitalyT"&gt;Risultato&lt;/div&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <p>I tried the function above which I can't get it to work. In practice, based on the selection button, only the results associated with it must appear and by default, the selected button must be <code>ALL</code>.</p>
[ { "answer_id": 74218505, "author": "Delano van londen", "author_id": 19923550, "author_profile": "https://Stackoverflow.com/users/19923550", "pm_score": 0, "selected": false, "text": " $(function () {\n $('input[name=\"test\"]').on('click', function (a, b) {\n v...
2022/10/27
[ "https://Stackoverflow.com/questions/74218458", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20346536/" ]
74,218,492
<p>I have a table in my react-app and I stored some data in there. Now I have a function that everytime I click/select a table row, I load more details about that typical data somewhere else. The problem is that the user will want to know which row is currently selected so they wouldn't be confused whether the right one is clicked or not.</p> <p>The table goes like this:</p> <pre><code>`&lt;table&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;Name&lt;/th&gt; &lt;th&gt;LastName&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; {myRecors.map((current) =&gt; ( &lt;tr&gt; &lt;td&gt;{current.Name}&lt;/td&gt; &lt;td&gt;{current.LastName}&lt;/td&gt; &lt;/tr&gt; ))} &lt;/tbody&gt; &lt;/table&gt;` </code></pre> <p>What I have tried:</p> <pre><code>const [isActive, setIsActive] = useState(false); // for setting a value whether it's clicked or not const handleColorChange = (e) =&gt; { setIsActive(current =&gt; !current); console.log(&quot;e=&quot;,e); }; </code></pre> <pre><code>`&lt;table&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;Name&lt;/th&gt; &lt;th&gt;LastName&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; {myRecors.map((current) =&gt; ( &lt;tr style= {{ backgroundColor: isActive ? 'crimson' : '', }} onClick={handleColorChange(e)} &gt; &lt;td&gt;{current.Name}&lt;/td&gt; &lt;td&gt;{current.LastName}&lt;/td&gt; &lt;/tr&gt; ))} &lt;/tbody&gt; &lt;/table&gt;` </code></pre> <p>This will select all the table row, not only the one that is selected. If I do the same thing to a <code>&lt;td&gt;</code> then again, it will set backgroundColor to every row, not just one. What am I missing here?</p>
[ { "answer_id": 74218731, "author": "Dulaj Ariyaratne", "author_id": 13368318, "author_profile": "https://Stackoverflow.com/users/13368318", "pm_score": 3, "selected": true, "text": "// Get a hook function\nconst {useState} = React;\n\nconst dummyData = [\n {\n id: 1,\n Name: 'Name...
2022/10/27
[ "https://Stackoverflow.com/questions/74218492", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17823599/" ]
74,218,512
<p>Suppose that we have this dataframe:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Value 1</th> <th>Value 2</th> <th>Value 3</th> </tr> </thead> <tbody> <tr> <td>6</td> <td>5</td> <td>6</td> </tr> <tr> <td>6</td> <td>5</td> <td>10</td> </tr> </tbody> </table> </div> <p>How to apply color if values on the same column is equals but skip the first column? In my case, column <strong>Value 2</strong> must be colored</p> <p>I have used Pandas df.apply, but the example is compare column on the same row</p>
[ { "answer_id": 74218592, "author": "Haekal Rizky Yulianto", "author_id": 20346604, "author_profile": "https://Stackoverflow.com/users/20346604", "pm_score": 2, "selected": true, "text": "df = df.style.apply(lambda x: ['background-color: lightgreen']*len(df) if (x.iloc[0] == x.iloc[1] and...
2022/10/27
[ "https://Stackoverflow.com/questions/74218512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20346586/" ]
74,218,514
<p>I'm making a get to an API in my Angular project and I get this JSON:</p> <pre><code> { &quot;id&quot;: 16, &quot;poste&quot;: &quot;ameur taboui&quot;, &quot;desciption&quot;: &quot;f&quot;, &quot;service&quot;: &quot;f&quot;, &quot;creationDate&quot;: &quot;2022-10-13&quot;, &quot;updatedDate&quot;: &quot;2022-10-24&quot;, &quot;active&quot;: true, &quot;personnelPosteListe&quot;: { &quot;id&quot;: 1, &quot;nomPersonnel&quot;: &quot;ADMIN&quot;, &quot;prenomPersonnel&quot;: &quot;ADMIN&quot;, &quot;matricule&quot;: 2564, &quot;dateNaissance&quot;: &quot;2022-07-26&quot;, &quot;cin&quot;: 7858585, &quot;telephone&quot;: 2554884, &quot;adresse&quot;: &quot;tunis&quot;, &quot;dateAff&quot;: &quot;2022-07-26&quot;, &quot;dateFinAff&quot;: &quot;2022-07-26&quot;, &quot;typeContrat&quot;: &quot;test&quot;, &quot;champInterim&quot;: &quot;f&quot;, &quot;active&quot;: true }, }, </code></pre> <p>I try to access personnelPosteListe in my HTML, but I got the error</p> <blockquote> <p>Error: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays. Any help on this? This is my TS file:</p> </blockquote> <pre><code>onGetPosteListeByID() { this.grhService .getPosteListeById(this.id) .pipe(takeUntil(this.onDestroy$)) .subscribe( (data) =&gt; { this.poste = data; console.log(this.poste); }, (err) =&gt; { console.log(err); } ); } } </code></pre> <p>This is my HTML :</p> <pre><code>&lt;table class=&quot;table table-striped table-hover table-bordered text-center table-centre table-res&quot;&gt; &lt;thead class=&quot;thead-light&quot;&gt; &lt;tr&gt; &lt;th&gt; {{&quot;Nom&quot; | translate }} &lt;/th&gt; &lt;th&gt; {{&quot;Prénom&quot; | translate }}&lt;/th&gt; &lt;th&gt; {{&quot;Type de contrat&quot; | translate}}&lt;/th&gt; &lt;th&gt; {{&quot;Matricule&quot; | translate }}&lt;/th&gt; &lt;th&gt; {{&quot;Telephone&quot; | translate }}&lt;/th&gt; &lt;/tr&gt; &lt;tr *ngFor=&quot;let b of poste?.personnelPosteListe ; trackBy: trackByMethod &quot;&gt; &lt;td&gt; {{ b?.nomPersonnel}}&lt;/td&gt; &lt;td&gt; {{ b?.prenomPersonnel }}&lt;/td&gt; . . . . &lt;/tr&gt; &lt;/thead&gt; &lt;/table&gt; </code></pre>
[ { "answer_id": 74218684, "author": "MoxxiManagarm", "author_id": 11011793, "author_profile": "https://Stackoverflow.com/users/11011793", "pm_score": 0, "selected": false, "text": "onGetPosteListeByID() {\n this.grhService.getPosteListeById(this.id).pipe(\n map(data => {\n ...
2022/10/27
[ "https://Stackoverflow.com/questions/74218514", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12931793/" ]
74,218,526
<p>i'm a highschool student and i'm doing a homework rn. I'm at the end of it but there's just something that doesn't work quite like i want it to..</p> <p>For some reason, my code above is doing the mean of the value &quot;year) and it's not something i want, but it seems it take the value &quot;year&quot; and not &quot;Life expectency&quot; as i want.</p> <p>For a better understanding, i've uploaded an image just below that show you my problem. The orange bar is right but the blue bar is not taking the good value... it's doing the mean of all the year so that's why all the blue bar are up to 2000s.</p> <p>below the image you can find my code. Thanks you for helping me and have a great day !</p> <p><a href="https://i.stack.imgur.com/siqQA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/siqQA.png" alt="" /></a></p> <pre><code>df_life_exp = (df .loc[df['year'].isin([1952, 2007]), ['year', 'continent', 'lifeExp']] .groupby('continent') .mean() .unstack() .unstack() .unstack() .unstack() ) ax = (df_life_exp .plot.bar(rot=45, figsize=(16, 6)) ) ax.set_xlabel('Continent', fontsize=12) ax.set_ylabel('Life Expectancy', fontsize=12) ax.set_title('Life Expectancy by continent in 1952 and 2007', fontsize=14) ax.legend(labels=['1952', '2007']) </code></pre>
[ { "answer_id": 74218696, "author": "Quan Nguyen", "author_id": 7661158, "author_profile": "https://Stackoverflow.com/users/7661158", "pm_score": 0, "selected": false, "text": "df_life_exp = df\n .loc[df['year'].isin([1952, 2007]), ['year', 'continent', 'lifeExp']]\n .groupby('continent...
2022/10/27
[ "https://Stackoverflow.com/questions/74218526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11066662/" ]
74,218,532
<p>When using eg. MySQL, one open a connection fx:</p> <pre><code>const c = await mysql.createConnection({ host: 'localhost', user: 'x', password: 'x', database: 'x', Promise: bluebird, }); </code></pre> <p>and then perform actions on the connection <code>c</code> like so</p> <pre><code>const [rows, fields] = await c.execute(q); </code></pre> <p>but with Mongoose <code>mongoose.connect()</code> <a href="https://mongoosejs.com/docs/connections.html#server-selection" rel="nofollow noreferrer">doesn't return a connection</a>. it is nice not that it &quot;just works&quot;, but I really would prefer the MySQL approach where it is explicitly written which database connection that is used.</p> <p>Is that possible with Mongoose?</p>
[ { "answer_id": 74218696, "author": "Quan Nguyen", "author_id": 7661158, "author_profile": "https://Stackoverflow.com/users/7661158", "pm_score": 0, "selected": false, "text": "df_life_exp = df\n .loc[df['year'].isin([1952, 2007]), ['year', 'continent', 'lifeExp']]\n .groupby('continent...
2022/10/27
[ "https://Stackoverflow.com/questions/74218532", "https://Stackoverflow.com", "https://Stackoverflow.com/users/256439/" ]
74,218,546
<p>Up to Hibernate 5 the class mapping can be defined either by using JPA annotations or with an XML file. The XML file is convenient because it isn't tied to the class, which means it's possible to:</p> <ol> <li>map a class even if you don't have the source code</li> <li>map a class differently depending on the context (a class may be mapped one way on the server, and another way on the client)</li> </ol> <p>Hibernate 6 removed the XML mapping. Is there an alternative method to define a mapping without adding annotations to the persisted classes?</p>
[ { "answer_id": 74662254, "author": "Gavin King", "author_id": 2889760, "author_profile": "https://Stackoverflow.com/users/2889760", "pm_score": 2, "selected": true, "text": "orm.xml" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74218546", "https://Stackoverflow.com", "https://Stackoverflow.com/users/525725/" ]
74,218,549
<p>Long term observer, first time poster.</p> <p>I have a table that is:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>UTC</th> <th>Allowed</th> <th>Blocked</th> </tr> </thead> <tbody> <tr> <td>1666852500</td> <td>100</td> <td>52</td> </tr> <tr> <td>1666853100</td> <td>45</td> <td>11</td> </tr> <tr> <td>1666853100</td> <td>67</td> <td>15</td> </tr> </tbody> </table> </div> <p>The UTC column has multiple duplicates, due to my sampling. I would like to remove duplicates of 'utc' and return the max value of Allowed and, or Blocked...for example</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>UTC</th> <th>Allowed</th> <th>Blocked</th> </tr> </thead> <tbody> <tr> <td>1666852500</td> <td>100</td> <td>52</td> </tr> <tr> <td>1666853100</td> <td>67</td> <td>15</td> </tr> </tbody> </table> </div> <p>I'm using SQL, but for the life of me I can't process it in my head. Can't even think of the terminology to google, hence why here. Hopefully someone can advise.</p> <p>SQL or python would be useful.</p> <p>Thank you in advance.</p> <p>Have attempted filtering in python with a bunch of for loops....Didn't workout... Have tried Nest SQL select queries. I believe it's something simple, but it eludes my tiny brain</p>
[ { "answer_id": 74662254, "author": "Gavin King", "author_id": 2889760, "author_profile": "https://Stackoverflow.com/users/2889760", "pm_score": 2, "selected": true, "text": "orm.xml" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74218549", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20346497/" ]
74,218,562
<p>For some reason I am getting Internal Error 500 when using c# HttpClient. The URL doesn't respond with 500 error when using chrome/web browser or Postman.</p> <p>The Test URL I am using is &quot;https://onlinetools.ups.com/track/v1/details/asdfa&quot;</p> <p>When I access the URL directly via Chrome by pasting it in, it gets the below response</p> <pre><code>&lt;CommonResponse&gt; &lt;response&gt; &lt;errors&gt; &lt;errors&gt; &lt;code&gt;250003&lt;/code&gt; &lt;message&gt;Invalid Access License number. Access Key not found&lt;/message&gt; &lt;/errors&gt; &lt;/errors&gt; &lt;/response&gt; &lt;/CommonResponse&gt; </code></pre> <p>It gets similar result for Postman (though in JSON format)</p> <p>But when I try to do it via HttpClient I get an Internal 500 Error. The Test code is</p> <pre><code> using (var client = new HttpClient()) { var testResult = client .GetAsync(&quot;https://onlinetools.ups.com/track/v1/details/asdfa&quot;).Result; } </code></pre> <p>Does anyone ever seen something similar or know of a fix? This is a bit too deep for my limited knowledge.</p>
[ { "answer_id": 74662254, "author": "Gavin King", "author_id": 2889760, "author_profile": "https://Stackoverflow.com/users/2889760", "pm_score": 2, "selected": true, "text": "orm.xml" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74218562", "https://Stackoverflow.com", "https://Stackoverflow.com/users/138965/" ]
74,218,584
<p>Since I am not yet good in generics I would like to ask:</p> <p><strong>Question</strong>: why I cannot inform the function <code>getResult</code> that the return value from <code>bundle.getParcelableCompat&lt;T&gt;(BUNDLE_KEY)</code> would be type of <code>T</code> (which is any class inheriting by Parcelable)?</p> <p>I get error:</p> <pre><code>Cannot use 'T' as reified type parameter. Use a class instead. </code></pre> <p>What am I mising? I though I passed all needed information what I am trying to achieve.</p> <pre><code>class MyClass&lt;T : Parcelable&gt;( private val key: String, private val clazz: Class&lt;T&gt; ) { private inline fun &lt;reified T : Parcelable&gt; Bundle.getParcelableCompat(name: String): T? = if (Build.VERSION.SDK_INT &gt;= 33) { this.getParcelable(name, T::class.java) } else { this.getParcelable(name) } fun getResult(fragment: Fragment, result: (T) -&gt; Unit) = with(fragment) { setFragmentResultListener(requestKey) { request, bundle -&gt; if (request == requestKey) { val parcelableCompat: T? = bundle.getParcelableCompat&lt;T&gt;(BUNDLE_KEY) parcelableCompat?.let(result) } } } } </code></pre>
[ { "answer_id": 74218781, "author": "Marcus Dunn", "author_id": 12639399, "author_profile": "https://Stackoverflow.com/users/12639399", "pm_score": 2, "selected": false, "text": "bundle.getParcelableCompat<T>(BUNDLE_KEY)" }, { "answer_id": 74218855, "author": "Sweeper", "a...
2022/10/27
[ "https://Stackoverflow.com/questions/74218584", "https://Stackoverflow.com", "https://Stackoverflow.com/users/619673/" ]
74,218,586
<p>I have been trying to do error handling so that if someone just hit enter and didnt input a value it would ask for a proper value. It appears that just pressing enter returns a value via readline although i cant determine what value here is my code which is supposed to handle null values</p> <pre><code> public static string StringTester(string? input) { string output; if (input != null) { Console.WriteLine(&quot;Not null nani&quot;); } if (input == null) { Console.WriteLine(&quot;Please input valid value&quot;); output = StringTester(Console.ReadLine()); } else if (input.Contains('\n') ^ input.Contains(' ') ^ input.Contains('\r')) { Console.WriteLine(&quot;Please input valid value&quot;); output = StringTester(Console.ReadLine()); } else { output = input; } return output; } </code></pre> <p>I tried to find the return value on google and through the documentation by microsoft on readline however none came up. I thought maybe it is reading a new line so i added a new line into the error handling.</p>
[ { "answer_id": 74218616, "author": "jmcilhinney", "author_id": 584183, "author_profile": "https://Stackoverflow.com/users/584183", "pm_score": 2, "selected": false, "text": "Console.ReadLine" }, { "answer_id": 74218775, "author": "Francesco Giancristofaro", "author_id": 1...
2022/10/27
[ "https://Stackoverflow.com/questions/74218586", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19919407/" ]
74,218,607
<p>I have a df with a column - queue time. It has time values. But the type of these values are str. It might also contain incorrect values like 'abc' or 'email' in it as well. The time values are of the form '10:23', '22:22', '1:1', etc.</p> <p>I want to convert these values to '10:23:00', '22:22:00', '01:01:00' and so on. If it's not a time value and is a string, I want to ignore them.</p> <p>I tried to apply this :</p> <pre><code>df['queue time'] = pd.to_datetime(df['queue time'].str.split(':', expand=True) .apply(lambda col: col.str.zfill(2)) .fillna('00') .agg(':'.join, axis=1)).dt.time </code></pre> <p>But it gives an error when it encounters values like 'abc' or 'email' and gives the following error : ParserError: Unknown string format: EM:AIL</p> <p>How do I tweak my code. Need some expert help. thanks!</p>
[ { "answer_id": 74218761, "author": "mozway", "author_id": 16343464, "author_profile": "https://Stackoverflow.com/users/16343464", "pm_score": 2, "selected": true, "text": "df['queue time'] = pd.to_datetime(df['queue time'], format='%H:%M', errors='coerce').dt.time\n" }, { "answer...
2022/10/27
[ "https://Stackoverflow.com/questions/74218607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12435792/" ]
74,218,643
<p>I want to somehow chain two web requests such that:</p> <ol> <li>Request A (<code>Observable&lt;void&gt;</code>) is always run.</li> <li>Request B (also <code>Observable&lt;void&gt;</code>) is also always run, after A and even when A completes with errors (like <a href="https://rxjs.dev/api/index/function/finalize" rel="nofollow noreferrer"><code>finalize()</code></a>).</li> <li>If A errors with E<sub>A</sub>, I want the whole pipeline to complete with E<sub>A</sub>.</li> <li>If A succeeds, but B errors with E<sub>B</sub>, I want the whole pipeline to complete with E<sub>B</sub>. <ul> <li>I could also do with the pipeline just succeeding in this case.</li> </ul> </li> <li>If both error, then I want the whole pipeline to complete with E<sub>A</sub>.</li> </ol> <hr /> <p>This is the solution I could come up with, but it feels very clumsy:</p> <pre class="lang-js prettyprint-override"><code>// Changes different parts of backend state in multiple steps, // some of which might fail. const reqA: Observable&lt;void&gt; = this.mutateSystemState(); // Loads &amp; renders the system state, updating the parts that // could be changed. const reqB: Observable&lt;void&gt; = this.updateSystemStateDisplay(); const pipeline = reqA.pipe( catchError(e =&gt; of({ errA: e })), mergeMap(resultA =&gt; reqB.pipe( catchError(e =&gt; of({ errB: e })), map(resultB =&gt; { if (resultA instanceof Object) { throw resultA.errA; } else if (resultB instanceof Object) { throw resultB.errB; } }) )) ); </code></pre>
[ { "answer_id": 74230803, "author": "JSmart523", "author_id": 7158380, "author_profile": "https://Stackoverflow.com/users/7158380", "pm_score": 2, "selected": false, "text": "pipeline$" }, { "answer_id": 74259777, "author": "Eddy Lin", "author_id": 19768317, "author_pr...
2022/10/27
[ "https://Stackoverflow.com/questions/74218643", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1025555/" ]
74,218,671
<p>I would like to do something similar to <code>justify-content:space-around</code> or <code>justify-content:space-between</code>, but with :</p> <ul> <li>x items side by side on the left,</li> <li>y items side by side on the middle,</li> <li>z items side by side on the right.</li> </ul> <p><a href="https://i.stack.imgur.com/2BKTJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2BKTJ.png" alt="enter image description here" /></a></p> <p>It would be simple by wrap elements but I can't because these items (<code>.left</code>, <code>.middle</code>, <code>.right</code>) would be checkboxes influencing the styles of elements below (and there is no well-supported parent selector).</p> <p>I found <a href="https://stackoverflow.com/a/8539107/17684809">this answer</a> to emulate <code>first-of-class</code> for the right side, but didn't find something similar to emulate <code>last-of-class</code>.</p> <pre><code>/* emulate first-of-class */ .container&gt;.right { margin-left: auto; } .container&gt;.right~.right { margin-left: unset; } </code></pre> <p>Here is a snippet of my current attempt :</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>.container { display: flex; flex-wrap: wrap; } input { display: none; } label { padding: 0 10px; background-color: orange; } .container&gt;.right { margin-left: auto; } .container&gt;.right~.right { margin-left: unset; } #check-center { width: 100%; text-align: center; } [ lang ] { display: none; } [ name="language" ]:checked+label { background-color: pink; } [ value="en" ]:checked ~ [ lang="en" ], [ value="en" ]:checked ~* [ lang="en" ], [ value="fr" ]:checked ~ [ lang="fr" ], [ value="fr" ]:checked ~* [ lang="fr" ], [ value="es" ]:checked ~ [ lang="es" ], [ value="es" ]:checked ~* [ lang="es" ] { display: block; } /*for codepen*/ html[ lang ] { display: block; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="container"&gt; &lt;input type="radio" name="left-field" id="A" /&gt; &lt;label class="left" for="A"&gt;A&lt;/label&gt; &lt;input type="radio" name="left-field" id="B" /&gt; &lt;label class="left" for="B"&gt;B&lt;/label&gt; &lt;input type="radio" name="middle-field" id="C" /&gt; &lt;label class="middle" for="C"&gt;C&lt;/label&gt; &lt;input type="radio" name="middle-field" id="D" /&gt; &lt;label class="middle" for="D"&gt;D&lt;/label&gt; &lt;input type="radio" name="middle-field" id="E" /&gt; &lt;label class="middle" for="E"&gt;E&lt;/label&gt; &lt;input type="radio" name="language" id="enLang" value="en" /&gt; &lt;label class="right" for="enLang"&gt;en&lt;/label&gt; &lt;input type="radio" name="language" id="frLang" value="fr" /&gt; &lt;label class="right" for="frLang"&gt;fr&lt;/label&gt; &lt;input type="radio" name="language" id="esLang" value="es" /&gt; &lt;label class="right" for="esLang"&gt;es&lt;/label&gt; &lt;div id="check-center"&gt;|&lt;/div&gt; &lt;div lang="en"&gt;EN selected&lt;/div&gt; &lt;div lang="fr"&gt;FR selected&lt;/div&gt; &lt;div lang="es"&gt;ES selected&lt;/div&gt; &lt;div&gt; &lt;div lang="en"&gt;EN selected&lt;/div&gt; &lt;div lang="fr"&gt;FR selected&lt;/div&gt; &lt;div lang="es"&gt;ES selected&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <p>I could cheat by adding a specific class to the last left element to apply <code>margin-right:auto;</code> and the first right element to apply <code>margin-left:auto;</code> in a <code>display:flex</code> container but it's not the best and even then, the middle items wouldn't be centered if the left and right parts have not the same width.</p> <p><div class="snippet" data-lang="js" data-hide="true" data-console="true" data-babel="false"> <div class="snippet-code snippet-currently-hidden"> <pre class="snippet-code-css lang-css prettyprint-override"><code>.container { display: flex; flex-wrap: wrap; } input { display: none; } label { padding: 0 10px; background-color: orange; } .cheat.left { margin-right: auto; } .cheat.right { margin-left: auto; } #check-center { width: 100%; text-align: center; } [ lang ] { display: none; } [ name="language" ]:checked+label { background-color: pink; } [ value="en" ]:checked ~ [ lang="en" ], [ value="en" ]:checked ~* [ lang="en" ], [ value="fr" ]:checked ~ [ lang="fr" ], [ value="fr" ]:checked ~* [ lang="fr" ], [ value="es" ]:checked ~ [ lang="es" ], [ value="es" ]:checked ~* [ lang="es" ] { display: block; } /*for codepen*/ html[ lang ] { display: block; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="container"&gt; &lt;input type="radio" name="left-field" id="A" /&gt; &lt;label class="left" for="A"&gt;A&lt;/label&gt; &lt;input type="radio" name="left-field" id="B" /&gt; &lt;label class="cheat left" for="B"&gt;B&lt;/label&gt; &lt;input type="radio" name="middle-field" id="C" /&gt; &lt;label class="middle" for="C"&gt;C&lt;/label&gt; &lt;input type="radio" name="middle-field" id="D" /&gt; &lt;label class="middle" for="D"&gt;D&lt;/label&gt; &lt;input type="radio" name="middle-field" id="E" /&gt; &lt;label class="middle" for="E"&gt;E&lt;/label&gt; &lt;input type="radio" name="language" id="enLang" value="en" /&gt; &lt;label class="cheat right" for="enLang"&gt;en&lt;/label&gt; &lt;input type="radio" name="language" id="frLang" value="fr" /&gt; &lt;label class="right" for="frLang"&gt;fr&lt;/label&gt; &lt;input type="radio" name="language" id="esLang" value="es" /&gt; &lt;label class="right" for="esLang"&gt;es&lt;/label&gt; &lt;div id="check-center"&gt;|&lt;/div&gt; &lt;div lang="en"&gt;EN selected&lt;/div&gt; &lt;div lang="fr"&gt;FR selected&lt;/div&gt; &lt;div lang="es"&gt;ES selected&lt;/div&gt; &lt;div&gt; &lt;div lang="en"&gt;EN selected&lt;/div&gt; &lt;div lang="fr"&gt;FR selected&lt;/div&gt; &lt;div lang="es"&gt;ES selected&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <p>My current goal is to display elements depending on the selected language even if JavaScript is disabled, so I'm looking for a solution <strong>without JavaScript</strong>.</p> <p>As <a href="https://stackoverflow.com/users/20357737/hackerfrosch">HackerFrosch</a> suggested, I tried to solve it by using a grid but I'm not used to it, the <code>.middle</code> items are not centered and I did not manage to make the elements below <code>.right</code> divs 100% width as by default.</p> <p><div class="snippet" data-lang="js" data-hide="true" data-console="true" data-babel="false"> <div class="snippet-code snippet-currently-hidden"> <pre class="snippet-code-css lang-css prettyprint-override"><code>.container { display: grid; grid-template-columns: auto 1fr auto auto auto 1fr auto auto; } input { display: none; } label { padding: 0 10px; background-color: orange; width: fit-content; } .cheat.left { margin-right: auto; } .cheat.right { margin-left: auto; } #check-center { width: 100%; text-align: center; } [ lang] { display: none; } [ name="language"]:checked+label { background-color: pink; } [ value="en"]:checked~[ lang="en"], [ value="en"]:checked~* [ lang="en"], [ value="fr"]:checked~[ lang="fr"], [ value="fr"]:checked~* [ lang="fr"], [ value="es"]:checked~[ lang="es"], [ value="es"]:checked~* [ lang="es"] { display: block; } /*for codepen*/ html[ lang] { display: block; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="container"&gt; &lt;input type="radio" name="left-field" id="A" /&gt; &lt;label class="left" for="A"&gt;A&lt;/label&gt; &lt;input type="radio" name="left-field" id="B" /&gt; &lt;label class="cheat left" for="B"&gt;B&lt;/label&gt; &lt;input type="radio" name="middle-field" id="C" /&gt; &lt;label class="middle" for="C"&gt;C&lt;/label&gt; &lt;input type="radio" name="middle-field" id="D" /&gt; &lt;label class="middle" for="D"&gt;D&lt;/label&gt; &lt;input type="radio" name="middle-field" id="E" /&gt; &lt;label class="middle" for="E"&gt;E&lt;/label&gt; &lt;input type="radio" name="language" id="enLang" value="en" /&gt; &lt;label class="cheat right" for="enLang"&gt;en&lt;/label&gt; &lt;input type="radio" name="language" id="frLang" value="fr" /&gt; &lt;label class="right" for="frLang"&gt;fr&lt;/label&gt; &lt;input type="radio" name="language" id="esLang" value="es" /&gt; &lt;label class="right" for="esLang"&gt;es&lt;/label&gt; &lt;div lang="en"&gt;EN selected&lt;/div&gt; &lt;div lang="fr"&gt;FR selected&lt;/div&gt; &lt;div lang="es"&gt;ES selected&lt;/div&gt; &lt;div&gt; &lt;div lang="en"&gt;EN selected&lt;/div&gt; &lt;div lang="fr"&gt;FR selected&lt;/div&gt; &lt;div lang="es"&gt;ES selected&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div id="check-center"&gt;|&lt;/div&gt;</code></pre> </div> </div> </p> <p>Is there a way to achieve this?</p>
[ { "answer_id": 74275227, "author": "HackerFrosch", "author_id": 20357737, "author_profile": "https://Stackoverflow.com/users/20357737", "pm_score": 2, "selected": false, "text": "css grid layout" }, { "answer_id": 74378882, "author": "Anton", "author_id": 15545116, "a...
2022/10/27
[ "https://Stackoverflow.com/questions/74218671", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17684809/" ]
74,218,673
<p>I want to get the value of a MySQL variable (example: <code>max_allowed_packet</code>) via jdbcTemplate. is this possible? if so, how ?</p> <p>In SQL, I can do <code>SHOW VARIABLES LIKE 'max_allowed_packet';</code> but how to do this via JDBCTemplate ?</p>
[ { "answer_id": 74219475, "author": "ali4j", "author_id": 2062407, "author_profile": "https://Stackoverflow.com/users/2062407", "pm_score": 1, "selected": false, "text": "public List<Variable> findAllVariables() {\n List<Variable> result = jdbcTemplate.query(\"SHOW GLOBAL VARIABLES\", ...
2022/10/27
[ "https://Stackoverflow.com/questions/74218673", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2715083/" ]
74,218,692
<p>The screen replicates a video call screen.Please see the image.</p> <p><a href="https://i.stack.imgur.com/JOqPQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JOqPQ.png" alt="screenshot" /></a>.</p> <ul> <li>There are 2 boxes - green and black. <ul> <li>Green box - Remote camera view.</li> <li>Black box is local camera view .</li> </ul> </li> </ul> <p>What I need is when clicked local camera view (black box) , it should expand to max size and the green box to take size of black box and bring to front. The functionality is exactly like a video call screen view switching. How can i achieve this size and order with a smooth transition .</p>
[ { "answer_id": 74219475, "author": "ali4j", "author_id": 2062407, "author_profile": "https://Stackoverflow.com/users/2062407", "pm_score": 1, "selected": false, "text": "public List<Variable> findAllVariables() {\n List<Variable> result = jdbcTemplate.query(\"SHOW GLOBAL VARIABLES\", ...
2022/10/27
[ "https://Stackoverflow.com/questions/74218692", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16382125/" ]
74,218,708
<p>I want to get the standard deviation of specific columns in a dataframe and store those means in a list in R.</p> <p>The specific variable names of the columns are stored in a vector. For those specific variables (depends on user input) I want to calculate the standard deviation and store those in a list, over which I can loop then to use it in another part of my code.</p> <p>I tried as follows, e.g.:</p> <pre><code>specific_variables &lt;- c(&quot;variable1&quot;, &quot;variable2&quot;) # can be of a different length depending on user input data &lt;- data.frame(...) # this is a dataframe with multiple columns, of which &quot;variable1&quot; and &quot;variable2&quot; are both columns from sd_list &lt;- 0 # empty variable for storage purposes # for loop over the variables for (i in length(specific_variables)) { sd_list[i] &lt;- sd(data$specific_variables[i], na.rm = TRUE) } print(sd_list) </code></pre> <p>I get an error.</p> <p>Second attempt using colSds and sapply:</p> <pre><code>colSds(data[sapply(specific_variables, na.rm = TRUE)]) </code></pre> <p>But the colSds function doesn't work (anymore?).</p> <p>Ideally, I'd like to store those the standard deviations from certain column names into a list.</p>
[ { "answer_id": 74219475, "author": "ali4j", "author_id": 2062407, "author_profile": "https://Stackoverflow.com/users/2062407", "pm_score": 1, "selected": false, "text": "public List<Variable> findAllVariables() {\n List<Variable> result = jdbcTemplate.query(\"SHOW GLOBAL VARIABLES\", ...
2022/10/27
[ "https://Stackoverflow.com/questions/74218708", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20279847/" ]
74,218,713
<p>Let's say I want to hide container's horizontal content, but at the same time time I want to translate child elements. Adding <code>overflow-x: hidden;</code> to the parent causes it to clip vertically translated children too. Why does this happen and how can I work around it?</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>.content{ margin: 1rem; } .rail { display: flex; padding: 0.5rem; background: #EEE; overflow-x: hidden; } .card { padding: 1rem; border: 1px solid gray; background: #FFF; } .card:hover { transform: translate3d(0px, -1.5rem, 0px); }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="content"&gt; &lt;div class="rail"&gt; &lt;div class="card"&gt;CONTENT&lt;/div&gt; &lt;/div&gt; &lt;/div</code></pre> </div> </div> </p>
[ { "answer_id": 74219520, "author": "Sigurd Mazanti", "author_id": 14776809, "author_profile": "https://Stackoverflow.com/users/14776809", "pm_score": 2, "selected": true, "text": ".content {\n margin: 1rem;\n}\n\n.rail {\n display: flex;\n padding: 0.5rem;\n background: #EEE;\n}\n\n....
2022/10/27
[ "https://Stackoverflow.com/questions/74218713", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19458784/" ]
74,218,746
<p>Is there any way to solve this? I am practicing SQL and I don't know how to do this.</p> <p>Image table</p> <pre><code>---------------------------- | prdctCode | imgPath | | P0003 | P0003-1.jpg | | P0003 | P0003-2.jpg | | P0003 | P0003-3.jpg | | P0004 | P0004-1.jpg | | P0004 | P0004-2.jpg | | P0004 | P0004-3.jpg | ---------------------------- </code></pre> <p>Product table</p> <pre><code>------------------------- | prdctCode | prdctName | | P0003 | Hand Bag | | P0004 | Pencil | ------------------------- </code></pre> <p>What I get</p> <pre><code>--------------------------------------- | prdctCode | prdctName | imgPath | | P0003 | Hand Bag | P0003-1.jpg | | P0003 | Hand Bag | P0003-2.jpg | | P0003 | Hand Bag | P0003-3.jpg | | P0004 | Pencil | P0004-1.jpg | | P0004 | Pencil | P0004-2.jpg | | P0004 | Pencil | P0004-3.jpg | --------------------------------------- </code></pre> <p>Expected output</p> <pre><code>-------------------------------------------------------------------- | prdctCode | prdctName | imgPath1 | imgPath2 | imgPath3 | | P0003 | Hand Bag | P0003-1.jpg | P0003-2.jpg | P0003-3.jpg | | P0004 | Pencil | P0004-1.jpg | P0004-2.jpg | P0004-3.jpg | -------------------------------------------------------------------- </code></pre> <p>This is my code</p> <pre><code> select prdTbl.prdctCode, prdTbl.prdctName, imgTbl.imgPath from [product_tbl]prdTbl left join [image_tbl]imgTbl on prdTbl.prdctCode = imgTbl.prdctCode </code></pre> <p>I'm not sure if this is possible.</p>
[ { "answer_id": 74219511, "author": "Delta32000", "author_id": 12939087, "author_profile": "https://Stackoverflow.com/users/12939087", "pm_score": -1, "selected": false, "text": "CREATE TABLE #TempAppointmentTable (\n UniqueID VARCHAR(MAX),\n VAL nvarchar(500)\n);\n \nINSERT INTO...
2022/10/27
[ "https://Stackoverflow.com/questions/74218746", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20066177/" ]
74,218,773
<p>I have ElasticSearch 7.16.2 cluster running with three nodes (2 master , 1 Voting node). An index has two primary shards and two replicas, and on restarting a node, both primary shards move to single node. How to restrict index in a nodes to have one primary shard and one replica each.</p>
[ { "answer_id": 74218940, "author": "Amit", "author_id": 4039431, "author_profile": "https://Stackoverflow.com/users/4039431", "pm_score": 2, "selected": true, "text": "PUT /_cluster/settings\n{\n \"persistent\":{\n \"cluster.routing.allocation.enable\": \"all\"\n }\n}\n" }, { ...
2022/10/27
[ "https://Stackoverflow.com/questions/74218773", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6925954/" ]
74,218,782
<p>This is a well working open-close script. What I would like to do is to have another text appear 15 minutes before closing time, saying that we are closing soon. Could you help me to complete the code?</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code> var a = document.getElementById("telefon"); var d = new Date(); var n = d.getDay(); var now = d.getHours() + "." + d.getMinutes(); var telefonweekdays = { 0: null, //Sunday 1: [8.30, 16.30], 2: [8.30, 16.30], 3: [8.30, 18.30], 4: [8.30, 16.30], 5: [8.30, 16.30], 6: null //Saturday }; var telefondayWorkingHours = telefonweekdays[n]; //Today working hours. if null we are close if (telefondayWorkingHours &amp;&amp; (now &gt; telefondayWorkingHours[0] &amp;&amp; now &lt; telefondayWorkingHours[1])) { a.innerHTML = "Most nyitva."; a.style.backgroundColor = '#e2efd9'; a.style.color = '#538135'; a.style.fontWeight = 'bold'; a.style.padding = '0 4px'; a.style.borderRadius = '3px'; a.style.marginLeft ='5px'; } else { a.innerHTML = "Most zárva."; a.style.backgroundColor = '#efd9df'; a.style.color = '#c91f41'; a.style.fontWeight = 'bold'; a.style.padding = '0 4px'; a.style.borderRadius = '3px'; a.style.marginLeft ='5px'; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;span id="telefon"&gt; &lt;/span&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74218940, "author": "Amit", "author_id": 4039431, "author_profile": "https://Stackoverflow.com/users/4039431", "pm_score": 2, "selected": true, "text": "PUT /_cluster/settings\n{\n \"persistent\":{\n \"cluster.routing.allocation.enable\": \"all\"\n }\n}\n" }, { ...
2022/10/27
[ "https://Stackoverflow.com/questions/74218782", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20319752/" ]
74,218,783
<p>I have two data frames:</p> <pre><code>df1 &lt;- data.frame(Q1 = rep(c(0, 1), 3), Q2 = rep(c(1, 0), 3), Q3 = rep(1, 6)) df2 &lt;- data.frame(Q1 = rep(c(0, 1, 2), 2), Q2 = rep(c(2, 1, 0), 2), Q3 = c(rep(1, 3), rep(2, 3))) &gt; df1 Q1 Q2 Q3 1 0 1 1 2 1 0 1 3 0 1 1 4 1 0 1 5 0 1 1 6 1 0 1 &gt; df2 Q1 Q2 Q3 1 0 2 1 2 1 1 1 3 2 0 1 4 0 2 2 5 1 1 2 6 2 0 2 </code></pre> <p>Now, I want to create a new data frame based on these two data frames, and fill the entries based on the following conditions:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>new entry</th> <th>condition</th> </tr> </thead> <tbody> <tr> <td>6</td> <td><code>if(df1 == 1 &amp; df2 == 2)</code></td> </tr> <tr> <td>5</td> <td><code>if(df1 == 1 &amp; df2 == 1)</code></td> </tr> <tr> <td>4</td> <td><code>if(df1 == 1 &amp; df2 == 0)</code></td> </tr> <tr> <td>3</td> <td><code>if(df1 == 0 &amp; df2 == 0)</code></td> </tr> <tr> <td>2</td> <td><code>if(df1 == 0 &amp; df2 == 1)</code></td> </tr> <tr> <td>1</td> <td><code>if(df1 == 0 &amp; df2 == 2)</code></td> </tr> </tbody> </table> </div> <p>My problem is that I don't know how to run through both data frames at the same time to modify them or create a new data frame. My poor attempt looks like:</p> <pre><code>df3 &lt;- modify(df1, function(x) ifelse(x == 1 &amp; df2[x] == 2, 6, ifelse(x == 1 &amp; df2[x] == 1, 5, ifelse(x == 1 &amp; df2[x] == 0, 4, ifelse(x == 0 &amp; df2[x] == 0, 3, ifelse(x == 0 &amp; df2[x] == 1, 2, 1)))))) </code></pre> <p>I know that this would never work, but this is the best I could manage. Does anyone know how to solve this? Thanks a lot!</p>
[ { "answer_id": 74218940, "author": "Amit", "author_id": 4039431, "author_profile": "https://Stackoverflow.com/users/4039431", "pm_score": 2, "selected": true, "text": "PUT /_cluster/settings\n{\n \"persistent\":{\n \"cluster.routing.allocation.enable\": \"all\"\n }\n}\n" }, { ...
2022/10/27
[ "https://Stackoverflow.com/questions/74218783", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20291515/" ]
74,218,797
<p>I am dealing with a simple premise that questions viewport and based on that i am returning different aspectRatios. Now, for some reason i always have else return as true and then millisecond later the viewport gets validated. The result is that i am picking 2 aspect ratios and that makes me download additional image, which presents as unnecessary. I am wondering if there is a way around it, or to write it differently?</p> <pre><code>const getResponsiveAspectRatio = (): { s: ValidRatios m: ValidRatios l: ValidRatios } =&gt; { if (viewport?.isWrapperWidthAndUp) { return { s: &quot;4-3&quot;, m: &quot;4-3&quot;, l: &quot;4-3&quot; } } else if (viewport?.isLargeDesktopAndUp) { return { s: &quot;1-1&quot;, m: &quot;1-1&quot;, l: &quot;1-1&quot; } } else if (viewport?.isDesktopAndUp) { return { s: &quot;3-4&quot;, m: &quot;3-4&quot;, l: &quot;3-4&quot; } } else if (viewport?.isTabletAndUp) { return { s: &quot;3-4&quot;, m: &quot;3-4&quot;, l: &quot;3-4&quot; } } else { return { s: &quot;1-1&quot;, m: &quot;1-1&quot;, l: &quot;1-1&quot; } } } </code></pre>
[ { "answer_id": 74218953, "author": "NineBerry", "author_id": 101087, "author_profile": "https://Stackoverflow.com/users/101087", "pm_score": 3, "selected": true, "text": "const getResponsiveAspectRatio = (): {\n s: ValidRatios\n m: ValidRatios\n l: ValidRatios\n } => {\n\n i...
2022/10/27
[ "https://Stackoverflow.com/questions/74218797", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19505157/" ]
74,218,815
<p>I want to assign a value of the input field to a variable but seems like it's not working for me can someone please help me to achieve this?</p> <pre class="lang-js prettyprint-override"><code>let username; cy.get(&quot;[id='dto.username']&quot;).invoke('val').then(val =&gt; { username = val; cy.log('username identified: ' + username); // this displays correctly return username; }); cy.log('Returned username :' + username); // this doesnt contains a value its undifined </code></pre> <p>I'm trying to assign it to a variable because I have to send an API request outside of the function.</p>
[ { "answer_id": 74219214, "author": "Nichola Walker", "author_id": 19939224, "author_profile": "https://Stackoverflow.com/users/19939224", "pm_score": 2, "selected": false, "text": ".then()" }, { "answer_id": 74219542, "author": "user9847788", "author_id": 10628282, "a...
2022/10/27
[ "https://Stackoverflow.com/questions/74218815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9933706/" ]
74,218,834
<p>I need to write a query that sums the values of all possible permutations and shows only one row for the result. I also need to mention that table is stored as an array and that number of items in the column table can be bigger or smaller than 3, for example, x,y, y,x or o,p,q,r, p,q,r,o and so on.</p> <p>I tried with a hardcoded query but seems like there are too much of different possibilities that can show up.</p> <pre><code> SELECT case when replace(replace(replace(cast(json_format(cast(ARRAY [table_list] as json)) as varchar), '[[&quot;', ''), '&quot;]]'), '&quot;,&quot;',', ') = 'a,b' or replace(replace(replace(cast(json_format(cast(ARRAY [table_list] as json)) as varchar), '[[&quot;', ''), '&quot;]]'), '&quot;,&quot;',', ') = 'b,a' then 'a,b' when replace(replace(replace(cast(json_format(cast(ARRAY [table_list] as json)) as varchar), '[[&quot;', ''), '&quot;]]'), '&quot;,&quot;',', ') = 'c,d' or replace(replace(replace(cast(json_format(cast(ARRAY [table_list] as json)) as varchar), '[[&quot;', ''), '&quot;]]'), '&quot;,&quot;',', ') = 'd,c' then 'c,d' END AS tables_list, SUM(value) AS value FROM my_table GROUP BY 1 </code></pre> <p>I have a table that looks like this:</p> <pre><code> table value a,b,c 10 b,c,a 21 c,b,a 12 a,c,b 13 b,a,c 16 c,a,b 12 d,e,f 15 e,f,d 12 f,e,d 13 d,f,e 16 e,d,f 11 f,d,e 20 ... </code></pre> <p>What I would like to get is to sum all the possible permutations and store it under one table, i.e. for a,b,c (10+21+12+13+16+12) = 84:</p> <pre><code> table value a,b,c 84 d,e,f 87 </code></pre>
[ { "answer_id": 74219214, "author": "Nichola Walker", "author_id": 19939224, "author_profile": "https://Stackoverflow.com/users/19939224", "pm_score": 2, "selected": false, "text": ".then()" }, { "answer_id": 74219542, "author": "user9847788", "author_id": 10628282, "a...
2022/10/27
[ "https://Stackoverflow.com/questions/74218834", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17124865/" ]
74,218,849
<p>Lets say i have som behaviour subject with boolean type. And I want that boolean to be true on init.</p> <pre><code>private _someBool: BehaviorSubject&lt;boolean&gt; = new BehaviorSubject&lt;boolean&gt;(true); get someBool$() { return this._someBool.asObservable(); } </code></pre> <p>But the problem is that when I subscribe to it the value is false and I have no idea why. How can i set default value when this approach does not work?</p>
[ { "answer_id": 74219214, "author": "Nichola Walker", "author_id": 19939224, "author_profile": "https://Stackoverflow.com/users/19939224", "pm_score": 2, "selected": false, "text": ".then()" }, { "answer_id": 74219542, "author": "user9847788", "author_id": 10628282, "a...
2022/10/27
[ "https://Stackoverflow.com/questions/74218849", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16344063/" ]
74,218,850
<p>I have this problem in my snapshot</p> <p>The method '[]' can't be unconditionally invoked because the receiver can be 'null'. Try making the call conditional (using '?.') or adding a null check to the target ('!').</p> <p><a href="https://i.stack.imgur.com/0B2FB.png" rel="nofollow noreferrer">enter image description here</a> <a href="https://i.stack.imgur.com/T439r.png" rel="nofollow noreferrer">enter image description here</a></p> <p><a href="https://i.stack.imgur.com/MMvcd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MMvcd.png" alt="enter image description here" /></a></p> <p><a href="https://i.stack.imgur.com/uHXD2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uHXD2.png" alt="enter image description here" /></a></p> <p>Greetings I hope you are very well, someone could help me, it is my first time creating a mobile app and with firebare.</p> <p>I tried by Var, put ! and nothing, I am not very aware of the error.</p>
[ { "answer_id": 74219214, "author": "Nichola Walker", "author_id": 19939224, "author_profile": "https://Stackoverflow.com/users/19939224", "pm_score": 2, "selected": false, "text": ".then()" }, { "answer_id": 74219542, "author": "user9847788", "author_id": 10628282, "a...
2022/10/27
[ "https://Stackoverflow.com/questions/74218850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20346837/" ]
74,218,886
<p>Just began backend development and got stuck on html tag not recgnized in node js server.</p> <p>I have an assignment to create local http server. When using the content type text and json, it works, but with html it doesnt work.</p> <p>Here is the code</p> <pre><code>const http = require('http'); //CREATE A SERVER wth the HTTP variable const server= http.createServer(function(req,res) { //headers //res.writeHead(200,{&quot;Content-Type&quot;: 'text/plain'}); //res.writeHead(200,{&quot;Content-Type&quot;: &quot;application/json&quot;}); res.writeHead(200,{&quot;Content-Type&quot;:'text/html'}); //send back the response information //res.end(&quot;wELCOME TO MY zURI INTERNSHIP SERVER!!!&quot;); //res.end('{&quot;name&quot;: &quot;Miaro the great&quot;, &quot;College&quot;: &quot; ESPA Vontovorona, Antananarivo&quot;, &quot;Occupation&quot;: &quot;Technical support engineer turned software developer&quot;}'); res.end('&lt;html&gt;&lt;body style=&quot;background:blue; text-align: center; color:orange&quot;&gt; &lt;h1&gt;&lt;marquee&gt;Welcome To THIS CLASS YALL&lt;/marquee&gt;&lt;/h1&gt; &lt;p&gt;HOW'S IT GOING?&lt;/p&gt; &lt;/body&gt;&lt;/html&gt;'); }); //creating a port server.listen(4000,'localhost'); console.log(&quot;GREAT DUDE! YOU HAVE CREATED A SERVER!!!!&quot;); </code></pre> <p>The error is for sure in the function res.end() arguments but I tried '' and &quot;&quot; but nothing works. Below is an example of error in VS CODE.</p> <pre><code>S D:\dwz\bosyz\zuri\tasks AND RESSOURCES\backend nodejs\wk05\portfolio&gt; node server.js D:\dwz\bosyz\zuri\tasks AND RESSOURCES\backend nodejs\wk05\portfolio\server.js:14 res.end('&lt;html&gt;&lt;body style=&quot;background:blue; text-align: center; color:orange&quot;&gt; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Invalid or unexpected token at Object.compileFunction (node:vm:360:18) at wrapSafe (node:internal/modules/cjs/loader:1084:15) at Module._compile (node:internal/modules/cjs/loader:1119:27) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10) at Module.load (node:internal/modules/cjs/loader:1033:32) at Function.Module._load (node:internal/modules/cjs/loader:868:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:22:47 PS D:\dwz\bosyz\zuri\tasks AND RESSOURCES\backend nodejs\wk05\portfolio&gt; </code></pre> <p>Tried to change the html tags, the delimiters '' and &quot;&quot;, or formatting the texts.</p>
[ { "answer_id": 74219214, "author": "Nichola Walker", "author_id": 19939224, "author_profile": "https://Stackoverflow.com/users/19939224", "pm_score": 2, "selected": false, "text": ".then()" }, { "answer_id": 74219542, "author": "user9847788", "author_id": 10628282, "a...
2022/10/27
[ "https://Stackoverflow.com/questions/74218886", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20148928/" ]
74,218,924
<p>I have three <strong>different</strong> Dates, in this format:</p> <pre><code>long firstDate = System.currentTimeMillis(); long secondDate = System.currentTimeMillis(); long thirdDate = System.currentTimeMillis(); </code></pre> <p>The <em>firstDate</em> is the starting point.</p> <p>I want the seconds + milliseconds that have passed between the starting point and to the others.</p> <p>Example:</p> <blockquote> <p>firstDate = 0.000</p> </blockquote> <blockquote> <p>secondDate= 1.234</p> <p>thirdDate = 2.345</p> </blockquote>
[ { "answer_id": 74219009, "author": "Tobb", "author_id": 1054021, "author_profile": "https://Stackoverflow.com/users/1054021", "pm_score": 1, "selected": false, "text": "final long totalDiffInMillis = thirdDate - firstDate;\nfinal long diffSeconds = totalDiffInMillis / 1000;\nfinal long d...
2022/10/27
[ "https://Stackoverflow.com/questions/74218924", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17658771/" ]
74,218,933
<p>We currently use the PhantomJS executable for two things in our Java project:</p> <ol> <li>Create a PDF file from a given <code>String html</code> we get from our database (for which we write the String to a temp file first)</li> <li>Create a screenshot of a given Widget-Object (for which we have an open HTML page on the front-end)</li> </ol> <p>Since PhantomJS hasn't been updated for a few years, I'm about to change it to a headless Chromium method instead, which has the options <code>--print-to-pdf</code> and <code>--screenshot</code> for options 1 and 2.</p> <p>Option 2 isn't really relevant since we have a page, but for option 1 it would be nice if we could directly use the chromium command-line with the given String. Right now with PhantomJS, we convert the String to a temp file, and then use the executable to generate the actual PDF output file. I can of course do the same with the headless Chromium executable, but since I'm changing it right now anyway, it would be nice if the 'String to temp HTML file' step wouldn't be necessary for creating the output PDF file, since we already have the page in memory anyway after retrieving it from the database.</p> <p>From what I've seen, the Chromium executable is usually run for either a HTML file to PDF file:</p> <pre><code>chromium --headless -disable-gpu --print-to-pdf=&quot;C:/path/to/output-file.pdf&quot; C:/path/to/input-file.html </code></pre> <p>Or for a HTML page to PDF file:</p> <pre><code>chromium --headless -disable-gpu --print-to-pdf=&quot;C:/path/to/output-file.pdf&quot; https://www.google.com/ </code></pre> <p>I couldn't really find the docs for the <code>chrome</code>/<code>chromium</code> executable (although I have been able to find <a href="https://source.chromium.org/chromium/chromium/src/+/main:headless/app/headless_shell_switches.cc;bpv=0;bpt=1" rel="nofollow noreferrer">the list of command options in the source code</a>), so maybe there are more options besides these two above? (If anyone has a link to the docs, that would be great as well.)<br /> If not, I guess I'll just use a temp file as we did before with PhantomJS.</p>
[ { "answer_id": 74219009, "author": "Tobb", "author_id": 1054021, "author_profile": "https://Stackoverflow.com/users/1054021", "pm_score": 1, "selected": false, "text": "final long totalDiffInMillis = thirdDate - firstDate;\nfinal long diffSeconds = totalDiffInMillis / 1000;\nfinal long d...
2022/10/27
[ "https://Stackoverflow.com/questions/74218933", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1682559/" ]
74,218,952
<p><strong>Problem</strong> - The query string parameter value is getting truncated if I have <code>#</code> in the parameter string value.</p> <p>I have a table where I am binding the anchor tag <code>&lt;a/&gt;</code> prop <code>href</code> value like below;</p> <blockquote> <p><code>&lt;a class=&quot;btn btn-primary&quot; href=&quot;/FileDetails/DownloadBlob?dirName=@data.FolderName&amp;blobName=@data.FileName&quot;&gt;</code></p> </blockquote> <p>after binding on browser:</p> <blockquote> <p><code>&lt;a class=&quot;btn btn-primary&quot; href=&quot;/FileDetails/DownloadBlob?dirName=RSHSYNCADE&amp;amp;blobName=J231132 anyfoostringnjectable barfoorBstringch #212422627, string Batch #145876V.pdf&quot;&gt;</code></p> </blockquote> <p>In the above anchor tag for <code>href</code> prop value I am setting a Controller/Action along with the query string parameters <code>dirName</code> and <code>blobName</code>.</p> <p>But when the control comes to the specified action method of the controller it truncates the second param value from <code>#</code> means I can only see a value upto <code>J231132 anyfoostringnjectable barfoorBstringch</code>.</p> <p>While trying to find a fix on internet, I am unable to find a proper solution which fit to my scenario till now.</p> <p>Can anyone please help me to understand what causing this issue and what would be the fix for these kind of issues?</p>
[ { "answer_id": 74219472, "author": "Ruikai Feng", "author_id": 18177989, "author_profile": "https://Stackoverflow.com/users/18177989", "pm_score": 1, "selected": false, "text": "asp-route-yourkey" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74218952", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4940017/" ]
74,218,960
<p>all. I'm new to SpringBoot. And now I hope to naming a thread based on the parameter.</p> <p>Take a simple example, I'm currently using <code>@Async</code> notation to create an Asynchronous Method</p> <pre><code>@PostMapping public void requestMethod(@RequestBody String id){ ... asyncMethod(id); } @Async public void asyncMethod(String id){ ... } </code></pre> <p>Once there is a <code>POST</code> request send to <code>requestMethod</code>, the method will create an asynchronous method in a new thread. The name of the thread is the same as the parameter received as <code>id</code>.</p> <p>Because there will be many asynchronous methods in the program. And the asynchronous method will run within in an infinite loop. So, I want to terminate the threads based on their name. But how can I do that?</p> <p>If there is any ambiguous, please let me know. Thanks in advance.</p>
[ { "answer_id": 74219077, "author": "Aid Hadzic", "author_id": 5963060, "author_profile": "https://Stackoverflow.com/users/5963060", "pm_score": 2, "selected": false, "text": "TaskExecutor" }, { "answer_id": 74219231, "author": "Tom Elias", "author_id": 6183889, "autho...
2022/10/27
[ "https://Stackoverflow.com/questions/74218960", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11422407/" ]
74,218,964
<p>I am retrieving a collection from firebase firestore. and it shows in my app. But when I manually change values in firebase it doesn't change in my Apps UI in real time. Changes only occur after a hot reload. I am using the Obx method</p> <p>Here is my modal page</p> <pre><code>StoreModel storeModelFromJson(String str) =&gt; StoreModel.fromJson(json.decode(str)); String storeModelToJson(StoreModel data) =&gt; json.encode(data.toJson()); class StoreModel { StoreModel({ required this.image, required this.name, required this.description, required this.type, }); String image; String name; String description; String type; factory StoreModel.fromJson(Map&lt;String, dynamic&gt; json) =&gt; StoreModel( image: json[&quot;image&quot;], name: json[&quot;Name&quot;], description: json[&quot;description&quot;], type: json[&quot;type&quot;], ); Map&lt;String, dynamic&gt; toJson() =&gt; { &quot;image&quot;: image, &quot;Name&quot;: name, &quot;description&quot;: description, &quot;type&quot;: type, }; } </code></pre> <p>Here's my GetxController class</p> <pre class="lang-dart prettyprint-override"><code>class StoreController extends GetxController{ var storeList = &lt;StoreModel&gt;[].obs; @override void onInit() { fetchRecords(); super.onInit(); } fetchRecords()async{ var records =await FirebaseFirestore.instance.collection('store_products').get(); showProducts(records); } showProducts(QuerySnapshot&lt;Map&lt;String,dynamic&gt;&gt; records) { var listDb = records.docs.map((item) =&gt; StoreModel( image:item['Image'], name: item['Name'], description:item['description'], type: item['type'] ) ).toList(); if(records != null){ storeList.value = listDb; } return storeList; } } </code></pre> <p>And below is where I use Obx</p> <pre class="lang-dart prettyprint-override"><code> Obx(()=&gt; GridView.builder( physics: ScrollPhysics(), shrinkWrap: true, gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, mainAxisSpacing: 10, crossAxisSpacing: 10, childAspectRatio: 2 / 3), itemCount:controller.storeList.length, itemBuilder: (BuildContext context, int index) { return StoreItemWidget( storeItem: controller.storeList[index], ); }, ) ) </code></pre>
[ { "answer_id": 74220320, "author": "double leem", "author_id": 17208314, "author_profile": "https://Stackoverflow.com/users/17208314", "pm_score": 0, "selected": false, "text": "storeList.refresh()" }, { "answer_id": 74238064, "author": "Marsad", "author_id": 12901786, ...
2022/10/27
[ "https://Stackoverflow.com/questions/74218964", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19849699/" ]
74,218,970
<p>I am unable to compare two columns inside a grouped pandas dataframe. I used groupby method to group the fields with respect to two columns</p> <p>I am required to get the list of fields that are not matching with the actual output.</p> <pre><code>file_name | page_no | field_name | value | predicted_value | actual_value ------------------------------------------------------------------------- A 1 a 1 zx zx A 2 b 0 xt xi B 1 a 1 qw qw B 2 b 0 xr xe </code></pre> <p>desired output:</p> <p><strong>b</strong></p> <p>Because <strong>b</strong> is the only field that is causing the mismatch between the two columns</p> <p>The following is my code:</p> <pre><code>groups = df1.groupby(['file_name', 'page_no']) a = pd.DataFrame(columns = ['file_name', 'page_no', 'value']) for name, group in groups: lst = [] if (group[group['predicted_value']] != group[group['actual_value']]): lst = lst.append(group[group['field_name']]) print(lst) </code></pre> <p>I am required to get the list of fields that are not matching with the actual output. Here, I'm trying to store them in a list but I am getting some key error.</p> <p>The error is as follows:</p> <pre><code>KeyError: &quot;None of [Index(['A', '1234'')] are in the [columns]&quot; </code></pre>
[ { "answer_id": 74219151, "author": "jezrael", "author_id": 2901002, "author_profile": "https://Stackoverflow.com/users/2901002", "pm_score": 1, "selected": false, "text": "df1 = df[df['predicted_value'] != df['actual_value']] \n\ns = df.loc[df['predicted_value'] != df['actual_value'], 'f...
2022/10/27
[ "https://Stackoverflow.com/questions/74218970", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20346798/" ]
74,218,985
<p>I have a JSON file abc.json</p> <pre><code>{&quot;value1&quot;:5.0,&quot;value2&quot;:2.5,&quot;value3&quot;:&quot;2019-10-24T15:26:00.000Z&quot;,&quot;modifier&quot;:[],&quot;value4&quot;:{&quot;value41&quot;:{&quot;value411&quot;:5,&quot;value412&quot;:&quot;hey&quot;}}} </code></pre> <p>I can get value2 using this regex</p> <blockquote> <p>sed -E 's/.<em>&quot;value2&quot;:&quot;?([^,&quot;]</em>)&quot;?.*/\1/' abc.json</p> </blockquote> <p>I want to know how I can get values of value411 and value412</p> <p>I don't want to use jq or any other tool as my requirement is to use regex for this.</p>
[ { "answer_id": 74219151, "author": "jezrael", "author_id": 2901002, "author_profile": "https://Stackoverflow.com/users/2901002", "pm_score": 1, "selected": false, "text": "df1 = df[df['predicted_value'] != df['actual_value']] \n\ns = df.loc[df['predicted_value'] != df['actual_value'], 'f...
2022/10/27
[ "https://Stackoverflow.com/questions/74218985", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18148705/" ]
74,219,020
<p>The task:</p> <p>I have list of IPs which needs to be added to the .htaccess files in this format:</p> <pre><code>##ip_access1 Require ip 127.0.0.1 Require ip 127.0.0.2 Require all denied ##ip_access2 </code></pre> <p>The problem:</p> <p>How to append text into .htaccess file with Python? I know how to do this with bash, but I need Python specifically for now.</p> <p>Cases:</p> <ol> <li>If tuple of IPs is empty, find pattern ##ip_access1 ##ip_access2 and delete everything between them including the pattern in the file;</li> <li>If .htaccess file is not empty, append ##ip_access1 &lt;...&gt; ##ip_access2 to the bottom of the file with all IPs;</li> </ol> <p>P.S. Bash implementation.</p> <pre><code>ip_access() { local user=$1 local htaccess=&quot;/var/www/${user}/site/.htaccess&quot; local ips=&quot;$2&quot; # manipulate records in .htaccess [ ! -f &quot;${htaccess}&quot; ] &amp;&amp; touch &quot;${htaccess}&quot; if [ -z &quot;${ips}&quot; ]; then sed -i '/##ip_access1/,/##ip_access2/{d}' &quot;${htaccess}&quot; chown &quot;${user}&quot;:&quot;${user}&quot; &quot;${htaccess}&quot; echo &quot;IP access successfully reset!&quot; exit 0 fi arrip=() for ip in ${ips//,/ }; do arrip+=(&quot;Require ip $ip\n&quot;) done # always inject fresh batch of ips sed -i '/##ip_access1/,/##ip_access2/{d}' &quot;${htaccess}&quot; { echo -e &quot;##ip_access1&quot;;\ echo -e &quot;${arrip:?}&quot; | head -c -1;\ echo -e &quot;Require all denied&quot;;\ echo -e &quot;##ip_access2&quot;; } &gt;&gt; &quot;${htaccess}&quot; chown &quot;${user}&quot;:&quot;${user}&quot; &quot;${htaccess}&quot; echo &quot;IP access successfully set!&quot; } </code></pre>
[ { "answer_id": 74219151, "author": "jezrael", "author_id": 2901002, "author_profile": "https://Stackoverflow.com/users/2901002", "pm_score": 1, "selected": false, "text": "df1 = df[df['predicted_value'] != df['actual_value']] \n\ns = df.loc[df['predicted_value'] != df['actual_value'], 'f...
2022/10/27
[ "https://Stackoverflow.com/questions/74219020", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10223057/" ]