qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,250,201
<p>I have a table called <code>Sets</code> for LEGO:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>set_number (Primary Key)</th> <th>set_name</th> <th>other_fields</th> </tr> </thead> <tbody> <tr> <td>123</td> <td>Firetruck</td> <td>abc</td> </tr> <tr> <td>234</td> <td>Star Wars</td> <td>abc</td> </tr> </tbody> </table> </div> <p>I have another table called <code>Parts</code> for LEGO:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>part_number (Primary Key)</th> <th>name</th> <th>set_number (references set_number from Sets)</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>Truck Roof</td> <td>123</td> </tr> <tr> <td>2</td> <td>Truck Body</td> <td>123</td> </tr> <tr> <td>3</td> <td>Neimoidian Viceroy Robe</td> <td>234</td> </tr> </tbody> </table> </div> <p>I want to create another column in the <code>Sets</code> table to indicate the number of unique parts the particular set has.</p> <p>I was able to output the number of unique parts with the following:</p> <pre><code>SELECT s.set_number, COUNT(*) AS num_diff_parts FROM Sets s, Parts p WHERE p.set_number = s.set_number GROUP BY s.set_number </code></pre> <p>This outputs the following table (let's call it <code>results</code>):</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>set_number</th> <th>num_diff_parts</th> </tr> </thead> <tbody> <tr> <td>123</td> <td>2</td> </tr> <tr> <td>234</td> <td>1</td> </tr> </tbody> </table> </div> <p>However, I wonder if I can put the column (<code>num_diff_parts</code>) into the Sets table as a new column, instead of having to run this query every time when I need this information, or create another table just to contain the content of the <code>results</code> table.</p> <p>Ideally, the <code>Sets</code> table should look like this:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>set_number (Primary Key)</th> <th>set_name</th> <th>other_fields</th> <th>num_diff_parts</th> </tr> </thead> <tbody> <tr> <td>123</td> <td>Firetruck</td> <td>abc</td> <td>2</td> </tr> <tr> <td>234</td> <td>Star Wars</td> <td>abc</td> <td>1</td> </tr> </tbody> </table> </div> <p>I've also tried to do <code>GROUP BY</code> on multiple fields, but I don't think that's safe to do as those fields can have repeats and will throw off the results.</p>
[ { "answer_id": 74250189, "author": "Michael Sohnen", "author_id": 5166365, "author_profile": "https://Stackoverflow.com/users/5166365", "pm_score": 0, "selected": false, "text": "def is_prime(i):\n \n # if I is divisible by any number smaller than it, it is not prime\n\n prime =...
2022/10/30
[ "https://Stackoverflow.com/questions/74250201", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16519688/" ]
74,250,301
<p>I have a file aa.txt:</p> <pre><code>Nothing is worth more than the truth. I like to say hello to him. Give me peach or give me liberty. Please say hello to strangers. I'ts ok to say Hello to strangers. </code></pre> <p>I tried with code:</p> <pre class="lang-perl prettyprint-override"><code>use strict; use warnings; my $input_aa='aa.txt'; while (1) { print &quot;Enter the word you are looking for (or 'quit' to exit): &quot;; my $answer = &lt;STDIN&gt;; chomp $answer; last if $answer =~/quit/i; # print &quot;Looking for '$answer'\n&quot;; my $found = 0; open my $f, &quot;&lt;&quot;, $input_aa or die &quot;ERROR: Cannot open '$input_aa': $!&quot;; while (&lt;$f&gt;) { m/$answer/ or next; $found=1; last; } close $f; if ($found) { print &quot;Found $answer!\n&quot;; while ( my $line = &lt;$input_aa&gt; ) { print $line; } } else { print &quot;Sorry - $answer was not found\n&quot;; } } </code></pre> <p>I want when I enter a keyword from the keyboard to compare in the file and output the line with that word. For example, when I enter the word <code>Nothing</code>, it should output the line <code>Nothing is worth more than the truth.</code>.</p> <p>I tried with the code but it doesn't output the line when I enter the keyword from the keychain. Where's the problem?</p>
[ { "answer_id": 74250341, "author": "Dan Bonachea", "author_id": 3528321, "author_profile": "https://Stackoverflow.com/users/3528321", "pm_score": 0, "selected": false, "text": "while ( my $line = <$input_aa> ) \n" }, { "answer_id": 74250349, "author": "craigb", "author_id...
2022/10/30
[ "https://Stackoverflow.com/questions/74250301", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20358122/" ]
74,250,329
<p>I have a DataFrame that I am adding data to, but I do not gather the data for each row at the same time. Some of the columns are assembled in pieces.</p> <p>The first time I have some data for a column, I can simply assign it:</p> <pre class="lang-py prettyprint-override"><code>import pandas as pd df = pd.DataFrame() df[&quot;name&quot;] = pd.Series([&quot;A&quot;, &quot;B&quot;, &quot;C&quot;, &quot;D&quot;, &quot;E&quot;, &quot;F&quot;, &quot;G&quot;, &quot;H&quot;, &quot;I&quot;]) df[&quot;data&quot;] = pd.Series([1, 2, 3]) new_data = pd.Series([4, 5, 6]) </code></pre> <p>How can I append <code>new_data</code> to the <code>&quot;data&quot;</code> column?</p> <p>Expected output:</p> <pre class="lang-py prettyprint-override"><code> name data 0 A 1.0 1 B 2.0 2 C 3.0 3 D 4.0 4 E 5.0 5 F 6.0 6 G NaN 7 H NaN 8 I NaN </code></pre> <p>Things I've tried:</p> <pre class="lang-py prettyprint-override"><code>df[&quot;data&quot;] += new_data # Adds instead of appending df[&quot;data&quot;] = df[&quot;data&quot;].append(new_data) # ValueError: cannot reindex on an axis with duplicate labels df[&quot;data&quot;] = pd.concat([df[&quot;data&quot;], new_data]) # ValueError: cannot reindex on an axis with duplicate labels column = df[&quot;data&quot;] df.drop(columns=&quot;data&quot;) df[&quot;data&quot;] = pd.concat([column, new_data]) # ValueError: cannot reindex on an axis with duplicate labels df[&quot;data&quot;] = pd.concat([df[&quot;data&quot;], new_data], ignore_index=True) # This doesn't appear to modify the column (but no errors) df[&quot;data&quot;] = pd.concat([df[&quot;data&quot;], new_data], axis=1) # ValueError: Columns must be same length as key </code></pre> <p>How can I accomplish this deceptively simple task? I believe I am not understanding how indexing works in Pandas.</p>
[ { "answer_id": 74250413, "author": "Ynjxsjmh", "author_id": 10315163, "author_profile": "https://Stackoverflow.com/users/10315163", "pm_score": 3, "selected": true, "text": "df['data'] = pd.concat([df['data'].dropna(), new_data], ignore_index=True)\n" }, { "answer_id": 74250432, ...
2022/10/30
[ "https://Stackoverflow.com/questions/74250329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11827673/" ]
74,250,331
<p>I'm trying to loop through the elements of a list, print them out, separate them by a comma but leave the trailing comma; all in a single loop. I'm aware of the join() method but I wanted to ask if there was a way to complete that within the loop?</p> <p>This is the code I'm currently working with:</p> <pre><code>grades = [['A1', 12], ['A2', 18], ['A3', 20], ['A4', 19]] for i in range(len(grades)): print(grades[i][0], end = ', ') </code></pre> <p>It keeps returning this:</p> <pre><code>A1, A2, A3, A4, </code></pre> <p>How do I stop that last comma from appearing?</p>
[ { "answer_id": 74250364, "author": "rdeepak", "author_id": 12101109, "author_profile": "https://Stackoverflow.com/users/12101109", "pm_score": 0, "selected": false, "text": "grades = [['A1', 12], ['A2', 18], ['A3', 20], ['A4', 19]]\n\nfor i in range(len(grades)):\n print(grades[i][0],...
2022/10/30
[ "https://Stackoverflow.com/questions/74250331", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17460503/" ]
74,250,337
<p>I know similar questions like this have already been asked on the platform but I checked them and did not find the help I needed.</p> <p>I have some String such as :</p> <p>path = &quot;most popular data structure in OOP lists/5438_133195_9917949_1218833? povid=racking these benchmarks&quot;</p> <p>path = &quot;activewear/2356_15890_9397775? povid=ApparelNavpopular data structure you to be informed when a regression&quot;</p> <p>I have a function :</p> <pre><code>def extract_id(path): pattern = re.compile(r&quot;([0-9]+(_[0-9]+)+)&quot;, re.IGNORECASE) return pattern.match(path) </code></pre> <p>The expected results are 5438_133195_9917949_1218833 and 2356_15890_9397775. I tested the function online, and it seems to produce the expected result but my it's returning None in my app. What am I doing wrong? Thanks.</p>
[ { "answer_id": 74250364, "author": "rdeepak", "author_id": 12101109, "author_profile": "https://Stackoverflow.com/users/12101109", "pm_score": 0, "selected": false, "text": "grades = [['A1', 12], ['A2', 18], ['A3', 20], ['A4', 19]]\n\nfor i in range(len(grades)):\n print(grades[i][0],...
2022/10/30
[ "https://Stackoverflow.com/questions/74250337", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10850374/" ]
74,250,338
<p>Thanks to <a href="https://stackoverflow.com/users/1645925/georgebutter">@GeorgeButter</a> for <a href="https://stackoverflow.com/a/60201308/1473559">this code</a>. I have applied it to my application, however have run into some problems.</p> <p>I'm having a little issue with finding out why my <code>case</code> statement wont load the SVG content.</p> <p>Below is the code that I have a added in the <code>Snippets</code> folder.</p> <pre><code>&lt;!-- snippets/icon.liquid --&gt; &lt;div class=&quot;icon icon-{{- icon | strip | strip_newlines -}}&quot;&gt; &lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; {%- if icon != blank %}aria-label=&quot;{{- icon | strip | strip_newlines -}}&quot;{% endif %} role=&quot;img&quot; width=&quot;{{ size | default: 30 }}px&quot; height=&quot;{{ size | default: 30 }}px&quot; viewBox=&quot;{{ viewbox | default: '0 0 30 30' }}&quot;&gt; {%- case icon -%} {%- when 'fabric' -%} &lt;g&gt; &lt;path clip-rule=&quot;evenodd&quot; d=&quot;m40.3566 22.3591c13.4123-9.346 28.6444-9.1866 37.0576-.7744l.0183.0186 38.0005 39.001c.026.0271.051.0549.076.0834 3.99 4.5877 7.934 16.7303-3.443 31.0561-11.099 13.9762-25.2466 12.6482-31.7294 9.8782-.6984-.298-1.2756-.733-1.7414-1.204l-40.7343-41.2137c-1.2041-1.2183-1.9027-2.966-1.6436-4.7993 1.3849-9.7968 7.2939-17.0397 13.8077-20.8001 3.2531-1.878 6.739-2.9351 9.9719-2.9446 3.2474-.0096 6.3448 1.0501 8.5083 3.5226 2.2386 2.5584 2.6604 5.5605 1.9955 8.3644-.6461 2.7248-2.3038 5.2654-4.2498 7.2798-1.9487 2.017-4.3395 3.6655-6.66 4.5001-2.2111.7953-5.0394 1.0527-7.0052-.913-1.1793-1.1794-1.8525-2.5197-2.0727-3.9289-.2162-1.3832.0234-2.7016.4506-3.8468.8365-2.2427 2.4958-4.1088 3.7445-5.1654.8432-.7134 2.1051-.6083 2.8186.2349.7135.8433.6083 2.1052-.2349 2.8187-.918.7768-2.0587 2.1107-2.5805 3.5097-.252.6756-.3311 1.2885-.2463 1.8312.0808.5169.3285 1.0975.9492 1.7181.2842.2843 1.0809.6041 2.8229-.0224 1.6327-.5873 3.5232-1.845 5.137-3.5155 1.6164-1.6731 2.8025-3.6013 3.2346-5.4234.4133-1.743.1476-3.3659-1.1138-4.8075-1.2262-1.4013-3.1011-2.1637-5.4862-2.1567-2.3997.0071-5.2065.8055-7.9838 2.4089-5.5471 3.2023-10.6497 9.4257-11.8469 17.8957-.0655.4629.1017.9965.5278 1.4276l40.7343 41.2137c.1727.1747.3313.2795.4681.338 5.2288 2.2339 17.2985 3.5609 27.0258-8.6878 10.179-12.8186 6.268-22.7786 3.592-25.9036l-37.9491-38.9484c-6.5896-6.5779-19.5211-7.4127-31.9334 1.2366-15.1335 10.5455-21.6087 25.9053-27.3802 41.6228-.2687.7317-.082 1.5577.4825 2.108l35.7093 34.8163c.0022.002.0039.004.0051.005.0059.001.0234.002.0506-.005.0314-.008.0588-.023.0776-.04.0153-.013.0271-.029.0361-.055 1.7117-4.9295 4.9881-12.3799 9.519-16.5622.8116-.7492 2.0769-.6986 2.8261.113s.6986 2.077-.113 2.8262c-3.7483 3.46-6.7654 10.074-8.4534 14.935-.9493 2.734-4.5286 3.804-6.7405 1.647l-35.7093-34.8163c-1.6873-1.6451-2.2602-4.1305-1.4449-6.3508 5.7772-15.7332 12.595-32.2002 28.8481-43.5258z&quot; fill-rule=&quot;evenodd&quot; data-original=&quot;#000000&quot; class=&quot;&quot;&gt;&lt;/path&gt; &lt;/g&gt; {%- when 'haberdashery' -%} &lt;g&gt; &lt;g fill=&quot;rgb(0,0,0)&quot;&gt; &lt;path d=&quot;m89.6437 15.2722c5.627-4.7957 13.9943-4.4625 19.2223.7654 1.659 1.6585 1.556 4.3775-.223 5.906l-33.8397 29.0732c-.8378.7199-2.1005.6242-2.8203-.2136s-.6242-2.1005.2137-2.8204l33.8393-29.0733c.004-.0035.006-.0063.006-.0063l.002-.0022c.001-.0018.002-.0063.002-.0129.001-.0066-.001-.0111-.001-.013l-.001-.0023s-.002-.0029-.006-.0068c-3.753-3.753-9.7602-3.9922-13.7997-.5494l-35.441 30.2054c-.8407.7165-2.103.6158-2.8195-.2249-.7165-.8406-.6158-2.1029.2249-2.8194z&quot; fill=&quot;#000000&quot; data-original=&quot;#000000&quot; class=&quot;&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m55.5 61.9998c-1.1046 0-2 .8955-2 2 0 1.1046.8954 2 2 2h1.5c1.1046 0 2-.8954 2-2 0-1.1045-.8954-2-2-2z&quot; fill=&quot;#000000&quot; data-original=&quot;#000000&quot; class=&quot;&quot;&gt;&lt;/path&gt;&lt;path clip-rule=&quot;evenodd&quot; d=&quot;m21.5 38.4998c-2.9221 0-6.2483 1.0103-8.8797 3.13-2.68608 2.1639-4.6203 5.4711-4.6203 9.87 0 6.2894 4.0493 10.2061 6.6954 11.7999.8919.5373 1.8542.7001 2.6831.7001h25.748c.5936 0 1.1565.2637 1.5364.7197l.3284.394-25.5331 24.0087c-4.5981 4.3236-4.9743 11.5018-.8531 16.2828 4.2456 4.925 11.6777 5.481 16.6092 1.243l18.8636-16.2109c3.9726-3.4139 4.2019-9.4859.4981-13.1897l-.1618-.1618c-.781-.781-2.0474-.781-2.8284 0-.7811.7811-.7811 2.0474 0 2.8285l.1618.1617c2.0576 2.0577 1.9302 5.431-.2767 7.3277l-18.8636 16.2105c-3.2579 2.8-8.1678 2.433-10.9726-.821-2.7225-3.1581-2.474-7.9004.5636-10.7567l25.3583-23.8444 2.2076 2.6491c1.1399 1.3679 2.8286 2.1588 4.6093 2.1588h51.1265c7.732 0 14-6.268 14-14 0-2.2091-1.791-4-4-4h-56.6045c-.5998 0-1.168-.2692-1.5479-.7335l-2.0994-2.5659c-1.1387-1.3918-2.8405-2.2006-4.6414-2.2006h-13.1074c-.9877 0-2.1363-.8906-2.7015-2.5761-2.2064-6.58-8.8388-8.4239-13.2979-8.4239zm-9.5 13c0-3.101 1.3158-5.2938 3.1297-6.7549 1.8686-1.5053 4.2924-2.2451 6.3703-2.2451 3.7856 0 8.117 1.555 9.5054 5.6956.8395 2.5036 3.0635 5.3044 6.494 5.3044h13.1074c.5986 0 1.1649.2683 1.5456.7336l2.0994 2.5659c1.1395 1.3928 2.8441 2.2005 4.6437 2.2005h56.6045c0 5.5229-4.477 10-10 10h-51.1265c-.5936 0-1.1565-.2636-1.5364-.7196l-5.1013-6.1215c-1.1399-1.3679-2.8286-2.1589-4.6093-2.1589h-25.748c-.3286 0-.5196-.0665-.6193-.1265-1.9189-1.1558-4.7592-3.9636-4.7592-8.3735z&quot; fill-rule=&quot;evenodd&quot; data-original=&quot;#000000&quot; class=&quot;&quot;&gt;&lt;/path&gt; &lt;/g&gt; &lt;/g&gt; {%- when 'patternsbooks' -%} &lt;g&gt; &lt;g fill=&quot;rgb(0,0,0)&quot;&gt; &lt;path d=&quot;m53.6807 29.9089c-.494-.7585-1.4358-1.0907-2.2964-.8099l-3.2203 1.0508c-1.0501.3427-1.6236 1.4717-1.2809 2.5218.3426 1.0501 1.4717 1.6235 2.5217 1.2809l1.8665-.6091c.5148.6066 1.1427 1.25 1.8728 1.8825.8348.7233 2.0979.6328 2.8212-.202s.6329-2.0979-.202-2.8212c-1.013-.8777-1.7138-1.7275-2.0826-2.2938z&quot; fill=&quot;#000000&quot; data-original=&quot;#000000&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m77.6157 29.099c-.8606-.2808-1.8024.0514-2.2964.8099-.3688.5663-1.0696 1.4161-2.0826 2.2938-.8349.7233-.9253 1.9864-.202 2.8212s1.9864.9253 2.8212.202c.7301-.6325 1.358-1.2759 1.8728-1.8825l1.8665.6091c1.05.3426 2.1791-.2308 2.5217-1.2809.3427-1.0501-.2308-2.1791-1.2809-2.5218z&quot; fill=&quot;#000000&quot; data-original=&quot;#000000&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m42.9641 36.0542c1.0501-.3427 1.6236-1.4717 1.2809-2.5218-.3426-1.0501-1.4717-1.6236-2.5217-1.2809l-3.2204 1.0508c-.8049.2627-1.5794.5962-2.3152.994-.9717.5253-1.3335 1.7389-.8082 2.7105.5254.9717 1.7389 1.3335 2.7106.8082.5255-.2842 1.0786-.5223 1.6537-.71z&quot; fill=&quot;#000000&quot; data-original=&quot;#000000&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m87.2767 32.2515c-1.05-.3427-2.1791.2308-2.5217 1.2809-.3427 1.0501.2308 2.1791 1.2809 2.5218l3.2203 1.0508c.5751.1877 1.1282.4258 1.6537.71.9717.5253 2.1852.1635 2.7106-.8082.5253-.9716.1635-2.1852-.8082-2.7105-.7358-.3978-1.5103-.7313-2.3152-.994z&quot; fill=&quot;#000000&quot; data-original=&quot;#000000&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m68.6303 39.0709c1.0694-.2765 1.7121-1.3676 1.4356-2.437s-1.3675-1.7122-2.4369-1.4357c-.9701.2509-2.0144.3978-3.129.3978s-2.1589-.1469-3.129-.3978c-1.0694-.2765-2.1604.3663-2.4369 1.4357s.3662 2.1605 1.4356 2.437c1.2797.3309 2.6604.5251 4.1303.5251s2.8506-.1942 4.1303-.5251z&quot; fill=&quot;#000000&quot; data-original=&quot;#000000&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m35.2933 40.0575c.7239-.8343.6345-2.0974-.1997-2.8214s-2.0974-.6346-2.8214.1997c-.5483.6318-1.042 1.3152-1.4734 2.0438l-2.255 3.809c-.5627.9505-.2483 2.1772.7022 2.7399s2.1772.2483 2.7399-.7022l2.2549-3.809c.3082-.5205.6609-1.0086 1.0525-1.4598z&quot; fill=&quot;#000000&quot; data-original=&quot;#000000&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m96.7278 37.4358c-.724-.8343-1.9872-.9237-2.8214-.1997s-.9236 1.9871-.1997 2.8214c.3916.4512.7443.9393 1.0525 1.4598l2.2549 3.809c.5627.9505 1.7894 1.2649 2.7399.7022.95-.5627 1.265-1.7894.702-2.7399l-2.2548-3.809c-.4313-.7286-.9251-1.412-1.4734-2.0438z&quot; fill=&quot;#000000&quot; data-original=&quot;#000000&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m27.476 52.9442c.5627-.9505.2483-2.1771-.7022-2.7398s-2.1772-.2484-2.7399.7021l-2.2549 3.809c-.309.5218-.3644 1.1556-.1509 1.7232.2136.5676.6731 1.0076 1.2495 1.1963l1.1958.3916c.4531.1484.9211.1261 1.3344-.0316.2399.3716.6041.6665 1.0572.8149l1.1959.3916c1.0497.3438 2.1793-.2285 2.5231-1.2782s-.2285-2.1794-1.2782-2.5231l-1.1959-.3917c-.4531-.1484-.9211-.1261-1.3344.0317-.024-.0372-.0492-.0736-.0757-.1092z&quot; fill=&quot;#000000&quot; data-original=&quot;#000000&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m104.966 50.9065c-.563-.9505-1.789-1.2648-2.74-.7021-.95.5627-1.265 1.7893-.702 2.7398l1.176 1.9868c-.026.0356-.052.072-.076.1092-.413-.1578-.881-.1801-1.334-.0317l-1.196.3917c-1.0495.3437-1.6218 1.4734-1.278 2.5231s1.473 1.622 2.523 1.2782l1.196-.3916c.453-.1484.817-.4433 1.057-.8149.413.1577.881.18 1.335.0316l1.195-.3916c.577-.1887 1.036-.6287 1.25-1.1963.213-.5676.158-1.2014-.151-1.7232z&quot; fill=&quot;#000000&quot; data-original=&quot;#000000&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m46 63.0003c0-1.1046-.8954-2-2-2s-2 .8954-2 2v3.3333c0 1.1046.8954 2 2 2s2-.8954 2-2z&quot; fill=&quot;#000000&quot; data-original=&quot;#000000&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m87 63.0003c0-1.1046-.8954-2-2-2s-2 .8954-2 2v3.3333c0 1.1046.8954 2 2 2s2-.8954 2-2z&quot; fill=&quot;#000000&quot; data-original=&quot;#000000&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m46 73.0003c0-1.1046-.8954-2-2-2s-2 .8954-2 2v6.6667c0 1.1045.8954 2 2 2s2-.8955 2-2z&quot; fill=&quot;#000000&quot; data-original=&quot;#000000&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m87 73.0003c0-1.1046-.8954-2-2-2s-2 .8954-2 2v6.6667c0 1.1045.8954 2 2 2s2-.8955 2-2z&quot; fill=&quot;#000000&quot; data-original=&quot;#000000&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m46 86.3336c0-1.1045-.8954-2-2-2s-2 .8955-2 2v6.6667c0 1.1046.8954 2 2 2s2-.8954 2-2z&quot; fill=&quot;#000000&quot; data-original=&quot;#000000&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m87 86.3336c0-1.1045-.8954-2-2-2s-2 .8955-2 2v6.6667c0 1.1046.8954 2 2 2s2-.8954 2-2z&quot; fill=&quot;#000000&quot; data-original=&quot;#000000&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m46 99.667c0-1.1046-.8954-2-2-2s-2 .8954-2 2v3.333c0 1.105.8954 2 2 2h3.4167c1.1045 0 2-.895 2-2 0-1.104-.8955-2-2-2h-1.4167z&quot; fill=&quot;#000000&quot; data-original=&quot;#000000&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m87 99.667c0-1.1046-.8954-2-2-2s-2 .8954-2 2v1.333h-1.4167c-1.1045 0-2 .896-2 2 0 1.105.8955 2 2 2h3.4167c1.1046 0 2-.895 2-2z&quot; fill=&quot;#000000&quot; data-original=&quot;#000000&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m54.25 101c-1.1046 0-2 .896-2 2 0 1.105.8954 2 2 2h6.8333c1.1046 0 2-.895 2-2 0-1.104-.8954-2-2-2z&quot; fill=&quot;#000000&quot; data-original=&quot;#000000&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m67.9167 101c-1.1046 0-2 .896-2 2 0 1.105.8954 2 2 2h6.8333c1.1046 0 2-.895 2-2 0-1.104-.8954-2-2-2z&quot; fill=&quot;#000000&quot; data-original=&quot;#000000&quot;&gt;&lt;/path&gt;&lt;path clip-rule=&quot;evenodd&quot; d=&quot;m78.7476 18.0365c.4825-.8773 1.5393-1.2626 2.4732-.9018l17.6684 6.8264c3.2518 1.2563 5.9178 3.6804 7.4768 6.7982l12.423 24.8466c.252.5035.28 1.0899.077 1.6151-.203.5251-.618.9405-1.143 1.144l-23.223 9.0049v44.6301h-60v-44.6301l-23.2231-9.0049c-.5249-.2035-.9397-.6189-1.1425-1.144-.20291-.5252-.17503-1.1116.0767-1.6151l12.4233-24.8466c1.5589-3.1178 4.2249-5.5419 7.4764-6.7982l17.6684-6.8264c.9339-.3608 1.9907.0245 2.4732.9018.7905 1.4372 2.5123 3.7202 5.001 5.6258 2.4723 1.8931 5.5979 3.338 9.2466 3.338s6.7743-1.4449 9.2466-3.338c2.4887-1.9056 4.2105-4.1886 5.001-5.6258zm11.7524 48.0105c-.0007-.0309-.0007-.0617 0-.0924v-9.9543c0-1.1046.8954-2 2-2s2 .8954 2 2v7.0794l19.729-7.6499-11.441-22.8816c-1.114-2.227-3.0179-3.9585-5.3404-4.8559l-16.1279-6.2312c-1.1633 1.6829-2.9004 3.6613-5.1413 5.3772-2.9693 2.2736-6.9271 4.162-11.6784 4.162s-8.7091-1.8884-11.6784-4.162c-2.2409-1.7159-3.978-3.6943-5.1413-5.3772l-16.1279 6.2312c-2.3225.8974-4.2268 2.6289-5.3403 4.8559l-11.4408 22.8816 19.7287 7.6499v-7.0794c0-1.1046.8954-2 2-2s2 .8954 2 2v9.9543c.0007.0307.0007.0615 0 .0924v41.953h52z&quot; fill-rule=&quot;evenodd&quot; data-original=&quot;#000000&quot;&gt;&lt;/path&gt; &lt;/g&gt; &lt;/g&gt; {%- when 'giftcards' -%} &lt;g&gt; &lt;g fill=&quot;rgb(0,0,0)&quot;&gt; &lt;g clip-rule=&quot;evenodd&quot; fill-rule=&quot;evenodd&quot;&gt;&lt;path d=&quot;m20 75c0 .5523.4477 1 1 1h2c.5523 0 1 .4477 1 1v14c0 .5523.4477 1 1 1h36c.5523 0 1-.4477 1-1v-14c0-.5523.4477-1 1-1h2c.5523 0 1-.4477 1-1v-14c0-.5523-.4477-1-1-1h-44c-.5523 0-1 .4477-1 1zm5-11c-.5523 0-1 .4477-1 1v6c0 .5523.4477 1 1 1h2c.5523 0 1 .4477 1 1v14c0 .5523.4477 1 1 1h28c.5523 0 1-.4477 1-1v-14c0-.5523.4477-1 1-1h2c.5523 0 1-.4477 1-1v-6c0-.5523-.4477-1-1-1z&quot; fill=&quot;#000000&quot; data-original=&quot;#000000&quot; class=&quot;&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m45 88v-24h-4v24zm4 4h-12v-32h12z&quot; fill=&quot;#000000&quot; data-original=&quot;#000000&quot; class=&quot;&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m38.6777 52.0305c1.6851 2.493 2.357 6.6985 2.357 9.9925h4c0-3.5395-.6782-8.7339-3.0431-12.2326-1.2285-1.8176-3.0158-3.3189-5.4874-3.6989-2.4225-.3724-5.1076.3957-8.0352 2.239-.0358.0226-.0709.0463-.1053.0711-1.8313 1.3226-3.9833 4.1454-3.203 7.5327.7865 3.4142 4.2798 6.1709 10.8325 8.0139l1.083-3.8506c-6.2473-1.7571-7.754-3.917-8.0176-5.0611-.266-1.1549.458-2.5103 1.5991-3.3571 2.4414-1.5251 4.1261-1.8054 5.2387-1.6344 1.0721.1649 1.9849.8072 2.7813 1.9855z&quot; fill=&quot;#000000&quot; data-original=&quot;#000000&quot; class=&quot;&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m47.357 52.0305c-1.6851 2.493-2.357 6.6985-2.357 9.9925h-4c0-3.5395.6781-8.7339 3.043-12.2326 1.2286-1.8176 3.0158-3.3189 5.4875-3.6989 2.4224-.3724 5.1075.3957 8.0351 2.239.0359.0226.071.0463.1054.0711 1.8313 1.3226 3.9832 4.1454 3.203 7.5327-.7865 3.4142-4.2798 6.1709-10.8325 8.0139l-1.083-3.8506c6.2473-1.7571 7.754-3.917 8.0175-5.0611.2661-1.1549-.4579-2.5103-1.599-3.3571-2.4414-1.5251-4.1261-1.8054-5.2387-1.6344-1.0721.1649-1.9849.8072-2.7813 1.9855z&quot; fill=&quot;#000000&quot; data-original=&quot;#000000&quot; class=&quot;&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;path d=&quot;m17 30c-2.2091 0-4 1.7909-4 4v60c0 2.2091 1.7909 4 4 4h94c2.209 0 4-1.7909 4-4v-5.5l4 4v1.5c0 4.4183-3.582 8-8 8h-94c-4.4183 0-8-3.5817-8-8v-60c0-4.4183 3.5817-8 8-8h36.5l3.5 4z&quot; fill=&quot;#000000&quot; data-original=&quot;#000000&quot; class=&quot;&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m115 34c0-2.2091-1.791-4-4-4h-39l-4-4h43c4.418 0 8 3.5817 8 8v43l-4-4z&quot; fill=&quot;#000000&quot; data-original=&quot;#000000&quot; class=&quot;&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m66.8434 28h-9.7331l18.3733 18.5-.9834 4.6862-23.614-23.7769c-1.2532-1.2619-.3594-3.4093 1.4191-3.4093h15.3665c.5304 0 1.0391.2107 1.4142.5858l15.9142 15.9142-3 2.6569z&quot; fill=&quot;#000000&quot; data-original=&quot;#000000&quot; class=&quot;&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m116 87.296v-10.1391l-15.157-15.1569 2.657-3 15.914 15.9142c.375.3751.586.8838.586 1.4142v15.8196c0 1.7851-2.161 2.676-3.419 1.4094l-23.8924-24.0574 4.8116-.8315z&quot; fill=&quot;#000000&quot; data-original=&quot;#000000&quot; class=&quot;&quot;&gt;&lt;/path&gt;&lt;path clip-rule=&quot;evenodd&quot; d=&quot;m73.0002 49.373c0 .2652-.1053.5195-.2928.7071l-5.2132 5.2131c-.3905.3905-.3905 1.0237 0 1.4142l5.2132 5.2132c.1875.1875.2928.4418.2928.7071v7.3726c0 .5523.4478 1 1 1h7.3727c.2652 0 .5196.1054.7071.2929l5.2132 5.2132c.3905.3905 1.0237.3905 1.4142 0l5.2132-5.2132c.1876-.1875.4419-.2929.7071-.2929h7.3723c.553 0 1-.4477 1-1v-7.3725c0-.2652.106-.5196.293-.7071l5.213-5.2133c.391-.3905.391-1.0237 0-1.4142l-5.213-5.2133c-.187-.1875-.293-.4419-.293-.7071v-7.3725c0-.5523-.447-1-1-1h-7.3723c-.2652 0-.5195-.1053-.7071-.2929l-5.2132-5.2132c-.3905-.3905-1.0237-.3905-1.4142 0l-5.2132 5.2132c-.1875.1876-.4419.2929-.7071.2929h-7.3727c-.5522 0-1 .4477-1 1zm5-4.3727c-.5522 0-1 .4477-1 1v5.0295c0 .2652-.1053.5196-.2928.7071l-3.5563 3.5563c-.3906.3905-.3906 1.0237 0 1.4142l3.5563 3.5563c.1875.1875.2928.4419.2928.7071v5.0295c0 .5523.4478 1 1 1h5.0296c.2652 0 .5195.1054.7071.2929l3.5563 3.5564c.3905.3905 1.0237.3905 1.4142 0l3.5564-3.5564c.1875-.1875.4419-.2929.7071-.2929h5.0293c.5523 0 1-.4477 1-1v-5.0294c0-.2652.1054-.5195.2929-.7071l3.5569-3.5564c.39-.3905.39-1.0237 0-1.4142l-3.5569-3.5564c-.1875-.1875-.2929-.4419-.2929-.7071v-5.0294c0-.5523-.4477-1-1-1h-5.0293c-.2652 0-.5196-.1053-.7071-.2929l-3.5564-3.5563c-.3905-.3906-1.0237-.3906-1.4142 0l-3.5563 3.5563c-.1876.1876-.4419.2929-.7071.2929z&quot; fill-rule=&quot;evenodd&quot; data-original=&quot;#000000&quot; class=&quot;&quot;&gt;&lt;/path&gt; &lt;/g&gt; &lt;/g&gt; {%- endcase -%} &lt;/svg&gt; &lt;/div&gt; </code></pre> <p>From there I have created a code to dynamically <code>render</code> the icon SVG based on the <code>variable</code>. The variable is based on the menu items title.</p> <pre><code>{% for link in section.settings.link_list.links %} {% capture icon %} {{ link.title | downcase | replace: &quot; &quot;, &quot;&quot; | remove: &quot;&amp;&quot; }} {% endcapture %} {% render 'icon', icon: icon %} &lt;a href=&quot;{{ link.url }}&quot; class=&quot;&quot; role=&quot;button&quot; data-bs-toggle=&quot;dropdown&quot;&gt; {{ link.title }} &lt;/a&gt; {% endfor %} </code></pre> <p>I seem to receive the correct output, as the class in the SVG file is loaded with the link title, its just the <code>case</code> code doesn't seem to render the SVG content?</p> <p><a href="https://i.stack.imgur.com/pB1H8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pB1H8.png" alt="Description" /></a></p>
[ { "answer_id": 74251152, "author": "Anake.me", "author_id": 1473559, "author_profile": "https://Stackoverflow.com/users/1473559", "pm_score": 0, "selected": false, "text": "case" }, { "answer_id": 74254120, "author": "David Lazar", "author_id": 210841, "author_profile...
2022/10/30
[ "https://Stackoverflow.com/questions/74250338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1473559/" ]
74,250,346
<p>Given a sequence U1, U2, U3,... and the rule is Ui = U(i-1) - 2*U(i-2) given the natural number n find Un</p> <p>Here's my approach</p> <pre><code>n = int(input()) u1 = 1 u2 = 1 for i in range(n//2-1): s = u2 - 2*u1 t = s - 2*u2 u1 = s u2 = t if n == 3: print(-1) elif n % 2 != 0: print(s) else: print(t) </code></pre> <p>example give n = 3 then the output will be -1 this works for small number but as the n get bigger it's not correct Can anyone help?</p>
[ { "answer_id": 74251152, "author": "Anake.me", "author_id": 1473559, "author_profile": "https://Stackoverflow.com/users/1473559", "pm_score": 0, "selected": false, "text": "case" }, { "answer_id": 74254120, "author": "David Lazar", "author_id": 210841, "author_profile...
2022/10/30
[ "https://Stackoverflow.com/questions/74250346", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19511880/" ]
74,250,361
<p>I have two 2d arrays of type Array&lt;Array&gt;, but when I combine it with plus method I get output like:</p> <pre><code>cells.plus(states.last().board.cells) —&gt; My output (cells here is my array of Array&lt;Array&lt;Char&gt;&gt;) | | | X | | | |X | | | | | </code></pre> <p>How to merge it correctly?</p> <p>For example I have:</p> <pre><code>val board3x3Array = arrayOf( arrayOf(' ', ' ', ' '), arrayOf(' ', 'X', ' '), arrayOf(' ', ' ', '0') ) val board3x3Array2 = arrayOf( arrayOf('0', ' ', ' '), arrayOf(' ', ' ', ' '), arrayOf(' ', ' ', ' ') ) And I need after merge: val merged = arrayOf( arrayOf('0', ' ', ' '), arrayOf(' ', 'X', ' '), arrayOf(' ', ' ', '0') ) </code></pre>
[ { "answer_id": 74250491, "author": "lablnet", "author_id": 12175903, "author_profile": "https://Stackoverflow.com/users/12175903", "pm_score": 3, "selected": true, "text": "val mergedArray = board3x3Array2.mapIndexed { index, array ->\n array.mapIndexed { index2, c ->\n if (c =...
2022/10/30
[ "https://Stackoverflow.com/questions/74250361", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12360652/" ]
74,250,385
<p><code>Uncaught (in promise) TypeError: Cannot set properties of undefined (setting '0')</code></p> <p>Hi, in this code block I get the error as mentioned above because of this line -&gt; <code>result.data[j][i] = matrix.data[i][j].</code></p> <p>I try to call a static transpose method and pass it a matrix, that is already created. For some reason, it throws an error that the given matrix is <strong>undefined</strong> even though it isn't, or is it?</p> <pre><code>static transpose(matrix) { let result = new Matrix(this.cols, this.rows); for (let i = 0; i &lt; matrix.rows; i++) { for (let j = 0; j &lt; matrix.cols; j++) { result.data[j][i] = matrix.data[i][j]; } } return result; } </code></pre> <p>I'm following a neural network playlist by daniel Shiffman, and I got the error on this episode linked below.</p> <p><a href="https://youtu.be/r2-P1Fi1g60?list=PLRqwX-V7Uu6aCibgK1PTWWu9by6XFdCfh" rel="nofollow noreferrer">https://youtu.be/r2-P1Fi1g60?list=PLRqwX-V7Uu6aCibgK1PTWWu9by6XFdCfh</a></p> <p>I've been stuck with this for so long, so thank you in advance.</p> <p>Since I'm new to js, I thought passing values or references might not work the same as in Java. So I tried creating a test matrix inside the method but still, it threw the same problem that it is undefined.</p> <pre><code>static transpose(matrix) { let test = new Matrix(2,2); let result = new Matrix(this.cols, this.rows); for (let i = 0; i &lt; matrix.rows; i++) { for (let j = 0; j &lt; matrix.cols; j++) { result.data[j][i] = test.data[i][j]; } } return result; } </code></pre>
[ { "answer_id": 74250491, "author": "lablnet", "author_id": 12175903, "author_profile": "https://Stackoverflow.com/users/12175903", "pm_score": 3, "selected": true, "text": "val mergedArray = board3x3Array2.mapIndexed { index, array ->\n array.mapIndexed { index2, c ->\n if (c =...
2022/10/30
[ "https://Stackoverflow.com/questions/74250385", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20369155/" ]
74,250,403
<p>Doing cs50w and I'm on the JS lecture. The assignment is to create a list of tasks, and everything in my code works, except that it doesn't append to the end of the <code>&lt;ul&gt;</code> and create a <code>&lt;li&gt;</code>. <code>document.querySelector('#button').disabled = true</code> still works, but the <code>append(li)</code> doesn't work.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>document.addEventListener('DOMContentLoaded', () =&gt; { document.querySelector('#submit').disabled = true; document.querySelector('#task').onkeyup = () =&gt; { if (document.querySelector('#task').value.length &gt; 0) { document.querySelector('#submit').disabled = false; } else { document.querySelector('#submit').disabled = true; } } document.querySelector('form').onsubmit = function() { const task = document.querySelector('#task').value; const li = document.createElement('li'); li.innerHTML = task; document.querySelector('#task').append(li); document.querySelector('#task').value = null; document.querySelector('#button').disabled = true; return false; } });</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;h1&gt;Tasks&lt;/h1&gt; &lt;ul id="tasks"&gt;&lt;/ul&gt; &lt;form&gt; &lt;input type="text" placeholder="Create a new task" id="task"&gt; &lt;input type="submit" id="submit"&gt; &lt;/form&gt;</code></pre> </div> </div> </p> <p>I tried to fix the code with some friends and they didn't fix it, and I also compared the instructor's code and my own, so I am now asking the internet.</p>
[ { "answer_id": 74250491, "author": "lablnet", "author_id": 12175903, "author_profile": "https://Stackoverflow.com/users/12175903", "pm_score": 3, "selected": true, "text": "val mergedArray = board3x3Array2.mapIndexed { index, array ->\n array.mapIndexed { index2, c ->\n if (c =...
2022/10/30
[ "https://Stackoverflow.com/questions/74250403", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19954483/" ]
74,250,435
<p>I am writing a function and I’m trying to ensure that it is type-stable and allocation-free. I am using the @code_warntype to check for type-stability and @btime to determine memory allocation.</p> <p>Here is my function:</p> <pre><code># we assume u is a 2 x num_particles matrix function rhs!(du, u, parameters, t) C = parameters v_x(x, y, t) = -sin(pi * y) * cos(pi * t / C) v_y(x, y, t) = sin(pi * x) * cos(pi * t / C) num_particles = size(u, 2) for i in 1:num_particles C = parameters du[1, i] = v_x(u[1, i], u[2, i], t) du[2, i] = v_y(u[1, i], u[2, i], t) end end using BenchmarkTools; @btime rhs!(du,u,parameters,t) @code_warntype rhs!(du,u,parameters,t) </code></pre> <p>How do I modify the function to make it allocation free and type-stable?</p>
[ { "answer_id": 74250934, "author": "August", "author_id": 2498956, "author_profile": "https://Stackoverflow.com/users/2498956", "pm_score": 0, "selected": false, "text": "C" }, { "answer_id": 74252859, "author": "AboAmmar", "author_id": 3943170, "author_profile": "htt...
2022/10/30
[ "https://Stackoverflow.com/questions/74250435", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20354019/" ]
74,250,442
<p>Is there anyone else who faced the issues just like me? I try to make a GET request to my API endpoint it keeps on returning 404 when the application is deployed on Vercel - <strong>it works perfectly fine on locally</strong>.</p> <p><a href="https://i.stack.imgur.com/DaElo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DaElo.png" alt="Get an 404 page while I'd call the api endpoint" /></a></p> <p>Even it is a simple api that are provided by the Next.JS by default.</p> <p><strong>default api location</strong>: pages/api/hello</p> <pre><code>export default async function handler(req, res) { res.status(200).json({ name: 'John Doe', }) </code></pre> <p>}</p> <p><strong>My package.json</strong></p> <pre><code>{ &quot;name&quot;: &quot;my-next-js-sample&quot; &quot;version&quot;: &quot;0.1.1&quot;, &quot;private&quot;: true, &quot;scripts&quot;: { &quot;dev&quot;: &quot;next dev&quot;, &quot;build&quot;: &quot;next build&quot;, &quot;start&quot;: &quot;next start&quot;, &quot;lint&quot;: &quot;next lint&quot; }, &quot;dependencies&quot;: { &quot;axios&quot;: &quot;^1.1.3&quot;, &quot;cheerio&quot;: &quot;^1.0.0-rc.12&quot;, &quot;dayjs&quot;: &quot;^1.11.6&quot;, &quot;firebase&quot;: &quot;^9.13.0&quot;, &quot;next&quot;: &quot;13.0.0&quot;, &quot;react&quot;: &quot;18.2.0&quot;, &quot;react-dom&quot;: &quot;18.2.0&quot; }, &quot;devDependencies&quot;: { &quot;eslint&quot;: &quot;8.26.0&quot;, &quot;eslint-config-next&quot;: &quot;13.0.0&quot; } </code></pre> <p>}</p> <p><strong>This is how I'd structured my folders.</strong></p> <p><a href="https://i.stack.imgur.com/GftZI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GftZI.png" alt="enter image description here" /></a></p> <p><strong>This is how'd called the api routes.</strong></p> <pre><code>http://localhost:3000/api/hello http://localhost:3000/api/v2/live </code></pre> <p>Perfectly can call any api routes just like this example in local development.</p> <p><a href="https://i.stack.imgur.com/ynm3P.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ynm3P.png" alt="enter image description here" /></a></p> <p><strong>Vercel Project Settings</strong></p> <p><a href="https://i.stack.imgur.com/tVUcd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tVUcd.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74250934, "author": "August", "author_id": 2498956, "author_profile": "https://Stackoverflow.com/users/2498956", "pm_score": 0, "selected": false, "text": "C" }, { "answer_id": 74252859, "author": "AboAmmar", "author_id": 3943170, "author_profile": "htt...
2022/10/30
[ "https://Stackoverflow.com/questions/74250442", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8687567/" ]
74,250,454
<p>I'm trying to connect my app service plan in to VNET. But always failed. I have red threads and everywhere saying App service plan should be Standard or higher.</p> <ol> <li>My App service Plan is S1.</li> <li>It's just an empty app.</li> <li>I'm creating new subnet (not select existing one) when configuring VNET.</li> <li>I have run the trouble-shooter and no issue found with connectivity</li> </ol> <p>Can someone help on this?</p> <p><a href="https://i.stack.imgur.com/SZes2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SZes2.png" alt="enter image description here" /></a> <a href="https://i.stack.imgur.com/SFi42.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SFi42.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74250934, "author": "August", "author_id": 2498956, "author_profile": "https://Stackoverflow.com/users/2498956", "pm_score": 0, "selected": false, "text": "C" }, { "answer_id": 74252859, "author": "AboAmmar", "author_id": 3943170, "author_profile": "htt...
2022/10/30
[ "https://Stackoverflow.com/questions/74250454", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2408266/" ]
74,250,466
<p>I am saving my jwt token secret into the <code>.env</code> file.</p> <pre><code>JWT_SECRET=&quot;secretsecret&quot; </code></pre> <p>Now when I try to fetch the value using <code>process.env.JWT_SECRET</code> I get error as</p> <pre><code>Argument of type 'string | undefined' is not assignable to parameter of type 'Secret' </code></pre> <p>I am trying to learn typescript but facing this issue with <code>.env</code> please guide me.</p>
[ { "answer_id": 74250487, "author": "Franco Agustín Torres", "author_id": 20318366, "author_profile": "https://Stackoverflow.com/users/20318366", "pm_score": 2, "selected": false, "text": ".env" }, { "answer_id": 74250799, "author": "Vishal Goyal", "author_id": 7390321, ...
2022/10/30
[ "https://Stackoverflow.com/questions/74250466", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17348251/" ]
74,250,502
<p>I'm asking a user to input a number from the keyboard. For example users input 190, How can I compare 190 that user input to the value of the dictionary with the same value? is it equal or not?</p> <p>This is my code:</p> <pre><code>my_dict = {'apple': [900, 190], 'orange': [1300, 90], 'pineapple': [550, 13], 'carrot': [600, 60], 'cucumber': [900, 30], 'egg plant': [1100, 20], 'zucchini': [1300, 10], 'garlic': [300, 70]} for key, value in my_dict: usernumber = input('Input your number: ') if usernumber == value: print(&quot;Equal&quot;) else: print(&quot;Not equal&quot;) </code></pre> <p>For example, if users input the number 190, how can I check this value is in dictionary or not</p>
[ { "answer_id": 74250487, "author": "Franco Agustín Torres", "author_id": 20318366, "author_profile": "https://Stackoverflow.com/users/20318366", "pm_score": 2, "selected": false, "text": ".env" }, { "answer_id": 74250799, "author": "Vishal Goyal", "author_id": 7390321, ...
2022/10/30
[ "https://Stackoverflow.com/questions/74250502", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20362914/" ]
74,250,507
<p>Let's say I have a function called <code>linksToAnotherPage</code> that receives an href. How can I check if the href takes you to another page or if it is a <code>tel:</code> , <code>mailto:</code>, <code>#anchor-link</code>, etc that does not take you to another page?</p> <pre><code>function linksToAnotherPage(href) { .... } linksToAnotherPage('tel:123-456-7890') -&gt; // false linksToAnotherPage('contact') -&gt; // true </code></pre> <p>--</p> <pre><code>// does not link to another page &lt;a href=&quot;tel:123-456-7890&quot;&gt;123-456-7890&lt;/a&gt; &lt;a href=&quot;mailto:email@example.com&quot;&gt;Send Email&lt;/a&gt; &lt;a href=&quot;#start-now&quot;&gt;Start Now&lt;/a&gt; // links to another page &lt;a href=&quot;contact&quot;&gt;Send Email&lt;/a&gt; </code></pre> <p>--</p> <p>UPDATE: here is my current solution based on the answers received</p> <pre><code> function isInteractiveHref (href) { return ( href.startsWith(&quot;mailto:&quot;) || href.startsWith(&quot;tel:&quot;) || href.startsWith(&quot;#&quot;) ) } isInteractiveHref(props.href) ? ( &lt;Link href={props.href}&gt; &lt;a&gt;Does not link to another page&lt;/a&gt; &lt;/Link&gt; ) : &lt;Link href={'/' + props.href}&gt; &lt;a&gt; Links to another page&lt;/a&gt; &lt;/Link&gt; </code></pre>
[ { "answer_id": 74250525, "author": "Amirhossein Sefati", "author_id": 11856099, "author_profile": "https://Stackoverflow.com/users/11856099", "pm_score": 1, "selected": false, "text": "function linksToAnotherPage(href) {\n if (href.startsWith(\"/\") || href.startsWith(\"http://\" || hr...
2022/10/30
[ "https://Stackoverflow.com/questions/74250507", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19666029/" ]
74,250,532
<p><strong>Can you please help me change my code from current output to expected output?</strong> I am using apply() function of dataframe. It would be great if it could also be done more efficiently using vector operation.</p> <p><strong>Current output:</strong></p> <pre><code> col1 col2 serialno 0 100 0 4 1 100 100 0 2 100 100 0 3 200 100 4 4 200 200 0 5 300 200 4 6 300 300 0 </code></pre> <p><strong>Expected output:</strong></p> <pre><code> col1 col2 serialno 0 100 0 4 1 100 100 4 2 100 100 4 3 200 100 5 4 200 200 5 5 300 200 6 6 300 300 6 </code></pre> <p>My current code contains a static value (4). I need to increment it by one based on a condition (col1 != col2). In addition, I need to repeat the serial no for all rows that meet the condition (col1 == col2).</p> <p><strong>My code:</strong></p> <pre><code>import pandas as pd columns = ['col1'] data = ['100','100','100','200','200','300','300'] df = pd.DataFrame(data=data,columns=columns) df['col2'] = df.col1.shift(1).fillna(0) print(df) start = 4 series = (df['col1']!=df['col2']).apply(lambda x: start if x==True else 0) df['serialno'] = series print(df) </code></pre>
[ { "answer_id": 74250602, "author": "assume_irrational_is_rational", "author_id": 11622508, "author_profile": "https://Stackoverflow.com/users/11622508", "pm_score": 1, "selected": false, "text": "import itertools\nstart = 4\ncounter = itertools.count(start) # to have incremental counter\...
2022/10/30
[ "https://Stackoverflow.com/questions/74250532", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20268123/" ]
74,250,560
<p>When the <code>qusrjobi</code> API is called from an SQL procedure, both the return data and return error output parameters are returned as blanks.</p> <pre><code>declare vData char(2000) default ' ' ; declare vDataLx int default 0 ; declare vFmtName char(8) default ' ' ; declare vJob char(26) default ' ' ; declare vJobId char(16) default ' ' ; declare VRESETFLAG char(1) default ' ' ; declare vErr char(2000) default ' ' ; declare VJOBNAME char(10) default ' ' ; set vDataLx = 2000 ; set vFmtName = 'JOBI0100' ; set vJob = '*' ; set vJobId = ' ' ; set vErr = x'000007D0' ; SET VRESETFLAG = '0' ; call qusrjobi( vData, vDataLx, vFmtName, vJob, vJobId, vErr, VRESETFLAG ) ; SET VJOBNAME = SUBSTR(VDATA,9,10) ; SET VERRMSG = SUBSTR(VERR,9,80) ; CALL SYSTOOLS.LPRINTF( 'QUSRJOBI. JOBNAME:' || VJOBNAME || ' ERRMSG:' || RTRIM(VERRMSG)) ; </code></pre> <p>The same SQL procedure code can successfully call an RPG program with the same parameters, where the RPG in turn calls <code>qusrjobi</code> and returns the results.</p> <pre><code>set vDataLx = 2000 ; set vFmtName = 'JOBI0100' ; set vJob = '*' ; set vJobId = ' ' ; set vErr = x'000007D0' ; SET VRESETFLAG = '0' ; call TESTRPG( vData, vDataLx, vFmtName, vJob, vJobId, vErr, VRESETFLAG ) ; SET VJOBNAME = SUBSTR(VDATA,9,10) ; CALL SYSTOOLS.LPRINTF( 'TESTRPG. JOBNAME:' || VJOBNAME ) ; </code></pre> <p>Here is the SQL procedure being called from <code>qcmd</code>:</p> <pre><code>&gt; call testsql TESTRPG. JOBNAME:STEVE28 ERRMSG: QUSRJOBI. JOBNAME: ERRMSG: </code></pre> <p>the RPG program has the same set of parameters as the API:</p> <pre><code>h option(*SrcStmt) ** ------------------------ testrpg ----------------------------- d testrpg pr extpgm('TESTRPG') d outData 2000a d inDataLx 10i 0 const d inFmtName 8a const d inJOb 26a const d inJobId 16a const d inErr 2000a d inResetFlag 1a ** ---------------------- pr_qusrJobi ------------------------------- ** QusrJobi - retrieve job information dpr_qusrjobi pr extpgm('QUSRJOBI') d OutRcv 2000a d InRcvLx 10i 0 const d InFmtName 8a const d InJob 26a const d InJobId 16a const d OutError 2000a d InReset 1a const ** ------------------------ testrpg ------------------------ d testrpg pi d outData 2000a d inDataLx 10i 0 const d inFmtName 8a const d inJOb 26a const d inJobId 16a const d inErr 2000a d inResetFlag 1a /free pr_qusrjobi( outData: inDataLx: inFmtName: inJob: inJobId: inErr: inResetFlag ) ; *inlr = '1' ; return ; /end-free </code></pre> <p>Why would this SQL procedure not be able to successfully call the <code>qusrjobi</code> api when it can call an RPG program with the same set of parameters?</p> <p>Here is the full code of the SQL procedure:</p> <pre><code>CREATE or replace PROCEDURE testsql( ) LANGUAGE SQL SPECIFIC testsql SET OPTION DATFMT = *ISO, DLYPRP = *YES, DBGVIEW = *SOURCE, USRPRF = *OWNER, DYNUSRPRF = *OWNER, COMMIT = *CHG BEGIN declare sqlCode int DEFAULT 0 ; declare vSqlCode decimal(5,0) ; declare vSqlState char(5) ; declare vErrText varchar(2000) ; declare sqlState char(5) ; declare vData char(2000) default ' ' ; declare vDataLx int default 0 ; declare vFmtName char(8) default ' ' ; declare vJob char(26) default ' ' ; declare vJobId char(16) default ' ' ; declare VRESETFLAG char(1) default ' ' ; declare vErr char(2000) default ' ' ; declare VJOBNAME char(10) default ' ' ; declare VERRMSG char(80) default ' ' ; DECLARE CONTINUE HANDLER FOR SQLEXCEPTION begin SET vSqlCode = SQLCODE ; SET vSqlState = SQLstate ; get diagnostics exception 1 vErrText = message_text ; CALL SYSTOOLS.LPRINTF( 'ERROR:' || VERRTEXT ) ; end ; set vDataLx = 2000 ; set vFmtName = 'JOBI0100' ; set vJob = '*' ; set vJobId = ' ' ; set vErr = x'000007D0' ; SET VRESETFLAG = '0' ; call TESTRPG( vData, vDataLx, vFmtName, vJob, vJobId, vErr, VRESETFLAG ) ; SET VJOBNAME = SUBSTR(VDATA,9,10) ; SET VERRMSG = SUBSTR(VERR,9,80) ; CALL SYSTOOLS.LPRINTF( 'TESTRPG. JOBNAME:' || VJOBNAME || ' ERRMSG:' || RTRIM(VERRMSG)) ; set vDataLx = 2000 ; set vFmtName = 'JOBI0100' ; set vJob = '*' ; set vJobId = ' ' ; set vErr = x'000007D0' ; SET VRESETFLAG = '0' ; call qusrjobi( vData, vDataLx, vFmtName, vJob, vJobId, vErr, VRESETFLAG ) ; SET VJOBNAME = SUBSTR(VDATA,9,10) ; SET VERRMSG = SUBSTR(VERR,9,80) ; CALL SYSTOOLS.LPRINTF( 'QUSRJOBI. JOBNAME:' || VJOBNAME || ' ERRMSG:' || RTRIM(VERRMSG)) ; END </code></pre>
[ { "answer_id": 74250602, "author": "assume_irrational_is_rational", "author_id": 11622508, "author_profile": "https://Stackoverflow.com/users/11622508", "pm_score": 1, "selected": false, "text": "import itertools\nstart = 4\ncounter = itertools.count(start) # to have incremental counter\...
2022/10/30
[ "https://Stackoverflow.com/questions/74250560", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5484737/" ]
74,250,570
<p>I had a docker file that was working fine. However to remote debug it , I read that I needed to install <code>dlv</code> on it and then I need to run dlv and pass the parameter of the app I am trying to debug. So after installing dlv on it and attempting to run it. I get the error</p> <pre><code>exec /dlv: no such file or directory </code></pre> <p>This is the docker file</p> <pre><code> FROM golang:1.18-alpine AS builder # Build Delve for debugging RUN go install github.com/go-delve/delve/cmd/dlv@latest # Create and change to the app directory. WORKDIR /app ENV CGO_ENABLED=0 # Retrieve application dependencies. COPY go.* ./ RUN go mod download # Copy local code to the container image. COPY . ./ # Build the binary. RUN go build -gcflags=&quot;all=-N -l&quot; -o fooapp # Use the official Debian slim image for a lean production container. FROM debian:buster-slim EXPOSE 8000 40000 RUN set -x &amp;&amp; apt-get update &amp;&amp; DEBIAN_FRONTEND=noninteractive apt-get install -y \ ca-certificates &amp;&amp; \ rm -rf /var/lib/apt/lists/* # Copy the binary to the production image from the builder stage. #COPY --from=builder /app/fooapp /app/fooapp #commented this out COPY --from=builder /go/bin/dlv /dlv # Run dlv as pass fooapp as parameter CMD [&quot;/dlv&quot;, &quot;--listen=:40000&quot;, &quot;--headless=true&quot;, &quot;--api-version=2&quot;, &quot;--accept-multiclient&quot;, &quot;exec&quot;, &quot;/app/fooapp&quot;] </code></pre> <p>The above results in <code>exec /dlv: no such file or directory</code></p> <p>I am not sure why this is happening. Being new to docker , I have tried different ways to debug it. I tried using <code>dive</code> to check and see if the image has <code>dlv</code> on it in the path <code>/dlv</code> and it does. I have also attached an image of it</p> <p><a href="https://i.stack.imgur.com/CSfKz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CSfKz.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74251529, "author": "David Chen", "author_id": 6355435, "author_profile": "https://Stackoverflow.com/users/6355435", "pm_score": 1, "selected": false, "text": "apt-get install musl" }, { "answer_id": 74252440, "author": "Pak Uula", "author_id": 9047589, ...
2022/10/30
[ "https://Stackoverflow.com/questions/74250570", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1305891/" ]
74,250,583
<p>I want for a number n for their to be a list starting off of n and decreasing to one as elements in the list. If n was 4, the list would be: [[0, 0, 0, 0][0, 0, 0][0, 0,][0]]</p> <pre><code>triangle = [] for i in range(n): for k in range(i): triangle.append(0) </code></pre> <p>That just gave out for input n = 5,</p> <pre><code>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0] </code></pre>
[ { "answer_id": 74250608, "author": "Abhijit Sarkar", "author_id": 839733, "author_profile": "https://Stackoverflow.com/users/839733", "pm_score": 0, "selected": false, "text": "n = 4\ntriangles = [[0] * x for x in range(n, 0, -1)]\n\nprint(triangles)\n" }, { "answer_id": 74250624...
2022/10/30
[ "https://Stackoverflow.com/questions/74250583", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20369427/" ]
74,250,597
<p>I am trying to build this simple text to speech feature using flutter_tts package but it doesn't speak no matter what I tried (official example, tutorials, etc.)</p> <p>I checked my Audio Output, it's set correctly. I have other MP3 sounds, they play just fine.</p> <p>I tried <code>^3.5.0</code> and <code>^3.5.3</code> versions, neither worked.</p> <p>Here is my code:</p> <pre class="lang-dart prettyprint-override"><code>class ColorsScreen extends StatefulWidget { const ColorsScreen({super.key, required this.title}); final String title; @override State&lt;ColorsScreen&gt; createState() =&gt; _ColorsScreenState(); } class _ColorsScreenState extends State&lt;ColorsScreen&gt; { late FlutterTts flutterTts; bool isPlaying = false; String _currentColor = &quot;black&quot;; String get currentColorName =&gt;_currentColor; @override void initState() { super.initState(); initTts(); flutterTts.setStartHandler(() { setState(() { isPlaying = true; }); }); flutterTts.setCompletionHandler(() { setState(() { isPlaying = false; }); }); } initTts() async { flutterTts = FlutterTts(); } Future _readColorName() async { await flutterTts.setVolume(1); await flutterTts.setSpeechRate(1); await flutterTts.setPitch(1); var result = await flutterTts.speak(currentColorName); if (result == 1) { setState(() { isPlaying = true; }); } } @override void dispose() { super.dispose(); flutterTts.stop(); } @override Widget build(BuildContext context) { return Scaffold( appBar: TopBar(widget.title), body: IconButton( padding: const EdgeInsets.all(0), icon: const Icon( Icons.play_circle_fill_rounded, color: Colors.red, size: 50, semanticLabel: 'Play color name', ), onPressed: _readColorName, ), ); } } </code></pre>
[ { "answer_id": 74250608, "author": "Abhijit Sarkar", "author_id": 839733, "author_profile": "https://Stackoverflow.com/users/839733", "pm_score": 0, "selected": false, "text": "n = 4\ntriangles = [[0] * x for x in range(n, 0, -1)]\n\nprint(triangles)\n" }, { "answer_id": 74250624...
2022/10/30
[ "https://Stackoverflow.com/questions/74250597", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7011860/" ]
74,250,604
<p>In trying to answer this <a href="https://stackoverflow.com/questions/74250292/command-works-in-shell-but-not-in-a-script">question</a>, I came up with this solution, which works:</p> <pre><code>#!/bin/bash testor=$(shopt | grep extglob | awk '{ print $2 }' ) if [ &quot;${testor}&quot; = &quot;off&quot; ] then shopt -s extglob shopt | grep extglob fi ls ./WORKS/@(*.sh|*.dat|*.txt) </code></pre> <p>and the output is this:</p> <pre><code>ericthered@OasisMega1:/0__WORK$ ./junk_37.sh extglob on ./WORKS/abc_junk_def.txt ./WORKS/junk_007.sh ./WORKS/junk_28.sh ./WORKS/assignListToBashArray.sh ./WORKS/junk_008.sh ./WORKS/junk_28.txt ./WORKS/awkEmbeddedFunction.sh ./WORKS/junk_009.sh ./WORKS/junk_29.dat ./WORKS/droneConnectWiFi.sh ./WORKS/junk_010.sh ./WORKS/junk_29.sh ./WORKS/expandNumericDirectories.sh ./WORKS/junk_011.sh ./WORKS/junk_30.sh ./WORKS/findMatchOnEmbeddedFilename.sh ./WORKS/junk_012.sh ./WORKS/junk_31.sh ./WORKS/junk_001.sh ./WORKS/junk_013.sh ./WORKS/musicplayer.sh ./WORKS/junk_002.sh ./WORKS/junk_014.sh ./WORKS/prototypeEditorWrapper.sh ./WORKS/junk_003.sh ./WORKS/junk_015.sh ./WORKS/prototypeSendmailWrapper.sh ./WORKS/junk_004.sh ./WORKS/junk_26.dat ./WORKS/reportNotLowercase.sh ./WORKS/junk_005.sh ./WORKS/junk_26.sh ericthered@OasisMega1:/0__WORK$ </code></pre> <p><strong>But</strong> ... if instead, I use the following line,</p> <pre><code>ls @(./WORKS/*.sh|./WORKS/*.dat|./WORKS/*.txt) </code></pre> <p>it reports this error:</p> <pre><code>ls: cannot access '@(./WORKS/*.sh|./WORKS/*.dat|./WORKS/*.txt)': No such file or directory </code></pre> <p>I would appreciate someone providing insights as to why the two forms are not equivalent.</p>
[ { "answer_id": 74250608, "author": "Abhijit Sarkar", "author_id": 839733, "author_profile": "https://Stackoverflow.com/users/839733", "pm_score": 0, "selected": false, "text": "n = 4\ntriangles = [[0] * x for x in range(n, 0, -1)]\n\nprint(triangles)\n" }, { "answer_id": 74250624...
2022/10/30
[ "https://Stackoverflow.com/questions/74250604", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9716110/" ]
74,250,612
<p>I have a text file containing number integer and string value pairs I want to sort them in ascending order but I am not getting it correct</p> <p>**TextFile.txt **</p> <pre><code>87,Toronto 45,USA 45,PAKISTAN 33,India 38,Jerry 30,Tom 23,Jim 7,Love 38,Hate 30,Stress </code></pre> <p><strong>My code</strong></p> <pre><code>def sort_outputFiles(): print('********* Sorting now **************') my_file = open(&quot;TextFile.txt&quot;, &quot;r&quot;,encoding='utf-8') data = my_file.read() data_into_list = data.split(&quot;\n&quot;) my_file.close() score=[] links=[] for d in data_into_list: if d != '': s=d.split(',') score.append(s[0]) links.append(s[1]) n = len(score) for i in range(n): for j in range(0, n-i-1): if score[j] &lt; score[j+1]: score[j], score[j+1] = score[j+1], score[j] links[j], links[j+1] = links[j+1], links[j] for l,s in zip(links,score): print(l,&quot; &quot;,s) </code></pre> <p><strong>My output</strong></p> <pre><code>********* Sorting now ************** Toronto 87 Love 7 USA 45 PAKISTAN 45 Jerry 38 Hate 38 India 33 Tom 30 Stress 30 Jim 23 </code></pre> <p><strong>Expected output</strong></p> <pre><code>********* Sorting now ************** Toronto 87 USA 45 PAKISTAN 45 Jerry 38 Hate 38 India 33 Tom 30 Stress 30 Jim 23 Love 7 </code></pre> <p>having error at line 2 in out put it should be in last</p>
[ { "answer_id": 74250608, "author": "Abhijit Sarkar", "author_id": 839733, "author_profile": "https://Stackoverflow.com/users/839733", "pm_score": 0, "selected": false, "text": "n = 4\ntriangles = [[0] * x for x in range(n, 0, -1)]\n\nprint(triangles)\n" }, { "answer_id": 74250624...
2022/10/30
[ "https://Stackoverflow.com/questions/74250612", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16887243/" ]
74,250,623
<p>When creating elements using a loop and adding a class to them, should I first declare the variable outside the loop?</p> <p>For example:</p> <pre><code>const mainContainer = document.queryselector('.main-container'); const arr = [1,2,3,4,5]; arr.forEach((num)=&gt; { const newEl = document.createElement('div'); newEl.innerHtml = num; mainContainer.appendChild(newEl); newEl.addEventListener('click',()=&gt; { window.open('google.com') }) }) </code></pre> <p>This would open 5 new tabs, but the only way I can access the element is inside the loop, should I delare newEl outside the loop and just change it with let?</p>
[ { "answer_id": 74250608, "author": "Abhijit Sarkar", "author_id": 839733, "author_profile": "https://Stackoverflow.com/users/839733", "pm_score": 0, "selected": false, "text": "n = 4\ntriangles = [[0] * x for x in range(n, 0, -1)]\n\nprint(triangles)\n" }, { "answer_id": 74250624...
2022/10/30
[ "https://Stackoverflow.com/questions/74250623", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19114966/" ]
74,250,643
<p>Below is my array</p> <pre><code>{ &quot;finalArray&quot;: [ {&quot;name&quot;: &quot;John&quot;}, {&quot;name&quot;: &quot;Pascal&quot;}, {&quot;name&quot;: &quot;Robert&quot;} ] } </code></pre> <p>But when I use console.log(finalArray) this is what I get</p> <pre><code>{ [ {&quot;name&quot;: &quot;John&quot;}, {&quot;name&quot;: &quot;Pascal&quot;}, {&quot;name&quot;: &quot;Robert&quot;} ] } </code></pre> <p>My question is how do I display the array with &quot;finalArray&quot; in console ?</p> <p>@symlink - Your solution worked for me but I would like to know how do I change this for your soultion</p> <pre><code>for (let i = 0; i &lt; names.length; i++) { finalArray.push({&quot;name&quot;: names[i]}); } </code></pre>
[ { "answer_id": 74250669, "author": "Varun Kaklia", "author_id": 18574568, "author_profile": "https://Stackoverflow.com/users/18574568", "pm_score": -1, "selected": false, "text": "const {finalArray} = myArray\nconst displayName = finalArray.map((name)=>name.name)\nconsole.log(displayName...
2022/10/30
[ "https://Stackoverflow.com/questions/74250643", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2119374/" ]
74,250,657
<p>I query the latitud and longitud from my database and stored these values in php using arrays. Since I have to use javaScript to use the Google API I pass the arrays to javaScript arrays but when I tried to make an addMarker function to pass the latitude and longitude, the marker is not being displayed. If there is a problem using the Json way to pass an php array i would ,ike to know too.</p> <p><code> var lat = &quot;[{&quot;latitude&quot;:&quot;-73.44282246117739&quot;},{&quot;latitude&quot;:&quot;-73.43353928556874&quot;},{&quot;latitude&quot;:&quot;-74.01881776353744&quot;},{&quot;latitude&quot;:&quot;-74.0188170929852&quot;}]&quot;; var lng = &quot;[{&quot;longitude&quot;:&quot;40.73354088144067&quot;},{&quot;longitude&quot;:&quot;40.76232657450102&quot;},{&quot;longitude&quot;:&quot;40.64831233555079&quot;},{&quot;longitude&quot;:&quot;40.648312844313715&quot;}]&quot;; var name = &quot;[{&quot;name&quot;:&quot;Saint Kilian&quot;},{&quot;name&quot;:&quot;Island Harvest&quot;},{&quot;name&quot;:&quot;Long Island Cares Inc&quot;},{&quot;name&quot;:&quot;City Harvest&quot;}]&quot;; var urls = &quot;[{&quot;url&quot;:&quot;https:\/\/stkilian.com\/&quot;},{&quot;url&quot;:&quot;https:\/\/www.islandharvest.org\/&quot;},{&quot;url&quot;:&quot;https:\/\/www.licares.org\/&quot;},{&quot;url&quot;:&quot;http:\/\/www.cityharvest.org\/&quot;}]&quot;; var map;</code></p> <p>`</p> <pre><code> This is the javascript Code &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Simple Map&lt;/title&gt; &lt;meta name=&quot;viewport&quot; content=&quot;initial-scale=1.0&quot;&gt; &lt;meta charset=&quot;utf-8&quot;&gt; &lt;style&gt; /* Always set the map height explicitly to define the size of the div * element that contains the map. */ #map { width: 600px; height: 400px; margin-left: 50%; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div id=&quot;map&quot;&gt;&lt;/div&gt; &lt;script&gt; var lat = &lt;?php echo json_encode($latitudes); ?&gt;; var lng = &lt;?php echo json_encode($longitudes); ?&gt;; var name = &lt;?php echo json_encode($names); ?&gt;; var urls = &lt;?php echo json_encode($urls); ?&gt;; var map; var latLong = {}; lat.forEach((element, index) =&gt; { latLong[element] = lng[index]; }); function initMap() { map = new google.maps.Map(document.getElementById('map'), { zoom: 9, center: {lat: 40.75296142342573 , lng: -73.42661893505269}, }); addMarker(latLong); function addMarker(){ console.log(myLatlng); var markerMap= new google.maps.Marker({ position: {myLatlng[0]}, map, }); const popUp = &quot;Hi&quot;; //Info Windows const detailWindow = new google.maps.InfoWindow({ content: popUp, ariaLabel: &quot;Food Bank&quot;, }); markerMap.addListener(&quot;click&quot;, ()=&gt;{ detailWindow.open({ anchor: markerMap, map, }); }); } } &lt;/script&gt; &lt;script src=&quot;https://maps.googleapis.com/maps/api /js?key=API_KEY&amp;callback=initMap&quot; async defer&gt;&lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>`</p> <p>For some reason only works with a static latitude and longitude.</p>
[ { "answer_id": 74250886, "author": "Naveen", "author_id": 20306839, "author_profile": "https://Stackoverflow.com/users/20306839", "pm_score": 1, "selected": true, "text": "Remember json_encode() parameter must be array or object." }, { "answer_id": 74283461, "author": "CrisB"...
2022/10/30
[ "https://Stackoverflow.com/questions/74250657", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20369487/" ]
74,250,665
<p>I am trying to create target group attachment to the instances. e.g. if there are 3 target groups and 2 instances, would like to attach 3 target groups to the 2 instances.</p> <p>Here is my code</p> <p><strong>instances</strong></p> <pre><code>resource &quot;aws_instance&quot; &quot;web_servers&quot; { ami = &quot;ami-1234&quot; instance_type = &quot;t3a.small&quot; subnet_id = module.vpc.private_subnets[0] key_name = aws_key_pair.keypair.key_name count = 2 root_block_device { volume_type = &quot;gp3&quot; volume_size = var.ws_storage encrypted = true delete_on_termination = true } tags = merge( { Name = &quot;${var.project}-${var.env}-ws-${count.index}&quot; }, var.tags ) } </code></pre> <p><strong>Target group attachment local variable</strong></p> <pre><code>locals { tg_attachments = distinct(flatten([ for tg in var.lb : [ for instance in aws_instance.web_servers : { tg_name = tg.tg_name tg_port = tg.listener_port tg_protocol = tg.protocol tg_instance = instance.id } ] ])) } </code></pre> <p><strong>target group attachment</strong></p> <pre><code>resource &quot;aws_lb_target_group_attachment&quot; &quot;ws_tg_attachement&quot; { depends_on = [ time_sleep.wait_30_seconds, aws_lb_listener.listener, aws_instance.web_servers, aws_lb_target_group.tg ] for_each = { for entry in local.tg_attachments: &quot;${entry.tg_name}-${entry.tg_port}-${entry.tg_instance}&quot; =&gt; entry } target_group_arn = aws_lb_target_group.tg[&quot;${each.value.tg_name}-${each.value.tg_port}&quot;].arn target_id = each.value.tg_instance port = each.value.tg_port } </code></pre> <p><strong>ERROR</strong></p> <pre><code>for_each = { for entry in local.tg_attachments: &quot;${entry.tg_name}-${entry.tg_port}-${entry.tg_instance}&quot; =&gt; entry } │ ├──────────────── │ │ local.tg_attachments is a list of object, known only after apply │ │ The &quot;for_each&quot; value depends on resource attributes that cannot be determined until apply, so Terraform cannot predict how many │ instances will be created. To work around this, use the -target argument to first apply only the resources that the for_each │ depends on. </code></pre>
[ { "answer_id": 74250886, "author": "Naveen", "author_id": 20306839, "author_profile": "https://Stackoverflow.com/users/20306839", "pm_score": 1, "selected": true, "text": "Remember json_encode() parameter must be array or object." }, { "answer_id": 74283461, "author": "CrisB"...
2022/10/30
[ "https://Stackoverflow.com/questions/74250665", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13712834/" ]
74,250,668
<p>if n=2</p> <pre><code>* * * * * * * * </code></pre> <p>if n=3</p> <pre><code>* * * * * * * * * * * * * * * * * * * * * * * * * * * </code></pre> <p>This code i written for. But this code is half this only print row and column not space condition.</p> <pre><code>n = int(input (&quot;: &quot;)) i = 0 for i in range (n**2): j = 0 for j in range (n): j+=1 print (&quot;* &quot; , end=&quot;&quot;) i+=1 print (&quot;&quot;) </code></pre>
[ { "answer_id": 74250834, "author": "ChamRun", "author_id": 14761615, "author_profile": "https://Stackoverflow.com/users/14761615", "pm_score": 2, "selected": true, "text": "i = 0" }, { "answer_id": 74250853, "author": "Giuseppe La Gualano", "author_id": 20249888, "aut...
2022/10/30
[ "https://Stackoverflow.com/questions/74250668", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20369506/" ]
74,250,675
<p>I've been battling with a script to upload photos for user comments. Needless to say, I'm new to PHP. I have it so it confirms the file is an image and then continues to check its size. It's all working except when the image exceeds the size I've set. It does absolutely nothing. Here's my code:</p> <pre class="lang-php prettyprint-override"><code>ini_set(&quot;display_errors&quot;,1); error_reporting(E_ALL); date_default_timezone_set('America/New_York'); $date = date('m-d-Y_h.i.s_a', time()); $target_path = &quot;/home/SOME_USER/WEB/SOME_SITE/comment/uploading/uploads/&quot;; $filename = $date. &quot;_&quot; .basename( $_FILES['uploadedfile']['name']); $ext = pathinfo($filename, PATHINFO_EXTENSION); $test = preg_replace('/\\.[^.\\s]{3,4}$/', '', $filename); $newName = bin2hex($test); $target_path = $target_path.&quot;&quot;. &quot;$newName.&quot;.$ext; if (is_uploaded_file($_FILES['uploadedfile']['tmp_name'])) { $mime_type = mime_content_type($_FILES['uploadedfile']['tmp_name']); $allowed_file_types = ['image/png', 'image/jpeg', 'image/gif']; if (! in_array($mime_type, $allowed_file_types)) { $url = &quot;./index.php&quot; . &quot;?&amp;message=Not an image&quot;; header('Location: '.$url); } else { echo ('made it to this part ?'); return proceed(); } } function proceed() { global $target_path; global $newName; global $ext; echo 'made it here. . .'; if(isset($_FILES['uploadedfile']['name'])) { if($_FILES['uploadedfile']['size'] &gt; 3145728) { //3mb) echo ('made it here #1'); $url = &quot;./index.php&quot; . &quot;?&amp;message=Too big !&quot;; header('Location: '.$url); } else { if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { $url = &quot;./index.php&quot; . &quot;?&amp;message=&quot;.$newName.&quot;.&quot;.$ext.&quot;&quot;; header('Location: '.$url); } else{ echo('Made it here'); $url = &quot;./index.php&quot; . &quot;?&amp;message=Too big !&quot;; header('Location: '.$url); } } } } </code></pre> <p>I know the code is probably pretty ugly and could be written a lot better, and I'll work on that when I get it working properly, but I'm stuck here. Again, everything is working except when the image is too large and it does absolutely nothing on the upload script. I've added some mile markers for debugging like I would in Python but it doesn't seem to help in PHP.</p> <p>Solved: In my <code>form</code> I had the file size limited to the same exact size as in my handler script. Changing the value in the <code>form</code> to just one byte larger fixed it.</p>
[ { "answer_id": 74250834, "author": "ChamRun", "author_id": 14761615, "author_profile": "https://Stackoverflow.com/users/14761615", "pm_score": 2, "selected": true, "text": "i = 0" }, { "answer_id": 74250853, "author": "Giuseppe La Gualano", "author_id": 20249888, "aut...
2022/10/30
[ "https://Stackoverflow.com/questions/74250675", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12556213/" ]
74,250,713
<p>I have list of special character</p> <pre><code>const charlist ={'a' : '', 'b' : '', 'c' : '', 'd' : '', } </code></pre> <p>The result I want is when I press key &quot;a&quot; at input text box i should get &quot;&quot; how I can achieve this?</p>
[ { "answer_id": 74250782, "author": "Delwyn Pinto", "author_id": 4428535, "author_profile": "https://Stackoverflow.com/users/4428535", "pm_score": 0, "selected": false, "text": "input //key from user input\n\nvar specialChar = charList[input]\n" }, { "answer_id": 74250876, "au...
2022/10/30
[ "https://Stackoverflow.com/questions/74250713", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16680000/" ]
74,250,761
<p>I'm trying to add 2 items to a dictionary state at once, but only the second one is added.</p> <p>I made an example below, you can also check the codesandbox. When I run add2Items, only &quot;Item2&quot; is added.</p> <p>Can anyone tell me what's going wrong here?</p> <pre><code> const [dict, setDict] = useState({}); const addItem = (name, value) =&gt; { console.log(&quot;name&quot;, name); const newItem = { [name]: value }; const newDict = Object.assign({}, dict, newItem); setDict(newDict); }; const add2Items = () =&gt; { addItem(&quot;Item1&quot;, &quot;test1&quot;); addItem(&quot;Item2&quot;, &quot;test2&quot;); }; </code></pre> <p><a href="https://codesandbox.io/embed/brave-mountain-ienzbu" rel="nofollow noreferrer">https://codesandbox.io/embed/brave-mountain-ienzbu</a></p>
[ { "answer_id": 74250782, "author": "Delwyn Pinto", "author_id": 4428535, "author_profile": "https://Stackoverflow.com/users/4428535", "pm_score": 0, "selected": false, "text": "input //key from user input\n\nvar specialChar = charList[input]\n" }, { "answer_id": 74250876, "au...
2022/10/30
[ "https://Stackoverflow.com/questions/74250761", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5157268/" ]
74,250,764
<p>I need to retrieve data from firestore collection and assign exact value to String...</p> <p>Here is my code.</p> <pre><code>class _AbcState extends State&lt;Abc&gt; { @override Widget build(BuildContext context) { return StreamBuilder&lt;QuerySnapshot&gt;( stream: FirebaseFirestore.instance.collection('boat').snapshots(), builder: (context, snapshot) { if (snapshot.hasError) { return const Center(child: Text('Something wrong!')); } if (snapshot.connectionState == ConnectionState.waiting) { return const Center(child: CircularProgressIndicator()); } if (snapshot.data!.size == 0) { return const Center( child: Text('No boats'), ); } return ListView.builder( padding: const EdgeInsets.all(15.0), physics: const ScrollPhysics(), shrinkWrap: true, itemCount: snapshot.data!.size, itemBuilder: (context, index) { Map&lt;String, dynamic&gt; boatData = snapshot.data!.docs[index].data() as Map&lt;String, dynamic&gt;; return Card( child: ListTile( contentPadding: const EdgeInsets.all(15.0), horizontalTitleGap: 50, title: Text(boatData['boatName']), subtitle: GetInfo(boatData: boatData), ), ); }, ); }, ); } } class GetInfo extends StatelessWidget { const GetInfo({ Key? key, required this.boatData, }) : super(key: key); final Map&lt;String, dynamic&gt; boatData; @override Widget build(BuildContext context) { return StreamBuilder&lt;DocumentSnapshot&gt;( stream: FirebaseFirestore.instance .collection('actor') .doc(boatData['uid']) .snapshots(), builder: (context, snapshot) { if (snapshot.hasError) { return const Text('Something went wrong'); } if (snapshot.connectionState == ConnectionState.waiting) { return const CircularProgressIndicator(); } return Text(snapshot.data!['name']); }, ); } } </code></pre> <p>By calling <strong>GetInfo</strong> I can get the data as a Text Widget.</p> <p>But I need to get that value and assign it to a variable for future purposes.</p> <p>I saved documents by user id in <strong>actor</strong> collection.</p> <h2>Please guide me to how to do that.</h2>
[ { "answer_id": 74250948, "author": "odinachi", "author_id": 11948079, "author_profile": "https://Stackoverflow.com/users/11948079", "pm_score": 0, "selected": false, "text": "class GetInfo extends StatelessWidget {\nconst GetInfo({Key? key, required this.boatData, required this.uidCallba...
2022/10/30
[ "https://Stackoverflow.com/questions/74250764", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19701828/" ]
74,250,817
<p>Anyone knows a fix for this i keep getting this error, I used an OnPressed here, I think im suppose to use a VoidCallback here but when i use that i get the error:</p> <p>&quot;The argument type 'void Function(dynamic)' can't be assigned to the parameter type 'void Function()'.&quot;</p> <p>Been stuck on this issue thanks for your help.</p> <pre><code>import 'package:concept1/constant.dart'; import 'package:concept1/screen/login/widget/welcome_back.dart'; import 'package:flutter/material.dart'; class LoginScreen extends StatelessWidget { const LoginScreen({super.key}); @override Widget build(BuildContext context) { return Scaffold( appBar: buildAppBar(context), body: Column( children: [ const WelcomeBack(), Container( padding: EdgeInsets.symmetric(vertical: 20, horizontal: 30), child: Column(children: &lt;Widget&gt;[ InputTextField( label: 'Email', onChange: (value) {}, ), InputTextField( label: 'Password', onChange: (value) {}, ), ]), ) ], ), ); } AppBar buildAppBar(BuildContext context) { return AppBar( backgroundColor: mBackgroundColor, elevation: 0, centerTitle: true, title: Text( 'Login Screen', style: TextStyle( color: mPrimaryColor, ), ), leading: IconButton( icon: const Icon(Icons.arrow_back_ios), color: mPrimaryColor, onPressed: () { Navigator.pop(context); }, ), ); } } class InputTextField extends StatelessWidget { const InputTextField({ Key? key, required this.label, required this.onChange, }) : super(key: key); final String label; final Function? onChange; @override Widget build(BuildContext context) { return TextField( onChanged: onChange, cursorColor: Colors.grey, decoration: InputDecoration( labelText: label, labelStyle: const TextStyle(color: Colors.grey), border: UnderlineInputBorder( borderSide: BorderSide( color: mPrimaryColor, width: 2, )), focusedBorder: UnderlineInputBorder( borderSide: BorderSide( color: mPrimaryColor, width: 2, )), enabledBorder: const UnderlineInputBorder( borderSide: BorderSide( color: Colors.grey, width: 0.5, ))), ); } } </code></pre>
[ { "answer_id": 74250838, "author": "Looth", "author_id": 17237271, "author_profile": "https://Stackoverflow.com/users/17237271", "pm_score": 0, "selected": false, "text": " import 'package:concept1/constant.dart';\nimport 'package:concept1/screen/login/widget/welcome_back.dart';\nimpo...
2022/10/30
[ "https://Stackoverflow.com/questions/74250817", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17237271/" ]
74,250,820
<p>For example, I want to get <code>&quot;,&quot;</code> printed given the following string and list because it's the first character of the string that appears in my list of characters.</p> <pre><code>my_list = [',', '.', ';', ':'] my_string = &quot;Hello world, I am a programmer.&quot; </code></pre> <p>The whole intersection list would be <code>','</code> and <code>'.'</code> with <code>','</code> being the first and therefore what I want to print</p> <p>I've tried the following code, but is there a shorter way to do it?</p> <pre><code>my_list = [',', '.', ';', ':'] my_string = &quot;Hello world, I am a programmer.&quot; my_set = set(my_string).intersection(my_list) my_list2 = [my_string.find(i) for i in my_set] my_list2.sort() num1 = my_list2[0] print(my_string[num1]) </code></pre>
[ { "answer_id": 74250851, "author": "PCDSandwichMan", "author_id": 12007307, "author_profile": "https://Stackoverflow.com/users/12007307", "pm_score": 2, "selected": true, "text": "my_chars = [',', '.', ';', ':']\nmy_string = \"Hello world, I am a programmer.\"\n\nfor char in my_string:\n...
2022/10/30
[ "https://Stackoverflow.com/questions/74250820", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19810733/" ]
74,250,837
<p>I am trying to update a record in Database using Django but it adds the same record again. How i can fix it? code is given below.</p> <pre><code>def update(request, id): book = tblbook.objects.get(id=id) form = tblbook(BookID = book.BookID, BookName=book.BookName, Genre=book.Genre,Price=book.Price) form.save() return redirect(&quot;/show&quot;) </code></pre>
[ { "answer_id": 74250851, "author": "PCDSandwichMan", "author_id": 12007307, "author_profile": "https://Stackoverflow.com/users/12007307", "pm_score": 2, "selected": true, "text": "my_chars = [',', '.', ';', ':']\nmy_string = \"Hello world, I am a programmer.\"\n\nfor char in my_string:\n...
2022/10/30
[ "https://Stackoverflow.com/questions/74250837", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15754241/" ]
74,250,866
<p>I am trying to take a user entered integer (positive or negative) and let them pick a digit position and output the digit at that position.</p> <pre><code>int findDigAtPos(int number) { int position; int result; cout &lt;&lt; &quot;Enter digit position between 1 and &quot; &lt;&lt; std::to_string(number).length() &lt;&lt; endl; cin &gt;&gt; position; while (position &lt; 0 || position &gt; std::to_string(number).length()) { cout &lt;&lt; &quot;Enter digit position between 1 and &quot;&lt;&lt; std::to_string(number).length()&lt;&lt;endl; cin &gt;&gt; position; } if (std::to_string(number).length() == 1) cout &lt;&lt; &quot;Only one digit&quot; &lt;&lt; endl; number = number / pow(10, (position - 1.0)); result = number % 10; return result; } </code></pre> <p>This is the code I currently have for the function. However, it outputs the number in reverse. How do I correct the digit position? I thought it didn't even function correctly until noticing it's in reverse order.</p>
[ { "answer_id": 74251122, "author": "selbie", "author_id": 104458, "author_profile": "https://Stackoverflow.com/users/104458", "pm_score": 1, "selected": false, "text": "number = number / pow(10, (position - 1.0));\nresult = number % 10;\n" }, { "answer_id": 74251140, "author"...
2022/10/30
[ "https://Stackoverflow.com/questions/74250866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20369762/" ]
74,250,873
<p>Without reading the contents of a file into memory, how can I read &quot;x&quot; bytes from the file so that I can specify what x is for every separate read operation?</p> <p>I see that the <code>Read</code> method of various <code>Reader</code>s takes a byte slice of a certain length and I can read from a file into that slice. But in that case the size of the slice is fixed, whereas what I would like to do, ideally, is something like:</p> <pre><code>func main() { f, err := os.Open(&quot;./file.txt&quot;) if err != nil { panic(err) } someBytes := f.Read(2) someMoreBytes := f.Read(4) } </code></pre> <p><code>bytes.Buffer</code> has a <code>Next</code> <a href="https://pkg.go.dev/bytes#Buffer.Next" rel="nofollow noreferrer">method</a> which behaves very closely to what I would want, but it requires an existing buffer to work, whereas I'm hoping to read an arbitrary amount of bytes from a file without needing to read the whole thing into memory.</p> <p>What is the best way to accomplish this?</p> <p>Thank you for your time.</p>
[ { "answer_id": 74250900, "author": "mohammad mobasher", "author_id": 2591714, "author_profile": "https://Stackoverflow.com/users/2591714", "pm_score": 0, "selected": false, "text": "f, err := os.Open(\"/tmp/dat\")\ncheck(err)\nb1 := make([]byte, 5)\nn1, err := f.Read(b1)\ncheck(err)\nfmt...
2022/10/30
[ "https://Stackoverflow.com/questions/74250873", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9225936/" ]
74,250,877
<p>I have a random graph with 10 nodes where 4 nodes have the zero degree.</p> <p>It is required to obtain the connected graph by 1) select a node with zero degree and a minimal feature (for exmaple, random number from uniform distribautin) corresponding to each edge and connect it with graph by creation two incident edges to the node and deleting the 3rd edge, 2) repeat step 1 for all zero degree nodes.</p> <p>The original graph in left, the resulting one in right.</p> <p><a href="https://i.stack.imgur.com/JQLZF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JQLZF.png" alt="enter image description here" /></a></p> <p>My attempt is:</p> <pre><code>library(igraph) ###################################################################### set.seed(5) g &lt;- sample_gnm(10, 4) xy &lt;- cbind(runif(10), runif(10)) par(mfrow=c(1,2)) plot(g, vertex.size=5, layout=xy) num_point &lt;- length(V(g)[degree(g)==0]) for(k in 1:num_point){ points = V(g)[degree(g)==0] for(i in 1:length(E(g))) { # loop over all edges head &lt;- get.edgelist(g)[i,][1]; h &lt;- c(V(g)[head]$x, V(g)[head]$y) tail &lt;- get.edgelist(g)[i,][2]; t &lt;- c(V(g)[tail]$x, V(g)[tail]$y) d &lt;- NULL # loop over all points for(j in points) d &lt;- c(d, runif(1)) E(g)[i]$d &lt;- min(d) # local min E(g)[i]$p &lt;- points[which(d == min(d))] } # i ei = which.min(E(g)$d) # edge with the global min vi = E(g)[ei]$p # head and tail of edge with global min head &lt;- get.edgelist(g)[E(g)[ei],][1]; tail &lt;- get.edgelist(g)[E(g)[ei],][2] g &lt;- add_edges(g, c(head, V(g)[vi], V(g)[vi], tail)); g &lt;- delete_edges(g, get.edge.ids(g, c(head, tail) )) } plot(g, vertex.size=5, layout=xy) </code></pre> <p><strong>Question.</strong> How to organize the loop over all edges when the number of edges increase by 1 and number of point decrising by 1 evety step? One can see, I don't use the k variable in explicit form.</p>
[ { "answer_id": 74250900, "author": "mohammad mobasher", "author_id": 2591714, "author_profile": "https://Stackoverflow.com/users/2591714", "pm_score": 0, "selected": false, "text": "f, err := os.Open(\"/tmp/dat\")\ncheck(err)\nb1 := make([]byte, 5)\nn1, err := f.Read(b1)\ncheck(err)\nfmt...
2022/10/30
[ "https://Stackoverflow.com/questions/74250877", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5692005/" ]
74,250,887
<p>I have a quick question. The R code is as below. When I want to run this code and enter a in textinput.</p> <p>&quot;query_db &lt;- paste(&quot;select name, Votes,city from zomato_rest where name like '%&quot;,input$names,&quot;%' and Votes &lt;=&quot;, input$slider_votes,&quot;;&quot;)&quot;</p> <p>The result always only shows ' a '. It won't show 'babb', 'accc' etc.</p> <p>If I correct it as below and enter Roku, it shows no this data, but it exists in the dataset. query_db &lt;- paste(&quot;select name, Votes,city from zomato_rest where name = '&quot;,input$names,&quot;' and Votes &lt;=&quot;, input$slider_votes,&quot;;&quot;)</p> <p>If I correct it again, it shows the data. query_db &lt;- paste(&quot;select name, Votes,city from zomato_rest where name ='Roku' and Votes &lt;=&quot;, input$slider_votes,&quot;;&quot;)</p> <p>Does anyone know the reason?</p> <pre><code>library(shiny) library(shinydashboard) library(leaflet) library(DBI) library(odbc) library(DT) ui &lt;- textInput(&quot;names&quot;, &quot;Pattern of Name&quot;, &quot;Please enter a name&quot;), actionButton(&quot;Go&quot;, &quot;Get results!&quot;), DT::dataTableOutput(&quot;mytable&quot;) ) server &lt;- function(input, output,session) { query_db &lt;- paste(&quot;select name, Votes,city from zomato_rest where name like '%&quot;,input$names,&quot;%' and Votes &lt;=&quot;, input$slider_votes,&quot;;&quot;) print(query_db) data_db &lt;- dbGetQuery(db, query_db) </code></pre> <p>output$mytable = DT::renderDataTable({ data_db })</p> <pre><code> </code></pre> <p>I want to see the result of code running in R same as the result running in SQL. But, it looks like it always has space between the value and symbol =&gt; '% a %', so 'cbac' won't show up, but ' a ' shows up.</p> <p>I expect it can show the result like '%a%', so 'cbac' shows up, but ' a ' won't show up. I hope that I describe the situation clear enough.</p>
[ { "answer_id": 74250900, "author": "mohammad mobasher", "author_id": 2591714, "author_profile": "https://Stackoverflow.com/users/2591714", "pm_score": 0, "selected": false, "text": "f, err := os.Open(\"/tmp/dat\")\ncheck(err)\nb1 := make([]byte, 5)\nn1, err := f.Read(b1)\ncheck(err)\nfmt...
2022/10/30
[ "https://Stackoverflow.com/questions/74250887", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20369749/" ]
74,250,922
<p>sorry for asking so soon again, this is my second project and I got stuck at this: I'm making a simple calculator with basic operations, and right now, I'm creating the buttons' functions so when they're pressed, the value of the button is input into the calculator screen; my problem is, that the button returns 'undefined', even though I think I'm targeting the right class using document.querySelectorAll().</p> <p>Again, thank you for helping me, I try no to ask much to be able to solve or at least figure out this stuff by myself, and though I like it and am motivated, i'm starting to feel kinda dumb.</p> <p>Here's the code:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang=&quot;en&quot;&gt; &lt;head&gt; &lt;meta charset=&quot;utf-8&quot;/&gt; &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;/&gt; &lt;title&gt;Ysmael's Calculator&lt;/title&gt; &lt;link rel=&quot;stylesheet&quot; href=&quot;calculator.css&quot;/&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;Calculator&lt;/h1&gt; &lt;div id=&quot;display&quot;&gt; &lt;input type=&quot;text&quot; id=&quot;numField&quot;/&gt; &lt;/div&gt; &lt;table&gt; &lt;tr&gt; &lt;th&gt;&lt;input type=&quot;button&quot; value=&quot;7&quot; class=&quot;numButton row1 buttons&quot; id=&quot;button7&quot;&gt;&lt;/th&gt; &lt;th&gt;&lt;input type=&quot;button&quot; value=&quot;4&quot; class=&quot;numButton row1 buttons&quot; id=&quot;button4&quot;/&gt;&lt;/th&gt; &lt;th&gt;&lt;input type=&quot;button&quot; value=&quot;1&quot; class=&quot;numButton row1 buttons&quot; id=&quot;button1&quot;/&gt;&lt;/th&gt; &lt;th&gt;&lt;input type=&quot;button&quot; value=&quot;+&quot; class=&quot;opButton row5 buttons&quot; id=&quot;buttonPlus&quot;&gt;&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th&gt;&lt;input type=&quot;button&quot; value=&quot;8&quot; class=&quot;numButton row2 buttons&quot; id=&quot;button8&quot;/&gt;&lt;/th&gt; &lt;th&gt;&lt;input type=&quot;button&quot; value=&quot;5&quot; class=&quot;numButton row2 buttons&quot; id=&quot;button5&quot;&gt;&lt;/th&gt; &lt;th&gt;&lt;input type=&quot;button&quot; value=&quot;2&quot; class=&quot;numButton row2 buttons&quot; id=&quot;button2&quot;&gt;&lt;/th&gt; &lt;th&gt;&lt;input type=&quot;button&quot; value=&quot;-&quot; class=&quot;opButton row5 buttons&quot; id=&quot;buttonMinus&quot;&gt;&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th&gt;&lt;input type=&quot;button&quot; value=&quot;9&quot; class=&quot;numButton row3 buttons&quot; id=&quot;button9&quot;&gt;&lt;/th&gt; &lt;th&gt;&lt;input type=&quot;button&quot; value=&quot;6&quot; class=&quot;numButton row3 buttons&quot; id=&quot;button6&quot;&gt;&lt;/th&gt; &lt;th&gt;&lt;input type=&quot;button&quot; value=&quot;3&quot; class=&quot;numButton row3 buttons&quot; id=&quot;button3&quot;&gt;&lt;/th&gt; &lt;th&gt;&lt;input type=&quot;button&quot; value=&quot;*&quot; class=&quot;opButton row5 buttons&quot; id=&quot;buttonMultiply&quot;&gt;&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th&gt;&lt;input type=&quot;button&quot; value=&quot;0&quot; class=&quot;numButton row4 buttons&quot; id=&quot;button0&quot;&gt;&lt;/th&gt; &lt;th&gt;&lt;input type=&quot;button&quot; value=&quot;.&quot; class=&quot;decButton row4 buttons&quot; id=&quot;buttonDot&quot;&gt;&lt;/th&gt; &lt;th&gt;&lt;button type=&quot;submit&quot; value=&quot;=&quot; class=&quot;equalButton row4 buttons&quot; id=&quot;buttonEqual&quot;&gt;=&lt;/button&gt;&lt;/th&gt; &lt;th&gt;&lt;input type=&quot;button&quot; value=&quot;%&quot; class=&quot;opButton row4 buttons&quot; id=&quot;buttonDivide&quot;&gt;&lt;/th&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/body&gt; &lt;/html&gt; &lt;script src=&quot;calculator.js&quot;&gt;&lt;/script&gt; </code></pre> <pre><code>//display// let calculatorScreen = document.getElementById('numField'); //display// const numButtons = document.querySelectorAll('.numButton'); const opButtons = document.querySelectorAll('.opButton'); const equalButton = document.querySelector('.equalButton'); const dotButton = document.querySelector('.decButton'); //buttons// //Button funtions// numButtons.forEach(number =&gt; { number.addEventListener('click', () =&gt; { calculatorScreen.value += numButtons.value; }) }) </code></pre> <p>I tried to input the value of a button, so I expected for the click to do that</p>
[ { "answer_id": 74250900, "author": "mohammad mobasher", "author_id": 2591714, "author_profile": "https://Stackoverflow.com/users/2591714", "pm_score": 0, "selected": false, "text": "f, err := os.Open(\"/tmp/dat\")\ncheck(err)\nb1 := make([]byte, 5)\nn1, err := f.Read(b1)\ncheck(err)\nfmt...
2022/10/30
[ "https://Stackoverflow.com/questions/74250922", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20228511/" ]
74,250,938
<p>I am a complete beginner at coding and Python.</p> <p>I have spent, I don't want to admit, a ridiculous amount of hours on what I know should be a simple thing in Python.</p> <ol> <li>open() method to open a *.csv file</li> <li>read that file using a for loop</li> <li>and then select a row using index and count how many times a word is there</li> </ol> <p>I am trying not to use modules. Just Python and a for loop.</p> <p>I will simply paste the info that I have in the csv file for testing purposes.</p> <p>Can someone please HELP!</p> <p>I was expecting to be naturally awesome at coding and I guess I am not.</p> <pre><code>date,rank,song title,artist,weeks-on-board 2022-10-25,1,This is love,doug,3 2022-10-26,2,Love sucks,steve,5 2022-10-27,3,Love love Love love,aaron,7 </code></pre> <pre class="lang-py prettyprint-override"><code>####################################################### # set the counter(accumulator) loveCount to equal 0 loveCount = 0 # use the python built in open() method to read a csv file file = open(&quot;love.csv&quot;) # read a line and go to the next line with readline() method data = file.readline() # start a loop that will love through the csv, strip off the 'ol # backslash n, and split the csv into seperate words for line in file: linelist = line.strip(&quot;\n&quot;).split(&quot;,&quot;) # the [2] refers to 'index' two in the list and will display the str there # Also, .lower() makes all the str lowercase, so if I could get this to # work would, wouldn't have to worry about uppercase loveCount = linelist[2] loveSucks = loveCount.lower() # I am pretty sure this is the area where I am getting it wrong? if loveCount == 'love': loveCount += 1 # print an unsuccessfull accumulation print(loveSucks) print(loveCount) </code></pre>
[ { "answer_id": 74250900, "author": "mohammad mobasher", "author_id": 2591714, "author_profile": "https://Stackoverflow.com/users/2591714", "pm_score": 0, "selected": false, "text": "f, err := os.Open(\"/tmp/dat\")\ncheck(err)\nb1 := make([]byte, 5)\nn1, err := f.Read(b1)\ncheck(err)\nfmt...
2022/10/30
[ "https://Stackoverflow.com/questions/74250938", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10865450/" ]
74,250,950
<p>Currently am trying to deploy my React Project on Github Pages, however I am unable to do so. After publishing on gh pages, all I am getting is a screen with the correct background color, but without any of the content.</p> <p>I used these 2 pages to try and figure out how I could deploy my page and they are <a href="https://www.c-sharpcorner.com/article/how-to-deploy-react-application-on-github-pages/" rel="nofollow noreferrer">https://www.c-sharpcorner.com/article/how-to-deploy-react-application-on-github-pages/</a> and <a href="https://www.youtube.com/watch?v=Q9n2mLqXFpU&amp;ab_channel=PedroTech" rel="nofollow noreferrer">https://www.youtube.com/watch?v=Q9n2mLqXFpU&amp;ab_channel=PedroTech</a>.</p> <p>Also after doing npm run deploy I am now running into some issues when I run npm start. I am instead automatically taken to the page localhost:3000/space-tourism-website, but to get to my page it is on localhost:3000/</p> <p>Source code is on github: <a href="https://github.com/farhan-navas/space-tourism-website" rel="nofollow noreferrer">https://github.com/farhan-navas/space-tourism-website</a>. If any more info is needed please do let me know. Would be very thankful for any tips and help.</p> <pre><code>&quot;name&quot;: &quot;space-tourism-website&quot;, &quot;version&quot;: &quot;0.1.0&quot;, &quot;private&quot;: true, &quot;homepage&quot;: &quot;https://farhan-navas.github.io/&quot;, &quot;dependencies&quot;: { &quot;@testing-library/jest-dom&quot;: &quot;^5.16.5&quot;, &quot;@testing-library/react&quot;: &quot;^13.4.0&quot;, &quot;@testing-library/user-event&quot;: &quot;^13.5.0&quot;, &quot;react&quot;: &quot;^18.2.0&quot;, &quot;react-dom&quot;: &quot;^18.2.0&quot;, &quot;react-router-dom&quot;: &quot;^6.4.2&quot;, &quot;react-scripts&quot;: &quot;5.0.1&quot;, &quot;web-vitals&quot;: &quot;^2.1.4&quot; }, &quot;scripts&quot;: { &quot;start&quot;: &quot;react-scripts start&quot;, &quot;predeploy&quot;: &quot;npm run build&quot;, &quot;deploy&quot;: &quot;gh-pages -d build&quot;, &quot;build&quot;: &quot;react-scripts build&quot;, &quot;test&quot;: &quot;react-scripts test&quot;, &quot;eject&quot;: &quot;react-scripts eject&quot; }, </code></pre> <p>this is how the top section package.json file looks like. Thanks once again.</p>
[ { "answer_id": 74250900, "author": "mohammad mobasher", "author_id": 2591714, "author_profile": "https://Stackoverflow.com/users/2591714", "pm_score": 0, "selected": false, "text": "f, err := os.Open(\"/tmp/dat\")\ncheck(err)\nb1 := make([]byte, 5)\nn1, err := f.Read(b1)\ncheck(err)\nfmt...
2022/10/30
[ "https://Stackoverflow.com/questions/74250950", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19002397/" ]
74,250,964
<p>Hi I am creating a custom middleware in Django for the DRF.</p> <p>So that when an user try to access any of the api the middleware will perform some operation and determine if the user is authorized to access the endpoint or not.</p> <p>My code is like below:</p> <pre class="lang-py prettyprint-override"><code>class PermissionMiddleware(MiddlewareMixin): def process_view(self, request, view_func, view_args, view_kwargs): if request.path.startswith('/admin/'): return None if request.path.startswith('/api/'): is_allowed = True if not is_allowed: return # &lt; -- What needs to return to block the access return None </code></pre> <p>My problem is what should I return from the method for disallowing access to api? I can return None, if I want to give access. But I want to disallow access and return some message from the api view so that user knows that he is not allwed.</p> <p>So in summery:</p> <ol> <li>What should I return from the middleware to block access?</li> <li>How can I return message to user from the view that he is not authorized?</li> </ol> <p>Thanks</p>
[ { "answer_id": 74250900, "author": "mohammad mobasher", "author_id": 2591714, "author_profile": "https://Stackoverflow.com/users/2591714", "pm_score": 0, "selected": false, "text": "f, err := os.Open(\"/tmp/dat\")\ncheck(err)\nb1 := make([]byte, 5)\nn1, err := f.Read(b1)\ncheck(err)\nfmt...
2022/10/30
[ "https://Stackoverflow.com/questions/74250964", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11348853/" ]
74,250,974
<ul> <li>I can assign a <em>unique</em> index to a python class data member like <a href="https://stackoverflow.com/questions/71195208/creating-a-unique-id-in-a-python-dataclass">here</a>.</li> <li>Is there an equivalent in typescript?</li> </ul> <pre class="lang-js prettyprint-override"><code>class Person { index: number age: number name: string constructor(age: number, name: string) { // this.index = fresh index every time this.age = age; this.name = name; } } </code></pre>
[ { "answer_id": 74251362, "author": "OrenIshShalom", "author_id": 3357352, "author_profile": "https://Stackoverflow.com/users/3357352", "pm_score": 0, "selected": false, "text": "static" }, { "answer_id": 74254238, "author": "Dimava", "author_id": 5734961, "author_prof...
2022/10/30
[ "https://Stackoverflow.com/questions/74250974", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3357352/" ]
74,250,998
<p>I want to fetch the id of only 1 row from my database for my change password. So that it will only change the password of that specific id selected. This code says an error, $id is undefined.</p> <pre><code>&lt;?php $connection = mysqli_connect(&quot;localhost&quot;, &quot;root&quot;, &quot;&quot;, &quot;ofad&quot;); $query = &quot;SELECT * FROM admin WHERE id='$id' LIMIT 1&quot;; $query_run = mysqli_query($connection, $query); if(mysqli_num_rows($query_run) == 0 ){ while($row = mysqli_fetch_assoc($query_run)){ ?&gt; &lt;input type=&quot;text&quot; class=&quot;input-field&quot; name=&quot;id&quot; value=&quot;&lt;?php echo $row ['id']; ?&gt;&quot; required&gt; &lt;div class=&quot;input-field&quot;&gt; &lt;label&gt;Current Password&lt;/label&gt; &lt;input type=&quot;password&quot; class=&quot;input&quot; name=&quot;oldPass&quot; placeholder=&quot;Current Password&quot; required&gt; &lt;/div&gt; &lt;div class=&quot;input-field&quot;&gt; &lt;label&gt;New Password&lt;/label&gt; &lt;input type=&quot;password&quot; class=&quot;input&quot; name=&quot;newPass&quot; placeholder=&quot;New Password&quot; required&gt; &lt;/div&gt; &lt;div class=&quot;input-field&quot;&gt; &lt;label&gt;Confirm New Password&lt;/label&gt; &lt;input type=&quot;password&quot; class=&quot;input&quot; name=&quot;confirmPass&quot; placeholder=&quot;Confirm New Password&quot; required&gt; &lt;/div&gt; &lt;div class=&quot;button&quot;&gt; &lt;input type=&quot;submit&quot; id=&quot;click&quot; name=&quot;save_btn&quot;&gt; &lt;label for=&quot;click&quot; class=&quot;save-me&quot;&gt;Save&lt;/label&gt; &lt;!--MODAL POPUP--&gt; &lt;/div&gt; &lt;?php } } ?&gt; </code></pre>
[ { "answer_id": 74251362, "author": "OrenIshShalom", "author_id": 3357352, "author_profile": "https://Stackoverflow.com/users/3357352", "pm_score": 0, "selected": false, "text": "static" }, { "answer_id": 74254238, "author": "Dimava", "author_id": 5734961, "author_prof...
2022/10/30
[ "https://Stackoverflow.com/questions/74250998", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20293607/" ]
74,251,016
<p>I develop with laravel9 and vue3.</p> <p>My problem is simple, But path setting is not go well.</p> <p>When I access url <code>localhost:8080/tasks</code></p> <p>This url return 404 not found and I get the following type error</p> <blockquote> <p>GET http://localhost:8000/tasks 404 (Not Found)</p> </blockquote> <p>I didn't know the reason , but When I rewrite path: <code>/tasks</code> to path <code>/</code>, localhost:8080 return Component that I want to need.</p> <p>I have following files.</p> <p><code>router.js</code></p> <pre class="lang-js prettyprint-override"><code>import { createRouter, createWebHistory } from &quot;vue-router&quot;; import TaskListComponent from &quot;./components/TaskListComponent.vue&quot;; const router = createRouter({ history: createWebHistory(), routes: [ { path: '/tasks', name: 'tasks.list', component: TaskListComponent } ] }) export default router </code></pre> <p><code>App.vue</code></p> <pre class="lang-html prettyprint-override"><code>&lt;script setup&gt; import HeaderComponent from &quot;./components/HeaderComponent.vue&quot;; &lt;/script&gt; &lt;template&gt; &lt;HeaderComponent /&gt; &lt;router-view&gt;&lt;/router-view&gt; &lt;/template&gt; </code></pre> <p><code>bootstrap.js</code></p> <pre class="lang-js prettyprint-override"><code>import { createApp } from &quot;vue&quot;; import App from &quot;./App.vue&quot;; import router from &quot;./router.js&quot; const app = createApp(App); app.use(router); app.mount(&quot;#app&quot;); </code></pre>
[ { "answer_id": 74251362, "author": "OrenIshShalom", "author_id": 3357352, "author_profile": "https://Stackoverflow.com/users/3357352", "pm_score": 0, "selected": false, "text": "static" }, { "answer_id": 74254238, "author": "Dimava", "author_id": 5734961, "author_prof...
2022/10/30
[ "https://Stackoverflow.com/questions/74251016", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19797882/" ]
74,251,074
<p>The requirement is to load <em>csv</em> and <em>parquet</em> files from S3 into a dataframe using PySpark.</p> <p>The code I'm using is :</p> <pre><code>from pyspark import SparkConf, SparkContext from pyspark.sql import SparkSession conf = SparkConf() appName = &quot;S3&quot; master = &quot;local&quot; conf.set('spark.executor.extraJavaOptions', '-Dcom.amazonaws.services.s3.enableV4=true') conf.set('spark.driver.extraJavaOptions', '-Dcom.amazonaws.services.s3.enableV4=true') sc = SparkContext.getOrCreate(conf=conf) sc.setSystemProperty('com.amazonaws.services.s3.enableV4', 'true') hadoopConf = sc._jsc.hadoopConfiguration() hadoopConf.set('fs.s3a.access.key', aws_access_key_id) hadoopConf.set('fs.s3a.secret.key', aws_secret_access_key) hadoopConf.set('fs.s3a.impl', 'org.apache.hadoop.fs.s3a.S3AFileSystem') spark = SparkSession(sc) df = spark.read.csv('s3://s3path/File.csv') </code></pre> <p>And it gives me the error :</p> <pre><code>py4j.protocol.Py4JJavaError: An error occurred while calling o34.csv. : java.lang.NoClassDefFoundError: org/jets3t/service/S3ServiceException </code></pre> <p>And similar error while reading Parquet files :</p> <pre><code>py4j.protocol.Py4JJavaError: An error occurred while calling o34.parquet. : java.lang.NoClassDefFoundError: org/jets3t/service/S3ServiceException </code></pre> <p>How to resolve this?</p>
[ { "answer_id": 74251344, "author": "Vaebhav", "author_id": 9108912, "author_profile": "https://Stackoverflow.com/users/9108912", "pm_score": -1, "selected": false, "text": "s3a" }, { "answer_id": 74262310, "author": "stevel", "author_id": 2261274, "author_profile": "h...
2022/10/30
[ "https://Stackoverflow.com/questions/74251074", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19641950/" ]
74,251,093
<p>Generate N * N Random character .</p> <p>I will make code perfect but it's not working .</p> <p>pls any one help men.</p> <pre><code>import random n=int(input(&quot;Enter a number :&quot;)) matrix = [] for i in range(n): for j in range(n): temp = chr(random.randrange(33,126)) if temp in matrix: j-=1 else: matrix.append(temp) print(matrix,len(matrix)) </code></pre> <p>n = 4 I want 16 random character.</p> <p>n = 5 ['a' , '@' , '5' ......] upto 25 characters I want.</p>
[ { "answer_id": 74251344, "author": "Vaebhav", "author_id": 9108912, "author_profile": "https://Stackoverflow.com/users/9108912", "pm_score": -1, "selected": false, "text": "s3a" }, { "answer_id": 74262310, "author": "stevel", "author_id": 2261274, "author_profile": "h...
2022/10/30
[ "https://Stackoverflow.com/questions/74251093", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17411747/" ]
74,251,120
<p>I would like to import the pre-installed ELB which is not made by Terraform. As far as I know, provisioned EC2s (not created by Terraform) are modified with no problems.</p> <p>Please refer to: <a href="https://www.youtube.com/watch?v=Abv3CHS4HTE" rel="nofollow noreferrer">https://www.youtube.com/watch?v=Abv3CHS4HTE</a></p> <p>All I want to know is to enable provisioned ELB with the Access logs. (* I don't want to provision a new ELB)</p> <p>Following is the code I run.</p> <pre><code> data &quot;aws_elb_service_account&quot; &quot;main&quot; {} resource &quot;aws_s3_bucket&quot; &quot;elb_logs&quot; { bucket = &quot;&lt;BucketName&gt;&quot; acl = &quot;private&quot; policy = &lt;&lt;POLICY { &quot;Id&quot;: &quot;Policy&quot;, &quot;Version&quot;: &quot;2012-10-17&quot;, &quot;Statement&quot;: [ { &quot;Action&quot;: [ &quot;s3:PutObject&quot; ], &quot;Effect&quot;: &quot;Allow&quot;, &quot;Resource&quot;: &quot;arn:aws:s3:::&lt;BucketName&gt;/AWSLogs/*&quot;, &quot;Principal&quot;: { &quot;AWS&quot;: [ &quot;${data.aws_elb_service_account.main.arn}&quot; ] } } ] } POLICY } resource &quot;aws_lb&quot; &quot;foobar&quot; { arn = &quot;arn:aws:elasticloadbalancing:ap-northeast-1:&lt;AccountName&gt;:loadbalancer/app/&lt;ELBName&gt;/7c6a359c72a9a02e&quot; name = &quot;&lt;ELBName&gt;&quot; internal = false load_balancer_type = &quot;application&quot; subnets = [ &quot;&lt;Subnet-1Name&gt;&quot;, &quot;&lt;Subnet-2Name&gt;&quot;, ] access_logs { bucket = &quot;${aws_s3_bucket.elb_logs.bucket}&quot; } } </code></pre>
[ { "answer_id": 74251344, "author": "Vaebhav", "author_id": 9108912, "author_profile": "https://Stackoverflow.com/users/9108912", "pm_score": -1, "selected": false, "text": "s3a" }, { "answer_id": 74262310, "author": "stevel", "author_id": 2261274, "author_profile": "h...
2022/10/30
[ "https://Stackoverflow.com/questions/74251120", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14695669/" ]
74,251,126
<p>I'm confused, I was asked to do a connection from Java into MySQL using OOP and DAO, but my professor asked us to do it in a the following way:</p> <p>We need to make the variable &quot;MethodOfPayment&quot; as an int in Java and as a char in MySQL table, and we need to write the method of payment depending on the number you put in Java. For example:</p> <p>Java: MethodOfPayment: (you write) 1 will insert &quot;Credit card&quot; in MySQL<br /> Java: MethodOfPayment: (you write) 2 will insert &quot;Debit card&quot; in MySQL<br /> but using the int MethodOfPayment variable.</p> <p>I tried a switch, but it won't let me convert the int &quot;With&quot; letters to string, I don't even know if it's possible.</p> <p>This is the insert I have in the DAO method class</p> <pre><code>private static final String SQL_INSERT = &quot;INSERT INTO Client(Name, LastName, MethodOfPayment ) VALUES (?,?,?)&quot;; </code></pre> <p>I do it with ResultSet, ArrayList, PreparedStatement with a JDBC connection to MySQL.</p> <pre><code>public static int = MethodOfPayment; </code></pre> <p>This is the variable that will write on the database an the one my professor is asking us to keep as an int in java and write the char on MySQL.</p> <p>This is the method I'm trying to convert the int to string, but obviously crashes because the letters inside the int. I don't know if it's possible or my professor is wrong.</p> <pre class="lang-java prettyprint-override"><code>public static void PaymentMethod() { int MethodSelection; //this is a variable to select the method in the switch and assign the values to the main variable of the payment System.out.println(&quot;Insert Payment Method&quot;); Scanner sc = new Scanner(System.in); MethodSelection = Integer.parseInt(sc.nextLine()); switch (MethodSelection) { case 1: MethodOfPayment = Integer.parseInt(&quot;Debit&quot;); break; case 2: MethodOfPayment = Integer.parseInt(&quot;Credit Card&quot;); break;// ... default: System.out.println(&quot;Invalid Method, Try Again&quot;); PaymentMethod(); // I don't know a way to restart the switch without restarting the whole method when another value is inserted } } </code></pre> <p>DAOmethod:</p> <p>Person is the father clas with, name and Last name. I get TypeOfPayment from a son class that has get, set and stringbuilder with the super to get the person data</p> <pre><code>public int insert(Client person){ Connection conn = null; PreparedStatement stmt = null; int registros = 0; try { conn = getConnection(); stmt = conn.prepareStatement(SQL_INSERT); stmt.setString(1, person.getStr_Name()); stmt.setString(2, person.getStr_Lastname); stmt.setInt(3, person.getInt_TypeOfPayment()); archives= stmt.executeUpdate(); } catch (SQLException ex) { ex.printStackTrace(System.out); }finally{ try { close(stmt); close(conn); } catch (SQLException ex) { } } return archives; } </code></pre>
[ { "answer_id": 74251184, "author": "Jishnu Prathap", "author_id": 3651739, "author_profile": "https://Stackoverflow.com/users/3651739", "pm_score": 1, "selected": false, "text": "package test1;\n\nimport java.util.Scanner;\n\npublic class Snippet {\n public static void PaymentMethod()...
2022/10/30
[ "https://Stackoverflow.com/questions/74251126", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18516724/" ]
74,251,137
<p>I have 3 tables:</p> <pre><code>companies (id, name) union_products (id, name) products (id, company_id, union_product_id, price_per_one_product) </code></pre> <p>I need to get all companies which have products with union_product_id in (1,2) and total price of products (per company) is less than 100.</p> <p>What I am trying to do now:</p> <pre><code>select * from &quot;companies&quot; where exists ( select id from &quot;products&quot; where &quot;companies&quot;.&quot;id&quot; = &quot;products&quot;.&quot;company_id&quot; and &quot;union_product_id&quot; in (1, 2) group by id having COUNT(distinct union_product_id) = 2 AND SUM(price_per_one_product) &lt; 100 ) </code></pre> <p>The problem I stuck with is that I'm getting 0 rows from the query above, but it works if I'll change <code>COUNT(distinct union_product_id) = 2</code> to 1.</p> <p>DB fiddle: <a href="https://www.db-fiddle.com/f/iRjfzJe2MTmnwEcDXuJoxn/0" rel="nofollow noreferrer">https://www.db-fiddle.com/f/iRjfzJe2MTmnwEcDXuJoxn/0</a></p>
[ { "answer_id": 74251300, "author": "Vrishab Sharma", "author_id": 14190971, "author_profile": "https://Stackoverflow.com/users/14190971", "pm_score": 0, "selected": false, "text": "SELECT c.name FROM \"companies\" c \nJOIN \"products\" p ON c.id = p.company_id \nWHERE union_product_id IN...
2022/10/30
[ "https://Stackoverflow.com/questions/74251137", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7976903/" ]
74,251,177
<p>Wondering, can hints work in PL SQL packages?</p> <p>Recently, I have to tune a long-running query in a PLSQL package because it causes a &quot;snapshot too old&quot; issue. I got the query out of the package and tuned it individually. I used the required hints for my case to tune that query and its running time significantly decreased. But I am not sure whether hints work in PL/SQL package as well. Could please clarify whether they can work in PL/SQL packages or not?</p> <p>Thanks in advance</p> <p>Regards</p>
[ { "answer_id": 74251300, "author": "Vrishab Sharma", "author_id": 14190971, "author_profile": "https://Stackoverflow.com/users/14190971", "pm_score": 0, "selected": false, "text": "SELECT c.name FROM \"companies\" c \nJOIN \"products\" p ON c.id = p.company_id \nWHERE union_product_id IN...
2022/10/30
[ "https://Stackoverflow.com/questions/74251177", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2761145/" ]
74,251,183
<p>So I have a problem that I'm dealing with for days now and I cant figure it out. I have this problem in excel, I am looking for assistance regarding a calculation. I want to be able to calculate a payment date schedule based on a set monthly payment date but to exclude exclude weekends and specific holiday dates e.g. Here's My file I'm Working on:[<img src="https://i.stack.imgur.com/oMMNx.png" alt="It didn't let me upload the excel file." />].</p> <p>Here is some function that I already used : <code>=IF(TEXT(O2,&quot;dddd&quot;)=$U$2,O2+2,IF(TEXT(O2,&quot;dddd&quot;)=$U$3,O2+1,O2))</code>This works for only weekends, It doesn't work on holidays, I want it to work not only on weekends and on holidays too.</p> <p>Thanks in advance.</p>
[ { "answer_id": 74251300, "author": "Vrishab Sharma", "author_id": 14190971, "author_profile": "https://Stackoverflow.com/users/14190971", "pm_score": 0, "selected": false, "text": "SELECT c.name FROM \"companies\" c \nJOIN \"products\" p ON c.id = p.company_id \nWHERE union_product_id IN...
2022/10/30
[ "https://Stackoverflow.com/questions/74251183", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20370040/" ]
74,251,199
<p>I have created a number guessing game from 1 to 10, Here is the Js code but i am unable to get the output.</p> <p>Here is my code:</p> <pre><code>var enterButton = document.getElementById('enterButton'); var againButton = document.getElementById('againButton'); var output = document.getElementById('outputText'); var randomNumber = Math.ceil(Math.random() * 10); function checkNumber() { var input = document.getElementById('userInput').value; if (input == randomNumber) { alert.innerHTML = &quot;Your guess is right &quot; + &quot;,&quot; + &quot;,it was &quot; + randomNumber; } else if (number &gt; randomNumber &amp;&amp; input &lt; 10) { alert.innerHTML = &quot;Your guess is to high&quot;; } else if (input &lt; randomNumber &amp;&amp; input &gt; 1) { alert.innerHTML = &quot;Your guess is too low &quot;; } else if (isNaN(input)) { alert.innerHTML = &quot;Invalid operator&quot;; } enterButton.addEventListener('click', checkNumber); againButton.addEventListener('click', function () { }) } </code></pre> <p>Here it the html code</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang=&quot;en&quot;&gt; &lt;head&gt; &lt;meta charset=&quot;UTF-8&quot;&gt; &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot;&gt; &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt; &lt;title&gt;Document&lt;/title&gt; &lt;link rel=&quot;sylesheet&quot; href=&quot;index.css&quot; /&gt; &lt;/head&gt; &lt;body&gt; &lt;script src=&quot;script.js&quot;&gt; &lt;/script&gt; &lt;/body&gt; &lt;div id=&quot;container&quot;&gt; &lt;p&gt; Guess a number between 1-10&lt;/p&gt; &lt;p id=&quot;outputtext&quot;&gt; Enter the number below &lt;/p&gt; &lt;input id=&quot;userInput&quot;&gt; &lt;button id=&quot;enterButton&quot;&gt;Enter&lt;/button&gt; &lt;button id=&quot;aginButton&quot;&gt;Try again&lt;/button&gt; &lt;/div&gt; &lt;/html&gt; </code></pre>
[ { "answer_id": 74251300, "author": "Vrishab Sharma", "author_id": 14190971, "author_profile": "https://Stackoverflow.com/users/14190971", "pm_score": 0, "selected": false, "text": "SELECT c.name FROM \"companies\" c \nJOIN \"products\" p ON c.id = p.company_id \nWHERE union_product_id IN...
2022/10/30
[ "https://Stackoverflow.com/questions/74251199", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19638023/" ]
74,251,249
<p>I have the following string in python:</p> <pre><code>datastring = &quot;&quot;&quot; Animals { idAnimal nameAnimal animalko5854hg[name=&quot;Jazz&quot;] animal6ljkjh[name=&quot;Pinky&quot;] animal595s422d1252g55[name=&quot;Steven&quot;] animalko5854hg[name=&quot;David&quot;] } &quot;&quot;&quot; print(type(datastring))#-&gt;str </code></pre> <p>My string is data than a read before from a file text, now I have that data in <code>datastring</code>. In <code>datastring</code> always in the fourth line, the data is showed in the next way: <code>animalidAnimal[name=&quot;nameAnimal&quot;</code></p> <p>So I would like to code a function that takes as a parameter a string like above, and return the part of <code>idAnimal</code> of the first line that starts in the following way: <code>animalidAnimal[name=&quot;nameAnimal&quot;</code> So for example in the first string my expected output would be:</p> <pre><code>ko5854hg </code></pre> <p>Other example:</p> <pre><code>datastring = &quot;&quot;&quot; Animals { idAnimal nameAnimal animal456jlk165ut[name=&quot;Dalty&quot;] animal6ljkj[name=&quot;Moon&quot;] } </code></pre> <p>Expected output:</p> <pre><code>456jlk165ut </code></pre> <p>Last example:</p> <pre><code>datastring = &quot;&quot;&quot; Animals { idAnimal nameAnimal animalk45lil69lhfr5942lk[name=&quot;Jazz&quot;] animal6ljkjh[name=&quot;Pinky&quot;] animal595s422d1252g55[name=&quot;Steven&quot;] animalko5854hg[name=&quot;David&quot;] animalko5854hg[name=&quot;Oty&quot;] animalko5854hg[name=&quot;Dan&quot;] } </code></pre> <p>Expected output:</p> <pre><code>k45lil69lhfr5942lk </code></pre> <p>I don´t want to be considered as a lazy person, but I don´t really know how to start coding that, I read about <code>startswith</code> and <code>endswith</code> functions, but those only return <code>True/False</code> values.</p> <p>Thanks.</p>
[ { "answer_id": 74251315, "author": "SadLandscape", "author_id": 12770982, "author_profile": "https://Stackoverflow.com/users/12770982", "pm_score": 1, "selected": false, "text": "re.find_all(r\"(?<=animal)(.*?)(?=\\[)\",datastring)" }, { "answer_id": 74251364, "author": "Cobr...
2022/10/30
[ "https://Stackoverflow.com/questions/74251249", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16513260/" ]
74,251,259
<p>I am trying to return an array of objects after retrieving data from two separate collections in mongodb.</p> <p>Since two collections are connected through foreign key, I am trying to do some <em>async await</em> operation to get data one after another and return the result after fulfilling all promises.</p> <p>But the <em>getCommentDetails</em> function is returning an empty array before running the forEach loop.</p> <pre><code>const getCommentDetails = async (id) =&gt; { const commentDetails = []; const comments = await commentsCollection .find({ complain_id: id }) .toArray(); comments.forEach(async (comment) =&gt; { const user = await usersCollection.findOne({ _id: ObjectId(comment.user_id), }); commentDetails.push({ _id: comment._id, complainId: comment.complain_id, userId: comment.user_id, comment: comment.comment, name: user.name, date: comment.createdAt, }); }); return commentDetails;// it returns [] }; const getComments = async (req, res, next) =&gt; { const id = req.params.id; try { const data = await getCommentDetails(id); return res.json(data); } catch (error) { console.log(error); } }; </code></pre>
[ { "answer_id": 74251315, "author": "SadLandscape", "author_id": 12770982, "author_profile": "https://Stackoverflow.com/users/12770982", "pm_score": 1, "selected": false, "text": "re.find_all(r\"(?<=animal)(.*?)(?=\\[)\",datastring)" }, { "answer_id": 74251364, "author": "Cobr...
2022/10/30
[ "https://Stackoverflow.com/questions/74251259", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15082073/" ]
74,251,276
<p>I'm still a beginner in php and need some help from you with my coding. I need to calculate how many layers i can make with the available blocks.</p> <p>see example below. For example, if i have 6 blocks, the pyramide will be 3 layers high, with 10 blocks 4 layers high ect. See example below</p> <p><img src="https://i.stack.imgur.com/0bck4.png" alt="pyramid" /></p> <p>Thank you in advance.</p> <pre><code>&lt;?php $blocks = readline(&quot;Enter how many blocks are available for a pyramid?&quot;) . PHP_EOL; $h = 1; while ($h &lt;= $blocks) { $layers = $h++; } echo $layers; </code></pre> <p>Is there any solution for this?</p>
[ { "answer_id": 74251315, "author": "SadLandscape", "author_id": 12770982, "author_profile": "https://Stackoverflow.com/users/12770982", "pm_score": 1, "selected": false, "text": "re.find_all(r\"(?<=animal)(.*?)(?=\\[)\",datastring)" }, { "answer_id": 74251364, "author": "Cobr...
2022/10/30
[ "https://Stackoverflow.com/questions/74251276", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10403563/" ]
74,251,305
<p>I'd like to set datagrid cell background colour based on its value</p> <p>What I understand is normally, I would need to create a class Then { get: set: } data property, bind data collection to datagrid itemsource, finally use datatrigger to set background color</p> <p>However, in my scenario, data is dynamic instead of static from column 4 (starting from column 'Data001' in below example screenshot)</p> <p>Which means,</p> <ol> <li>number of columns is dynamic;</li> <li>column header name is dynamic;</li> </ol> <p><a href="https://i.stack.imgur.com/mvO7u.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mvO7u.png" alt="enter image description here" /></a></p> <p>So I didn't end up creating data class, instead I put data into a dictionary first</p> <p>And then from dictionary into datatable, convert datatable into dataview and finally bind to ItemsSource.</p> <p>Something like below:</p> <pre class="lang-cs prettyprint-override"><code>//viewModel var dtCalcResult = new DataTable(); DtView = dtCalcResult.AsDataView(); //xaml &lt;DataGrid x:Name=&quot;dtgdTest&quot; HorizontalAlignment=&quot;Stretch&quot; VerticalAlignment=&quot;Stretch&quot; Margin=&quot;10&quot; ItemsSource=&quot;{Binding DtView}&quot; RowHeight=&quot;16&quot; FrozenColumnCount=&quot;3&quot; ColumnHeaderHeight=&quot;24&quot; EnableRowVirtualization=&quot;True&quot; EnableColumnVirtualization=&quot;True&quot; Loaded=&quot;dtgdTest_Load&quot; &gt; </code></pre> <p>Now my question is how to assign cell background colour by its value?</p> <p>I have tried to work with the following way -&gt;</p> <p>Use GetCellContent() to get cell value, then set background colour base on value</p> <p>Something like this:</p> <pre class="lang-cs prettyprint-override"><code> // GET ROW COUNT var rowCount = targetDataGrid.Items.Count; for (int i = 0; i &lt; rowCount; ++i) { // GET ROW OBJECT var row = targetDataGrid.ItemContainerGenerator.ContainerFromIndex(i) as DataGridRow; if (row == null) { // USE ScrollIntoView() TO THAT ROW targetDataGrid.UpdateLayout(); targetDataGrid.ScrollIntoView(targetDataGrid.Items[i]); // TRY TO GET OBJECT AGAIN row = targetDataGrid.ItemContainerGenerator.ContainerFromIndex(i) as DataGridRow; } // GET COLUMN COUNT var columnCount = targetDataGrid.Columns.Count; for (int j = 0; j &lt; columnCount; ++j) { // GET CELL OBJECT var elem = targetDataGrid.Columns[j].GetCellContent(row); if (elem == null) { // USE ScrollIntoView() TO THAT COLUMN targetDataGrid.UpdateLayout(); targetDataGrid.ScrollIntoView(targetDataGrid.Columns[j]); // TRY TO GET OBJECT AGAIN elem = targetDataGrid.Columns[j].GetCellContent(row); } // SET BACKGROUND COLOUR DataGridCell cell = elem.Parent as DataGridCell; string colHeader = targetDataGrid.Columns[j].Header.ToString(); string cellData = _viewModel.DictColNameAndValues[colHeader][i]; //float actHour = _viewModel.DictValueLists_ActHour[colHeader][i]; if (8 &lt; float.Parse(cellData)) { cell.Background = Brushes.Green; } else { cell.Background = Brushes.White; } </code></pre> <p>With above, the result is:</p> <ol> <li>Getting error, after ScrollIntoView(), still cannot get cell value, returns null;</li> <li>While cells without an error, background colour assignment is wrong; (like colour appears to incorrect cells)</li> <li>Once I scroll in view, the assigned colour will shift position;</li> <li>When I load ~1k+ columns, pagination becomes super slow and lag (I felt this one probably need to create a separate thread to ask)</li> </ol> <p>Something like this: <a href="https://i.stack.imgur.com/kmKuS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kmKuS.png" alt="enter image description here" /></a></p> <p>If datagrid is not the best way to do this, is there any other user control or method to archive my goal? (to be able to assign cell background colour when having dynamic columns)</p> <p>I can give it a try if there's any as long as the package license is free to publish</p> <p>Thanks!</p> <hr /> <p><em>2022-Oct30 Update</em></p> <p>Follow up question to @Siegfried.V answer:</p> <p>Here hopefully I made a better example which closer to my real scenario:</p> <p><a href="https://i.stack.imgur.com/P55EA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/P55EA.png" alt="enter image description here" /></a></p> <p>It can show that starting from column-4, column names are all dates</p> <p>The range of dates is also going to be dynamic populated depending on the data source pulled each time. Which means I cannot bind with any static properties unlike first three columns(Name, Pref and Age)</p>
[ { "answer_id": 74251315, "author": "SadLandscape", "author_id": 12770982, "author_profile": "https://Stackoverflow.com/users/12770982", "pm_score": 1, "selected": false, "text": "re.find_all(r\"(?<=animal)(.*?)(?=\\[)\",datastring)" }, { "answer_id": 74251364, "author": "Cobr...
2022/10/30
[ "https://Stackoverflow.com/questions/74251305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20369938/" ]
74,251,314
<p>Next.js 13 is out. One of the refactored components is <code>next/image</code>.</p> <p>I want to use it, but I want to set the image size using tailwind.</p> <p>Here's my code:</p> <pre><code>import Image from 'next/image' const Index = () =&gt; { return ( &lt;div&gt; &lt;Image src=&quot;https://picsum.photos/800/600&quot; layout=&quot;fill&quot; className=&quot;w-48 aspect-square md:w-72 xl:w-48&quot; /&gt; &lt;/div&gt; ) } </code></pre> <p>And I get this error:</p> <blockquote> <p>Error: Image with src &quot;https://picsum.photos/800/600&quot; is missing required &quot;width&quot; property.</p> </blockquote> <p>However, in <a href="https://nextjs.org/docs/basic-features/image-optimization#image-sizing" rel="nofollow noreferrer">docs</a> it's said that it's possible to use <code>fill</code> without specifying the <code>width</code> and <code>height</code>.</p> <p>What do I miss here?</p>
[ { "answer_id": 74252384, "author": "ivanatias", "author_id": 17195992, "author_profile": "https://Stackoverflow.com/users/17195992", "pm_score": 2, "selected": true, "text": "fill" }, { "answer_id": 74526814, "author": "Yilmaz", "author_id": 10262805, "author_profile"...
2022/10/30
[ "https://Stackoverflow.com/questions/74251314", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19390849/" ]
74,251,316
<p>I have to call fetch api till it's response value is updated(response value will get updated only after a time period). let p1 = fetch(url); How to call to this fetch api by executing multiple promise sequentially till the response value is updated</p> <p>I tried to achieve the same using infinite loop. But that did not work. How to achieve this using promise?</p>
[ { "answer_id": 74252384, "author": "ivanatias", "author_id": 17195992, "author_profile": "https://Stackoverflow.com/users/17195992", "pm_score": 2, "selected": true, "text": "fill" }, { "answer_id": 74526814, "author": "Yilmaz", "author_id": 10262805, "author_profile"...
2022/10/30
[ "https://Stackoverflow.com/questions/74251316", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13223078/" ]
74,251,319
<p>I've been learning for 10 days, this is my 1st mini project, I'm asked to build a log in system for employees and 1 admin, with each having a simple menu with multiple options. I must create a txt file with 10 employees each with different charact(id, username, salary..). The employee should enter a username and leave password empty but admin should enter predefined username and password with only 5 wrong attempts allowed. but its not working as intended for admin, when I enter wrong password, it just goes for 5 attempts and state that password limit reached.</p> <pre><code>with open('data.txt') as f: data = f.readlines() dict = {} for r in data: fields = r.split(&quot;,&quot;) id = fields[0] username = fields[1] date = fields[2] gender = fields[3] salary = fields[4] dict[username] = {&quot;id&quot;: id, &quot;name&quot;: username, &quot;date of joining&quot;: date, &quot;gender&quot;: gender, &quot;salary&quot;: salary}#use username as primary key since it is what employee use to log in def log_in(username,password): if username in dict.keys() and password==&quot;&quot;: print(&quot;welcome employee,you will be redirected to employee menu&quot;) menu_employee() elif username not in dict.keys() and password==&quot;&quot; : print(&quot;Incorrect Username &quot;) elif username in dict.keys() and password !=&quot;&quot;: print(&quot;Incorrect Username&quot;) else: for i in range(5,0,-1): if username == &quot;admin&quot; and password == &quot;admin123123&quot;: print(&quot;welcome admin,you will be redirected to admin menu&quot;) menu_admin() else: print(&quot;Incorrect Username and/or password, try again&quot;) if i==1: print(&quot;reached attempt limit&quot;) else: print(&quot;Incorrect Username and/or password, try again&quot;) username = input(&quot;Enter a username: &quot;)#log in menu password = input(&quot;Enter a password: &quot;) </code></pre>
[ { "answer_id": 74252384, "author": "ivanatias", "author_id": 17195992, "author_profile": "https://Stackoverflow.com/users/17195992", "pm_score": 2, "selected": true, "text": "fill" }, { "answer_id": 74526814, "author": "Yilmaz", "author_id": 10262805, "author_profile"...
2022/10/30
[ "https://Stackoverflow.com/questions/74251319", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20364738/" ]
74,251,321
<p>'</p> <pre><code>File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 1006, in _find_and_load_unlocked File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 688, in _load_unlocked File &quot;&lt;frozen importlib._bootstrap_external&gt;&quot;, line 883, in exec_module File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 241, in _call_with_frames_removed File &quot;/Users/mihirshah/Desktop/api/create_area_api/urls.py&quot;, line 3, in &lt;module&gt; from create_area_api.views import api_create_area File &quot;/Users/mihirshah/Desktop/api/create_area_api/views.py&quot;, line 7, in &lt;module&gt; class api_create_area(viewsets.ModelViewSet): File &quot;/Users/mihirshah/Desktop/api/create_area_api/views.py&quot;, line 10, in api_create_area print(queryset.get()) File &quot;/usr/local/lib/python3.10/site-packages/django/db/models/query.py&quot;, line 646, in get num = len(clone) File &quot;/usr/local/lib/python3.10/site-packages/django/db/models/query.py&quot;, line 376, in __len__ self._fetch_all() File &quot;/usr/local/lib/python3.10/site-packages/django/db/models/query.py&quot;, line 1866, in _fetch_all self._result_cache = list(self._iterable_class(self)) File &quot;/usr/local/lib/python3.10/site-packages/django/db/models/query.py&quot;, line 87, in __iter__ results = compiler.execute_sql( File &quot;/usr/local/lib/python3.10/site-packages/django/db/models/sql/compiler.py&quot;, line 1398, in execute_sql cursor.execute(sql, params) File &quot;/usr/local/lib/python3.10/site-packages/django/db/backends/utils.py&quot;, line 103, in execute return super().execute(sql, params) File &quot;/usr/local/lib/python3.10/site-packages/django/db/backends/utils.py&quot;, line 67, in execute return self._execute_with_wrappers( File &quot;/usr/local/lib/python3.10/site-packages/django/db/backends/utils.py&quot;, line 80, in _execute_with_wrappers return executor(sql, params, many, context) File &quot;/usr/local/lib/python3.10/site-packages/django/db/backends/utils.py&quot;, line 84, in _execute with self.db.wrap_database_errors: File &quot;/usr/local/lib/python3.10/site-packages/django/db/utils.py&quot;, line 91, in __exit__ raise dj_exc_value.with_traceback(traceback) from exc_value File &quot;/usr/local/lib/python3.10/site-packages/django/db/backends/utils.py&quot;, line 89, in _execute return self.cursor.execute(sql, params) django.db.utils.ProgrammingError: relation &quot;accounts_project&quot; does not exist LINE 1: ....&quot;start_date&quot;, &quot;accounts_project&quot;.&quot;end_date&quot; FROM &quot;accounts_... </code></pre> <p>`</p> <p>I typed cmd - &quot;python3 manage.py makemigrations&quot; and encountered the above error,</p> <ul> <li>I tried several commands and tried refreshing the database too by changing it,</li> <li>Deleted all the .pyc in migrations and <strong>pycache</strong> folder but still getting the same problem.</li> </ul> <pre><code>python3 manage.py makemigrations </code></pre>
[ { "answer_id": 74252384, "author": "ivanatias", "author_id": 17195992, "author_profile": "https://Stackoverflow.com/users/17195992", "pm_score": 2, "selected": true, "text": "fill" }, { "answer_id": 74526814, "author": "Yilmaz", "author_id": 10262805, "author_profile"...
2022/10/30
[ "https://Stackoverflow.com/questions/74251321", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13760217/" ]
74,251,334
<p>The <code>text</code> does not not update. Here is our code.</p> <pre><code>&lt;some-builder :blaa=&quot;{name: 'something', type: 1}&quot;&gt;&lt;/some-builder&gt; </code></pre> <p>On the <code>some-builder.vue</code></p> <pre><code>&lt;input type=&quot;text&quot; v-model=&quot;blaa.type&quot; /&gt; &lt;button type=&quot;button&quot; @click=&quot;selectType('1')&quot;&gt;1&lt;/button&gt; &lt;button type=&quot;button&quot; @click=&quot;selectType('2')&quot;&gt;2&lt;/button&gt; &lt;button type=&quot;button&quot; @click=&quot;selectType('3')&quot;&gt;3&lt;/button&gt; export default { props: [&quot;blaa&quot;], components: {}, methods: { selectType(t) { this.blaa.type = t; console.log(this.blaa); }, }, }; </code></pre> <p>As you can see we have a click event that would change the <code>type</code> of <code>blaa</code> json. The <code>console.log</code> works just fine but the text box that has model <code>blaa.type</code> does not change.</p> <p>Any help is much appreciated.</p>
[ { "answer_id": 74252384, "author": "ivanatias", "author_id": 17195992, "author_profile": "https://Stackoverflow.com/users/17195992", "pm_score": 2, "selected": true, "text": "fill" }, { "answer_id": 74526814, "author": "Yilmaz", "author_id": 10262805, "author_profile"...
2022/10/30
[ "https://Stackoverflow.com/questions/74251334", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12223830/" ]
74,251,338
<p>I need the code to show all 5 values (with one being a link) in the array item but it is only showing 3 values. This is the code that I'm using:</p> <pre><code>myArrayValues.innerHTML += &quot;&lt;li&gt;&lt;h2&gt;&quot; + myArrayEvent[i][0] + '&lt;/h2&gt;&lt;p&gt;&lt;a href=&quot;myPage.php?itemID=' + [i] + '&quot;&gt;' + myArrayEvent[i][1] + &quot;&lt;/a&gt;&lt;br/&gt;&quot; + myArrayEvent[i][2] + &quot;&lt;/p&gt;&lt;/li&gt;&quot;; } </code></pre> <p>and this is the array values:</p> <pre><code>var myArrayEvent = [ [&quot;United States&quot;, &quot;Drew Bird Photography — California&quot;, &quot;Rockville&quot;, &quot;Contact Info&quot;, &quot;Email Address&quot;] </code></pre> <p>It is only showing until &quot;Rockville&quot;.</p> <p>I am still new to javascript array, and that is the code that I was provided with. In the original sample, there were only 3 values in one array item, and I was asked to turn it into a 5-value array item with headline 1, headline 2, and a link.</p>
[ { "answer_id": 74251689, "author": "Nusrat Jahan", "author_id": 20315115, "author_profile": "https://Stackoverflow.com/users/20315115", "pm_score": 2, "selected": false, "text": "myArrayEvent" }, { "answer_id": 74251701, "author": "dale landry", "author_id": 1533592, ...
2022/10/30
[ "https://Stackoverflow.com/questions/74251338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20370215/" ]
74,251,370
<p>I am trying to reverse the words from a <strong>string = &quot;One Two three Four&quot;</strong> whose length is odd, I am using <strong>StringBuilder</strong> class to reverse the words my expected output is <strong>&quot;enO owT eerht Four&quot;</strong> but I am getting <strong>&quot;eerht enO Two Four&quot;</strong> here the order is not correct also it is not reversing <strong>&quot;Two&quot;</strong>, what's wrong with my code also please provide a solution to it.</p> <pre><code>package QAIntvSprint; import java.util.Arrays; public class SecretAgent { static StringBuilder sb = new StringBuilder(); public static void main(String[] args) { secretAgentII(&quot;One Two three Four&quot;); } static void secretAgentII(String s) { String[] arr = s.split(&quot; &quot;); System.out.println(Arrays.toString(arr)); int i; for (i = 0; i &lt; arr.length; i++) { if (arr[i].length() % 2 == 0) { sb.append(arr[i] + &quot; &quot;); } else { sb.append(arr[i]).reverse().append(&quot; &quot;); } } System.out.println(sb.toString()); } } </code></pre> <p>output is below <a href="https://i.stack.imgur.com/way2H.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/way2H.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74251427, "author": "hfontanez", "author_id": 2851311, "author_profile": "https://Stackoverflow.com/users/2851311", "pm_score": 2, "selected": true, "text": "StringBuilder" }, { "answer_id": 74251445, "author": "Tim Biegeleisen", "author_id": 1863229, "...
2022/10/30
[ "https://Stackoverflow.com/questions/74251370", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13337068/" ]
74,251,404
<p>Say I have a list and I want to append an item to that list.</p> <p>I want the recently added item to flash green for a few seconds so I could easily identify it in the existing list?</p> <pre><code>const mockdata = [ {id: 1, title: 'one'}, {id: 2, title: 'two'}, {id: 3, title: 'three'}, {id: 4, title: 'four', {id: 5, title: 'five'} ] export default function List() { const [data, setData] = useState(mockdata) const addItem = () =&gt; { const newValue = {id: 6, title: 'six'} setData(data =&gt; [...data, newValue]) } return ( &lt;&gt; {data.map((item) =&gt; { return( &lt;div key={item.id}&gt; {item.title} &lt;/div&gt; )}) } &lt;button onClick={() =&gt; handleClick()} &gt; Add Item &lt;/button&gt; &lt;/&gt; ) } </code></pre> <p>I have tried adding an onChange to the div without success.</p> <pre><code>const handleChange = (e) =&gt; { e.target.value.style.backgroundColor = &quot;green&quot; } </code></pre>
[ { "answer_id": 74252336, "author": "Osama Malik", "author_id": 18195045, "author_profile": "https://Stackoverflow.com/users/18195045", "pm_score": 1, "selected": false, "text": "animation-iteration-count: initial;\n" }, { "answer_id": 74258886, "author": "James Prentice", ...
2022/10/30
[ "https://Stackoverflow.com/questions/74251404", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13967147/" ]
74,251,408
<p>I have been dealing with this problem many times and after reading different articles, I still dont know which is the best approach</p> <p>Lets say I have this model:</p> <p>-Author -Category -Book</p> <p>A book cannot exists without an author and a category, so when talking about a post endpoint for a creating a new book, I have fouroptions:</p> <ol> <li><p>myapi/v1/authors/{authorId}/category/{categoryId}/boooks (nesting entities)</p> </li> <li><p>myapi/v1/{authorId}/{categoryId}/boooks (just the foreign keys as path parameters)</p> </li> <li><p>myapi/v1/books/?author={authorId}&amp;category={categoryId} (using query params)</p> </li> <li><p>myapi/v1/books (using a request DTO containing both author and category id)</p> </li> </ol> <p>Which one of these options is the best? Option 1 gives a lot of information about the relations, but it can be difficult to mantain as relationships grow (very long URI)</p> <p>Options 2 and 3 looks fine to me, but I dont know if it is the proper approach</p> <p>Option 4 is easier to read and mantain, but it does not provide information about how book i related to author and category</p> <p>I am open to advice. Thanks!</p> <pre><code>Trying to build a proper and readable post endpoint for a post rest api endpoint </code></pre>
[ { "answer_id": 74252336, "author": "Osama Malik", "author_id": 18195045, "author_profile": "https://Stackoverflow.com/users/18195045", "pm_score": 1, "selected": false, "text": "animation-iteration-count: initial;\n" }, { "answer_id": 74258886, "author": "James Prentice", ...
2022/10/30
[ "https://Stackoverflow.com/questions/74251408", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20370241/" ]
74,251,412
<p>please, I don't know what to do. I want to get (create) rows in Google Sheets from other row by number in this row. From other tab or diferent sheet.</p> <p>For example: Create the second table from the first table. I tried Query and Sequence, but I guess I don't have that skill. Formula ideally based on &quot;query&quot;.</p> <p>1)</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Code</th> <th>PCS</th> <th>Data</th> </tr> </thead> <tbody> <tr> <td>Product1</td> <td>2</td> <td>DataA</td> </tr> <tr> <td>Product2</td> <td>1</td> <td>DataB</td> </tr> <tr> <td>Product3</td> <td>0</td> <td>DataC</td> </tr> <tr> <td>Product4</td> <td>4</td> <td>DataD</td> </tr> </tbody> </table> </div> <p>2)</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Code</th> <th>PCS</th> <th>Data</th> </tr> </thead> <tbody> <tr> <td>Product1</td> <td>2</td> <td>DataA</td> </tr> <tr> <td>Product1</td> <td>2</td> <td>DataA</td> </tr> <tr> <td>Product2</td> <td>1</td> <td>DataB</td> </tr> <tr> <td>Product4</td> <td>4</td> <td>DataD</td> </tr> <tr> <td>Product4</td> <td>4</td> <td>DataD</td> </tr> <tr> <td>Product4</td> <td>4</td> <td>DataD</td> </tr> <tr> <td>Product4</td> <td>4</td> <td>DataD</td> </tr> </tbody> </table> </div>
[ { "answer_id": 74252336, "author": "Osama Malik", "author_id": 18195045, "author_profile": "https://Stackoverflow.com/users/18195045", "pm_score": 1, "selected": false, "text": "animation-iteration-count: initial;\n" }, { "answer_id": 74258886, "author": "James Prentice", ...
2022/10/30
[ "https://Stackoverflow.com/questions/74251412", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7023550/" ]
74,251,458
<p>I was recently writing a program to scrape links from &quot;https://news.ycombinator.com/&quot; but I've tried many methods and whenever I request the link it returns <code>None</code>.</p> <pre><code>import requests from bs4 import BeautifulSoup response = requests.get('https://news.ycombinator.com/') soup = BeautifulSoup(response.text , 'html.parser') links = soup.select('.titleline') print(links[0].get('href')) </code></pre>
[ { "answer_id": 74252336, "author": "Osama Malik", "author_id": 18195045, "author_profile": "https://Stackoverflow.com/users/18195045", "pm_score": 1, "selected": false, "text": "animation-iteration-count: initial;\n" }, { "answer_id": 74258886, "author": "James Prentice", ...
2022/10/30
[ "https://Stackoverflow.com/questions/74251458", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16961823/" ]
74,251,481
<p>My purpose is to gain averages of values stored in child-tables depending on each parent-table. In my case, I want to gain averages of satisfaction stored in the Evaluation model (child) depending on each Professor model (parent).</p> <p>models.py</p> <pre><code>class Professor(models.Model): college = models.CharField(max_length=50, choices=COLLEGE_CHOICES) name = models.CharField(max_length=50) def __str__(self): return self.name class Evaluation(models.Model): name = models.ForeignKey(Professor, on_delete=models.CASCADE, related_name='evaluation_names', null=True) satisfaction = models.IntegerField(choices=SATISFACTION_CHOICES) def __str__(self): return self.comment </code></pre> <p>views.py</p> <pre><code>class ProfessorDetail(generic.DetailView): model = Professor context_object_name = &quot;professor_detail&quot; template_name = &quot;professors/professor_detail.html&quot; def get_context_data(self, *args, **kwargs): context = super().get_context_data(*args, **kwargs) context['avgs'] = Professor.objects.all().evaluation_set.all().annotate(avg_satisfactions=Avg('satisfaction')) return context </code></pre> <p>professors/professor_detail.html</p> <pre><code> {% for evaluation in avgs %} &lt;p&gt;{{ evaluation.avg_satisfactions }}&lt;/p&gt; {% endfor %} </code></pre> <p>I tried following codes for views.py.</p> <ol> <li><code>context['avgs'] = Professor.objects.all().evaluation_set.all().annotate(avg_satisfactions=Avg('satisfaction'))</code></li> <li><code>context['avgs'] = Professor.objects.prefetch_related().all().annotate(avg_satisfactions=Avg('satisfaction'))</code></li> <li><code>context['avgs'] = Professor.objects.all().prefetch_related(Prefetch('evaluation_set', queryset=Evaluation.objects.all().annotate(avg_satisfactions=Avg('satisfaction'))))</code></li> </ol> <p>But, all of them do not work.</p>
[ { "answer_id": 74251827, "author": "Alombaros", "author_id": 20263044, "author_profile": "https://Stackoverflow.com/users/20263044", "pm_score": 0, "selected": false, "text": "Professor.objects.annotate(avg_satisfaction=Avg(\"evaluation_names__satisfaction\"))\n" }, { "answer_id"...
2022/10/30
[ "https://Stackoverflow.com/questions/74251481", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19071913/" ]
74,251,497
<p>How would I make commands for an input tag. For example, when you type <code>!echo 'test'</code> in an text input it would edit the content of a p tag</p> <p>I tried this</p> <pre class="lang-html prettyprint-override"><code>&lt;input type=&quot;text id=&quot;input&quot; onchange=&quot;update()&quot;/&gt; &lt;p id=&quot;output&quot;&gt;&lt;/p&gt; </code></pre> <pre class="lang-js prettyprint-override"><code>function update(){ var x = document.getElementById(&quot;input&quot;).value; if(x == &quot;!echo &quot;, args){ document.getElementById(&quot;output&quot;).innerHTML = x; } } </code></pre>
[ { "answer_id": 74251964, "author": "tatactic", "author_id": 1247977, "author_profile": "https://Stackoverflow.com/users/1247977", "pm_score": 0, "selected": false, "text": " <input type=\"text\" id=\"input\" onKeyUp=\"update('\\'test\\'')\">\n <p id=\"output\"></p>\n" }, { ...
2022/10/30
[ "https://Stackoverflow.com/questions/74251497", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17920096/" ]
74,251,510
<p>i have a string like <code>var string = &quot;5+7+10&quot;</code></p> <p>is there a way to turn this into a double and add them all up and get</p> <p><code>var double = 22.0</code></p> <p>i tried to store operators and numbers in seperate variables but it still does not work when i try to add them up</p>
[ { "answer_id": 74251964, "author": "tatactic", "author_id": 1247977, "author_profile": "https://Stackoverflow.com/users/1247977", "pm_score": 0, "selected": false, "text": " <input type=\"text\" id=\"input\" onKeyUp=\"update('\\'test\\'')\">\n <p id=\"output\"></p>\n" }, { ...
2022/10/30
[ "https://Stackoverflow.com/questions/74251510", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14938636/" ]
74,251,511
<p>I am writing discord bot on python (discord.py). This bot for many servers and I want to make cooldown system. This looks like this: User uses command on the first server and if he uses it again, bot will tell user that command on cooldown, but if user will go to the second server, command will work without cooldown that is on the first server.</p>
[ { "answer_id": 74251964, "author": "tatactic", "author_id": 1247977, "author_profile": "https://Stackoverflow.com/users/1247977", "pm_score": 0, "selected": false, "text": " <input type=\"text\" id=\"input\" onKeyUp=\"update('\\'test\\'')\">\n <p id=\"output\"></p>\n" }, { ...
2022/10/30
[ "https://Stackoverflow.com/questions/74251511", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20165331/" ]
74,251,530
<pre><code> struct khatian{ uint64 khatianiId; bytes32 plotHash; uint16 percentOwn; bytes32 buyFrom; bytes32[] sellTo; uint16[] sellPercentage; uint[] ownerArray; uint16[] perOwnerPercentage; bool isExist; } </code></pre> <pre><code>function addKhatianFromOld(uint64 _khatianiId, bytes32 _plotHash, uint16 _percentOwn, bytes32 _buyFrom, uint[] _user, uint16[] _percentage) public{ require(msg.sender == contarctOwner, &quot;Sender is not authorized&quot;); require(plotMapping[_plotHash].isExist == true, &quot;Plot doesn't exist&quot;); bytes32 khatianHash = keccak256(abi.encodePacked(_khatianiId, _plotHash)); require(khatianMapping[khatianHash].isExist != true, &quot;Khatian already exists&quot;); require(khatianMapping[_buyFrom].isExist, &quot;previous Khatian doesn't exist&quot;); require(khatianMapping[_buyFrom].percentOwn &gt;= _percentOwn, &quot;Not enough land to sell&quot;); for(uint j = 0; j&lt; _user.length; j++){ require(userMapping[_user[j]].isExist == true, &quot;User's NID doesn't exist&quot;); } </code></pre> <p>This are my code snippet. I getting this error</p> <pre><code> ''Error: expected array value (argument=null, value=&quot;1&quot;, code=INVALID_ARGUMENT, version=abi/5.5.0)'' </code></pre> <p>What type of data should I give input here? specially in bytes32_buyFrom, uint[] _user, uint16[] _percentage?</p> <p>I tried to give address and other string as input</p>
[ { "answer_id": 74251964, "author": "tatactic", "author_id": 1247977, "author_profile": "https://Stackoverflow.com/users/1247977", "pm_score": 0, "selected": false, "text": " <input type=\"text\" id=\"input\" onKeyUp=\"update('\\'test\\'')\">\n <p id=\"output\"></p>\n" }, { ...
2022/10/30
[ "https://Stackoverflow.com/questions/74251530", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20370363/" ]
74,251,556
<p>I'm currently trying to parse <a href="https://easyupload.io/8nncki" rel="nofollow noreferrer">excel files</a> that contain somewhat structured information. The data I am interested in is in a subrange of an excel sheet. Basically the excel contains key-value pairs where the key is usually named in a predictable manner (found with regex). Keys are in the same column and the value pair is on the right side of the key in the excel sheet.</p> <p>Regex pattern <code>pattern = r'[Tt]emperature|[Ss]tren|[Cc]omment' </code> predictably matches the keys. Therefore if I can find the column where the keys are located and the rows where the keys are present, I am able to find the subrange of interest and parse it further.</p> <p>Goals:</p> <ol> <li>Get list of row indices that match regex (e.g. <code>[5, 6, 8, 9]</code>)</li> <li>Find which column contains keys that match regex (e.g. <code>Unnamed: 3</code>)</li> </ol> <p><a href="https://i.stack.imgur.com/hevO8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hevO8.png" alt="Image of original excel" /></a></p> <p>When I read in the excel using <code>df_original = pd.read_excel(filename, sheet_name=sheet)</code> the dataframe looks like this</p> <pre><code>df_original = pd.DataFrame({'Unnamed: 0':['Value', 'Name', np.nan, 'Mark', 'Molly', 'Jack', 'Tom', 'Lena', np.nan, np.nan], 'Unnamed: 1':['High', 'New York', np.nan, '5000', '5250', '4600', '2500', '4950', np.nan, np.nan], 'Unnamed: 2':[np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan], 'Unnamed: 3':['Other', 125, 127, np.nan, np.nan, 'Temperature (C)', 'Strength', np.nan, 'Temperature (F)', 'Comment'], 'Unnamed: 4':['Other 2', 25, 14.125, np.nan, np.nan, np.nan, '1500', np.nan, np.nan, np.nan], 'Unnamed: 5':[np.nan, np.nan, np.nan, np.nan, np.nan, 25, np.nan, np.nan, 77, 'Looks OK'], 'Unnamed: 6':[np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, 'Add water'], }) +----+--------------+--------------+--------------+-----------------+--------------+--------------+--------------+ | | Unnamed: 0 | Unnamed: 1 | Unnamed: 2 | Unnamed: 3 | Unnamed: 4 | Unnamed: 5 | Unnamed: 6 | |----+--------------+--------------+--------------+-----------------+--------------+--------------+--------------| | 0 | Value | High | nan | Other | Other 2 | nan | nan | | 1 | Name | New York | nan | 125 | 25 | nan | nan | | 2 | nan | nan | nan | 127 | 14.125 | nan | nan | | 3 | Mark | 5000 | nan | nan | nan | nan | nan | | 4 | Molly | 5250 | nan | nan | nan | nan | nan | | 5 | Jack | 4600 | nan | Temperature (C) | nan | 25 | nan | | 6 | Tom | 2500 | nan | Strength | 1500 | nan | nan | | 7 | Lena | 4950 | nan | nan | nan | nan | nan | | 8 | nan | nan | nan | Temperature (F) | nan | 77 | nan | | 9 | nan | nan | nan | Comment | nan | Looks OK | Add water | +----+--------------+--------------+--------------+-----------------+--------------+--------------+--------------+ </code></pre> <p>This code finds the rows of interest and solves Goal 1.</p> <pre><code>df = df_original.dropna(how='all', axis=1) pattern = r'[Tt]emperature|[Ss]tren|[Cc]omment' mask = np.column_stack([df[col].str.contains(pattern, regex=True, na=False) for col in df]) row_range = df.loc[(mask.any(axis=1))].index.to_list() print(df.loc[(mask.any(axis=1))].index.to_list()) [5, 6, 8, 9] display(df.loc[row_range]) +----+--------------+--------------+-----------------+--------------+--------------+--------------+ | | Unnamed: 0 | Unnamed: 1 | Unnamed: 3 | Unnamed: 4 | Unnamed: 5 | Unnamed: 6 | |----+--------------+--------------+-----------------+--------------+--------------+--------------| | 5 | Jack | 4600 | Temperature (C) | nan | 25 | nan | | 6 | Tom | 2500 | Strength | 1500 | nan | nan | | 8 | nan | nan | Temperature (F) | nan | 77 | nan | | 9 | nan | nan | Comment | nan | Looks OK | Add water | +----+--------------+--------------+-----------------+--------------+--------------+--------------+ </code></pre> <p>What is the easiest way to solve Goal 2? Basically I want to find columns that contain at least one value that matches the regex pattern. The wanted output would be <code>[Unnamed: 5]</code>. There may be some easy way to solve goals 1 and 2 at the same time. For example:</p> <pre><code>col_of_interest = 'Unnamed: 3' # &lt;- find this value col_range = df_original.columns[df_original.columns.to_list().index(col_of_interest): ] print(col_range) Index(['Unnamed: 3', 'Unnamed: 4', 'Unnamed: 5', 'Unnamed: 6'], dtype='object') target = df_original.loc[row_range, col_range] display(target) +----+-----------------+--------------+--------------+--------------+ | | Unnamed: 3 | Unnamed: 4 | Unnamed: 5 | Unnamed: 6 | |----+-----------------+--------------+--------------+--------------| | 5 | Temperature (C) | nan | 25 | nan | | 6 | Strength | 1500 | nan | nan | | 8 | Temperature (F) | nan | 77 | nan | | 9 | Comment | nan | Looks OK | Add water | +----+-----------------+--------------+--------------+--------------+ </code></pre>
[ { "answer_id": 74251869, "author": "ouroboros1", "author_id": 18470692, "author_profile": "https://Stackoverflow.com/users/18470692", "pm_score": 0, "selected": false, "text": "NaN" }, { "answer_id": 74251878, "author": "sammywemmy", "author_id": 7175713, "author_prof...
2022/10/30
[ "https://Stackoverflow.com/questions/74251556", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16868163/" ]
74,251,563
<p>Because I am dealing with an environment with certain memory constraints, I need to allocate a very large statically sized array at the beginning of my program's execution:</p> <pre><code>let mut data: [Foo; 1024] = ? </code></pre> <p>How can I initialize this array with &quot;empty&quot; data?</p> <p>I have tried using the <code>default</code> method, since <code>Foo</code> also has a default:</p> <pre><code>let mut data: [Foo; 1024] = Default::default(), </code></pre> <p>but it doesn't work, because <code>array</code> only implements default for a fixed set of sizes:</p> <pre><code>error[E0277]: the trait bound `[foo::Foo; 1024]: std::default::Default` is not satisfied --&gt; /src/foo.rs:143:22 | 143 | = Default::default(), | ^^^^^^^^^^^^^^^^ the trait `std::default::Default` is not implemented for `[foo::Foo; 1024]` | = help: the following other types implement trait `std::default::Default`: &amp;[T] &amp;mut [T] [T; 0] [T; 10] [T; 11] [T; 12] [T; 13] [T; 14] and 27 others </code></pre> <p>How can I initialize such a large statically sized array without typing a giant literal in my code?</p>
[ { "answer_id": 74251792, "author": "Miiao", "author_id": 20028181, "author_profile": "https://Stackoverflow.com/users/20028181", "pm_score": 2, "selected": false, "text": "[{data}; {times}]" }, { "answer_id": 74252009, "author": "prog-fh", "author_id": 11527076, "auth...
2022/10/30
[ "https://Stackoverflow.com/questions/74251563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/814570/" ]
74,251,571
<p>When I SSH to another server thare are some blurbs of text that always outputs when you log in. (wheather its SSH or just logging in to its own session)</p> <p>&quot;Authentification banner&quot; is what it prints out every time i either scp a file over or SSH into it.</p> <p>My code iterates thru a list of servers and sends a file, each time it does that it outputs a lot of text id like to suppress.</p> <p>This code loops thru each server printing out what its doing.</p> <pre><code>for(my $j=0; $j &lt; $#servName+1; $j++) { print &quot;\n\nSending file: $fileToTransfer to \n$servName[$j]:$targetLocation\n\n&quot;; my $sendCommand = `scp $fileToTransfer $servName[$j]:$targetLocation`; print $sendCommand; } </code></pre> <p>But then it comes out like this:</p> <pre><code>Sending file: /JacobsScripts/AddAlias.pl to denamap2:/release/jscripts ==================================================== Welcome authorized users. This system is company property and unauthorized access or use is prohibited and may subject you to discipline, civil suit or criminal prosecution. To the extent permitted by law, system use and information may be monitored, recorded or disclosed. Using this system constitutes your consent to do so. You also agree to comply with applicable company procedures for system use and the protection of sensitive (including export controlled) data. ==================================================== Sending file: /JacobsScripts/AddAlias.pl to denfpev1:/release/jscripts ==================================================== Welcome authorized users. This system is company property and unauthorized access or use is prohibited and may subject you to discipline, civil suit or criminal prosecution. To the extent permitted by law, system use and information may be monitored, recorded or disclosed. Using this system constitutes your consent to do so. You also agree to comply with applicable company procedures for system use and the protection of sensitive (including export controlled) data. ==================================================== </code></pre> <p>I havent tried much, i saw a few forums that mention taking the output into a file and then delete it but idk if thatll work for my situation.</p>
[ { "answer_id": 74256167, "author": "zdim", "author_id": 4653379, "author_profile": "https://Stackoverflow.com/users/4653379", "pm_score": 2, "selected": false, "text": "ssh" }, { "answer_id": 74264311, "author": "ikegami", "author_id": 589924, "author_profile": "https...
2022/10/30
[ "https://Stackoverflow.com/questions/74251571", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20313503/" ]
74,251,602
<p>For example, <code>most_average([1, 2, 3, 4, 5])</code> should return 3 (the average of the numbers in the list is 3.0, and 3 is clearly closest to this). <code>most_average([3, 4, 3, 1])</code> should also return 3 (the average is 2.75, and 3 is closer to 2.75 than is any other number in the list).</p> <p>This is what I have right now:</p> <pre class="lang-py prettyprint-override"><code>def most_average(numbers): sum = 0 for num in numbers: sum += num result = sum / len(numbers) return result </code></pre> <p>I can only get the normal average, but I don't know how to find the most closest number in the list.</p>
[ { "answer_id": 74251619, "author": "ShlomiF", "author_id": 5024514, "author_profile": "https://Stackoverflow.com/users/5024514", "pm_score": 2, "selected": false, "text": "min" }, { "answer_id": 74251639, "author": "Fra93", "author_id": 4952549, "author_profile": "htt...
2022/10/30
[ "https://Stackoverflow.com/questions/74251602", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19689268/" ]
74,251,631
<p>I have an HTML textarea and when the user types on it, I need to print the character that the user inputs to the console.</p> <p>So I tried the following code</p> <p>HTML (<code>index.html</code>):</p> <pre class="lang-html prettyprint-override"><code>&lt;textarea id=&quot;editor&quot;&gt;&lt;/textarea&gt; </code></pre> <p>TypeScript (<code>script.ts</code>):</p> <pre><code>const editor = document.getElementById(&quot;editor&quot;) as HTMLTextAreaElement; editor.addEventListener(&quot;input&quot;, e =&gt; { console.log(e.data); }); </code></pre> <p>This works well as I expected but when compiling this TypeScript code to JavaScript, the compiler gives the following error:</p> <pre><code>script.ts:4:19 - error TS2339: Property 'data' does not exist on type 'Event'. 4 console.log(e.data); ~~~~ Found 1 error in script.ts:4 </code></pre> <p>How do I fix this?</p>
[ { "answer_id": 74251987, "author": "Lord-JulianXLII", "author_id": 19529102, "author_profile": "https://Stackoverflow.com/users/19529102", "pm_score": 0, "selected": false, "text": "event" }, { "answer_id": 74252071, "author": "Zsolt Meszaros", "author_id": 6126373, "...
2022/10/30
[ "https://Stackoverflow.com/questions/74251631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19099302/" ]
74,251,635
<p>Hello Im trying to get data from the Jasonplaceholder Api, and I want to map it in a dart model but I tried videos on YouTube and none of them work and I use autogenerated models but the data that received are inside a list but in that list have nested maps</p> <pre><code> var myMap=[{ &quot;name&quot; : &quot;Ravindu&quot;, &quot;age&quot; : 20, &quot;scl&quot; : &quot;smc&quot;, &quot;address&quot; : { &quot;city&quot; : &quot;Kegalle&quot;, &quot;country&quot; : &quot;sri lanka&quot; } }, { &quot;name&quot; : &quot;Ravindu1&quot;, &quot;age&quot; : 20, &quot;scl&quot; : &quot;smc1&quot;, &quot;address&quot; : { &quot;city&quot; : &quot;Kegalle1&quot;, &quot;country&quot; : &quot;sri lanka1&quot; } }]; </code></pre> <p>like this I want this to map to a Molde class and also, I want to know how to access Items inside this map tried <code>myMap[0][&quot;address&quot;]</code> but it only retrieve the whole map of address in the 0 index</p> <p>so How can I pass these type of Json data to a model class</p> <p>this is the actual url im working with</p> <p>'''final String url =&quot;https://jsonplaceholder.typicode.com/users&quot;'''</p> <p>I get this error when I try this on darpad</p> <p>Uncaught Error: TypeError: Instance of 'JsLinkedHashMap&lt;String, String&gt;': type 'JsLinkedHashMap&lt;String, String&gt;' is not a subtype of type 'List'</p> <p>this is the code I tried on dartpad</p> <pre><code>void main() { var myMap=[{ &quot;name&quot; : &quot;Ravindu&quot;, &quot;age&quot; : 20, &quot;scl&quot; : &quot;smc&quot;, &quot;address&quot; : { &quot;city&quot; : &quot;Kegalle&quot;, &quot;country&quot; : &quot;sri lanka&quot; } }, { &quot;name&quot; : &quot;Ravindu1&quot;, &quot;age&quot; : 20, &quot;scl&quot; : &quot;smc1&quot;, &quot;address&quot; : { &quot;city&quot; : &quot;Kegalle1&quot;, &quot;country&quot; : &quot;sri lanka1&quot; } }]; print(myMap[0]); var addressList = myMap[0][&quot;address&quot;][&quot;city&quot;]; print(addressList); (addressList as List).forEach((i){ print(i[&quot;country&quot;]); }); } </code></pre>
[ { "answer_id": 74251718, "author": "Yeasin Sheikh", "author_id": 10157127, "author_profile": "https://Stackoverflow.com/users/10157127", "pm_score": 2, "selected": false, "text": "addressList" }, { "answer_id": 74251828, "author": "Alexandru Mariuti", "author_id": 1536161...
2022/10/30
[ "https://Stackoverflow.com/questions/74251635", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20370427/" ]
74,251,650
<p>I have the following error when I pass in a function to another function?</p> <pre class="lang-rust prettyprint-override"><code>const std = @import(&quot;std&quot;); const St = struct { a: usize }; fn returnFunc(print: fn (str: []const u8, st: St) void) void { print(&quot;Hello&quot;, St{ .a = 1 }); } fn toTest(str: []const u8, st: St) void { std.debug.print(&quot;{s}: {d}\n&quot;, .{str, st.a}); } pub fn main() !void { returnFunc(toTest); } </code></pre> <p>Return the following error:</p> <pre><code>error: parameter of type 'fn([]const u8, main.St) void' must be declared comptime </code></pre> <p><strong>Machine details:</strong> Zig version: 0.10.0-dev.4588+9c0d975a0 M1 Mac, MAC OS Ventura</p>
[ { "answer_id": 74251781, "author": "Himujjal", "author_id": 6697318, "author_profile": "https://Stackoverflow.com/users/6697318", "pm_score": 0, "selected": false, "text": "returnFunc" }, { "answer_id": 74252762, "author": "sigod", "author_id": 944911, "author_profile...
2022/10/30
[ "https://Stackoverflow.com/questions/74251650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6697318/" ]
74,251,710
<p>so basically i have 20 lists and i want to find the mean of those lists. however, i don't know how to manipulate the code in order to do it efficiently. currently i am plugging each list into the mean function one by one and it is very time consuming. is there any way that i can do this quickly?</p> <p>each individual list of numbers is down below. help would be very much appreciated!</p> <pre><code>`import statistics import math def mean(data): answer = sum(data)/len(data) return answer samples = [153.43, 161.45, 166.74, 167.28, 185.09] [161.44, 175.4, 166.38, 174.19, 167.24] [177.46, 176.65, 165.96, 171.52, 153.38] [183.94, 189.5, 174.21, 176.17, 187.07] [183.34, 165.49, 172.63, 158.5, 164.52] [179.93, 172.61, 156.15, 165.89, 158.5] [164.91, 174.71, 178.26, 176.74, 188.23] [188.7, 181.8, 174.1, 167.18, 166.6] [168.44, 162.14, 174.66, 173.89, 177.69] [183.84, 161.34, 165.76, 173.74, 173.39] [156.99, 173.59, 174.17, 177.2, 164.2] [166.34, 179.78, 160.13, 166.54, 169.55] [164.3, 172.07, 167.35, 184.02, 174.3] [161.53, 161.77, 171.62, 165.17, 190.27] [173.94, 170.21, 173.68, 172.77, 166.62] [165.76, 156.93, 160.18, 166.27, 169.14] [183.99, 174.7, 159.05, 161.27, 164.46] [155.29, 161.3, 164.67, 174.18, 171.12] [180.6, 177.58, 168.16, 173.81, 161.27] [191.13, 170.21, 166.62, 173.56, 171.56] ``` `` </code></pre>
[ { "answer_id": 74251781, "author": "Himujjal", "author_id": 6697318, "author_profile": "https://Stackoverflow.com/users/6697318", "pm_score": 0, "selected": false, "text": "returnFunc" }, { "answer_id": 74252762, "author": "sigod", "author_id": 944911, "author_profile...
2022/10/30
[ "https://Stackoverflow.com/questions/74251710", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20370502/" ]
74,251,728
<p>I am working with a React project and I was trying to add a content after I clicked on a link to show that it's active, but it keeps popping out that bug. Is there any way I can fix this?</p> <p>This is my code below:</p> <pre><code>const activeClassName = 'relative before:content-[' * '] before:-top-4 before:left-1/2 before:-ml-1 before:absolute before:text-amber-400' </code></pre>
[ { "answer_id": 74251781, "author": "Himujjal", "author_id": 6697318, "author_profile": "https://Stackoverflow.com/users/6697318", "pm_score": 0, "selected": false, "text": "returnFunc" }, { "answer_id": 74252762, "author": "sigod", "author_id": 944911, "author_profile...
2022/10/30
[ "https://Stackoverflow.com/questions/74251728", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20282456/" ]
74,251,729
<p>I'm referencing the instruction on <a href="https://developer.chrome.com/docs/extensions/reference/tabs/#get-the-current-tab" rel="nofollow noreferrer">https://developer.chrome.com/docs/extensions/reference/tabs/#get-the-current-tab</a>.</p> <p>I know there are many questions on this but I want to get the url of the current tab. The problem is I'm getting an error I'm struggling to understand.</p> <p><code>Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'query')</code></p> <p>I've tried moving the snippet of code to the background.js, pop.js, and the content.js files.</p> <p>background.js</p> <pre class="lang-js prettyprint-override"><code>async function getTabUrl() { const [tab] = await chrome.tabs.query({ active: true, lastFocusedWindow: true }); console.log(tab); return tab[0].url; } getTabUrl().then(tab =&gt; console.log(tab)) </code></pre> <p>manifest.json</p> <pre class="lang-js prettyprint-override"><code>{ &quot;manifest_version&quot;: 3, &quot;name&quot;: &quot;...&quot;, &quot;description&quot;: &quot;...&quot;, &quot;version&quot;: &quot;1&quot;, &quot;action&quot;: { &quot;default_popup&quot;: &quot;popup.html&quot;, &quot;default_icon&quot;: &quot;icons/favicon.ico&quot; }, &quot;background&quot;: { &quot;service_worker&quot;: &quot;background.js&quot; }, &quot;content_scripts&quot;: [ { &quot;js&quot;: [ &quot;scripts/content.js&quot; ], &quot;matches&quot;: [ ... ] } ], &quot;permissions&quot;: [ &quot;activeTab&quot; ] } </code></pre> <p>scripts/content.js is blank.</p>
[ { "answer_id": 74251781, "author": "Himujjal", "author_id": 6697318, "author_profile": "https://Stackoverflow.com/users/6697318", "pm_score": 0, "selected": false, "text": "returnFunc" }, { "answer_id": 74252762, "author": "sigod", "author_id": 944911, "author_profile...
2022/10/30
[ "https://Stackoverflow.com/questions/74251729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8278075/" ]
74,251,780
<p>I have 2 tables connected with each other, for simplicity lets say ID of the 1st is connected to UserCreated_FK of the 2nd table.</p> <p>Table A:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>ID</th> <th>NAME</th> </tr> </thead> <tbody> <tr> <td>237</td> <td>Gal</td> </tr> <tr> <td>240</td> <td>blah</td> </tr> <tr> <td>250</td> <td>blah2</td> </tr> </tbody> </table> </div> <p>in the parallel table ( aka table B ) I have the following:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>UserCreated_FK</th> <th>col2</th> </tr> </thead> <tbody> <tr> <td>237</td> <td>10/10</td> </tr> <tr> <td>20 more rows of 237</td> <td>20 more rows of 237</td> </tr> <tr> <td>240</td> <td>11/10</td> </tr> <tr> <td>5 more rows of 240</td> <td>20 more rows of 240</td> </tr> <tr> <td>250</td> <td>12/10</td> </tr> <tr> <td>14 more rows of 250</td> <td>20 more rows of 250</td> </tr> </tbody> </table> </div> <p>Result wanted: id.237 x10 last(might be sorted by date col I have).</p> <p>no 240 (cause less than 10).</p> <p>id.250 x10 last records(might be sorted by date col I have).</p> <p>My task is to check which of those IDs(person'sIds) have more then 10 records on table B ( because table A is just the ids and names not the actual records of them.</p> <p>So for example, ID no.237 got 19 records on table B I want to be able to pull the last 10 records of that user.</p> <p>And again, the condition is only users that have more than 10 records, then to pull the last of 10 of those..</p> <p>Hope I was understandable, thanks a lot, any help will be appreciated!</p>
[ { "answer_id": 74251781, "author": "Himujjal", "author_id": 6697318, "author_profile": "https://Stackoverflow.com/users/6697318", "pm_score": 0, "selected": false, "text": "returnFunc" }, { "answer_id": 74252762, "author": "sigod", "author_id": 944911, "author_profile...
2022/10/30
[ "https://Stackoverflow.com/questions/74251780", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
74,251,783
<p>I'm trying to fill table with values which I'm getting from the database but when I loop though array some values are getting out of the table.</p> <p>DB values image: <a href="https://i.stack.imgur.com/JjukY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JjukY.png" alt="enter image description here" /></a></p> <p>DB structure with dump: <a href="https://www.db-fiddle.com/f/9gTDRBFnguHtagJC4YNnRg/5" rel="nofollow noreferrer">https://www.db-fiddle.com/f/9gTDRBFnguHtagJC4YNnRg/5</a></p> <p><strong>DB Values Explanation:</strong></p> <p>Data column contains JSON format data of users activity.</p> <p>For example</p> <p><strong>January:</strong></p> <pre><code>{ &quot;Jan&quot;:&quot;1563&quot;, // Total users registered in January &quot;Feb&quot;:&quot;0&quot;, &quot;Mar&quot;:&quot;0&quot;, &quot;Apr&quot;:&quot;0&quot;, &quot;May&quot;:&quot;0&quot;, &quot;Jun&quot;:&quot;0&quot;, &quot;Jul&quot;:&quot;13&quot;, // Out of 1563 registered users only 13 users are active in July &quot;Aug&quot;:&quot;7&quot;, // Out of 1563 registered users only 7 users are active in August &quot;Sep&quot;:&quot;4&quot;, // Out of 1563 registered users only 4 users are active in September &quot;Oct&quot;:&quot;0&quot;, &quot;Nov&quot;:&quot;0&quot;, &quot;Dec&quot;:&quot;0&quot; } </code></pre> <p><strong>February:</strong></p> <pre><code> { &quot;Feb&quot;:&quot;1727&quot;, // Total users registered in February &quot;Mar&quot;:&quot;0&quot;, &quot;Apr&quot;:&quot;0&quot;, &quot;May&quot;:&quot;0&quot;, &quot;Jun&quot;:&quot;0&quot;, &quot;Jul&quot;:&quot;10&quot;, // Out of 1727 registered users only 10 users are active in July &quot;Aug&quot;:&quot;11&quot;, // Out of 1727 registered users only 11 users are active in August &quot;Sep&quot;:&quot;8&quot;, // Out of 1727 registered users only 8 users are active in September &quot;Oct&quot;:&quot;0&quot;, &quot;Nov&quot;:&quot;0&quot;, &quot;Dec&quot;:&quot;0&quot; } </code></pre> <p>Code:</p> <pre><code>$query = &quot;SELECT * FROM monthly_report&quot;; $result = $this-&gt;db-&gt;query($query)-&gt;result_array(); $data['data'] = $result; </code></pre> <pre><code>&lt;table class=&quot;table table-hover table-striped&quot;&gt; &lt;thead&gt; &lt;tr&gt; &lt;th style=&quot;text-align:center;&quot;&gt;Month&lt;/th&gt; &lt;th style=&quot;text-align:center;&quot;&gt;Total Registered&lt;/th&gt; &lt;th style=&quot;text-align:center;&quot;&gt;January&lt;/th&gt; &lt;th style=&quot;text-align:center;&quot;&gt;February&lt;/th&gt; &lt;th style=&quot;text-align:center;&quot;&gt;March&lt;/th&gt; &lt;th style=&quot;text-align:center;&quot;&gt;April&lt;/th&gt; &lt;th style=&quot;text-align:center;&quot;&gt;May&lt;/th&gt; &lt;th style=&quot;text-align:center;&quot;&gt;June&lt;/th&gt; &lt;th style=&quot;text-align:center;&quot;&gt;July&lt;/th&gt; &lt;th style=&quot;text-align:center;&quot;&gt;August&lt;/th&gt; &lt;th style=&quot;text-align:center;&quot;&gt;September&lt;/th&gt; &lt;th style=&quot;text-align:center;&quot;&gt;October&lt;/th&gt; &lt;th style=&quot;text-align:center;&quot;&gt;November&lt;/th&gt; &lt;th style=&quot;text-align:center;&quot;&gt;December&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;?php $num = 0; for ($m = 1; $m &lt;= 12; $m++) { $month = date('F', mktime(0, 0, 0, $m, 1, date('Y'))); echo &quot;&lt;tr style='text-align:center;'&gt;&quot;; echo &quot;&lt;td&gt;&quot; . $month . &quot;&lt;/td&gt;&quot;; $short_month_name = date('M', strtotime(&quot;2022-$m-01&quot;)); if (isset($data[$num]['month']) &amp;&amp; $data[$num]['month'] == $short_month_name) { $decode_data = json_decode($data[$num]['data'], true); $decode_isset = isset($decode_data[$short_month_name]) ? $decode_data[$short_month_name] : ''; echo &quot;&lt;td&gt;&quot; . $decode_isset . &quot;&lt;/td&gt;&quot;; } $num_1 = 0; for ($day = 1; $day &lt;= 12; $day++) { $short_month_name_1 = date('M', strtotime(&quot;2022-$day-01&quot;)); if (isset($data[$num]['month']) &amp;&amp; $data[$num]['month'] == $short_month_name_1) { $decode_data_1 = json_decode($data[$num]['data'], true); $decode_isset_1 = isset($decode_data_1) ? $decode_data_1 : []; foreach ($decode_isset_1 as $v) { if (!empty($v)) { echo &quot;&lt;td&gt;&quot; . $v . &quot;&lt;/td&gt;&quot;; } else { echo &quot;&lt;td&gt;0&lt;/td&gt;&quot;; } } } else { echo &quot;&lt;td&gt;0&lt;/td&gt;&quot;; } $num_1++; } echo &quot;&lt;/tr&gt;&quot;; $num++; } ?&gt; &lt;/tbody&gt; &lt;/table&gt; </code></pre> <p>And output is:</p> <p><a href="https://i.stack.imgur.com/1bHMC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1bHMC.png" alt="enter image description here" /></a></p> <p>In above output vertical months are registered users count and horizontal rows are their activity.</p> <p>Example:</p> <p>In vertical January month 1563 users are registered, in same row horizontal January has 1563 because registration will count as their activity. In same row July month 13 users are active out of 1563 registered users and same goes on for other months of same row.</p> <p>I'm getting values in expected tds but want to remove extra generated td (Marked in red box).</p>
[ { "answer_id": 74251781, "author": "Himujjal", "author_id": 6697318, "author_profile": "https://Stackoverflow.com/users/6697318", "pm_score": 0, "selected": false, "text": "returnFunc" }, { "answer_id": 74252762, "author": "sigod", "author_id": 944911, "author_profile...
2022/10/30
[ "https://Stackoverflow.com/questions/74251783", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11438589/" ]
74,251,796
<p>I am using <strong>WSO2 Integration Studio 8.1.0</strong> to develop an API on my machine, and when trying to run on Micro Integrator, I get the following error :</p> <pre><code>ERROR {Framework} - FrameworkEvent ERROR org.osgi.framework.BundleException: Could not resolve module: org.wso2.carbon.capp.monitor [170] Unresolved requirement: Import-Package: org.wso2.carbon.application.deployer at org.eclipse.osgi.container.Module.start(Module.java:457) at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$1.run(ModuleContainer.java:1820) at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$2$1.execute(EquinoxContainerAdaptor.java:150) at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1813) at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1770) at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1735) at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1661) at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345) </code></pre> <p>But after the error appears in the console the application runs fine.</p> <p>Any ideas why I get this error and how to avoid it ?</p>
[ { "answer_id": 74251781, "author": "Himujjal", "author_id": 6697318, "author_profile": "https://Stackoverflow.com/users/6697318", "pm_score": 0, "selected": false, "text": "returnFunc" }, { "answer_id": 74252762, "author": "sigod", "author_id": 944911, "author_profile...
2022/10/30
[ "https://Stackoverflow.com/questions/74251796", "https://Stackoverflow.com", "https://Stackoverflow.com/users/429377/" ]
74,251,801
<p>I have a terraform variable:</p> <pre><code>variable &quot;volumes&quot; { default = [ { &quot;name&quot; : &quot;mnt&quot;, &quot;value&quot; : &quot;/mnt/cvdupdate/&quot; }, { &quot;name&quot; : &quot;efs&quot;, &quot;value&quot; : &quot;/var&quot; }, ] } </code></pre> <p>and I am trying to create a dynamic block</p> <pre><code> dynamic &quot;volume&quot; { for_each = var.volumes == &quot;&quot; ? [] : [true] content { name = volume[&quot;name&quot;] } } </code></pre> <p>but I get an error when I run plan</p> <pre><code>name = volume[&quot;name&quot;] │ │ The given key does not identify an element in this collection value. </code></pre> <p>the desired output would be:</p> <pre><code> volume { name = &quot;mnt&quot; } volume { name = &quot;efs&quot; } </code></pre> <p>what is wrong with my code?</p>
[ { "answer_id": 74252014, "author": "Marcin", "author_id": 248823, "author_profile": "https://Stackoverflow.com/users/248823", "pm_score": 3, "selected": true, "text": "for_each" }, { "answer_id": 74252035, "author": "YCF_L", "author_id": 5558072, "author_profile": "ht...
2022/10/30
[ "https://Stackoverflow.com/questions/74251801", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7013795/" ]
74,251,815
<p>I am trying to solve <code>Recurive Digit Sum</code>, and I actually solved it, but I got <code>3 runtime errors</code> on <code>large inputs</code> when submitting. I have optimized my code a lot, but still I am getting <code>runtime errors</code>. I have <strong>googled</strong> and tried every answers/solutions I got on Internet, but they were all wrong, those codes were not able to pass all tests cases. I think my code should be optimized more, but I don't know how.<br> <strong>Here is my code:</strong><br></p> <pre><code>function superDigit(n, k) { // Write your code here if (n &lt; 10) return n let c = &quot;&quot; let i = 0 if (k &amp;&amp; k &gt; 0) { while(i &lt; k) { c += n i++ } } return findSum(c === &quot;&quot; ? n : c) } function findSum(n) { let sum = 0 let i = 0 while(i &lt; n.length) { sum += +n[i] i++ } if (sum &lt; 10) return sum return findSum(sum.toString()) } </code></pre> <p><strong>I am stuck, any help would be appreciated!</strong></p>
[ { "answer_id": 74252014, "author": "Marcin", "author_id": 248823, "author_profile": "https://Stackoverflow.com/users/248823", "pm_score": 3, "selected": true, "text": "for_each" }, { "answer_id": 74252035, "author": "YCF_L", "author_id": 5558072, "author_profile": "ht...
2022/10/30
[ "https://Stackoverflow.com/questions/74251815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12938285/" ]
74,251,855
<p>I want to use Powershell to recursively search a JSON for a string, and then have it report back the path to the value and what the value was.</p> <p>In this example I want to search the whole JSON for any key that has 'corset' in its value, and then return back that it was found in :</p> <ul> <li>Data.RootChunk.appearances[0].Data.compiledData.Data.Chunk[0].mesh.DepotPath with the value &quot;base\characters\garment\player_equipment\torso\t1_060_tank__corset\t1_060_pma_tank__corset.mesh&quot;,</li> <li>Data.RootChunk.appearances[0].Data.compiledData.Data.Chunk[0].name with the value t1_060_pma_tank__corset3513</li> </ul> <p>Here is the C:\myFile.json file. It's only a partial for the full file, which is very long. For example, the full file has 20 records inside of Data.RootChunk.appearances[#]</p> <pre><code>{ &quot;Header&quot;: { &quot;Version&quot;: &quot;2022-10-28&quot;, &quot;JsonVersion&quot;: &quot;0.0.3&quot; }, &quot;Data&quot;: { &quot;Version&quot;: 195, &quot;BuildVersion&quot;: 0, &quot;RootChunk&quot;: { &quot;$type&quot;: &quot;appearanceAppearanceResource&quot;, &quot;alternateAppearanceMapping&quot;: [], &quot;alternateAppearanceSettingName&quot;: 0, &quot;alternateAppearanceSuffixes&quot;: [], &quot;appearances&quot;: [ { &quot;HandleId&quot;: &quot;0&quot;, &quot;Data&quot;: { &quot;$type&quot;: &quot;appearanceAppearanceDefinition&quot;, &quot;censorFlags&quot;: 0, &quot;compiledData&quot;: { &quot;BufferId&quot;: &quot;0&quot;, &quot;Data&quot;: { &quot;Version&quot;: 4, &quot;Sections&quot;: 7, &quot;CruidIndex&quot;: -1, &quot;CruidDict&quot;: { &quot;0&quot;: 2050492557716705284 }, &quot;Chunks&quot;: [ { &quot;$type&quot;: &quot;entGarmentSkinnedMeshComponent&quot;, &quot;acceptDismemberment&quot;: 1, &quot;chunkMask&quot;: 18446744073709551615, &quot;LODMode&quot;: &quot;AlwaysVisible&quot;, &quot;mesh&quot;: { &quot;DepotPath&quot;: &quot;base\\characters\\garment\\player_equipment\\torso\\t1_060_tank__corset\\t1_060_pma_tank__corset.mesh&quot;, &quot;Flags&quot;: &quot;Default&quot; }, &quot;meshAppearance&quot;: &quot;military_dirty&quot;, &quot;name&quot;: &quot;t1_060_pma_tank__corset3513&quot;, &quot;navigationImpact&quot;: { &quot;$type&quot;: &quot;NavGenNavigationSetting&quot;, &quot;navmeshImpact&quot;: &quot;Ignored&quot; }, &quot;order&quot;: 0, &quot;overrideMeshNavigationImpact&quot;: 1, &quot;parentTransform&quot;: { &quot;HandleId&quot;: &quot;1&quot;, &quot;Data&quot;: { &quot;$type&quot;: &quot;entHardTransformBinding&quot;, &quot;bindName&quot;: &quot;root&quot;, &quot;enabled&quot;: 1, &quot;enableMask&quot;: { &quot;$type&quot;: &quot;entTagMask&quot;, &quot;excludedTags&quot;: { &quot;$type&quot;: &quot;redTagList&quot;, &quot;tags&quot;: [ &quot;NoBinding&quot; ] } }, &quot;slotName&quot;: 0 } } } ] } } } } ] }, &quot;forceCompileProxy&quot;: 0, &quot;generatePlayerBlockingCollisionForProxy&quot;: 0, &quot;partType&quot;: 0, &quot;preset&quot;: 0, &quot;proxyPolyCount&quot;: 1400, &quot;Wounds&quot;: [] } } </code></pre> <p>The only success I've had is getting Powershell to show the full JSON. Converting the JSON to a hashtable causes its key-value information to drop, and for some reason I cannot get nested foreach or a recursive functions to drill into the JSON structure. I had the most promise with the recursive function, but it kept reporting back Header and Data as the results, it never even drilled down to the second layer.</p> <pre><code>$SourceFile = 'C:\myFile.json' $Properties = Get-Content -Path $SourceFile | ConvertTo-Json $Properties </code></pre>
[ { "answer_id": 74252014, "author": "Marcin", "author_id": 248823, "author_profile": "https://Stackoverflow.com/users/248823", "pm_score": 3, "selected": true, "text": "for_each" }, { "answer_id": 74252035, "author": "YCF_L", "author_id": 5558072, "author_profile": "ht...
2022/10/30
[ "https://Stackoverflow.com/questions/74251855", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20354959/" ]
74,251,865
<pre><code>,100440001,5.4223240E-03,0.0000000E+00,9.5142264E-05,-1.6846368E-06,-1.6727865E-03,-3.5820480E-05, ,100440002,5.4231864E-03,-3.5126557E-05,1.7357473E-03,-8.8694117E-06,-1.6764278E-03,-3.1980174E-05, ,100440003,5.4183852E-03,-6.6414255E-05,3.3785363E-03,-1.9082331E-05,-1.6818597E-03,-2.7734946E-05, ,100440004,5.4019716E-03,-9.3277219E-05,5.0285659E-03,-2.6789506E-05,-1.6775288E-03,-2.3428154E-05, ,100440005,5.3782800E-03,-1.1620488E-04,6.6671266E-03,-3.5024775E-05,-1.6730428E-03,-2.0065860E-05, ,100440006,5.3434499E-03,-1.3648158E-04,8.3032505E-03,-4.1388424E-05,-1.6595235E-03,-1.8468531E-05, ,100440007,5.3042150E-03,-1.5528464E-04,9.9208083E-03,-4.7619368E-05,-1.6499927E-03,-1.7274167E-05, ,100440008,5.2545296E-03,-1.7329156E-04,1.1532459E-02,-5.3200382E-05,-1.6321282E-03,-1.7011654E-05, ,100440009,5.2003424E-03,-1.9090019E-04,1.3120634E-02,-5.8649741E-05,-1.6177379E-03,-1.6518644E-05, ,100440010,5.1361942E-03,-2.0826934E-04,1.4699071E-02,-6.4123893E-05,-1.5961040E-03,-1.6557273E-05, ,100440011,5.0667241E-03,-2.2552290E-04,1.6249184E-02,-6.9267478E-05,-1.5761539E-03,-1.6321806E-05, ,100440012,4.9883180E-03,-2.4265505E-04,1.7785292E-02,-7.4745884E-05,-1.5511048E-03,-1.6298149E-05, ,100440013,4.9034371E-03,-2.5969812E-04,1.9288632E-02,-7.9735148E-05,-1.5254069E-03,-1.6189753E-05, ,100440014,4.8108122E-03,-2.7658709E-04,2.0773313E-02,-8.5170787E-05,-1.4969780E-03,-1.5965583E-05, ,100440015,4.7105420E-03,-2.9331884E-04,2.2221114E-02,-9.0040440E-05,-1.4655895E-03,-1.5931278E-05, ,100440016,4.6036249E-03,-3.0979610E-04,2.3645303E-02,-9.5325104E-05,-1.4336460E-03,-1.5445142E-05, ,100440017,4.4881038E-03,-3.2599053E-04,2.5028789E-02,-1.0006818E-04,-1.3968052E-03,-1.5421975E-05, </code></pre> <p>I want to separate the numbers between commas and put each in a separate column. Then I want to save them to excel file.</p>
[ { "answer_id": 74252014, "author": "Marcin", "author_id": 248823, "author_profile": "https://Stackoverflow.com/users/248823", "pm_score": 3, "selected": true, "text": "for_each" }, { "answer_id": 74252035, "author": "YCF_L", "author_id": 5558072, "author_profile": "ht...
2022/10/30
[ "https://Stackoverflow.com/questions/74251865", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20365300/" ]
74,251,875
<p>I'm trying to make a simple Puppeteer project. My current code is just a test. It doesn't work though.</p> <pre class="lang-js prettyprint-override"><code>import bypass from './captcha/captchaBypasser.js'; import {createRequire} from &quot;module&quot;; const require = createRequire(import.meta.url); const puppeteer = require('puppeteer-extra'); const hidden = require('puppeteer-extra-plugin-stealth') test() async function test() { // Launch sequence puppeteer.use(hidden()) const browser = await puppeteer.launch({ args: ['--no-sandbox',], headless: false, ignoreHTTPSErrors: true }) const page = await browser.newPage() await page.setViewport({ width: 1920, height: 1280, deviceScaleFactor: 1, }); //Go to page await page.goto('https://google.com/', { waitUntil: 'networkidle0', }); } </code></pre> <p>I searched around for an explanation but it seems like I am the only one getting this error</p> <pre class="lang-none prettyprint-override"><code> throw new Error(message); ^ Error: An `executablePath` or `channel` must be specified for `puppeteer-core` at assert (C:\Users\Julian\Desktop\project\node_modules\puppeteer-core\lib\cjs\puppeteer\util\assert.js:28:15) at ChromeLauncher.launch (C:\Users\Julian\Desktop\project\node_modules\puppeteer-core\lib\cjs\puppeteer\node\ChromeLauncher.js:69:36) at PuppeteerNode.launch (C:\Users\Julian\Desktop\project\node_modules\puppeteer-core\lib\cjs\puppeteer\node\PuppeteerNode.js:154:105) at PuppeteerExtra.launch (C:\Users\Julian\Desktop\project\node_modules\puppeteer-extra\dist\index.cjs.js:128:41) at async test (file:///C:/Users/Julian/Desktop/project/test.js:21:19) Node.js v18.12.0 </code></pre> <p>I was expecting a Puppeteer instance to pop up and go to google.com. Instead, I got an error.</p>
[ { "answer_id": 74259041, "author": "Hizrian Hartono", "author_id": 10418830, "author_profile": "https://Stackoverflow.com/users/10418830", "pm_score": 4, "selected": false, "text": "executablePath" } ]
2022/10/30
[ "https://Stackoverflow.com/questions/74251875", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19587278/" ]
74,251,882
<p>I'm trying to scraping data form the following web site:</p> <blockquote> <p><a href="https://shafafiyah.socpa.org.sa/EmployeeDetails.aspx" rel="nofollow noreferrer">https://shafafiyah.socpa.org.sa/EmployeeDetails.aspx</a></p> </blockquote> <p>The issue is the table that I need is not showing, and I think that because I need to click from drop down list before scraping</p> <p>I'm trying the below scraping but its return null</p> <pre><code>import requests from bs4 import BeautifulSoup import html5lib headers = {'User-Agent': &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246&quot;} URL2 = &quot;https://shafafiyah.socpa.org.sa/EmployeeDetails.aspx&quot; r2 = requests.get(URL2,headers=headers) soup2 = BeautifulSoup(r2.content, 'html5lib') </code></pre> <p>how can I show hidden tables</p>
[ { "answer_id": 74260366, "author": "baduker", "author_id": 6106791, "author_profile": "https://Stackoverflow.com/users/6106791", "pm_score": 1, "selected": false, "text": "POST" }, { "answer_id": 74272720, "author": "Fatima", "author_id": 10718214, "author_profile": "...
2022/10/30
[ "https://Stackoverflow.com/questions/74251882", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10718214/" ]
74,251,900
<pre><code>text = '''hi guy- s how do i re- order this text so it doesn- t have any &quot;-&quot; ele- ments and it is still i this form''' </code></pre> <p>I have this text and i want function that makes it to be in this form:</p> <pre><code>text = '''hi guys how do i reorder this text so it doesnt have any &quot;-&quot; elements and it is still i this form''' </code></pre> <pre><code>def uprav(text): zoz = &quot;&quot; text = text.split() print (len (text)) for i in text: if i[-1] == &quot;-&quot;: nove_slovo = i[:-1] zoz = zoz + nove_slovo else: zoz = zoz + i+ &quot; &quot; zoz.split() print (zoz) This is what i tried </code></pre>
[ { "answer_id": 74251931, "author": "Đorđe Radujković", "author_id": 20065169, "author_profile": "https://Stackoverflow.com/users/20065169", "pm_score": 0, "selected": false, "text": "text.replace('-', ' ')\n" }, { "answer_id": 74251969, "author": "okursan", "author_id": 3...
2022/10/30
[ "https://Stackoverflow.com/questions/74251900", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20251491/" ]
74,251,910
<p>i want to get the location this store from google maps but selenium is unable to locate it. why is that?</p> <p>store google maps link: <a href="https://www.google.com/maps/place/Blaze+Pizza/@24.5014283,54.387503,17z/data=!3m1!4b1!4m5!3m4!1s0x3e5e676982d20b17:0xe2c5b69e67e4c85d!8m2!3d24.5014283!4d54.3896917" rel="nofollow noreferrer">https://www.google.com/maps/place/Blaze+Pizza/@24.5014283,54.387503,17z/data=!3m1!4b1!4m5!3m4!1s0x3e5e676982d20b17:0xe2c5b69e67e4c85d!8m2!3d24.5014283!4d54.3896917</a></p> <p>by code segment:</p> <pre><code>location = driver.find_element('xpath','//*[@id=&quot;QA0Szd&quot;]/div/div/div[1]/div[2]/div/div[1]/div/div/div[9]/div[3]/button/div[1]/div[2]/div[1]').text </code></pre> <p>Note: xPath is correct, and page is fully loading. what do you think the problem is?</p> <p>thank you</p> <p>i tried different xPath and letting the page load fully, also tried scrolling a bit but still. i want to get the text of the location.</p> <p>Here's my code:</p> <pre><code>chrome_options = webdriver.ChromeOptions() chrome_options.add_argument('--headless') chrome_options.add_argument('--no-sandbox') chrome_options.add_argument('--disable-dev-shm-usage') driver = webdriver.Chrome('chromedriver',options=chrome_options) driver.get(url) time.sleep(5) location = driver.find_element('xpath','//*[@id=&quot;QA0Szd&quot;]/div/div/div[1]/div[2]/div/div[1]/div/div/div[9]/div[3]/button/div[1]/div[2]/div[1]').text </code></pre>
[ { "answer_id": 74252015, "author": "skyriver", "author_id": 15252941, "author_profile": "https://Stackoverflow.com/users/15252941", "pm_score": 0, "selected": false, "text": "from selenium import webdriver\nfrom selenium.webdriver.common.by import By\nfrom selenium.webdriver.chrome.servi...
2022/10/30
[ "https://Stackoverflow.com/questions/74251910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20370678/" ]
74,251,965
<p>I have a dataset with price column as type of string, and some of the values in the form of range (15000-20000). I want to extract the first number and convert the entire column to integers.</p> <p>I tried this :</p> <pre><code>df['ptice'].apply(lambda x:x.split('-')[0]) </code></pre> <p>The code just return the original column.</p>
[ { "answer_id": 74252015, "author": "skyriver", "author_id": 15252941, "author_profile": "https://Stackoverflow.com/users/15252941", "pm_score": 0, "selected": false, "text": "from selenium import webdriver\nfrom selenium.webdriver.common.by import By\nfrom selenium.webdriver.chrome.servi...
2022/10/30
[ "https://Stackoverflow.com/questions/74251965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20025932/" ]
74,251,979
<p>So, I just started coding a discord bot in python. I've done this several times before, but when I tried to run the code this error message came up.</p> <pre><code>TypeError: event() missing 1 required positional argument: 'coro' </code></pre> <p>This is my code:</p> <pre><code>#import import discord import os #client client = discord.Client @client.event async def on_ready(): print('Best bot is online. ({0.user})' .format(client)) #commands @client.event async def on_message(message): if message.author == client.user: return if message.content.startswith('Ωhello'): await message.channel.send('responded Hello World!') #run client.run(os.getenv('token')) </code></pre> <p>Thanks.</p>
[ { "answer_id": 74252015, "author": "skyriver", "author_id": 15252941, "author_profile": "https://Stackoverflow.com/users/15252941", "pm_score": 0, "selected": false, "text": "from selenium import webdriver\nfrom selenium.webdriver.common.by import By\nfrom selenium.webdriver.chrome.servi...
2022/10/30
[ "https://Stackoverflow.com/questions/74251979", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17292994/" ]
74,252,001
<p>A few months ago I had a job interview test where I was asked to code an interface that functions like an online personality test using HTML5, CSS, and Javascript.</p> <p>This simple online test will display one question at a time, with the answer options at the bottom. When the user clicks on one of the answers, it will move on to display the next question. The answer selected will be stored in a JS array to be submitted at the end of the test.</p> <p>The interface will prompt user questions with answer options, upon answering, the next question will show. Upon every new test, the questions should randomize their order.</p> <p>The body of my HTML looks like this:</p> <pre><code>&lt;div class=&quot;panel&quot;&gt; &lt;div class=&quot;question-container&quot; id=&quot;question&quot;&gt; &lt;h1&gt;Question goes here&lt;/h1&gt; &lt;/div&gt; &lt;div class=&quot;option-container&quot;&gt; &lt;button type=&quot;button&quot; class=&quot;option next&quot; id=&quot;op1&quot;&gt;Option 1&lt;/button&gt; &lt;button type=&quot;button&quot; class=&quot;option next&quot; id=&quot;op2&quot;&gt;Option 2&lt;/button&gt; &lt;/div&gt; &lt;div class=&quot;navigation&quot;&gt; &lt;p&gt;&lt;span id=&quot;numbers&quot;&gt;0&lt;/span&gt; of 5 questions completed.&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>My JS code looks like this:</p> <pre><code>const Questions = [{ id: 0, q: &quot;I value&quot;, a: [&quot;justice&quot;, &quot;mercy&quot;], }, { id: 1, q: &quot;A quiet weekend at home is&quot;, a: [&quot;boring&quot;, &quot;rejuvenating&quot;], }, { id: 2, q: &quot;I prefer speakers that communicate&quot;, a: [&quot;literally&quot;, &quot;figuratively&quot;], }, { id: 3, q: &quot;With people, I am more often&quot;, a: [&quot;brief and to the point&quot;, &quot;friendly and warm&quot;], }] const Answers = [] var start = true; function iterate(id){ // Test get text console.log(Questions[id].q); console.log(Questions[id].a[0]); console.log(Questions[id].a[1]); // Getting the question const question = document.getElementById(&quot;question&quot;); const numbers = document.getElementById(&quot;numbers&quot;); // Setting the question text question.innerText = Questions[id].q; numbers.innerText = Questions[id].id; // Getting the options const op1 = document.getElementById(&quot;op1&quot;); const op2 = document.getElementById(&quot;op2&quot;); // Providing option text op1.innerText = Questions[id].a[0]; op2.innerText = Questions[id].a[1]; } if (start) { iterate(0); } // Next button and method const next = document.getElementsByClassName('next')[0]; var id = 0; next.addEventListener(&quot;click&quot;, () =&gt; { start = false; if (id &lt; 4) { id++; iterate(id); console.log(id); } else { // Mark the test as finished Questions.innerText = &quot;Congratulations. You have finished your personality assessment test&quot; op1.innerText = &quot;Option 1&quot;; op2.innerText = &quot;Option 2&quot;; } }) </code></pre> <p>However, I am having a problem when trying to run the code, the interface cannot display any questions or answers, only the initial texts set by the static HTML file (Question goes here, Option 1, Option 2). In addition, I opened the Inspect tool on the browser, which the console produces the following error message:</p> <blockquote> <p>Uncaught TypeError: Cannot set properties of null (setting 'innerText') at iterate (script.js:38:24) at script.js:57:5</p> </blockquote> <pre><code>question.innerText = Questions[id].q; </code></pre> <p>If anyone is having the same problem and is expertise in JavaScript and front-end development, please provide a solution to solve the errors.</p> <p>I have tried to code the online test interface with the given sample questions and answers according to the JavaScript standards and references from similar codes and projects. However, it did not work out and the questions and answers do not display on the interface.</p>
[ { "answer_id": 74252015, "author": "skyriver", "author_id": 15252941, "author_profile": "https://Stackoverflow.com/users/15252941", "pm_score": 0, "selected": false, "text": "from selenium import webdriver\nfrom selenium.webdriver.common.by import By\nfrom selenium.webdriver.chrome.servi...
2022/10/30
[ "https://Stackoverflow.com/questions/74252001", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13346467/" ]
74,252,011
<p>what should I do? I want the amount of digits to be configurable</p> <p>I've tried the following:</p> <pre><code>my $digits = 2; my $test = 5.42223; $test = sprintf (&quot;%.$digits\f&quot;, $test); print &quot;$test \n&quot;; </code></pre> <p>but it won't work, it would print &quot;%.2&quot; I should get 5.42</p>
[ { "answer_id": 74252152, "author": "Dave Mitchell", "author_id": 9749458, "author_profile": "https://Stackoverflow.com/users/9749458", "pm_score": 2, "selected": false, "text": "sprintf (\"%.${digits}f\", $test)\n" }, { "answer_id": 74255990, "author": "brian d foy", "aut...
2022/10/30
[ "https://Stackoverflow.com/questions/74252011", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20004949/" ]
74,252,043
<p>Using Regex, I want to remove all hyphens only from specific quoted words in a text file.</p> <p>Scenario: This is from code where I need to remove hyphens from Json property names before the Json string is deserialized using a JsonConstructor (<strike>which does not honor JsonPropertyName attributes</strike> <em><strong>see edit below</strong></em>).</p> <p>Example list of words which need hyphens removed (quotes should be part of the match):</p> <pre><code>&quot;monthly-amount&quot; &quot;annual-amount&quot; &quot;ask-for-shipping-address&quot; </code></pre> <p>Example input Json:</p> <pre><code>{ &quot;id&quot;: &quot;b9d7574f-5246-4c94-ade5-1d4e9b169afc&quot;, &quot;name&quot;: &quot;James-John Moonly-Batcher&quot; &quot;monthly-amount&quot; : 2000, &quot;annual-amount&quot; : 12000, &quot;ask-for-shipping-address&quot; : false } </code></pre> <p>Expected output Json:</p> <pre><code>{ &quot;id&quot;: &quot;b9d7574f-5246-4c94-ade5-1d4e9b169afc&quot;, &quot;name&quot;: &quot;James-John Moonly-Batcher&quot; &quot;monthlyamount&quot; : 2000, &quot;annualamount&quot; : 12000, &quot;askforshippingaddress&quot; : false } </code></pre> <p>Note that in the example, hyphens in the name and id values are not removed.</p> <p>I understand how I can match the words in the list. What I don't understand is how I can then use the matched word and replace all hyphens in it.</p> <p>Alternatively, if a regex can be constructed that works without the word list which can replace hyphens in any property name (but not in property values), that would also be welcome.</p> <p>I would love to receive some input on this task before the little hair I have left is being scratched off my head.....</p> <p><strong>EDIT:</strong></p> <p>Only after I successfully applied the accepted answer did I realize that my initial problem was an entirely different one: wrong parameter names of the class constructor for deserialization (JSON constructor).</p> <p>I had misunderstood the <a href="https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/immutability?pivots=dotnet-6-0" rel="nofollow noreferrer">docs</a> about how parameter names of a JsonConstructor need to be, thinking that the parameter names of the JSON constructor need to match the names in the JSON, whereas in reality, the parameter names of the JSON constructor need to match the actual property names of the C# class (case insensitive). By matching the property names of the C# class, the deserializer can find the JsonPropertyName attribute corresponding to the constructor parameter name, and thus it can find the JSON names to look for.</p> <p>So with the correct parameter names in place, there is no need to alter Json property names in the first place.</p>
[ { "answer_id": 74252338, "author": "bobble bubble", "author_id": 5527985, "author_profile": "https://Stackoverflow.com/users/5527985", "pm_score": 2, "selected": true, "text": "-(?=[^\"]*\"\\s*:)\n" }, { "answer_id": 74252628, "author": "Guru Stron", "author_id": 2501279,...
2022/10/30
[ "https://Stackoverflow.com/questions/74252043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11035069/" ]