qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,220,835
<p>I want to split my string at each hyphen but only if it's not preceded by a whitespace. However, if it is followed by a whitespace, I wanna split it and have the hyphen removed. The same should happen if the hyphen is the last character of the string.</p> <p>Example:</p> <p><code>myString = '- foo - -bar --baz -'</code></p> <p>Let's say I call</p> <pre><code>myString.split(regExImLookingFor).join(' ').split(' ').filter(word =&gt; word !== '') </code></pre> <p>I want it to return the following array:</p> <pre><code>[foo, -bar, --baz] </code></pre> <p><strong>Notice how all the orphaned hyphens disappeared</strong>. There were 3 of them in <code>myString</code>: One at the start, one in the middle, and one in the end.</p>
[ { "answer_id": 74220922, "author": "anubhava", "author_id": 548225, "author_profile": "https://Stackoverflow.com/users/548225", "pm_score": 2, "selected": false, "text": "match" }, { "answer_id": 74220926, "author": "Wiktor Stribiżew", "author_id": 3832970, "author_pr...
2022/10/27
[ "https://Stackoverflow.com/questions/74220835", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8281994/" ]
74,220,844
<p>Here's my toy dataframe:</p> <pre><code>df &lt;- data.frame( date = (1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2), action =c(&quot;ID=1&quot;, &quot;foo&quot;,&quot;bah&quot;, &quot;error&quot;, &quot;ID=2&quot;, &quot;foo&quot;,&quot;bah&quot;, &quot;success&quot;, &quot;ID=3&quot;, &quot;foo&quot;,&quot;bah&quot;, &quot;error&quot;, &quot;ID=4&quot;, &quot;foo&quot;,&quot;bah&quot;, &quot;success&quot;, &quot;ID=5&quot;, &quot;foo&quot;,&quot;bah&quot;, &quot;success&quot;, &quot;ID=6&quot;, &quot;foo&quot;,&quot;bah&quot;, &quot;error&quot;, &quot;ID=7&quot;, &quot;foo&quot;,&quot;bah&quot;, &quot;error&quot;, &quot;ID=8&quot;, &quot;foo&quot;,&quot;bah&quot;, &quot;success&quot;, &quot;ID=9&quot;, &quot;foo&quot;,&quot;bah&quot;, &quot;success&quot;, &quot;ID=10&quot;, &quot;foo&quot;,&quot;bah&quot;, &quot;success&quot; ) ) </code></pre> <p>I would like to process <code>df</code> so that whenever an entry in the <code>action</code> column is equal to &quot;error&quot;, the preceding row containing &quot;ID=&quot; is returned together with the associated entry in the data column. So expected result would be:</p> <pre><code>date action 1 ID=1 2 ID=3 2 ID=6 2 ID=7 </code></pre> <p>I tried using something along the lines of:</p> <pre><code>df %&gt;% filter(str_detect(action,&quot;error&quot;)) %&gt;% slice(-4) </code></pre> <p>,but it's not quite there!</p>
[ { "answer_id": 74220922, "author": "anubhava", "author_id": 548225, "author_profile": "https://Stackoverflow.com/users/548225", "pm_score": 2, "selected": false, "text": "match" }, { "answer_id": 74220926, "author": "Wiktor Stribiżew", "author_id": 3832970, "author_pr...
2022/10/27
[ "https://Stackoverflow.com/questions/74220844", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1819186/" ]
74,220,881
<pre><code>int memcmp(const void *s1, const void *s2, size_t n); </code></pre> <p>most of the implementations of memcmp function in c cast the arguments s1 and s2 into unsigned char. I am aware the the two arguments are casted to char so that memcmp compare 1 byte at a time, but why use unsigned char instead of just char ?</p> <p>I tried to understand the function by reading its source code but I couldn't understand that specific part.</p>
[ { "answer_id": 74221067, "author": "Lundin", "author_id": 584518, "author_profile": "https://Stackoverflow.com/users/584518", "pm_score": 1, "selected": false, "text": "char" }, { "answer_id": 74221109, "author": "DevSolar", "author_id": 60281, "author_profile": "http...
2022/10/27
[ "https://Stackoverflow.com/questions/74220881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20189666/" ]
74,220,894
<p>Need help with postsql query field matching a certain domain names in the end as per below in a particular FIELD. 1234.abc.xyz.com; 0971.abc.xyz.com</p> <pre><code>WHERE CAST (domain_name AS text) LIKE '%\d{4}.abc.xyz.com%' </code></pre> <p>#where domain_name is the FIELD name</p>
[ { "answer_id": 74221241, "author": "FatFreddy", "author_id": 9322156, "author_profile": "https://Stackoverflow.com/users/9322156", "pm_score": 0, "selected": false, "text": "where domain_name ~ '\\d\\d\\d\\d\\.abc\\.xyz\\.com' \n" }, { "answer_id": 74221925, "author": "Bjarni...
2022/10/27
[ "https://Stackoverflow.com/questions/74220894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6346997/" ]
74,220,927
<p>I have a file with 7 columns with 192 million lines. I want to filter the file so it only has data beginning with <code>chr1_</code> and <code>chr7_</code> in the second column.</p> <pre><code>head file.txt.gz gene_id variant_id tss_distance ma_samples ma_count maf pval_nominal slope slope_se ENSG00000227232.5 chr1_13550_G_A_b38 -16003 16 16 0.0132231 0.329834 0.188778 0.193552 ENSG00000227232.5 chr1_14671_G_C_b38 -14882 12 12 0.00991736 0.618791 0.110828 0.222611 ENSG00000227232.5 chr2_14677_G_A_b38 -14876 60 60 0.0495868 0.378305 -0.090737 0.102905 ENSG00000227232.5 chr3_16841_G_T_b38 -12712 46 46 0.0380165 0.100419 -0.191008 0.116067 ENSG00000227232.5 chrX_16856_A_G_b38 -12697 10 10 0.00826446 0.708684 -0.0901965 0.241282 ENSG00000227232.5 chrX_17005_A_G_b38 -12548 18 18 0.014876 0.153674 -0.257458 0.180205 ENSG00000227232.5 chr4_17005_A_G_b38 -12548 18 18 0.014876 0.153674 -0.257458 0.180205 ENSG00000227232.5 chr7_17005_A_G_b38 -12548 18 18 0.014876 0.153674 -0.257458 0.180205 </code></pre> <p>output:</p> <pre><code>head file.txt.gz gene_id variant_id tss_distance ma_samples ma_count maf pval_nominal slope slope_se ENSG00000227232.5 chr1_13550_G_A_b38 -16003 16 16 0.0132231 0.329834 0.188778 0.193552 ENSG00000227232.5 chr1_14671_G_C_b38 -14882 12 12 0.00991736 0.618791 0.110828 0.222611 ENSG00000227232.5 chr7_17005_A_G_b38 -12548 18 18 0.014876 0.153674 -0.257458 0.180205 </code></pre> <p>The second column has data in the format <code>chrnumber _number_letter_letter_b38</code>. The number and letters can be different. E.g <code>chr4_17005_A_G_b38</code> or <code>ch7_17090_A_T_b38</code>. I just want the second column to begin with <code>chr1_</code> or <code>chr7_</code>. How would I do this using <code>awk</code>?</p> <p>I have tired</p> <pre><code>gunzip -c file.txt.gz | awk '$2 ~ /^chr1/' &gt; output.txt </code></pre> <p>However the output also contains chr19 and chr10. Everything with 1. I am also unsure how to include chr7.</p>
[ { "answer_id": 74213399, "author": "markp-fuso", "author_id": 7366100, "author_profile": "https://Stackoverflow.com/users/7366100", "pm_score": 0, "selected": false, "text": "awk" }, { "answer_id": 74213400, "author": "Ted Lyngmo", "author_id": 7582247, "author_profil...
2022/10/27
[ "https://Stackoverflow.com/questions/74220927", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14614150/" ]
74,220,944
<p>I am trying to get all the &quot;Keys&quot; of annotations for use later, I am initializing the value like this:</p> <pre><code>private val wgKeys = SpecialRequestContext::class.members.associate { m -&gt; m.name to run { val headerAnnotation = m.annotations.find { a -&gt; a is Header } as? Header headerAnnotation?.key } } </code></pre> <p>Unfortunately, the result is a Map with name for keys (correct), but all the values are null. While debugging I see that <code>m.annotations</code> has no values.</p> <p>Are annotations not available at this step?</p> <p><strong>Update</strong>: The minimum code to demonstrate this is here, unfortunately Kotlin playground cannot do reflection though:</p> <pre><code>@Target(AnnotationTarget.VALUE_PARAMETER) annotation class Header(val key: String) data class SpecialRequestContext( @Header(&quot;BK-Correlation-Id&quot;) val correlationId: String? = null, @Header(&quot;BK-Origin&quot;) val origin: String? = null, @Header(&quot;BK-Origin-City&quot;) val originCity: String? = null, ) fun main() { println(wgKeys.count()) println(wgKeys[&quot;origin&quot;]) } private val wgKeys = SpecialRequestContext::class.members.associate { m -&gt; m.name to run { val headerAnnotation = m.annotations.find { a -&gt; a is Header } as? Header headerAnnotation?.key } } </code></pre>
[ { "answer_id": 74213399, "author": "markp-fuso", "author_id": 7366100, "author_profile": "https://Stackoverflow.com/users/7366100", "pm_score": 0, "selected": false, "text": "awk" }, { "answer_id": 74213400, "author": "Ted Lyngmo", "author_id": 7582247, "author_profil...
2022/10/27
[ "https://Stackoverflow.com/questions/74220944", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5481865/" ]
74,220,948
<p>I am working with an appointment booking system. this system includes a full calendar with a monthly list view.I want to change the background and text color when hover list item.it default gets a white color background. how do change it?</p> <pre><code>if (calev.end._d.getTime() &lt; ntoday.getTime() ) { elt.css('background-color', '#5c5c3d');//change backgroud color elt.css('color', 'white');//change text color elt.find(&quot;.fc-event-dot&quot;).css('background-color','white');//change dot color //here I want write a hover background and text color code } </code></pre> <p><a href="https://i.stack.imgur.com/CHz7I.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CHz7I.png" alt="Sample view" /></a></p>
[ { "answer_id": 74213399, "author": "markp-fuso", "author_id": 7366100, "author_profile": "https://Stackoverflow.com/users/7366100", "pm_score": 0, "selected": false, "text": "awk" }, { "answer_id": 74213400, "author": "Ted Lyngmo", "author_id": 7582247, "author_profil...
2022/10/27
[ "https://Stackoverflow.com/questions/74220948", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12080866/" ]
74,220,952
<p>i have an Array with this string value.</p> <pre><code>[VALIDUNTIL] =&gt; 28.08.23 </code></pre> <p>Now i need to compare it with the todays date and check if the VALIDUNTIL date is in the same month and year as the today´s date i looked for a while now but i cant find any solution.</p> <pre><code>while ($row = oci_fetch_assoc($dbResult)) { $data[] = $row; } foreach($data as $ar) { if ($ar['VALIDUNTIL'] &amp;&amp; $ar['VALIDUNTIL'] != null) { if(strtotime($ar['VALIDUNTIL']) &gt;= strtotime($date)) { } } </code></pre> <p>When i try to do it with timestamps it cant read the VALIDUNTIL date and gives me the 1970 timestamp strtotime seems not to work too. tnx 4 help.</p>
[ { "answer_id": 74213399, "author": "markp-fuso", "author_id": 7366100, "author_profile": "https://Stackoverflow.com/users/7366100", "pm_score": 0, "selected": false, "text": "awk" }, { "answer_id": 74213400, "author": "Ted Lyngmo", "author_id": 7582247, "author_profil...
2022/10/27
[ "https://Stackoverflow.com/questions/74220952", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20346484/" ]
74,221,033
<p>In the projects in IntelliJ IDEA I am using <strong>JDK 8 Update 321</strong>, but I am missing javadoc or source for the SDK.</p> <p>OS is Windows 10.</p> <p>I realy tried, but wasn't able to find either on the internet.</p>
[ { "answer_id": 74221678, "author": "sinclair", "author_id": 2315162, "author_profile": "https://Stackoverflow.com/users/2315162", "pm_score": 3, "selected": true, "text": "src.zip" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74221033", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14132343/" ]
74,221,077
<p>I have data that looks like this :</p> <pre><code>X snp_id is_severe encoding_1 encoding_2 encoding_0 1 0 GL000191.1-37698 0 0 1 7 3 2 GL000191.1-37922 1 1 0 12 </code></pre> <p>what I wish to do is to add a new row after every row that will contain the previous snp_id value and the is_sever value will be 1 if the previous is 0 and 0 if the previous is 1 (the goal is that every value of snp_id will have zero and one in is_severe column and not only zero or one ( and every snp_id will appear twice once with is_sever =zero and once with is_sever=1 all values of snp_id in the data are unique ) . Also, the encoding_1 &amp; ancoding_2 will have the value 0 and the encoding_0 column will follow the equation: if in the new row the is_severe value is 0 the encoding_0 will be =8 and if in the new row the is_severe value is 1 the encoding_0 will be =13</p> <p>Examples of desired output:</p> <pre><code>X snp_id is_severe encoding_1 encoding_2 encoding_0 1 0 GL000191.1-37698 0 0 1 7 2 1 GL000191.1-37698 1 0 0 13 &lt;- new row 3 2 GL000191.1-37922 1 1 0 12 4 3 GL000191.1-37922 0 0 0 8 &lt;- new row </code></pre> <p>i saw a similar QA here:<a href="https://stackoverflow.com/questions/16453452/how-can-i-add-rows-to-an-r-data-frame-every-other-row">How can I add rows to an R data frame every other row?</a> but i need to do more data manipulation and unfortunately this solution doesn't solve my problem . thank you:)</p>
[ { "answer_id": 74221678, "author": "sinclair", "author_id": 2315162, "author_profile": "https://Stackoverflow.com/users/2315162", "pm_score": 3, "selected": true, "text": "src.zip" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74221077", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12733891/" ]
74,221,082
<p>I have a .txt file which has the following format:</p> <pre><code>1 a 0.01 0.03 0.01 ... 2 b 0.04 0.03 0.01 ... </code></pre> <p>which may contain any number of columns with additional numbers. I need to find the index of the maximum value in each row for a large (2.5 million) number of rows.</p> <p>So far my approach was to preallocate an array and read the file line by line. I've been trying to avoid reading the whole file into memory due to its size:</p> <pre><code>import numpy as np indices = [] with open(file.txt) as f: for line in f: numbers = [float(s) for s in line[2:]] indices.append(np.argmax(numbers)) </code></pre> <p>This takes very long however and I am wondering if there is a more efficent method/package I could use?</p>
[ { "answer_id": 74221220, "author": "Whoeza", "author_id": 16210223, "author_profile": "https://Stackoverflow.com/users/16210223", "pm_score": -1, "selected": false, "text": "def recordsFromFile(inputFile):\n for line in inputFile:\n yield line\n\ninputFile = open('test.txt')\nf...
2022/10/27
[ "https://Stackoverflow.com/questions/74221082", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20348171/" ]
74,221,117
<p>Sorry if the question was not phrased awkwardly, I didn't know how to put it without an example.</p> <p>Given I have a 2 tables, Watch and WorkIn:</p> <p>Watch: {email<em>address, video</em>ID)<br /> WorkIn: {videoID, castname}</p> <p>How do I find for example, the email address of people who have watched ALL of 'David' products?</p> <p>I was thinking of using GROUP BY and ALL but I'm rather new to sql querying and don't really know how to put it all together.</p> <p><a href="https://i.stack.imgur.com/JjU6d.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JjU6d.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74221220, "author": "Whoeza", "author_id": 16210223, "author_profile": "https://Stackoverflow.com/users/16210223", "pm_score": -1, "selected": false, "text": "def recordsFromFile(inputFile):\n for line in inputFile:\n yield line\n\ninputFile = open('test.txt')\nf...
2022/10/27
[ "https://Stackoverflow.com/questions/74221117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18570358/" ]
74,221,138
<p>I need to add column in table called <code>value</code> which needs to store value from 0 to 1 up to 2 decimal points i.e. 0.25 0.50 0.75 0.80 etc..</p> <p>Can anyone help with this? Thanks in advance</p>
[ { "answer_id": 74221234, "author": "Zegarek", "author_id": 5298879, "author_profile": "https://Stackoverflow.com/users/5298879", "pm_score": 1, "selected": false, "text": "create table test (\n yournum numeric(3,2),\n check (yournum between 0 and 1));\n" }, { "answer_id": 74223...
2022/10/27
[ "https://Stackoverflow.com/questions/74221138", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15367939/" ]
74,221,149
<p>I often do this:</p> <pre><code>└─ mymodule ├─__init__.py ├─ MyClass1.py ... └─ MyClass2.py </code></pre> <p>And each file contains a single class, named accordingly MyClass1, MyClass2.</p> <p>I know, I know, not pythonic of me, but I believe that convention should not limit my possibilities.</p> <p>But, I encounter problems that I can not solve on my own - python import rules defy my logic.</p> <p>Could you please help me, if not understand, but at least to have a way to do what I want. I want to compose my <code>__init__.py</code> so, that &quot;mymodule&quot; behaves as if all classes were in one file &quot;mymodule.py&quot;.</p> <p>I.e. from outside file, I want to be able to do:</p> <p><code>from mymodule import MyClass1</code></p> <p>And it would give me the class, and not the module, without having to do MyClass1.MyClass1.</p> <p>Is there a way to do this in Python?</p>
[ { "answer_id": 74221234, "author": "Zegarek", "author_id": 5298879, "author_profile": "https://Stackoverflow.com/users/5298879", "pm_score": 1, "selected": false, "text": "create table test (\n yournum numeric(3,2),\n check (yournum between 0 and 1));\n" }, { "answer_id": 74223...
2022/10/27
[ "https://Stackoverflow.com/questions/74221149", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2487835/" ]
74,221,202
<p>I have a script that puts the line that starts with #Solution 1 in a new file together with the name of the input file. But I want to add the piece belonging to Major from the input file. Can someone please help me to figure out how to get the piece of text?</p> <p>The script now:</p> <pre><code>#!/usr/bin/env python3 import os dr = &quot;/home/nwalraven/Result_pgx/Runfolder/Runres_Aldy&quot; outdr = &quot;/home/nwalraven/Result_pgx/Runfolder/Aldy_res_txt&quot; tag = &quot;.aldy&quot; for f in os.listdir(dr): if f.endswith(tag): print(f) new_file_name = f.split('_')[0]+'.txt' # get the name of the file before the '_' and add '.txt' to it with open(dr+&quot;/&quot;+f) as file: for line in file.readlines(): f if line.startswith(&quot;#Solution 1&quot;): with open(outdr+&quot;/&quot;+new_file_name,&quot;a&quot;,newline='\n') as new_file: new_file.write(f.split('.')[0] + &quot;\n&quot;) new_file.write(line + &quot;\n&quot;) if line.startswith(&quot;#Solution 2&quot;): with open(outdr+&quot;/&quot;+new_file_name,&quot;a&quot;,newline='\n') as new_file: new_file.write(line + &quot;\n&quot;) print(&quot;Meerdere oplossingen gevonden! Check Aldy bestand&quot; ) </code></pre> <p>The input:</p> <p>file = EMQN3-S3_COMT.aldy</p> <pre><code>#Sample Gene SolutionID Major Minor Copy Allele Location Type Coverage Effect dbSNP Code Status #Solution 1: *Met, *ValB EMQN3-S3 COMT 1 *Met/*ValB Met;ValB 0 Met 19950234 C&gt;T 530 H62= rs4633 EMQN3-S3 COMT 1 *Met/*ValB Met;ValB 0 Met 19951270 G&gt;A 651 V158M rs4680 EMQN3-S3 COMT 1 *Met/*ValB Met;ValB 1 ValB </code></pre> <p>file = EMQN3-S3_CYP2B6.aldy</p> <pre><code>#Sample Gene SolutionID Major Minor Copy Allele Location Type Coverage Effect dbSNP Code Status #Solution 1: *1.001, *1.001 EMQN3-S3 CYP2B6 1 *1/*1 1.001;1.001 0 1.001 EMQN3-S3 CYP2B6 1 *1/*1 1.001;1.001 1 1.001 </code></pre> <p>The result it gives right now:</p> <pre><code>EMQN3-S3_COMT.aldy #Solution 1: *Met, *ValB EMQN3-S3_CYP2B6.aldy #Solution 1: *1.001, *1.001 </code></pre> <p>The result I need:</p> <pre><code>EMQN3-S3_COMT.aldy #Solution 1: *Met/*ValB EMQN3-S3_CYP2B6.aldy #Solution 1: *1/*1 </code></pre>
[ { "answer_id": 74221234, "author": "Zegarek", "author_id": 5298879, "author_profile": "https://Stackoverflow.com/users/5298879", "pm_score": 1, "selected": false, "text": "create table test (\n yournum numeric(3,2),\n check (yournum between 0 and 1));\n" }, { "answer_id": 74223...
2022/10/27
[ "https://Stackoverflow.com/questions/74221202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20229918/" ]
74,221,208
<p>I want to implement an expression-tree for assignment-calls to properties of my model. So I am able to call it like this:</p> <pre><code>UpdateFeature(myFeature, x =&gt; x.MyProperty, &quot;newValue&quot;); </code></pre> <p>which would set the <code>myFeature.MyProperty</code> to <code>&quot;newValue&quot;</code>.</p> <p><code>myFeature</code> is of type <code>MyType</code>:</p> <pre><code>class MyType { public string MyProperty { get; set; } } </code></pre> <p>My <code>UpdateFeature</code>-function is this:</p> <pre><code>void UpdateFeature&lt;T, TResult&gt;(T feature, Expression&lt;Func&lt;T, TResult&gt;&gt; e, TResult newValue) { Expression exp = Expression.Assign((MemberExpression)e.Body, Expression.Constant(newValue)); var lambda = Expression.Lambda(exp, Expression.Parameter(typeof(T))); lambda.Compile().DynamicInvoke(feature); } </code></pre> <p>However I get an <code>InvalidOperationException</code> when calling <code>Compile</code>:</p> <blockquote> <p>variable 'x' of type 'MyType' referenced from scope '', but it is not defined</p> </blockquote> <p>I also tried using strongly-typed lambda:</p> <pre><code>var lambda = Expression.Lambda&lt;Action&lt;T&gt;&gt;(exp, Expression.Parameter(typeof(T))); </code></pre> <p>with the exact same error appearing.</p>
[ { "answer_id": 74221824, "author": "MakePeaceGreatAgain", "author_id": 2528063, "author_profile": "https://Stackoverflow.com/users/2528063", "pm_score": 1, "selected": false, "text": "PropertyExpression" }, { "answer_id": 74233305, "author": "Svyatoslav Danyliv", "author_...
2022/10/27
[ "https://Stackoverflow.com/questions/74221208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2528063/" ]
74,221,268
<p>I have two data frames in R</p> <pre><code>df1 &lt;- data.frame(Name = c(&quot;RIS_001&quot;, &quot;RIS_002&quot;, &quot;RIS_003&quot;, &quot;RIS_004&quot;, &quot;RIS_005&quot;)) %&gt;% mutate(Value = c(5, 3, 8, 6, 9)) df2 &lt;- data.frame(Prod = c(&quot;RIS_010&quot;, &quot;RIS_011&quot;, &quot;RIS_012&quot;, &quot;RIS_013&quot;, &quot;RIS_014&quot;, &quot;RIS_015&quot;, &quot;RIS_016&quot;, &quot;RIS_017&quot;)) %&gt;% mutate(Value = c(54, 87, 92, 48, 66, 35, 12, 18)) </code></pre> <p><strong>I want to create two new data frames from them as in below images. How to accomplish this in R?</strong></p> <p><strong>new_df1, concatenation of Row &amp; Column or Column &amp; Row separated by a special character &quot;|&quot;</strong></p> <p><a href="https://i.stack.imgur.com/0iIa4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0iIa4.png" alt="enter image description here" /></a></p> <p><strong>new_df2, mean of each intersecting row &amp; column</strong> Ex: Mean for RIS_001 &amp; RIS_010 = mean(5 + 54) = 29.5</p> <p><a href="https://i.stack.imgur.com/bKamo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bKamo.png" alt="enter image description here" /></a></p> <p><em>Appreciate any help. Thank you!</em></p>
[ { "answer_id": 74221824, "author": "MakePeaceGreatAgain", "author_id": 2528063, "author_profile": "https://Stackoverflow.com/users/2528063", "pm_score": 1, "selected": false, "text": "PropertyExpression" }, { "answer_id": 74233305, "author": "Svyatoslav Danyliv", "author_...
2022/10/27
[ "https://Stackoverflow.com/questions/74221268", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6237274/" ]
74,221,293
<p><strong>Data as in big Query</strong> <img src="https://i.stack.imgur.com/UBbui.png" alt="enter image description here" /></p> <p><strong>Output Required</strong> <a href="https://i.stack.imgur.com/EEH23.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EEH23.png" alt="enter image description here" /></a></p> <p><strong>Request everyone to design a query to get desired output in Big Query</strong></p>
[ { "answer_id": 74221824, "author": "MakePeaceGreatAgain", "author_id": 2528063, "author_profile": "https://Stackoverflow.com/users/2528063", "pm_score": 1, "selected": false, "text": "PropertyExpression" }, { "answer_id": 74233305, "author": "Svyatoslav Danyliv", "author_...
2022/10/27
[ "https://Stackoverflow.com/questions/74221293", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8301818/" ]
74,221,343
<p>I’m trying to stream data from parquet files stored in Dropbox (but it could be somewhere else, S3, gdrive, etc…) and reading in Pandas, while caching it. For that I’m trying to use <a href="https://filesystem-spec.readthedocs.io/en/latest/index.html" rel="nofollow noreferrer">fsspec for Python</a></p> <p>Following <a href="https://arrow.apache.org/docs/python/filesystems.html#using-arrow-filesystems-with-fsspec" rel="nofollow noreferrer">these instructions</a> that’s what I’m trying right now:</p> <pre class="lang-py prettyprint-override"><code>from fsspec.implementations.arrow import ArrowFSWrapper from fsspec.implementations.cached import CachingFileSystem import pandas as pd cfs = CachingFileSystem(target_protocol=&quot;http&quot;, cache_storage=&quot;cache_fs&quot;) cfs_arrow = ArrowFSWrapper(cfs) url = &quot;https://www.dropbox.com/s/…./myfile.parquet?dl=0&quot; f = cfs_arrow.open(url, &quot;rb&quot;) df = pd.read_parquet(f) </code></pre> <p>but this raises the following error at <code>cfs_arrow.open(url, &quot;rb&quot;)</code>:</p> <pre class="lang-py prettyprint-override"><code>AttributeError: type object 'HTTPFileSystem' has no attribute 'open_input_stream' </code></pre> <p>I’ve used fsspec <code>CachingFileSystem</code> before to stream hdf5 data from S3, so I presumed it would work out-of-the-box, but I’m probably doing something wrong.</p> <p>Can someone help me with that? Or other suggestions on how to accomplish the goal of streaming my tabular data while keeping a cache for fast later access in the same session?</p>
[ { "answer_id": 74221822, "author": "0x26res", "author_id": 109525, "author_profile": "https://Stackoverflow.com/users/109525", "pm_score": 1, "selected": false, "text": "arrow" }, { "answer_id": 74222855, "author": "mdurant", "author_id": 3821154, "author_profile": "h...
2022/10/27
[ "https://Stackoverflow.com/questions/74221343", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11483674/" ]
74,221,349
<p>I have the following list</p> <pre><code>['BILL FROM:', 'TestCorp', 'USA, NY 02123, Washington St.', 'New York, NY, 02123', 'United States', 'musicjohnliofficial@gmail.com', 'BILL TO:', 'Yao Min', 'LA, 2123, Los Angeles', 'new York, NY, 9803432', 'United States', 'yao123@mail.com', 'INVOICE #', '01', 'INVOICE DATE', '2022-08-05', 'AMOUNT DUE', '$36.79', 'SUBTOTAL', '$36.74', 'TAX (0.13%)', '$0.05', 'TOTAL', '$36.79', 'Item', 'Description', 'Quantity', 'Unit Cost', 'Line Total', 'Pen', 'Pen, black coloe', '1.5', '$1.16', '$1.74', 'Book', 'Calculus, Zorych, pt. 1', '3.5', '$10.00', '$35.00', 'Powered by Shopify', 'www.shopify.com'] </code></pre> <p>and I'm tryin to convert it to dictionary to get something like this:</p> <pre><code>{'Bill From:': 'TestCorp',...,'Powered by Shopify': 'www.shopify.com'} </code></pre> <p>So, every key in the dict should be i-th elemnt from my list, each value - i+1 element from the list. I'm trying to loop through that list taking each pair of it's elements and put it into empty dict:</p> <pre><code>res_dct = {prepared_data[i]: prepared_data[i + 1] for i in range(, len(prepared_data))} </code></pre> <p>But I'm getting an error</p> <pre><code>IndexError: list index out of range </code></pre> <p>I have tried this code with smaller list and it worked!</p> <pre><code>&gt;&gt;&gt; lst = ['a', 1, 'b', 2, 'c', 3] &gt;&gt;&gt; res_dct = {lst[i]: lst[i + 1] for i in range(0, len(lst), 2)} &gt;&gt;&gt; res_dct {'a': 1, 'b': 2, 'c': 3} </code></pre> <p>So what's wrong? If somebody has any ideas please help me figure that out. Thank you!</p>
[ { "answer_id": 74221386, "author": "Rahul K P", "author_id": 4407666, "author_profile": "https://Stackoverflow.com/users/4407666", "pm_score": 2, "selected": false, "text": "zip" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74221349", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
74,221,375
<p>I am looking into this dataset: <a href="https://www.kaggle.com/datasets/stefanoleone992/rotten-tomatoes-movies-and-critic-reviews-dataset?select=rotten_tomatoes_movies.csv" rel="nofollow noreferrer">https://www.kaggle.com/datasets/stefanoleone992/rotten-tomatoes-movies-and-critic-reviews-dataset?select=rotten_tomatoes_movies.csv</a></p> <p>I am interested in scores grouped by production companies, but some companies have subdivisions that are very similar to each other, e.g. 20th Century Fox, 20th Century Fox Distribution, 20th Century Fox Film, 20th Century Fox Film Corp., and so on.</p> <p>I am searching for a way to collect all the movies produced under subdivision into one category, in this case 20th Century Fox - as I am not interested in their specific division.</p> <p>I have done some initalization and cleaning of the data based on a Git depository:</p> <pre><code>import pandas as pd import numpy as np df = pd.read_csv('rotten_tomatoes_movies.csv') cols_of_interest = ['movie_title', 'genres', 'content_rating', 'original_release_date', 'streaming_release_date', 'runtime', 'tomatometer_rating', 'tomatometer_count', 'audience_rating', 'audience_count', 'production_company'] df = df[cols_of_interest] df.original_release_date.fillna(df.streaming_release_date, inplace=True) df.drop(columns=['streaming_release_date'], inplace=True) df.rename(columns={'original_release_date': 'release_date'}, inplace=True) df = df[(df.tomatometer_count&gt;0) &amp; (df.audience_count&gt;0)] df.drop_duplicates(subset=['movie_title', 'release_date'], inplace=True) df.dropna(subset=['genres', 'release_date'], inplace=True) df = df.sort_values(by='release_date', ascending=True).reset_index(drop=True) </code></pre> <p>For my specific problem I had the idea to base analysis on the first word using:</p> <pre><code>df.production_company.astype('|S') test = df.production_company.split(' ',1) </code></pre> <p>which gives</p> <pre><code>UnicodeEncodeError: 'ascii' codec can't encode character '\xe9' in position 1: ordinal not in range(128) </code></pre> <p>Any ideas on other approaches or help on the current Error would be greatly appreciated!</p>
[ { "answer_id": 74221741, "author": "0x0fba", "author_id": 20339407, "author_profile": "https://Stackoverflow.com/users/20339407", "pm_score": 2, "selected": true, "text": "df = pd.read_csv('rotten_tomatoes_movies.csv', encoding='utf-8')\n" }, { "answer_id": 74234240, "author"...
2022/10/27
[ "https://Stackoverflow.com/questions/74221375", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17106249/" ]
74,221,378
<p>short python question:</p> <p>I have the following df with fake data in it: <a href="https://i.stack.imgur.com/wreo9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wreo9.png" alt="enter image description here" /></a></p> <p>I need to count for each hour (purchase_hour column) the maximum consecutive tickets sold to a show. meaning, I expect to see for 9 AM adel sold 2 consecutive (she sold 4, but not consecutively), and kanye didn't sell anything consecutively. For 10 am, adel sold 3 and kanye sold 2.</p> <p>Anyone?</p> <p>I created the following code, but it has it issues and it's not complete. The main issue I can't get it to print for 10 am</p> <pre><code>i=0 count_adel, count_kanye =0,0 while i &lt; (len(df)-1): if (df[&quot;purchase_hour&quot;].iloc[i] == df[&quot;purchase_hour&quot;].iloc[i+1] and \ df[&quot;ticket_desc&quot;].iloc[i] == df[&quot;ticket_desc&quot;].iloc[i+1] and i != (len(df)-1)): if df[&quot;ticket_desc&quot;][i] == &quot;Adel L.A. Concert&quot;: count_adel+=1 else: count_kanye+=1 elif (df[&quot;purchase_hour&quot;].iloc[i] != df[&quot;purchase_hour&quot;].iloc[i+1]): print(&quot;adel ticket at &quot; + str(df[&quot;purchase_hour&quot;][i]) + &quot; is &quot; +str(count_adel)) print(&quot;kanye ticket at &quot; + str(df[&quot;purchase_hour&quot;][i]) + &quot; is &quot; +str(count_kanye)) count_adel=0 count_kanye=0 i=i+1 </code></pre>
[ { "answer_id": 74221741, "author": "0x0fba", "author_id": 20339407, "author_profile": "https://Stackoverflow.com/users/20339407", "pm_score": 2, "selected": true, "text": "df = pd.read_csv('rotten_tomatoes_movies.csv', encoding='utf-8')\n" }, { "answer_id": 74234240, "author"...
2022/10/27
[ "https://Stackoverflow.com/questions/74221378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12006067/" ]
74,221,398
<p>I am writing a lyrics app, that saves a song book and the songs in that book to an SQL lite database. I am mapping through an array of books and calling an API to save the book's songs. I want the saveBook() function to fully complete before moving on to the saveBookSong() function. I have tried async await but it is not working. Any help would be greatly appreciated, Thanks, Sam</p> <pre><code>useEffect( () =&gt; { Books.map ((book) =&gt;{ saveBook(book) saveBookSong(book.songId.toString()) }) </code></pre> <pre><code> function saveBook(book) { db.transaction( (tx) =&gt; { tx.executeSql( `INSERT INTO books (id, description, img, name, song_id) VALUES (?, ?, ?, ?, ?)`, [book.id, book.description, book.img, book.name, book.songId], () =&gt; { console.log(&quot;Saved!!&quot;, book.id) } ); }); } </code></pre> <pre><code> function saveBookSong(id) { axios .get(`songs/${id}`) .then((bookSong) =&gt; { bookSong.data.forEach((song) =&gt; { db.transaction((tx) =&gt; { tx.executeSql( `INSERT INTO songs (id, book, book_id, data, int_song_number, lang, search_title, song_number, title, url) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [ song.id, song.book, song.bookId, song.data, song.intSongNumber, song.lang, song.searchTitle, song.songNumber, song.title, song.url, ], () =&gt; { } ); }); }); }) .catch((err) =&gt; { console.log(err); }); } </code></pre>
[ { "answer_id": 74221518, "author": "Jacki", "author_id": 11743127, "author_profile": "https://Stackoverflow.com/users/11743127", "pm_score": 1, "selected": false, "text": "useEffect( () => {\n Books.map ((book) =>{\n saveBook(book).then(() => saveBookSong(book.songId.toString()))\n ...
2022/10/27
[ "https://Stackoverflow.com/questions/74221398", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15803332/" ]
74,221,405
<p>I would like to open a powershell from my python script, then launch another python script in this newly created powershell.</p> <pre class="lang-py prettyprint-override"><code>import subprocess subprocess.call(&quot;start C:\\Windows\\System32\\WindowsPowerShell\\v1.0&quot;, shell=True) # Here, I would like to write this in the new opened powershell : python ./hello_world.py (then press ENTER) input(&quot;end&quot;) </code></pre> <p>Any idea how I can do that ? Thanks and have a good day !</p> <p>I tried the subprocess.Popen + communicate but nothing was written in my new powershell</p>
[ { "answer_id": 74221542, "author": "Omer Dagry", "author_id": 15010874, "author_profile": "https://Stackoverflow.com/users/15010874", "pm_score": 1, "selected": true, "text": "os.system()" }, { "answer_id": 74221588, "author": "Pascal", "author_id": 6453106, "author_p...
2022/10/27
[ "https://Stackoverflow.com/questions/74221405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20348423/" ]
74,221,408
<p>i recently started using the marqo library and i am trying to add document so that marqo can search and return the relevant part of the document but i keep getting error when i run the the code.</p> <p>i used the</p> <pre><code>add_document() </code></pre> <p>method and i pass the document as a string for search but it returns an error. Here is what my code look like;</p> <pre><code>import marqo DOCUMENT = 'the document' mq = marqo.Client(url='http://localhost:8882') mq.index(&quot;my-first-index&quot;).add_documents(DOCUMENT) </code></pre> <p>and when i run it i get a</p> <pre><code> MarqoWebError </code></pre>
[ { "answer_id": 74221651, "author": "sirrdeeqq", "author_id": 20020671, "author_profile": "https://Stackoverflow.com/users/20020671", "pm_score": 3, "selected": true, "text": "add_document()" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74221408", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20348340/" ]
74,221,419
<p>I have two dataframes that both have a column that <em><strong>can</strong></em> have the same number/value in it. One 'small df with ~300 rows (which is my leading file) and 1 df with ~ 5000 rows. I want to merge on 1 column but I cannot get the same amount of rows when I print the data.</p> <p><strong>first (small) dataframe (left):</strong></p> <pre><code>import pandas as pd df1 = pd.read_excel('./file.xlsx') df1 = df.replace(' ', np.nan) df1.head() col1 row1 123456 row2 123457 row3 123458 row4 123459 row5 123450 </code></pre> <p><strong>second (big) df (right):</strong></p> <pre><code>import pandas as pd df2 = pd.read_excel('./file2.xlsx') df2 = df.replace(' ', np.nan) df2 col1 col2 row1 123456 hello1 row2 123457 hello2 row3 123458 hello3 row4 123459 hello4 row5 123450 hello4 row7 555555 street1 row8 666666 street1 row9 777777 street1 </code></pre> <p><strong>I tried:</strong></p> <pre><code>merged = pd.merge(left=df1, right=df2, how='inner', left_on='col1', right_on='col1') print(&quot;Orginele data&quot;, len(df1)) print(&quot;Merged data&quot;, len(df2)) </code></pre> <p>When I print I get like 30k rows in the left df but I only want to see the rows used in the left df (~300 rows). Most of them are NaN's. I tried changing the 'how=' but that did not work. I also checked the post &quot;Merging 101&quot; but can't seem to figure this out.</p> <p><strong>Expected result in left (small) dataframe:</strong></p> <pre><code> col1 col2 row1 123456 hello1 row2 123457 hello2 row3 123458 hello3 row4 123459 hello4 row5 123450 hello4 </code></pre> <p>Appreciate the help and effort. Thank you!</p>
[ { "answer_id": 74221451, "author": "assume_irrational_is_rational", "author_id": 11622508, "author_profile": "https://Stackoverflow.com/users/11622508", "pm_score": 4, "selected": true, "text": "dataframe.join" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74221419", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20301326/" ]
74,221,425
<p>I'm trying to cycle through several url's to download the pdf to a local folder.</p> <p>An example of the url is <a href="https://find-energy-certificate.service.gov.uk/energy-certificate/8309-9619-9729-7796-8423?print=true" rel="nofollow noreferrer">https://find-energy-certificate.service.gov.uk/energy-certificate/8309-9619-9729-7796-8423?print=true</a></p> <p>This is the vb I've written so far.</p> <pre><code>Dim sveloc As String Dim svenme As String Dim url As String sveloc = Application.ActiveWorkbook.Path &amp; &quot;\Saved EPCs&quot; i = 7 Do Until sh01.Cells(i, 27) = &quot;&quot; 'all cells in the list are populated with no gaps url = sh01.Cells(i, 27) svenme = sh01.Cells(i, 2) sveloc = sveloc &amp; &quot;\&quot; &amp; svenme &amp; &quot;.pdf&quot; ThisWorkbook.FollowHyperlink (url) 'code to open and save the pdf goes here i = i + 1 Loop </code></pre> <p>Any help gratefully received as I'm really stumped on this one. TIA.</p>
[ { "answer_id": 74221927, "author": "K J", "author_id": 10802527, "author_profile": "https://Stackoverflow.com/users/10802527", "pm_score": 1, "selected": false, "text": "\"C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe\" --profile-directory=Default --headless -print-to...
2022/10/27
[ "https://Stackoverflow.com/questions/74221425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10598570/" ]
74,221,445
<p>I have 3 django models. Requirement Model has its own fields. RequirementImage and RequirementDOc models have Requirement as foreign key in them which are used for multiple image and multiple document upload. In admin ,I want to show the Requirement along with the images and documents related to requirement. How can i show it in admin panel. i want to show a view where i can list all fields of Requirement and RequirementImages and RequirementDocs together. Below is the exact code of models.</p> <pre><code>class Requirement(models.Model): name = models.CharField(max_length=100) description = models.CharField(max_length = 5000) mobile = models.CharField(max_length=15, null=True, blank=True) email = models.EmailField(null=True, blank=True) city = models.CharField(max_length=100) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) class RequirementImage(models.Model): requirement = models.ForeignKey('Requirement', on_delete=models.CASCADE) image = models.ImageField(null=True, blank=True, validators=[ FileMimeValidator() ], upload_to=settings.MEDIA_RELATIVE_ROOT + &quot;requirements/images&quot;) class RequirementDoc(models.Model): requirement = models.ForeignKey('Requirement', on_delete=models.CASCADE) requirement_file = models.FileField(null=True, blank=True, upload_to=settings.MEDIA_RELATIVE_ROOT + &quot;requirements/docs&quot;) </code></pre> <p>Python version is 3.7.12 and django version is 3.2.14</p>
[ { "answer_id": 74221927, "author": "K J", "author_id": 10802527, "author_profile": "https://Stackoverflow.com/users/10802527", "pm_score": 1, "selected": false, "text": "\"C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe\" --profile-directory=Default --headless -print-to...
2022/10/27
[ "https://Stackoverflow.com/questions/74221445", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1388835/" ]
74,221,460
<p>I am building a Spring Boot REST API application and using Kotlin as the language. For the development I am using IntellJ as the IDE.</p> <p>The project structure looks as follows:</p> <p><a href="https://i.stack.imgur.com/k9ORY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/k9ORY.png" alt="enter image description here" /></a></p> <p>Is there a way to watch changes in the folder <code>src</code> to trigger the gradle task <code>./gradlew test</code> after files have been changed?</p>
[ { "answer_id": 74221684, "author": "Andy Wilkinson", "author_id": 1384297, "author_profile": "https://Stackoverflow.com/users/1384297", "pm_score": 4, "selected": true, "text": "./gradlew test --continuous\n" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74221460", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1743843/" ]
74,221,466
<p>I'm struggle with this situation.</p> <p>I have these 2 macros that do not work together in the same worksheet.</p> <p>First</p> <pre><code>Private Sub Worksheet_Change(ByVal Target As Range) Dim rng As Range Dim cell As Range Set rng = Intersect(Target, Range(&quot;C:C&quot;)) ' Exit if no updates made to desired range If rng Is Nothing Then Exit Sub ' Loop through cells just updated Application.EnableEvents = False For Each cell In rng Cells(cell.Row, &quot;B&quot;) = Application.UserName Cells(cell.Row, &quot;A&quot;) = Format(Date, &quot;dd.mm.yyyy&quot;) Next cell Application.EnableEvents = True End Sub </code></pre> <p>And second</p> <pre><code>Private Sub Worksheet_Change(ByVal Target As Range) Dim rng1 As Range Dim cell As Range Set rng1 = Intersect(Target, Range(&quot;G:G&quot;)) ' Exit if no updates made to desired range If rng1 Is Nothing Then Exit Sub ' Loop through cells just updated Application.EnableEvents = False For Each cell In rng1 Cells(cell.Row, &quot;F&quot;) = Application.UserName Cells(cell.Row, &quot;E&quot;) = Format(Date, &quot;dd.mm.yyyy&quot;) Next cell Application.EnableEvents = True End Sub </code></pre> <p>I tried to get application.username in a specific column but the same row with the modified cell from another specific column. All of this but different ranges, in the same worksheet. Is it possible to combine these 2 macros in only one?</p>
[ { "answer_id": 74221882, "author": "FunThomas", "author_id": 7599798, "author_profile": "https://Stackoverflow.com/users/7599798", "pm_score": 3, "selected": true, "text": "Private Sub Worksheet_Change(ByVal Target As Range)\n Dim rng As Range, cell As Range\n Set rng = Intersect(T...
2022/10/27
[ "https://Stackoverflow.com/questions/74221466", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20348363/" ]
74,221,480
<p>I would like to sort an Excel pivot table created by using the win32com module with Python.</p> <p>As I understood, I should use the function AutoSort() and according to the official <a href="https://learn.microsoft.com/en-us/office/vba/api/excel.pivotfield.autosort" rel="nofollow noreferrer">documentation</a>, there are four fields, two of which are optional. Therefore, I am specifying only the &quot;Order&quot; and &quot;Field&quot; fields.</p> <pre><code>AutoSort(Order=1, Field=&quot;Tot Converted Amount Due&quot;) </code></pre> <p>However, when I run the below line of code, I get an error.</p> <pre><code> wb.Sheets(&quot;pivot_table&quot;).PivotTables(&quot;pivot_table&quot;).PivotFields(&quot;Tot Converted Amount Due&quot;).AutoSort(Order=1, Field=&quot;Tot Converted Amount Due&quot;) </code></pre> <p>Error:</p> <pre><code>def AutoSort(self, Order=defaultNamedNotOptArg, Field=defaultNamedNotOptArg, PivotLine=defaultNamedOptArg, CustomSubtotal=defaultNamedOptArg): ---&gt; 44 return self._oleobj_.InvokeTypes(1514, LCID, 1, (24, 0), ((3, 1), (8, 1), (12, 17), (12, 17)),Order 45 , Field, PivotLine, CustomSubtotal) 46 com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2146827284), None) </code></pre> <p>What am I doing wrong?</p> <p>I would really appreciate any inputs or help. Thanks!</p>
[ { "answer_id": 74221882, "author": "FunThomas", "author_id": 7599798, "author_profile": "https://Stackoverflow.com/users/7599798", "pm_score": 3, "selected": true, "text": "Private Sub Worksheet_Change(ByVal Target As Range)\n Dim rng As Range, cell As Range\n Set rng = Intersect(T...
2022/10/27
[ "https://Stackoverflow.com/questions/74221480", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11919592/" ]
74,221,498
<p>I am trying to write unit tests for a flutter app and I can't get this one test case to work correctly.</p> <p>Here is the function returning <code>Future&lt;Either&lt;WeatherData, DataError&gt;&gt;</code>:</p> <pre class="lang-dart prettyprint-override"><code>@override Future&lt;Either&lt;WeatherData, DataError&gt;&gt; fetchWeatherByCity({required String city}) async { try { var response = await apiService.fetchWeatherByCity(city: city); if (response.statusCode == 200) { return Left(WeatherData.fromJson(jsonDecode(response.body))); } else { return Right(DataError(title: &quot;Error&quot;, description: &quot;Desc&quot;, code: 0, url: &quot;NoUrl&quot;)); } } catch (error) { AppException exception = error as AppException; return Right(DataError( title: exception.title, description: exception.description, code: exception.code, url: exception.url)); } } </code></pre> <hr /> <p>Here is the code where I am trying to write the unit test:</p> <pre class="lang-dart prettyprint-override"><code>sut = WeatherRepositoryImpl(apiService: mockWeatherApiService); test( &quot;get weather by city DataError 1 - Error 404 &quot;, () async { when(mockWeatherApiService.fetchWeatherByCity(city: &quot;city&quot;)) .thenAnswer((_) async =&gt; Future.value(weatherRepoMockData.badResponse)); final result = await sut.fetchWeatherByCity(city: &quot;city&quot;); verify(mockWeatherApiService.fetchWeatherByCity(city: &quot;city&quot;)).called(1); expect(result, isInstanceOf&lt;DataError&gt;); verifyNoMoreInteractions(mockWeatherApiService); }, ); </code></pre> <p>When I run this specific test, I receive this error:</p> <pre><code> Expected: &lt;Instance of 'DataError'&gt; Actual: Right&lt;WeatherData, DataError&gt;:&lt;Right(Instance of 'DataError')&gt; Which: is not an instance of 'DataError' </code></pre> <p>What I am not getting here? What should I be expecting from the function for the test to pass successfully?</p>
[ { "answer_id": 74221882, "author": "FunThomas", "author_id": 7599798, "author_profile": "https://Stackoverflow.com/users/7599798", "pm_score": 3, "selected": true, "text": "Private Sub Worksheet_Change(ByVal Target As Range)\n Dim rng As Range, cell As Range\n Set rng = Intersect(T...
2022/10/27
[ "https://Stackoverflow.com/questions/74221498", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19599115/" ]
74,221,506
<p>Im working with a data set that needs some manual cleanup. One thing that i need to do is assign a certain value in one column to some of my rows, if in another column, that row has a value that is present in a list ive defined.</p> <p>So here a reduced example of what i want to do:</p> <pre class="lang-py prettyprint-override"><code>to_be_changed = ['b','e','a'] df = pd.DataFrame({'col1':[1,2,2,1,2],'col2':['a','b','c','d','e' ]}) # change col1 in all rows which label shows up in to_be_changed to 3 </code></pre> <p>So the desidered modified Dataframe would look like:</p> <pre><code> col1 col2 0 3 a 1 3 b 2 2 c 3 1 d 4 3 e </code></pre> <hr /> <p>My closest attempt to solving this is:</p> <pre class="lang-py prettyprint-override"><code>df = pd.DataFrame(np.where(df=='b' ,3,df) ,index=df.index,columns=df.columns) </code></pre> <p>Which produces:</p> <pre><code> col1 col2 0 1 a 1 2 3 2 2 c 3 1 d 4 2 e </code></pre> <p>This only changes col2 and obviously only the rows with the hardcoded-label <code>'b'</code>.</p> <p>I also tried:</p> <pre class="lang-py prettyprint-override"><code>df = pd.DataFrame(np.where(df in to_be_changed ,3,df) ,index=df.index,columns=df.columns) </code></pre> <p>But that produces an error:</p> <pre><code>ValueError Traceback (most recent call last) /tmp/ipykernel_11084/574679588.py in &lt;cell line: 4&gt;() 3 df = pd.DataFrame({'col1':[1,2,2,1,2],'col2':['a','b','c','d','e' ]}) 4 df = pd.DataFrame( ----&gt; 5 np.where(df in to_be_changed ,3,df) 6 ,index=df.index,columns=df.columns) 7 df ~/.local/lib/python3.9/site-packages/pandas/core/generic.py in __nonzero__(self) 1525 @final 1526 def __nonzero__(self): -&gt; 1527 raise ValueError( 1528 f&quot;The truth value of a {type(self).__name__} is ambiguous. &quot; 1529 &quot;Use a.empty, a.bool(), a.item(), a.any() or a.all().&quot; ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all(). </code></pre> <p>Thanks for any help !</p>
[ { "answer_id": 74221536, "author": "assume_irrational_is_rational", "author_id": 11622508, "author_profile": "https://Stackoverflow.com/users/11622508", "pm_score": 1, "selected": false, "text": "numpy.where" }, { "answer_id": 74221662, "author": "mozway", "author_id": 16...
2022/10/27
[ "https://Stackoverflow.com/questions/74221506", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8230508/" ]
74,221,516
<p>I have a button and a message that should be shown if condition is true.</p> <pre><code>&lt;button @onclick=&quot;Helper.CallFunc&quot;&gt;Call async func&lt;/button&gt; @if(Helper.Loading) { @(&quot;Loading...&quot;) } </code></pre> <p><code>LoadingHelper</code> class look like this</p> <pre><code>public class LoadingHelper { public bool Loading { get; private set; } = false; public Func&lt;Task&gt; PassedFunc { private get; set; } = async () =&gt; await Task.Delay(2000); public Func&lt;Task&gt; CallFunc =&gt; async () =&gt; { Loading = true; await PassedFunc(); Loading = false; }; } </code></pre> <p>When I define <code>Helper</code> object like this the message is indeed shown for 2000 miliseconds</p> <pre><code>LoadingHelper Helper { get; set; } = new() { PassedFunc = async () =&gt; await Task.Delay(2000) }; </code></pre> <p>However when it's defined like this the message is never shown</p> <pre><code>LoadingHelper Helper =&gt; new() { PassedFunc = async () =&gt; await Task.Delay(2000) }; </code></pre> <p>I'm a little bit confused here as to why the <code>Loading</code> change is not shown in second example. Shouldn't the change be visible regardless if the <code>Helper</code> object is set with <code>getter</code> and <code>setter</code> or only <code>getter</code> since I'm not modifying the <code>Loading</code> property directly?</p> <p><strong>Edit</strong> When it's defined like this for some reason <strong>it works</strong></p> <pre><code>LoadingHelper Helper { get; } = new() { PassedFunc = async () =&gt; await Task.Delay(2000) }; </code></pre>
[ { "answer_id": 74221667, "author": "RandomSlav", "author_id": 13922250, "author_profile": "https://Stackoverflow.com/users/13922250", "pm_score": 0, "selected": false, "text": "LoadingHelper Helper => new()" }, { "answer_id": 74224589, "author": "MrC aka Shaun Curtis", "a...
2022/10/27
[ "https://Stackoverflow.com/questions/74221516", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13922250/" ]
74,221,557
<p>I have a JSON array that looks similar to this</p> <p>[{sku:fgh456,price:239.22,quantity:1},{sku:ALK0069,price:110,quantity:1},{sku:dgft567,price:43.92,quantity:1},{sku:NAS0222,price:421.55,quantity:1}]</p> <p>** note we do not have double quotation and the array is stored as string</p> <p>Wanted to extract the each sku value. Please help. Thanks</p> <p>I tried json_query function</p>
[ { "answer_id": 74221667, "author": "RandomSlav", "author_id": 13922250, "author_profile": "https://Stackoverflow.com/users/13922250", "pm_score": 0, "selected": false, "text": "LoadingHelper Helper => new()" }, { "answer_id": 74224589, "author": "MrC aka Shaun Curtis", "a...
2022/10/27
[ "https://Stackoverflow.com/questions/74221557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20348540/" ]
74,221,563
<p>I am trying to add a column to data I have imported (and will export) as a CSV.</p> <p>I am importing a CSV:</p> <p><a href="https://i.stack.imgur.com/WWmX2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WWmX2.png" alt="enter image description here" /></a></p> <p>What I want to do add another column, perhaps &quot;10/15/22&quot; when the process runs, and then update the values under that date.</p> <p>In effect, the document will grow to the right, adding a column each time it is run.</p> <p>I have an object called $test. It will have values like:</p> <pre><code>$test.users = &quot;7&quot; $test.SomeBSValue = &quot;22&quot; $test.Computers = &quot;52&quot; </code></pre> <p>When all is said and done, my output should look like: <a href="https://i.stack.imgur.com/f7WV6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/f7WV6.png" alt="enter image description here" /></a></p> <p>Adding to the list any values I have that are not part of the list already, but recording the values I have under the heading for the date.</p> <p>So, if the script is run and collects 100 data points, those data point would all be in the CSV under the date.</p> <p>I would have thought this would be easy, but now I am drawing a complete blank.</p> <p>I've considered (but have not coded) even trying to put into a GUI grid view and then reading the data back and writing the CSV (but there should be an easier way, right?)</p>
[ { "answer_id": 74221667, "author": "RandomSlav", "author_id": 13922250, "author_profile": "https://Stackoverflow.com/users/13922250", "pm_score": 0, "selected": false, "text": "LoadingHelper Helper => new()" }, { "answer_id": 74224589, "author": "MrC aka Shaun Curtis", "a...
2022/10/27
[ "https://Stackoverflow.com/questions/74221563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11340383/" ]
74,221,572
<p>I have a dataframe where two of the columns <code>Start</code> and <code>End</code> are lists of dates. What I would like to do is create two separate dataframes where, for the first dataframe, the first value in the <code>Start</code> column matches the value in the <code>End</code> column, while for the second dataframe the second value in the <code>Start</code> column also matches the value in the <code>End</code> column.</p> <p>Basically, if there are two values in the <code>Start</code> column, then as long as the date in the <code>End</code> column is after the first date and before the second date (as given in row BBB in the examples below), then I want to put these values into two separate dataframes. Additionally, even if there's no date in the <code>End</code> column (as in row EEE in the examples below) then I still want to split it. Finally, if either or both the <code>Start</code> and <code>End</code> columns are empty, then they are kept in both dataframes.</p> <p>As an example, for the dataframe below:</p> <pre><code>Name Start End AAA 2017-09-13 BBB 2021-11-20, 2022-06-04 2022-04-07 CCC 2022-09-29 DDD EEE 2021-04-28, 2022-06-14 </code></pre> <p>I am trying to get the first dataframe to look like this:</p> <pre><code>Name Start End AAA 2017-09-13 BBB 2021-11-20 2022-04-07 CCC 2022-09-29 DDD EEE 2021-04-28 </code></pre> <p>and the second dataframe to look like this:</p> <pre><code>Name Start End AAA 2016-09-13 BBB 2022-06-04 2022-04-07 CCC 2022-09-29 DDD EEE 2022-06-14 </code></pre> <p>If the dates in the <code>Start</code> and <code>End</code> columns weren't in lists, it would be slightly easier, but as of now I'm finding it difficult to think of a computationally fast way of doing this, so any help would be greatly appreciated, thanks!</p>
[ { "answer_id": 74221862, "author": "mozway", "author_id": 16343464, "author_profile": "https://Stackoverflow.com/users/16343464", "pm_score": 3, "selected": true, "text": "tmp_df = df.assign(Start=df['Start'].str.split(',')).explode('Start')\n\ndf1 = tmp_df.groupby(level=0).first()\ndf2 ...
2022/10/27
[ "https://Stackoverflow.com/questions/74221572", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13910525/" ]
74,221,627
<p>I want to access the name property. I tried doing the following but it returned <code>undefined</code>:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>Category.find() .select("-_id") .select("-__v") .then((categories) =&gt; { let creator = req.userId; console.log(categories.name) //undefined if (categories.creator === creator &amp;&amp; categories.name === categoryName) { note .save()</code></pre> </div> </div> </p> <p>this is <code>console.log(categories)</code> :</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>[ { name: 'test11', creator: new ObjectId("6359766eaf27f731e789f061") }, { name: 'test11', creator: new ObjectId("6359766eaf27f731e789f061") }, { name: 'categ1', creator: new ObjectId("635a316453d25ea50a3a4c5c") }, { name: 'categ1', creator: new ObjectId("635a316453d25ea50a3a4c5c") }, { name: 'categ1', creator: new ObjectId("635a316453d25ea50a3a4c5c") }, { name: 'categ1', creator: new ObjectId("635a316453d25ea50a3a4c5c") }, { name: 'categ1', creator: new ObjectId("635a316453d25ea50a3a4c5c") }, { name: 'newCategName', creator: new ObjectId("635a316453d25ea50a3a4c5c") } ]</code></pre> </div> </div> </p> <p>I want to check that if the current signed in user's ID and the document name match an exact pair in the Category schema</p>
[ { "answer_id": 74221798, "author": "Alexey Khachatryan", "author_id": 8913631, "author_profile": "https://Stackoverflow.com/users/8913631", "pm_score": 1, "selected": false, "text": "console.log(categories.name)\n" }, { "answer_id": 74221850, "author": "ambianBeing", "aut...
2022/10/27
[ "https://Stackoverflow.com/questions/74221627", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19577126/" ]
74,221,677
<p>I have response data in CSV format which I want to use in the table and get the row data if I click on any row of that particular row data</p> <p>I try using CSVtoHtml npm but the row-clicking functionality does not work there.</p> <p><strong>CSV:</strong></p> <pre><code> {**CSV here**} </code></pre> <p>I have to make Symbol, Name, Sector, Validtill as heading and data below.</p> <p>I have tried converting them in an object which came up like this but doesn't show up in the table unable to map the data:</p> <pre><code>CSV after converting to Objects: {0:...}, {1:...}, {2:...}, ..., .. </code></pre> <p>this didn't map to the table</p> <p>the code:</p> <pre><code>function Stocks() { const { readString } = usePapaParse(); const navigate = useNavigate(); const [stocksData, setStocksData] = useState([]); useEffect(() =&gt; { axios.get(baseURL).then((response) =&gt; { console.log(response.data) readString(response.data, { worker: true, complete: (results) =&gt; { const obj = results.data.map((el) =&gt; { return { ...el }; }); console.log(obj, &quot;obj&quot;); setStocksData(obj); }, }); }); }, []); return ( &lt;div className=&quot;grid inline mx-8&quot;&gt; &lt;div className=&quot;w-full flex justify-end grid my-4&quot;&gt; &lt;input className=&quot;bg-white rounded w-48 outline-0&quot; /&gt; &lt;/div&gt; &lt;div className=&quot;bg-white text-red&quot;&gt; &lt;THeader&gt; &lt;THCell&gt;Symbol&lt;/THCell&gt; &lt;THCell&gt;Name&lt;/THCell&gt; &lt;THCell&gt;Category&lt;/THCell&gt; &lt;THCell&gt;Time&lt;/THCell&gt; &lt;/THeader&gt; &lt;TBody&gt;&lt;/TBody&gt; &lt;/div&gt; &lt;/div&gt; ); } </code></pre>
[ { "answer_id": 74221798, "author": "Alexey Khachatryan", "author_id": 8913631, "author_profile": "https://Stackoverflow.com/users/8913631", "pm_score": 1, "selected": false, "text": "console.log(categories.name)\n" }, { "answer_id": 74221850, "author": "ambianBeing", "aut...
2022/10/27
[ "https://Stackoverflow.com/questions/74221677", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20347723/" ]
74,221,698
<p>I am trying to get form data to json object and modify it... But it is not working... <br>Here is my code-</p> <pre><code>let formData = new FormData(thisForm).entries(); let body = JSON.stringify(Object.fromEntries(formData)); console.log(body); console.log(body.firstName); console.log(&quot;service=&quot; + body.service); body.service = &quot;hello&quot;; </code></pre> <p>the console.log(body) is printing output like this-</p> <pre><code>{&quot;prospectType&quot;:&quot;1&quot;,&quot;firstName&quot;:&quot;Arnab&quot;,&quot;middleName&quot;:&quot;&quot;,&quot;lastName&quot;:&quot;Maiti&quot;,&quot;mobileNumber&quot;:&quot;07xxxxxx&quot;,&quot;workPhoneNumber&quot;:&quot;&quot;,&quot;sourceOther&quot;:&quot;&quot;,&quot;streetArea&quot;:&quot;Kanakpur&quot;,&quot;service&quot;:&quot;OTT&quot;} </code></pre> <p>But <strong>console.log(body.firstName);</strong> is printing undefined.<br> Same thing is happening for other things.. What is the problem?</p>
[ { "answer_id": 74221729, "author": "Piemol", "author_id": 3090890, "author_profile": "https://Stackoverflow.com/users/3090890", "pm_score": 0, "selected": false, "text": "JSON.stringify()" }, { "answer_id": 74221734, "author": "Rick", "author_id": 5064575, "author_pro...
2022/10/27
[ "https://Stackoverflow.com/questions/74221698", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11821885/" ]
74,221,701
<p>I am currently updating my project and as one of the steps I am changing gradle files to use the <code>plugins { id 'xxx' }</code> way instead of the legacy <code>apply plugin 'xxx'</code> approach. I was able to migrate most of the imports to the new format, however I cannot add some plugins, as I am unable to find their gradle plugin ids.</p> <p>For example, here are my old gradle files:</p> <p>settings.gradle file</p> <pre><code>include ':app' </code></pre> <p>project's build.gradle file</p> <pre><code>buildscript { repositories { google() mavenCentral() (...) } dependencies { (...) classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.0' classpath 'com.google.android.gms:oss-licenses-plugin:0.10.5' } } (...) </code></pre> <p>module's build.gradle file</p> <pre><code>apply plugin: 'com.android.application' apply plugin: 'com.google.firebase.crashlytics' apply plugin: 'com.google.android.gms.oss-licenses-plugin' (...) </code></pre> <p>And here are partially modified new gradle files:</p> <p>settings.gradle file</p> <pre><code>pluginManagement { repositories { gradlePluginPortal() google() mavenCentral() } } dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { google() mavenCentral() } } rootProject.name = &quot;xxxx&quot; include ':app' </code></pre> <p>project's build.gradle file</p> <pre><code>plugins { id 'com.android.application' version '7.3.1' apply false id 'com.google.firebase.crashlytics' version '2.9.2' apply false // DOESN'T WORK: id 'com.google.android.gms.oss-licenses-plugin' version '0.10.5' apply false } (...) </code></pre> <p>module's build.gradle file</p> <pre><code>plugins { id 'com.android.application' id 'com.google.firebase.crashlytics' // NEED TO SET SAME ID AS IN PROJECT'S GRADLE FILE PROBABLY: id 'com.google.android.gms.oss-licenses-plugin' (...) } </code></pre> <p>Problem lays in how to get gradle plugin id for given plugin? Many plugin installation instructions use the old <code>apply plugin</code> approach and I don't want to mix both of them.</p> <p>For example in case of Crashlytics with classpath of <code>com.google.firebase:firebase-crashlytics-gradle</code>, the id is <code>com.google.firebase.crashlytics</code> - how was I supposed to know that? I found this in one of the answers on Stackoverflow, but without information about how someone knew that.</p> <p>Currently I am trying to add the oss-licenses-plugin and I am completly clueless as about how to find its gradle plugin id... Any suggestions?</p> <p>Or maybe it is not guaranteed that every plugin added with use of <code>classpath</code> can be translated to the new <code>plugins { }</code> way? In this case, how can I tell it is this situation?</p>
[ { "answer_id": 74411243, "author": "Vikram", "author_id": 2558882, "author_profile": "https://Stackoverflow.com/users/2558882", "pm_score": 3, "selected": true, "text": "properties" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74221701", "https://Stackoverflow.com", "https://Stackoverflow.com/users/536255/" ]
74,221,710
<p>I have a grid of cards for service requests. I have not been able to get all cards to simply have the same height. It works fine for the row the largest item is at but the next row height is smaller. How do I have them all the same height?</p> <p>Code:</p> <p><a href="https://play.tailwindcss.com/ACR2zkFOeb" rel="nofollow noreferrer">https://play.tailwindcss.com/ACR2zkFOeb</a></p>
[ { "answer_id": 74222420, "author": "ChenBr", "author_id": 17718587, "author_profile": "https://Stackoverflow.com/users/17718587", "pm_score": 2, "selected": true, "text": "auto-rows-max" }, { "answer_id": 74223203, "author": "MONTASIM", "author_id": 20348607, "author_...
2022/10/27
[ "https://Stackoverflow.com/questions/74221710", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6114401/" ]
74,221,711
<p>I'm converting a Symfony 3.4 site to 6.1. I created a brand new 6.1 site and am copying elements over 1-by-1. I'm using Attributes to define routes inside Controllers (no changes to routing.yaml).</p> <p>I was working on some fixes in the CustomerController, when suddenly I started getting <code>route does not exist</code> errors for the routes inside that Controller. All other routes are working perfectly. Routes within this Controller were previously working perfectly.</p> <p>I ran <code>bin/console debug:router</code> and sure enough, the routes inside the CustomerController are missing. However, the CustomerController.php file is still there, it has the correct permissions, as far as I can tell there are no syntax errors, but even if there were, I should be able to see the syntax errors instead of <code>route does not exist</code> errors, no?</p> <p>As far as I can tell, Symfony is simply ignoring the existence of the CustomerController.php file. How can that be? How can I get it to include it again?</p> <p>I have run <code>bin/console cache:clear</code> but it had no effect on this.</p> <p>EDIT: I deliberately introduced a syntax error into the CustomerController.php file and refreshed the page in the browser, sure enough Symfony showed me the syntax error. I fixed the syntax error and the error went back to <code>route does not exist</code> - even though the route does exist in the CustomerController.php file and was previously working.</p> <p>There is no further information in the log file other than the missing route exception.</p> <p>EDIT2: Here's the first route and function in the Controller:</p> <pre><code> #[Route('/sales/customer', name: 'customer')] public function index(): Response { return $this-&gt;render('customer/list.html.twig', [ 'controller_name' =&gt; 'CustomerController', 'list' =&gt; 'customer' ]); } </code></pre>
[ { "answer_id": 74222420, "author": "ChenBr", "author_id": 17718587, "author_profile": "https://Stackoverflow.com/users/17718587", "pm_score": 2, "selected": true, "text": "auto-rows-max" }, { "answer_id": 74223203, "author": "MONTASIM", "author_id": 20348607, "author_...
2022/10/27
[ "https://Stackoverflow.com/questions/74221711", "https://Stackoverflow.com", "https://Stackoverflow.com/users/206852/" ]
74,221,717
<p>I build an android app <strong>Countdown Timer</strong> using Kotlin. When I start the timer using <strong>Coroutines</strong> it throws an error as follows.</p> <p>Need your help that:</p> <ul> <li>How I can handle or implement the Countdown Timer's handler which will run on a different thread instead of the main thread ... <strong>OR</strong> ... How to implement the timer using kotlin coroutines?</li> </ul> <p><strong>Error Text:</strong></p> <pre><code>java.lang.RuntimeException: Can't create handler inside thread Thread[DefaultDispatcher-worker-1,5,main] that has not called Looper.prepare() </code></pre> <p><strong>Code:</strong></p> <pre><code>override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) btnStartPause.setOnClickListener { if (isRunning) { pauseTimer() } else { val time = edtTxtTimer.text.toString().trim() timeInMilliSeconds = time.toLong() * 60000L // 1m = 60,000ms CoroutineScope(Dispatchers.Default).launch { startTimer(timeInMilliSeconds) } } } } //////////////////////////////////////////////////// //////////////////////////////////////////////////// private fun startTimer(time_in_milli_second: Long) { countdown_timer = object : CountDownTimer(time_in_milli_second, 1000) { override fun onTick(millisUntilFinished: Long) { timeInMilliSeconds = millisUntilFinished updateUI() } override fun onFinish() { btnStartPause.text = &quot;Start&quot; loadConfeti() } } countdown_timer.start() isRunning = true btnStartPause.text = &quot;Pause&quot; btnReset.visibility = View.GONE } </code></pre>
[ { "answer_id": 74222997, "author": "Tenfour04", "author_id": 506796, "author_profile": "https://Stackoverflow.com/users/506796", "pm_score": 2, "selected": false, "text": "Dispatchers.Main" }, { "answer_id": 74288847, "author": "Mehar Ahmer", "author_id": 19436650, "a...
2022/10/27
[ "https://Stackoverflow.com/questions/74221717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19436650/" ]
74,221,738
<pre><code>## KAPLAN MEIER fit.obj&lt;-survfit(Surv(duree_suivi,k_oesogastr) ~ baria_t, data = pts_raw_matched) library(survminer) </code></pre> <p>I am comparing two curves. But the number of events is so low that you can't see the curves very well. I want to truncate the y-axis (between 0.9 and 1 for example) to see the evolution of the two curves.</p> <pre><code> n events median 0.95LCL 0.95UCL baria_t=Sleeve 114221 61 NA NA NA baria_t=Bypass 114221 58 NA NA NA ggsurvplot(fit.obj, conf.int = T, risk.table =&quot;absolute&quot;, tables.theme = theme_cleantable()) </code></pre> <p>Here are the survival curves:</p> <p><a href="https://i.stack.imgur.com/9cPZM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9cPZM.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74222997, "author": "Tenfour04", "author_id": 506796, "author_profile": "https://Stackoverflow.com/users/506796", "pm_score": 2, "selected": false, "text": "Dispatchers.Main" }, { "answer_id": 74288847, "author": "Mehar Ahmer", "author_id": 19436650, "a...
2022/10/27
[ "https://Stackoverflow.com/questions/74221738", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11652655/" ]
74,221,757
<p>I am unable to read this type of excel file from pandas in python.</p> <p><a href="https://i.stack.imgur.com/sgn6p.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sgn6p.png" alt="enter image description here" /></a></p> <p><a href="https://i.stack.imgur.com/pkzjR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pkzjR.png" alt="This is the excel file" /></a></p>
[ { "answer_id": 74222997, "author": "Tenfour04", "author_id": 506796, "author_profile": "https://Stackoverflow.com/users/506796", "pm_score": 2, "selected": false, "text": "Dispatchers.Main" }, { "answer_id": 74288847, "author": "Mehar Ahmer", "author_id": 19436650, "a...
2022/10/27
[ "https://Stackoverflow.com/questions/74221757", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20279353/" ]
74,221,769
<p>I am trying to replace a list of filenames inside a directory. For example</p> <pre><code>cd /home/towers ls c3_slo_live_ox_dns_m2m_pcg.yaml c3_slo_live_ox_dns_service_pcg_physnet4.yaml c3_slo_live_ox_dns_service_pcg_physnet2.yaml to cd /home/towers ls c3_dsd_live_ox_dns_m2m_pcg.yaml c3_dsd_live_ox_dns_service_pcg_physnet4.yaml c3_dsd_live_ox_dns_service_pcg_physnet2.yaml Which is the best way? can we use sed? Any example that I should try? </code></pre>
[ { "answer_id": 74222997, "author": "Tenfour04", "author_id": 506796, "author_profile": "https://Stackoverflow.com/users/506796", "pm_score": 2, "selected": false, "text": "Dispatchers.Main" }, { "answer_id": 74288847, "author": "Mehar Ahmer", "author_id": 19436650, "a...
2022/10/27
[ "https://Stackoverflow.com/questions/74221769", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13334309/" ]
74,221,780
<p>I created two remote virtual repos: <a href="http://download.rockylinux.org/pub/rocky/9/AppStream/x86_64/os/" rel="nofollow noreferrer">http://download.rockylinux.org/pub/rocky/9/AppStream/x86_64/os/</a> <a href="http://download.rockylinux.org/pub/rocky/9/BaseOS/x86_64/os/" rel="nofollow noreferrer">http://download.rockylinux.org/pub/rocky/9/BaseOS/x86_64/os/</a></p> <p>then I created virtual repo with both remote. And it works, but looking for packets only in the first in the list remote repo of that virtual repo. Is it something we need to fix/configure on JFROG side or dnf/yum side?</p> <p>Create virtual repo with two remotes. Expecting to search packages from both remotes</p>
[ { "answer_id": 74222997, "author": "Tenfour04", "author_id": 506796, "author_profile": "https://Stackoverflow.com/users/506796", "pm_score": 2, "selected": false, "text": "Dispatchers.Main" }, { "answer_id": 74288847, "author": "Mehar Ahmer", "author_id": 19436650, "a...
2022/10/27
[ "https://Stackoverflow.com/questions/74221780", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8130227/" ]
74,221,791
<p>I want to use <code>sync()</code> for table <code>client_package</code> except some values/fields.</p> <p>It's because I'm displaying <code>checkboxes</code> with <code>client</code> names, that I want to add to a <code>package</code>. So if User has specific <code>permission</code>, he could see specific <code>clients</code>, and it's done:</p> <pre><code>&lt;div class=&quot;mb-6&quot;&gt; &lt;label for=&quot;package_clients&quot; class=&quot;block mb-2 text-sm font-medium flex&quot;&gt;Bundle Clients:&lt;/label&gt; &lt;div class=&quot;border border-gray-200 rounded-lg&quot;&gt; &lt;div class=&quot;p-4 overflow-auto min-h-40 max-h-96&quot;&gt; @foreach($clients as $client) &lt;p&gt;&lt;input type=&quot;checkbox&quot; name=&quot;package_clients[]&quot; id=&quot;client-{{$client-&gt;id}}&quot; value=&quot;{{ $client-&gt;id }}&quot; @foreach($package_clients as $package_client) @if($client-&gt;id == $package_client-&gt;id) checked @else @endif @endforeach /&gt; &lt;label for=&quot;bundle-{{$client-&gt;id}}&quot;&gt; {{ $client-&gt;name }} &lt;/label&gt; &lt;/p&gt; @endforeach &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>But after <code>syncing</code> the list of <code>clients</code> assigned to a <code>package</code> I got <code>detached</code> clients, that are not in the list (the remaining ones from the DataBase).</p> <p>I want to avoid that, but in my case I can't use <code>attach()</code> and <code>detach()</code> separately(depending on situation), because User could assign and misallocate multiple <code>clients</code> at once.</p> <p>I want to pass f.e. <code>array</code> of Clients, that could not be <code>detached</code>. Is that possible?</p> <p>My way to syncing Clients to Package:</p> <pre><code>$package-&gt;clients()-&gt;sync($clients); </code></pre> <p><code>$clients</code> is an array of <code>id's</code>.</p> <p>Or there's a option of doing the <code>sync()</code> only on that Collection of <code>clients</code> not in whole DB?</p>
[ { "answer_id": 74222997, "author": "Tenfour04", "author_id": 506796, "author_profile": "https://Stackoverflow.com/users/506796", "pm_score": 2, "selected": false, "text": "Dispatchers.Main" }, { "answer_id": 74288847, "author": "Mehar Ahmer", "author_id": 19436650, "a...
2022/10/27
[ "https://Stackoverflow.com/questions/74221791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10889851/" ]
74,221,793
<p>I searched the internet for 2 days to find the answer and couldn't.</p> <p>Basically I have this as a problem : &quot;The login is composed of the first letter of the first name and the first 7 letters of the name (in lowercase) followed by two numbers.&quot;</p> <p>My problem relies in the last 4 words &quot;followed by two numbers&quot;. The first part I have done it correctly and it validates it, but i cant seem to find the answer to the problem specified above.</p> <p>I tried doing something like this.</p> <pre><code> CONSTRAINT ck_user_login CHECK (login LIKE SUBSTR(prenom,1, 1) || LOWER(SUBSTR(nom, 0, 7)) || '%[0-9]%') </code></pre> <p>But that does not seem to work.</p> <p>All help will be appreciated. Thank you in advance.</p>
[ { "answer_id": 74221961, "author": "Olivier Jacot-Descombes", "author_id": 880990, "author_profile": "https://Stackoverflow.com/users/880990", "pm_score": 0, "selected": false, "text": "'[0-9][0-9]'" }, { "answer_id": 74222030, "author": "Littlefoot", "author_id": 9097906...
2022/10/27
[ "https://Stackoverflow.com/questions/74221793", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20348662/" ]
74,221,803
<p>Given the following CSV:</p> <pre><code>ID,Title,Created By,Created On,Estimate,Forecast,Priority,References,Section,Section Depth,Section Description,Suite,Suite ID,Type,Updated By,Updated On C28045,test1,dsa,10/27/2022 1:56 AM,,,Highest,,primary,0,,Master,S378,Automated,test,10/27/2022 4:33 AM C28060,test32,dsa,10/27/2022 4:34 AM,,,Medium,,primary,0,,Master,S378,Automated,test,10/27/2022 4:34 AM C28062,test5,dsa,10/27/2022 4:34 AM,,,Medium,,primary,0,,Master,S378,Automated,test,10/27/2022 4:34 AM C28059,test6,dsa,10/27/2022 4:06 AM,,,Medium,,sec,0,,Master,S378,Automated,test,10/27/2022 4:33 AM C28061,test643,dsa,10/27/2022 4:34 AM,,,Medium,,sec,0,,Master,S378,Automated,test,10/27/2022 4:34 AM C28063,tes4352,dsa,10/27/2022 4:34 AM,,,Medium,,sec,0,,Master,S378,Automated,test,10/27/2022 4:34 AM </code></pre> <p>Using pandas I want to return the ID, for a given &quot;Section&quot; and &quot;Title&quot;</p> <pre><code>data = pd.read_csv(csvPath) data.query('Section = primary and Title = test32', inplace=True) print(data) </code></pre> <p>Raises:</p> <pre><code> File &quot;&lt;unknown&gt;&quot;, line 1 Section =primary and Title =test32 ^^^^^^^^^^^^^^^^ SyntaxError: Python keyword not valid identifier in numexpr query </code></pre>
[ { "answer_id": 74221912, "author": "Daniel Schneider", "author_id": 8821969, "author_profile": "https://Stackoverflow.com/users/8821969", "pm_score": 3, "selected": true, "text": "# using query, filter for Section == 'primary' and Title == 'test32'\ndata.query(\"Section == 'primary' and ...
2022/10/27
[ "https://Stackoverflow.com/questions/74221803", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20290234/" ]
74,221,841
<p>I have this variable:</p> <pre><code>let obj = { &quot;aff_link&quot;: &quot;https://event.2performant.com/events/click?ad_type=product_store&amp;unique=83b281931&amp;aff_code=d79aaed64&amp;campaign_unique=2e49eab4f&quot;, &quot;availability&quot;: true, &quot;brand&quot;: &quot;Casio&quot;, &quot;date_add&quot;: 1666792631, &quot;date_upd&quot;: 1666792631, &quot;id&quot;: 78594, &quot;price&quot;: 159.24, &quot;product_type&quot;: &quot;Ceasuri de mana&quot;, &quot;title&quot;: &quot;Ceas Casio CLASSIC LTP-1303L-7BVEF&quot;, &quot;update_history&quot;: [ { &quot;id_feed&quot;: 108, &quot;date_upd&quot;: 1666794541, &quot;address&quot; : [ { &quot;present&quot; : &quot;Dhanmondi 15&quot;, &quot;permanent&quot; : &quot;Gulshan 2&quot; } ] } ], &quot;vgt_id&quot;: 0, &quot;originalIndex&quot;: 0 }; </code></pre> <p>Now, I have an array called:</p> <pre><code>let arr = []; </code></pre> <p>Now Using below function I loop through all the property and store it to variable <code>arr</code>.</p> <pre><code>function eachRecursive(obj) { for (var k in obj) { if( k !== 'additional_image_link' ) { if (typeof obj[k] == &quot;object&quot; &amp;&amp; obj[k] !== null) { eachRecursive(obj[k]); } else { arr.push({ [k] : obj[k] }) } } } } </code></pre> <p>Now, usinge <code>console.log( arr )</code> I got this output:</p> <pre><code>[ { aff_link: 'https://event.2performant.com/events/click?ad_type=product_store&amp;unique=83b281931&amp;aff_code=d79aaed64&amp;campaign_unique=2e49eab4f' }, { availability: true }, { brand: 'Casio' }, { date_add: 1666792631 }, { date_upd: 1666792631 }, { id: 78594 }, { price: 159.24 }, { product_type: 'Ceasuri de mana' }, { title: 'Ceas Casio CLASSIC LTP-1303L-7BVEF' }, { id_feed: 108 }, { date_upd: 1666794541 }, { present: 'Dhanmondi 15' }, { permanent: 'Gulshan 2' }, { vgt_id: 0 }, { originalIndex: 0 } ] </code></pre> <p>if you look at it you can see the there is no <strong>key</strong> called <strong>update_history</strong>, right ? I want that above output should contain <strong>update_history</strong> as a key and the value should contain <strong>id_feed</strong>, <strong>date_upd</strong>, <strong>present</strong>, <strong>permanent</strong> with their corresponding value.</p> <p>Can you help me please?</p>
[ { "answer_id": 74221955, "author": "Nick", "author_id": 9473764, "author_profile": "https://Stackoverflow.com/users/9473764", "pm_score": 3, "selected": true, "text": "update_history" }, { "answer_id": 74222158, "author": "Rocky Sims", "author_id": 4123400, "author_pr...
2022/10/27
[ "https://Stackoverflow.com/questions/74221841", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1091439/" ]
74,221,842
<p>I have a Config class. I would like it to have several methods, which depends on another variable of the class. This way I would only have to change one variable in the config class and then it would function differently.</p> <p>I tried the following. When creating an instance I can access other_param, but the objective function is lost.</p> <pre><code>class Config: def __init__(self): self.task = 'Task1' if self.task=='Task1': self.other_param = 1 def objective(self,probs): return probs[0] if self.task=='Task2': self.other_param = 2 def objective(self,probs): return probs[1] </code></pre> <p>In fact I can get a solution by reversing the logic, i.e. defining a method and having an if statement within that. But I want several methods for each if branch... and I don't want to have all these methods full of if statements. The code would just be more readable if all the methods belonging to the same if branch would be in the same place.</p>
[ { "answer_id": 74221955, "author": "Nick", "author_id": 9473764, "author_profile": "https://Stackoverflow.com/users/9473764", "pm_score": 3, "selected": true, "text": "update_history" }, { "answer_id": 74222158, "author": "Rocky Sims", "author_id": 4123400, "author_pr...
2022/10/27
[ "https://Stackoverflow.com/questions/74221842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6346533/" ]
74,221,844
<pre><code>void _set() { late List&lt;int&gt; _babus = []; for (int i = 0; i &lt; 31; i++) { _babus.add(_consumptionData['Energies'][0]['EnergyInfo']['Last30DayData'] .values .toList()[i] ?? 0); } print(_babus); } </code></pre> <p>I need to assign 0 if the value is empty but I'am gettin Invalid value: Valid value range is empty: 0</p> <pre><code>void _set() { late List&lt;int&gt; _babus = []; for (int i = 0; i &lt; 31; i++) { if (_consumptionData['Energies'][0]['EnergyInfo']['Last30DayData'] != null) { _babus.add(_consumptionData['Energies'][0]['EnergyInfo'] ['Last30DayData'] .values .toList()[i]); } else { (_babus.add(0)); } } print(_babus); } </code></pre>
[ { "answer_id": 74221955, "author": "Nick", "author_id": 9473764, "author_profile": "https://Stackoverflow.com/users/9473764", "pm_score": 3, "selected": true, "text": "update_history" }, { "answer_id": 74222158, "author": "Rocky Sims", "author_id": 4123400, "author_pr...
2022/10/27
[ "https://Stackoverflow.com/questions/74221844", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19794761/" ]
74,221,871
<p>I want to programtically kill an EMR streaming task. If I kill it from EMR UI or boto client, it disappears in EMR, but it is still active in the Hadoop cluster (see <a href="https://medium.com/everything-full-stack/emr-hadoop-dissonance-330f322a1d40" rel="nofollow noreferrer">this article</a>). Only if I go through the Hadoop resource manager and kill it from there, the job is terminated. How can do the same programatically?</p>
[ { "answer_id": 74221920, "author": "maxime G", "author_id": 9729847, "author_profile": "https://Stackoverflow.com/users/9729847", "pm_score": 1, "selected": false, "text": "ssh" }, { "answer_id": 74410598, "author": "Amir Kost", "author_id": 1769353, "author_profile":...
2022/10/27
[ "https://Stackoverflow.com/questions/74221871", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1769353/" ]
74,221,948
<p>How can I obtain a list of all branches that introduce changes to a certain file?</p> <p>Context: When starting to edit a certain file it might be interesting to see what unmerged changes exist on the same file.</p> <p>We can assume that all branches that are already merged are also deleted. However, if we can filter on branches that are ahead of [main] it would be a plus.</p>
[ { "answer_id": 74222403, "author": "AmShaegar", "author_id": 1823593, "author_profile": "https://Stackoverflow.com/users/1823593", "pm_score": 1, "selected": false, "text": "$ git branch --no-merged | xargs -I branch bash -c \"git diff --stat master...branch | grep -q rails/apps/main/Gem...
2022/10/27
[ "https://Stackoverflow.com/questions/74221948", "https://Stackoverflow.com", "https://Stackoverflow.com/users/993718/" ]
74,221,984
<p>In my website, I got dates and wanted to group by week number. It seems SQL puts the Sunday into the next week number.</p> <pre><code>SELECT [SelectedDate], (DATEPART(Week, [SelectedDate]) - 1) AS [Week] FROM [dbo].[EmployeeTimeSheetModel] </code></pre> <p>Output:</p> <pre><code>SelectedDate Week ----------------------- 2022-10-01 39 ==&gt; Correct. It is the last SATURDAY of the month week 39 2022-10-02 40 ==&gt; Wrong. It is SUNDAY and supposed to be 39 2022-10-03 40 ==&gt; Correct. It is MONDAY and the first day of week 40 2022-10-08 40 ==&gt; Correct. It is SATURDAY and week 40 2022-10-09 41 ==&gt; Wrong. It is SUNDAY and supposed to be 40 2022-10-10 41 ==&gt; Correct. It is MONDAY and the first day of week 41 </code></pre> <p>SQL calculates the week number. I am trying to figure out how to fix this issue, but I need to figure out where to start.</p> <p><strong>UPDATE</strong> I added a CASE Statement to solve my problem, but feel that it is wrong to solve the issue. I am sure there is a better way to do it.</p> <pre><code> SELECT [SelectedDate],DATENAME(WEEKDAY,[SelectedDate]), CASE WHEN DATENAME(WEEKDAY,[SelectedDate]) ='Sunday' THEN (DATEPART(Week,[SelectedDate])-2) ELSE (DATEPART(Week,[SelectedDate])-1) END AS [Week] FROM [dbo].[EmployeeTimeSheetModel] </code></pre>
[ { "answer_id": 74222831, "author": "Stigi", "author_id": 19950627, "author_profile": "https://Stackoverflow.com/users/19950627", "pm_score": 3, "selected": true, "text": "Select datepart(iso_week,'2022-10-09');\n" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74221984", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7520496/" ]
74,222,024
<p>How to check the value of <code> &quot;newOk&quot;:(true/false)</code>, which comes in the response body from the post request?</p> <pre><code>httpAddr = 'https://&lt;link&gt;' client = WebClient() client.Headers.Add(&quot;Content-Type&quot;,&quot;application/json&quot;) client.Headers.Add(&quot;Authorization&quot;,&quot;Basic &lt;code&gt;&quot;) client.Encoding = System.Text.Encoding.UTF8; </code></pre> <pre><code>webRequest = WebRequest.Create(httpAddr); reply = client.UploadString(httpAddr, body.ToString()) </code></pre>
[ { "answer_id": 74222831, "author": "Stigi", "author_id": 19950627, "author_profile": "https://Stackoverflow.com/users/19950627", "pm_score": 3, "selected": true, "text": "Select datepart(iso_week,'2022-10-09');\n" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74222024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20348828/" ]
74,222,047
<p>Suppose that I have a list:</p> <pre><code>List&lt;String&gt; dest = Arrays.asList( &quot;abc abd 2000&quot;, &quot;idf owe 1200&quot;, &quot;jks ldg 789&quot;, &quot;ccc hhh 2000&quot;, &quot;www uuu 1000&quot; ); </code></pre> <p>And I'm trying to get the number at the end of every string. The given list has only integers in it, but I'm writing the regex for doubles too:<code>(\\d+\\.?\\d+)</code>. In Java 1.8, I wrote the following code:</p> <pre><code>ArrayList&lt;String&gt; mylist = new ArrayList&lt;&gt;( dest.stream() .filter(Pattern.compile(&quot;\\D+\\s\\D+\\s(\\d+\\.?\\d+)&quot;).asPredicate()) .collect(Collectors.toList()) ); </code></pre> <p>What I'm trying to do is - get the <code>(\\d+\\.?\\d+)</code> group from each found string, how can I do it?</p> <p>I was thinking about applying a <code>Matcher</code> to each element of the list, but I'm not sure about how to implement it.</p>
[ { "answer_id": 74222157, "author": "YCF_L", "author_id": 5558072, "author_profile": "https://Stackoverflow.com/users/5558072", "pm_score": 3, "selected": true, "text": "List<String> response = dest.stream()\n .map(String::trim)\n .map(s -> s.split(\"\\\\s+\"))\n .map...
2022/10/27
[ "https://Stackoverflow.com/questions/74222047", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13228003/" ]
74,222,050
<p>given the following array:</p> <pre><code>[['team1','dep1','tkt1'], ['team2','dep1','tkt2'], ['team2','dep3','tkt75'], ['team2','dep1','tkt10']] </code></pre> <p>(where the internal array will always have team, dependency, tickets)</p> <p>• Generate a function that, having the above array as input parameter, generates the following output:</p> <pre><code>[ { &quot;dependencies&quot;: [ { &quot;name&quot;: &quot;dep1&quot;, &quot;tickets&quot;: [ { &quot;name&quot;: &quot;tkt1&quot; } ] } ], &quot;name&quot;: &quot;team1&quot; }, { &quot;dependencies&quot;: [ { &quot;name&quot;: &quot;dep1&quot;, &quot;tickets&quot;: [ { &quot;name&quot;: &quot;tkt2&quot; }, { &quot;name&quot;: &quot;tkt10&quot; } ] }, { &quot;name&quot;: &quot;dep3&quot;, &quot;tickets&quot;: [ { &quot;name&quot;: &quot;tkt75&quot; } ] } ], &quot;name&quot;: &quot;team2&quot; } ] </code></pre>
[ { "answer_id": 74222145, "author": "Abito Prakash", "author_id": 10069313, "author_profile": "https://Stackoverflow.com/users/10069313", "pm_score": 1, "selected": false, "text": "const input = [\n [\"team1\", \"dep1\", \"tkt1\"],\n [\"team2\", \"dep1\", \"tkt2\"],\n [\"team2\", \"dep...
2022/10/27
[ "https://Stackoverflow.com/questions/74222050", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6806210/" ]
74,222,089
<p>I'm currently trying to pass a ref to get the value of the input (base-input component) on submit. You will find below the two components. With the console.log in handleSubmit, email is always undefined.</p> <p>Thanks in advance for your help.</p> <p>Parent component</p> <pre><code>&lt;template&gt; &lt;form @submit.prevent=&quot;handleSubmit&quot;&gt; &lt;div class=&quot;flex flex-col mt-10&quot;&gt; &lt;form-label forInput=&quot;email&quot; label=&quot;Email Address&quot; /&gt; &lt;base-input type=&quot;email&quot; name=&quot;email&quot; ref=&quot;email&quot; /&gt; &lt;/div&gt; &lt;/form&gt; &lt;/template&gt; &lt;script&gt; import BaseInput from &quot;../UI/BaseInput.vue&quot;; export default { components: { BaseInput, }, methods: { handleSubmit() { const email = this.$refs.email.value; console.log(email); }, }, }; &lt;/script&gt; </code></pre> <p>Child Input component</p> <pre><code>&lt;template&gt; &lt;input :type=&quot;type&quot; :name=&quot;name&quot; :ref=&quot;name&quot; /&gt; &lt;/template&gt; &lt;script&gt; export default { props: [&quot;type&quot;, &quot;name&quot;], }; &lt;/script&gt; </code></pre>
[ { "answer_id": 74222145, "author": "Abito Prakash", "author_id": 10069313, "author_profile": "https://Stackoverflow.com/users/10069313", "pm_score": 1, "selected": false, "text": "const input = [\n [\"team1\", \"dep1\", \"tkt1\"],\n [\"team2\", \"dep1\", \"tkt2\"],\n [\"team2\", \"dep...
2022/10/27
[ "https://Stackoverflow.com/questions/74222089", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20025134/" ]
74,222,101
<p>Currently I am developing an eCommerce platform with Node and React where the user has to fill in a form their shipment information + email and after they submit that information they receive the shipping cost calculation. The thing is I also want to display the submitted information on the webpage in case the user misspelled something and needs to edit the information. I will not use dangerouslySetInnerHtml for this I was more thinking of just rendering the state values of the input. Can I do that or am I enabling an XSS attack by displaying the users input on to the webpage?</p> <p>From what I understand the values of the state variable will not be rendered as HTML and instead as a string. Therefore, I should be fine doing this?</p>
[ { "answer_id": 74222145, "author": "Abito Prakash", "author_id": 10069313, "author_profile": "https://Stackoverflow.com/users/10069313", "pm_score": 1, "selected": false, "text": "const input = [\n [\"team1\", \"dep1\", \"tkt1\"],\n [\"team2\", \"dep1\", \"tkt2\"],\n [\"team2\", \"dep...
2022/10/27
[ "https://Stackoverflow.com/questions/74222101", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20348718/" ]
74,222,121
<p>I have the following scenario that I need to put in place: A user from SF must generate a contract with tables for a customer. As soon as the contract is generated, the user will handle the contract in a tablet to the customer, so he can sign it off in person.</p> <p>To implement this I'm using DocuSign Gen to generate a template, because this particular template needs to have a table with multiple rows. So:</p> <ol> <li>I declared all the <code>Salesforce Fields</code> I'm using on the contract .</li> <li>I placed all the anchor texts on the MS Word file.</li> <li>I declared all the <code>DocuSign Fields</code> (i.e. Signature, Name, Date Signed).</li> <li>I also placed them all their anchor texts at the bottom of the MS Word file.</li> <li>Finally, I selected a DocuSign Envelope (check the description below) template to streamline the signature delivery.</li> </ol> <p>For the DocuSign Envelope, I simply created a template, but I didn't select any document, since that was going to be handle by the <code>DocuSign Gen template</code>. I defined the recipients (In Person Signer), and for the sending experience I selected the option <code>Send Now: Skips all controls and sends the envelope immediately.</code></p> <p>So, I was expecting that after clicking on the DocuSign Gen template button, the contract will be sent to the user so, he can handle the contract to the customer, <strong>to sign it directly</strong>. Instead, after the contract is sent, and the user handled the control to the customer, they need to place <strong>AGAIN</strong> the <code>DocuSign Fields</code> (i.e. Signature, date, name) on the contract before signing it off.</p> <p>How can I avoid that? I want neither the user nor the customer to place the fields again, since that's already defined on the template created on DocuSign Gen already.</p>
[ { "answer_id": 74226805, "author": "Inbar Gazit", "author_id": 3255871, "author_profile": "https://Stackoverflow.com/users/3255871", "pm_score": 2, "selected": true, "text": "\\ObjectName_FieldName_{r}\\" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74222121", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5535262/" ]
74,222,141
<p>I'm using Base R 4.2.1 and have a strange problem with lagging a column My dataframe has two columns, one for time and the other for the yield of a bond</p> <pre><code>df_bond &lt;- data. Frame(t = seq(0, 10, 1), y_t = seq(.1, 0, -.01) ) &gt; df_bond t y_t 1 0 0.10 2 1 0.09 3 2 0.08 4 3 0.07 5 4 0.06 6 5 0.05 7 6 0.04 8 7 0.03 9 8 0.02 10 9 0.01 11 10 0.00 </code></pre> <p>I then add a column for price and it works like a charm:</p> <pre><code>&gt; df_bond$p_t &lt;- 100 / (1 + df_bond$y_t)^(10 - df_bond$t) &gt; df_bond t y_t p_t 1 0 0.10 38.55433 2 1 0.09 46.04278 3 2 0.08 54.02689 4 3 0.07 62.27497 5 4 0.06 70.49605 6 5 0.05 78.35262 7 6 0.04 85.48042 8 7 0.03 91.51417 9 8 0.02 96.11688 10 9 0.01 99.00990 11 10 0.00 100.00000 </code></pre> <p>But if I now add a column for return, I get something weird</p> <pre><code>&gt; df_bond$r_prior_yr &lt;- df_bond$p_t / lag(df_bond$p_t, 1) &gt; df_bond t y_t p_t r_prior_yr 1 0 0.10 38.55433 1 2 1 0.09 46.04278 1 3 2 0.08 54.02689 1 4 3 0.07 62.27497 1 5 4 0.06 70.49605 1 6 5 0.05 78.35262 1 7 6 0.04 85.48042 1 8 7 0.03 91.51417 1 9 8 0.02 96.11688 1 10 9 0.01 99.00990 1 11 10 0.00 100.00000 1 </code></pre> <p>Doing the division without the assignment shows that it is picking up a time series attribute, but I can't for the life of me explain why the ratio is always 1.</p> <pre><code>&gt; df_bond$p_t / lag(df_bond$p_t, 1) [1] 1 1 1 1 1 1 1 1 1 1 1 attr(,&quot;tsp&quot;) [1] 0 10 1 </code></pre> <p>Any assistance is greatly appreciated.</p> <p>Sincerely and with many thanks in advance</p> <p>Thomas Philips</p>
[ { "answer_id": 74222229, "author": "Allan Cameron", "author_id": 12500315, "author_profile": "https://Stackoverflow.com/users/12500315", "pm_score": 2, "selected": false, "text": "dplyr::lag" }, { "answer_id": 74222231, "author": "Seth", "author_id": 19316600, "author...
2022/10/27
[ "https://Stackoverflow.com/questions/74222141", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4462690/" ]
74,222,155
<p>I don't really know how to explain the problem. I do have a scanner imported after the package. I'm not sure if you can stack methods, and if you can I'm definitely doing it wrong.</p> <pre class="lang-java prettyprint-override"><code>Scanner console = new Scanner(System.in); System.out.print(&quot;Enter your name: &quot;); String name = console.next(); name.trim(); name.toUpperCase(name.substring(name.charAt(name.indexOf(&quot; &quot;)))); System.out.println(&quot;Your name is: &quot; + name); </code></pre>
[ { "answer_id": 74222342, "author": "mmartinez04", "author_id": 20131874, "author_profile": "https://Stackoverflow.com/users/20131874", "pm_score": 1, "selected": true, "text": "indexOf(\" \")" }, { "answer_id": 74222477, "author": "oleg.cherednik", "author_id": 3461397, ...
2022/10/27
[ "https://Stackoverflow.com/questions/74222155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20348970/" ]
74,222,174
<p>I have an entity like</p> <pre><code>@Getter @Setter public class MyObject { private String name; private String extension; } </code></pre> <p>I need to generate (for a web service) following JSON:</p> <pre><code>{ &quot;name&quot; : &quot;Hein Blöd&quot; &quot;extension:anybill&quot; : &quot;blah blah&quot; } </code></pre> <p>To generate the JSON I use <code>javax.ws.rs.client.Entity.json(myObject)</code>. The problem is the &quot;:&quot; in the second attribute (because &quot;:&quot; is an invalid character for variable names). Is there any annotation to specify the name of attribute key? Or can I rename the generated JSON attribute in any other way?</p>
[ { "answer_id": 74222335, "author": "oleg.cherednik", "author_id": 3461397, "author_profile": "https://Stackoverflow.com/users/3461397", "pm_score": 0, "selected": false, "text": "import com.fasterxml.jackson.annotation.JsonProperty;\nimport com.fasterxml.jackson.databind.ObjectMapper;\n\...
2022/10/27
[ "https://Stackoverflow.com/questions/74222174", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1465758/" ]
74,222,190
<p>I am using next js and material ui to build a demo dapp for learning. I have metamask installed and so far I can only setup a &quot;connect to wallet&quot; button.</p> <p>I am stuck at a point where I have to import Web3 constructor. Here is how my code looks like:</p> <p><a href="https://i.stack.imgur.com/TH6i6.png" rel="nofollow noreferrer">Screenshot of my package json</a></p> <p>I have downloaded some useless stuff too as devDs because I thought they would solve the problem but they didn't.</p> <p>This is the error that I am getting:</p> <p><a href="https://i.stack.imgur.com/0KvnW.png" rel="nofollow noreferrer">The error</a></p> <p>This is the entire error:</p> <blockquote> <p>Server Error TypeError: Cannot set property Request of # which has only a getter</p> <p>This error happened while generating the page. Any console logs will be displayed in the terminal window. Call Stack file:///C:/projects/BC/vending-machine/node_modules/abortcontroller-polyfill/dist/polyfill-patch-fetch.js (529:18) file:///C:/projects/BC/vending-machine/node_modules/abortcontroller-polyfill/dist/polyfill-patch-fetch.js (542:5) file:///C:/projects/BC/vending-machine/node_modules/abortcontroller-polyfill/dist/polyfill-patch-fetch.js (3:3) Object. file:///C:/projects/BC/vending-machine/node_modules/abortcontroller-polyfill/dist/polyfill-patch-fetch.js (4:3) Module._compile node:internal/modules/cjs/loader (1155:14) Object.Module._extensions..js node:internal/modules/cjs/loader (1209:10) Module.load node:internal/modules/cjs/loader (1033:32) Function.Module._load node:internal/modules/cjs/loader (868:12) Module.require node:internal/modules/cjs/loader (1057:19) require node:internal/modules/cjs/helpers (103:18)</p> </blockquote> <p>Please I have tried everything. I hope someone has the answer. If you need anymore information or screenshots or code or anything tell me. As far as using Web3 goes, I am only simply trying to import it. I can't even import the damn thing without getting these errors.</p> <p>This is where I am importing web3</p> <pre class="lang-js prettyprint-override"><code>import * as React from &quot;react&quot;; import AppBar from &quot;@mui/material/AppBar&quot;; import Box from &quot;@mui/material/Box&quot;; import Toolbar from &quot;@mui/material/Toolbar&quot;; import Typography from &quot;@mui/material/Typography&quot;; import Button from &quot;@mui/material/Button&quot;; import useStatus from &quot;../custom-hooks/useStatus&quot;; import { Alert } from &quot;@mui/material&quot;; import { useState } from &quot;react&quot;; import Web3 from &quot;web3&quot;; export default function ButtonAppBar() { const [error, setError] = useState(&quot;&quot;); const { connected } = useStatus(setError); const connectClickHandler = async () =&gt; { if (!connected &amp;&amp; typeof window.ethereum !== &quot;undefined&quot;) { ethereum .request({ method: &quot;eth_requestAccounts&quot; }) .then(() =&gt; { // }) .catch((err) =&gt; { setError(err.message); }); } }; return ( &lt;Box sx={{ flexGrow: 1 }}&gt; &lt;AppBar position=&quot;static&quot;&gt; &lt;Toolbar&gt; &lt;Typography variant=&quot;h6&quot; component=&quot;div&quot; sx={{ flexGrow: 1 }}&gt; Vending Machine &lt;/Typography&gt; &lt;Button variant={connected ? &quot;disabled&quot; : &quot;inherit&quot;} onClick={connectClickHandler} &gt; connect wallet &lt;/Button&gt; &lt;/Toolbar&gt; &lt;/AppBar&gt; {error &amp;&amp; &lt;Alert severity=&quot;error&quot;&gt;{error}&lt;/Alert&gt;} &lt;/Box&gt; ); } </code></pre>
[ { "answer_id": 74237449, "author": "Andre Miras", "author_id": 185510, "author_profile": "https://Stackoverflow.com/users/185510", "pm_score": 2, "selected": false, "text": "npm install web3@1.7.4\n" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74222190", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18999644/" ]
74,222,199
<p>Given a bunch of ( not sorted ) entities</p> <pre><code>const entities = [ { id: &quot;person-1&quot;, type: &quot;person&quot;, fields: { age: 34 }}, { id: &quot;car-2&quot;, type: &quot;car&quot;, fields: { manufacturer: &quot;bar&quot; }}, { id: &quot;house-2&quot;, type: &quot;house&quot;, fields: { constructionYear: 2010 }}, { id: &quot;person-4&quot;, type: &quot;person&quot;, fields: { age: 71 }}, { id: &quot;person-2&quot;, type: &quot;person&quot;, fields: { age: 57 }}, { id: &quot;house-1&quot;, type: &quot;house&quot;, fields: { constructionYear: 1968 }}, { id: &quot;car-1&quot;, type: &quot;car&quot;, fields: { manufacturer: &quot;foo&quot; }}, { id: &quot;person-3&quot;, type: &quot;person&quot;, fields: { age: 42 }}, ]; </code></pre> <p>and a bunch of &quot;sources&quot; with an optional sort object describing the sort index and a &quot;isLessThan&quot; compare function as a string</p> <pre><code>const sources = [ { type: &quot;person&quot;, sort: { index: 1, isLessThanFunctionAsString: &quot;(left, right) =&gt; left.fields.age &lt; right.fields.age&quot; }}, { type: &quot;car&quot; }, { type: &quot;house&quot;, sort: { index: 0, isLessThanFunctionAsString: &quot;(left, right) =&gt; left.fields.constructionYear &lt; right.fields.constructionYear&quot; }}, ]; </code></pre> <p><em>Each source describes how to deal with entities of the given type. The source for &quot;person&quot; defines how entities of type &quot;person&quot; should be sorted.</em></p> <p><em>I do not have any control over the configuration, the <code>isLessThan</code> function comes as a stringified function and its signature is <code>(leftEntity: Entity, rightEntity: Entity) =&gt; boolean</code>, so the logic inside the compare function could be anything</em></p> <p>I want to sort the array <code>entities</code> by the information gathered from <code>sources</code> and started with</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>const entities = [{id:"person-1",type:"person",fields:{age:34}},{id:"car-2",type:"car",fields:{manufacturer:"bar"}},{id:"house-2",type:"house",fields:{constructionYear:2010}},{id:"person-4",type:"person",fields:{age:71}},{id:"person-2",type:"person",fields:{age:57}},{id:"house-1",type:"house",fields:{constructionYear:1968}},{id:"car-1",type:"car",fields:{manufacturer:"foo"}},{id:"person-3",type:"person",fields:{age:42}}]; const sources = [{type:"person",sort:{index:1,isLessThanFunctionAsString:"(left, right) =&gt; left.fields.age &lt; right.fields.age"}},{type:"car"},{type:"house",sort:{index:0,isLessThanFunctionAsString:"(left, right) =&gt; left.fields.constructionYear &lt; right.fields.constructionYear"}}]; function sortEntities(unsortedEntities, allSources) { // if there are no entities, there is nothing to do if (unsortedEntities.length === 0) { return unsortedEntities; } // only care for the sources with a sort function const sourcesWithSort = allSources.filter(source =&gt; !!source.sort); // if there are no sources with sort, there is nothing to do if (sourcesWithSort.length === 0) { return unsortedEntities; } // since we can only compare two entities of the same type we must sort the entities by type first let sortedEntities = entities.sort((leftEntity, rightEntity) =&gt; { // no need for sorting if both have the same type if (leftEntity.type === rightEntity.type) { return 0; } if (leftEntity.type &lt; rightEntity.type) { return -1; } return 1; }); // we must sort the sources by sort index ( at this point we now that sort must exist ) const sortSources = sourcesWithSort.sort((leftSource, rightSource) =&gt; leftSource.sort.index - rightSource.sort.index); // NOW we can start sorting the entities for (const source of sortSources) { sortedEntities = sortedEntities.sort((leftEntity, rightEntity) =&gt; { const { type } = source; // we can't compare entities if the types aren't equal to the source type if (leftEntity.type !== type || rightEntity.type !== type) { return 0; } const isLessThanFunction = (new Function("return " + source.sort.isLessThanFunctionAsString))(); const isLeftEntityLessThanRightEntity = isLessThanFunction( leftEntity, rightEntity ); if (isLeftEntityLessThanRightEntity) { return -1; } return 1; }); } return sortedEntities; } console.log(sortEntities([...entities], [...sources]));</code></pre> </div> </div> </p> <p>My approach is getting really slow when dealing with many entities ( &gt; 100 ) and many sources ( &gt; 20 )</p> <p>Do you have any ideas how to improve the code or maybe come up with faster alternatives?</p>
[ { "answer_id": 74223063, "author": "Mr. Polywhirl", "author_id": 1762224, "author_profile": "https://Stackoverflow.com/users/1762224", "pm_score": 0, "selected": false, "text": "isLessThan" }, { "answer_id": 74223819, "author": "adiga", "author_id": 3082296, "author_p...
2022/10/27
[ "https://Stackoverflow.com/questions/74222199", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19698303/" ]
74,222,209
<p>So I have read tons of solutions to this type of questions, but they all seem to be way too complicated, or I can't find any useful solutions in them.</p> <p>I have written the first part where I have to ask for an input and validate it to be an integer, but I can't figure out how to write the code for the second part. Efficiency isn't a necessity here, but I think it's better if I learn the most efficient way from the get go. From what I read, using the radicle of the input and checking the divisors is the way to go here, but as I said, I can't figure out how to actually write the code and integrate it into what I already have.</p> <pre><code>while True: x = str(input(&quot;Please enter an integer: &quot;)) try: x = int(x) except ValueError: print(&quot;Please enter a valid integer: &quot;) continue break </code></pre> <p>Any help is greatly appreciated!</p>
[ { "answer_id": 74223063, "author": "Mr. Polywhirl", "author_id": 1762224, "author_profile": "https://Stackoverflow.com/users/1762224", "pm_score": 0, "selected": false, "text": "isLessThan" }, { "answer_id": 74223819, "author": "adiga", "author_id": 3082296, "author_p...
2022/10/27
[ "https://Stackoverflow.com/questions/74222209", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20111366/" ]
74,222,248
<p>Csv files only store a single row of data and if i use range into csv then it execute only one lines again and again until fulfilments of range.</p> <p>I can't fix this bugs,i took my 2 days.</p> <pre><code> for page in range(0,10): url = &quot;https://cryptonews.net/?page={page}&quot;.format(page =page) # print(url) # open the file in the write mode # f = open('file.csv', 'w',newline='' ) header = ['Title', 'Tag', 'UTC','Web_Address'] # write a row to the csv file page = requests.get(url) soup = BeautifulSoup(page.content, &quot;html.parser&quot;) lists = soup.find_all(&quot;main&quot;) for lis in lists: title = lis.find('a', class_=&quot;title&quot;).text tag = lis.find('span', class_=&quot;etc-mark&quot;).text datetime = lis.find('span', class_=&quot;datetime&quot;).text address = lis.find('div', class_=&quot;middle-xs&quot;).text img = lis.find('span', class_=&quot;src&quot;) data =([title, tag, datetime,address,img]) counter = range(100) with open('crypto.csv', 'a', newline='') as crypto: FileWriter = csv.writer(crypto) FileWriter.writerow(header) for x in counter: FileWriter.writerow(data)# writer.writerows(data) </code></pre>
[ { "answer_id": 74223209, "author": "chitown88", "author_id": 7752296, "author_profile": "https://Stackoverflow.com/users/7752296", "pm_score": 1, "selected": false, "text": "lists" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74222248", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20347991/" ]
74,222,260
<p>I've been trying to get questions from an API for my quiz website I want to push the questions that are being returned from <code>processData</code> function inside the <code>questions</code> list that is in the <code>data</code> object.</p> <p>When i added the returned items from the <code>processData</code> function in the <code>setData</code> it does not add all the returned items and only add the last one, I want all the items i don't know what is wrong with it.</p> <pre><code> const [data, setData] = useState({ questions: [], }); useEffect(() =&gt; { const fetchData = async () =&gt; { await axios.get(baseURL).then((res) =&gt; { const apiData = res.data.results; apiData.map((e) =&gt; { const questions = processData(e); setData((prevData) =&gt; { return { ...prevData, questions: questions, }; }); }); }); }; fetchData(); }, []); </code></pre>
[ { "answer_id": 74223209, "author": "chitown88", "author_id": 7752296, "author_profile": "https://Stackoverflow.com/users/7752296", "pm_score": 1, "selected": false, "text": "lists" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74222260", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12039679/" ]
74,222,283
<p>I have a table A</p> <pre><code>aId aCode 1 ABC 2 DEF 3 GHI </code></pre> <p>..and B table</p> <pre><code>bId bCode 1 JKL 2 MNO 3 PQR </code></pre> <p>In a C table I should update a column 'inAorB' if the cCode is in A or B table so it look like this:</p> <pre><code>cId cCode inAorB 1 ABC A 2 GHI A 3 PQR B </code></pre> <p>.. right now C looks like this:</p> <pre><code>cId cCode inAorB 1 ABC NULL 2 GHI NULL 3 PQR NULL </code></pre> <p>It should update all rows.</p>
[ { "answer_id": 74223209, "author": "chitown88", "author_id": 7752296, "author_profile": "https://Stackoverflow.com/users/7752296", "pm_score": 1, "selected": false, "text": "lists" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74222283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4424698/" ]
74,222,287
<p>I'm new to SQL and I would like to to group by ID and create another column based on value.</p> <p>Let me give an example:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: center;">Foreign ID</th> <th style="text-align: center;">Type</th> <th style="text-align: center;">Value</th> </tr> </thead> <tbody> <tr> <td style="text-align: center;">1</td> <td style="text-align: center;">'X'</td> <td style="text-align: center;">10</td> </tr> <tr> <td style="text-align: center;">1</td> <td style="text-align: center;">'Y'</td> <td style="text-align: center;">20</td> </tr> <tr> <td style="text-align: center;">2</td> <td style="text-align: center;">'X'</td> <td style="text-align: center;">30</td> </tr> <tr> <td style="text-align: center;">2</td> <td style="text-align: center;">'Y'</td> <td style="text-align: center;">40</td> </tr> </tbody> </table> </div> <p>My expected output would be</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: center;">Foreign ID</th> <th style="text-align: center;">X</th> <th style="text-align: center;">Y</th> </tr> </thead> <tbody> <tr> <td style="text-align: center;">1</td> <td style="text-align: center;">10</td> <td style="text-align: center;">20</td> </tr> <tr> <td style="text-align: center;">2</td> <td style="text-align: center;">30</td> <td style="text-align: center;">40</td> </tr> </tbody> </table> </div>
[ { "answer_id": 74223209, "author": "chitown88", "author_id": 7752296, "author_profile": "https://Stackoverflow.com/users/7752296", "pm_score": 1, "selected": false, "text": "lists" } ]
2022/10/27
[ "https://Stackoverflow.com/questions/74222287", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8029206/" ]
74,222,339
<pre><code>import React from 'react'; import { Layout } from '../components' import '../styles/globals.css'; function MyApp({ Component, pageProps }) { return ( &lt;Layout&gt; &lt;Component {...pageProps} /&gt; &lt;/Layout&gt; ) } export default MyApp </code></pre> <p>The layout component, the one I think I am facing a problem with.</p> <pre><code>import React from 'react'; import Head from 'next/head'; import Navbar from './Navbar'; import Footer from './Footer'; const Layout = ({children}) =&gt; { return ( &lt;div className=&quot;layout&quot;&gt; &lt;Head&gt; &lt;title&gt;Ecss&lt;/title&gt; &lt;/Head&gt; &lt;header&gt; &lt;Navbar /&gt; &lt;/header&gt; &lt;main className=&quot;main-container&quot;&gt; {children} &lt;/main&gt; &lt;footer&gt; &lt;Footer /&gt; &lt;/footer&gt; &lt;/div&gt; ) } export default Layout </code></pre> <p>This is also the layout component</p> <p>I am facing a problem with this code I am getting a server error:</p> <p><a href="https://i.stack.imgur.com/m16s3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/m16s3.png" alt="enter image description here" /></a></p> <p>I am trying to wrap <code>&lt;component {...pageProps}/&gt;</code> with the <code>&lt;Layout&gt;</code> tag.</p>
[ { "answer_id": 74222920, "author": "Elio Rahi", "author_id": 19338748, "author_profile": "https://Stackoverflow.com/users/19338748", "pm_score": 0, "selected": false, "text": "import {Layout} from '../components'" }, { "answer_id": 74224656, "author": "shamal iroshan", ...
2022/10/27
[ "https://Stackoverflow.com/questions/74222339", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14168771/" ]
74,222,349
<p>I am facing issue while formatting the date to custom format. I need to convert date <code>yyyy-MM-dd HH:mm:ss</code> ===&gt; <code>EEEE, MMM dd, yyyy</code></p> <p>For example I am getting date from server 27-10-2022 11:02:50, and I need to convert it to Thursday, October 27, 2022</p>
[ { "answer_id": 74222574, "author": "Rohan Jariwala", "author_id": 13954519, "author_profile": "https://Stackoverflow.com/users/13954519", "pm_score": 1, "selected": false, "text": "\"2012-02-27 13:27:00\"\n\"2012-02-27 13:27:00.123456789z\"\n\"2012-02-27 13:27:00,123456789z\"\n\"20120227...
2022/10/27
[ "https://Stackoverflow.com/questions/74222349", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2875724/" ]
74,222,354
<p>I created mern stack react application, using nodejs and express as a server. I want to recieve cookie with jwt token from the server and afterwards refresh the whole page completely and save the cookie. I tried to refresh the page by using window.location.reload(false) and also useHistory.get(0) but both of them refresh the page endless times till I deleted the token and then it stoped refreshing. I also tried to write window.stop() right after window.location.reload(false) but then it did not refresh the window at all. How an I refresh the whole window only once?</p> <p>It is worth to mention that I don't have so much experience with react, so I would really appreciate your help. Thank you.</p>
[ { "answer_id": 74222574, "author": "Rohan Jariwala", "author_id": 13954519, "author_profile": "https://Stackoverflow.com/users/13954519", "pm_score": 1, "selected": false, "text": "\"2012-02-27 13:27:00\"\n\"2012-02-27 13:27:00.123456789z\"\n\"2012-02-27 13:27:00,123456789z\"\n\"20120227...
2022/10/27
[ "https://Stackoverflow.com/questions/74222354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20324554/" ]
74,222,376
<p>I am fairly new to Python and I wanted to generate a simple user input that asks for your name. I got the prompt to work but when I added code that detects if the input is not a string, it doesn't let me input anything at all.</p> <p>It was working up until I added the code that tells the user if they used an unsupported character. Here's the code I have so far:</p> <pre><code>while True: name = input('What is your name? ') if name is str: print('Hi,%s. ' % name) if name != str: print('That is not a valid character!') </code></pre>
[ { "answer_id": 74222574, "author": "Rohan Jariwala", "author_id": 13954519, "author_profile": "https://Stackoverflow.com/users/13954519", "pm_score": 1, "selected": false, "text": "\"2012-02-27 13:27:00\"\n\"2012-02-27 13:27:00.123456789z\"\n\"2012-02-27 13:27:00,123456789z\"\n\"20120227...
2022/10/27
[ "https://Stackoverflow.com/questions/74222376", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20348707/" ]
74,222,401
<p>I have a string like this : <code>Indoformosa/Folder1/SubFolder1</code>, and with those string will be generate an array for a breadcrumbs URL. The app needs an array format lke this:</p> <pre><code>[ 0 =&gt; [ 'label' =&gt; 'Indoformosa' 'url' =&gt; 'Indoformosa' ] 1 =&gt; [ 'label' =&gt; 'Folder1' 'url' =&gt; 'Indoformosa/Folder1' ] 2 =&gt; [ 'label' =&gt; 'SubFolder1' 'url' =&gt; 'Indoformosa/Folder1/SubFolder1' ] ] </code></pre> <p>So far, my PHP code looked like this:</p> <pre><code> $queryParamsPath = 'Indoformosa/Folder1/SubFolder1' $links = explode('/', $queryParamsPath); $links = array_map(function ($el) { return [ 'label' =&gt; $el, 'url' =&gt; Url::to($el) ]; }, $links); </code></pre> <p>The output looked like this:</p> <pre><code>[ 0 =&gt; [ 'label' =&gt; 'Indoformosa' 'url' =&gt; 'Indoformosa' ] 1 =&gt; [ 'label' =&gt; 'Folder1' 'url' =&gt; 'Folder1' ] 2 =&gt; [ 'label' =&gt; 'SubFolder1' 'url' =&gt; 'SubFolder1' ] ] </code></pre>
[ { "answer_id": 74222574, "author": "Rohan Jariwala", "author_id": 13954519, "author_profile": "https://Stackoverflow.com/users/13954519", "pm_score": 1, "selected": false, "text": "\"2012-02-27 13:27:00\"\n\"2012-02-27 13:27:00.123456789z\"\n\"2012-02-27 13:27:00,123456789z\"\n\"20120227...
2022/10/27
[ "https://Stackoverflow.com/questions/74222401", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4452417/" ]
74,222,421
<p>I have a huge text file where i need to grab every n, n+1 th line in a separate file.</p> <p>I came across sed command but that could help me grab every n th line only from a text file. For example:</p> <p>**</p> <pre><code>$ sed -n '0~4p' somefile** **```** Any suggestions on grabbing n+1th line at the same time? ** </code></pre> <p>$ sed -n '0~4p' somefile** <strong>```</strong></p>
[ { "answer_id": 74223094, "author": "Sundeep", "author_id": 4082052, "author_profile": "https://Stackoverflow.com/users/4082052", "pm_score": 0, "selected": false, "text": "$ seq 20 | sed -n '0~4{N;p}'\n4\n5\n8\n9\n12\n13\n16\n17\n" }, { "answer_id": 74224352, "author": "Willi...
2022/10/27
[ "https://Stackoverflow.com/questions/74222421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14726199/" ]
74,222,455
<p>I 'm trying to fetch data from internet using jsoap in kotlin. I fetched data from internet and I want to assigned it to a property that I declared to use easily again but I got this error. I know it is very simple error but I want to learn bacground of issiue. First of all I declared a property and assigned it to datas from internet in the scope but when I want to use it outside of scope it accours this error. What I don't understand is that I have already assigned the data from the internet to this variable, why does it want to initialize the variable again? and when I define it like this,</p> <pre><code>var wordList : MutableList&lt;ExtractedData&gt;?=null </code></pre> <p>the error goes away, but then the data outside the scope is null or empty in the console. But again, the data in the scop I made fetchdata continues to come properly, there is no problem there again.</p> <p><strong>My Code</strong></p> <pre><code>@Composable fun MostUsedWordScreen(viewModel: MostUsedWordScreenViewModel = hiltViewModel()) { var wordList : MutableList&lt;ExtractedData&gt; viewModel.fetchData().observe(LocalLifecycleOwner.current, Observer { wordList = it println(&quot;inside wordlist&quot;+wordList) }) println(&quot;outside wordlist&quot;+wordList) MostUsedWordItem(wordArray = wordList) } </code></pre> <p><strong>My error</strong></p> <pre><code>Variable 'wordList' must be initialized </code></pre>
[ { "answer_id": 74223094, "author": "Sundeep", "author_id": 4082052, "author_profile": "https://Stackoverflow.com/users/4082052", "pm_score": 0, "selected": false, "text": "$ seq 20 | sed -n '0~4{N;p}'\n4\n5\n8\n9\n12\n13\n16\n17\n" }, { "answer_id": 74224352, "author": "Willi...
2022/10/27
[ "https://Stackoverflow.com/questions/74222455", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18002913/" ]
74,222,466
<pre><code> &lt;tbody&gt; &lt;tr ng-repeat=&quot;eta in etaArray&quot;&gt; &lt;td ng-init=&quot;modelIndex =$index&quot;&gt;{{$index+1}}&lt;/td&gt; &lt;td style=&quot;visibility: hidden&quot;&gt;{{eta.BKE_ID}}&lt;/td&gt; &lt;td style=&quot;visibility: hidden&quot;&gt;{{eta.BKE_POINT}}&lt;/td&gt; &lt;td&gt;{{modelIndex}}&lt;/td&gt; &lt;td&gt;{{eta.BKE_POINT_Text}}&lt;/td&gt; &lt;td&gt;{{eta.BKE_DESC}}&lt;/td&gt; &lt;td&gt;{{eta.BKE_DATE | date:'dd-MM-yyyy'}}&lt;/td&gt; &lt;td&gt; &lt;input class=&quot;form-control factDateInput&quot; value=&quot;{{eta.BKE_FACTDATE| date:'yyyy-MM-dd' }}&quot; ng-keyup=&quot;trackTimeChanging($event,this,$index)&quot; ng-model=&quot;factDate[$index]&quot; style=&quot;width: 55%&quot; type=&quot;date&quot; id=&quot;inputFactDate&quot; /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; </code></pre> <p>Hi, everyone i have problem that i can't value from ng-model . Is there any solution how to get value of ng-model that inside ng-repeat</p>
[ { "answer_id": 74225647, "author": "Kinglish", "author_id": 1772933, "author_profile": "https://Stackoverflow.com/users/1772933", "pm_score": 0, "selected": false, "text": "$index" }, { "answer_id": 74232466, "author": "FarHard112", "author_id": 16298531, "author_prof...
2022/10/27
[ "https://Stackoverflow.com/questions/74222466", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16298531/" ]
74,222,482
<p>I've got a file (file1.txt) that looks like like</p> <pre><code>0,100,500 0,200,300 etc. </code></pre> <p>For each line, I need to run a program that will use some of this data as arguments.</p> <p>Hence I wrote:</p> <pre><code>while IFS=',' read -r parameter1 parameter2 parameter3; do /path/to/program/./program.bin -arg2 &quot;$parameter2&quot; -arg3 &quot;$parameter3&quot; done &lt; file1.txt </code></pre> <p>When running the script, the program starts but it hangs and becomes totally unresponsive.</p> <p>The funny thing is that when doing:</p> <pre><code>while IFS=',' read -r parameter1 parameter2 parameter3; do echo /path/to/program/./program.bin -arg2 &quot;$parameter2&quot; -arg3 &quot;$parameter3&quot; &gt;&gt; commands.txt done &lt; file1.txt </code></pre> <p>and then</p> <pre><code>bash -i commands.txt </code></pre> <p>It works. The programs starts normally, finishes then runs again.</p> <p>I don't have any background in IT and I don't understand what I'm doing wrong. Excuse me if the vocabulary I'm using isn't adequate.</p>
[ { "answer_id": 74225647, "author": "Kinglish", "author_id": 1772933, "author_profile": "https://Stackoverflow.com/users/1772933", "pm_score": 0, "selected": false, "text": "$index" }, { "answer_id": 74232466, "author": "FarHard112", "author_id": 16298531, "author_prof...
2022/10/27
[ "https://Stackoverflow.com/questions/74222482", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1444848/" ]
74,222,485
<p>I have that object that I want to use as a type:</p> <pre><code>interface MyInput { id: string, label: string, setter: Function, type: string, value: string | string[] | boolean, options?: string[] } </code></pre> <p>I have some errors like:</p> <blockquote> <p><em>Property 'map' does not exist on type 'string | boolean | string[]'.</em> <em>Type 'string | boolean | string[]' is not assignable to type 'boolean | undefined'.</em></p> </blockquote> <p>The thing is that I will always know whether my value is string[], boolean or string with my type property.</p> <p>Is there any solution to remove those errors without make 3 different interfaces?</p> <p>Beside putting my value property to any or to create 3 diffent types, I do not known.</p>
[ { "answer_id": 74222520, "author": "possum", "author_id": 12050506, "author_profile": "https://Stackoverflow.com/users/12050506", "pm_score": -1, "selected": true, "text": "@ts-ignore" }, { "answer_id": 74222642, "author": "Wazeed", "author_id": 6394979, "author_profi...
2022/10/27
[ "https://Stackoverflow.com/questions/74222485", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14406592/" ]
74,222,547
<p>Look at the HTML table below:</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).on('change', '[name="item_inline"]', function(e) { var $this = $(this); var $inp = $this.closest('tr').find('[name="rtn_qty[item_id]"]'); var qty = $this.closest('tr').find('.qty').text(); $inp.val(qty); })</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt; &lt;table&gt; &lt;thead&gt; &lt;tr&gt; &lt;td&gt;&lt;input type="checkbox" name="select_all" id="select_all" value="1"&gt;&lt;/td&gt; &lt;td&gt;Item Name&lt;/td&gt; &lt;td&gt;Qty&lt;/td&gt; &lt;td&gt;Return Qty&lt;/td&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt;&lt;input type="checkbox" name="item_inline" value="1"&gt;&lt;/td&gt; &lt;td&gt;Name 01&lt;/td&gt; &lt;td class="qty"&gt;150&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="rtn_qty[item_id]" value=""&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;input type="checkbox" name="item_inline" value="1"&gt;&lt;/td&gt; &lt;td&gt;Name 02&lt;/td&gt; &lt;td class="qty"&gt;250&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="rtn_qty[item_id]" value=""&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;input type="checkbox" name="item_inline" value="1"&gt;&lt;/td&gt; &lt;td&gt;Name 03&lt;/td&gt; &lt;td class="qty"&gt;350&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="rtn_qty[item_id]" value=""&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt;</code></pre> </div> </div> </p> <p>Using this table, let say if I checked <code>select_all</code> check box, then I need to fill all the input under Return Qty column with the values of qty column. According to the above table input values should be (150,250,350). And other thing is, if I click on a checkbox inside <code>tr</code> then <code>input</code> of that row should be fill out the qty value of that same row.</p> <p>I tried the similar way to <code>select_all</code> checkbox with <code>each</code> loop, But I confuse how I use <code>each</code> for this.</p> <p>Hope somebody may help me out.</p>
[ { "answer_id": 74222520, "author": "possum", "author_id": 12050506, "author_profile": "https://Stackoverflow.com/users/12050506", "pm_score": -1, "selected": true, "text": "@ts-ignore" }, { "answer_id": 74222642, "author": "Wazeed", "author_id": 6394979, "author_profi...
2022/10/27
[ "https://Stackoverflow.com/questions/74222547", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19205248/" ]
74,222,573
<p>I have a problem with SQL Server Database Project in Visual Studio Community 2022 (Version 17.3.5).</p> <p>It looks like if there is a reference to a not existing function in the select statement, where in 'from' or 'join' statement is a variable of table type or user-defined table type, MSBuild stops tracking reference to the function and compiles the project without any warning.</p> <p>How to force MSBuild to check also that kind of reference? It is quite frustrating because may produce runtime errors after deployment to the SQL server database.</p> <p>I've tried with a blank SQL Server Database Project with one simple procedure:</p> <pre class="lang-sql prettyprint-override"><code>CREATE PROCEDURE [dbo].[SimpleProcedure] AS declare @b table(id int) select dbo.UDF_NotExistingFunction() someColumn --from @b </code></pre> <p>In this form MSBuild says:</p> <blockquote> <p>Warning SQL71502: Procedure: [dbo].[SimpleProcedure] has an unresolved reference to object [dbo].[UDF_SomeNotExistingFunction].</p> </blockquote> <p>When 'from @b' is uncommented, MSBuild compiles the project without being notified about this kind of issue.</p>
[ { "answer_id": 74222520, "author": "possum", "author_id": 12050506, "author_profile": "https://Stackoverflow.com/users/12050506", "pm_score": -1, "selected": true, "text": "@ts-ignore" }, { "answer_id": 74222642, "author": "Wazeed", "author_id": 6394979, "author_profi...
2022/10/27
[ "https://Stackoverflow.com/questions/74222573", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20349128/" ]
74,222,578
<p>I am trying to create a new .txt file after a certain number of entries in an existing .txt file. I would like to have, for example, 50 entries in my file and then, after that, I would like a new file to be created and that the entries continue in that new file. Let us say that I don't want my log files to be filled with a lot of lines, but to have instead more .txt files where entries would be divided.</p> <p>Here is my example code:</p> <pre><code>procedure TForm1.Button3Click(Sender: TObject); function CountRows(Afilename: string): integer; var f: TextFile; i: integer; begin assignfile(f, afilename); reset(f); result := 0; while not eof(f) do begin readln(f); inc(result); end; closefile(f); end; var f: TextFile; fileName: String; fs: Tformatsettings; begin fs.shortdateformat := 'DD.MM.YYYY'; fs.TimeSeparator := ':'; filename := 'D:\LogLprf\LogLpFr ' + Datetostr(now, fs) + '.txt'; assignfile(f, filename); if FileExists(filename) then begin if CountRows(filename)&gt;=2 then begin filename := 'D:\LogLprf\LogLpFr ' + Datetostr(now, fs) +'1.txt'; assignfile(f, filename); rewrite(f); end else append(f); end else begin rewrite(f); end; fs.ShortDateFormat := 'DD.MM.YYYY HH:mm:ss'; Writeln(f, datetimetostr(now, fs)+'- '+'Some error...'); closefile(f); end; </code></pre> <p>With the above code I manage to create the first file and to create the second one if the limit of the entries is reached in the first file. But, the second file keeps re-creating every time. I know that is because I am calling <code>rewrite(f)</code> but I need that to create a new .txt file after the entries for the previous file reach their end. I have also tried calling the <code>fileexists(filename)</code> after <code>CountRows(filename)</code> but that is not a good solution as I will have a lot of nested if statements and that will not solve the issue if we need to create a lot of .txt files. I have also tried going through loops, but that also doesn't solve the problem. Any suggestions are wlcome...thank you</p>
[ { "answer_id": 74223019, "author": "Ehab", "author_id": 20342736, "author_profile": "https://Stackoverflow.com/users/20342736", "pm_score": -1, "selected": false, "text": "function GetFilesCount(SearchDir, SearchFile : String) : Integer;\nvar\n SearchRec: TSearchRec;\nbegin\n Result :=...
2022/10/27
[ "https://Stackoverflow.com/questions/74222578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10520168/" ]
74,222,588
<p>I am trying to get a list of all applications on my Windows Desktop.</p> <p>I have tried the following command but this is not giving me a full list with some applications missing (e.g.: Steam):</p> <p>`</p> <pre><code>Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | Format-Table –AutoSize </code></pre> <p>` I have seen that Windows is providing the virtual folder &quot;shell:AppsFolder&quot; but I am not able to use a Get-ChildItem to see all contents of this path.</p> <p>Do you have any solutions to my problem?</p> <p>Tried:</p> <p>`</p> <pre><code>Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | Format-Table –AutoSize </code></pre> <p>`</p> <p>Result:</p> <pre><code>AnyDesk ad 7.0.14 philandro Software GmbH Google Chrome 106.0.5249.119 Google LLC 20221014 KeePass Password Safe 2.51.1 2.51.1 Dominik Reichl 20220830 Lenovo Welcome 3.6.1.2 Lenovo Group Ltd. Trellix Agent 5.7.7.378 Trellix Microsoft Edge 106.0.1370.52 Microsoft Corporation 20221021 Microsoft Edge Update 1.3.169.31 Microsoft Edge WebView2-Laufzeit 106.0.1370.52 Microsoft Corporation 20221024 Lenovo Vantage Service 3.13.14.0 Lenovo Group Ltd. 20220830 WatchGuard System Manager 12.7.0 WatchGuard Technologies, Inc. 20220906 WinSCP 5.21.2 5.21.2 Martin Prikryl 20220830 Java 8 Update 351 8.0.3510.10 Oracle Corporation 20221019 Microsoft Visual C++ 2019 X86 Minimum Runtime - 14.29.30135 14.29.30135 Microsoft Corporation 20221004 mRemoteNG 1.76.20.24615 Next Generation Software 20220909 Java Auto Updater 2.8.351.10 Oracle Corporation 20221019 Microsoft Azure Information Protection 2.14.90.0 Microsoft Corporation 20220930 Teams Machine-Wide Installer 1.5.0.8070 Microsoft Corporation 20220830 Microsoft Visual C++ 2019 X86 Additional Runtime - 14.29.30135 14.29.30135 Microsoft Corporation 20221004 Jabra Direct 6.4.28501 GN Audio A/S 20221020 Microsoft S/MIME ActiveX Control 15.4.7047 Microsoft Corporation 20221004 Office 16 Click-to-Run Extensibility Component 16.0.15629.20118 Microsoft Corporation 20220929 Office 16 Click-to-Run Localization Component 16.0.15629.20118 Microsoft Corporation 20220929 Jabra Direct 6.4.28501 GN Audio A/S Microsoft Visual C++ 2015-2019 Redistributable (x86) - 14.29.30135 14.29.30135.0 Microsoft Corporation Microsoft Search in Bing 2.0.2 Microsoft Corporation 20220830 VMware Remote Console 12.0.2 VMware, Inc. 20220906 Trellix Data Exchange Layer for MA 6.0.3.847 Trellix DefaultPackMSI 4.6.2.0 Microsoft 20220830 DFUDriverSetupX64Setup 7.0.32822.0 GN Netcom A/S 20220830 Microsoft Visual C++ 2010 x86 Redistributable - 10.0.40219 10.0.40219 Microsoft Corporation 20220906 </code></pre>
[ { "answer_id": 74223019, "author": "Ehab", "author_id": 20342736, "author_profile": "https://Stackoverflow.com/users/20342736", "pm_score": -1, "selected": false, "text": "function GetFilesCount(SearchDir, SearchFile : String) : Integer;\nvar\n SearchRec: TSearchRec;\nbegin\n Result :=...
2022/10/27
[ "https://Stackoverflow.com/questions/74222588", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20349233/" ]
74,222,604
<p>I need some help with a task in python. The task is to make a program that downloads a text file from the internet. Then you have to find &quot;Saturday&quot; and &quot;Sunday&quot; in the text file. Next to those are the temperatures. The task is to calculate the average temperature of the weekend. <em>I am not allowed to change the text file.</em></p> <p>Here is an example of the text file contents:</p> <pre><code>Thursday: 21 Friday: 19 Saturday: 13 Sunday: 17 Monday: 19 Tuesday: 21 Wednesday: 16 </code></pre> <p>well... i found which line they are but i don't know how to get the temperatures. I need to seperate the numbers from the text and assign them to my two variables temp1 and temp2. I would be grateful if you could help me. (sorry for my english. i am not a native speaker.)</p> <pre><code>import urllib.request my_list = list() word1 = &quot;Saturday&quot; word2 = &quot;Sunday&quot; temp1 = 0 temp2 = 0 average = (temp1 + temp2) / 2 urllib.request.urlretrieve(&quot;https://www.senarclens.eu/~gerald/teaching/cms/data/fc.txt&quot;, &quot;fc.txt&quot;) open('fc.txt', 'r') with open('fc.txt') as f: lines = f.read().split(&quot;\n&quot;) for i, line in enumerate(lines): if word1 in line: print(&quot;Word \&quot;{}\&quot; found in line {}&quot;.format(word1, i + 1)) for i, line in enumerate(lines): if word2 in line: print(&quot;Word \&quot;{}\&quot; found in line {}&quot;.format(word2, i + 1)) # need the temperature next to the name of day for temp1, temp2 if average &gt; 25: print(&quot;Next weekend, swimming would be a good activity.&quot;) elif average &gt;= 12 and average &lt; 25: print(&quot;Next weekend, hiking would be a good activity.&quot;) elif average &gt;= 5 and average &lt; 12: print(&quot;Next weekend, watching movies would be a good activity.&quot;) elif average &gt;= -5 and average &lt; 5: print(&quot;Next weekend, relaxing in the local hot springs would be a good activity.&quot;) else: print(&quot;Next weekend, skiing would be a good activity.&quot;) </code></pre>
[ { "answer_id": 74222735, "author": "surge10", "author_id": 8442560, "author_profile": "https://Stackoverflow.com/users/8442560", "pm_score": 2, "selected": true, "text": "daily_temps = {}\n\nfor i, line in enumerate(lines):\n splits = line.split(\":\")\n day = splits[0].strip()\n ...
2022/10/27
[ "https://Stackoverflow.com/questions/74222604", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20349072/" ]
74,222,616
<p>How do you change the search bar text &quot;Search&quot; in a reactable table? I would like to change &quot;Search&quot; to &quot;Search for Your Name&quot;</p> <p>I have looked everywhere online for a solution but haven't found anything. The <a href="https://glin.github.io/reactable/articles/examples.html#searching" rel="nofollow noreferrer">reactable examples article</a> doesn't have anything either. Also, their section on custom filtering has examples that don't work anymore.</p> <pre><code>data &lt;- MASS::Cars93[1:20, c(&quot;Manufacturer&quot;, &quot;Model&quot;, &quot;Type&quot;, &quot;AirBags&quot;, &quot;Price&quot;)] reactable(data, searchable = TRUE, minRows = 10) </code></pre>
[ { "answer_id": 74222735, "author": "surge10", "author_id": 8442560, "author_profile": "https://Stackoverflow.com/users/8442560", "pm_score": 2, "selected": true, "text": "daily_temps = {}\n\nfor i, line in enumerate(lines):\n splits = line.split(\":\")\n day = splits[0].strip()\n ...
2022/10/27
[ "https://Stackoverflow.com/questions/74222616", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12772200/" ]
74,222,620
<p>I have a string of some random length (not specified as requirement).</p> <p>Example:</p> <pre class="lang-none prettyprint-override"><code>dev.ca.ind.clientaddress-completed-events.dom.0.ind-isl-clientaddress-completed.dlq </code></pre> <p>Here, I have to skip three strings, i.e. <code>dev.ca.ind.</code> (I want what is after these strings and before this) <code>.dom</code>, i.e. <code>clientaddress-completed-events</code> (I want to fetch this string from that whole string)</p> <p>Second example:</p> <pre class="lang-none prettyprint-override"><code>dev.ca.ind.insurance.client.insurance.dom.0 </code></pre> <p>I want to fetch <code>insurance.client.insurance</code> after <code>ind</code> and before <code>dom</code> and also this <code>ind</code> can also be <code>gb</code>,<code>grs</code>,<code>all</code>,<code>ind</code>. And <code>dom</code> can also be <code>raw</code>,<code>cdc</code>.</p> <p>How do I do this? I am unable to get idea on how to do this.</p> <p>I have tried splitting these string with &quot;.&quot; but pattern is different for some string as shown in example and this is creating some bugs, so I thought of this way, but wasn't able to implement.</p> <pre><code>String[] splitName = topics.get(PROJECT+i).get(TOPIC_NAME).split(&quot;\\.&quot;); </code></pre> <p>but it was not good as I have to assign substrings using hardcoded index values, e.g. <code>ss.set(splitName[2]+splitName[3])</code>.</p> <p>Some more examples:</p> <pre class="lang-none prettyprint-override"><code>dev.ca.xfunc.cxo.rawleads.dom.0 - get &quot;cxo.rawleads&quot; dev.ca.epm.ceapm.zab.dom.0 - get &quot;ceapm.zab&quot; dev.ca.ind.cx.talas.cdc.0 - get &quot;cx.talas&quot; dev.ca.cif.source-system-client.dom.0 -get &quot;source-system-client&quot; dev.ca.gb.claim.providers.int.0 -get &quot;claim.providers&quot; </code></pre>
[ { "answer_id": 74223015, "author": "Waxhaw", "author_id": 9319615, "author_profile": "https://Stackoverflow.com/users/9319615", "pm_score": -1, "selected": false, "text": "String target = \"dev.ca.ind.clientaddress-completed-events.dom.0.ind-isl-clientaddress-completed.dlq\" \nString ...
2022/10/27
[ "https://Stackoverflow.com/questions/74222620", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20285291/" ]
74,222,632
<p>I am very new on Django. I wanna make patient storage system but i'm stuck. These things must be in project. 1-) In my project i want to add hundreds of patients and also some new patients can add their own infos via register. 2-) Every patients will answer more then 300 questions, so i wanna split the model for good user experience.</p> <p>Here is the my problem. I split the main models, and then i add some basic information from hastaekle.html and then when i looked the admin panel. I see this selection page on the image at below. How can it be automatically.</p> <p><a href="https://i.stack.imgur.com/3Ejig.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3Ejig.jpg" alt="enter image description here" /></a></p> <p>Here is my models.py</p> <pre><code>from django.db import models from django.shortcuts import render from django.urls import reverse # Create your models here. class HastaProfil(models.Model): #id = models.IntegerField(primary_key=True) hasta_ad = models.CharField(max_length=155) hasta_soyad = models.CharField(max_length=155) hasta_dogum_yeri = models.CharField(max_length=155) def __str__(self): return self.hasta_ad + ' ' + self.hasta_soyad def get_absolute_url(self): return reverse('hasta-aliskanlik') class HastaAliskanlik(models.Model): #id = models.IntegerField(primary_key=True) sigara = models.CharField(max_length=155) alkol = models.CharField(max_length=155) uyusturucu = models.CharField(max_length=155) def __str__(self): return self.sigara def get_absolute_url(self): return reverse('hasta-listele') class Hasta(models.Model): #id = models.IntegerField(primary_key=True) hastaprofil = models.ForeignKey(HastaProfil, on_delete=models.CASCADE, null=True) hastaaliskanlik = models.ForeignKey(HastaAliskanlik, on_delete=models.CASCADE, null=True) </code></pre> <p>forms.py</p> <pre><code>from .models import HastaAliskanlik, HastaProfil, Hasta from django import forms class HastaProfilForm(forms.ModelForm): class Meta: model = HastaProfil fields = '__all__' widgets = { 'hasta_ad' : forms.TextInput(attrs={'class': 'form-control'} ), 'hasta_soyad' : forms.TextInput(attrs={'class': 'form-control'}), 'hasta_dogum_yeri' : forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Tıklayarak Seçiniz'}), } class HastaAliskanlikForm(forms.ModelForm): class Meta: model = HastaAliskanlik fields = '__all__' widgets = { 'sigara' : forms.TextInput(attrs={'class': 'form-control'} ), 'alkol' : forms.TextInput(attrs={'class': 'form-control'}), 'uyusturucu' : forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Tıklayarak Seçiniz'}), } class HastaForm(forms.ModelForm): class Meta: model = Hasta fields = '__all__' widgets = { 'hastaprofil' : forms.TextInput(attrs={'class': 'form-control'} ), 'hastaaliskanlik' : forms.TextInput(attrs={'class': 'form-control'}), #'uyusturucu' : forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Tıklayarak Seçiniz'}), } </code></pre> <p>views.py</p> <pre><code>from django.http import HttpResponse from django.shortcuts import render from django.views.generic import CreateView from .forms import HastaProfilForm, HastaAliskanlikForm, HastaForm from .models import HastaProfil, HastaAliskanlik, Hasta # Create your views here. class HastaProfil(CreateView): model = HastaProfil form_class = HastaProfilForm template_name = 'hastaekle.html' class HastaAliskanlik(CreateView): model = HastaAliskanlik form_class = HastaAliskanlikForm template_name = 'hasta_aliskanlik.html' def HastaListele(request): tum_hasta = Hasta.objects.all() return render(request, 'hasta_listele.html', {'tum_hasta': tum_hasta}) def Home(request): return render(request, 'home.html') </code></pre> <p>hastaekle.html</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Hasta Ekle &lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;a href=&quot;{% url 'home' %}&quot;&gt; Anasayfa &lt;/a&gt;&lt;br&gt; &lt;a href=&quot;{% url 'hasta-listele' %}&quot;&gt; Hasta Listele &lt;/a&gt; &lt;h1&gt;Hasta Ekle &lt;/h1&gt; &lt;form action=&quot;&quot; method=&quot;POST&quot;&gt; {% csrf_token %} &lt;h3&gt;Hasta Profil Ekle:&lt;/h3&gt; Hasta Ad: &lt;input type=&quot;text&quot; name=&quot;hasta_ad&quot;/&gt;&lt;br/&gt; Hasta Soyad: &lt;input type=&quot;text&quot; name=&quot;hasta_soyad&quot;/&gt;&lt;br/&gt; Hasta Doğum Yeri: &lt;br/&gt; &lt;textarea cols=&quot;35&quot; rows=&quot;8&quot; name=&quot;hasta_dogum_yeri&quot;&gt; &lt;/textarea&gt;&lt;br/&gt; &lt;input type=&quot;submit&quot; value=&quot;Post&quot;/&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>hasta_aliskanlik.html</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Alışkanlıklarınız &lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;a href=&quot;{% url 'home' %}&quot;&gt; Anasayfa &lt;/a&gt;&lt;br&gt; &lt;a href=&quot;{% url 'hasta-listele' %}&quot;&gt; Hasta Listele &lt;/a&gt; &lt;h1&gt;Hasta Ekle &lt;/h1&gt; &lt;form action=&quot;&quot; method=&quot;POST&quot;&gt; {% csrf_token %} &lt;h3&gt;Alışkanlıklarınız:&lt;/h3&gt; Sigara: &lt;input type=&quot;text&quot; name=&quot;sigara&quot;/&gt;&lt;br/&gt; Alkol: &lt;input type=&quot;text&quot; name=&quot;alkol&quot;/&gt;&lt;br/&gt; Uyuşturucu: &lt;br/&gt; &lt;textarea cols=&quot;35&quot; rows=&quot;8&quot; name=&quot;uyusturucu&quot;&gt; &lt;/textarea&gt;&lt;br/&gt; &lt;input type=&quot;submit&quot; value=&quot;Post&quot;/&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>hasta_listele.html</p> <pre><code>&lt;h1&gt;Hastalar&lt;/h1&gt; &lt;a href=&quot;{% url 'home' %}&quot;&gt; Anasayfa &lt;/a&gt;&lt;br&gt; &lt;a href=&quot;{% url 'hasta-ekle' %}&quot;&gt; Hasta Ekle &lt;/a&gt; &lt;ul&gt; {% for post in tum_hasta %} &lt;li&gt;&lt;a href=&quot;#&quot;&gt;{{ post.hastaprofil.hasta_ad }} {{ post.hastaprofil.hasta_soyad }}&lt;/a&gt; {% endfor %} &lt;/ul&gt; </code></pre>
[ { "answer_id": 74223015, "author": "Waxhaw", "author_id": 9319615, "author_profile": "https://Stackoverflow.com/users/9319615", "pm_score": -1, "selected": false, "text": "String target = \"dev.ca.ind.clientaddress-completed-events.dom.0.ind-isl-clientaddress-completed.dlq\" \nString ...
2022/10/27
[ "https://Stackoverflow.com/questions/74222632", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16535928/" ]
74,222,649
<p>I'm struggling with this split function based on C. After returning the struct by reference from the strSplit() function the token handle seems wrong. The variable sd-&gt;tokens is the right address, but I cannot get the tokens. But they are correct because inside the function I can get it. How can I resolve this and what is the reason for this behavior. All remaining variables in the struct are ok.</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;string.h&gt; struct splitResult { char *source; long lSource; int result; char **tokens; }; typedef struct splitResult splitResultStruct; splitResultStruct * strSplit(char *source, char *delimiter); int main(int argc, const char * argv[]) { char *source = &quot;part1.part2.part3&quot;; splitResultStruct *sd; sd = strSplit(source, &quot;.&quot;); printf(&quot;%d tokens found\n&quot;, sd-&gt;result); for(int i=0; i&lt;sd-&gt;result; i++) { printf(&quot;%s\n&quot;, sd-&gt;tokens[i]); } return 0; } splitResultStruct * strSplit(char *source, char *delimiter) { // Defines the result struct splitResultStruct sData, *sDataPtr; sDataPtr = &amp;sData; sData.source = source; // Gets the length of source string sData.lSource = strlen(source); // Don't split if empty string is given if(sData.lSource == 0) { sData.result = -1; return sDataPtr; } // Allocate memory according teh size of source string char data[sData.lSource]; // Copy the source into the allocated memory strcpy(data,source); // Just count the tokens char *token = strtok(data, delimiter); int tc = 0; while (token != NULL) { token = strtok(NULL, delimiter); tc++; } if(tc == 0) { sData.result = -1; return sDataPtr; } // Defines an array of char pointer with the dimension of the number of tokens sData.result = tc; char *tokens[tc]; // Resets the token engine strcpy(data,source); // Strip out the first token found token = strtok(data, delimiter); tokens[0] = token; tc = 0; while (token != NULL) { // Strip out one token and store them into the token array token = strtok(NULL, delimiter); tc++; tokens[tc] = token; } sData.tokens = tokens; for(int i=0; i&lt;sData.result; i++) { printf(&quot;%s\n&quot;, sData.tokens[i]); } return sDataPtr; } </code></pre>
[ { "answer_id": 74223015, "author": "Waxhaw", "author_id": 9319615, "author_profile": "https://Stackoverflow.com/users/9319615", "pm_score": -1, "selected": false, "text": "String target = \"dev.ca.ind.clientaddress-completed-events.dom.0.ind-isl-clientaddress-completed.dlq\" \nString ...
2022/10/27
[ "https://Stackoverflow.com/questions/74222649", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15750238/" ]
74,222,650
<p>i'm trying to multiply the result &quot;5,0&quot; but nothing works, can someone explain what i'm doing wrong?</p> <p>print result is &quot;5,0 5,0 5,0 5,0 5,0 &quot; i used .replace to remove &quot;KM&quot; from result.</p> <pre><code>import selenium from selenium import webdriver from webdriver_manager.chrome import ChromeDriverManager from selenium.webdriver.chrome.service import Service from selenium.webdriver.common.keys import Keys from time import sleep import pandas as pd import re #C:\Users\jefferson\AppData\Roaming\Python\Python39\site-packages\webdriver_manager\drivers servico = Service(ChromeDriverManager().install()) navegador = webdriver.Chrome(service=servico) navegador.get(&quot;https://www.google.com.br/maps/dir//&quot;) #digitar primeiro endereço navegador.find_element('xpath', '//*[@id=&quot;sb_ifc50&quot;]/input').send_keys(&quot;Rimatur Transportes, Rodovia Curitiba - Ponta Grossa Br-277, Km 2,1875 - Mossunguê, Curitiba - PR, 82305-100&quot;) navegador.find_element('xpath', '//*[@id=&quot;sb_ifc50&quot;]/input').send_keys(Keys.ENTER) #destino navegador.find_element('xpath', '//*[@id=&quot;sb_ifc51&quot;]/input').send_keys(&quot;Av. Juscelino Kubitschek De Oliveira - Ld, 2600 - Cidade Industrial De Curitiba, Curitiba - PR, 81260-900&quot;) navegador.find_element('xpath', '//*[@id=&quot;sb_ifc51&quot;]/input').send_keys(Keys.ENTER) def km(): sleep(10) kmtotal=navegador.find_element('xpath', '/html/body/div[3]/div[9]/div[9]/div/div/div[1]/div[2]/div/div[1]/div/div/div[4]/div[1]/div[1]/div[1]/div[1]/div[2]/div') km1 = kmtotal.text value = km1.replace('km', '') kmprint = value a = 5 print(kmprint * a) #kmprint2 = int(float(kmprint)) # print(type(kmprint2)) km()` print result &gt;&gt;&gt; 5,0 5,0 5,0 5,0 5,0 ` </code></pre>
[ { "answer_id": 74222815, "author": "povk", "author_id": 8737235, "author_profile": "https://Stackoverflow.com/users/8737235", "pm_score": 0, "selected": false, "text": "kmprint" }, { "answer_id": 74223990, "author": "Flow", "author_id": 19893394, "author_profile": "ht...
2022/10/27
[ "https://Stackoverflow.com/questions/74222650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20138896/" ]
74,222,675
<p>I have a dataframe that represents a two-year daily time series of temperature for one river. For this river, I would like to know what day of year (<code>doy</code>):</p> <ol> <li>temperature is sustained greater than or equal to 10 degrees</li> </ol> <ul> <li>sustained is when there are no more dips below 10 until <em>after</em> the peak temperature of the year, such as during autumn or winter</li> </ul> <ol start="2"> <li>temperature is sustained less than or equal to 10 degrees</li> </ol> <ul> <li>sustained is when there are no more peaks above 10 until the following year</li> </ul> <p>I run into errors when I try to calculate 2 because there are multiple <code>TRUE</code> answers for the code to choose from. I would like to know how I can make the code go with the first <code>TRUE</code> answer if there are multiple <code>TRUE</code> answers.</p> <p>Example Dataset</p> <pre><code>library(ggplot2) library(lubridate) library(dplyr) library(dataRetrieval) siteNumber &lt;- &quot;01417500&quot; parameterCd &lt;- &quot;00010&quot; # water temperature statCd &lt;- &quot;00003&quot; # mean startDate &lt;- &quot;2015-01-01&quot; endDate &lt;- &quot;2016-12-31&quot; dat &lt;- readNWISdv(siteNumber, parameterCd, startDate, endDate, statCd=statCd) dat &lt;- dat[,c(2:4)] colnames(dat)[3] &lt;- &quot;temperature&quot; # Visually inspect the time series ggplot(data = dat, aes(x = Date, y = temperature)) + geom_point() + theme_bw() </code></pre> <p>Code for 1 &amp; 2 where 2 is having issues because there are multiple <code>TRUE</code> statements to choose from</p> <pre><code>dat %&gt;% mutate(year = year(Date), doy = yday(Date)) %&gt;% group_by(year) %&gt;% mutate(gt_10 = temperature &gt;= 10, # greater than or equal to 10 degrees lt_10 = temperature &lt;= 10, # less than or equal to 10 degrees peak_doy = doy[which.max(temperature)], # what doy is max temperature below_peak = doy &lt; peak_doy, # is the observed doy less than the peak temperature doy after_peak = doy &gt; peak_doy, # is the observed doy greater than the peak temperature doy test_above = ave(gt_10, cumsum(!gt_10), FUN = cumsum), # counts number of days above 10 degree threshold test_below = ave(lt_10, cumsum(!lt_10), FUN = cumsum)) %&gt;% # counts number of days below 10 degree threshold summarise(first_above_10_sustained = doy[below_peak == T &amp; test_above == 14]-13, # answer to 1 first_below_10_sustained = doy[after_peak == T &amp; test_below == 14]-13) # answer to 2 </code></pre> <ul> <li>To answer 2, the code is looking at those times when temperature is <em>after</em> the annual peak temperature (i.e., <code>after_peak == T</code>) <strong>and</strong> when temperature has been below the 10 threshold for 14 consecutive days (i.e., <code>test_below == 14</code>). The <code>test_below == 14</code> is where the error lies because there are multiple times when this occurs. Yes, you could change the threshold of consecutive days to some value &gt; 14 but that is beside the point. How can I get the code to accept the first <code>TRUE</code> answer is there are multiple <code>TRUE</code> answers?</li> </ul> <p>I have a <a href="https://stackoverflow.com/questions/74212908/which-is-first-day-above-and-below-threshold/74213412#74213412">similar SO question here</a> but my answer only works when there is not multiple <code>TRUE</code> answers to choose from.</p>
[ { "answer_id": 74223335, "author": "Allan Cameron", "author_id": 12500315, "author_profile": "https://Stackoverflow.com/users/12500315", "pm_score": 4, "selected": true, "text": "rleid" }, { "answer_id": 74239474, "author": "tassones", "author_id": 12836787, "author_p...
2022/10/27
[ "https://Stackoverflow.com/questions/74222675", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12836787/" ]
74,222,681
<p>Is there any solution to use <code>Validators.minLength(6)</code> but to ignore spaces ?</p> <p>E.G: <code>1234 5</code> this would validate but it shouldn't as I'm looking to validate 6 digits without spaces E.G: <code>1234 56</code></p> <p>Thanks.</p>
[ { "answer_id": 74222937, "author": "Juliano", "author_id": 5508434, "author_profile": "https://Stackoverflow.com/users/5508434", "pm_score": 1, "selected": false, "text": "html minlength validation digits without spaces" }, { "answer_id": 74223121, "author": "Chund", "aut...
2022/10/27
[ "https://Stackoverflow.com/questions/74222681", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5508434/" ]
74,222,710
<p>I am learning azure functions as a part of it, i want to merge two different xml files of same xml structures in to a single xml file. Can some one please help me how to do that using azure functions ?</p> <p>While merging the xml through async method, i am unable to open the xmldocument using XmlDocument.Open as there is no definition Open for XmlDocument. How do we open the xmldocument data ?</p> <p>This is my code and i got stuck at while open the xmldocument through memorystream</p> <pre><code> private async Task&lt;IList&gt; MergeFileAsync(CloudBlobContainer container, string[] blobFiles) { XmlDocument outputDocument = new XmlDocument(); foreach(String fileblob in blobFiles) { string file = $&quot;&quot; + blobFiles; CloudBlockBlob blockBlob = container.GetBlockBlobReference(file); using(var memoryStream = new MemoryStream()) { await blockBlob.DownloadToStreamAsync(memoryStream); string contents = blockBlob.DownloadTextAsync().Result; //stuck here var inputDocument = XmlDocument.Open(memoryStream, XmlDocument.Import); } } } </code></pre>
[ { "answer_id": 74222937, "author": "Juliano", "author_id": 5508434, "author_profile": "https://Stackoverflow.com/users/5508434", "pm_score": 1, "selected": false, "text": "html minlength validation digits without spaces" }, { "answer_id": 74223121, "author": "Chund", "aut...
2022/10/27
[ "https://Stackoverflow.com/questions/74222710", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14960497/" ]
74,222,717
<p>I'm learning Java 8 with Lambda and Streams and method reference. And I have a question regarding the example below.</p> <pre><code>Optional&lt;String&gt; s = Optional.of(&quot;test&quot;); System.out.println(s.map(String::toUpperCase).get()); </code></pre> <p>I don't understand how is it possible to use <code>String::toUpperCase</code> as an input for this <code>map()</code> method. This is the method implementation:</p> <pre><code>public &lt;U&gt; Optional&lt;U&gt; map(Function&lt;? super T, ? extends U&gt; mapper) { Objects.requireNonNull(mapper); if (!isPresent()) { return empty(); } else { return Optional.ofNullable(mapper.apply(value)); } } </code></pre> <p>So it requires a Function interface, and it has this apply() method: <code>R apply(T t);</code> This method has an input argument.</p> <p>And <code>toUpperCase()</code> method doesn't have any argument:</p> <pre><code>public String toUpperCase() { return toUpperCase(Locale.getDefault()); } </code></pre> <p>I know that if the abstract method has one argument then the implemented method should have one argument of the same type. How can <code>toUpperCase()</code> method implement <code>apply(T t)</code> method from Function interface?</p> <p>I try to recreate the same conditions:</p> <p>I create a functional interface:</p> <pre><code>public interface Interf { String m1(String value); } </code></pre> <p>Then I create a class with the method reference for m1():</p> <pre><code>public class Impl { public String value; public String toUpp() { return value.toUpperCase(); } } </code></pre> <p>And here is a class for test:</p> <pre><code>public class Test { public static void main(String[] args) { Interf i = String::toUpperCase; System.out.println(i.m1(&quot;hey&quot;)); Interf i1 = Impl::toUpp; System.out.println(i.m1(&quot;hello&quot;)); } } </code></pre> <p>There is no issue at this statement: <code>Interf i = String::toUpperCase;</code> but there is a compilation error on this line: <code>Interf i1 = Impl::toUpp;</code>. It says:</p> <pre class="lang-none prettyprint-override"><code>Non-static method cannot be referenced from a static context </code></pre> <p>But <code>toUpperCase()</code> is also a non-static method. And even if I make the <code>toUpp()</code> static, it is still not working, it is working only if I add a String argument as an input argument for <code>toUpp()</code>. But then why is it working for <code>String::toUpperCase</code> ?</p>
[ { "answer_id": 74224132, "author": "radof", "author_id": 20349343, "author_profile": "https://Stackoverflow.com/users/20349343", "pm_score": 4, "selected": true, "text": "String::toUpperCase" }, { "answer_id": 74267272, "author": "Alexander Ivanchenko", "author_id": 17949...
2022/10/27
[ "https://Stackoverflow.com/questions/74222717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7516740/" ]
74,222,730
<pre><code>df.columns = pd.MultiIndex.from_tuples( zip(['AA ', 'BB ', '','DD', 'EE',''],df.columns)) </code></pre> <p>I used the above code in my script that's why I have to set <code>index=True</code></p> <pre><code>df.to_excel(arg,index=True) </code></pre> <p>But now I want to drop my <code>index column</code> What can I Do?</p> <p>I Tried : <code>df.reset_index(inplace=True) data.reset_index(drop=True, inplace=True) df.drop()</code> But no one is worked..!</p>
[ { "answer_id": 74222850, "author": "Khaled DELLAL", "author_id": 15852600, "author_profile": "https://Stackoverflow.com/users/15852600", "pm_score": 0, "selected": false, "text": "df.to_excel(arg,index=False)\n" }, { "answer_id": 74222890, "author": "Ashutosh Yadav", "aut...
2022/10/27
[ "https://Stackoverflow.com/questions/74222730", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11987760/" ]
74,222,733
<p>I'm trying to shutdown a process a bit more gracefully than what the <code>process.Kill(true)</code>, method does.</p> <p>I have a console application, where I start start another process &quot;myProcess&quot; (which is not an application I have sourcecode for), which I want to be able to shutdown, as if pressing <code>ctrl+c</code> in the console. &quot;myProcess&quot; is essentially pinging a receiver at a fixed interval.</p> <p>When I shut it down using <code>ctrl+c</code> the &quot;myProcess&quot; shuts down gracefully, sending an &quot;i am offline now&quot; request to a receiver. However, when I shut it down using <code>kill(true)</code>, it doesn't get to send the offline request, and the receiver stops receiving pings, but doesn't mark it as online.</p> <p>Note I don't have control over the source for myProcess nor the receiver, so I can't change any behaviour in those.</p> <p>I have tried using <code>waitForExit()</code>, <code>waitForExit(0)</code> and <code>kill()</code>, all of which only stops my debugging session, but myProcess keeps running.</p> <p>Searching for a solution I come across answers suggestion these methods, and using <code>GenerateConsoleCtrlEvent</code>, to send the <code>ctrl+c</code> event programmatically. However my console app does not recognize that method, and I can't seem to find any way to use it. I assume, because the answers were fairly old, that it is no longer an option in .NET 6.</p> <p>Does anyone know, how to shutdown a process gracefully, wither a spawned chilprocess, or the self process <code>Process.GetCurrentProcess()</code>?</p>
[ { "answer_id": 74222850, "author": "Khaled DELLAL", "author_id": 15852600, "author_profile": "https://Stackoverflow.com/users/15852600", "pm_score": 0, "selected": false, "text": "df.to_excel(arg,index=False)\n" }, { "answer_id": 74222890, "author": "Ashutosh Yadav", "aut...
2022/10/27
[ "https://Stackoverflow.com/questions/74222733", "https://Stackoverflow.com", "https://Stackoverflow.com/users/744610/" ]
74,222,741
<p>I have a screen with the following:</p> <pre><code>function Intereset ({ navigation }) { function ReturnMyFunction () { if (!var.length) { return ( &lt;NoILikes /&gt; ) } else { return ( &lt;FlatList data={Ilike} keyExtractor={item =&gt; item._id} ItemSeparatorComponent={() =&gt; &lt;Divider /&gt;} renderItem={UserRow} /&gt; ) } } return ( &lt;ReturnILikeOrNoILike /&gt; ) } export default Interest </code></pre> <p>Here is my <code>UserRow</code> component below:</p> <pre><code>const UserRow = ({ item, navigation }) =&gt; ( &lt;TouchableOpacity onPress={() =&gt; navigation.navigate(&quot;ProfileDetailScreenSingle&quot;, { userID: item.likeTo })}&gt; &lt;View style={styles.row}&gt; &lt;Image style={styles.avatar} resizeMode={&quot;cover&quot;} source={{ uri: item.likeToProfileImage }} /&gt; &lt;View style={styles.textContainer}&gt; &lt;Text style={styles.name}&gt;{item.likeToName}, &lt;Text&gt;{item.likeToAge}&lt;/Text&gt;&lt;/Text&gt; &lt;/View&gt; &lt;Text style={styles.viewProfileText}&gt;View Profile&lt;/Text&gt; &lt;AntDesign name=&quot;right&quot; size={14} color=&quot;black&quot; /&gt; &lt;/View&gt; &lt;/TouchableOpacity&gt; </code></pre> <p>)</p> <p>When I click on the <code>UserRow</code> to navigate I get the following issue.</p> <p><a href="https://i.stack.imgur.com/e0vm3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/e0vm3.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74226135, "author": "user18309290", "author_id": 18309290, "author_profile": "https://Stackoverflow.com/users/18309290", "pm_score": 0, "selected": false, "text": "onPress" }, { "answer_id": 74272326, "author": "Vu Phung", "author_id": 12040727, "author...
2022/10/27
[ "https://Stackoverflow.com/questions/74222741", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5724342/" ]