qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,149,335
<p>As the title says, I'm trying to delete &amp; insert records to an Historical Table.</p> <p>The Historical <strong>tbl_b</strong> has to receive records from a <strong>tbl_a</strong>, filtered by the column <em>val_id</em>; but there is a limit of records per each <em>val_id</em>, also it must keep only the most recent ones per <em>val_id</em>.</p> <h5>TBL_A</h5> <ul> <li>It has columns <em><strong>id_val</strong></em>, <em><strong>reg_date</strong></em>, <em><strong>flag</strong></em></li> <li>it has up to date records (constantly, records are inserted on this table).</li> <li>only records with <em>flag=1</em> should be inserted on TBL_B.</li> <li>records are deleted by another scheduled process.</li> </ul> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>val_id</th> <th>reg_date</th> <th>flag</th> </tr> </thead> <tbody> <tr> <td>33</td> <td>2022-10-20 23:00:00</td> <td>1</td> </tr> <tr> <td>22</td> <td>2022-10-20 22:00:01</td> <td>0</td> </tr> <tr> <td>22</td> <td>2022-10-20 22:00:02</td> <td>1</td> </tr> <tr> <td>11</td> <td>2022-10-20 21:00:01</td> <td>1</td> </tr> <tr> <td>11</td> <td>2022-10-20 21:00:02</td> <td>1</td> </tr> <tr> <td>11</td> <td>2022-10-20 21:00:03</td> <td>1</td> </tr> </tbody> </table> </div><h5>TBL_B:</h5> <ul> <li>It has columns <em><strong>id_val</strong></em>, <em><strong>reg_date</strong></em></li> <li>it should store 2 records per <em><strong>id_val</strong></em> and the most recent ones (order by <em><strong>reg_date</strong></em>).</li> <li>it's partitioned monthly, this table will store 150 Million records aprox.</li> </ul> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>val_id</th> <th>reg_date</th> </tr> </thead> <tbody> <tr> <td>11</td> <td>2022-10-19 11:00:01</td> </tr> <tr> <td>11</td> <td>2022-10-19 11:00:02</td> </tr> <tr> <td>22</td> <td>2022-10-19 12:00:01</td> </tr> <tr> <td>22</td> <td>2022-10-19 12:00:02</td> </tr> </tbody> </table> </div><h5>Desired Result on TBL_B:</h5> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>val_id</th> <th>reg_date</th> </tr> </thead> <tbody> <tr> <td>11</td> <td>2022-10-20 21:00:02</td> </tr> <tr> <td>11</td> <td>2022-10-20 21:00:03</td> </tr> <tr> <td>22</td> <td>2022-10-19 12:00:02</td> </tr> <tr> <td>22</td> <td>2022-10-20 22:00:02</td> </tr> <tr> <td>33</td> <td>2022-10-20 23:00:00</td> </tr> </tbody> </table> </div> <p>To approach this, I'm trying to do it in 2 steps:</p> <ol> <li>first delete records from TBL_B, if it's necessary.</li> <li>then insert records from TBL_A, since they are always the most recent ones.</li> </ol> <p>But at this moment I'm stuck trying to filter the records that should be deleted from TBL_B.</p> <p>Link: <a href="http://sqlfiddle.com/#!4/73271c/1" rel="nofollow noreferrer">http://sqlfiddle.com/#!4/73271c/1</a></p> <pre><code>DELETE FROM tbl_b where rowid in ( SELECT rowid FROM (SELECT m.*, ROW_NUMBER() OVER ( PARTITION BY id_val ORDER BY reg_date DESC ) AS rownumb FROM (SELECT h.* FROM tbl_b h LEFT JOIN (SELECT * FROM (SELECT tbl_a.*, ROW_NUMBER() OVER ( PARTITION BY id_val ORDER BY reg_date DESC ) AS seqnum FROM tbl_a WHERE flag = 1) f WHERE f.seqnum &lt;= 2) t ON t.id_val = h.id_val) m) n WHERE n.rownumb &gt; 2 ); </code></pre> <p>Any help is appreciated.</p>
[ { "answer_id": 74553754, "author": "David Nugent", "author_id": 1956886, "author_profile": "https://Stackoverflow.com/users/1956886", "pm_score": 0, "selected": false, "text": "echo \"::set-output...\"" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74149335", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18235355/" ]
74,149,392
<p>My team and I are making a search function with pagination and the base table works fine, even the pagination works fine. The problem is when we use the search function. Upon searching, an error message pops up on the first page: <a href="https://i.stack.imgur.com/r2GyH.png" rel="nofollow noreferrer">Error message on the first page</a>, although the results for the search query shows up. But when you turn to the page 2 of the search query, error message disappears and everything is normal.</p> <p>This is the url of the first page where the error above shows up:</p> <blockquote> <p>project1/index.php/configname/view?name=smith</p> </blockquote> <p>This is the url when you turn to the next page where there are no errors:</p> <blockquote> <p>project1/index.php/configname/view/8?name=smith</p> </blockquote> <p>When we manually insert a zero as before the question mark, no error shows up, like so:</p> <blockquote> <p>project1/index.php/configname/view/0?name=smith</p> </blockquote> <p>We figured it has something to do with the uri segment not showing up on the first page, so we are looking for a solution where the zero will be the default and will be there upon loading the view/searching.</p> <p>here is our config function:</p> <pre><code>public function view() { $data['title'] = 'View'; $config = array(); $search = $this-&gt;input-&gt;get(&quot;name&quot;); $config[&quot;base_url&quot;] = base_url() . &quot;/index.php/configname/view&quot;; $config[&quot;total_rows&quot;] = $this-&gt;Users_model-&gt;get_search_count($search); $config[&quot;per_page&quot;] = 8; $config[&quot;uri_segment&quot;] = 3; if (count($_GET) &gt; 0) $config['suffix'] = '?' . http_build_query($_GET); $config['first_url'] = $config['base_url'].'?'.http_build_query($_GET); $config['full_tag_open'] = '&lt;div class=&quot;pagination&quot;&gt;'; $config['full_tag_close'] = '&lt;/div&gt;'; $config['first_link'] = 'First'; $config['last_link'] = 'Last'; $config['first_tag_open'] = '&lt;li class=&quot;page-item&quot;&gt;&lt;span class=&quot;page-link&quot;&gt;'; $config['first_tag_close'] = '&lt;/span&gt;&lt;/li&gt;'; $config['prev_link'] = '&amp;laquo'; $config['prev_tag_open'] = '&lt;li class=&quot;page-item&quot;&gt;&lt;span class=&quot;page-link&quot;&gt;'; $config['prev_tag_close'] = '&lt;/span&gt;&lt;/li&gt;'; $config['next_link'] = '&amp;raquo'; $config['next_tag_open'] = '&lt;li class=&quot;page-item&quot;&gt;&lt;span class=&quot;page-link&quot;&gt;'; $config['next_tag_close'] = '&lt;/span&gt;&lt;/li&gt;'; $config['last_tag_open'] = '&lt;li class=&quot;page-item&quot;&gt;&lt;span class=&quot;page-link&quot;&gt;'; $config['last_tag_close'] = '&lt;/span&gt;&lt;/li&gt;'; $config['cur_tag_open'] = '&lt;li class=&quot;page-item active&quot;&gt;&lt;a class=&quot;page-link&quot; href=&quot;#&quot;&gt;'; $config['cur_tag_close'] = '&lt;/a&gt;&lt;/li&gt;'; $config['num_tag_open'] = '&lt;li class=&quot;page-item&quot;&gt;&lt;span class=&quot;page-link&quot;&gt;'; $config['num_tag_close'] = '&lt;/span&gt;&lt;/li&gt;'; $this-&gt;pagination-&gt;initialize($config); $page = ($this-&gt;uri-&gt;segment(3)) ? $this-&gt;uri-&gt;segment(3) : 0; $data['list'] = $this-&gt;Users_model-&gt;get_all($config['per_page'], $page, $search); $data['links'] = $this-&gt;pagination-&gt;create_links(); $this-&gt;load-&gt;view('include/header', $data); $this-&gt;load-&gt;view('include/sidetopbar', $data); $this-&gt;load-&gt;view('user/viewloans', $data); } </code></pre> <p>This is our model:</p> <pre><code>function get_all($limit, $start, $st) { $sql = &quot;select * from $this-&gt;tbl where full_name like '%$st%' order by date DESC limit &quot; . $start . &quot;, &quot; . $limit; $query = $this-&gt;db-&gt;query($sql); return $query-&gt;result(); } function get_search_count($st = NULL) { if ($st == &quot;NULL&quot;) $st = &quot;&quot;; $sql = &quot;select * from $this-&gt;tbl where full_name like '%$st%'&quot;; $query = $this-&gt;db-&gt;query($sql); return $query-&gt;num_rows(); } </code></pre> <p>This is the line in which the error was referring to for our Pagination.php on CI, but we didn't change anything from it:</p> <pre><code>if ($this-&gt;prefix !== '' OR $this-&gt;suffix !== '') { $this-&gt;cur_page = str_replace(array($this-&gt;prefix, $this-&gt;suffix), '', $this-&gt;cur_page); } </code></pre> <p>TL;DR: Error message shows up on the first page upon using our search function. We just want to make it disappear as the search queries properly work, just the error makes us mad.</p>
[ { "answer_id": 74553754, "author": "David Nugent", "author_id": 1956886, "author_profile": "https://Stackoverflow.com/users/1956886", "pm_score": 0, "selected": false, "text": "echo \"::set-output...\"" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74149392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20219333/" ]
74,149,404
<p>I have no idea what to do. Whenever I try to insert <code>read_num[size]</code> it does not work. My debugger shows the value as 0. I want to take a value for the size of the array from the user. Then I want to use the value in another file.</p> <p>So what I want to do is, I will do a printf to ask the user to give a value so that I can pass it as the size of the array. I did and it didn't work. Then I decided to write a direct value [36]. But I want user to insert 36.</p> <p>This is what I have tried:</p> <p>main.c</p> <pre><code>int main(void) { int numbers[ARR_SIZE] = { 0 }; int size = 36; // I am doing directly but I want to take the value from the user but it just does not work. double mean = 0; double stddev = 0; read_array(size); } </code></pre> <p>file.c</p> <pre><code>int read_array(int a[36]) //placing 36 directly, I want it to be placed by the user { int num_read[36]; int i = 0; // I have no clue whats i am doing. I just want to pass the value from the user. while (i &lt; a) { printf(&quot;Enter number&quot;); scanf_s(&quot;%d&quot;, &amp;num_read[i]); ++i; } } </code></pre> <p>header file</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;math.h&gt; #define ARR_SIZE 100 int read_array(int arr[ARR_SIZE]); double calc_mean(int arr[], int size); double calc_stddev(int arr[], int size); void print_array(int arr[], int size); </code></pre>
[ { "answer_id": 74553754, "author": "David Nugent", "author_id": 1956886, "author_profile": "https://Stackoverflow.com/users/1956886", "pm_score": 0, "selected": false, "text": "echo \"::set-output...\"" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74149404", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20298167/" ]
74,149,409
<p>From the URL column I need keep word &quot;export&quot; or &quot;import&quot; if it exist in the string</p> <pre><code>df &lt;- data.frame (URL = c(&quot;export-180100-from-ec-to-us&quot;, &quot;import-420340-to-ir-from-es&quot;,&quot;export&quot;,&quot;Product&quot;), X = c(100,200,50,600)) URL X 1 export-180100-from-ec-to-us 100 2 import-420340-to-ir-from-es 200 3 export 50 4 Product 600 </code></pre> <p>Expected output</p> <pre><code> URL X 1 export 100 2 import 200 3 export 50 4 Product 600 </code></pre>
[ { "answer_id": 74149485, "author": "onyambu", "author_id": 8380272, "author_profile": "https://Stackoverflow.com/users/8380272", "pm_score": 1, "selected": true, "text": "sub" }, { "answer_id": 74155275, "author": "akrun", "author_id": 3732271, "author_profile": "http...
2022/10/21
[ "https://Stackoverflow.com/questions/74149409", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20181941/" ]
74,149,419
<p>I'm working on Pyspark python. I downloaded a sample csv file from Kaggle <code>(Covid Live.csv)</code> and the data from the table is as follows when opened in visual code (Raw CSV data only partial data)</p> <p><a href="https://i.stack.imgur.com/swO9Z.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/swO9Z.jpg" alt="enter image description here" /></a></p> <pre><code>#,&quot;Country, Other&quot;,&quot;Total Cases&quot;,&quot;Total Deaths&quot;,&quot;New Deaths&quot;,&quot;Total Recovered&quot;,&quot;Active Cases&quot;,&quot;Serious, Critical&quot;,&quot;Tot Cases/ 1M pop&quot;,&quot;Deaths/ 1M pop&quot;,&quot;Total Tests&quot;,&quot;Tests/ 1M pop&quot;,Population 1,USA,&quot;98,166,904&quot;,&quot;1,084,282&quot;,,&quot;94,962,112&quot;,&quot;2,120,510&quot;,&quot;2,970&quot;,&quot;293,206&quot;,&quot;3,239&quot;,&quot;1,118,158,870&quot;,&quot;3,339,729&quot;,&quot;334,805,269&quot; 2,India,&quot;44,587,307&quot;,&quot;528,629&quot;,,&quot;44,019,095&quot;,&quot;39,583&quot;,698,&quot;31,698&quot;,376,&quot;894,416,853&quot;,&quot;635,857&quot;,&quot;1,406,631,776&quot;........ </code></pre> <p>The problem i'm facing here, the column names are also being displayed as records in pyspark databricks console when executed with below code</p> <pre><code>from pyspark.sql.types import * df1 = spark.read.format(&quot;csv&quot;) \ .option(&quot;inferschema&quot;, &quot;true&quot;) \ .option(&quot;header&quot;, &quot;true&quot;) \ .load(&quot;dbfs:/FileStore/shared_uploads/mahesh2247@gmail.com/Covid_Live.csv&quot;) \ .select(&quot;*&quot;) </code></pre> <pre><code>Spark Jobs --&gt; df1:pyspark.sql.dataframe.DataFrame #:string Country,:string </code></pre> <p>As can be observed above , spark is detecting only two columns # and Country but not aware that 'Total Cases', 'Total Deaths' . . are also columns</p> <p><a href="https://i.stack.imgur.com/F6Qid.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/F6Qid.png" alt="enter image description here" /></a></p> <p>How do i tackle this malformation ?</p>
[ { "answer_id": 74150492, "author": "Mahesh M", "author_id": 19372947, "author_profile": "https://Stackoverflow.com/users/19372947", "pm_score": 0, "selected": false, "text": " .option(\"multiLine\",\"true\") \\" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74149419", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19372947/" ]
74,149,441
<pre><code>IEnumerator CoTest() { yield return CoTest2(); Debug.Log(&quot;Done&quot;); } </code></pre> <p>If <code>CoTest2</code> had error , I want to stop exactly line I called ( <code>yield return CoTest2();</code> ) before <code>Debug.Log(&quot;Done&quot;);</code></p> <p>Is there any way to do this ? or better way</p>
[ { "answer_id": 74149585, "author": "Sandman", "author_id": 6070324, "author_profile": "https://Stackoverflow.com/users/6070324", "pm_score": -1, "selected": true, "text": "CoTest2" }, { "answer_id": 74150150, "author": "derHugo", "author_id": 7111561, "author_profile"...
2022/10/21
[ "https://Stackoverflow.com/questions/74149441", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15881776/" ]
74,149,449
<p>I have <code>data</code> like this:</p> <pre><code>data&lt;-data.frame(id=c(1,1,1,1,2,2,2,3,3,3,4,4,4), yearmonthweek=c(2012052,2012053,2012061,2012062,2013031,2013052,2013053,2012052, 2012053,2012054,2012071,2012073,2012074), event=c(0,1,1,0,0,1,0,0,0,0,0,0,0), a=c(11,12,13,10,11,12,15,14,13,15,19,10,20)) </code></pre> <p><code>id</code> stands for personal id. <code>yearmonthweek</code> means year, month and week. I want to clean <code>data</code> by the following rules. First, find <code>id</code> that have at least one <code>event</code>. In this case <code>id</code>=1 and 2 have events and <code>id</code>=3 and 4 have no events. Secondly, pick a random row from an <code>id</code> that has events and pick a random row from an <code>id</code> that has no events. So, the number of rows should be same as the number of <code>id</code>. My expected output looks like this:</p> <pre><code>data&lt;-data.frame(id=c(1,2,3,4), yearmonthweek=c(2012053,2013052,2012052,2012073), event=c(1,1,0,0), a=c(12,12,14,10)) </code></pre> <p>Since I use random sampling, the values can be different as above, but there should be 4 rows like this.</p>
[ { "answer_id": 74149588, "author": "Rui Barradas", "author_id": 8245406, "author_profile": "https://Stackoverflow.com/users/8245406", "pm_score": 1, "selected": false, "text": "dplyr" }, { "answer_id": 74149644, "author": "Maurits Evers", "author_id": 6530970, "author...
2022/10/21
[ "https://Stackoverflow.com/questions/74149449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17930715/" ]
74,149,456
<p>I created this code because I was not able to find any functional that accomplishes my requirement.</p> <p>If you can reduce it will be better.</p> <p>Just enter de prefix lenght from 1 to 32 and you will get the decimal mask. This code help me with my scripts for cisco.</p> <pre><code>import math #Netmask octets octet1 = [0,0,0,0,0,0,0,0] octet2 = [0,0,0,0,0,0,0,0] octet3 = [0,0,0,0,0,0,0,0] octet4 = [0,0,0,0,0,0,0,0] #POW list pow_list = [7,6,5,4,3,2,1,0] #Introduce prefix lenght mask = int(input(&quot;Introduce the prefix lenght: &quot;)) #According to the number of bits we will change the array elements from 0 to 1 while mask &gt;= 25 and mask &lt;= 32: octet4[mask-25] = 1 mask -= 1 while mask &gt;= 17 and mask &lt;= 24: octet3[mask-17] = 1 mask -= 1 while mask &gt;= 9 and mask &lt;= 16: octet2[mask-9] = 1 mask -= 1 while mask &gt;= 1 and mask &lt;= 8: octet1[mask-1] = 1 mask -= 1 #Obtain the number of ones ones1 = octet1.count(1) ones2 = octet2.count(1) ones3 = octet3.count(1) ones4 = octet4.count(1) #Summary and reuslt of each octet. sum1 = 0 for i in range(0,ones1): sum1 = sum1 + math.pow(2,pow_list[i]) sum1 = int(sum1) sum2 = 0 for i in range(0,ones2): sum2 = sum2 + math.pow(2,pow_list[i]) sum2 = int(sum2) sum3 = 0 for i in range(0,ones3): sum3 = sum3 + math.pow(2,pow_list[i]) sum3 = int(sum3) sum4 = 0 for i in range(0,ones4): sum4 = sum4 + math.pow(2,pow_list[i]) sum4 = int(sum4) #Join the results with a &quot;.&quot; decimal_netmask = str(sum1) + &quot;.&quot; + str(sum2) + &quot;.&quot; + str(sum3) + &quot;.&quot; + str(sum4) #Result print(&quot;Decimal netmask is: &quot;+ decimal_netmask) </code></pre> <p>Result: Introduce the prefix lenght: 23 Decimal netmask is: 255.255.254.0</p>
[ { "answer_id": 74150535, "author": "Nick", "author_id": 9473764, "author_profile": "https://Stackoverflow.com/users/9473764", "pm_score": 0, "selected": false, "text": "mask = 2**32 - 2**(32-prefix_length)\n" }, { "answer_id": 74153675, "author": "ubaumann", "author_id": ...
2022/10/21
[ "https://Stackoverflow.com/questions/74149456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20140780/" ]
74,149,490
<p><sub>(This is a question after reading <a href="https://stackoverflow.com/a/2402607/10027592">this answer</a>)</sub></p> <p>I tried this code:</p> <pre><code>#include &lt;iostream&gt; class A { public: int a; A(int val) : a{val}{} int f(int); int (A::*p)(int); }; int A::f(int in) { return in + a; } int main() { A a1(1000); A a2(2000); // Without these two lines, segmentation fault. a1.p = &amp;A::f; // no instance information. a2.p = &amp;A::f; // no instance information. std::cout &lt;&lt; a1.p &lt;&lt; &quot; &quot; &lt;&lt; a2.p &lt;&lt; '\n'; std::cout &lt;&lt; std::boolalpha &lt;&lt; (a1.p == a2.p) &lt;&lt; '\n'; std::cout &lt;&lt; (a1.*(a1.p))(5) &lt;&lt; '\n'; std::cout &lt;&lt; (a1.*(a2.p))(5) &lt;&lt; '\n'; std::cout &lt;&lt; (a2.*(a1.p))(5) &lt;&lt; '\n'; std::cout &lt;&lt; (a2.*(a2.p))(5) &lt;&lt; std::endl; } </code></pre> <p>Results:</p> <pre><code>1 1 true 1005 1005 // the same result as above. 2005 2005 // the same result as above. </code></pre> <ol> <li><p>It seems that <code>a1.p</code> and <code>a2.p</code> are the same. Is the member function's address <strong>not</strong> assigned until it is dereferenced and called by attaching the instance's name?</p> </li> <li><p>If so, what's the point of assigning <code>&amp;A::f</code>, if it has no information about the instance?</p> </li> </ol>
[ { "answer_id": 74150535, "author": "Nick", "author_id": 9473764, "author_profile": "https://Stackoverflow.com/users/9473764", "pm_score": 0, "selected": false, "text": "mask = 2**32 - 2**(32-prefix_length)\n" }, { "answer_id": 74153675, "author": "ubaumann", "author_id": ...
2022/10/21
[ "https://Stackoverflow.com/questions/74149490", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10027592/" ]
74,149,523
<p>I hope to do the following using X-macro with c++17, but since template parameter does not support trailing comma, it does not work for the std::variant part. Is there someway around it?</p> <pre class="lang-cpp prettyprint-override"><code>#define LIST_OF_TYPES(X) \ X(Type1) \ X(Type2) \ X(Type3) #define MAKE_TYPE(name) class name {}; LIST_OF_TYPES(MAKE_TYPE) #undef MAKE_TYPE std::variant&lt; #define MAKE_VARIANT(name) name, LIST_OF_TYPES(MAKE_VARIANT) #undef MAKE_VARIANT &gt; </code></pre>
[ { "answer_id": 74149649, "author": "HolyBlackCat", "author_id": 2752075, "author_profile": "https://Stackoverflow.com/users/2752075", "pm_score": 3, "selected": true, "text": "#define EMPTY(...)\n#define IDENTITY(...) __VA_ARGS__\n#define IDENTITY2(...) __VA_ARGS__\n\nstd::variant<\n#def...
2022/10/21
[ "https://Stackoverflow.com/questions/74149523", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3520697/" ]
74,149,532
<p>I created two widgets from same custom <code>StatefulWidget</code> class. I want them to use separate <code>ChangeNotifier</code> instance from same <code>ChangeNotifier</code> derived class because they need to consume different data set. Unfortunately just like below example, it's not working like I want it to. Both <code>read()</code> and <code>watch()</code> respectively write and read data on the same <code>ChangeNotifier</code> instance.</p> <p>Wait a minute. Isn't that what <code>Provider</code> supposed to do?. Yes I know. I'm aware that. But now I just need a little flexibility. I think I'm just using <code>Provider</code> the wrong way if I'm not wrong.</p> <p>Thank you for your help. Greatly appreciate it.</p> <pre><code>MultiProvider App() =&gt; MultiProvider( ... providers : [ ... ChangeNotifierProvider(create : (_) =&gt; Notifier()), ] ); class TestState extends State&lt;Test&gt;{ GlobalKey&lt;CounterState&gt; gk1 = GlobalKey&lt;CounterState&gt;(); GlobalKey&lt;CounterState&gt; gk2 = GlobalKey&lt;CounterState&gt;(); @override Widget build(BuildContext context){ ... .. [Counter(gk1), Counter(gk2)] ... .. onPressed: (){ .. gk1.currentState?.increment(1); .. gk2.currentState?.increment(2); .. }, ... } } class CounterState extends State&lt;Counter&gt;{ @override Widget build(BuildContext context){ ... .. context.watch&lt;Notifier&gt;().count ... } void increment(int v){ context.read&lt;Notifier&gt;().count += v; } } class Notifier with ChangeNotifier{ int _count = 0; int get count =&gt; _count; void set count(int v){ _count = v; notifyListeners(); } } </code></pre>
[ { "answer_id": 74149892, "author": "Axel", "author_id": 18162964, "author_profile": "https://Stackoverflow.com/users/18162964", "pm_score": 2, "selected": true, "text": "class Notifier with ChangeNotifier{\n\n List<int> _counts = [0, 0];\n\n int getCountAt(int index) {\n return _cou...
2022/10/21
[ "https://Stackoverflow.com/questions/74149532", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1297048/" ]
74,149,533
<p>I have an MAUI app that is essentially a <code>WebView</code> that hosts a wordpress website. My problem is that whenever I try to load an external link it will simply not load the &quot;href&quot; redirect... It works fine on Windows and iOS devices, but not in android.</p> <p>EDIT: The href is a &quot;_blank&quot; target.</p> <p>Is there a specific permission I need in the manifest?</p> <p>In case it helps, here is the code for the page:</p> <pre class="lang-xml prettyprint-override"><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt; &lt;ContentPage xmlns=&quot;http://schemas.microsoft.com/dotnet/2021/maui&quot; xmlns:x=&quot;http://schemas.microsoft.com/winfx/2009/xaml&quot; x:Class=&quot;MYAPPNAME.EnglishPage&quot; NavigationPage.HasNavigationBar=&quot;False&quot; NavigationPage.HasBackButton=&quot;False&quot; Shell.NavBarIsVisible=&quot;False&quot;&gt; &lt;Grid BackgroundColor=&quot;DarkSlateGrey&quot;&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height=&quot;Auto&quot;/&gt; &lt;RowDefinition Height=&quot;*&quot;/&gt; &lt;/Grid.RowDefinitions&gt; &lt;StackLayout Grid.Row=&quot;0&quot; Grid.Column=&quot;0&quot; Spacing=&quot;5&quot; Orientation=&quot;Horizontal&quot; Padding=&quot;8&quot;&gt; &lt;Button Text=&quot;Go Back&quot; TextColor=&quot;DarkSlateGray&quot; BackgroundColor=&quot;White&quot;/&gt; &lt;Button Text=&quot;Change Language&quot; x:Name=&quot;ChangeLangBtn&quot; TextColor=&quot;DarkSlateGray&quot; BackgroundColor=&quot;White&quot;/&gt; &lt;/StackLayout&gt; &lt;WebView Grid.Row=&quot;1&quot; Grid.Column=&quot;0&quot; Source=&quot;https://example.com&quot; x:Name=&quot;WebView&quot;/&gt; &lt;/Grid&gt; &lt;/ContentPage&gt; </code></pre> <p>And here is the manifest:</p> <pre class="lang-xml prettyprint-override"><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt; &lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot; android:versionCode=&quot;2&quot; android:versionName=&quot;2&quot;&gt; &lt;application android:allowBackup=&quot;true&quot; android:icon=&quot;@mipmap/appicon&quot; android:roundIcon=&quot;@mipmap/appicon_round&quot; android:supportsRtl=&quot;true&quot; android:label=&quot;MYAPPNAME&quot;&gt;&lt;/application&gt; &lt;uses-permission android:name=&quot;android.permission.ACCESS_NETWORK_STATE&quot; /&gt; &lt;uses-permission android:name=&quot;android.permission.INTERNET&quot; /&gt; &lt;uses-sdk android:minSdkVersion=&quot;21&quot; android:targetSdkVersion=&quot;31&quot; /&gt; &lt;/manifest&gt; </code></pre>
[ { "answer_id": 74150663, "author": "Liyun Zhang - MSFT", "author_id": 17455524, "author_profile": "https://Stackoverflow.com/users/17455524", "pm_score": 2, "selected": false, "text": "android:usesCleartextTraffic" }, { "answer_id": 74153770, "author": "YaRmgl", "author_i...
2022/10/21
[ "https://Stackoverflow.com/questions/74149533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10904737/" ]
74,149,536
<p>I've been trying to compare two csv file using simple shell script but I think the code that I was using is not doing it's job. what I want to do is, compare the two files using Column 6 from first.csv and Column 2 in second.csv and when it matches, it will output the line from first.csv. see below as an example</p> <p><strong>first.csv</strong></p> <pre><code>1,0,3210820,0,536,7855712 1,0,3523340820,0,36,53712 1,0,321023423i420,0,336,0255712 1,0,321082234324,0,66324,027312 </code></pre> <p><strong>second.csv</strong></p> <pre><code>14,7855712,Whie,Black 124,7855712,Green,Black 174,1197,Black,Orange 1284,98132197,Yellow,purple 35384,9811123197,purple,purple 13354,0981123131197,green,green 183434,0811912313127,white,green </code></pre> <p><strong>Output should be from the first file:</strong></p> <pre><code>1,0,3210820,0,536,7855712 </code></pre> <p>I've been using the code below.</p> <pre><code>cat first.csv | while read line do cat second.csv | grep $line &gt; output_file done </code></pre> <p>please help. Thank you</p>
[ { "answer_id": 74150663, "author": "Liyun Zhang - MSFT", "author_id": 17455524, "author_profile": "https://Stackoverflow.com/users/17455524", "pm_score": 2, "selected": false, "text": "android:usesCleartextTraffic" }, { "answer_id": 74153770, "author": "YaRmgl", "author_i...
2022/10/21
[ "https://Stackoverflow.com/questions/74149536", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20249814/" ]
74,149,542
<p>I use lodash-debounce on input tag.</p> <p>If I typed in five letters, api called 5 times.</p> <pre class="lang-js prettyprint-override"><code> const onChangeInput: ChangeEventHandler = (e: any) =&gt; { setWords(e.target.value); e.target.value.length &gt;= 2 &amp;&amp; debounceInputChanged(); }; const debounceInputChanged = useMemo( () =&gt; debounce(() =&gt; { searchWords(); }, 1000), [words], ); </code></pre> <hr /> <p>doesnt work lodash-debounce.</p> <pre class="lang-js prettyprint-override"><code> const onChangeInput: ChangeEventHandler = (e: any) =&gt; { setInput(e.target.value); debounceInput(e.target.value); }; // eslint-disable-next-line react-hooks/exhaustive-deps const debounceInput = useMemo( () =&gt; debounce((value: any) =&gt; { console.log(value); }, 3000), [input], ); </code></pre> <p>console.log shows 1 12 123 1234 I expect console.log only shows 1234 <a href="https://i.stack.imgur.com/yOEdx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yOEdx.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74149578, "author": "Himanshu Prajapati", "author_id": 20289252, "author_profile": "https://Stackoverflow.com/users/20289252", "pm_score": 0, "selected": false, "text": "const onChangeInput: ChangeEventHandler = (e: any) => {\nsetWords(e.target.value);\ne.target.value.leng...
2022/10/21
[ "https://Stackoverflow.com/questions/74149542", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18168112/" ]
74,149,572
<p>I'm building a regex to be able to parse addresses and am running into some blocks. An example address I'm testing against is:</p> <pre><code>5173B 63rd Ave NE, Lake Forest Park WA 98155 </code></pre> <p>I am looking to capture the house number, street name(s), city, state, and zip code as individual groups. I am new to regex and am using regex101.com to build and test against, and ended up with:</p> <pre><code>(^\d+\w?)\s((\w*\s?)+).\s(\w*\s?)+([A-Z]{2})\s(\d{5}) </code></pre> <p>It matches all the groups I need and matches the whole string, but there are extra groups that are null value according to the match information (3 and 4). I've looked but can't find what is causing this issue. Can anyone help me understand?</p>
[ { "answer_id": 74149578, "author": "Himanshu Prajapati", "author_id": 20289252, "author_profile": "https://Stackoverflow.com/users/20289252", "pm_score": 0, "selected": false, "text": "const onChangeInput: ChangeEventHandler = (e: any) => {\nsetWords(e.target.value);\ne.target.value.leng...
2022/10/21
[ "https://Stackoverflow.com/questions/74149572", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9919516/" ]
74,149,589
<p>I have to make some SQL query. I'll only put here tables and results I need - I am sure this is the best way for a clear explanation (at the bottom of the question I provided SQL queries for database filling).</p> <hr /> <ul> <li>short description:</li> </ul> <p>TASK: After <code>full join</code> concatenation I receive a result where (for example) <code>tableA.point</code> column (that is used in the SELECT statement) in some cells returns <code>NULL</code>. In these cases, I need to change <code>tableA.point</code> column to the <code>tableB.point</code> (from the joined table).</p> <p>So, tables:</p> <p>(Columns <code>point</code> + <code>date</code> are composite key.)</p> <ul> <li>outcome_o:</li> </ul> <p><a href="https://i.stack.imgur.com/wSxd2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wSxd2.png" alt="enter image description here" /></a></p> <ul> <li>income_o:</li> </ul> <p><a href="https://i.stack.imgur.com/exca0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/exca0.png" alt="enter image description here" /></a></p> <ul> <li>The result I need an example (we can see - I need a concatenated table with both <code>out</code> and <code>inc</code> columns in rows)</li> </ul> <p><a href="https://i.stack.imgur.com/uCRZE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uCRZE.png" alt="enter image description here" /></a></p> <hr /> <p>My attempt:</p> <pre class="lang-sql prettyprint-override"><code>SELECT outcome_o.point, outcome_o.date, inc, out FROM income_o FULL JOIN outcome_o ON income_o.point = outcome_o.point AND income_o.date = outcome_o.date </code></pre> <p>The result is the same as I need, except <code>NULL</code> in different <code>point</code> and <code>date</code> columns:</p> <p><a href="https://i.stack.imgur.com/r6J26.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/r6J26.png" alt="enter image description here" /></a></p> <p>I tried to avoid this with <code>CASE</code> statement:</p> <pre class="lang-sql prettyprint-override"><code>SELECT CASE outcome_o.point WHEN NULL THEN income_o.point ELSE outcome_o.point END as point, .... </code></pre> <p>But this not works as I imagined (all cells became NULL in <code>point</code> column).</p> <p>Could anyone help me with this solution? I know there is I have to use <code>JOIN</code>, <code>CASE</code> (case-mandatory) and possibly <code>UNION</code> commands. Thanks</p> <hr /> <p>Tables creation:</p> <pre class="lang-sql prettyprint-override"><code> CREATE TABLE income( point INT, date VARCHAR(60), inc FLOAT ) CREATE TABLE outcome( point INT, date VARCHAR(60), ou_t FLOAT ) INSERT INTO income VALUES (1, '2001-03-22', 15000.0000), (1, '2001-03-23', 15000.0000), (1, '2001-03-24', 3400.0000), (1, '2001-04-13', 5000.0000), (1, '2001-05-11', 4500.0000), (2, '2001-03-22', 10000.0000), (2, '2001-03-24', 1500.0000), (3, '2001-09-13', 11500.0000), (3, '2001-10-02', 18000.0000); INSERT INTO outcome VALUES (1, '2001-03-14 00:00:00.000', 15348.0000), (1, '2001-03-24 00:00:00.000', 3663.0000), (1, '2001-03-26 00:00:00.000', 1221.0000), (1, '2001-03-28 00:00:00.000', 2075.0000), (1, '2001-03-29 00:00:00.000', 2004.0000), (1, '2001-04-11 00:00:00.000', 3195.0400), (1, '2001-04-13 00:00:00.000', 4490.0000), (1, '2001-04-27 00:00:00.000', 3110.0000), (1, '2001-05-11 00:00:00.000', 2530.0000), (2, '2001-03-22 00:00:00.000', 1440.0000), (2, '2001-03-29 00:00:00.000', 7848.0000), (2, '2001-04-02 00:00:00.000', 2040.0000), (3, '2001-09-13 00:00:00.000', 1500.0000), (3, '2001-09-14 00:00:00.000', 2300.0000), (3, '2002-09-16 00:00:00.000', 2150.0000); </code></pre>
[ { "answer_id": 74150907, "author": "FanoFN", "author_id": 10910692, "author_profile": "https://Stackoverflow.com/users/10910692", "pm_score": 1, "selected": false, "text": "WITH RECURSIVE cte AS (\n SELECT Min(mndate) mindt, MAX(mxdate) maxdt \n FROM (SELECT MIN(date) AS mndate, MAX(...
2022/10/21
[ "https://Stackoverflow.com/questions/74149589", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9689945/" ]
74,149,617
<h1>The Problem</h1> <p>In Angular when you call a function such as a <code>public get value() { ... }</code> in a template any time the template is re-rendered the function will be called again leading to many different calls. On many different questions that seem to be related to this topic they talk about using various approaches to get the values from a form control such as <code>this.form.controls.your_control_here.value</code> or <code>this.form.get('your_control_here').value</code>. However, either of these these approaches could not be referenced nicely in the template as they are both not very easy to follow (in a template) and using a function like above would lead to the duplication of calls which isn't preferable.</p> <h1>Possible Solutions</h1> <p>From what I could tell you might be able to use something like <code>this.form.controls.your_control_here.valueChanges</code> and <code>pipe tap</code> the value into another exposed variable that your template watches. However, given Angular/RxJS does not publish the value of the Observable that backs <code>valueChanges</code> you would miss out on the initial value of your form control. Along with that as far as I'm aware when you can you don't want to use subscribe in controller logic when possible as you must also manage unsubscribing the value and to instead prefer <code>| async</code> instead, but that goes back to the other <code>valueChanges</code> error of missing the first value.</p> <h1>The Question</h1> <p>What I am wondering is, is there an acceptable way to accomplish getting a value from an angular form into its associated template. While avoiding the issue of calling functions multiple times and preferably keeping to the ideal of using <code>| async</code>? Perhaps there is not but it feels a bit like a hack to add all of this extra stuff just to get a simple value to use in the template.</p> <p>Here are some examples from a test application I made to try and work through this.</p> <h1>Controller Logic:</h1> <pre><code>import { Component } from &quot;@angular/core&quot;; import { FormBuilder, FormControl, Validators } from &quot;@angular/forms&quot;; @Component({ selector: &quot;app-inventory-setup-page&quot;, templateUrl: &quot;./inventory-setup-page.component.html&quot;, styleUrls: [&quot;./inventory-setup-page.component.scss&quot;], }) export class InventorySetupPageComponent implements OnInit { public createInventory = false; public inventoryType = this._formBuilder.group({ options: new FormControl(&quot;/inventory/create/supplies&quot;, [Validators.required]), }); constructor(private _formBuilder: FormBuilder) { } public startInventoryCreation() { this.createInventory = !this.createInventory; } // this would get called many times in the browser public get route(): string { console.log(&quot;This got called&quot;); return this.inventoryType.controls.options.value!; } public route$: Observable&lt;string | null&gt;; public ngOnInit() { // using this with `| async` in the template will miss the initial value of &quot;/inventory/create/supplies&quot; above this.route$ = this.inventoryType.controls.options.valueChanges; } } </code></pre> <h1>The Template</h1> <pre class="lang-html prettyprint-override"><code>&lt;section *ngIf=&quot;!createInventory&quot;&gt; &lt;h1&gt;You do not have any inventory&lt;/h1&gt; &lt;button mat-button (click)=&quot;startInventoryCreation()&quot;&gt;Add Inventory Item&lt;/button&gt; &lt;button mat-button&gt;Import Inventory&lt;/button&gt; &lt;/section&gt; &lt;div *ngIf=&quot;createInventory&quot;&gt; &lt;section&gt; &lt;h1&gt;How will you track this item?&lt;/h1&gt; &lt;form [formGroup]=&quot;inventoryType&quot;&gt; &lt;ng-template matStepLabel&gt;Select Inventory Type&lt;/ng-template&gt; &lt;mat-label&gt;How will you track this item?&lt;/mat-label&gt; &lt;mat-radio-group formControlName=&quot;options&quot; required&gt; &lt;mat-radio-button value=&quot;/inventory/create/supplies&quot;&gt;Quantity&lt;/mat-radio-button&gt; &lt;mat-radio-button value=&quot;/inventory/create/equipment&quot;&gt;Individually&lt;/mat-radio-button&gt; &lt;/mat-radio-group&gt; &lt;/form&gt; &lt;/section&gt; &lt;section&gt; {{ route }} &lt;a mat-flat-button color=&quot;primary&quot; [routerLink]=&quot;route&quot;&gt;Create&lt;/a&gt; &lt;/section&gt; &lt;/div&gt; </code></pre>
[ { "answer_id": 74149968, "author": "Eliseo", "author_id": 8558186, "author_profile": "https://Stackoverflow.com/users/8558186", "pm_score": 1, "selected": false, "text": "<section *ngIf=\"{route:route$|async} as data\">\n {{ data.route }}\n <a mat-flat-button color=\"primary\" [rou...
2022/10/21
[ "https://Stackoverflow.com/questions/74149617", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13204578/" ]
74,149,640
<p>I want to open the Swift screen from Flutter, but an error occurs and I can't open it. I am using FirebaseAnalytics in Swift screen.</p> <pre><code>Error (Xcode): Undefined symbol: _$s19FirebaseSharedSwift0A11DataDecoderC0D16DecodingStrategyO6base64yA2EmFWC Error (Xcode): Undefined symbol: _$s19FirebaseSharedSwift0A11DataDecoderC19KeyDecodingStrategyO14useDefaultKeysyA2EmFWC Error (Xcode): Undefined symbol: _$s19FirebaseSharedSwift0A11DataDecoderC19keyDecodingStrategyAC03KeygH0OvsTj Error (Xcode): Undefined symbol: _$s19FirebaseSharedSwift0A11DataDecoderC20DateDecodingStrategyO6customyAE10Foundation0F0Vs0E0_pKccAEmFWC Error (Xcode): Undefined symbol: _$s19FirebaseSharedSwift0A11DataDecoderC20dataDecodingStrategyAC0dgH0OvsTj Error (Xcode): Undefined symbol: _$s19FirebaseSharedSwift0A11DataDecoderC20dateDecodingStrategyAC04DategH0OvsTj Error (Xcode): Undefined symbol: _$s19FirebaseSharedSwift0A11DataDecoderC23passthroughTypeResolverAA026StructureCodingPassthroughgH0_pXpvsTj Error (Xcode): Undefined symbol: _$s19FirebaseSharedSwift0A11DataDecoderC34NonConformingFloatDecodingStrategyO5throwyA2EmFWC Error (Xcode): Undefined symbol: _$s19FirebaseSharedSwift0A11DataDecoderC34nonConformingFloatDecodingStrategyAC03NonghiJ0OvsTj Error (Xcode): Undefined symbol: _$s19FirebaseSharedSwift0A11DataDecoderC6decode_4fromxxm_yptKSeRzlFTj Error (Xcode): Undefined symbol: _$s19FirebaseSharedSwift0A11DataDecoderC8userInfoSDys010CodingUserG3KeyVypGvsTj Error (Xcode): Undefined symbol: _$s19FirebaseSharedSwift0A11DataEncoderC0D16EncodingStrategyO6base64yA2EmFWC Error (Xcode): Undefined symbol: _$s19FirebaseSharedSwift0A11DataEncoderC19KeyEncodingStrategyO14useDefaultKeysyA2EmFWC Error (Xcode): Undefined symbol: _$s19FirebaseSharedSwift0A11DataEncoderC19keyEncodingStrategyAC03KeygH0OvsTj Error (Xcode): Undefined symbol: _$s19FirebaseSharedSwift0A11DataEncoderC20DateEncodingStrategyO6customyAEy10Foundation0F0V_s0E0_ptKccAEmFWC Error (Xcode): Undefined symbol: _$s19FirebaseSharedSwift0A11DataEncoderC20dataEncodingStrategyAC0dgH0OvsTj </code></pre>
[ { "answer_id": 74176624, "author": "rai", "author_id": 18510207, "author_profile": "https://Stackoverflow.com/users/18510207", "pm_score": -1, "selected": false, "text": "pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '9.6.0'\n" ...
2022/10/21
[ "https://Stackoverflow.com/questions/74149640", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18510207/" ]
74,149,641
<p>I am working in very restricted project, and we are using linux vm to run terraform scripts. Sometimes it is very difficult to modify scripts in browser. Is there any way I can connect to vm through vs code and do script modification as we do it traditionally with config file.</p> <p><a href="https://i.stack.imgur.com/Ed2na.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ed2na.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74176624, "author": "rai", "author_id": 18510207, "author_profile": "https://Stackoverflow.com/users/18510207", "pm_score": -1, "selected": false, "text": "pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '9.6.0'\n" ...
2022/10/21
[ "https://Stackoverflow.com/questions/74149641", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20284973/" ]
74,149,647
<p>I'm trying everything, I'm new at this and just cannot get it to work. I just wanted my logo (&quot;animated&quot;) to always align left, and the links to align right. Just like any normal nav bar.</p> <p>The animated logo works just fine. I just can't separate the logo from the links and align them?</p> <p>I've tried <code>float: right</code> and <code>margin-right: auto</code> under the animated logo.</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 { max-width: 1280px; margin: 0 right; display: flex; align-items: center; justify-content: space-between; } nav { display: flex; z-index: 50; background-color: #FFFFFF; padding: 16px 32px; } a { text-decoration: none; } .logo { display: inline-flex; } .animated-logo { display: flex; color: #000000; transition-property: transform; transition-duration: .15s; font-size: 35px; font-weight: 600; } menu a { color: black; margin: 0 16px; font-weight: 300; text-decoration: none; transition: 0.2s; padding: 8px 5px; border-radius: 99px; font-size: 20px; } .menu a:hover { color: #808080; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;nav&gt; &lt;div class="container"&gt; &lt;a href="index.html" class="logo"&gt; &lt;h3 class="animated-logo"&gt; &lt;span class="letter first"&gt;t&lt;/span&gt; &lt;span class="letter"&gt;a&lt;/span&gt; &lt;span class="letter-hide"&gt;a&lt;/span&gt; &lt;span class="letter"&gt;r&lt;/span&gt; &lt;span class="letter"&gt;s&lt;/span&gt; &lt;span class="letter-hide"&gt;t&lt;/span&gt; &lt;span class="letter"&gt;r&lt;/span&gt; &lt;/h3&gt; &lt;/a&gt; &lt;div class="menu"&gt; &lt;a href="about.html"&gt;About&lt;/a&gt; &lt;a href="experience.html"&gt;Experience&lt;/a&gt; &lt;a href="mailto:email"&gt;Contact Me&lt;/a&gt; &lt;/div&gt; &lt;/nav&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74149744, "author": "Cervus camelopardalis", "author_id": 10347145, "author_profile": "https://Stackoverflow.com/users/10347145", "pm_score": 3, "selected": true, "text": "width: 100vw;" }, { "answer_id": 74149796, "author": "BlueBird931", "author_id": 1805...
2022/10/21
[ "https://Stackoverflow.com/questions/74149647", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17207309/" ]
74,149,650
<p>how can we put &quot;http://localhost:4200/#/{&quot;page&quot;:&quot;product&quot;, &quot;shoe&quot;:&quot;47372&quot;, &quot;isOpen&quot;:false} &quot; on url so that when the user share the link, the other end could construct the state using it using angular spa with ngrx</p> <p>Edited One,</p> <p>the question is not how to pars params but how to put in the params of the active route.</p>
[ { "answer_id": 74149744, "author": "Cervus camelopardalis", "author_id": 10347145, "author_profile": "https://Stackoverflow.com/users/10347145", "pm_score": 3, "selected": true, "text": "width: 100vw;" }, { "answer_id": 74149796, "author": "BlueBird931", "author_id": 1805...
2022/10/21
[ "https://Stackoverflow.com/questions/74149650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2417726/" ]
74,149,699
<p>Below is a code i am using to set state for some data:</p> <pre><code> const [loader, setLoader] = useState(true); const [trendData, setTrend] = useState([]); const [thisMonthData, setThisMonth] = useState([]); useEffect(() =&gt; { graphData(); }, [loader]); async function graphData() { await getRequest(process.env.REACT_APP_apiUrl + ':0000/abc/xyz').then( (response) =&gt; { let series = []; let months; for (let index = 0; index &lt; response.length; index++) { months = response[index]['Month'].split(','); series.push(response[index]['Useres'].split(',')); } setTrendMonth(series); setThisMonthData(series); console.log(thisMonthData); setLoader(false); }); } </code></pre> <p>And now i am attaching a response getting in <code>console.log(thisMonthData);</code> this. I have tried everything, including <code>thisMonthData</code> in <code>useEffect</code> and other state keys. But everytime data is going blank or missing values.</p> <p>Whats wrong here.</p> <p><a href="https://i.stack.imgur.com/N6YA9.png" rel="nofollow noreferrer">enter image description here</a></p> <p><a href="https://i.stack.imgur.com/PIeIM.png" rel="nofollow noreferrer">enter image description here</a></p>
[ { "answer_id": 74149744, "author": "Cervus camelopardalis", "author_id": 10347145, "author_profile": "https://Stackoverflow.com/users/10347145", "pm_score": 3, "selected": true, "text": "width: 100vw;" }, { "answer_id": 74149796, "author": "BlueBird931", "author_id": 1805...
2022/10/21
[ "https://Stackoverflow.com/questions/74149699", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19533559/" ]
74,149,713
<p>I have implemented the following method format request body</p> <pre><code>private async Task&lt;string&gt; FormatRequest(HttpRequest request) { request.EnableBuffering(); //Create a new byte[] with the same length as the request stream var buffer = new byte[Convert.ToInt32(request.ContentLength)]; //Copy the entire request stream into the new buffer await request.Body.ReadAsync(buffer, 0, buffer.Length).ConfigureAwait(false); //Convert the byte[] into a string using UTF8 encoding var bodyAsText = Encoding.UTF8.GetString(buffer); request.Body.Position = 0; return bodyAsText; } </code></pre> <p>I got the following result</p> <pre><code>------WebKitFormBoundaryY8OPXY2MlrKMjBRe Content-Disposition: form-data; name=&quot;RoleId&quot; 2 ------WebKitFormBoundaryY8OPXY2MlrKMjBRe Content-Disposition: form-data; name=&quot;AuthenticationSettingsId&quot; 3 ..... </code></pre> <p>Expected result</p> <pre><code>&quot;{\&quot;fields\&quot;:[\&quot;RoleId\&quot;,\&quot;2\&quot;,\&quot;AuthenticationSettingsId\&quot;,\&quot;1\&quot;,\&quot;recommendation\&quot;,\&quot;reviewerId\&quot;],\&quot;size\&quot;:100,\&quot;filter\&quot;:[{\&quot;id\&quot;:\&quot;ApplicationId\&quot;,\&quot;operator\&quot;:\&quot;and\&quot;,\&quot;parent\&quot;:\&quot;\&quot;,\&quot;nested\&quot;:false,\&quot;type\&quot;:\&quot;integer\&quot;,\&quot;value\&quot;:[360]}],\&quot;aggregate\&quot;:[],\&quot;sort\&quot;:[]}&quot; </code></pre> <p>Note: Previously we used request.EnableRewind() it was returning the above result and later upgraded to .net core 3.0</p>
[ { "answer_id": 74227428, "author": "n-azad", "author_id": 5997281, "author_profile": "https://Stackoverflow.com/users/5997281", "pm_score": 0, "selected": false, "text": "var reader = new System.IO.StreamReader(request.Body); \nvar body = reader.ReadToEndAsync().Result;\n" }, ...
2022/10/21
[ "https://Stackoverflow.com/questions/74149713", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5084965/" ]
74,149,716
<p>I am experimenting the projection features of Hibernatesearch 6.2.0.Alpha1 before integrating our existing app.</p> <p>I have created a spring-boot project with JHIPSTER <a href="https://github.com/anothergoodguy/spring-data-hibernate-search" rel="nofollow noreferrer">sample project</a>. And added the Hibernate-search dependencies and configurations in both POM.XML and application*.yml. Using JHipster because it helps me with the boilerplate code and fake data.</p> <p>Have configured pom.xml with both <code>-parameters</code> and <code>jandex</code>. Application runs successfully and loads the data into the database. And i am able to mass Index with the utility we wrote as per the documents.</p> <p>However when try to search the data with projections we are recieving the error <code>Exception in searchWithProjection() with cause = 'NULL' and exception = 'HSEARCH700112: Invalid object class for projection: com.sample.shop.service.projections.dto.Address. Make sure that this class is mapped correctly, either through annotations (@ProjectionConstructor) or programmatic mapping. If it is, make sure the class is included in a Jandex index made available to Hibernate Search.'</code>. The same query/logic works perfectly fine if we search without projections.</p> <p>Ex. if you view the files <code>AddressResource.java &amp; AddressService.java</code> in the above linked repository; you can find 2 implementations for projections and no-projections respectively. while the one without projections works perfectly fine the one with projects is throwing the error.</p> <p>I feel it might be some configuration issue, however not able to figure-out myself. Appreciate your help on configuration / code approach.</p> <p>Please be informed that I have gone through the follwoing tickets already:</p> <ol> <li><a href="https://stackoverflow.com/questions/71801844/hibernate-search-6-combine-projections-not-working">Hibernate Search 6 combine projections not working</a></li> <li><a href="https://stackoverflow.com/questions/69735853/single-return-type-in-hibernate-search/69736338?r=SearchResults&amp;s=2%7C10.6766#69736338">Single return type in Hibernate Search</a></li> </ol>
[ { "answer_id": 74227428, "author": "n-azad", "author_id": 5997281, "author_profile": "https://Stackoverflow.com/users/5997281", "pm_score": 0, "selected": false, "text": "var reader = new System.IO.StreamReader(request.Body); \nvar body = reader.ReadToEndAsync().Result;\n" }, ...
2022/10/21
[ "https://Stackoverflow.com/questions/74149716", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16942421/" ]
74,149,718
<p>Is there a way to get a list of all commits after the commit I am checked out currently? For example in this image, I'm on commit 84a90... <a href="https://i.stack.imgur.com/GHmYE.png" rel="nofollow noreferrer">Commit History in Sourcetree</a></p> <p>and in my terminal, I want to see a list of the next 3 commits, preferably with the commit comment &amp; the changed files.</p>
[ { "answer_id": 74149775, "author": "Jagrut Sharma", "author_id": 2780480, "author_profile": "https://Stackoverflow.com/users/2780480", "pm_score": -1, "selected": false, "text": "git log --name-status" }, { "answer_id": 74149816, "author": "Prateek Chaudhary", "author_id"...
2022/10/21
[ "https://Stackoverflow.com/questions/74149718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18278107/" ]
74,149,736
<p>I have a dropdown that has products, and once the user selects a product, it automatically fills two input fields with the price and levy of that selected product. Is there a way using JavaScript to <strong>automatically</strong> calculate those two values and display it in a third input field.</p> <p>The issue is that I have to manually change one of the input fields in order for the calculation to show. What I need, once the product gets selected it already displays the calculation in the &quot;total&quot; input field.</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>document.addEventListener('input', function(event) { let mySelect = document.getElementById("item"); mySelect.addEventListener("change", () =&gt; document.getElementById("first_calc_1").value = mySelect.options[mySelect.selectedIndex].getAttribute("data-price")); mySelect.addEventListener("change", () =&gt; document.getElementById("second_calc_1").value = mySelect.options[mySelect.selectedIndex].getAttribute("data-levy")); mySelect.addEventListener("change", () =&gt; document.getElementById("id").value = mySelect.options[mySelect.selectedIndex].getAttribute("data-id")); }); $("#orders").on('input', 'input.first_calc,input.second_calc', function() { getTotalCost($(this).attr("for")); }); function getTotalCost(ind) { let number_1 = document.getElementById('first_calc_' + ind).value; let number_2 = document.getElementById('second_calc_' + ind).value; let total = number_1 * number_2; $('#total_' + ind).val(total); }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"&gt;&lt;/script&gt; &lt;form id="orders" action="" method="post"&gt; &lt;select id="item" name="get_value"&gt; &lt;option value="Guitar" data-price="2500" data-levy="25"&gt;Guitar&lt;/option&gt; &lt;option value="Drums" data-price="3500" data-levy="35"&gt;Drums&lt;/option&gt; &lt;option value="Trello" data-price="5500" data-levy="45"&gt;Trello&lt;/option&gt; &lt;/select&gt; &lt;input class="first_calc" type="number" id="first_calc_1" for="1"&gt; &lt;input class="second_calc" type="number" id="second_calc_1" for="1"&gt; &lt;input type="text" id="total_1"&gt; &lt;/form&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74149973, "author": "Ken Lee", "author_id": 11854986, "author_profile": "https://Stackoverflow.com/users/11854986", "pm_score": 2, "selected": true, "text": "mySelect.addEventListener(\"change\", () => getTotalCost(i));\n" }, { "answer_id": 74149976, "author": ...
2022/10/21
[ "https://Stackoverflow.com/questions/74149736", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18632039/" ]
74,149,760
<p>I have the following code, why is the range based output is not what is stored in the vector?</p> <pre><code>#include &lt;iostream&gt; #include &lt;memory&gt; #include &lt;vector&gt; using namespace std; shared_ptr&lt;vector&lt;double&gt;&gt; get_ptr() { vector&lt;double&gt; v{1, 2, 3, 4, 5}; return make_shared&lt;vector&lt;double&gt;&gt;(v); } int main() { auto vec = get_ptr(); for (int i = 0; i&lt;get_ptr()-&gt;size(); ++i) { std::cout &lt;&lt; (*get_ptr())[i] &lt;&lt; std::endl; } for (auto v: (*get_ptr())) { std::cout &lt;&lt; v &lt;&lt; std::endl; } } </code></pre> <p>The output on my ubuntu is something like below,</p> <pre><code>1 2 3 4 5 4.67913e-310 4.67913e-310 3 4 5 </code></pre>
[ { "answer_id": 74149839, "author": "Some programmer dude", "author_id": 440558, "author_profile": "https://Stackoverflow.com/users/440558", "pm_score": 1, "selected": true, "text": "get_ptr()" }, { "answer_id": 74149846, "author": "songyuanyao", "author_id": 3309790, ...
2022/10/21
[ "https://Stackoverflow.com/questions/74149760", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1569058/" ]
74,149,762
<p>I use standard user flows and custom pages for Forgotten Password and Sign-Up. On these pages, I need to add a link to the Sign-In page. How to add the tag itself is described <a href="https://learn.microsoft.com/en-us/answers/questions/755343/azure-ad-b2c-signupsignin-combined-flow-link-from.html" rel="nofollow noreferrer">here</a>.</p> <p>At the moment, I do not understand how to generate the link itself correctly. Out from the box on the Sign-In page, links for Forgotten Password and Sign-Up are generated using the getRedirectLink function, but I can’t generate a link for Sign-in using it. As an alternative, it is suggested <a href="https://stackoverflow.com/questions/57670125/how-to-restart-azure-ad-b2c-userjourney-when-user-cancels-signup?newreg=3e022de38ec44393bddc56169443434e">here</a> to use history.back(), but unfortunately this is not covered all cases.</p>
[ { "answer_id": 74149839, "author": "Some programmer dude", "author_id": 440558, "author_profile": "https://Stackoverflow.com/users/440558", "pm_score": 1, "selected": true, "text": "get_ptr()" }, { "answer_id": 74149846, "author": "songyuanyao", "author_id": 3309790, ...
2022/10/21
[ "https://Stackoverflow.com/questions/74149762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20298280/" ]
74,149,780
<p>while try to connect with my DB . I'm getting some popup window to download some .jar files. But for a single file I can't to download it. Please say how to resolve this issue. I'm getting error code for missing file</p> <p>&quot;mvn:org.talend.libraries/mssql-jdbc/6&quot;</p> <p>Error Screenshot in below link :</p> <p><a href="https://i.stack.imgur.com/8LR4G.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8LR4G.jpg" alt="enter image description here" /></a></p>
[ { "answer_id": 74149839, "author": "Some programmer dude", "author_id": 440558, "author_profile": "https://Stackoverflow.com/users/440558", "pm_score": 1, "selected": true, "text": "get_ptr()" }, { "answer_id": 74149846, "author": "songyuanyao", "author_id": 3309790, ...
2022/10/21
[ "https://Stackoverflow.com/questions/74149780", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20298441/" ]
74,149,793
<p>First of all, I am not experienced coder.</p> <p>I have been coding a windows desktop application which uses a lot of forms. Main form has a panel that controls childforms and app makes calculations in thoose childforms than records results in ms-access database. I was wondering if I could reach button located in main form without usind Formmain main = new Formmain(); - main.Show();I would like to trigger that button on mainform automatically. I would love to know if that is possible.</p> <p>Best regards.</p>
[ { "answer_id": 74150818, "author": "Jiale Xue - MSFT", "author_id": 16764901, "author_profile": "https://Stackoverflow.com/users/16764901", "pm_score": 2, "selected": true, "text": "private void button1_Click(object sender, EventArgs e)\n{\n textBox1.Text = \"I'm a \";\n}\n\nprivate v...
2022/10/21
[ "https://Stackoverflow.com/questions/74149793", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20298437/" ]
74,149,841
<p><strong>STATE OF CURRENT DATE</strong></p> <pre><code>const [date, setDate] = React.useState(new Date()) console.log('date', date); </code></pre> <p><strong>DATE CAN'T PUSHED TO FIREBASE DATABASE AND HOW TO PUSH DATE IN REALTIME DATABASE.</strong></p> <pre><code> function addNewPerson() { push(ref(db, '/addperson'), { // addperson: value, // value, 'Name': name, 'Room_no': selectedRoomNo, 'Contact': contact, 'Address': address, 'Image': fetchImage, 'Advanced_amount': advancedAmount, 'Date': date, }); // setPresentTodo(''); } </code></pre>
[ { "answer_id": 74151913, "author": "Nensi Kasundra", "author_id": 7846071, "author_profile": "https://Stackoverflow.com/users/7846071", "pm_score": 2, "selected": true, "text": "function addNewPerson() {\n push(ref(db, '/addperson'), {\n // addperson: value,\n // va...
2022/10/21
[ "https://Stackoverflow.com/questions/74149841", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19279366/" ]
74,149,913
<p>I would like to count for each day valid items in a table. For example:</p> <p>I have in my table table1 5 entries with following myDate values:</p> <pre><code> 1. 01.10.2022 09:13 2. 01.10.2022 11:33 3. 01.10.2022 11:40 5. 02.10.2022 07:00 6. 04.10.2022 06:30 </code></pre> <p>Now I would like to count for each day the number of rows, with the following result:</p> <pre><code> 1. 01.10.2022 - 3 rows 2. 02.10.2022 - 1 row 3. 04.10.2022 - 1 row </code></pre> <p>I've already found a statement to iterate through each day of a period and join my table. But the problem is, that I am receiving duplicate values, if there are multiple values valid in my join condition:</p> <pre><code> 1. 01.10.2022 - 1 row 2. 01.10.2022 - 1 row 3. 01.10.2022 - 1 row 4. 02.10.2022 - 1 row 5. .... </code></pre> <p>here is my statement:</p> <pre><code>SELECT all_date, COALESCE (cnt, 0) FROM (SELECT to_date('01/10/2022', 'dd/mm/yyyy') + rownum - 1 AS all_date FROM dual CONNECT BY LEVEL &lt;= 30) d LEFT JOIN (SELECT TRUNC(myDate) as myDate, COUNT(myDate) AS cnt FROM table1 GROUP BY myDate) r ON d.all_date &lt; TRUNC(r.myDate); </code></pre> <p>Thanks in advance!</p> <hr /> <p>edit: I used d.all_date &lt; trunc(r.myDate) because I would like to select valid values in a timerange.</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>myKey</th> <th>myDatf</th> <th>myDatt</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>01.10.2022 08:00</td> <td>14.10.2022 08:30</td> </tr> <tr> <td>2</td> <td>01.10.2022 09:00</td> <td>07.10.2022 09:30</td> </tr> <tr> <td>3</td> <td>03.10.2022 11:00</td> <td>03.10.2022 12:00</td> </tr> <tr> <td>4</td> <td>07.10.2022 08:00</td> <td>08.10.2022 11:00</td> </tr> </tbody> </table> </div> <p>Based on previous table, I would like to get the following result. At 04.10.2022 00:00:00 there were 2 valid values with datf &lt; 04.10.2022 00:00:00 and datt &gt; 04.10.2022 00:00:00.</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>date</th> <th>count</th> </tr> </thead> <tbody> <tr> <td>02.10.2022 00:00:00</td> <td>1</td> </tr> <tr> <td>03.10.2022 00:00:00</td> <td>1</td> </tr> <tr> <td>04.10.2022 00:00:00</td> <td>2</td> </tr> <tr> <td>05.10.2022 00:00:00</td> <td>2</td> </tr> <tr> <td>06.10.2022 00:00:00</td> <td>2</td> </tr> <tr> <td>07.10.2022 00:00:00</td> <td>3</td> </tr> <tr> <td>08.10.2022 00:00:00</td> <td>2</td> </tr> <tr> <td>...</td> <td>...</td> </tr> </tbody> </table> </div>
[ { "answer_id": 74151913, "author": "Nensi Kasundra", "author_id": 7846071, "author_profile": "https://Stackoverflow.com/users/7846071", "pm_score": 2, "selected": true, "text": "function addNewPerson() {\n push(ref(db, '/addperson'), {\n // addperson: value,\n // va...
2022/10/21
[ "https://Stackoverflow.com/questions/74149913", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6442601/" ]
74,149,916
<p>Im making an accordion and wonder how to make an arrow (lets suppose its an arrow svg icon) rotate 180deg once an accordion element is clicked and expanded in Vanilla JS?</p> <p>Currently it only rotates the first element from the dom found that is matching my selected tag, because of <code>querySelector</code> and not <code>querySelectorAll</code>. How to use <code>querySelectorAll</code> properly in this case so not all of them get rotated?</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>document.querySelectorAll("details").forEach((accordion) =&gt; { accordion.addEventListener("click", () =&gt; { document.querySelectorAll("details").forEach((event) =&gt; { document.querySelector("details span").classList.add("active"); if (accordion !== event) { event.removeAttribute("open"); } }); }); });</code></pre> <pre class="snippet-code-css lang-css prettyprint-override"><code>summary{ list-style: none } details{ padding: 1rem; background-color: lightblue; } details summary{ display: flex; justify-content: space-between; } details:nth-child(even){ background-color: lightgreen; } p{ padding-top: 0.3rem; } .active{ transform: rotate(180deg); } span{ display: block; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div&gt; &lt;details&gt; &lt;summary&gt; &lt;h3&gt;item1&lt;/h3&gt; &lt;span&gt;arrow&lt;/span&gt; &lt;/summary&gt; &lt;p&gt;desc1&lt;/p&gt; &lt;/details&gt; &lt;details&gt; &lt;summary&gt; &lt;h3&gt;item2&lt;/h3&gt; &lt;span&gt;arrow&lt;/span&gt; &lt;/summary&gt; &lt;p&gt;desc2&lt;/p&gt; &lt;/details&gt; &lt;details&gt; &lt;summary&gt; &lt;h3&gt;item3&lt;/h3&gt; &lt;span&gt;arrow&lt;/span&gt; &lt;/summary&gt; &lt;p&gt;desc3&lt;/p&gt; &lt;/details&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74150023, "author": "Tushar Shahi", "author_id": 10140124, "author_profile": "https://Stackoverflow.com/users/10140124", "pm_score": 2, "selected": true, "text": "span" }, { "answer_id": 74150604, "author": "Bowiemtl", "author_id": 13088630, "author_pro...
2022/10/21
[ "https://Stackoverflow.com/questions/74149916", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16205610/" ]
74,149,928
<pre><code>int run(std::string type, std::string interval) { if(type == &quot;ST&quot;){ if(interval == &quot;SEC&quot;){ constexpr unsigned int N = 10; Runner&lt;N&gt; data(); data.parse(); } else{ constexpr unsigned int N = 20; Runner&lt;N&gt; data(); data.parse(); } } else if(type == &quot;JST&quot;){ constexpr unsigned int N = 23; Runner&lt;N&gt; data(); data.parse(); } else{ constexpr unsigned int N = 5; Runner&lt;N&gt; data(); data.parse(); } } </code></pre> <p>I want to reduce the if statements and do the conditional checks on a separate function:</p> <pre><code>constexpr unsigned int arraysize(std::string type, std::string interval){ if(type == &quot;ST&quot;){ if(interval == &quot;SEC&quot;){ return 10; } else{ return 20; } } else if(type == &quot;JST&quot;){ return 23; } else{ return 5; } } </code></pre> <p>However this doesn't work because a constexpr function cannot have a parameter of nonliteral type std::string.</p> <p>Is there a better way to take out conditional checks so that I end up with something like this:</p> <pre><code>int run(std::string type, std::string interval) { constexpr unsigned int N = arraysize(type, interval); Runner&lt;N&gt; data(); data.parse(); } </code></pre>
[ { "answer_id": 74150085, "author": "user17732522", "author_id": 17732522, "author_profile": "https://Stackoverflow.com/users/17732522", "pm_score": 3, "selected": true, "text": "run" }, { "answer_id": 74153828, "author": "Jarod42", "author_id": 2684539, "author_profil...
2022/10/21
[ "https://Stackoverflow.com/questions/74149928", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5192123/" ]
74,149,929
<p>When I begin to write type <code>Visual Studio IDE</code> and <code>VSCode</code> show not only the C# types but <code>.Net</code> types also (i.e: int - Int16, byte - Byte):</p> <p><a href="https://i.stack.imgur.com/Olb5y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Olb5y.png" alt="enter image description here" /></a></p> <p>Is it possible to hide <code>.Net</code> type intelliSense?</p>
[ { "answer_id": 74150085, "author": "user17732522", "author_id": 17732522, "author_profile": "https://Stackoverflow.com/users/17732522", "pm_score": 3, "selected": true, "text": "run" }, { "answer_id": 74153828, "author": "Jarod42", "author_id": 2684539, "author_profil...
2022/10/21
[ "https://Stackoverflow.com/questions/74149929", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16644879/" ]
74,149,934
<p>I am new to Flask, I wanted to know few things around it, like how to create a REST api i am getting this error <code>TypeError: The view function for 'create_employee' did not return a valid response</code></p> <p>Been checking some stuff on the internet and not been able to see this to solve this correctly.</p> <p>My source code is looking like this :</p> <pre><code>import pymysql from app import app from config import mysql from flask import jsonify from flask import flash, request @app.route('/api/create',methods=['POST']) def create_employee(): try: _json = request.json _name = _json['name'] _email = _json['email'] _phone = _json['phone'] _address = _json['address'] _salary = _json['salary'] if _name and _email and _phone and _address and _salary and request.methods == 'POST' : conn = mysql.connect() cursor = conn.cursor(pymysql.cursors.DictCursor) query = &quot;insert into empData (name, email, phone, address, salary) values (%s, %s,%s, %s,%s)&quot; bindData = (_name, _email, _phone, _address, _salary) cursor.execute(query,bindData) conn.commit() respone = jsonify({&quot;message&quot;:&quot;OK&quot;}) respone.status_code = 200 return respone else: return showMessage() except Exception as e: print(e) @app.route('/api/employee') def listEmployee(): try: conn = mysql.connect() cursor = conn.cursor(pymysql.cursors.DictCursor) cursor.execute(&quot;select * from empData&quot;) empRows = cursor.fetchall() respone = jsonify(empRows) respone.status_code = 200 return respone except Exception as e: print(e) @app.route('/api/employee/&lt;int:emp_id&gt;') def listsingleEmployee(emp_id): try: conn = mysql.connect() cursor = conn.cursor(pymysql.cursors.DictCursor) cursor.execute(&quot;select * from empData where id = %s&quot;, emp_id) empRows = cursor.fetchone() respone = jsonify(empRows) respone.status_code = 200 return respone except Exception as e: print(e) @app.route('/api/update',methods=['PUT']) def update_employee(): try: _json = request.json _name = _json['name'] _email = _json['email'] _phone = _json['phone'] _address = _json['address'] _salary = _json['salary'] if _name and _email and _phone and _address and _salary and request.methods == 'PUT' : conn = mysql.connect() cursor = conn.cursor(pymysql.cursors.DictCursor) #query = &quot;insert into empData (name, email, phone, address, salary) values (%s, %s,%s, %s,%s)&quot; query = &quot;update empData set name = %s, email = %s, phone = %s, address = %s, salary = %s&quot; bindData = (_name, _email, _phone, _address, _salary) cursor.execute(query,bindData) conn.commit() respone = jsonify({&quot;message&quot;:&quot;OK&quot;}) respone.status_code = 200 return respone else: return showMessage() except Exception as e: print(e) @app.errorhandler(404) def showMessage(error=None): message = { 'status': 404, 'message': 'Record not found: ' + request.url, } respone = jsonify(message) respone.status_code = 404 return respone if __name__ == &quot;__main__&quot;: app.run() </code></pre> <p>I am just starting out with Flask today. I kind of need clarification in this point.</p>
[ { "answer_id": 74150085, "author": "user17732522", "author_id": 17732522, "author_profile": "https://Stackoverflow.com/users/17732522", "pm_score": 3, "selected": true, "text": "run" }, { "answer_id": 74153828, "author": "Jarod42", "author_id": 2684539, "author_profil...
2022/10/21
[ "https://Stackoverflow.com/questions/74149934", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19813264/" ]
74,149,941
<p>Stackoverflow</p> <p>I tried to activate a role assignment in powershell. Basically trying to create a script to just run all my roles in single click - and not that I need to get to AzureAD and click every role and activate them. (and wait for activation...).</p> <p>So basically I tried this:</p> <pre><code>$schedule = New-Object Microsoft.Open.MSGraph.Model.AzureADMSPrivilegedSchedule $schedule.Type = &quot;Once&quot; #Schedule starts from now $schedule.StartDateTime =(Get-Date).ToUniversalTime().ToString(&quot;yyyy-MM-ddTHH:mm:ss.fffZ&quot;) #Schedule ends after 4 hours $schedule.endDateTime = (Get-Date).AddHours(0.5).ToUniversalTime().ToString(&quot;yyyy-MM-ddTHH:mm:ss.fffZ&quot;) Open-AzureADMSPrivilegedRoleAssignmentRequest -ProviderId 'aadRoles' -ResourceId '&lt;My Resource ID&gt;' -RoleDefinitionId 'fe930be7-5e62-47db-91af-98c3a49a38b1' -SubjectId 'af25fdae-dc28-4855-b22d-4f5881b89ea9' -AssignmentState 'Active' -Type 'userAdd' -Schedule $schedule -Reason &quot;Work&quot; </code></pre> <p>The error I receive:</p> <pre><code>Open-AzureADMSPrivilegedRoleAssignmentRequest : Error occurred while executing OpenAzureADMSPrivilegedRoleAssignmentRequest Code: InvalidScope Message: The resource scope is not valid. InnerError: RequestId: 766f029f-0be6-420b-b961-f56ce8736bd6 DateTimeStamp: Fri, 21 Oct 2022 06:36:21 GMT HttpStatusCode: BadRequest HttpStatusDescription: Bad Request HttpResponseStatus: Completed At line:10 char:1 + Open-AzureADMSPrivilegedRoleAssignmentRequest -ProviderId 'aadRoles' ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Open-AzureADMSP...signmentRequest], ApiException + FullyQualifiedErrorId : Microsoft.Open.MSGraphBeta.Client.ApiException,Microsoft.Open.MSGraphBeta.PowerShell.OpenAzureADMSPrivilegedRoleAssignmentRequest </code></pre> <p>When I try to change -Type &quot;userAdd&quot; for -Type &quot;adminAdd&quot; the error is different:</p> <pre><code>Open-AzureADMSPrivilegedRoleAssignmentRequest : Error occurred while executing OpenAzureADMSPrivilegedRoleAssignmentRequest Code: RoleAssignmentRequestPolicyValidationFailed Message: The following policy rules failed: [&quot;AdminRequestRule&quot;] InnerError: RequestId: f180bba3-d557-491f-b4be-525b8a0d6483 DateTimeStamp: Fri, 21 Oct 2022 06:55:01 GMT HttpStatusCode: BadRequest HttpStatusDescription: Bad Request HttpResponseStatus: Completed At line:7 char:1 + Open-AzureADMSPrivilegedRoleAssignmentRequest -ProviderId 'aadRoles' ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Open-AzureADMSP...signmentRequest], ApiException + FullyQualifiedErrorId : Microsoft.Open.MSGraphBeta.Client.ApiException,Microsoft.Open.MSGraphBeta.PowerShell.OpenAzureADMSPrivilegedRoleAssignmentRequest </code></pre> <p>I am actually unable to find the solution. Maybe some settings of the role? I try also change -AssigmentState for &quot;Eligible&quot; but it doesn't change much.</p>
[ { "answer_id": 74150085, "author": "user17732522", "author_id": 17732522, "author_profile": "https://Stackoverflow.com/users/17732522", "pm_score": 3, "selected": true, "text": "run" }, { "answer_id": 74153828, "author": "Jarod42", "author_id": 2684539, "author_profil...
2022/10/21
[ "https://Stackoverflow.com/questions/74149941", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20298565/" ]
74,149,944
<p>say i have a function which takes a lambda function as a parameter to access/return properties of an object, is there a way for the generic to be destructured (perhaps recursively?) so i know if that property exists? i would prefer not to extend T to any existing type as i would like to keep this functions input types as general as possible</p> <p>heres an example for clarification:</p> <pre class="lang-js prettyprint-override"><code>const binarySearch = &lt;T, U&gt;(array:T[], value:(T|U), getProperty?:(item:T, index?:number) =&gt; U):number =&gt; {} </code></pre> <p>where &quot;U&quot; could be any one of &quot;T&quot;s properties</p> <p>and which is called either by acessing a property using a lambda if it is an object array</p> <pre class="lang-js prettyprint-override"><code>const index = binarySearch(objectArray, objectProperty, (obj) =&gt; obj.property) </code></pre> <p>or by using the array value if it isnt</p> <pre class="lang-js prettyprint-override"><code>const index = binarySearch(primitiveArray, primitive) </code></pre> <p>im expecting the function to behave as a normal binary search method with more versatility as to not have to make several similar functions to access different property types (especially if those properties are nested)</p>
[ { "answer_id": 74150085, "author": "user17732522", "author_id": 17732522, "author_profile": "https://Stackoverflow.com/users/17732522", "pm_score": 3, "selected": true, "text": "run" }, { "answer_id": 74153828, "author": "Jarod42", "author_id": 2684539, "author_profil...
2022/10/21
[ "https://Stackoverflow.com/questions/74149944", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18032752/" ]
74,149,945
<p>I know that I can redirect the standard error output stream by: <em>$ ./my-C-binary 2&gt;error.log</em></p> <p>What if I want to ignore the first two characters of anything from stderr before writing to the file? I've searched but I can't seem to find a way to do so. I'm not allowed to re-build my-C-binary (i.e. not allowed to change the source code). I am also not allowed to write an additional program to help with the task, it <strong>must</strong> be solved with a single command line to modify the <em>2&gt;error.log</em> portion. I don't know how to do that even after a few days of searching and trying.</p> <p>Let's say the output of stderr is:</p> <p><em>The quick brown fox jumps over the lazy dog.</em></p> <p>The text in error.log must be:</p> <p><em>e quick brown fox jumps over the lazy dog.</em></p> <p>Thanks in advance for any suggestions and help.</p>
[ { "answer_id": 74150085, "author": "user17732522", "author_id": 17732522, "author_profile": "https://Stackoverflow.com/users/17732522", "pm_score": 3, "selected": true, "text": "run" }, { "answer_id": 74153828, "author": "Jarod42", "author_id": 2684539, "author_profil...
2022/10/21
[ "https://Stackoverflow.com/questions/74149945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20298513/" ]
74,149,952
<p>I have this simple wrapper in HTML with simple content and simple CSS but the text is not adjusting according to screen size and overflowing</p> <p>HTML</p> <pre><code>&lt;div class=&quot;no-task-wrapper&quot;&gt; &lt;h2&gt;Oops! Looks like there are no &lt;span&gt;Tasks&lt;/span&gt;&lt;/h2&gt; &lt;/div&gt; </code></pre> <p>CSS</p> <pre><code>.no-task-wrapper { color: rgb(122, 122, 122); display: grid; place-items: center; } .no-task-wrapper h2 { font-size: 2rem; font-family: var(--main-font); } .no-task-wrapper span { color: var(--main-color); font-size: inherit; } </code></pre> <p>First Pic with no overflow</p> <p><a href="https://i.stack.imgur.com/X2I0s.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/X2I0s.png" alt="No overflow img" /></a></p> <p>Second pic with overflow</p> <p><a href="https://i.stack.imgur.com/21TxN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/21TxN.png" alt="Over Flow Img" /></a></p>
[ { "answer_id": 74150003, "author": "Himanshu Gabhane", "author_id": 20291681, "author_profile": "https://Stackoverflow.com/users/20291681", "pm_score": 1, "selected": false, "text": "@media only screen and (max-width: 1200px){\n /*Tablets [601px -> 1200px]*/\n //Here you can add yo...
2022/10/21
[ "https://Stackoverflow.com/questions/74149952", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18412369/" ]
74,149,954
<p>I'm looking for an algorithm to find the longest path through an edge weighted tree. The graph is acyclic and connected, but <strong>not directed</strong> and only <strong>sparsely connected</strong>, doesn't have a defined start point and can have many leaf nodes. The longest path can only traverse an edge and pass through a vertex once.</p> <p>A simplified representation as shown in this example where the edge weights are proportional to their length</p> <p><a href="https://i.stack.imgur.com/7t5YH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7t5YH.png" alt="enter image description here" /></a></p> <p>would have the solution B-C-D-G-H-I.</p> <p>I've had a look at the standard graph traversal algorithms, e.g. BFS, DFS, MST, etc; but none seem to be a good fit for my problem.</p> <p>Before I go and implement a brute force algorithm I thought I would check here for any suggested solutions.</p>
[ { "answer_id": 74150003, "author": "Himanshu Gabhane", "author_id": 20291681, "author_profile": "https://Stackoverflow.com/users/20291681", "pm_score": 1, "selected": false, "text": "@media only screen and (max-width: 1200px){\n /*Tablets [601px -> 1200px]*/\n //Here you can add yo...
2022/10/21
[ "https://Stackoverflow.com/questions/74149954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20298474/" ]
74,149,964
<p>I don't know why the create function worked before, but now is not working. I see only &quot;It's not POST, it's GET&quot;. I have tried to delete something, for example: from <code>def index(request)</code>:</p> <pre><code>email = str(request.GET.get('autorization_email')) </code></pre> <p>and from <code>def create(request)</code></p> <pre><code>type_values = Type.objects.all() model_values = Model.objects.all() equipment_values = Equipment.objects.all() </code></pre> <p>It didn't help</p> <p>url.py</p> <pre><code>urlpatterns = [ path('', views.autorization, name='autorization'), path('home/', views.index, name='home'), path('return_equpment/', views.return_equpment, name='return_equpment'), path('create/', views.create, name='create'), ] </code></pre> <p>create.html</p> <pre><code>{% block content %} &lt;form method=&quot;post&quot; action=&quot;{% url 'create' %}&quot;&gt; {% csrf_token %} ... &lt;button type=&quot;submit&quot; class=&quot;btn btn-success&quot;&gt;Save&lt;/button&gt;&lt;br&gt; &lt;span&gt;{{ error }}&lt;/span&gt;&lt;br&gt; &lt;/form&gt; {% endblock%} </code></pre> <p>views.py</p> <pre><code>from django.shortcuts import render, redirect from .models import Booking, Type, Model, Equipment from .forms import BookingForm error = '' email = '' def index(request): global email global error email = str(request.GET.get('autorization_email')) context = { 'title': 'Main page', 'error': error, 'index_email': email } return render(request, 'main/index.html', context) def create(request): type_values = Type.objects.all() model_values = Model.objects.all() equipment_values = Equipment.objects.all() form2 = BookingForm() global error global email context = { 'form': form2, 'error': error, 'type_values': type_values, 'model_values': model_values, 'equipment_values': equipment_values, 'create_email': email } if request.method == 'POST': form2 = BookingForm(request.POST) form2.email = email form2.type = request.POST.get('type') form2.model = request.POST.get('model') form2.number = request.POST.get('number') if form2.is_valid(): form2.save() return redirect('autorization') else: error = 'Form incorrect' else: error = 'It's not POST, it's '+request.method return render(request, 'main/create.html', context) </code></pre>
[ { "answer_id": 74150003, "author": "Himanshu Gabhane", "author_id": 20291681, "author_profile": "https://Stackoverflow.com/users/20291681", "pm_score": 1, "selected": false, "text": "@media only screen and (max-width: 1200px){\n /*Tablets [601px -> 1200px]*/\n //Here you can add yo...
2022/10/21
[ "https://Stackoverflow.com/questions/74149964", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20297262/" ]
74,149,983
<p>I have an array like below. What I want to know is: how to split that array into multiple sub-arrays when the value satisfies a condition? For example, if the next value difference exceeds 9, it will automatically create a new array. Here is a sample code.</p> <pre class="lang-js prettyprint-override"><code>const arr = [1,2,3,4,5,6,7,8,25,26,27,28,29,50] // Expected result = [[1,2,3,4,5,6,7,8], [25,26,27,28,29], [50]] </code></pre> <p>I've tried using <code>array.reduce()</code> but it doesn't work or I haven't found the right way.</p>
[ { "answer_id": 74150203, "author": "Xavier Garnier", "author_id": 9015973, "author_profile": "https://Stackoverflow.com/users/9015973", "pm_score": 1, "selected": false, "text": "const arr = [1,2,3,4,5,6,7,8,25,26,27,28,29,50];\ncont DIFF = 9;\n\nconst result = arr.reduce((acc, val) => {...
2022/10/21
[ "https://Stackoverflow.com/questions/74149983", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17836676/" ]
74,149,988
<p><strong>Code:</strong></p> <pre><code>` public function up() { Schema::create('subscriptions', function (Blueprint $table) { $table-&gt;id(); $table-&gt;integer('month',4); $table-&gt;integer('price',7); $table-&gt;tinyInteger('status')-&gt;default(1); $table-&gt;timestamps(); }); }` </code></pre> <p><strong>Error:</strong> <em>QLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key (SQL: create table <code>subscriptions</code> (<code>id</code> bigint unsigned not null auto_increment primary key, <code>month</code> int not null auto_increment primary key, <code>price</code> int not null auto_increment primary key, <code>status</code> tinyint not null default '1', <code>created_at</code> timestamp null, <code>updated_at</code> timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')</em></p>
[ { "answer_id": 74150271, "author": "Ahsan", "author_id": 19147542, "author_profile": "https://Stackoverflow.com/users/19147542", "pm_score": 1, "selected": false, "text": " $table->integer('month');\n $table->integer('price');\n" }, { "answer_id": 74150278, "author": "Frances...
2022/10/21
[ "https://Stackoverflow.com/questions/74149988", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19147542/" ]
74,150,009
<p>I have a list and in that list there are multiple records of dictionaries. I want to create a new list with some of the dictionaries in my previous list.</p> <p>for example,</p> <pre><code>s_dict = [{'cs':'10', 'ca':'11', 'cb':'12', 'cc':'same'}, {'cs':'114', 'ca':'121','cb':'132', 'cc':'diff'}, {'cs':'20', 'ca':'21', 'cb':'22', 'cc':'same'}, {'cs':'210', 'ca':'211', 'cb':'212', 'cc':'diff'}] </code></pre> <p>In the above dictionary I want to make a new list below which will only contain the dictionary where the key <code>'cc' == 'same'</code> hence the new list will only contain 2 dictionaries from the 4 that where stated above.</p> <p>Is there a way of doing this?</p> <pre><code>for val in s_dict: for key in val: print(val[key]) print(type(s_dict)) index = 0 while index &lt; len(s_dict): for key in s_dict[index]: print(s_dict[index][key]) index += 1 for dic in s_dict: for val,cal in dic.items(): if cal == 'same': print(f'{val} is {cal}') else: print('nothing') </code></pre> <p>The Above are the ways I've tried doing it but then it gives me back either the keys alone or the values on their own. I want it to return a complete list but only with specific dictionaries containing a key thats equal to a specific value.</p>
[ { "answer_id": 74150271, "author": "Ahsan", "author_id": 19147542, "author_profile": "https://Stackoverflow.com/users/19147542", "pm_score": 1, "selected": false, "text": " $table->integer('month');\n $table->integer('price');\n" }, { "answer_id": 74150278, "author": "Frances...
2022/10/21
[ "https://Stackoverflow.com/questions/74150009", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20118758/" ]
74,150,012
<p>Here is my code for a bubble sort that is supposed to put the customer structs in order by the last name of the customer that is read in by ...last_customer. I am not sure why it isn't working.</p> <pre><code> void sort_customers (struct customers *p_info, int num_customers) { struct customers *p_temp, *p_walker; int current; for (current = 0; current &lt; (num_customers-1); current++) 0 for(p_walker = p_info; (p_walker-p_info) &gt; current; p_walker--) if (strcmp(p_walker-&gt;last_name, (p_info)-&gt;last_name) != 0) { p_temp = p_walker; p_walker = p_info; p_info = p_temp; } return; } </code></pre> <p>Given the ideal input: Jones, Smith, Allen</p> <p>This would be the ideal output: Allen, Jones, Smith</p> <p>As you can see this loop is supposed to set the structures in order so that when i call the structure last names in a print function, they will appear in order.</p>
[ { "answer_id": 74152252, "author": "frightenedpigeon", "author_id": 20294628, "author_profile": "https://Stackoverflow.com/users/20294628", "pm_score": 2, "selected": false, "text": "{}" }, { "answer_id": 74154945, "author": "lutz.brandt", "author_id": 20240303, "auth...
2022/10/21
[ "https://Stackoverflow.com/questions/74150012", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17406250/" ]
74,150,109
<p>I tried to do a searchbox to filter a multiple value by using the <code>StartsWith</code>. Is this possible the <code>StartsWith</code> to add-in the multiple value besides the &quot;X&quot;, like added in the &quot;Y&quot;, &quot;z&quot;? If yes, how to add-in?</p> <pre><code>StringBuilder sb = new StringBuilder(); string dateStart = txtDateStart.Text; string dateEnd = txtDateEnd.Text; string filter = txtFilter.Text; if (!filter.StartsWith(&quot;X&quot;)) return; </code></pre>
[ { "answer_id": 74152252, "author": "frightenedpigeon", "author_id": 20294628, "author_profile": "https://Stackoverflow.com/users/20294628", "pm_score": 2, "selected": false, "text": "{}" }, { "answer_id": 74154945, "author": "lutz.brandt", "author_id": 20240303, "auth...
2022/10/21
[ "https://Stackoverflow.com/questions/74150109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13074671/" ]
74,150,114
<p>I am thinking a way to order the data frame and create a column to sort the order. For example:</p> <pre><code>df = pd.DataFrame({'YYYYMM':[202206,202207,202206,202209,202206,202207]}) YYYYMM 0 202206 1 202207 2 202206 3 202209 4 202206 5 202207 </code></pre> <p>Then I tried to order it by using numpy</p> <pre><code>df['order'] = np.argsort(df['YYYYMM']) YYYYMM order 0 202206 0 1 202207 2 2 202206 4 3 202209 1 4 202206 5 5 202207 3 </code></pre> <p>However, I want the same value can share the same order like</p> <pre><code> YYYYMM ORDER 0 202206 0 1 202207 1 2 202206 0 3 202209 2 4 202206 0 5 202207 1 </code></pre> <p>What should I do to achieve it? Thank you.</p>
[ { "answer_id": 74152252, "author": "frightenedpigeon", "author_id": 20294628, "author_profile": "https://Stackoverflow.com/users/20294628", "pm_score": 2, "selected": false, "text": "{}" }, { "answer_id": 74154945, "author": "lutz.brandt", "author_id": 20240303, "auth...
2022/10/21
[ "https://Stackoverflow.com/questions/74150114", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14269135/" ]
74,150,141
<p>Hi :) my question is basically what the title says. How do i create a function that calls another function ten times and only if all those times the function2 returns True function 1 prints “good job”</p> <p>For example:</p> <pre><code> def function_one(s) #returns true if string is increasing x = all(x &lt;= y for x, y in itertools.pairwise(seq)) return x </code></pre> <p>Function 2 should only print good job if function one returns true when called ten times. I tried:</p> <pre><code> s = random.randint(0,10) for i in range (10): if function_one(s) == True: print (“Good job”) </code></pre> <p>But this prints it the second function one is true, no matter how many other falses there were prior. Please help :)</p>
[ { "answer_id": 74150272, "author": "Swifty", "author_id": 20267366, "author_profile": "https://Stackoverflow.com/users/20267366", "pm_score": 0, "selected": false, "text": "def func2 ():\n s = random.randint(0,10)\n flag = True\n for i in range (10):\n newtry = function_o...
2022/10/21
[ "https://Stackoverflow.com/questions/74150141", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20265420/" ]
74,150,144
<p><a href="https://i.stack.imgur.com/J0XNA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/J0XNA.png" alt="enter image description here" /></a></p> <p>This above is a simple example</p> <p>I want to add the data which columns with &quot;a&quot;</p> <pre><code>df['a+abc+bca'] = df[['a', 'abc','bca']].sum(axis=1) </code></pre> <p>Although this method can be counted successfully, it is not very flexible, because if I have many columns whose field names contain &quot;A&quot;, the drawbacks of this method will appear.</p> <p>I would like to know if there is a more convenient or flexible way to achieve this? I am a novice in Python, if this seems to be a very simple question, please be able to answer it for me, thank you very much for your help.</p>
[ { "answer_id": 74150181, "author": "Ynjxsjmh", "author_id": 10315163, "author_profile": "https://Stackoverflow.com/users/10315163", "pm_score": 4, "selected": true, "text": "DataFrame.filter(like=)" } ]
2022/10/21
[ "https://Stackoverflow.com/questions/74150144", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19540809/" ]
74,150,147
<p>I need to replace sequences (of various length) of characters by another character. I am working in Eclipse on xml files</p> <p>For exemple <code>--------</code> should be replaced by <code>********</code>.</p> <p>The replacement should be done only for sequences of at least 3 characters, not 1 or 2.</p> <p>It is easy to find the matching sequences in regex for example with <code>-{3,30}</code> but I don't understand how to specify the replacement sequence.</p>
[ { "answer_id": 74151465, "author": "Wiktor Stribiżew", "author_id": 3832970, "author_profile": "https://Stackoverflow.com/users/3832970", "pm_score": 2, "selected": true, "text": "(?:\\G(?!\\A)|(?<!-)(?=-{3,30}(?!-)))-\n" }, { "answer_id": 74152746, "author": "anubhava", ...
2022/10/21
[ "https://Stackoverflow.com/questions/74150147", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5836577/" ]
74,150,168
<p>I'm a beginner in c language and programming, I heard that an array's elements were stored in successive memory location.</p> <ol> <li>if I somehow manage to make memory location like this:<a href="https://i.stack.imgur.com/nQGX5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nQGX5.png" alt="memory drawing" /></a> what will happen if I declare an <code>int8_t arr[2]</code>, will it go wrong?</li> <li>does compiler have a list of the allocated memory and check when it declares variable?</li> <li>calling <code>malloc(1)</code> in a while loop, why their return value has the difference of 0x20?</li> </ol> <p>thanks for your helping!</p>
[ { "answer_id": 74150214, "author": "0___________", "author_id": 6110094, "author_profile": "https://Stackoverflow.com/users/6110094", "pm_score": 1, "selected": false, "text": "int8_t" }, { "answer_id": 74150328, "author": "Özgür Güzeldereli", "author_id": 12196664, "...
2022/10/21
[ "https://Stackoverflow.com/questions/74150168", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19113599/" ]
74,150,199
<p>initial state is:</p> <pre><code> const [state, setState] = useState({ priceType: 0, recurrenceType: 0, start_date: '', end_date: '', minCapacity: 0, maxCapacity: 0, price: 0, min: 0, max: 0, days: [] }); </code></pre> <p>data which I want to update, <a href="https://i.stack.imgur.com/mztLV.png" rel="nofollow noreferrer">SpecialPriceEditData</a></p> <p>I am trying in this way;</p> <pre><code> useEffect(() =&gt; { { if (SpecialPriceEditData !== null) { setState(SpecialPriceEditData) } setState({ ...state }); } }, [SpecialPriceEditData]); </code></pre> <p>But state not getting update,</p> <p>How to achive this</p> <p>Thank you..</p>
[ { "answer_id": 74150214, "author": "0___________", "author_id": 6110094, "author_profile": "https://Stackoverflow.com/users/6110094", "pm_score": 1, "selected": false, "text": "int8_t" }, { "answer_id": 74150328, "author": "Özgür Güzeldereli", "author_id": 12196664, "...
2022/10/21
[ "https://Stackoverflow.com/questions/74150199", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20290421/" ]
74,150,202
<p>I tried to sample 25 samples by using lapply,</p> <pre><code>a = list(c(1:5),c(100:105),c(110:115),c(57:62),c(27:32)) lapply(a,function(x)sample(x,5)) </code></pre> <p>is it possible to use base::sample to do the vectorized sampling?</p> <p>i.e.</p> <pre><code>sample(c(5,5),a) </code></pre>
[ { "answer_id": 74150214, "author": "0___________", "author_id": 6110094, "author_profile": "https://Stackoverflow.com/users/6110094", "pm_score": 1, "selected": false, "text": "int8_t" }, { "answer_id": 74150328, "author": "Özgür Güzeldereli", "author_id": 12196664, "...
2022/10/21
[ "https://Stackoverflow.com/questions/74150202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11124121/" ]
74,150,236
<p>given a List in Python I want top create a dictionary that stores all possible two sums as keys and the corresponding indices as values, e.g.</p> <p>list = [1,0,-1, 0] Then I would to compute the dictionary {1:{0,1}, {0,3}, 0: {1,3},{0,2}, -1:{1,2}, {2,3}}.</p> <p>I am having troubles finding out how to have a dictionary where one key corresponds to multiple values. If I use dict[sum]={i,j} I am always replacing the entries in my dictionary while instead I would like to add them.</p> <p>Does anyone know if there exists a solution?</p>
[ { "answer_id": 74150214, "author": "0___________", "author_id": 6110094, "author_profile": "https://Stackoverflow.com/users/6110094", "pm_score": 1, "selected": false, "text": "int8_t" }, { "answer_id": 74150328, "author": "Özgür Güzeldereli", "author_id": 12196664, "...
2022/10/21
[ "https://Stackoverflow.com/questions/74150236", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14571933/" ]
74,150,287
<p>So I want to log in with a certain role where I try to login with the user role, but it always goes into the else condition, because <code>snapshot.child(uid).child(&quot;role&quot;).equals(&quot;user&quot;)</code> this condition always false. Is there any solution to this problem?</p> <p><a href="https://i.stack.imgur.com/yYReb.png" rel="nofollow noreferrer">this is my database structure</a></p> <p>and this is my code :</p> <pre><code>package com.example.finalproject2; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.os.Bundle; import android.util.Patterns; import android.view.View; import android.widget.Button; import android.widget.ProgressBar; import android.widget.Switch; import android.widget.TextView; import android.widget.Toast; import com.google.firebase.auth.FirebaseAuth; import com.google.firebase.database.DataSnapshot; import com.google.firebase.database.DatabaseError; import com.google.firebase.database.DatabaseReference; import com.google.firebase.database.FirebaseDatabase; import com.google.firebase.database.ValueEventListener; public class LoginScreenUser extends AppCompatActivity implements View.OnClickListener{ private TextView phone,pass; private Button button; private ProgressBar progressBar; private FirebaseAuth mAuth; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login_screen); phone = (TextView) findViewById(R.id.nomorTelp); pass = (TextView) findViewById(R.id.passUser); button = (Button) findViewById(R.id.loginUser); progressBar = (ProgressBar) findViewById(R.id.loads); button.setOnClickListener(this); progressBar.setVisibility(View.GONE); } @Override public void onClick(View v) { switch(v.getId()){ case R.id.loginUser: userlogin(); } } private void userlogin() { String nomor = phone.getText().toString().trim(); String password = pass.getText().toString().trim(); // progressBar.setVisibility(View.VISIBLE); String uid = FirebaseAuth.getInstance().getCurrentUser().getUid(); DatabaseReference DatabaseReference = FirebaseDatabase.getInstance().getReference(); DatabaseReference.child(&quot;Users&quot;).orderByChild(&quot;role&quot;).equalTo(&quot;user&quot;).addValueEventListener(new ValueEventListener() { @Override public void onDataChange(@NonNull DataSnapshot snapshot) { if (snapshot.child(nomor).exists() &amp;&amp; snapshot.child(password).exists() &amp;&amp; snapshot.child(uid).child(&quot;role&quot;).equals(&quot;user&quot;)){ Toast.makeText(LoginScreenUser.this,&quot;Login Succes&quot;,Toast.LENGTH_SHORT).show(); back(); }else{ Toast.makeText(LoginScreenUser.this,&quot;Data Belum Terdaftar&quot;,Toast.LENGTH_SHORT).show(); } } @Override public void onCancelled(@NonNull DatabaseError error) { } }); } private void back() { startActivity(new Intent(this,MainActivity.class)); } } </code></pre>
[ { "answer_id": 74150214, "author": "0___________", "author_id": 6110094, "author_profile": "https://Stackoverflow.com/users/6110094", "pm_score": 1, "selected": false, "text": "int8_t" }, { "answer_id": 74150328, "author": "Özgür Güzeldereli", "author_id": 12196664, "...
2022/10/21
[ "https://Stackoverflow.com/questions/74150287", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15769500/" ]
74,150,375
<p>I need to find a way when the request gets a 403 I can use <code>if</code> before calling JSON with status and data. Only 403 returns HTML</p> <pre class="lang-js prettyprint-override"><code>const response = await fetch( // Fetch info ).then((response) =&gt; { if (!response.ok &amp;&amp; response.status === 403) { // Stuffs throw new Error('Exception message'); // Raise error to stop the code } return response.json(); }) .then((data) =&gt; ({ // I need use status code again, and keep the if statement 403 on top. status: response.status, data, })); </code></pre>
[ { "answer_id": 74150214, "author": "0___________", "author_id": 6110094, "author_profile": "https://Stackoverflow.com/users/6110094", "pm_score": 1, "selected": false, "text": "int8_t" }, { "answer_id": 74150328, "author": "Özgür Güzeldereli", "author_id": 12196664, "...
2022/10/21
[ "https://Stackoverflow.com/questions/74150375", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14550534/" ]
74,150,405
<p>I have made a Main Navigator in which I have made 2 sub navigators: This is my MainNavigator:</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>import React, {useEffect, useState} from 'react'; import {createStackNavigator} from '@react-navigation/stack'; import storage from '../services/storage'; import {useDispatch, useSelector} from 'react-redux'; import {setUser} from '../store/reducers/auth'; import AuthNavigation from './AuthNavigation'; import MainNavigation from './MainNavigation'; const {Navigator, Screen} = createStackNavigator(); const StackNavigation = () =&gt; { const [isLogged, setIsLogged] = useState(false); const dispatch = useDispatch(); const loadUser = async () =&gt; { try { const data = await storage.get('USER'); if (data !== null &amp;&amp; data !== '') { console.log('Hello user', data); dispatch(setUser(data)); setIsLogged(true); } } catch (error) { console.log('APP JS ERROR', error.message); } }; useEffect(() =&gt; { loadUser(); }, []); return ( &lt;Navigator screenOptions={{headerShown: false}}&gt; {isLogged ? ( &lt;Screen name="MainNavigation" component={MainNavigation} /&gt; ) : ( &lt;Screen name="AuthNavigation" component={AuthNavigation} /&gt; )} &lt;/Navigator&gt; ); }; export default StackNavigation;</code></pre> </div> </div> </p> <p>These are my sub navigators:</p> <p>AuthNavigation: <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>import React from 'react'; import {createStackNavigator} from '@react-navigation/stack'; import SignUpScreen from '../screens/AccountScreens/SignUpScreen'; import LoginScreen from '../screens/AccountScreens/LoginScreen'; import ForgotPassword from '../screens/AccountScreens/ForgotPassword'; import OTPVerification from '../screens/AccountScreens/OTPVerification'; import SetNewPassword from '../screens/AccountScreens/SetNewPassword'; const {Navigator, Screen} = createStackNavigator(); const AuthNavigation = () =&gt; { const verticalAnimation = { gestureDirection: 'vertical', cardStyleInterpolator: ({current, layouts}) =&gt; { return { cardStyle: { transform: [ { translateY: current.progress.interpolate({ inputRange: [0, 1], outputRange: [layouts.screen.height, 0], }), }, ], }, }; }, }; return ( &lt;Navigator initialRouteName={'Login'} screenOptions={{headerShown: false, animationEnabled: true}}&gt; &lt;Screen name="SignUp" component={SignUpScreen} options={verticalAnimation} /&gt; &lt;Screen name="Login" component={LoginScreen} /&gt; &lt;Screen name="ForgotPassword" component={ForgotPassword} /&gt; &lt;Screen name="OTPVerification" component={OTPVerification} /&gt; &lt;Screen name="SetNewPassword" component={SetNewPassword} /&gt; &lt;/Navigator&gt; ); }; export default AuthNavigation;</code></pre> </div> </div> </p> <p>MainNavigation:</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>import React, {useState} from 'react'; import {createStackNavigator} from '@react-navigation/stack'; import MyTabNavigation from './MyTabNavigation'; import GymDetailScreen from '../screens/InnerScreens/GymDetailScreen'; import AccountOverview from '../screens/DrawerScreens/AccountOverview'; import SubscriptionDetails from '../screens/DrawerScreens/SubscriptionDetails'; import BillingDetails from '../screens/DrawerScreens/BillingDetails'; import ChangePassword from '../screens/DrawerScreens/ChangePassword'; import BuySubscribtion from '../screens/InnerScreens/BuySubscribtion'; import ScanScreen from '../screens/InnerScreens/ScanScreen'; import PaymentSummary from '../screens/InnerScreens/PaymentSummary'; import PaymentMethod from '../screens/InnerScreens/PaymentMethod'; const {Navigator, Screen} = createStackNavigator(); const MainNavigation = () =&gt; { const horizontalAnimation = { cardStyleInterpolator: ({current, layouts}) =&gt; { return { cardStyle: { transform: [ { translateX: current.progress.interpolate({ inputRange: [0, 1], outputRange: [layouts.screen.width, 0], }), }, ], }, }; }, }; return ( &lt;Navigator initialRouteName={'MyTabNavigation'} screenOptions={{headerShown: false, animationEnabled: true}}&gt; &lt;Screen name="GymDetailScreen" component={GymDetailScreen} /&gt; &lt;Screen name="MyTabNavigation" component={MyTabNavigation} options={horizontalAnimation} /&gt; &lt;Screen name="AccountOverview" component={AccountOverview} /&gt; &lt;Screen name="SubscriptionDetails" component={SubscriptionDetails} /&gt; &lt;Screen name="BillingDetails" component={BillingDetails} /&gt; &lt;Screen name="ChangePassword" component={ChangePassword} /&gt; &lt;Screen name="BuySubscription" component={BuySubscribtion} /&gt; &lt;Screen name="ScanScreen" component={ScanScreen} /&gt; &lt;Screen name="PaymentSummary" component={PaymentSummary} /&gt; &lt;Screen name="PaymentMethod" component={PaymentMethod} /&gt; &lt;/Navigator&gt; ); }; export default MainNavigation;</code></pre> </div> </div> </p> <p>I want to go to MainNavigator on Login which is in AuthNavigator, Here is how I am doing this:</p> <pre><code>navigation.navigate('MainNavigation'); </code></pre> <p>But its giving me this error:</p> <p>The action 'NAVIGATE' with payload {&quot;name&quot;:&quot;MainNavigation&quot;} was not handled by any navigator.</p> <p>Do you have a screen named 'MainNavigation'?</p> <p>If you're trying to navigate to a screen in a nested navigator, see <a href="https://reactnavigation.org/docs/nesting-navigators#navigating-to-a-screen-in-a-nested-navigator" rel="nofollow noreferrer">https://reactnavigation.org/docs/nesting-navigators#navigating-to-a-screen-in-a-nested-navigator</a>.</p> <p>This is a development-only warning and won't be shown in production.</p> <p>Please help me with this coz I am trying this for the first time. Thanks in advance</p>
[ { "answer_id": 74150214, "author": "0___________", "author_id": 6110094, "author_profile": "https://Stackoverflow.com/users/6110094", "pm_score": 1, "selected": false, "text": "int8_t" }, { "answer_id": 74150328, "author": "Özgür Güzeldereli", "author_id": 12196664, "...
2022/10/21
[ "https://Stackoverflow.com/questions/74150405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16840989/" ]
74,150,409
<p>I am trying to understand how Go context cancellation works underneath in client service communication (say, any gRPC API call ).</p> <p>Let's say a client canceled the context on its end. Does it result in a new HTTP request to the server communicating the context of the previous/ongoing gRPC request is canceled? How does server knows if client cancelled the context?</p>
[ { "answer_id": 74150214, "author": "0___________", "author_id": 6110094, "author_profile": "https://Stackoverflow.com/users/6110094", "pm_score": 1, "selected": false, "text": "int8_t" }, { "answer_id": 74150328, "author": "Özgür Güzeldereli", "author_id": 12196664, "...
2022/10/21
[ "https://Stackoverflow.com/questions/74150409", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5432699/" ]
74,150,413
<p>I want to check for duplicate rows . and see there column values . if there were only few columns in my table - 2 for example - I would have done something like: '''</p> <pre><code>select col1, col2 ,count(*) from mytable group by col1,col2 having count(*) &gt; 1. </code></pre> <p>''' but I have dozens of column in my table .... and using the above syntax is tedious to specify all the columns in the table. trying another approach with select distinct ... will not identify for me the content of duplicated rows . I tried somthing like '''</p> <pre><code>select * , count (*) from my table group by * </code></pre> <p>''' but that doesn't work.</p>
[ { "answer_id": 74150584, "author": "Littlefoot", "author_id": 9097906, "author_profile": "https://Stackoverflow.com/users/9097906", "pm_score": 1, "selected": false, "text": "SQL> select * from my_data order by 1;\n\nFULL_NAME FIRST_NAME LAST_NAME\n---------- -----------------...
2022/10/21
[ "https://Stackoverflow.com/questions/74150413", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2026754/" ]
74,150,425
<p>I have a list of data:</p> <pre><code>data = ['value', '&quot;&quot;&quot;', 'Comment 1st row', 'Comment 2nd row', 'Comment 3rd row', '&quot;&quot;&quot;', 'another value'] </code></pre> <p>I would like to remove the whole comment from the list, including docstrings. Also not just once, but everytime a comment appears.</p> <p>Could someone help?</p>
[ { "answer_id": 74150452, "author": "mozway", "author_id": 16343464, "author_profile": "https://Stackoverflow.com/users/16343464", "pm_score": 3, "selected": true, "text": "\"\"\"" }, { "answer_id": 74150477, "author": "Community", "author_id": -1, "author_profile": "h...
2022/10/21
[ "https://Stackoverflow.com/questions/74150425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10155537/" ]
74,150,460
<p>I've created a custom button and set two images, one is for normal, and the other is for the selected mode. But the voice-over always says the normal image name text when the button is not selected. I've tried a lot but could not disable it.</p> <p>When I disable the button imageView accessibility it is not working.</p> <pre><code>button.imageView?.isAccessibilityElement = false </code></pre> <p>When I disable the button accessibility, the voice-over is not working in accessibility mode.</p> <pre><code>button.isAccessibilityElement = false </code></pre> <p>If I remove the '.normal' mode image then it works, but normal mode image functionality is not considered/worked there. I'm surfing a lot. Help anyone and thanks in advance.</p> <p>Code:</p> <pre><code>self.setImage(UIImage.init(named: imageName1), for: .normal) self.setImage(UIImage.init(named: imageName1), for: .selected) </code></pre>
[ { "answer_id": 74151407, "author": "Fabio", "author_id": 5575955, "author_profile": "https://Stackoverflow.com/users/5575955", "pm_score": 2, "selected": false, "text": " let newButton: UIButton = {\n let button = UIButton(type: .system)\n button.backgroundColor = .red\n button....
2022/10/21
[ "https://Stackoverflow.com/questions/74150460", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8493670/" ]
74,150,463
<p>I would like to update the schema of an spark dataframe by first converting it to a dataset which contains less columns. Background: i would like to remove some deeply nested fields from a schema.</p> <p>I tried the following but the schema does not change:</p> <pre><code>import org.apache.spark.sql.functions._ val initial_df = spark.range(10).withColumn(&quot;foo&quot;, lit(&quot;foo!&quot;)).withColumn(&quot;bar&quot;, lit(&quot;bar!&quot;)) case class myCaseClass(bar: String) val reduced_ds = initial_df.as[myCaseClass] </code></pre> <p>The schema still includes the other fields:</p> <pre><code>reduced_ds.schema // StructType(StructField(id,LongType,false),StructField(foo,StringType,false),StructField(bar,StringType,false)) </code></pre> <p>Is there a way to update the schema that way?`</p> <p>It also confuses me that when i collect the dataset it only returns the fields defined in the case class:</p> <pre><code>reduced_ds.limit(1).collect() // Array(myCaseClass(bar!)) </code></pre>
[ { "answer_id": 74151407, "author": "Fabio", "author_id": 5575955, "author_profile": "https://Stackoverflow.com/users/5575955", "pm_score": 2, "selected": false, "text": " let newButton: UIButton = {\n let button = UIButton(type: .system)\n button.backgroundColor = .red\n button....
2022/10/21
[ "https://Stackoverflow.com/questions/74150463", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20298679/" ]
74,150,485
<p>I was wondering what is the difference between this two code examples. The first one doesn't work(Key error) but the second one works perfectly. I was using the append function and somehow it didn't work for me. Can someone explain why is it. Thank you!</p> <ul> <li>First one (with key error)</li> </ul> <pre><code>class Solution: def containsNearbyDuplicate(self, nums: List[int], k: int) -&gt; bool: map = dict() for i, j in enumerate(nums): map[i].append(j) #adding the element using append function return(map) </code></pre> <p>Traceback (most recent call last): File &quot;C:\Users\Larionova\Desktop\containsNearbyDuplicate.py&quot;, line 14, in s1 = Solution().containsNearbyDuplicate(list1, 3) File &quot;C:\Users\Larionova\Desktop\containsNearbyDuplicate.py&quot;, line 11, in containsNearbyDuplicate map[i].append(j) KeyError: 0</p> <pre><code>class Solution: def containsNearbyDuplicate(self, nums: List[int], k: int) -&gt; bool: map = dict() for i, j in enumerate(nums): map[i] = j return(map) </code></pre>
[ { "answer_id": 74150524, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "map[i].append(j)" }, { "answer_id": 74150722, "author": "Vishesh Varma", "author_id": 14482993, "author_...
2022/10/21
[ "https://Stackoverflow.com/questions/74150485", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15121796/" ]
74,150,494
<p>I have a &quot;MainForm&quot; and a &quot;GraphicsForm&quot;. Clicking &quot;New&quot; on the main form, a &quot;GraphicsForm&quot; will be created.</p> <p>The problem is that when I create multiple &quot;GraphicsForm&quot;, and when I want to save the content of one of the &quot;GraphicsForm&quot;, I need to clicking &quot;Save&quot; on the &quot;MainForm&quot; and the program will save the content of the active &quot;GraphicsForm&quot; to a file, I don't know how to pass the content of this &quot;GraphicsForm&quot; to &quot;MainForm&quot; for storage.</p> <p>MainForm.cs</p> <pre><code>public partial class MainForm : Form { public MainForm() { InitializeComponent(); } private ToolStripMenuItem _winMenuItem = new ToolStripMenuItem(); private GraphicsForm _graphicsForm; private int _counter = 1; private void New_Click(objec sender, EventArgs e) { _winMenuItem.Name = &quot;Win&quot;; _winMenuItem.Text = &quot;Windows&quot;; int item = MainMenuStrip.Items.IndexOf(_winMenuItem); if (item == -1) { MainMenuStrip.Items.Add(_winMenuItem); MainMenuStrip.MdiWindowListItem = _winMenuItem; } _graphicsForm = new GraphicsForm(); _graphicsForm.Name = string.Concat(&quot;Win_&quot;, _counter.ToString()); _graphicsForm.Text = _graphicsForm.Name; _graphicsForm.MdiParent = this; _graphicsForm.Show(); _graphicsForm.WindowState = FormWindowState.Maximized; _counter++; } private void Save_Click(object sender, EventArgs e) { ... // Problem here } private void Open_Click(object sender, EventArgs e) { ... // Problem here } } </code></pre> <p>GraphicsForm.cs</p> <pre><code>public partial class GraphicsForm : Form { //StorageDoc is a class to manage all the graphics drawn by the user in the form. private StorageDoc _storageDoc = new StotageDoc(); public GraphicsForm() { InitializeComponent(); } private Canvas_MouseDown() { } private Canvas_Paint() { } ... </code></pre>
[ { "answer_id": 74150524, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "map[i].append(j)" }, { "answer_id": 74150722, "author": "Vishesh Varma", "author_id": 14482993, "author_...
2022/10/21
[ "https://Stackoverflow.com/questions/74150494", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
74,150,497
<p>I have a dataframe that looks like this (<a href="https://pastebin.com/embed_js/3tKLJ5Yv" rel="nofollow noreferrer">link to csv</a>)</p> <pre><code>id time value approved 1 0:00 10 false 1 0:01 20 true 1 0:02 30 true 1 0:03 20 true 1 0:04 40 false 1 0:05 35 false 1 0:06 60 false 2 0:07 20 true 2 0:08 30 true 2 0:09 50 false 2 0:10 45 false 2 0:11 70 false 2 0:12 62 false </code></pre> <p>and I want to create two more columns that will keep the max approved values with a tolerance of 2 secs and the time of the respective max values. So I want it to look like this</p> <pre><code>id time value approved max_approved max_time 1 0:00 10 false NaN NaN 1 0:01 20 true 20 0:01 1 0:02 30 true 30 0:02 1 0:03 20 true 30 0:02 1 0:04 40 false 40 0:04 1 0:05 35 false 40 0:04 1 0:06 60 false 40 0:04 2 0:07 20 true 20 0:07 2 0:08 30 true 30 0:08 2 0:09 50 false 50 0:09 2 0:10 45 false 50 0:09 2 0:11 70 false 50 0:09 </code></pre> <p>How can I do this? Thanks</p>
[ { "answer_id": 74150706, "author": "tturbo", "author_id": 12284585, "author_profile": "https://Stackoverflow.com/users/12284585", "pm_score": 0, "selected": false, "text": "max_value = 0\nfor index, row_data in df.iterrows():\n # your logic, e.g.\n if row_data.approved and row_data.val...
2022/10/21
[ "https://Stackoverflow.com/questions/74150497", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5003784/" ]
74,150,499
<p><strong>Question:</strong></p> <p>I am learning c++, and i created a class to represent complex numbers. I created a copy constructor with the format</p> <pre><code>complex(const complex &amp;c); </code></pre> <p>and the program worked fine.</p> <p>Then, i removed the const (so it became: <code>complex( complex &amp;c);</code> ) and the program doesn't work. It gives me this error:</p> <p><code>&quot;message&quot;: &quot;class \&quot;complex\&quot; has no suitable copy constructor&quot;</code></p> <p>and it refers to the add method. The add method is this:</p> <pre><code>complex complex::add(complex &amp;c){ return complex( re + c.re, im + c.im); }; </code></pre> <p>If i do not add this method (and methods that generally return a complex number that is created in the return line, like this: <code>return complex (integer_variable_Re, integer_variable_Im)</code> ) the program works fine. When i add these kinds of methods, it throws me the error. I cannot understand why this doesn't work, as it should call the constructor that takes two integers and not the copy constructor.</p> <p><strong>Specs:</strong> Ubuntu: 20.04Lts</p> <p>IDE: VScode</p> <p>Compliler: G++ 9.4</p> <p>(it says somewhere this: <code>GNU C17 (Ubuntu 9.4.0-1ubuntu1~20.04.1) version 9.4.0 (x86_64-linux-gnu) compiled by GNU C version 9.4.0, GMP version 6.2.0, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.22.1-GMP</code>, do not know if it it the compliler standard.)</p> <p><strong>Whole error message:</strong> <code>[{ &quot;resource&quot;: &quot;/home/papaveneti/Documents/Programming/LearnCpp/complex_classStack.cpp&quot;, &quot;owner&quot;: &quot;C/C++&quot;, &quot;code&quot;: &quot;334&quot;, &quot;severity&quot;: 8, &quot;message&quot;: &quot;class \&quot;complex\&quot; has no suitable copy constructor&quot;, &quot;source&quot;: &quot;C/C++&quot;, &quot;startLineNumber&quot;: 48, &quot;startColumn&quot;: 12, &quot;endLineNumber&quot;: 48, &quot;endColumn&quot;: 19 }]</code></p> <p><strong>Whole program:</strong></p> <pre><code>#include &lt;iostream&gt; #include &lt;math.h&gt; using namespace std; class complex { public: complex (double r, double i); // constructor // only method that does not specify type //default constructor complex (); //copy cosntructor complex( complex &amp;c); // methods: complex add(complex &amp;c); void norm1(); private: // fields: double re, im; double norm; }; //constructor does not need to name a type complex::complex(double r=0.0, double i=0.0){ // default values are 0 re = r; im = i; norm1(); }; complex::complex(){ re=im=0; } complex::complex( complex &amp;c){ re=c.re; im=c.im; } void complex::norm1(){ norm = sqrt(re*re + im*im); }; complex complex::add(complex &amp;c){ return complex( re + c.re, im + c.im); }; int main(){ complex c1(3,4), c2(1,2); return 0; } </code></pre>
[ { "answer_id": 74150879, "author": "Jakob Stark", "author_id": 17862371, "author_profile": "https://Stackoverflow.com/users/17862371", "pm_score": 2, "selected": true, "text": "return complex( re + c.re, im + c.im);\n" }, { "answer_id": 74150943, "author": "Jason Liam", "...
2022/10/21
[ "https://Stackoverflow.com/questions/74150499", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17330440/" ]
74,150,502
<p>I want to remove the first and last characters of a text in a cell. I know how to remove just the first or the last with formulas such as =LEFT(A27, LEN(A27)-1) but i want to combine two formulas at the same time for first and last character or maybe there is a formula that I'm not aware of which removes both (first and last characters) at the same time.</p> <p>I know about Power Tool but i want to avoid using this tool and I'm trying to realize this simply by formulas.</p>
[ { "answer_id": 74150569, "author": "Tim Biegeleisen", "author_id": 1863229, "author_profile": "https://Stackoverflow.com/users/1863229", "pm_score": 2, "selected": true, "text": "REGEXREPLACE()" }, { "answer_id": 74153122, "author": "player0", "author_id": 5632629, "a...
2022/10/21
[ "https://Stackoverflow.com/questions/74150502", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7301164/" ]
74,150,503
<p>I have the following code. A <code>body</code> object and a <code>sensitive</code> word array.</p> <p>If the <code>body</code> key contains any word from <code>sensitive</code> words, it should returns true.</p> <pre><code>const body = { name: &quot;&quot;, email: &quot;&quot;, otpp: &quot;&quot; } const sensitiveWords = [&quot;password&quot;, &quot;pin&quot;, &quot;otp&quot;] const isSensitive = sensitiveWords.some(el =&gt; Object.keys(body).map(name =&gt; name.toLowerCase()).includes(el)) || false console.log(isSensitive); // returns: false // expected result: true </code></pre> <p>But as you can see, the word <code>otp</code> is in the sensitive words, but its not matching <code>otpp</code>. I guess its because its looking for full string match.</p> <p>I need the above function to return true since the key contains <code>otp</code> in <code>otpp</code>.</p> <p>Thank you.</p>
[ { "answer_id": 74150607, "author": "Bergi", "author_id": 1048572, "author_profile": "https://Stackoverflow.com/users/1048572", "pm_score": 4, "selected": true, "text": "const containsSensitive = sensitiveWords.some(el =>\n Object.keys(body).some(name =>\n// ^^^^\n na...
2022/10/21
[ "https://Stackoverflow.com/questions/74150503", "https://Stackoverflow.com", "https://Stackoverflow.com/users/890082/" ]
74,150,518
<p>I have two lists whose no. of elements are not equal. I want to put these two lists in a csv whose heading is 'video' and 'image'. But as the elements of these 2 lists are not the same I got an error.</p> <pre><code>ValueError: All arrays must be of the same length import pandas as pd VID = ['00001', '05445', '987457', '15455'] IMG = ['00001', '05445', '987457'] df = pd.DataFrame(data={&quot;video&quot;: VID, &quot;image&quot;: IMG}) df.to_csv(&quot;./file.csv&quot;, sep=',',index=False) </code></pre>
[ { "answer_id": 74150607, "author": "Bergi", "author_id": 1048572, "author_profile": "https://Stackoverflow.com/users/1048572", "pm_score": 4, "selected": true, "text": "const containsSensitive = sensitiveWords.some(el =>\n Object.keys(body).some(name =>\n// ^^^^\n na...
2022/10/21
[ "https://Stackoverflow.com/questions/74150518", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20294040/" ]
74,150,519
<p>how can i extract the first number from this array? The number is taken from the variable and then divided, from 0222 to [ 0, 2, 2, 2 ] I need to check the first number, but I can't.</p> <p>thank you</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>var cellF9 = sh.getRange(9, 6, 1, 1).getValue(); String(cellF9).split("").map(Number); function splitNum(num) { return String(num).split("").map(Number); } console.log(splitNum(cellF9)); switch (cellF9[0]) { case 0: sh.getRange("F18").setValue("test"); break; default: SpreadsheetApp.getUi().alert(".......", ".............", SpreadsheetApp.getUi().ButtonSet.OK); }</code></pre> </div> </div> </p>
[ { "answer_id": 74150607, "author": "Bergi", "author_id": 1048572, "author_profile": "https://Stackoverflow.com/users/1048572", "pm_score": 4, "selected": true, "text": "const containsSensitive = sensitiveWords.some(el =>\n Object.keys(body).some(name =>\n// ^^^^\n na...
2022/10/21
[ "https://Stackoverflow.com/questions/74150519", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8908071/" ]
74,150,540
<p>I have a <code>pg_config</code> file in my <code>/bin/</code> directory, and my <code>/bin/</code> directory is in <code>$PATH</code>, but when I run <code>$PATH pg_config</code>, it says that the file is not found :</p> <p><a href="https://i.stack.imgur.com/tb1i6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tb1i6.png" alt="$PATH pg_config not found" /></a></p> <p>Does anyone know where can it come from ?</p> <p>Update : when i just run 'pg_config', i have this :</p> <pre><code>[root@PF9SODEVSTU048 clickandqualif]# pg_config BINDIR = /usr/bin DOCDIR = /usr/share/doc/pgsql HTMLDIR = /usr/share/doc/pgsql INCLUDEDIR = /usr/include PKGINCLUDEDIR = /usr/include/pgsql INCLUDEDIR-SERVER = /usr/include/pgsql/server LIBDIR = /usr/lib64 PKGLIBDIR = /usr/lib64/pgsql LOCALEDIR = /usr/share/locale MANDIR = /usr/share/man SHAREDIR = /usr/share/pgsql SYSCONFDIR = /etc </code></pre> <p>I should have specified the reason why I wanted to find 'pg_config' in the path. I have 'psycopg2-binary==2.9.4' in my requirements.txt and it fail when it tries to install psycopg2 with this error :</p> <pre><code>Error: pg_config executable not found. pg_config is required to build psycopg2 from source. Please add the directory containing pg_config to the $PATH or specify the full executable path with the option: python setup.py build_ext --pg-config /path/to/pg_config build ... or with the pg_config option in 'setup.cfg'. </code></pre> <p>And it's because of this that I want to know if my 'pg_config' file is really in my $PATH</p>
[ { "answer_id": 74150607, "author": "Bergi", "author_id": 1048572, "author_profile": "https://Stackoverflow.com/users/1048572", "pm_score": 4, "selected": true, "text": "const containsSensitive = sensitiveWords.some(el =>\n Object.keys(body).some(name =>\n// ^^^^\n na...
2022/10/21
[ "https://Stackoverflow.com/questions/74150540", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19750608/" ]
74,150,548
<p>Consider the following code:</p> <pre class="lang-py prettyprint-override"><code>code = input() eval(code) </code></pre> <p>If I run it and type<br /> <code>&gt; print(10)</code><br /> It will get executed and print &quot;10&quot;</p> <p>My question is when the code needs an indent, such as:</p> <pre><code>&gt; for i in range(10): &gt; print(i) </code></pre> <p>How can I receive this code with <code>input()</code> (notice that I have to keep the indent) so that I can use <code>eval()</code> to run it?</p>
[ { "answer_id": 74150897, "author": "NULL", "author_id": 8775282, "author_profile": "https://Stackoverflow.com/users/8775282", "pm_score": -1, "selected": false, "text": "eval()" }, { "answer_id": 74151313, "author": "Inspi", "author_id": 8915326, "author_profile": "ht...
2022/10/21
[ "https://Stackoverflow.com/questions/74150548", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14012142/" ]
74,150,549
<p>I have function which call's itself recursively until connect to server. Then the function returns 0. Why I have such behaviour of error:&quot; Control reaches end of non-void function&quot; pointing the line where function ends, what I did wrong. I have if/else statement with only return in else, but even if return in the if it is still the same. Isn't my logic correct ??</p> <p>code:</p> <pre><code>uint8_t TcpClient::ConnectToBoard(uint8_t attempts) { struct sockaddr_in server; /* server address */ server.sin_family = AF_INET; server.sin_port = htons(port); server.sin_addr.s_addr = inet_addr(ip); if(connect(client_socket, (struct sockaddr *)&amp;server, sizeof(server)) &lt; 0) { close(client_socket); GetStreamSocket(0,0); cout&lt;&lt;&quot;attempts&quot;&lt;&lt;(unsigned)attempts&lt;&lt;endl; if(attempts == 10) { attempts =0; printf(&quot;ERROR: %s\n&quot;, strerror(errno)); } attempts++; usleep(500000); // 5 seconds trying to get socket before error log ConnectToBoard(attempts); //recursive call } else { cout&lt;&lt;&quot;Here inside else of connect to board&quot;&lt;&lt;endl; return 0; } } </code></pre>
[ { "answer_id": 74150655, "author": "elanius", "author_id": 1719921, "author_profile": "https://Stackoverflow.com/users/1719921", "pm_score": 2, "selected": false, "text": "ConnectToBoard(attempts); //recursive call\n" }, { "answer_id": 74151121, "author": "463035818_is_not_a_...
2022/10/21
[ "https://Stackoverflow.com/questions/74150549", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17294780/" ]
74,150,557
<p>I have nested dictionaries, which are representations of XML that I have parsed using xmltodict.</p> <p>Now I want to give the possibility to extract certain sub-structures and remove keys which contain '@'.</p> <pre><code>{'rpc': {'@xmlns': 'urn:1.0', '@message-id': '4', 'edit-config': {'target': {'running': None}, 'config': {'test': {'@xmlns': 'urn:2.0', 'common': {'abc': 'forward', 'bbc': {'geo-model': 'texas', 'remote': [{'id': '288', 'transport': 'tcp', 'port': '8', 'ipv4-address': '0.0.0.0'}, {'distributed-system-id': '318', 'transport': 'tcp', 'port': '8', 'ipv4-address': '0.0.0.0'}, {'distributed-system-id': '348', 'transport': 'tcp', 'port': '8', 'ipv4-address': '0.0.0.0'}]}}}}}}} </code></pre> <p>I have defined a function where the user should be able to provide an input to choose which tag they want to extract the substructure from, while also removing any key with '@' in it.</p> <pre><code>def process_xml_dict(d,clean_d,start_after_tag = None,reached_tag=False): if start_after_tag == None: for k, v in d.items(): if isinstance(v, dict): process_xml_dict(v,clean_d) else: if '@' not in k: clean_d[k] = v else: for k,v in d.items(): if isinstance(v, dict): if k == start_after_tag: reached_tag = True process_xml_dict(v,clean_d,start_after_tag,reached_tag) else: if '@' not in k and reached_tag: clean_d[k] = v </code></pre> <p>But it does not work</p> <pre><code> clean_d = dict() process_xml_dict(d,clean_d) print(clean_d) </code></pre> <p>Should output</p> <pre><code>{'rpc': { 'edit-config': {'target': {'running': None}, 'config': {'test': { 'common': {'abc': 'forward', 'bbc': {'geo-model': 'texas', 'remote': [{'id': '288', 'transport': 'tcp', 'port': '8', 'ipv4-address': '0.0.0.0'}, {'distributed-system-id': '318', 'transport': 'tcp', 'port': '8', 'ipv4-address': '0.0.0.0'}, {'distributed-system-id': '348', 'transport': 'tcp', 'port': '8', 'ipv4-address': '0.0.0.0'}]}}}}}}} </code></pre> <p>But now it outputs</p> <pre><code>{ 'running': None, 'abc': 'forward', 'geo-model': 'texas', 'remote': [{'id': '288', 'transport': 'tcp', 'port': '8', 'ipv4-address': '0.0.0.0'}, {'distributed-system-id': '318', 'transport': 'tcp', 'port': '8', 'ipv4-address': '0.0.0.0'}, {'distributed-system-id': '348', 'transport': 'tcp', 'port': '8', 'ipv4-address': '0.0.0.0'}]} </code></pre> <p>And if I input</p> <pre><code>clean_d = dict() process_xml_dict(d,clean_d,start_after_tag='config') print(clean_d) </code></pre> <p>It should output</p> <pre><code>{'test': {'common': {'abc': 'forward', 'bbc': {'geo-model': 'texas', 'remote': [{'id': '288', 'transport': 'tcp', 'port': '8', 'ipv4-address': '0.0.0.0'}, {'distributed-id': '318', 'transport': 'tcp', 'port': '8', 'ipv4-address': '0.0.0.0'}, {'distributed-id': '348', 'transport': 'tcp', 'port': '8', 'ipv4-address': '0.0.0.0'}]}}}} </code></pre> <p>but now it outputs</p> <pre><code>{'abc': 'forward', 'geo-model': 'texas', 'remote': [{'id': '288', 'transport': 'tcp', 'port': '8', 'ipv4-address': '0.0.0.0'}, {'distributed-id': '318', 'transport': 'tcp', 'port': '8', 'ipv4-address': '0.0.0.0'}, {'distributed-id': '348', 'transport': 'tcp', 'port': '8', 'ipv4-address': '0.0.0.0'}]} </code></pre> <p>What am I doing wrong? And how would I modify my function to output expected output?</p> <p>Thankful for any input.</p>
[ { "answer_id": 74151466, "author": "Fabio Craig Wimmer Florey", "author_id": 14705210, "author_profile": "https://Stackoverflow.com/users/14705210", "pm_score": 0, "selected": false, "text": "\ndef clean(dictionary):\n return {key:value for key, value in dictionary.items() if '@' not ...
2022/10/21
[ "https://Stackoverflow.com/questions/74150557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7791963/" ]
74,150,573
<p>When i am trying to fetch multiple API using map() method, and launch the project it's given me empty which is i understand my console.log couldn't able to fetch at the time, and just use <strong>Ctrl+s</strong> press to save the file again, it's start to giving me value in react native vs code. in this case how can i avoid to launch the project and again <strong>Ctrl+s</strong> press. <strong>what should i use to avoid them and once i launch, i will able to fetch the data.</strong></p> <p>i already have tried setinterval but it's repeating me empty array, the setinterval isn't reach to fetch again.</p> <p>should i try any function for it or something?</p> <p>here is my code in vs code:</p> <pre><code>const [dataLoc, setDataLoc] = useState([]); const ids = [1,2,3,4,5]; useEffect(() =&gt; { ids?.map((id) =&gt; { fetch(`https://jsonplaceholder.typicode.com/posts/${id}`) .then((response) =&gt; response.json()) .then((dataLoc) =&gt; setDataLoc((prev) =&gt; [...prev, dataLoc.title])) .catch((error) =&gt; console.error(error)); }); }, []); console.log(dataLoc); </code></pre> <p>when i tried it to run in vs code i get this problem as i mention already.</p> <p>Anyone can help me? i'm stack at the place for a long time. i appreciate your trying. Thanks for your trying in advance!</p>
[ { "answer_id": 74151466, "author": "Fabio Craig Wimmer Florey", "author_id": 14705210, "author_profile": "https://Stackoverflow.com/users/14705210", "pm_score": 0, "selected": false, "text": "\ndef clean(dictionary):\n return {key:value for key, value in dictionary.items() if '@' not ...
2022/10/21
[ "https://Stackoverflow.com/questions/74150573", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19900677/" ]
74,150,589
<p>My task is to get the Kafka message before the method with the @KafkaListner annotation, check the correlationId and requestId headers in it. If they're present, flush them to MDC or generate them otherwise.</p> <p>And my question is how to get Kafka message with headers before method with the @KafkaListner?</p>
[ { "answer_id": 74151466, "author": "Fabio Craig Wimmer Florey", "author_id": 14705210, "author_profile": "https://Stackoverflow.com/users/14705210", "pm_score": 0, "selected": false, "text": "\ndef clean(dictionary):\n return {key:value for key, value in dictionary.items() if '@' not ...
2022/10/21
[ "https://Stackoverflow.com/questions/74150589", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7665294/" ]
74,150,613
<p>When I am using gets() to scan input it is working perfectly ,but when I'm using fgets() to scan the input then the answer is coming out as 1 more than the actual length. For example:--&gt; For input &quot;Hello&quot; fgets() is printing 6. BUT the answer should be 5. Why? How to resolve</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;string.h&gt; int string_length(char str[]); int main() { char str[100]; printf(&quot;**********************************************\n&quot;); printf(&quot;This is a program to reverse a string.\n&quot;); printf(&quot;**********************************************\n&quot;); printf(&quot;Enter a string: &quot;); fgets(str,100,stdin); // ----&gt; when using this fgets() answer of length of string is coming out to be one more than the actual answer gets(str); //This is giving the correct answer if used instead of fgets(). printf(&quot;%d&quot;,string_length(str)); return 0; } //function for calculating string length int string_length(char str[]) { int i; for(i=0; str[i]!='\0'; i++); return i; //WAY__2 //OR by while loop // int i,length=0; // while (str[length] != '\0') // { // length ++; // } // return length; //WAY__3 //OR by using strlen() function; // int length = strlen(str); // return length; } </code></pre>
[ { "answer_id": 74150657, "author": "Vlad from Moscow", "author_id": 2877241, "author_profile": "https://Stackoverflow.com/users/2877241", "pm_score": 1, "selected": false, "text": "fgets" }, { "answer_id": 74151299, "author": "0___________", "author_id": 6110094, "aut...
2022/10/21
[ "https://Stackoverflow.com/questions/74150613", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20089275/" ]
74,150,629
<p>I'm quite new to coding and I'm doing this task that requires the user to input an integer to the code. The function should keep on asking the user to input an integer and stop asking when the user inputs an integer bigger than 1. Now the code works, but it accepts all the integers.</p> <pre><code> while True: try: number = int(input(number_rnd)) except ValueError: print(not_a_number) else: return number </code></pre>
[ { "answer_id": 74150657, "author": "Vlad from Moscow", "author_id": 2877241, "author_profile": "https://Stackoverflow.com/users/2877241", "pm_score": 1, "selected": false, "text": "fgets" }, { "answer_id": 74151299, "author": "0___________", "author_id": 6110094, "aut...
2022/10/21
[ "https://Stackoverflow.com/questions/74150629", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20298998/" ]
74,150,660
<p>i tried it in all my html projects and all images in my project are gone.Im sure the pictures path is correct.ı checked it too many times.here is my code.I didnt add css because there is nothing important;</p> <pre><code>&lt;html lang=&quot;en&quot;&gt; &lt;head&gt; &lt;link rel=&quot;stylesheet&quot; href=&quot;mad.css&quot;&gt; &lt;meta charset=&quot;UTF-8&quot;&gt; &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot;&gt; &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt; &lt;link rel=&quot;icon&quot; type=&quot;image/png&quot; href=&quot;C:\Users\Samet\Desktop\Resim\mogus.png&quot;&gt; &lt;title&gt;wutr&lt;/title&gt; &lt;link rel=&quot;stylesheet&quot; href=&quot;https://fonts.google.com/specimen/K2D&quot;&gt; &lt;link rel=&quot;preconnect&quot; href=&quot;https://fonts.googleapis.com&quot;&gt; &lt;link rel=&quot;preconnect&quot; href=&quot;https://fonts.gstatic.com&quot; crossorigin&gt; &lt;link href=&quot;https://fonts.googleapis.com/css2?family=Cinzel&amp;display=swap&quot; rel=&quot;stylesheet&quot;&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;There is 7 rules in this world&lt;/h1&gt; &lt;ol&gt; &lt;div class=&quot;prf&quot;&gt;&lt;li&gt;&lt;p&gt;There is only one thing in this world&lt;/p&gt; &lt;/div&gt;&lt;/li&gt; &lt;/ol&gt; &lt;img src=&quot;C:\Users\Samet\Desktop\Resim\mogus.png&quot; alt=&quot;imgd&quot; height=&quot;1000px&quot;width=&quot;100px&quot;&gt; &lt;p class=&quot;pain&quot;&gt;Pain&lt;/p&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
[ { "answer_id": 74561031, "author": "FUZIION", "author_id": 13050564, "author_profile": "https://Stackoverflow.com/users/13050564", "pm_score": 2, "selected": false, "text": "<img src=\"file://C:\\Users\\Samet\\Desktop\\Resim\\mogus.png\" alt=\"imgd\" height=\"1000px\"width=\"100px\">\n" ...
2022/10/21
[ "https://Stackoverflow.com/questions/74150660", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20107823/" ]
74,150,686
<p><img src="https://i.stack.imgur.com/aUIFd.png" alt="Spreadsheet picture" /></p> <p>as in the above picture, I need to sum all the values within the table <code>C8:V22</code> which match</p> <ol> <li>the first three characters of <code>column B</code>(orange),</li> <li><code>row 5</code> for the number(blue),</li> <li><code>row 6</code> for the first character(green),</li> <li><code>row 7</code> for the first three characters(yellow)</li> </ol> <p>The desire result would be the sum of the number in red, which is 10001 + 10081 + 10161 + 10221 = <code>40464</code></p> <p>I tried many different ways to write the formula, one of that is:</p> <pre><code>=INDEX($B$5:$V$22, MATCH($D$26,LEFT($B$5:$B$90,3),0), MATCH(($F$26=$5:$5) * ($G$26=LEFT($6:$6, 1)) * (H26=LEFT($7:$7,3)), 0)) </code></pre> <p>and pressed <code>Ctrl+Shift+Enter</code> to make it as an array formula, but couldn't figure out where is the error.</p> <p>Anyone could help on this? Thank you!</p> <p>Edit: The following is a simplify table for easy reference:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th></th> <th>1</th> <th>2</th> <th>3</th> </tr> </thead> <tbody> <tr> <td></td> <td>a1</td> <td>a2</td> <td>b1</td> </tr> <tr> <td></td> <td>abc1</td> <td>abdf2</td> <td>abc2</td> </tr> <tr> <td>111a</td> <td>11</td> <td>12</td> <td>13</td> </tr> <tr> <td>222a</td> <td>14</td> <td>15</td> <td>16</td> </tr> <tr> <td>111b</td> <td>17</td> <td>18</td> <td>19</td> </tr> <tr> <td>555a</td> <td>20</td> <td>21</td> <td>22</td> </tr> <tr> <td>333d</td> <td>23</td> <td>24</td> <td>25</td> </tr> <tr> <td>111a</td> <td>26</td> <td>27</td> <td>28</td> </tr> </tbody> </table> </div> <p>in this case, the match values are <code>11</code> + <code>17</code> + <code>26</code> = <code>54</code></p> <p>I also tried using combinations of functions such as <code>SUMIFS</code>, <code>SUMPRODUCT</code>, <code>search</code>, e.t.c. but still not able figure out the solution.</p>
[ { "answer_id": 74151346, "author": "Ike", "author_id": 16578424, "author_profile": "https://Stackoverflow.com/users/16578424", "pm_score": 1, "selected": false, "text": "=LET(data,C8:V22,\n ruleColumnB,LEFT(B8:B22,LEN(D26))=TEXT(D26,\"0\"),\n ruleRow5,C5:V5=F26,\n ruleRow6, LEFT(C6...
2022/10/21
[ "https://Stackoverflow.com/questions/74150686", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20012176/" ]
74,150,711
<p>I have this enum :</p> <pre><code>public enum MyEnum { A = 0, B = 1, C = 2, D = 3, E = 4 } </code></pre> <p>I have a <code>List&lt;string&gt; {&quot;A&quot;, &quot;C&quot;, &quot;E&quot;}</code></p> <p>I'd like make a query on <code>MyEnum</code> to get back the int values as a <code>List&lt;int&gt;</code> Here the result should be 0,2,4</p> <p>Same question but when I have a <code>List&lt;int&gt; {0, 2, 4}</code> I'd like get back a <code>List&lt;string&gt;</code> with <code>A,C,E</code></p> <p>Do you have an idea how do this in .NET 4.7 ?</p> <p>Thanks,</p>
[ { "answer_id": 74151346, "author": "Ike", "author_id": 16578424, "author_profile": "https://Stackoverflow.com/users/16578424", "pm_score": 1, "selected": false, "text": "=LET(data,C8:V22,\n ruleColumnB,LEFT(B8:B22,LEN(D26))=TEXT(D26,\"0\"),\n ruleRow5,C5:V5=F26,\n ruleRow6, LEFT(C6...
2022/10/21
[ "https://Stackoverflow.com/questions/74150711", "https://Stackoverflow.com", "https://Stackoverflow.com/users/118584/" ]
74,150,719
<p>lets say we have to arrays</p> <p>first:</p> <pre><code>arr1= [1000 5.0 1270 5.0 1315 5.0 ] arr2= [578 5.0 1000 5.0 1315 5.0 ] </code></pre> <p>So as you can see we have indexes and their values what I want to do is concat them in a way if they have the same index then add them if not just put them with their values.</p> <p><strong>Final output</strong>:</p> <pre><code>FINAL_ARR= [578 5.0 1000 10.0 1270 5.0 1315 10.0 ] </code></pre> <p>I've tried to do the <code>zip()</code> method but I need to <strong>keep the indexes</strong></p> <p>note: they dont need to be sorted.</p>
[ { "answer_id": 74150827, "author": "Julien Briand", "author_id": 4819984, "author_profile": "https://Stackoverflow.com/users/4819984", "pm_score": 2, "selected": false, "text": "map1={\n 1000: 5.0,\n 1270: 5.0,\n 1315: 5.0\n}\n\nmap2={\n578: 5.0,\n1000: 5.0,\n1315: 5.0\n}\n\nr = map1\...
2022/10/21
[ "https://Stackoverflow.com/questions/74150719", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14092472/" ]
74,150,738
<p>I have a problem transferring data from an excel file into a 3D array. The different variables of data is latitude, longitude and depth of an area in western norway. The plan is to later have a reinforcement learning algorithm use this map of a 3D array to learn navigate the area at sea, i.e. where the depth is positive. We're essentially in the first step of making an automated route-planner.</p> <p>This is the code I've used so far, which seems to create 3 different arrays, with the number of elements in the excel file used as rows for each individual one.</p> <pre><code> import pandas as pd import numpy as np file_loc = &quot;excel1.xlsx&quot; Lat = pd.read_excel(file_loc,sheet_name='Sheet2', index_col=None, na_values=['NA'], usecols=&quot;A&quot;) long = pd.read_excel(file_loc,sheet_name='Sheet2', index_col=None, na_values=['NA'], usecols=&quot;B&quot;) Depth = pd.read_excel(file_loc,sheet_name='Sheet2', index_col=None, na_values=['NA'], usecols=&quot;C&quot;) treD_array = np.array([[[Lat], [long]], [Depth]]) print(treD_array) </code></pre> <p>And this is what I get as an output;</p> <p>VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray. treD_array = np.array([[[Lat], [long]], [Depth]]) [list([[ 60.262092 0 60.262092 1 60.262092 2 60.262092 3 60.262092 4 60.262092 ... ... 23973 60.444314 23974 60.444314 23975 60.444314 23976 60.444314 23977 60.444314</p> <p>[23978 rows x 1 columns]], [ 5.12317 0 5.123893 1 5.124616 2 5.125339 3 5.126063 4 5.126786 ... ... 23973 5.277191 23974 5.277915 23975 5.278638 23976 5.279361 23977 5.280084</p> <p>[23978 rows x 1 columns]]]) list([ 27.47 0 42.26 1 60.70 2 81.17 3 100.91 4 118.34 ... ... 23973 187.83 23974 155.94 23975 104.80 23976 74.50 23977 54.84</p> <pre><code> [23978 rows x 1 columns]])] </code></pre> <p>Where I do not understand the warning at all.</p> <p>Any help would be much appreciated :)</p>
[ { "answer_id": 74150827, "author": "Julien Briand", "author_id": 4819984, "author_profile": "https://Stackoverflow.com/users/4819984", "pm_score": 2, "selected": false, "text": "map1={\n 1000: 5.0,\n 1270: 5.0,\n 1315: 5.0\n}\n\nmap2={\n578: 5.0,\n1000: 5.0,\n1315: 5.0\n}\n\nr = map1\...
2022/10/21
[ "https://Stackoverflow.com/questions/74150738", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20299024/" ]
74,150,739
<p>I have the following code.</p> <pre><code>import { useQuery } from &quot;@vue/apollo-composable&quot;; const ACCOUNTS_QUERY = gql` { accounts { id name number } } `; interface Accounts { accounts: [ { id: number; name: string; number: string; } ]; } export default defineComponent({ name: &quot;AccountsView&quot;, setup() { const { result, loading, error } = useQuery&lt;Accounts&gt;(ACCOUNTS_QUERY); return { accounts: result.accounts, } </code></pre> <p>Here I get TS2339: Property 'accounts' does not exist on type 'Ref&lt;Accounts | undefined&gt;' in the return.</p> <p>Now if I swap the return statement for:</p> <pre><code> return { result, } </code></pre> <p>I can access <code>result.accounts</code> in the template and iterate over it with <code>v-for</code>. Why can't I return <code>result.accounts</code>?</p>
[ { "answer_id": 74150827, "author": "Julien Briand", "author_id": 4819984, "author_profile": "https://Stackoverflow.com/users/4819984", "pm_score": 2, "selected": false, "text": "map1={\n 1000: 5.0,\n 1270: 5.0,\n 1315: 5.0\n}\n\nmap2={\n578: 5.0,\n1000: 5.0,\n1315: 5.0\n}\n\nr = map1\...
2022/10/21
[ "https://Stackoverflow.com/questions/74150739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/424586/" ]
74,150,747
<p>I have a data frame <code>df</code> which looks something like what you see below.</p> <pre><code>df &lt;- data.frame(id = c(&quot;abc&quot;, &quot;def&quot;, &quot;ghi&quot;, &quot;jkl&quot;, &quot;mno&quot;), flag_V1 = c(2, 1, 1, 0, 1), V1 = c(600, 1000, 500, NA, 700), flag_V2 = c(1, 1, 0, 2, 0), V2 = c(400, 600, 100, 700, NA), flag_V3 = c(1, 2, 1, 0, 1), V3 = c(600, 300, 600, NA, 700)) &gt; df id flag_V1 V1 flag_V2 V2 flag_V3 V3 1 abc 2 600 1 400 1 600 2 def 1 1000 1 600 2 300 3 ghi 1 500 0 100 1 600 4 jkl 0 NA 2 700 0 NA 5 mno 1 700 0 NA 1 700 </code></pre> <p>Essentially, each column <code>V1</code>, <code>V2</code>, and <code>V3</code> comes with a flag variable <code>flag_V1</code>, <code>flag_V2</code>, and <code>flag_V3</code> which contain information about how the values in <code>V1</code>, <code>V2</code>, and <code>V3</code> where collected.</p> <p>As you can see, whenever the flag variable reports <code>0</code>, the value in the associated column is <code>NA</code>. I want to replace these missing values with zeroes if (and only if) the flag variable reports <code>0</code>. I want something like this</p> <pre><code>df_modified &lt;- df %&gt;% mutate(V1 = ifelse(flag_V1 == 0, 0, V1)) </code></pre> <p>for <strong>every</strong> column that comes with a flag variable. The actual data that I'm working with has hundreds of columns, and not all of them come with a flag variable.</p> <p>Is there a simple way to perform the above operation on many columns without having to do it one by one, preferably using dplyr-like syntax and avoiding traditional loops? I want to highlight again that I don't want to change all missing values to zeroes; it is very important that this is only done when the flag variable reports <code>0</code>. Thank you!</p>
[ { "answer_id": 74150827, "author": "Julien Briand", "author_id": 4819984, "author_profile": "https://Stackoverflow.com/users/4819984", "pm_score": 2, "selected": false, "text": "map1={\n 1000: 5.0,\n 1270: 5.0,\n 1315: 5.0\n}\n\nmap2={\n578: 5.0,\n1000: 5.0,\n1315: 5.0\n}\n\nr = map1\...
2022/10/21
[ "https://Stackoverflow.com/questions/74150747", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20128304/" ]
74,150,778
<p>I have a weird probleme here, so i am working with redux and this is my component code for a selected product from reducer state.</p> <pre><code>import './productInfo.css'; import { useParams } from 'react-router-dom'; import { getProduct } from '../../actions/productActions'; import { connect } from 'react-redux'; import { useEffect, useState } from 'react'; const ProductInfo = (props) =&gt; { const [usedProduct, setUsedProduct] = useState(props) const {id} = useParams(); useEffect(() =&gt; { props.getProduct(id); }, [usedProduct]) let newUsedProduct = usedProduct; console.log(usedProduct.products[0].name) return ( &lt;div&gt; &lt;/div&gt; ); } const mapStateToProps = (state) =&gt; { return{ products : state.myProduct.product } } export default connect( mapStateToProps, { getProduct })(ProductInfo); </code></pre> <p>so when i launch the component for the first time it works and i got the necessary data from the reducer state but when i refresh the page it gives me this error : Uncaught TypeError: Cannot read properties of undefined (reading '0') in this line of code :</p> <pre><code>console.log(usedProduct.products[0].name) </code></pre> <p>i'm totally lost !</p>
[ { "answer_id": 74150827, "author": "Julien Briand", "author_id": 4819984, "author_profile": "https://Stackoverflow.com/users/4819984", "pm_score": 2, "selected": false, "text": "map1={\n 1000: 5.0,\n 1270: 5.0,\n 1315: 5.0\n}\n\nmap2={\n578: 5.0,\n1000: 5.0,\n1315: 5.0\n}\n\nr = map1\...
2022/10/21
[ "https://Stackoverflow.com/questions/74150778", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17862094/" ]
74,150,821
<p>My index.html page</p> <pre><code>&lt;html lang=&quot;en&quot;&gt; &lt;head&gt; &lt;meta charset=&quot;UTF-8&quot;&gt; &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot;&gt; &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt; &lt;title&gt;Welcome Home&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;a href=&quot;./login.html&quot;&gt;Please Login Here!&lt;/a&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>My login.html page</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang=&quot;en&quot;&gt; &lt;head&gt; &lt;meta charset=&quot;UTF-8&quot;&gt; &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot;&gt; &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt; &lt;title&gt;Example of Login Form&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form action=&quot;login.html&quot; method=&quot;post&quot;&gt; Username:&lt;br&gt; &lt;input type=&quot;text&quot; name=&quot;username&quot; placeholder=&quot;Username&quot; required&gt;&lt;br&gt;&lt;br&gt; Password:&lt;br&gt; &lt;input type=&quot;password&quot; name=&quot;password&quot; placeholder=&quot;Password&quot; required&gt;&lt;br&gt;&lt;br&gt; &lt;input type=&quot;submit&quot; value=&quot;login&quot;&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>My server page</p> <pre><code>const express = require('express'); const app = express(); const bodyParser = require('body-parser'); app.use(bodyParser.urlencoded({extended:false})) app.get('/',(req,res)=&gt;{ res.sendFile(__dirname+'/static/index.html'); }) app.get('/login',(req,res)=&gt;{ res.sendFile(__dirname+&quot;/static/&quot;+&quot;login.html&quot;); }) app.post('/login',(req,res)=&gt;{ let username = req.body.username; let password = req.body.password; res.send(`Username : ${username} Password: ${password}`) }) const port = 3000; app.listen(port,()=&gt;console.log(`This app is listening on port : ${port}`)); </code></pre> <p>I am new to node.js.When I run using node server.js, I get Cannot GET /login.html.I can get into index.html. Why I am getting this. This is my directory</p> <pre> . ├── package.json . ├── server.js . └── static . . ├── index.html . . └── login.html </pre>
[ { "answer_id": 74150827, "author": "Julien Briand", "author_id": 4819984, "author_profile": "https://Stackoverflow.com/users/4819984", "pm_score": 2, "selected": false, "text": "map1={\n 1000: 5.0,\n 1270: 5.0,\n 1315: 5.0\n}\n\nmap2={\n578: 5.0,\n1000: 5.0,\n1315: 5.0\n}\n\nr = map1\...
2022/10/21
[ "https://Stackoverflow.com/questions/74150821", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11847670/" ]
74,150,831
<p>I wish to show on my scatter plot :</p> <ol> <li>how far away are values from the plot origin [0,0], and</li> <li>are they closer to the center, X, Y axis, both XY, or far away? In terms of spliting the plot into sectors by 2 lines (at 30 degrees) and cirle-like sections.</li> </ol> <p>To estimate how far are the points from the origin [0,0], I can easily calculate the Euclidian distace.</p> <p>But I am not sure how to classify my points based to their distance to the origin [0,0], and to the X, or Y axis or both? I think my issue here is that I can't simply set the classification rule s as:</p> <p><strong>Center</strong> = <code>if X &lt; 0.5 &amp; Y &lt; 0.5</code>, as this represents a square. Rather, my values should follow the euclidian distance here? e.g <code>Center = X &lt; 0.5 &amp; Y &lt; 0.5 &amp; Euclid_dist &lt; 0.5</code></p> <p>But how to get the classification for the 'X', 'Y', 'XY' and their 'far' alternatives, considering at the same time both lines and circles as sectors? It is likely a simple trigonometric question, but I can't figure it out.</p> <p>Here is my ideal case:</p> <p><a href="https://i.stack.imgur.com/BeKz3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BeKz3.png" alt="enter image description here" /></a></p> <p>And my dummy example:</p> <pre><code>dd &lt;- data.frame(x = runif(10, min=0, max=2), y = runif(10, min=0, max=2)) # Get euclidean distance euclidean &lt;- function(a, b) sqrt(sum((a - b)^2)) dd &lt;- dd %&gt;% mutate(euclid_dist = euclidean(x, y)) dd %&gt;% ggplot(aes(x = x, y = y)) + geom_point() + theme_bw() + theme_update(aspect.ratio=1) </code></pre> <p><a href="https://i.stack.imgur.com/bur4e.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bur4e.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74150827, "author": "Julien Briand", "author_id": 4819984, "author_profile": "https://Stackoverflow.com/users/4819984", "pm_score": 2, "selected": false, "text": "map1={\n 1000: 5.0,\n 1270: 5.0,\n 1315: 5.0\n}\n\nmap2={\n578: 5.0,\n1000: 5.0,\n1315: 5.0\n}\n\nr = map1\...
2022/10/21
[ "https://Stackoverflow.com/questions/74150831", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2742140/" ]
74,150,867
<p>Program to find a prime number after a given number: I used the theory that prime numbers are divisible by only 2 numbers 1 and itself.</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;conio.h&gt; int main(int argc, char const *argv[]) { int num,a=0,i,j; printf(&quot;Enter a number: &quot;); scanf(&quot;%d&quot;,&amp;num); for(i=num+1;i&gt;0;i++){ for(j=1;j&lt;=i;j++){ if(i%j==0){ a=a+1; } } if(a==2){ printf(&quot;%d&quot;,i); break; } } return 0; } </code></pre> <p>This code is working only for a single increment like if user gives the input as 4 it is returning the output as 5. But it wont return output if input is given as 7 (it should return 11)</p> <p>Then I modified the code as below :</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;conio.h&gt; void main(int argc, char const *argv[]) { int num,a=0,i,j; printf(&quot;Enter a number: &quot;); scanf(&quot;%d&quot;,&amp;num); for(i=num+1;i&gt;0;i++){ a=0; for(j=1;j&lt;=i;j++){ if(i%j==0){ a=a+1; } } if(a==2){ printf(&quot;%d&quot;,i); break; } } } </code></pre> <p>This one runs well. I am confused why the program gives the output if i declared the variable after the for loop but fails to give it if declared before?</p>
[ { "answer_id": 74150979, "author": "Dniel BV", "author_id": 9472541, "author_profile": "https://Stackoverflow.com/users/9472541", "pm_score": 3, "selected": true, "text": "a" }, { "answer_id": 74151196, "author": "abdo Salm", "author_id": 16305340, "author_profile": "...
2022/10/21
[ "https://Stackoverflow.com/questions/74150867", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20284879/" ]
74,150,881
<p>I have a string like:</p> <pre><code> -------beginning certificate 2323jjjdcnnjjjsd sdsdsdsdsdsdsd </code></pre> <p>and I would like to transform it in (white spaces should be removed only at beginning of each lines):</p> <pre><code>-------beginning certificate 2323jjjdcnnjjjsd sdsdsdsdsdsdsd </code></pre> <p>I have tried with :</p> <pre><code>string.replaceAll(&quot;^[\n\r\s]*&quot;,&quot;&quot;); </code></pre> <p>but seems nothing happens.</p>
[ { "answer_id": 74150946, "author": "anubhava", "author_id": 548225, "author_profile": "https://Stackoverflow.com/users/548225", "pm_score": 2, "selected": true, "text": "string = string.replaceAll(\"(?m)^\\\\s+|\\\\h+$\", \"\");\n" }, { "answer_id": 74151221, "author": "bobbl...
2022/10/21
[ "https://Stackoverflow.com/questions/74150881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9551700/" ]
74,150,899
<p>I have the following table. When I am missing a value from the num dimension, I would like to replace it with the value of the previous row. The following is an example of what I have tried. I'm using the lag window function, and is not working.</p> <pre><code>CREATE TABLE test(dt text, num INT); INSERT INTO test VALUES(&quot;2011-11-11&quot;, 3); INSERT INTO test VALUES(&quot;2011-11-12&quot;, NULL); INSERT INTO test VALUES(&quot;2011-11-13&quot;, 5); INSERT INTO test VALUES(&quot;2011-11-14&quot;, NULL); INSERT INTO test VALUES(&quot;2011-11-15&quot;, NULL); INSERT INTO test VALUES(&quot;2011-11-16&quot;, 2); select dt, case when num is not null then num else lag(num,1,0) over (order by dt) end from test </code></pre> <p>The error that I'm getting: <code>OperationalError: near &quot;(&quot;: syntax error</code> which I am not even sure what it means. Any help will be appreciated.</p>
[ { "answer_id": 74150946, "author": "anubhava", "author_id": 548225, "author_profile": "https://Stackoverflow.com/users/548225", "pm_score": 2, "selected": true, "text": "string = string.replaceAll(\"(?m)^\\\\s+|\\\\h+$\", \"\");\n" }, { "answer_id": 74151221, "author": "bobbl...
2022/10/21
[ "https://Stackoverflow.com/questions/74150899", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14857189/" ]
74,150,931
<p>In class we are currently making lottery tickets as a project, I'm currently stuck on a question with equals: The same rows are not allowed to appear multiple times on the same ticket.</p> <p>I have tried a couple of things, but nothing has been working yet.</p> <pre><code>public class TalRækker //rows { static Random rnd = new Random(); public static int[,] Line() { int[,] line = new int[10, 7]; //int x = rnd.Next(1, 36); for (int i = 0; i &lt; line.GetLength(0); i++) { for (int j = 0; j &lt; line.GetLength(1); j++) { line[i, j] = rnd.Next(1, 36); } } return line; } public static void Print2DArray&lt;T&gt;(T[,] line) { var lineNumber = 1; for (int i = 0; i &lt; line.GetLength(0); i++) { Console.Write(&quot; {0:D2}.\t&quot;, lineNumber); for(int j = 0; j &lt; line.GetLength(1); j++) { Console.Write(&quot;{0:D2} &quot;, line[i, j]); } Console.WriteLine(); lineNumber++; } } </code></pre> <p>I've updated my code to the following but still getting an issue:</p> <pre><code>namespace lottery { class Program { static void Main(string[] args) { Console.WriteLine(&quot;\t Lotto &quot; + DateTime.Now.ToString(&quot;dd/MM/yyyy&quot;)); Console.WriteLine(&quot;\t&quot; + &quot;\t1-uge&quot;); Console.WriteLine(&quot;\t LYN-LOTTO\t&quot;); Console.WriteLine(&quot; &quot;); TalRækker.Print2DArray(TalRækker.?()); //here is the problem Console.WriteLine(&quot;&quot;); } } } </code></pre>
[ { "answer_id": 74151716, "author": "sr28", "author_id": 2381942, "author_profile": "https://Stackoverflow.com/users/2381942", "pm_score": 1, "selected": false, "text": " static Random rnd = new Random();\n public static int[][] GenerateTicket(int numberOfRows, int rowLength)\n {...
2022/10/21
[ "https://Stackoverflow.com/questions/74150931", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20299174/" ]
74,150,954
<p>I have a generated token and I want to display it inside a div container</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 { padding: 10px; background: #f0f0f0; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="container"&gt;eyJhbGciOiJSUzUxMiJ9.eyJhcGkiOnsiZGF0YVByb3ZpZGVyIjp7InR5cGUiOiJodHRwIiwib3B0aW9ucyI6eyJ1cmwiOiJodHRwczovL3d3dy5leGFtcGxlLmNvbSJ9fSwiZGF0YVNvdXJjZXMiOnsibGVhZGluZyI6eyJpZCI6InNvdXJjZUVudGl0eSIsImVudGl0eVR5cGVJZCI6Im1haW5FbnRpdHkiLCJmaWVsZElkcyI6WyJhIiwiYiJdfSwiZm9sbG93aW5nIjpbeyJpZCI6ImZvbGxvd2luZ0VudGl0eSIsImVudGl0eVR5cGVJZCI6InJlbGF0ZWRFbnRpdHkiLCJmaWVsZElkcyI6WyJhIiwiYyIsImQiXSwiZGVwZW5kc09uIjp7ImRhdGFTb3VyY2VJZCI6InNvdXJjZUVudGl0eSIsInJlbGF0aW9uIjp7InR5cGVJZCI6ImlzUmVsYXRlZFRvIiwic291cmNlSXMiOiJvdGhlciJ9fX1dfX0sImZpZWxkcyI6W3siaWQiOiJhIiwidGl0bGUiOnsiZW4iOiJBIn0sImlzUmVxdWlyZWQiOnRydWUsImRhdGFUeXBlIjp7InR5cGUiOiJib29sZWFuIn0sImRlZmF1bHRWYWx1ZUZ1bmN0aW9uQXNTdHJpbmciOiIoKSA9PiB1bmRlZmluZWQiLCJydWxlcyI6W3sicnVsZUZ1bmN0aW9uQXNTdHJpbmciOiIoKSA9PiB0cnVlIiwiZXJyb3JNZXNzYWdlIjp7ImVuIjoiZmFsc2UifX1dfV0sImxvb2t1cHMiOnsiaW5pdGlhbExvb2t1cHMiOlt7ImlkIjoibG9va3VwLTEiLCJzb3VyY2UiOiJodHRwOi8vbG9jYWxob3N0OjMwMDAvbG9va3VwLTEifV19LCJ1aSI6eyJmb3JtcyI6W3siaWQiOiJmb3JtLTEiLCJmaWVsZHMiOlt7ImlkIjoiYSIsImlzUmVhZG9ubHkiOmZhbHNlLCJpc0hpZGRlbiI6ZmFsc2V9XX0seyJpZCI6ImZvcm0tMiIsImZpZWxkcyI6W3siaWQiOiJhIiwiaXNSZWFkb25seSI6dHJ1ZSwiaXNIaWRkZW4iOnRydWUsImRpc3BsYXlQbGFpblZhbHVlRnVuY3Rpb24iOnsiZW4iOiJ2YWx1ZSA9PiBKU09OLnN0cmluZ2lmeSh2YWx1ZSkifX1dfV0sImNvbHVtbnMiOlt7InR5cGUiOiJlbnRpdHkiLCJkYXRhU291cmNlSWQiOiJzb3VyY2VFbnRpdHkiLCJjcmVhdGVGb3JtSWQiOiJmb3JtLTEiLCJjb2xsYXBzZWRGb3JtSWQiOiJmb3JtLTEiLCJleHBhbmRlZEZvcm1JZCI6ImZvcm0tMSIsInRpdGxlIjp7ImVuIjoiU291cmNlcyJ9LCJzdHJpbmdpZnlFbnRpdHlGdW5jdGlvbkFzU3RyaW5nIjp7ImVuIjoiZW50aXR5ID0-IEpTT04uc3RyaW5naWZ5KGVudGl0eSkifSwiaXNMZXNzVGhhbiI6eyJmdW5jdGlvbkFzU3RyaW5nIjoiKCkgPT4gdHJ1ZSIsImluZGV4IjowfX0seyJ0eXBlIjoiZW50aXR5IiwiZGF0YVNvdXJjZUlkIjoiZm9sbG93aW5nRW50aXR5IiwiY3JlYXRlRm9ybUlkIjoiZm9ybS0yIiwiY29sbGFwc2VkRm9ybUlkIjoiZm9ybS0yIiwiZXhwYW5kZWRGb3JtSWQiOiJmb3JtLTIiLCJ0aXRsZSI6eyJlbiI6IkZvbGxvd2VycyJ9LCJzdHJpbmdpZnlFbnRpdHlGdW5jdGlvbkFzU3RyaW5nIjp7ImVuIjoiZW50aXR5ID0-IEpTT04uc3RyaW5naWZ5KGVudGl0eSkifX1dfX0.2pkkq_rD95XsnZLzDh3vrhUHwUdEyWK1vrON0tIAISgDqQ0ZajFO34aQCwsboS-121G8kNckaZ2L10oMyREX_4ORdklMkbSPv49n5MUmc_o_eN3jYZKZ9ikKefKKHQzzkZF6UVurNImnHcskniLJisfIjsmJyVypNFG05QlXlrS19AdBSAom5w4pAsDhYmoBubyS0_SYmrbRnWLfvXuz_kgamB_rmCKqVHIDZEDBI8LCBiGWNt6TILvrVht0nS3AWrE55mZRVA9C0sP-DvWzUffXP_b51pqUqve0z50JWZwaP2Mp9WfqBu-r2_4xOsNJkLo437btTrl2hLlr2VMJCQ&lt;/div&gt;</code></pre> </div> </div> </p> <p>As you can see it exceeds the container width and does not add a linebreak automatically. How can I display such tokens?</p>
[ { "answer_id": 74151716, "author": "sr28", "author_id": 2381942, "author_profile": "https://Stackoverflow.com/users/2381942", "pm_score": 1, "selected": false, "text": " static Random rnd = new Random();\n public static int[][] GenerateTicket(int numberOfRows, int rowLength)\n {...
2022/10/21
[ "https://Stackoverflow.com/questions/74150954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19698303/" ]
74,150,968
<p>I want to call some existing code in my XQuery script in MarkLogic that takes a JSON as function parameter.</p> <p>Depending on the input to my own code, I need to feed the other function a variant of the JSON so that it does contain an extra property or doesn't.</p> <p>So far I only figured out to do this with code duplication:</p> <pre class="lang-xquery prettyprint-override"><code>let $json := if (fn:exists($extraAttribute)) then object-node { &quot;query&quot;: array-node { $id }, &quot;extra&quot;: $extraAttribute } else object-node { &quot;query&quot;: array-node { $id } } </code></pre> <p>Is there a more elegant way to solve this? With various values for <code>&quot;extra&quot;</code> the behaviour of the called code is different then without the property at all. So far I tried an empty sequence <code>()</code>, an empty string <code>&quot;&quot;</code> and <code>null-node {}</code> as alternative values.</p> <p>UPDATE: The called code evaluates the JSON input like this:</p> <pre class="lang-xquery prettyprint-override"><code>let $extraStuff := $json/extra/fn:string() </code></pre> <p>I don't want to change the called code because I'm not the only caller and I don't know if others rely on that behaviour.</p>
[ { "answer_id": 74151810, "author": "cyberbrain", "author_id": 2846138, "author_profile": "https://Stackoverflow.com/users/2846138", "pm_score": 0, "selected": false, "text": "import module namespace json = \"http://marklogic.com/xdmp/json\"\n at \"/MarkLogic/json/json.xqy\";\n\n\nlet ...
2022/10/21
[ "https://Stackoverflow.com/questions/74150968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2846138/" ]
74,150,970
<p>I’m trying to use the <a href="https://paperless-ngx.readthedocs.io/en/latest/api.html" rel="nofollow noreferrer">REST APi for Paperless-ngx</a> to upload documents to a http server, their instructions are as follows..</p> <blockquote> <p>POSTing documents</p> <p>The API provides a special endpoint for file uploads:</p> <p>/api/documents/post_document/</p> <p>POST a multipart form to this endpoint, where the form field document contains the document that you want to upload to paperless. The filename is sanitized and then used to store the document in a temporary directory, and the consumer will be instructed to consume the document from there.</p> <p>The endpoint supports the following optional form fields:</p> <p>title: Specify a title that the consumer should use for the document.</p> <p>created: Specify a DateTime document was created (e.g. “2016-04-19” or “2016-04-19 06:15:00+02:00”).</p> <p>correspondent: Specify the ID of a correspondent that the consumer should use for the document.</p> <p>document_type: Similar to correspondent.</p> <p>tags: Similar to correspondent. Specify this multiple times to have multiple tags added to the document.</p> <p>The endpoint will immediately return “OK” if the document consumption process was started successfully. No additional status information about the consumption process itself is available, since that happens in a different process</p> </blockquote> <p>While I’ve been able to achieve what I needed with curl (see below), I’d like to achieve the same result with Lua.</p> <pre><code>curl -H &quot;Authorization: Basic Y2hyaXM62tgbsgjunotmeY2hyaXNob3N0aW5n&quot; -F &quot;title=Companies House File 10&quot; -F &quot;correspondent=12&quot; -F &quot;document=@/mnt/nas/10.pdf&quot; http://192.168.102.134:8777/api/documents/post_document/ </code></pre> <p>On the Lua side, I’ve tried various ways to get this to work, but all have been unsuccessful, at best it just times out and returns nil.</p> <p><strong>Update:</strong> I’ve progressed from a nil timeout, to a <code>400 table: 0x1593c00 HTTP/1.1 400 Bad Request {&quot;document&quot;:[&quot;No file was submitted.&quot;]}</code> error message</p> <p>Please could someone help ..</p> <pre><code>local http = require(&quot;socket.http&quot;) local ltn12 = require(&quot;ltn12&quot;) local mime = require(&quot;mime&quot;) local lfs = require(&quot;lfs&quot;) local username = &quot;username&quot; local password = &quot;password&quot; local httpendpoint = 'http://192.168.102.134:8777/api/documents/post_document/' local filepath = &quot;/mnt/nas/10.pdf&quot; local file = io.open(filepath, &quot;rb&quot;) local contents = file:read( &quot;*a&quot; ) -- https://stackoverflow.com/questions/3508338/what-is-the-boundary-in-multipart-form-data local boundary = &quot;somerndstring&quot; local send = &quot;--&quot;..boundary.. &quot;\r\nContent-Disposition: form-data; &quot;.. &quot;title='testdoc'; document=&quot;..filepath.. --&quot;\r\nContent-type: image/png&quot;.. &quot;\r\n\r\n&quot;..contents.. &quot;\r\n--&quot;..boundary..&quot;--\r\n&quot;; -- Execute request (returns response body, response code, response header) local resp = {} local body, code, headers, status = http.request { url = httpendpoint, method = 'POST', headers = { -- ['Content-Length'] = lfs.attributes(filepath, 'size') + string.len(send), -- [&quot;Content-Length&quot;] = fileContent:len(), -- [&quot;Content-Length&quot;] = string.len(fileContent), [&quot;Content-Length&quot;] = lfs.attributes(filepath, 'size'), ['Content-Type'] = &quot;multipart/form-data; boundary=&quot;..boundary, [&quot;Authorization&quot;] = &quot;Basic &quot; .. (mime.b64(username ..&quot;:&quot; .. password)), --body = send }, source = ltn12.source.file( io.open(filepath,&quot;rb&quot;) ), sink = ltn12.sink.table(resp) } print(body, code, headers, status) print(table.concat(resp)) if headers then for k,v in pairs(headers) do print(k,v) end end </code></pre>
[ { "answer_id": 74151810, "author": "cyberbrain", "author_id": 2846138, "author_profile": "https://Stackoverflow.com/users/2846138", "pm_score": 0, "selected": false, "text": "import module namespace json = \"http://marklogic.com/xdmp/json\"\n at \"/MarkLogic/json/json.xqy\";\n\n\nlet ...
2022/10/21
[ "https://Stackoverflow.com/questions/74150970", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6676439/" ]
74,150,971
<p>I know how to compare lists but working with unflatten data in Pandas is beyond my skills..anyway.. I have:</p> <pre><code>list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] </code></pre> <p>and</p> <pre><code>df = pd.DataFrame({ &quot;col1&quot;:[&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;], &quot;col2&quot;:[[1, 2, 3, 4, 5], [20, 30, 100], [1, 3, 20], [20,30]] }) </code></pre> <p>I want to compare the <code>list</code> with the <code>df</code> and <code>print</code> rows that contain 100% matches, partial matches and dismatches. Desired outcome is then this:</p> <pre><code>&quot;100% matches are in rows: a&quot; &quot;Partial matches are in rows: c&quot; &quot;Dismatches are in rows: b, d&quot; </code></pre> <p>Python 3 solution would be much appreciated.Thanks!</p>
[ { "answer_id": 74151810, "author": "cyberbrain", "author_id": 2846138, "author_profile": "https://Stackoverflow.com/users/2846138", "pm_score": 0, "selected": false, "text": "import module namespace json = \"http://marklogic.com/xdmp/json\"\n at \"/MarkLogic/json/json.xqy\";\n\n\nlet ...
2022/10/21
[ "https://Stackoverflow.com/questions/74150971", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20051041/" ]
74,150,978
<p>I have an entity sensor. How i can to do a search by all fields (include type and unit), because now i get a result only by (id, name, model, .., location, description) I use Spring Data Jpa</p> <pre><code> @Query(&quot;SELECT s &quot; + &quot;FROM Sensor s &quot; + &quot;WHERE CONCAT(s.name, s.model, s.rangeFrom, s.rangeTo, s.location, s.description, s.type, s.unit) &quot; + &quot;LIKE %:text%&quot;) List&lt;Sensor&gt; findAllSensorsByText(@Param(&quot;text&quot;) String text); </code></pre> <p><strong>Sensor class</strong></p> <pre><code>@Entity @Table(name = &quot;sensors&quot;) @Data @NoArgsConstructor @AllArgsConstructor public class Sensor { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = &quot;sensor_id&quot;) private Integer id; private String name; private String model; @Column(name = &quot;range_from&quot;) private Integer rangeFrom; @Column(name = &quot;range_to&quot;) private Integer rangeTo; private String location; private String description; @ManyToOne @JoinColumn(name = &quot;type_id&quot;) private Type type; @ManyToOne @JoinColumn(name = &quot;unit_id&quot;) private Unit unit; } </code></pre> <p><strong>Type class</strong></p> <pre><code>@Entity @Table(name = &quot;types&quot;) @Data @NoArgsConstructor @AllArgsConstructor public class Type { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = &quot;type_id&quot;) private Integer id; private String type; } </code></pre> <p><strong>Unit class</strong></p> <pre><code>@Entity @Table(name = &quot;units&quot;) @Data @NoArgsConstructor @AllArgsConstructor public class Unit { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = &quot;unit_id&quot;) private Integer id; private String unit; } </code></pre>
[ { "answer_id": 74151810, "author": "cyberbrain", "author_id": 2846138, "author_profile": "https://Stackoverflow.com/users/2846138", "pm_score": 0, "selected": false, "text": "import module namespace json = \"http://marklogic.com/xdmp/json\"\n at \"/MarkLogic/json/json.xqy\";\n\n\nlet ...
2022/10/21
[ "https://Stackoverflow.com/questions/74150978", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19738095/" ]
74,151,002
<p>I'm building an admin panel and now when I run the code there is no error but the drawer is not working</p> <p>I looked for the problem and I can't find it</p> <p>These are the controllers where I create the with multiple scaffold key</p> <pre><code>class MenuController extends ChangeNotifier { final GlobalKey&lt;ScaffoldState&gt; _scaffoldkey = GlobalKey&lt;ScaffoldState&gt;(); final GlobalKey&lt;ScaffoldState&gt; _gridScaffoldkey = GlobalKey&lt;ScaffoldState&gt;(); final GlobalKey&lt;ScaffoldState&gt; _addProductsScaffoldkey = GlobalKey&lt;ScaffoldState&gt;(); GlobalKey&lt;ScaffoldState&gt; get getScaffoldkey =&gt; _scaffoldkey; GlobalKey&lt;ScaffoldState&gt; get getGridScaffoldkey =&gt; _gridScaffoldkey; GlobalKey&lt;ScaffoldState&gt; get getAddProductsScaffoldkey =&gt; _addProductsScaffoldkey; void controlDashboardMenu() { if (_scaffoldkey.currentState!.isDrawerOpen) { _scaffoldkey.currentState!.openDrawer(); } } void controlProductsMenu() { if (_gridScaffoldkey.currentState!.isDrawerOpen) { _gridScaffoldkey.currentState!.openDrawer(); } } void controlAddProductsMenu() { if (_addProductsScaffoldkey.currentState!.isDrawerOpen) { _addProductsScaffoldkey.currentState!.openDrawer(); } } } </code></pre> <p>and this is where I call it inside a function that is inside the drawer widget and i passed it to this widget</p> <pre><code>class DashboardScreen extends StatelessWidget { const DashboardScreen({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return SafeArea( child: SingleChildScrollView( child: Column( children: [ Header(fuc: () { context.read&lt;MenuController&gt;().controlDashboardMenu(); }), Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Expanded( child: Column( children: [ProductsWidget()], ), ), ], ), ], ), ), ); } } </code></pre> <p>and here I call the key inside the scaffold for this is my main screen</p> <pre><code>class MainScreen extends StatelessWidget { const MainScreen({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( key: context.read&lt;MenuController&gt;().getScaffoldkey, drawer: const SideMenu(), body: SafeArea( child: Row( children: [ if (Responsive.isDesktop(context)) const Expanded( child: SideMenu(), ), const Expanded( flex: 5, child: DashboardScreen(), ), ], ), ), ); } } </code></pre>
[ { "answer_id": 74151810, "author": "cyberbrain", "author_id": 2846138, "author_profile": "https://Stackoverflow.com/users/2846138", "pm_score": 0, "selected": false, "text": "import module namespace json = \"http://marklogic.com/xdmp/json\"\n at \"/MarkLogic/json/json.xqy\";\n\n\nlet ...
2022/10/21
[ "https://Stackoverflow.com/questions/74151002", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17755642/" ]
74,151,037
<p>I've a problem with price range input in Firefox, in every browser its works fine but in Mozilla first or second dot on range are unclickable. I was looking to fix this everywhere and can't find answer.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="UTF-8"&gt; &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt; &lt;title&gt;Price Range&lt;/title&gt; &lt;link rel="stylesheet" href="style.css"&gt; &lt;style&gt; .range-slider { width: 480px; /* Match this to the SVG's x2 value */ margin: auto; text-align: center; position: relative; height: 6em; } .range-slider svg, .range-slider input[type="range"] { position: absolute; left: 0; bottom: 0; } input[type="number"] { border: 1px solid #ddd; text-align: center; font-size: 1.6em; } input[type="number"]:invalid, input[type="number"]:out-of-range { border: 2px solid #ff6347; } input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; } input[type="range"]:focus { outline: none; } input[type="range"]:focus::-webkit-slider-runnable-track { background: #2497e3; } input[type="range"]:focus::-ms-fill-lower { background: #2497e3; } input[type="range"]:focus::-ms-fill-upper { background: #2497e3; } input[type="range"]::-webkit-slider-runnable-track { width: 100%; height: 5px; cursor: pointer; animate: 0.2s; background: #2497e3; border-radius: 1px; box-shadow: none; border: 0; } input[type="range"]::-webkit-slider-thumb { z-index: 2; position: relative; box-shadow: 0px 0px 0px #000; border: 1px solid #2497e3; height: 18px; width: 18px; border-radius: 25px; background: #a1d0ff; cursor: pointer; -webkit-appearance: none; appearance: none; margin-top: -7px; } input[type="range"]::-moz-range-track { width: 100%; height: 5px; cursor: pointer; animate: 0.2s; background: #2497e3; border-radius: 1px; box-shadow: none; border: 0; } input[type="range"]::-moz-range-thumb { z-index: 2; position: relative; box-shadow: 0px 0px 0px #000; border: 1px solid #2497e3; height: 18px; width: 18px; border-radius: 25px; background: #a1d0ff; cursor: pointer; } input[type="range"]::-ms-track { width: 100%; height: 5px; cursor: pointer; animate: 0.2s; background: transparent; border-color: transparent; color: transparent; } input[type="range"]::-ms-fill-lower, input[type="range"]::-ms-fill-upper { background: #2497e3; border-radius: 1px; box-shadow: none; border: 0; } input[type="range"]::-ms-thumb { z-index: 2; position: relative; box-shadow: 0px 0px 0px #000; border: 1px solid #2497e3; height: 18px; width: 18px; border-radius: 25px; background: #a1d0ff; cursor: pointer; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="range-slider"&gt; &lt;span&gt;from &lt;input type="number" value="25000" min="0" max="100000" step="500"&gt; to &lt;input type="number" value="75000" min="0" max="100000" step="500"&gt;&lt;/span&gt; &lt;input value="25000" min="0" max="100000" step="500" type="range"&gt; &lt;input value="50000" min="0" max="100000" step="500" type="range"&gt; &lt;svg width="100%" height="24"&gt; &lt;line x1="4" y1="0" x2="480" y2="0" stroke="#444" stroke-width="12" stroke-dasharray="1 28"&gt;&lt;/line&gt; &lt;/svg&gt; &lt;/div&gt; &lt;script&gt; (function() { const parent = document.querySelector('.range-slider'); if (!parent) { return; } const rangeS = parent.querySelectorAll('input[type="range"]'), numberS = parent.querySelectorAll('input[type="number"]'); rangeS.forEach((el) =&gt; { el.oninput = () =&gt; { let slide1 = parseFloat(rangeS[0].value), slide2 = parseFloat(rangeS[1].value); if (slide1 &gt; slide2) { [slide1, slide2] = [slide2, slide1]; } numberS[0].value = slide1; numberS[1].value = slide2; } }); numberS.forEach((el) =&gt; { el.oninput = () =&gt; { let number1 = parseFloat(numberS[0].value), number2 = parseFloat(numberS[1].value); if (number1 &gt; number2) { let tmp = number1; numberS[0].value = number2; numberS[1].value = tmp; } rangeS[0].value = number1; rangeS[1].value = number2; } }); })(); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74151810, "author": "cyberbrain", "author_id": 2846138, "author_profile": "https://Stackoverflow.com/users/2846138", "pm_score": 0, "selected": false, "text": "import module namespace json = \"http://marklogic.com/xdmp/json\"\n at \"/MarkLogic/json/json.xqy\";\n\n\nlet ...
2022/10/21
[ "https://Stackoverflow.com/questions/74151037", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20299243/" ]