qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
74,332,791 | <p>First of all sorry if this question seems trivial but i have no experience in office development
we have a VSTO addin for MS word developed in c# as a part of windows Desktop application
this addin works fine for office 2013 , when we tried to add it to office 365 , 2019 and 2021 it failed
when i searched for a solution i got confused weather the desktop addins for office still supported or we have to move our work to Office JS ?</p>
<p>i have not tried coding yet , just searching for the problem</p>
| [
{
"answer_id": 74334416,
"author": "Eugene Astafiev",
"author_id": 1603351,
"author_profile": "https://Stackoverflow.com/users/1603351",
"pm_score": 1,
"selected": false,
"text": "OfficeJS"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74332791",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15662532/"
] |
74,332,824 | <p>I'm pretty new to using css and html. I don't know why the nav part doesn't have the same background and it's not at the same height as the logo.
I'd really appreciate the help!</p>
<p><a href="https://i.stack.imgur.com/XDc9K.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XDc9K.png" alt="enter image description here" /></a></p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{
font-family: sans-serif;
}
header{
background-color: #14597f;
height: 60px;
}
nav ul{
list-style: none;
text-align: right;
}
nav li{
display: inline-block;
}
nav a{
color: #ffff;
display: block;
text-transform: uppercase;
font-weight: bold;
padding: 10px 10px;
}
nav a:hover{
background-color: #ca0ed1 ;
}
.active{
background-color: #1fb5e9;
border-radius: 4px;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><header>
<a href="./index.html" >
<img class="logo" src="assets/img/logo.svg" alt="logo" width="200px">
</a>
<nav>
<ul>
<li><a class="active" href="index.html"> Accueil</a></li>
<li><a href="products.html"> Produits</a></li>
<li><a href="contact.html"> Contact</a></li>
<li><a class="shopping-cart" href="./shopping-cart.html" title="Panier">
<span class="fa-stack fa-lg">
<i class="fa fa-circle fa-stack-2x fa-inverse"></i>
<i class="fa fa-shopping-cart fa-stack-1x"></i>
</span>
<span class="count">3</span></a>
</li>
</ul>
</nav>
</header></code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74332870,
"author": "Mad7Dragon",
"author_id": 6467902,
"author_profile": "https://Stackoverflow.com/users/6467902",
"pm_score": -1,
"selected": false,
"text": "* {\n border: 1px solid red;\n}\n\nbody{\n font-family: sans-serif;\n }\n \n header{\n background-color: #14597f;\n height: 60px; \n display: flex; \n justify-content: space-between; \n align-items: center;\n }\n\n nav ul{\n list-style: none;\n text-align: right; \n }\n nav li{\n display: inline-block;\n }\n nav a{\n color: #ffff;\n display: block;\n text-transform: uppercase;\n font-weight: bold;\n padding: 10px 10px; \n }\n nav a:hover{\n background-color: #ca0ed1 ;\n }\n \n .active{\n background-color: #1fb5e9;\n border-radius: 4px;\n \n }"
},
{
"answer_id": 74332886,
"author": "str1ng",
"author_id": 12826055,
"author_profile": "https://Stackoverflow.com/users/12826055",
"pm_score": 3,
"selected": true,
"text": "header {\n display: flex;\n justify-content: space-between;\n align-items:center;\n\n}\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74332824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20153722/"
] |
74,332,842 | <p>little help please, it is WP site,</p>
<p>I have hidden section on page, and when user scroll to it popup shows asking for password, and when user enter password I must compare it with password from ACF field.</p>
<p>I tried several examples getting this done but i cant get anything... I could not find any clear examples of that on stackowerflow, or step by step examples, there are few of them that are not clear to me, I am kinda beginer</p>
<p>EDIT:</p>
<pre><code> function.php
function my_enqueue() {
wp_enqueue_script( 'ajax-script', get_template_directory_uri() . '/js/global.js', array('jquery') );
wp_localize_script( 'ajax-script', 'my_ajax_object', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );
}
add_action( 'wp_enqueue_scripts', 'my_enqueue' );
add_action('wp_ajax_nopriv_get_acf_field_ajax', 'my_action');
add_action('wp_ajax_get_acf_field_ajax', 'my_action');
function my_action() {
$result = get_field('password', 'option');
echo json_encode($result);
// wp_send_json($result);
}
global.js
$.ajax({
type: "post",
dataType: "json",
url: my_ajax_object.ajax_url,
data: { action: 'my_action' },
success: function (data) {
console.log(data);
}
});
</code></pre>
<p>i got POST <a href="http://my-local-website.com/wp-admin/admin-ajax.php" rel="nofollow noreferrer">http://my-local-website.com/wp-admin/admin-ajax.php</a> error 400 bad request</p>
| [
{
"answer_id": 74332870,
"author": "Mad7Dragon",
"author_id": 6467902,
"author_profile": "https://Stackoverflow.com/users/6467902",
"pm_score": -1,
"selected": false,
"text": "* {\n border: 1px solid red;\n}\n\nbody{\n font-family: sans-serif;\n }\n \n header{\n background-color: #14597f;\n height: 60px; \n display: flex; \n justify-content: space-between; \n align-items: center;\n }\n\n nav ul{\n list-style: none;\n text-align: right; \n }\n nav li{\n display: inline-block;\n }\n nav a{\n color: #ffff;\n display: block;\n text-transform: uppercase;\n font-weight: bold;\n padding: 10px 10px; \n }\n nav a:hover{\n background-color: #ca0ed1 ;\n }\n \n .active{\n background-color: #1fb5e9;\n border-radius: 4px;\n \n }"
},
{
"answer_id": 74332886,
"author": "str1ng",
"author_id": 12826055,
"author_profile": "https://Stackoverflow.com/users/12826055",
"pm_score": 3,
"selected": true,
"text": "header {\n display: flex;\n justify-content: space-between;\n align-items:center;\n\n}\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74332842",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11384672/"
] |
74,332,848 | <p>I have these lines in a file:</p>
<pre><code>Oct 29 23:14:39
Oct 30 19:45:15
Oct 31 13:15:19
Nov 1 10:34:15
Nov 2 18:39:20
Nov 3 12:34:59
Nov 4 16:34:59
Nov 5 20:34:59
</code></pre>
<p>When I run <code>sort -r -k2</code> it gives me the following:</p>
<pre><code> Nov 5
Nov 4
Nov 3
Oct 31
Oct 30
Oct 29
Nov 2
Nov 1
</code></pre>
<p>How do I get it like so:</p>
<pre><code>Nov 5
Nov 4
Nov 3
Nov 2
Nov 1
Oct 31
Oct 30
Oct 29
</code></pre>
<p>Would appreciate any pointers, comments, advices at all. Do I also need to sort on months in reverse order? How? -M -r?</p>
| [
{
"answer_id": 74332903,
"author": "ramsay",
"author_id": 5738112,
"author_profile": "https://Stackoverflow.com/users/5738112",
"pm_score": 0,
"selected": false,
"text": "sort -k1Mr,1 -k2r,2\n"
},
{
"answer_id": 74332945,
"author": "Beta",
"author_id": 128940,
"author_profile": "https://Stackoverflow.com/users/128940",
"pm_score": 0,
"selected": false,
"text": "Oct"
},
{
"answer_id": 74333069,
"author": "SaSkY",
"author_id": 18104248,
"author_profile": "https://Stackoverflow.com/users/18104248",
"pm_score": 1,
"selected": false,
"text": "sort -k1Mr -r -k2nr file.txt\n"
},
{
"answer_id": 74333071,
"author": "dan",
"author_id": 13919668,
"author_profile": "https://Stackoverflow.com/users/13919668",
"pm_score": 1,
"selected": false,
"text": "tac file\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74332848",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10703048/"
] |
74,332,878 | <p><a href="https://github.blog/changelog/2022-10-20-new-branch-protections-last-pusher-and-locked-branch/" rel="nofollow noreferrer">GitHub says I can disable protections that prevent the last pusher from approving the PR</a>, but I am not able to even when I have that setting turned on. Is there some other setting I need to disable in my branch protections?</p>
<p><img src="https://i.stack.imgur.com/5o8Pe.png" alt="approval is blocked" title="approval is blocked" /></p>
<p><img src="https://i.stack.imgur.com/cHIOx.png" alt="here are my settings" title="Here are my settings:" /></p>
<p>I can still merge the pull request by bypassing the requirements (since I'm the administrator of the repository), but that's not what I want to do. I want to be able (and want other pushers to be able) to approve my own pull requests, as long as they are considered Code Owners (which I am, in this case).</p>
<p>I have tried enabling the setting and disabling it again. It does not seem to make a difference.</p>
<p>I created this PR before I even had branch protections turned on, and I turned off branch protections off altogether to confirm that the branch protection settings are indeed being updated.</p>
<p>I also tried requiring a PR but unchecking "require approvals" and leaving "require review from Code Owners" checked, and this did not work either.</p>
| [
{
"answer_id": 74332903,
"author": "ramsay",
"author_id": 5738112,
"author_profile": "https://Stackoverflow.com/users/5738112",
"pm_score": 0,
"selected": false,
"text": "sort -k1Mr,1 -k2r,2\n"
},
{
"answer_id": 74332945,
"author": "Beta",
"author_id": 128940,
"author_profile": "https://Stackoverflow.com/users/128940",
"pm_score": 0,
"selected": false,
"text": "Oct"
},
{
"answer_id": 74333069,
"author": "SaSkY",
"author_id": 18104248,
"author_profile": "https://Stackoverflow.com/users/18104248",
"pm_score": 1,
"selected": false,
"text": "sort -k1Mr -r -k2nr file.txt\n"
},
{
"answer_id": 74333071,
"author": "dan",
"author_id": 13919668,
"author_profile": "https://Stackoverflow.com/users/13919668",
"pm_score": 1,
"selected": false,
"text": "tac file\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74332878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8804276/"
] |
74,332,890 | <p>With below dictionary, I want to make a new single list with all directories:</p>
<pre><code>nominated = {1931: ['Norman Taurog', 'Wesley Ruggles', 'Clarence Brown', 'Lewis Milestone', 'Josef Von Sternberg'],
1932: ['Frank Borzage', 'King Vidor', 'Josef Von Sternberg'],
1933: ['Frank Lloyd', 'Frank Capra', 'George Cukor']}
</code></pre>
<p>Desired output: 1 single list with all directors</p>
<pre><code>all_directors = ['Norman Taurog', 'Wesley Ruggles', 'Clarence Brown', 'Lewis Milestone', 'Josef Von Sternberg','Frank Borzage', 'King Vidor', 'Josef Von Sternberg','Frank Lloyd', 'Frank Capra', 'George Cukor']
</code></pre>
<p><strong>Attempt 1: list comprehension</strong></p>
<pre><code>all_directors = [[director for director in nominated_directors] for year, nominated_directors in nominated.items()]
print(all_directors)
</code></pre>
<p><strong>Output attempt 1</strong></p>
<pre><code>[['Norman Taurog', 'Wesley Ruggles', 'Clarence Brown', 'Lewis Milestone', 'Josef Von Sternberg'], ['Frank Borzage', 'King Vidor', 'Josef Von Sternberg'], ['Frank Lloyd', 'Frank Capra', 'George Cukor']]
</code></pre>
<p><strong>Attempt 1: using for loop</strong></p>
<pre><code>all_directors = []
for year, directors in nominated.items():
for director in directors:
all_directors.append(director)
print(all_directors)
</code></pre>
<p><strong>Output attempt 2</strong></p>
<pre><code>['Norman Taurog', 'Wesley Ruggles', 'Clarence Brown', 'Lewis Milestone', 'Josef Von Sternberg', 'Frank Borzage', 'King Vidor', 'Josef Von Sternberg', 'Frank Lloyd', 'Frank Capra', 'George Cukor']
</code></pre>
<p>The output is correct with for loop but not list comprehension. Not sure what I missed, can you please help?</p>
| [
{
"answer_id": 74332904,
"author": "Zac Anger",
"author_id": 5774952,
"author_profile": "https://Stackoverflow.com/users/5774952",
"pm_score": 0,
"selected": false,
"text": "sum"
},
{
"answer_id": 74332932,
"author": "Steven",
"author_id": 6543301,
"author_profile": "https://Stackoverflow.com/users/6543301",
"pm_score": 2,
"selected": true,
"text": "all_directors = [\n director for year, nominated_directors in nominated.items() \n for director in nominated_directors\n ]\n"
},
{
"answer_id": 74333045,
"author": "M2014",
"author_id": 4172444,
"author_profile": "https://Stackoverflow.com/users/4172444",
"pm_score": 0,
"selected": false,
"text": "all_directors = [director for nominated_directors in nominated.values() for director in nominated_directors]\n"
},
{
"answer_id": 74333166,
"author": "Richard Plester",
"author_id": 15474105,
"author_profile": "https://Stackoverflow.com/users/15474105",
"pm_score": 1,
"selected": false,
"text": "nominated = {1931: ['Norman Taurog', 'Wesley Ruggles', 'Clarence Brown', 'Lewis Milestone', 'Josef Von Sternberg'],\n 1932: ['Frank Borzage', 'King Vidor', 'Josef Von Sternberg'],\n 1933: ['Frank Lloyd', 'Frank Capra', 'George Cukor']}\n\nall_directors = [name for year,director_sublist in nominated.items() for name in director_sublist]\n\nprint(all_directors)\n\n\n['Norman Taurog', 'Wesley Ruggles', 'Clarence Brown', 'Lewis Milestone', 'Josef Von Sternberg', 'Frank Borzage', 'King Vidor', 'Josef Von Sternberg', 'Frank Lloyd', 'Frank Capra', 'George Cukor']\n"
},
{
"answer_id": 74342257,
"author": "gregory",
"author_id": 2057509,
"author_profile": "https://Stackoverflow.com/users/2057509",
"pm_score": 0,
"selected": false,
"text": "def flatten(items):\n \"\"\"Yield items from any nested iterable\"\"\"\n for x in items:\n if isinstance(x, Iterable) and not isinstance(x, (str, bytes)):\n for sub_x in flatten(x):\n yield sub_x\n else:\n yield x\n\nlist(flatten(nominated.values()))\n"
},
{
"answer_id": 74343063,
"author": "ukBaz",
"author_id": 7721752,
"author_profile": "https://Stackoverflow.com/users/7721752",
"pm_score": 0,
"selected": false,
"text": "itertools"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74332890",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3464792/"
] |
74,332,985 | <p>with this code:</p>
<pre><code>import pandas as pd
import requests
import json
url = 'https://www.loves.com/api/sitecore/StoreSearch/SearchStores'
#get the data from url
response = requests.get(url).json()
df = pd.read_json(url)
df1 = pd.json_normalize(response)
</code></pre>
<p>both DFs return this:
<a href="https://i.stack.imgur.com/ySBe5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ySBe5.png" alt="enter image description here" /></a></p>
<p>This is what the response looks like
<a href="https://i.stack.imgur.com/Ee2kf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ee2kf.png" alt="enter image description here" /></a></p>
<p>How to get normal pandas dataframe?</p>
| [
{
"answer_id": 74332904,
"author": "Zac Anger",
"author_id": 5774952,
"author_profile": "https://Stackoverflow.com/users/5774952",
"pm_score": 0,
"selected": false,
"text": "sum"
},
{
"answer_id": 74332932,
"author": "Steven",
"author_id": 6543301,
"author_profile": "https://Stackoverflow.com/users/6543301",
"pm_score": 2,
"selected": true,
"text": "all_directors = [\n director for year, nominated_directors in nominated.items() \n for director in nominated_directors\n ]\n"
},
{
"answer_id": 74333045,
"author": "M2014",
"author_id": 4172444,
"author_profile": "https://Stackoverflow.com/users/4172444",
"pm_score": 0,
"selected": false,
"text": "all_directors = [director for nominated_directors in nominated.values() for director in nominated_directors]\n"
},
{
"answer_id": 74333166,
"author": "Richard Plester",
"author_id": 15474105,
"author_profile": "https://Stackoverflow.com/users/15474105",
"pm_score": 1,
"selected": false,
"text": "nominated = {1931: ['Norman Taurog', 'Wesley Ruggles', 'Clarence Brown', 'Lewis Milestone', 'Josef Von Sternberg'],\n 1932: ['Frank Borzage', 'King Vidor', 'Josef Von Sternberg'],\n 1933: ['Frank Lloyd', 'Frank Capra', 'George Cukor']}\n\nall_directors = [name for year,director_sublist in nominated.items() for name in director_sublist]\n\nprint(all_directors)\n\n\n['Norman Taurog', 'Wesley Ruggles', 'Clarence Brown', 'Lewis Milestone', 'Josef Von Sternberg', 'Frank Borzage', 'King Vidor', 'Josef Von Sternberg', 'Frank Lloyd', 'Frank Capra', 'George Cukor']\n"
},
{
"answer_id": 74342257,
"author": "gregory",
"author_id": 2057509,
"author_profile": "https://Stackoverflow.com/users/2057509",
"pm_score": 0,
"selected": false,
"text": "def flatten(items):\n \"\"\"Yield items from any nested iterable\"\"\"\n for x in items:\n if isinstance(x, Iterable) and not isinstance(x, (str, bytes)):\n for sub_x in flatten(x):\n yield sub_x\n else:\n yield x\n\nlist(flatten(nominated.values()))\n"
},
{
"answer_id": 74343063,
"author": "ukBaz",
"author_id": 7721752,
"author_profile": "https://Stackoverflow.com/users/7721752",
"pm_score": 0,
"selected": false,
"text": "itertools"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74332985",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8291387/"
] |
74,332,986 | <p>I have a requirement for VBA, wherein, If I select a cell in excel, it will export that entire row values to csv.</p>
<p>I have tried</p>
<pre><code>Sub WriteCSVFile()
Dim My_filenumber As Integer
Dim logSTR As String
My_filenumber = FreeFile
logSTR = logSTR & Cells(1, "A").Value & " , "
logSTR = logSTR & Cells(2, "A").Value & " , "
logSTR = logSTR & Cells(3, "A").Value & " , "
logSTR = logSTR & Cells(4, "A").Value
Open "C:\Users\xxxxx\Desktop\Sample.csv" For Append As #My_filenumber
Print #My_filenumber, logSTR
Close #My_filenumber
End Sub
</code></pre>
<p>If the range selection can be made dynamic, it can solve the purpose.</p>
| [
{
"answer_id": 74332904,
"author": "Zac Anger",
"author_id": 5774952,
"author_profile": "https://Stackoverflow.com/users/5774952",
"pm_score": 0,
"selected": false,
"text": "sum"
},
{
"answer_id": 74332932,
"author": "Steven",
"author_id": 6543301,
"author_profile": "https://Stackoverflow.com/users/6543301",
"pm_score": 2,
"selected": true,
"text": "all_directors = [\n director for year, nominated_directors in nominated.items() \n for director in nominated_directors\n ]\n"
},
{
"answer_id": 74333045,
"author": "M2014",
"author_id": 4172444,
"author_profile": "https://Stackoverflow.com/users/4172444",
"pm_score": 0,
"selected": false,
"text": "all_directors = [director for nominated_directors in nominated.values() for director in nominated_directors]\n"
},
{
"answer_id": 74333166,
"author": "Richard Plester",
"author_id": 15474105,
"author_profile": "https://Stackoverflow.com/users/15474105",
"pm_score": 1,
"selected": false,
"text": "nominated = {1931: ['Norman Taurog', 'Wesley Ruggles', 'Clarence Brown', 'Lewis Milestone', 'Josef Von Sternberg'],\n 1932: ['Frank Borzage', 'King Vidor', 'Josef Von Sternberg'],\n 1933: ['Frank Lloyd', 'Frank Capra', 'George Cukor']}\n\nall_directors = [name for year,director_sublist in nominated.items() for name in director_sublist]\n\nprint(all_directors)\n\n\n['Norman Taurog', 'Wesley Ruggles', 'Clarence Brown', 'Lewis Milestone', 'Josef Von Sternberg', 'Frank Borzage', 'King Vidor', 'Josef Von Sternberg', 'Frank Lloyd', 'Frank Capra', 'George Cukor']\n"
},
{
"answer_id": 74342257,
"author": "gregory",
"author_id": 2057509,
"author_profile": "https://Stackoverflow.com/users/2057509",
"pm_score": 0,
"selected": false,
"text": "def flatten(items):\n \"\"\"Yield items from any nested iterable\"\"\"\n for x in items:\n if isinstance(x, Iterable) and not isinstance(x, (str, bytes)):\n for sub_x in flatten(x):\n yield sub_x\n else:\n yield x\n\nlist(flatten(nominated.values()))\n"
},
{
"answer_id": 74343063,
"author": "ukBaz",
"author_id": 7721752,
"author_profile": "https://Stackoverflow.com/users/7721752",
"pm_score": 0,
"selected": false,
"text": "itertools"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74332986",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20429502/"
] |
74,332,995 | <pre><code>if (File.Exists(settingsFile))
{
string[] lines = File.ReadAllLines(settingsFile);
if (lines.Length > 0)
{
trackBarHours.Value = Convert.ToInt32(optionsfile.GetKey("trackbarhours"));
trackBarMinutes.Value = Convert.ToInt32(optionsfile.GetKey("trackbarminutes"));
trackBarSeconds.Value = Convert.ToInt32(optionsfile.GetKey("trackbarseconds"));
savedMilliseconds = Convert.ToInt32(optionsfile.GetKey("milliseconds"));
dateTimePicker1.Value = Convert.ToDateTime(optionsfile.GetKey("timetargetvalue"));
richTextBox1.Text = optionsfile.GetKey("result");
}
}
</code></pre>
<p>because the key "timetargetvalue" is not yet created in the settingsFile because i didn't saved it yet for the first time the value of the key of "timetargetvalue" is '01/01/0001 00:00:00'</p>
<p>in that case that there is no yet the key hwo can i handle the datetime exception ?</p>
<p>dateTimePicker1 is a DateTimePicker control.</p>
<p>the exception is on the line :</p>
<pre><code>dateTimePicker1.Value = Convert.ToDateTime(optionsfile.GetKey("timetargetvalue"));
</code></pre>
<p>System.ArgumentOutOfRangeException: 'Value of '01/01/0001 00:00:00' is not valid for 'Value'. 'Value' should be between 'MinDate' and 'MaxDate'.
Parameter name: Value'</p>
<p>what should i check against of so it will not throw the exception ?</p>
| [
{
"answer_id": 74332904,
"author": "Zac Anger",
"author_id": 5774952,
"author_profile": "https://Stackoverflow.com/users/5774952",
"pm_score": 0,
"selected": false,
"text": "sum"
},
{
"answer_id": 74332932,
"author": "Steven",
"author_id": 6543301,
"author_profile": "https://Stackoverflow.com/users/6543301",
"pm_score": 2,
"selected": true,
"text": "all_directors = [\n director for year, nominated_directors in nominated.items() \n for director in nominated_directors\n ]\n"
},
{
"answer_id": 74333045,
"author": "M2014",
"author_id": 4172444,
"author_profile": "https://Stackoverflow.com/users/4172444",
"pm_score": 0,
"selected": false,
"text": "all_directors = [director for nominated_directors in nominated.values() for director in nominated_directors]\n"
},
{
"answer_id": 74333166,
"author": "Richard Plester",
"author_id": 15474105,
"author_profile": "https://Stackoverflow.com/users/15474105",
"pm_score": 1,
"selected": false,
"text": "nominated = {1931: ['Norman Taurog', 'Wesley Ruggles', 'Clarence Brown', 'Lewis Milestone', 'Josef Von Sternberg'],\n 1932: ['Frank Borzage', 'King Vidor', 'Josef Von Sternberg'],\n 1933: ['Frank Lloyd', 'Frank Capra', 'George Cukor']}\n\nall_directors = [name for year,director_sublist in nominated.items() for name in director_sublist]\n\nprint(all_directors)\n\n\n['Norman Taurog', 'Wesley Ruggles', 'Clarence Brown', 'Lewis Milestone', 'Josef Von Sternberg', 'Frank Borzage', 'King Vidor', 'Josef Von Sternberg', 'Frank Lloyd', 'Frank Capra', 'George Cukor']\n"
},
{
"answer_id": 74342257,
"author": "gregory",
"author_id": 2057509,
"author_profile": "https://Stackoverflow.com/users/2057509",
"pm_score": 0,
"selected": false,
"text": "def flatten(items):\n \"\"\"Yield items from any nested iterable\"\"\"\n for x in items:\n if isinstance(x, Iterable) and not isinstance(x, (str, bytes)):\n for sub_x in flatten(x):\n yield sub_x\n else:\n yield x\n\nlist(flatten(nominated.values()))\n"
},
{
"answer_id": 74343063,
"author": "ukBaz",
"author_id": 7721752,
"author_profile": "https://Stackoverflow.com/users/7721752",
"pm_score": 0,
"selected": false,
"text": "itertools"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74332995",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9890333/"
] |
74,333,011 | <p>I am a beginner programmer working on a Two Sum problem. An array of integers are given as well as an integer, target. The intention of the program is to find which two numbers in the array of integers add up to the target integer. The most efficient solution I am seeing is quite ingenious in how it iterates over all of the integers in the array and checks if the difference between each integer in the array and the target number is another integer in the array. Then those two would be the solution. My issue is with the HashMap part. How would an empty HashMap .containsKey() work if it is empty and has no keys in it?</p>
<pre><code>class Solution {
public int[] twoSum(int[] nums, int target) {
int n=nums.length;
Map<Integer,Integer> map=new HashMap<>();
int[] result=new int[2];
for(int i=0;i<n;i++){
if(map.containsKey(target-nums[i])){
result[1]=i;
result[0]=map.get(target-nums[i]);
return result;
}
map.put(nums[i],i);
}
return result;
}
}
</code></pre>
<p>I tried to research solution explanations but all of them just said that the solution checks if the values are in the map but how would any values be in the map if it is empty and was never linked to the integers array? Thanks a lot for the help.</p>
| [
{
"answer_id": 74332904,
"author": "Zac Anger",
"author_id": 5774952,
"author_profile": "https://Stackoverflow.com/users/5774952",
"pm_score": 0,
"selected": false,
"text": "sum"
},
{
"answer_id": 74332932,
"author": "Steven",
"author_id": 6543301,
"author_profile": "https://Stackoverflow.com/users/6543301",
"pm_score": 2,
"selected": true,
"text": "all_directors = [\n director for year, nominated_directors in nominated.items() \n for director in nominated_directors\n ]\n"
},
{
"answer_id": 74333045,
"author": "M2014",
"author_id": 4172444,
"author_profile": "https://Stackoverflow.com/users/4172444",
"pm_score": 0,
"selected": false,
"text": "all_directors = [director for nominated_directors in nominated.values() for director in nominated_directors]\n"
},
{
"answer_id": 74333166,
"author": "Richard Plester",
"author_id": 15474105,
"author_profile": "https://Stackoverflow.com/users/15474105",
"pm_score": 1,
"selected": false,
"text": "nominated = {1931: ['Norman Taurog', 'Wesley Ruggles', 'Clarence Brown', 'Lewis Milestone', 'Josef Von Sternberg'],\n 1932: ['Frank Borzage', 'King Vidor', 'Josef Von Sternberg'],\n 1933: ['Frank Lloyd', 'Frank Capra', 'George Cukor']}\n\nall_directors = [name for year,director_sublist in nominated.items() for name in director_sublist]\n\nprint(all_directors)\n\n\n['Norman Taurog', 'Wesley Ruggles', 'Clarence Brown', 'Lewis Milestone', 'Josef Von Sternberg', 'Frank Borzage', 'King Vidor', 'Josef Von Sternberg', 'Frank Lloyd', 'Frank Capra', 'George Cukor']\n"
},
{
"answer_id": 74342257,
"author": "gregory",
"author_id": 2057509,
"author_profile": "https://Stackoverflow.com/users/2057509",
"pm_score": 0,
"selected": false,
"text": "def flatten(items):\n \"\"\"Yield items from any nested iterable\"\"\"\n for x in items:\n if isinstance(x, Iterable) and not isinstance(x, (str, bytes)):\n for sub_x in flatten(x):\n yield sub_x\n else:\n yield x\n\nlist(flatten(nominated.values()))\n"
},
{
"answer_id": 74343063,
"author": "ukBaz",
"author_id": 7721752,
"author_profile": "https://Stackoverflow.com/users/7721752",
"pm_score": 0,
"selected": false,
"text": "itertools"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333011",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20429668/"
] |
74,333,029 | <pre class="lang-c prettyprint-override"><code>#include <iostream>
class Test {
public:
static int numelem;
Test() {}
~Test() {}
int increment();
};
int Test::numelem = 0;
int Test::increment()
{
return ++Test::numelem;
}
</code></pre>
<p>So I want to make a counter for my Stacks data structure.
Whenever I push, it increments and when popped it decrements.</p>
<p>My code works, but <code>int Test::numelem = 0;</code> is a global variable.
I tried using <code>inline</code> but unfortunately I have C++14.</p>
<p>I only put the <code>static int numelem</code> instead of the whole <code>Stack</code> class to focus on one feature.</p>
<p>Is there an alternative way I can put <code>int Test::numelem = 0;</code> inside the class without getting any error?</p>
| [
{
"answer_id": 74333106,
"author": "Jason Liam",
"author_id": 12002570,
"author_profile": "https://Stackoverflow.com/users/12002570",
"pm_score": 2,
"selected": true,
"text": "int Test::numelem = 0;"
},
{
"answer_id": 74333164,
"author": "Wyck",
"author_id": 1563833,
"author_profile": "https://Stackoverflow.com/users/1563833",
"pm_score": 2,
"selected": false,
"text": "class Test {\npublic:\n static int& numelem() {\n static int val = 0; // or your initializer here\n return val;\n }\n\n int increment() {\n return ++numelem();\n }\n};\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333029",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19006940/"
] |
74,333,036 | <pre><code> let num1 = prompt("Enter Eaxam 1");
let num2 = prompt("Enter Eaxam 2");
let num3 = prompt("Enter Eaxam 3");
let num4 = prompt("Enter Eaxam 4");
let num5 = prompt("Enter Eaxam 5");
var grade1 = parseInt(num1);
var grade2 = parseInt(num2);
var grade3 = parseInt(num3);
var grade4 = parseInt(num4);
var grade5 = parseInt(num5);
let averageGrade = ((grade1+grade2+grade3+grade4+grade5)/5);
console.log(averageGrade);
do{
console.log("Please enter a valid test grade!")
let num1 = prompt("Enter Eaxam 1");
let num2 = prompt("Enter Eaxam 2");
let num3 = prompt("Enter Eaxam 3");
let num4 = prompt("Enter Eaxam 4");
let num5 = prompt("Enter Eaxam 5");
var grade1 = parseInt(num1);
var grade2 = parseInt(num2);
var grade3 = parseInt(num3);
var grade4 = parseInt(num4);
var grade5 = parseInt(num5)
}
while((num1 > 100 || num1 < 0) || (num2 > 100 || num2 < 0) || (num3 > 100 || num3 < 0) || (num4 > 100 || num4 < 0) || (num5 > 100 || num5 < 0))
switch(true){
case (averageGrade >= 90):
console.log("You recived an A")
break;
case (averageGrade <= 89 && averageGrade >= 80):
console.log("You recived a B")
break;
case (averageGrade <= 79 && averageGrade >= 70):
console.log("You recived a C")
break;
case (averageGrade <= 69 && averageGrade >= 60):
console.log("You recived a D")
break;
case (averageGrade <= 59):
console.log("You failed dumbass")
break;
}
</code></pre>
<p>I tried adding a block of code that would validate the grades to make sure they are between 0 to 100 but for some reason the whole do-while loop executes despite the grades going between 0-100. What are some things that are wrong with my code?</p>
| [
{
"answer_id": 74333106,
"author": "Jason Liam",
"author_id": 12002570,
"author_profile": "https://Stackoverflow.com/users/12002570",
"pm_score": 2,
"selected": true,
"text": "int Test::numelem = 0;"
},
{
"answer_id": 74333164,
"author": "Wyck",
"author_id": 1563833,
"author_profile": "https://Stackoverflow.com/users/1563833",
"pm_score": 2,
"selected": false,
"text": "class Test {\npublic:\n static int& numelem() {\n static int val = 0; // or your initializer here\n return val;\n }\n\n int increment() {\n return ++numelem();\n }\n};\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333036",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20429705/"
] |
74,333,038 | <p>I'm trying to work with generics to create a <a href="https://go.dev/ref/spec#Type_parameter_declarations" rel="nofollow noreferrer">parameterised type</a> which can be of:</p>
<pre><code>T, *T, T[], map[interface{}]interface{}
</code></pre>
<p>Where: <code>T</code> is of <code>comparable</code> type, but <em><strong>is not</strong> an interface</em>.</p>
<hr />
<p>I've attempted to formulate this through constrained typeset, but this fails due to <a href="https://pkg.go.dev/golang.org/x/tools/internal/typesinternal#MisplacedTypeParam:%7E:text=//%20MisplacedTypeParam%20occurs%20when%20a%20type%20parameter%20is%20used%20in%20a%20place%20where%0A%09//%20it%20is%20not%20permitted." rel="nofollow noreferrer">MisplacedTypeParam</a> compiler error:</p>
<pre><code>type myType[T comparable] interface {
T | *T | T[] | map[interface{}]interface{}
}
</code></pre>
<p>I also have the issue when using <code>reflect</code>, that getting the <code>reflect.Kind</code>
or <code>reflect.Type</code> of an interface will return the value's type underlying the interface, which means I haven't figured out how to assert the type <em><strong>is not</strong> an interface</em>.</p>
<hr />
<p>From this, I am wondering what the best alternative way to represent such a type would be?</p>
<hr>
<p>This is my work in progress (<a href="https://github.com/mcwalrus/go-jitjson" rel="nofollow noreferrer">https://github.com/mcwalrus/go-jitjson</a>) and its main parts:</p>
<pre><code>type JitJSON[T any] struct {
data []byte
val *T
}
func (jit *JitJSON[T]) Unmarshal() (T, error) {
if jit.val != nil {
return *jit.val, nil
}
var val T
if jit.data == nil {
return val, nil
}
jit.val = &val
err := json.Unmarshal(jit.data, jit.val)
if err != nil {
return val, err
}
return *jit.val, nil
}
</code></pre>
| [
{
"answer_id": 74333494,
"author": "Hymns For Disco",
"author_id": 11424673,
"author_profile": "https://Stackoverflow.com/users/11424673",
"pm_score": 3,
"selected": true,
"text": "reflect"
},
{
"answer_id": 74353402,
"author": "blackgreen",
"author_id": 4108803,
"author_profile": "https://Stackoverflow.com/users/4108803",
"pm_score": 0,
"selected": false,
"text": "comparable"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333038",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9170199/"
] |
74,333,048 | <p>I have tried to create Listview.builder with help of API(for displaying API product). but i got error in bottom pixel. i tried many ways to solve this problem. but couldn't find anything,
how can i solve this problems by editing code... And what is the main reason for this error</p>
<p><a href="https://i.stack.imgur.com/BQlPu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BQlPu.png" alt="enter image description here" /></a></p>
<p>code is here</p>
<pre><code> Container(
height: 650,
child: FutureBuilder(
future: _getProduct(),
builder: (context, snapshot) {
if (snapshot.data == null) {
return const Center(child: Text("Loading"));
} else {
return GridView.builder(
gridDelegate:
const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2),
itemCount: snapshot.data?.length,
itemBuilder: (context, index) {
return Padding(
padding: const EdgeInsets.only(right: 10),
child: Container(
width: 130,
height: 485,
decoration: BoxDecoration(
color: Colors.white,
borderRadius:
BorderRadius.circular(10)),
child: Container(
height: 240,
child: Column(
children: [
Padding(
padding: EdgeInsets.all(5),
child: Image.network(
snapshot.data![index].image)),
Padding(
padding: const EdgeInsets.all(10),
child: Row(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: [
Expanded(
child: Text(
snapshot.data![index].name,
overflow: TextOverflow.fade,
maxLines: 2,
style: const TextStyle(
fontSize: 15,
fontWeight:
FontWeight.w700),
)),
Text(
snapshot.data![index].price)
],
),
)
],
),
),
),
);
},
);
}
}),
)
</code></pre>
| [
{
"answer_id": 74333494,
"author": "Hymns For Disco",
"author_id": 11424673,
"author_profile": "https://Stackoverflow.com/users/11424673",
"pm_score": 3,
"selected": true,
"text": "reflect"
},
{
"answer_id": 74353402,
"author": "blackgreen",
"author_id": 4108803,
"author_profile": "https://Stackoverflow.com/users/4108803",
"pm_score": 0,
"selected": false,
"text": "comparable"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333048",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17934416/"
] |
74,333,058 | <p>How do I interchange a fixed string with a sequential string?</p>
<p>For instance, if I want to repeat a pattern of a string, I would do the following:</p>
<pre><code>> rep(c("Filler","Model"),2)
[1] "Filler" "Model" "Filler" "Model" "Filler" "Model"
</code></pre>
<p>But, I want something like this where I can automatically add numbers behind "Model" with each iteration of a repeat:</p>
<pre><code>[1] "Filler" "Model 1" "Filler" "Model 2" "Filler" "Model 3"
</code></pre>
<p>Is there a way to combine <code>rep()</code> with <code>sprintf()</code>?</p>
| [
{
"answer_id": 74333092,
"author": "Tim Biegeleisen",
"author_id": 1863229,
"author_profile": "https://Stackoverflow.com/users/1863229",
"pm_score": 3,
"selected": true,
"text": "x <- rep(c(\"Filler\",\"Model\"),3)\nx[c(FALSE, TRUE)] <- paste(x[c(FALSE, TRUE)], c(1:3))\nx\n\n[1] \"Filler\" \"Model 1\" \"Filler\" \"Model 2\" \"Filler\" \"Model 3\"\n"
},
{
"answer_id": 74333922,
"author": "TarJae",
"author_id": 13321647,
"author_profile": "https://Stackoverflow.com/users/13321647",
"pm_score": 1,
"selected": false,
"text": "x <- rep(c(\"Filler\",\"Model\"),3)\n\nx[x==\"Model\"] = paste(\"Model\", seq_along(x[x==\"Model\"]))\nx\n"
},
{
"answer_id": 74335153,
"author": "AndS.",
"author_id": 9778513,
"author_profile": "https://Stackoverflow.com/users/9778513",
"pm_score": 1,
"selected": false,
"text": "x <- c(\"Filler\", \"Model\", \"Filler\", \"Model\", \"Model\", \"Model\")\n\nreplace(x, which(x == \"Model\"), paste(x, cumsum(x == \"Model\"))[which(x == \"Model\")])\n#> [1] \"Filler\" \"Model 1\" \"Filler\" \"Model 2\" \"Model 3\" \"Model 4\"\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333058",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10178641/"
] |
74,333,082 | <p>Hopefully, someone can help me out because I've tried a bunch of things and it appears my system is in some weird state.</p>
<p>The way I am running the system, I am running, essentially, a test environment on my local computer. I do various changes etc locally. I then push to bitbucket, ideally making origin/master the ideal production branch.</p>
<p>The Production server I utilize pulls only from origin. There are no changes made on the production server, so there are no unpushed commits.</p>
<p>The link between my local test environment and the origin works as expected. I'm doing it through GitKraken. I can see the origin/master and local master, and various other branches and they are all where I expect them to be.</p>
<p><strong>The problem is the production server:</strong></p>
<p>When I run "git pull http://.......bitbucket....git master
It pulls everything down and acts like it is in the correct commit for origin/master.</p>
<p>However, it says it is 26 commits ahead of origin/master.</p>
<p>I tried running <code>git branch -a</code> and it shows 1 local branch and 2 remote branches. However, there should be four remote branches, not 2.</p>
<p>Additionally, it seems like I can do anything to pull the correct origin/master location. It always thinks it is at the commit 26 behind.</p>
<p>I have tried git reset --hard origin/master, and that put me to what it thinks is the origin/master, the commit 26 behind where it should be.</p>
<p>My theories as to why this is occurring are as follows:</p>
<ul>
<li><p>The commit it is stuck on was the last commit by the previous developer. The repo was set up by this previous dev and his account. My account has admin access to the repo, but I was wondering if there could be a cause here.</p>
</li>
<li><p>There is a git command I'm not using properly that is meant to pull information from the origin.</p>
</li>
</ul>
<p>Any suggestions are appreciated.</p>
<p><strong>Edit:
Some clarification on recent comments.</strong></p>
<pre><code>git fetch, git pull, git fetch origin
</code></pre>
<p>all provide the following error:</p>
<pre><code>fatal: could not read Password for 'https://djprior@bitbucket.org': No such device or address.
</code></pre>
<p>I can only seem to get anything by running:</p>
<pre><code>git pull https://{username}:{password}@bitbucket.org/{account}/{repo}.git master
</code></pre>
<p>I was under the impression that if my 'git pull ....' command is working, then it should run a git fetch at the same time, updating the remote branches correctly.</p>
<p>Running "git reset —hard origin/master" pushes me back to the commit 26 commits behind the correct one. (presumably because git fetch is failing)</p>
<p>After reading comments perhaps there is a problem with my git/config.</p>
<p>See below:</p>
<pre><code> [core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = https://{username}@bitbucket.org/{account}/mii.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
</code></pre>
| [
{
"answer_id": 74340167,
"author": "torek",
"author_id": 1256452,
"author_profile": "https://Stackoverflow.com/users/1256452",
"pm_score": 1,
"selected": false,
"text": "git pull http://.......bitbucket....git master\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333082",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8856511/"
] |
74,333,086 | <p>Beginner-ish to python and my sleep function in the function pet_dog is not working properly. I want heart2 to appear when u pet the dog, then sleep for a second, and then it hides. However, instead no heart appears, it just waits a second then adds 1 to the score. I think the sleep function is not pausing before the hideturtle command for some reason and I dont know why.</p>
<p>Tried getting there to be a pause between "heart2.showturtle()" and "heart2.hideturtle()" but instead it is acting as if the pause is between "heart2.hideturtle()" and "score += 1"</p>
<pre><code>import turtle
from time import sleep
wn = turtle.Screen()
wn.title("dog petting game!!!")
wn.bgcolor("green")
wn.setup(width = 500, height = 500)
wn.tracer(0)
#person and dogs
shape_heart = ((-6, -10), (-6,-6), (-4, -6), (-4, -4), (-2, -4), (-2, -2), (0, -2), (0,0), (6, 0), (6, -2), (8,-2), (8, -4), (12, -4), (12, -2), (14, -2), (14, 0), (20, 0), (20, -2), (22, -2), (22, -4), (24, -4), (24, -6), (26, -6), (26, -12), (24, -12), (24, -16), (22, -16), (22, -18), (20, -18), (20, -20), (18, -20), (18, -22), (16, -22), (16, -24), (14, -24), (14, -26), (12, -26), (12, -28), (8, -28), (8, -26), (6, -26), (6, -24), (4, -24), (4, -22), (2, -22), (2, -20), (0, -20), (0, -18), (-2, -18), (-2, -16), (-4, -16))
shape_dog = ((0,0), (0, 5), (15, 5), (15, 10), (45, 10), (45, 15), (47, 15), (47, 19), (51, 19,), (51, 15), (54, 15), (54, 19), (58, 19), (58, 15), (60, 15), (60, 0), (50,0), (50, -5), (45, -5), (45, -20), (41, -20), (41, -5), (38, -5), (38, -20), (34, -20), (34, -5), (31, -5), (31, -20), (27, -20), (27, -5), (24, -5), (24, -20), (20, -20), (20, -5), (15, -5), (15, 0))
shape_person = ((0, 100), (0, 110), (35, 110), (35, 135), (60, 135), (60, 110), (95, 110), (95, 100), (60, 100), (60, 20), (52, 20), (52, 60), (43, 60), (43, 20), (35, 20), (35, 100))
turtle.register_shape('heart', shape_heart)
heart1 = turtle.Turtle()
heart1.speed(0)
heart1.left(90)
heart1.shape('heart')
heart1.color('red')
heart1.penup()
heart1.goto(155, 205)
heart1.hideturtle()
heart2 = turtle.Turtle()
heart2.speed(0)
heart2.left(90)
heart2.shape('heart')
heart2.color('red')
heart2.penup()
heart2.goto(-5, 155)
heart2.hideturtle()
heart3 = turtle.Turtle()
heart3.speed(0)
heart3.left(90)
heart3.shape('heart')
heart3.color('red')
heart3.penup()
heart3.goto(-175, 205)
heart3.hideturtle()
turtle.register_shape('dog', shape_dog)
dog1 = turtle.Turtle()
dog1.speed(0)
dog1.left(90)
dog1.shape('dog')
dog1.color('orange')
dog1.penup()
dog1.goto(-200, 150)
dog2 = turtle.Turtle()
dog2.speed(0)
dog2.left(90)
dog2.shape('dog')
dog2.color('orange')
dog2.penup()
dog2.goto(-30, 100)
dog3 = turtle.Turtle()
dog3.speed(0)
dog3.left(90)
dog3.shape('dog')
dog3.color('orange')
dog3.penup()
dog3.goto(130, 150)
turtle.register_shape('person', shape_person)
character = turtle.Turtle()
character.speed(0)
character.left(90)
character.shape("person")
character.color("white")
character.penup()
character.goto(-40, -150)
#functions
def pet_dog():
global score
if character.xcor() > 13 and character.xcor() < 31 and character.ycor() > -10 and character.ycor() < 10:
heart2.showturtle()
sleep(1)
heart2.hideturtle()
score += 1
if character.xcor() > -156 and character.xcor() < -139 and character.ycor() > 39 and character.ycor() < 60:
heart3.showturtle()
score += 1
if character.xcor() > 174 and character.xcor() < 191 and character.ycor() > 39 and character.ycor() < 60:
heart1.showturtle()
score += 1
pen.clear()
pen.write(f"Dogs pet: {score}", align = 'center', font = ('Courier', 16, 'normal'))
def character_up():
y = character.ycor()
y += 5
character.sety(y)
def character_down():
y = character.ycor()
y -= 5
character.sety(y)
def character_right():
x = character.xcor()
x += 5
character.setx(x)
def character_left():
x = character.xcor()
x -= 5
character.setx(x)
#Keyboard binding
wn.listen()
wn.onkeypress(character_up, "Up")
wn.onkeypress(character_down, "Down")
wn.onkeypress(character_right, "Right")
wn.onkeypress(character_left, "Left")
wn.onkeypress(pet_dog, "p")
#Scoreboard
pen = turtle.Turtle()
pen.speed(0)
pen.color('blue')
pen.penup()
pen.hideturtle()
pen.goto(0, 200)
pen.write("Dogs pet: 0", align = 'center', font = ('Courier', 16, 'normal'))
#Score
score = 0
while True:
wn.update()
#Don't let character leave boarders
if character.ycor() > 120:
character.goto(character.xcor(), 110)
if character.ycor() < -270:
character.goto(character.xcor(), -260)
if character.xcor() > 185:
character.goto(180, character.ycor())
if character.xcor() < -285:
character.goto(-280, character.ycor())
</code></pre>
| [
{
"answer_id": 74337080,
"author": "KillerRebooted",
"author_id": 18554284,
"author_profile": "https://Stackoverflow.com/users/18554284",
"pm_score": 1,
"selected": false,
"text": "wn.tracer(0)"
},
{
"answer_id": 74342071,
"author": "cdlane",
"author_id": 5771269,
"author_profile": "https://Stackoverflow.com/users/5771269",
"pm_score": 0,
"selected": false,
"text": "update()"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333086",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20429738/"
] |
74,333,094 | <p>My <code>paintings</code> table looks like this</p>
<pre><code>| id | artist_id | name
| 1 | 7 | landscape painting
| 2 | 15 | flowers painting
| 3 | 15 | scuffed painting
</code></pre>
<p>The <code>artist_id</code> is indexed and the <code>name</code> has a <code>fulltext</code> index on it. The table contains about 10M record.</p>
<p>Queries that match the <code>name</code> agains some keywords are ok:</p>
<pre><code>select * from `paintings` where match (`name`) against ('+scuffed*' in boolean mode) limit 10;
10 rows in set (0.04 sec)
</code></pre>
<p>But when I sometimes want to only check for a certain painting done by a certain artist:</p>
<pre><code>select * from `paintings` where `artist_id` = 15 and match (`name`) against ('+scuffed*' in boolean mode) limit 10;
7 rows in set (0.40 sec)
</code></pre>
<p>As you can see it takes 10x longer to run the query when I include the <code>artist_id</code>. I also tried running a nested query in order to get only paintings that have specific ids:</p>
<pre><code>select * from `paintings` where id in (SELECT id from paintings where artist_id = 15) and match (`name`) against ('+scuffed*' in boolean mode) limit 10;
7 rows in set (0.44 sec)
</code></pre>
<p>This ended up being even slower.</p>
<p>How can this query be optimized to work well with and without a where clause on the <code>artist_id</code>?</p>
<p>Thank you!</p>
| [
{
"answer_id": 74337080,
"author": "KillerRebooted",
"author_id": 18554284,
"author_profile": "https://Stackoverflow.com/users/18554284",
"pm_score": 1,
"selected": false,
"text": "wn.tracer(0)"
},
{
"answer_id": 74342071,
"author": "cdlane",
"author_id": 5771269,
"author_profile": "https://Stackoverflow.com/users/5771269",
"pm_score": 0,
"selected": false,
"text": "update()"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333094",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11820856/"
] |
74,333,103 | <p>I have cloud function defined in my <code>index.ts</code>. However, when try to deploy my cloud functions with <code>firebase deploy</code>, the Firebase CLI is not detecting my function.</p>
<p>Output in the terminal</p>
<pre><code>✔ functions: Finished running predeploy script.
i functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i functions: ensuring required API cloudbuild.googleapis.com is enabled...
i artifactregistry: ensuring required API artifactregistry.googleapis.com is enabled...
✔ functions: required API cloudfunctions.googleapis.com is enabled
✔ functions: required API cloudbuild.googleapis.com is enabled
✔ artifactregistry: required API artifactregistry.googleapis.com is enabled
i functions: preparing codebase default for deployment
i functions: preparing cloud_functions directory for uploading...
i functions: packaged /Users/nils/cloud_functions (243.98 KB) for uploading
✔ functions: cloud_functions folder uploaded successfully
i functions: cleaning up build files...
✔ Deploy complete!
</code></pre>
<p>My <code>index.ts</code></p>
<pre><code>import { submitFunction } from "./features/submit/submit_function";
</code></pre>
<p>My <code>submit_function.ts</code>:</p>
<pre><code>exports.submit = submitFunction();
</code></pre>
<pre><code>import * as functions from "firebase-functions";
export async function submitFunction() {
return functions.https.onRequest(async (req, response) => {
response.status(200);
});
}
</code></pre>
| [
{
"answer_id": 74333104,
"author": "Nils Reichardt",
"author_id": 8358501,
"author_profile": "https://Stackoverflow.com/users/8358501",
"pm_score": 1,
"selected": true,
"text": "submitFunction"
},
{
"answer_id": 74333293,
"author": "Frank van Puffelen",
"author_id": 209103,
"author_profile": "https://Stackoverflow.com/users/209103",
"pm_score": 1,
"selected": false,
"text": "index.js"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333103",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8358501/"
] |
74,333,109 | <p>Here is original text file:</p>
<pre><code>s1 10 s2
s2 12 s3
s3 25 s1
s1 14 s3
</code></pre>
<p>I am making a dictionary of first value in each line as a key, the output should be:
{'s1': [<strong>('s2', 's10'), ('s3', '14')</strong>], 's2': [('s3', '12')], 's3': [('s1', '25')]}</p>
<p>When i run my code I get a key error:</p>
<pre><code>def graph_dict(filename):
dictx = {}
with open(filename) as x:
for i in x:
c, c1, c2 = i.split()
dictx[c] += [(c2,c1)]
return dictx
Traceback (most recent call last):
File "<pyshell#361>", line 1, in <module>
graph_dict("filename.txt")
File "*********************************************", line 7, in graph_dict
dictx[c] += [(c2,c1)]
KeyError: 's1'
</code></pre>
<p>in the above line when I make it into dictx[c] = [(c2,c1)] I get output;</p>
<pre><code>{'s1': [('s3', '14')], 's2': [('s3', '12')], 's3': [('s1', '25')]}
</code></pre>
<p>And so it is throwing a key error as attempting to add a list of 2 tuples to "s1", which I thought should be okay. Does anyone have advice to get output:</p>
<pre><code>{'s1': [('s2', 's10'), ('s3', '14')], 's2': [('s3', '12')], 's3': [('s1', '25')]}
</code></pre>
<p>Thanks</p>
| [
{
"answer_id": 74333138,
"author": "Алексей Р",
"author_id": 15035314,
"author_profile": "https://Stackoverflow.com/users/15035314",
"pm_score": 0,
"selected": false,
"text": ".setdefault()"
},
{
"answer_id": 74333141,
"author": "tdelaney",
"author_id": 642070,
"author_profile": "https://Stackoverflow.com/users/642070",
"pm_score": 1,
"selected": true,
"text": "dictx[c] += [(c2,c1)]"
},
{
"answer_id": 74333144,
"author": "Mark",
"author_id": 2203038,
"author_profile": "https://Stackoverflow.com/users/2203038",
"pm_score": 0,
"selected": false,
"text": "from collections import defaultdict \n\ndef graph_dict(filename):\n dictx = defaultdict(list)\n with open(filename) as x:\n for i in x:\n c, c1, c2 = i.split()\n dictx[c] += [(c2,c1)]\n return dictx\n\nprint(graph_dict('data'))\n"
},
{
"answer_id": 74333168,
"author": "Steven",
"author_id": 6543301,
"author_profile": "https://Stackoverflow.com/users/6543301",
"pm_score": 1,
"selected": false,
"text": "defaultdict"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333109",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20217852/"
] |
74,333,132 | <p>I am having problems running my React Native application that was running fine just yesterday. Therefore I ran the command:</p>
<pre><code>npx react-native run-android -- --warning-mode=all
</code></pre>
<p>Which gives information starting with:</p>
<pre><code>> Task :react-native-async-storage_async-storage:generateDebugRFile FAILED
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
FAILURE: Build failed with an exception.
...
* What went wrong:
Execution failed for task ':react-native-async-storage_async-storage:generateDebugRFile'.
> Could not resolve all files for configuration ':react-native-async-storage_async-storage:debugCompileClasspath'.
> Failed to transform react-native-0.71.0-rc.0-debug.aar (com.facebook.react:react-native:0.71.0-rc.0) to match attributes {artifactType=android-symbol-with-package-name, com.android.build.api.attributes.BuildTypeAttr=debug, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-api}.
> Execution failed for JetifyTransform: C:\Users\pangi\.gradle\caches\modules-2\files-2.1\com.facebook.react\react-native\0.71.0-rc.0\7a7f5a0af6ebd8eb94f7e5f7495e9d9684b4f543\react-native-0.71.0-rc.0-debug.aar.
> Java heap space
</code></pre>
<p>My first problem is how to resolve this issue? I seem to be unable to find resolutions for this particular issue on the Internet. Obviously it is related to the 'async storage' package and I did update it, however that did not resolve the issue.</p>
<p>Supposedly using the "--warning-mode=all" verbiage should provide links to Gradle to help resolve the issue...however I see none. I also notice in that output mention is given of 'react-native-0.71' however I am using a lower version...not sure if that is related to the issue. Any advice appreciated.</p>
<p>My second question is more general. Why do nonsensical and ridiculous things like this CONSTANTLY happen in React Native? As mentioned, the code worked fine last time I booted up. I can make no changes whatsoever to my code (or minimal ones) and suddenly the code is broken and non-functional...through no fault of my own but relating to some npm package or some other reason (Gradle for example) that has nothing to do with me. I have never seen, nor imagined...that such an unreliable and 'bug-ridden' piece of software could be released to the general public. Why are issues like this consistently occurring in React Native? Is it just incompetence or is there a better answer? I am always dealing with unending frustration and anger due to these practices causing me problems with this particular platform. If somebody could explain why this development 'environment' is riddled with these problems I would be most appreciative.</p>
| [
{
"answer_id": 74334408,
"author": "ZFloc Technologies",
"author_id": 10657559,
"author_profile": "https://Stackoverflow.com/users/10657559",
"pm_score": 5,
"selected": true,
"text": "0.71.0-rc0"
},
{
"answer_id": 74337494,
"author": "Sir'Energieman",
"author_id": 12008648,
"author_profile": "https://Stackoverflow.com/users/12008648",
"pm_score": 3,
"selected": false,
"text": "// Top-level build file where you can add configuration options common to all sub-projects/modules.\n\nbuildscript {\n\n ext {\n buildToolsVersion = \"30.0.2\"\n minSdkVersion = 21\n compileSdkVersion = 30\n targetSdkVersion = 30\n ndkVersion = \"21.4.7075529\"\n kotlinVersion = '1.6.0'\n }\n repositories {\n google()\n mavenCentral()\n }\n dependencies {\n classpath(\"com.android.tools.build:gradle:4.2.2\")\n // NOTE: Do not place your application dependencies here; they belong\n // in the individual module build.gradle files\n }\n}\n\nallprojects {\n repositories {\n\n // ------ Fix starts here\n\n exclusiveContent {\n filter {\n includeGroup \"com.facebook.react\"\n }\n forRepository {\n maven {\n url \"$rootDir/../node_modules/react-native/android\"\n }\n }\n }\n \n // --------- Fix ends here\n\n \n maven {\n // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm\n url(\"$rootDir/../node_modules/react-native/android\")\n }\n maven {\n // Android JSC is installed from npm\n url(\"$rootDir/../node_modules/jsc-android/dist\")\n }\n mavenCentral {\n // We don't want to fetch react-native from Maven Central as there are\n // older versions over there.\n content {\n excludeGroup \"com.facebook.react\"\n }\n }\n google()\n maven { url 'https://www.jitpack.io' }\n }\n}\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333132",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9674022/"
] |
74,333,176 | <p>Good day,
Im trying to upload a image to flutter but i cannot see whats wrong with my code.
any help will be highly appreciated.
thank you
this is image of my file system</p>
<p><a href="https://i.stack.imgur.com/fKFys.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fKFys.png" alt="image " /></a></p>
<p><a href="https://i.stack.imgur.com/GdQpG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GdQpG.png" alt="file system" /></a></p>
<p>and here the error a get
[![enter image description here][3]][3]</p>
<p>and if you want to try my code</p>
<pre><code>import 'package:flutter/material.dart';
class Dashboard extends StatelessWidget {
const Dashboard({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
body: SingleChildScrollView(
child: SafeArea(
child: Column(
children: [
Padding(
padding: const EdgeInsets.symmetric(vertical: 30.0, horizontal: 40),
child: Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: const [
Text('Hi Emma', style:TextStyle(fontSize: 30),),
Text('Welcome back', style: TextStyle(fontSize: 40),),
],
),
],
),
),
Image.asset('assets/images/pic.png')
],
),
),
),
);
}
}
</code></pre>
<p>the error</p>
<pre><code>Launching lib/main.dart on iPhone 14 Pro Max in debug mode...
Running Xcode build...
Xcode build done. 16.7s
Debug service listening on ws://127.0.0.1:64299/4VQyTtoPAoU=/ws
Syncing files to device iPhone 14 Pro Max...
======== Exception caught by image resource service ================================================
The following assertion was thrown resolving an image codec:
Unable to load asset: assets/images/pic.png.
When the exception was thrown, this was the stack:
#0 PlatformAssetBundle.loadBuffer (package:flutter/src/services/asset_bundle.dart:288:7)
#1 AssetBundleImageProvider._loadAsync (package:flutter/src/painting/image_provider.dart:731:35)
#2 AssetBundleImageProvider.loadBuffer (package:flutter/src/painting/image_provider.dart:695:14)
#3 ImageProvider.resolveStreamForKey.<anonymous closure> (package:flutter/src/painting/image_provider.dart:513:13)
#4 ImageCache.putIfAbsent (package:flutter/src/painting/image_cache.dart:384:22)
#5 ImageProvider.resolveStreamForKey (package:flutter/src/painting/image_provider.dart:511:81)
#6 ScrollAwareImageProvider.resolveStreamForKey (package:flutter/src/widgets/scroll_aware_image_provider.dart:106:19)
#7 ImageProvider.resolve.<anonymous closure> (package:flutter/src/painting/image_provider.dart:358:9)
#8 ImageProvider._createErrorHandlerAndKey.<anonymous closure> (package:flutter/src/painting/image_provider.dart:473:24)
<asynchronous suspension>
Image provider: AssetImage(bundle: null, name: "assets/images/pic.png")
Image key: AssetBundleImageKey(bundle: PlatformAssetBundle#9da8b(), name: "assets/images/pic.png", scale: 1.0)
====================================================================================================
</code></pre>
| [
{
"answer_id": 74334523,
"author": "Nguyen family",
"author_id": 19992458,
"author_profile": "https://Stackoverflow.com/users/19992458",
"pm_score": 0,
"selected": false,
"text": "flutter:\n uses-material-design: true\n assets:\n - assets/icons/\n - assets/fonts/\n - assets/images/\n"
},
{
"answer_id": 74334577,
"author": "TANIMUL ISLAM",
"author_id": 18262004,
"author_profile": "https://Stackoverflow.com/users/18262004",
"pm_score": 3,
"selected": true,
"text": " assets:\n - assets/images/\n"
},
{
"answer_id": 74334607,
"author": "Tasnuva Tavasum oshin",
"author_id": 8480069,
"author_profile": "https://Stackoverflow.com/users/8480069",
"pm_score": 0,
"selected": false,
"text": "Image.asset('lib/assets/images/pic.png')\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333176",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4687850/"
] |
74,333,217 | <p>I apologize if this is a bit confusing to read, this is my first post.
Please consider the following code:</p>
<p>HTML:</p>
<pre><code>...
<form>
<input type="text" id="to-do-input" placeholder="Add new task..">
<button id="add-to-do" type="button">Add ToDo</button>
</form>
<div id="to-do-container">
</div>
...
</code></pre>
<p>JAVASCRIPT:</p>
<pre><code> var addButton = document.getElementById("add-to-do");
toDoArray = [];
addButton.addEventListener("click", function() {
let nHTML = '';
let todoValue = document.getElementById("to-do-input").value;
toDoArray.push(todoValue);
toDoArray.forEach( function(item) {
//READ BELOW
//<!--set each array item's id to it's own string value minus white spaces
var itemId = item.replace(' ','');
item.setAttribute("id", itemId); //console: "item.setAttribute is not a function"
//-->
nHTML += '<li>' + item + ' <button id="delete">Remove</button> </li>';
});
document.getElementById("to-do-container").innerHTML = '<ul>' + nHTML + '</ul>';
document.getElementById("to-do-input").value = '';
});
</code></pre>
<p>PROBLEM:
The plan is to set each array item's id value to its own string value minus all spaces via .replace(), but the console is saying:</p>
<pre><code>app.js:17 Uncaught TypeError: item.setAttribute is not a function
at app.js:17:26
at Array.forEach (<anonymous>)
at HTMLButtonElement.<anonymous> (app.js:14:27
</code></pre>
<p>I tried to also type item.setAttribute("id", <code>${itemId}</code>), but that hasn't worked either.</p>
| [
{
"answer_id": 74334523,
"author": "Nguyen family",
"author_id": 19992458,
"author_profile": "https://Stackoverflow.com/users/19992458",
"pm_score": 0,
"selected": false,
"text": "flutter:\n uses-material-design: true\n assets:\n - assets/icons/\n - assets/fonts/\n - assets/images/\n"
},
{
"answer_id": 74334577,
"author": "TANIMUL ISLAM",
"author_id": 18262004,
"author_profile": "https://Stackoverflow.com/users/18262004",
"pm_score": 3,
"selected": true,
"text": " assets:\n - assets/images/\n"
},
{
"answer_id": 74334607,
"author": "Tasnuva Tavasum oshin",
"author_id": 8480069,
"author_profile": "https://Stackoverflow.com/users/8480069",
"pm_score": 0,
"selected": false,
"text": "Image.asset('lib/assets/images/pic.png')\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20429713/"
] |
74,333,237 | <p>I'm trying to count days between two dates but I can't figure out how to do it.</p>
<p>This is the code I am using:</p>
<pre><code>from datetime import datetime
from datetime import date
hoy = date(datetime.today().strftime("%Y,%m,%e")) #current time
otra_fecha = date(2022, 11, 5)
delta = hoy - otra_fecha
print(delta.days)
</code></pre>
<p>This is the error that is thrown:</p>
<pre class="lang-none prettyprint-override"><code>TypeError: an integer is required (got type str)
</code></pre>
| [
{
"answer_id": 74333357,
"author": "Manoj Awasthi",
"author_id": 83602,
"author_profile": "https://Stackoverflow.com/users/83602",
"pm_score": 0,
"selected": false,
"text": ".date()"
},
{
"answer_id": 74333429,
"author": "sagamantus",
"author_id": 16002540,
"author_profile": "https://Stackoverflow.com/users/16002540",
"pm_score": 1,
"selected": false,
"text": "datetime.today().strftime(\"%Y,%m,%e\")"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333237",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20429898/"
] |
74,333,262 | <p>xcodebuild: error: SDK "/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk" cannot be located.</p>
<p>git: error: Failed to determine realpath of '/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk' (errno=No such file or directory)</p>
<p>this caused a dead lock, git can not found this path, and it can not be installed, then it ask to install, I installed, it can not foud this path, and it can not be installed.....</p>
<p>what should I do?</p>
| [
{
"answer_id": 74336122,
"author": "Ahmad Santarissy",
"author_id": 915306,
"author_profile": "https://Stackoverflow.com/users/915306",
"pm_score": 1,
"selected": false,
"text": "xcrun --show-sdk-path"
},
{
"answer_id": 74639734,
"author": "EimerReis",
"author_id": 11874243,
"author_profile": "https://Stackoverflow.com/users/11874243",
"pm_score": 0,
"selected": false,
"text": "sudo xcode-select --switch /Library/Developer/CommandLineTools"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333262",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6744309/"
] |
74,333,271 | <pre><code>import math
def max_magnitude(val1, val2, val3):
if abs(val1) > abs(val2) and abs(val3):
return(val1)
elif abs(val2) > abs(val3) and abs(val1):
return(val2)
elif abs(val3) > abs(val2) and abs(val1):
return(val3)
def main():
val1 = int(input())
val2 = int(input())
val3 = int(input())
print(max_magnitude(val1, val2, val3))
if __name__ == '__main__':
main()
</code></pre>
<p>input:
25 0 -50
expected test: return correctly -50
but
my output test : return incorrectly 25</p>
<p>someone help me to fix that error while texting</p>
| [
{
"answer_id": 74333305,
"author": "Krzysztof Chojnacki",
"author_id": 16617833,
"author_profile": "https://Stackoverflow.com/users/16617833",
"pm_score": 0,
"selected": false,
"text": "def max_magnitude(val1, val2, val3): \n \n if abs(val1) > abs(val2) and abs(val1) > abs(val3):\n return(val1)\n elif abs(val2) > abs(val3) and abs(val2) > abs(val1):\n return(val2)\n elif abs(val3) > abs(val2) and abs(val3) > abs(val1):\n return(val3)\ndef main():\n val1 = int(input())\n val2 = int(input())\n val3 = int(input())\n \n print(max_magnitude(val1, val2, val3))\n \n\n\nif __name__ == '__main__':\n main()\n"
},
{
"answer_id": 74333319,
"author": "The Myth",
"author_id": 15042008,
"author_profile": "https://Stackoverflow.com/users/15042008",
"pm_score": 1,
"selected": false,
"text": "map()"
},
{
"answer_id": 74333361,
"author": "Алексей Р",
"author_id": 15035314,
"author_profile": "https://Stackoverflow.com/users/15035314",
"pm_score": 1,
"selected": false,
"text": "sorted()"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333271",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20429919/"
] |
74,333,282 | <p>Can't install package for AudioKit on Xcode 14.1, in Monterey.</p>
<p>It is asking for credentials and there is no choice for unsigned packages.</p>
<p>Followed these instructions:</p>
<p>Using Xcode, you can add AudioKit and any of the other AudioKit libraries using Collections</p>
<p>Select File -> Add Packages...
Click the + icon on the bottom left of the Collections sidebar on the left.
Choose Add Swift Package Collection from the pop-up menu.
In the Add Package Collection dialog box, enter <a href="https://swiftpackageindex.com/AudioKit/collection.json" rel="nofollow noreferrer">https://swiftpackageindex.com/AudioKit/collection.json</a> as the URL and click the "Load" button.
It will warn you that the collection is not signed, but it is fine, click "Add Unsigned Collection".
Now you can add any of the AudioKit Swift Packages you need and read about what they do, right from within Xcode.</p>
<p><a href="https://i.stack.imgur.com/nJ92O.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nJ92O.jpg" alt="enter image description here" /></a></p>
<p>Try to add package as per the instructions. It's asking for credentials.</p>
| [
{
"answer_id": 74333305,
"author": "Krzysztof Chojnacki",
"author_id": 16617833,
"author_profile": "https://Stackoverflow.com/users/16617833",
"pm_score": 0,
"selected": false,
"text": "def max_magnitude(val1, val2, val3): \n \n if abs(val1) > abs(val2) and abs(val1) > abs(val3):\n return(val1)\n elif abs(val2) > abs(val3) and abs(val2) > abs(val1):\n return(val2)\n elif abs(val3) > abs(val2) and abs(val3) > abs(val1):\n return(val3)\ndef main():\n val1 = int(input())\n val2 = int(input())\n val3 = int(input())\n \n print(max_magnitude(val1, val2, val3))\n \n\n\nif __name__ == '__main__':\n main()\n"
},
{
"answer_id": 74333319,
"author": "The Myth",
"author_id": 15042008,
"author_profile": "https://Stackoverflow.com/users/15042008",
"pm_score": 1,
"selected": false,
"text": "map()"
},
{
"answer_id": 74333361,
"author": "Алексей Р",
"author_id": 15035314,
"author_profile": "https://Stackoverflow.com/users/15035314",
"pm_score": 1,
"selected": false,
"text": "sorted()"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2880784/"
] |
74,333,304 | <pre><code>import random
string = ''
keys = ['car', 'banana', 'groof', 'jump', 'king', 'alley']
temp = random.randint(2,3)
for i in range(temp):
string = string + random.choice(keys) + ' '
string.strip()
print(string)
</code></pre>
<p>I'm just learning programming
Even if you use the strip function,
the space on the right end does not disappear.</p>
<p>What did I do wrong?</p>
| [
{
"answer_id": 74333305,
"author": "Krzysztof Chojnacki",
"author_id": 16617833,
"author_profile": "https://Stackoverflow.com/users/16617833",
"pm_score": 0,
"selected": false,
"text": "def max_magnitude(val1, val2, val3): \n \n if abs(val1) > abs(val2) and abs(val1) > abs(val3):\n return(val1)\n elif abs(val2) > abs(val3) and abs(val2) > abs(val1):\n return(val2)\n elif abs(val3) > abs(val2) and abs(val3) > abs(val1):\n return(val3)\ndef main():\n val1 = int(input())\n val2 = int(input())\n val3 = int(input())\n \n print(max_magnitude(val1, val2, val3))\n \n\n\nif __name__ == '__main__':\n main()\n"
},
{
"answer_id": 74333319,
"author": "The Myth",
"author_id": 15042008,
"author_profile": "https://Stackoverflow.com/users/15042008",
"pm_score": 1,
"selected": false,
"text": "map()"
},
{
"answer_id": 74333361,
"author": "Алексей Р",
"author_id": 15035314,
"author_profile": "https://Stackoverflow.com/users/15035314",
"pm_score": 1,
"selected": false,
"text": "sorted()"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333304",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20429930/"
] |
74,333,311 | <p><code>this.$route.path</code> gets the URL without the hashcode at the end. How do I either get the hash-part of the URL or get the full URL so I can figure out how to separate the hash part?</p>
<p>To be clear, for an URL like <code>https://example.com#test</code>, I'm looking the get the <code>test</code> part in a Nuxt page.</p>
<p>Couldn't seem to find documentation for all stuff in <code>$route</code> to see if this is something that is available.</p>
| [
{
"answer_id": 74333332,
"author": "Tim Biegeleisen",
"author_id": 1863229,
"author_profile": "https://Stackoverflow.com/users/1863229",
"pm_score": 1,
"selected": false,
"text": "match()"
},
{
"answer_id": 74335194,
"author": "kissu",
"author_id": 8816585,
"author_profile": "https://Stackoverflow.com/users/8816585",
"pm_score": 3,
"selected": true,
"text": "<script>\nexport default {\n mounted() {\n console.log('mounted', this.$route.hash)\n },\n}\n</script>\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333311",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7299313/"
] |
74,333,327 | <p>I'm the author of <a href="https://github.com/snoopyjc/pythonizer" rel="nofollow noreferrer">pythonizer</a>, perl to python converter, and I'm trying to translate a perl split statement that has a string pattern that includes a backslash, and I need some help understanding the behavior. Here is the example based on the source code I'm trying to translate:</p>
<pre><code>$s = 'a|b|c';
@a = split '\|', $s;
print scalar(@a) . "\n";
print "@a\n";
</code></pre>
<p>The output is:</p>
<pre><code>3
a b c
</code></pre>
<p>Now if I just print <code>'\|'</code> it prints <code>\|</code> so I'm not sure why the backslash is being ignored in the string pattern. The documentation doesn't say much of anything about a string being used as a pattern, except for the <code>' '</code> special case. Feeding <code>'\|'</code> to python string split will not split this string.</p>
<p>Even more strange is what happens if I change the above code to use a double-quoted string:</p>
<pre><code>@a = split "\|", $s;
</code></pre>
<p>Then the output is:</p>
<pre><code>5
a | b | c
</code></pre>
<p>If I change it to a regex, then it does the same thing as if it was a single-quoted string (splitting into 3 pieces), which makes perfect sense because <code>|</code> is a special char in a regex so it needs to be escaped:</p>
<pre><code>@a = split /\|/, $s;
</code></pre>
<p>So my question is - how is a split on a string that contains a backslash (in single and then double quotes) supposed to work so I can reproduce it in python? Should I just remove all backslashes, except for <code>\\</code> from a single-quoted input string if it's on a split?</p>
<p>Also, why does a split on <code>"\|"</code> (or <code>"|"</code>) split the string into 5 pieces? (I'm thinking of punting on this case.)</p>
| [
{
"answer_id": 74333643,
"author": "Crunchers3",
"author_id": 13129698,
"author_profile": "https://Stackoverflow.com/users/13129698",
"pm_score": 1,
"selected": false,
"text": "'\\|'"
},
{
"answer_id": 74334307,
"author": "zdim",
"author_id": 4653379,
"author_profile": "https://Stackoverflow.com/users/4653379",
"pm_score": 2,
"selected": false,
"text": "split"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333327",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11397243/"
] |
74,333,403 | <p>I'm not new to both coding and Godot and was trying to follow <a href="https://www.youtube.com/watch?v=nR0nCFJ8-qM&t=1084s" rel="nofollow noreferrer">this</a> tutorial but I keep getting the same error</p>
<blockquote>
<p>Invalid set index 'texture' (on base: 'TextureButton (ITEM_SPRITE.gd)') with value of type 'StreamTexture'.</p>
</blockquote>
<p>my code in the item class is:</p>
<pre><code>tool
extends Resource
class_name ITEM
export(String) var ITEM_NAME
export(int) var QUANT
export(String, MULTILINE) var HOVER_TEXT
export(Texture) var ITEM_TEXTURE
func addQuant(addedQuant :int):
QUANT += addedQuant
func getTexture() -> Texture:
return ITEM_TEXTURE
func getHover() -> String:
return HOVER_TEXT
</code></pre>
<p>This is the code for item sprite which should read <code>ITEM_TEXTURE</code> and set it to its own texture:</p>
<pre><code>tool
extends TextureButton
export(Resource) var item setget setItem
onready var labelText = $RichTitemextLabel
func addQuant(addedQuant :int):
item.addQuant(addedQuant)
func setItem(newItem : Resource):
item = newItem
self.texture = item.getTexture()
labelText.text = str(newItem.getHover())
</code></pre>
<p>I have tried changing the variable type of the texture var to <code>StreamTexture</code> and that did nothing, the actual item that uses the class works fine it is just the item sprite that can't read it for some reason. I have looked at a similar post but because my texture is an exported variable idk if change that if it is a problem</p>
<p>it should read the texture from the item and display it (but it is just returning the error)</p>
<p>sorry for the stupid question & please help if you can</p>
| [
{
"answer_id": 74333814,
"author": "Theraot",
"author_id": 402022,
"author_profile": "https://Stackoverflow.com/users/402022",
"pm_score": 1,
"selected": false,
"text": "TextureButton"
},
{
"answer_id": 74339766,
"author": "B0T_Alan",
"author_id": 20430011,
"author_profile": "https://Stackoverflow.com/users/20430011",
"pm_score": 0,
"selected": false,
"text": "self.texture"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333403",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20430011/"
] |
74,333,418 | <p>Is there a difference between the 2 sets of <code>#include</code> lines below?</p>
<pre><code>#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
</code></pre>
<p>and</p>
<pre><code>#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
</code></pre>
<p>Is it important in terms of coding style?</p>
<p>Does it the order matter for any optimizations?</p>
<p>Is it a matter of coding conventions?</p>
| [
{
"answer_id": 74333814,
"author": "Theraot",
"author_id": 402022,
"author_profile": "https://Stackoverflow.com/users/402022",
"pm_score": 1,
"selected": false,
"text": "TextureButton"
},
{
"answer_id": 74339766,
"author": "B0T_Alan",
"author_id": 20430011,
"author_profile": "https://Stackoverflow.com/users/20430011",
"pm_score": 0,
"selected": false,
"text": "self.texture"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333418",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17473587/"
] |
74,333,422 | <pre><code>const mark = {
fullName: 'Mark Miller',
mass: 78,
height: 1.69,
calcBMI: function () {
this.bmi = this.mass / (this.height * this.height);
return this.bmi
}
};
const john = {
fullName: 'John Smith',
mass: 92,
height: 1.95,
calcBMI: function () {
this.bmi = this.mass / (this.height * this.height);
return this.bmi
}
};
mark.bmi < john.bmi ? console.log(`${john.fullName}'s BMI ${john.calcBMI()} is greater than ${mark.fullName}'s BMI of ${mark.calcBMI()}`)
: console.log(`${mark.fullName}'s BMI ${mark.calcBMI()} is greater than ${john.fullName}'s BMI of ${john.calcBMI()}`)
</code></pre>
<p>so this code DOES produce the right log, except if i change johns height or weight the if/else doesnt update and log a different result and im confused as to why</p>
<p>thanks!</p>
| [
{
"answer_id": 74333814,
"author": "Theraot",
"author_id": 402022,
"author_profile": "https://Stackoverflow.com/users/402022",
"pm_score": 1,
"selected": false,
"text": "TextureButton"
},
{
"answer_id": 74339766,
"author": "B0T_Alan",
"author_id": 20430011,
"author_profile": "https://Stackoverflow.com/users/20430011",
"pm_score": 0,
"selected": false,
"text": "self.texture"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333422",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14290737/"
] |
74,333,437 | <p>I have an exe file and I want to have its hex bytes to load it in the memory of another process and then execute it (something like process injection). What I want is almost what <a href="https://cocomelonc.github.io/tutorial/2021/11/23/malware-injection-6.html" rel="nofollow noreferrer">this post</a> implements. The payload in this post in calculator software and it works well, but I want to substitute it with each exe file that I want. In short, how can I do this exe to hex conversion in such a way that it can be executed in another process context?</p>
<p>Methods like copying hex of exe from hex editors and debugger, online exe to hex converters and also using c++ instructions to do this conversion was not successful for me. This is the code I wrote in Go language:</p>
<pre><code>file, err := ioutil.ReadFile("...\\helper.exe")
if err != nil {
}
//fmt.Print(file)
f, err := os.Create("...\\fileInByte.txt")
if err != nil {
}
defer f.Close()
_, err = f.Write([]byte(file))
file2, err2 := ioutil.ReadFile("...\\fileInByte.txt")
if err2 != nil {
}
fmt.Print(file2)
</code></pre>
<p>And this is c++ code first instructions to load fileInByte.txt hex bytes for process injectio:</p>
<pre><code>std::ifstream input("...\\fileInByte.txt", std::ios::binary);
std::vector<unsigned char> buffer(std::istreambuf_iterator<char>(input), {});
unsigned char* my_payload;
my_payload = &buffer[0];
unsigned int my_payload_len = sizeof(my_payload);
...
...
...
// allocate memory buffer for remote process
rb = VirtualAllocEx(ph, NULL, my_payload_len, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE);
// write payload to memory buffer
if(!WriteProcessMemory(ph, rb, my_payload, my_payload_len, NULL))
</code></pre>
| [
{
"answer_id": 74333814,
"author": "Theraot",
"author_id": 402022,
"author_profile": "https://Stackoverflow.com/users/402022",
"pm_score": 1,
"selected": false,
"text": "TextureButton"
},
{
"answer_id": 74339766,
"author": "B0T_Alan",
"author_id": 20430011,
"author_profile": "https://Stackoverflow.com/users/20430011",
"pm_score": 0,
"selected": false,
"text": "self.texture"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333437",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16385455/"
] |
74,333,469 | <p>I'm learning Python. I have a CSV file with these rows. I am trying to search and return rows that have <code>year_ceremony</code> matched with the <code>year</code> parameter the function accepts.</p>
<pre><code>year_film,year_ceremony,ceremony,category,name,film,winner
1927,1928,1,ACTOR,Richard Barthelmess,The Noose,False
1927,1928,1,ACTOR,Emil Jannings,The Last Command,True
1927,1928,1,ACTRESS,Louise Dresser,A Ship Comes In,False
1928,1929,2,CINEMATOGRAPHY,Ernest Palmer,Four Devils;,False
1928,1929,2,CINEMATOGRAPHY,John Seitz,The Divine Lady,False
1928,1929,2,DIRECTING,Lionel Barrymore,Madame X,False
1928,1929,2,DIRECTING,Harry Beaumont,The Broadway Melody,False
</code></pre>
<pre><code>def get_academy_awards_nominees(year):
response = []
csv_file = csv.reader(open("csvs/the_oscar_award.csv", "r"), delimiter=",")
for row in csv_file:
if row[1] == year:
response.append(row)
return response
</code></pre>
<p>I'm looking for a way to format matching row with the header (year_film,year_ceremony,ceremony,category,name,film,winner) as key and value and return them as JSON.</p>
| [
{
"answer_id": 74333814,
"author": "Theraot",
"author_id": 402022,
"author_profile": "https://Stackoverflow.com/users/402022",
"pm_score": 1,
"selected": false,
"text": "TextureButton"
},
{
"answer_id": 74339766,
"author": "B0T_Alan",
"author_id": 20430011,
"author_profile": "https://Stackoverflow.com/users/20430011",
"pm_score": 0,
"selected": false,
"text": "self.texture"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333469",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20377435/"
] |
74,333,470 | <p>d = {'col1': ['Son', 2, 'Dad'], 'col2': [3, 4, 5]}
df = pd.DataFrame(data=d)</p>
<p>I want to drop change the second row to 'Unknown'</p>
<pre><code> col1 col2
0 Son 3
1 2 4
2 Dad 5
</code></pre>
<p>change to</p>
<pre><code> col1 col2
0 Son 3
1 Unknown 4
2 Dad 5
</code></pre>
| [
{
"answer_id": 74333814,
"author": "Theraot",
"author_id": 402022,
"author_profile": "https://Stackoverflow.com/users/402022",
"pm_score": 1,
"selected": false,
"text": "TextureButton"
},
{
"answer_id": 74339766,
"author": "B0T_Alan",
"author_id": 20430011,
"author_profile": "https://Stackoverflow.com/users/20430011",
"pm_score": 0,
"selected": false,
"text": "self.texture"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333470",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20430139/"
] |
74,333,482 | <p>The goal of my code is so that whenever I hover over an element it goes to the center of the page and the image is enlarged. However when I do this either either the images listed appears with a gap matching the resized element, or the unchanged elements take up the space that was freed causing issues when trying to hover over images more than once.</p>
<p>I'm incredibly new to html and css so bear with me if I missed something simple, was unable to find anything googling but may have just been not knowing the keywords to search for.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{
margin: 5px;
background-color: rgb(203, 220, 236);
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
.container{
display: block;
width: 110px;
}
.img-wrapper{
height: auto;
width: 100px;
text-align: center;
position: inherit;
transition: transform 0.5s ease-in-out;
float: left;
}
.img-wrapper:hover{
transition: transform 0.5s ease-in-out;
transform: rotate(1deg);
width: 1920px;
position: relative;
align-self: center;
top: 0;
bottom: 0;
left: 0;
right: 0;
padding: 10px;
font-style: italic;
}
.img-wrapper:hover img{
width: 600px;
}
img{
width: 100px;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Portfolio</title>
<link rel="stylesheet" href="stylesheet.css">
</head>
<body>
<header>
<h1>My Portfolio</h1>
</header>
<div class="container">
<div class="img-wrapper">
<img src="images\1.png" alt="drops logo 1">
<div class="content">Drops Logo 1</div>
</div>
<div class="img-wrapper">
<img src="images\2.png" alt="Abstract 1">
<div class="content">Abstract 1</div>
</div>
<div class="img-wrapper">
<img src="images\3.png" alt="drops logo 2">
<div class="content">Drops Logo 2</div>
</div>
<div class="img-wrapper">
<img src="images\4.png" alt="Abstract 2">
<div class="content">Abstract 2</div>
</div>
<div class="img-wrapper">
<img src="images\5.png" alt="Abstract 3">
<div class="content">Abstract 3</div>
</div>
</div>
</body>
</html></code></pre>
</div>
</div>
</p>
<p>I'm assuming it's something to do with the position tag but all the combinations I've tried have not worked.</p>
| [
{
"answer_id": 74333814,
"author": "Theraot",
"author_id": 402022,
"author_profile": "https://Stackoverflow.com/users/402022",
"pm_score": 1,
"selected": false,
"text": "TextureButton"
},
{
"answer_id": 74339766,
"author": "B0T_Alan",
"author_id": 20430011,
"author_profile": "https://Stackoverflow.com/users/20430011",
"pm_score": 0,
"selected": false,
"text": "self.texture"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20430122/"
] |
74,333,485 | <p>I have two lists, studentList ( is already made and I have no problem with ) and studentList2 ( a list of data read from a csv file.)</p>
<p>The part of the code that works is the part where studentList1 is able to display the class students and the 5 objects. however as for studentList 2, I'm able to read from the csv file but unable to add the 2 students into a list and display it together with studentList 1.</p>
<p>I tried to apply the same concept from the first list (which is manually made) to the second list (read from csv file). but I can see it obviously doesn't work and I'm not sure on how to fix it.</p>
<p>This is what I've got so far:</p>
<pre><code>using school;
using System.Reflection.PortableExecutable;
DateTime dob1 = new DateTime(2000, 10, 13);
Student s1 = new Student(1, "John Tan", "88552211", dob1);
DateTime dob2 = new DateTime(2001, 11, 01);
Student s2 = new Student(2, "Peter Lim", "85678141", dob2);
DateTime dob3 = new DateTime(2000, 01, 03);
Student s3 = new Student(3, "David Chan", "88555461", dob3);
DateTime dob4 = new DateTime(2000, 05, 07);
Student s4 = new Student(4, "Muhammed Faizal", "98762211", dob4);
DateTime dob5 = new DateTime(2000, 08, 09);
Student s5 = new Student(5, "Esther Eng", "83352245", dob5);
List<Student> studentList = new List<Student>();
studentList.Add(s1);
studentList.Add(s2);
studentList.Add(s3);
studentList.Add(s4);
studentList.Add(s5);
//call the method to display the student list
DisplayOutput(studentList);
studentList.Add(GetStudent());
DisplayOutput(studentList);
DisplayOutput(studentList2);
//method that displays all the students
static void DisplayOutput(List<Student> sList)
{
Console.WriteLine("");
//header id name tel dob
Console.WriteLine("{0,-5} {1,-17} {2,-10} {3,-20}",
"ID", "Name", "Tel", "Date of Birth");
//for loop to print the rest of the info
foreach (Student s in sList)
{
Console.WriteLine("{0,-5} {1,-17} {2,-10} {3,-20}",
s.ID, s.Name, s.Tel, s.DateOfBirth.ToString("dd/MM/yyyy"));
}
}
static Student GetStudent()
{
// prompt user for info
Console.Write("Enter id: ");
int id = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter name: ");
string? name = Console.ReadLine();
Console.Write("Enter tel: ");
string? tel = Console.ReadLine();
Console.Write("Enter Date of Birth: ");
DateTime dateOfBirth = Convert.ToDateTime(Console.ReadLine());
Console.WriteLine("");
return new Student(id, name, tel, dateOfBirth);
}
//list from the csv
List<Student> studentList2 = new List<Student>();
studentList2.Add(s6);
studentList2.Add(s7);
string[] csvLines = File.ReadAllLines("Students.csv");
string[] heading = csvLines[0].Split(',');
// Read and display lines from the file until the end of
// the file is reached.
for (int i = 1; i < csvLines.Length; i++)
{
string[] data = csvLines[i].Split(',');
//Console.WriteLine("{0,-5} {1,-17} {2,-10} {3,-20}",
// data[0], data[1], data[2], data[3]);
Student s6 = new Student(data[0], data[1], data[2], data[3]);
Student s7 = new Student(data[0], data[1], data[2], data[3]);
}
</code></pre>
<p>and this is my class</p>
<pre><code>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace school
{
class Student
{
private int id;
public int ID
{
get { return id; }
set { id = value; }
}
private string? name;
public string? Name
{
get { return name; }
set { name = value; }
}
private string? tel;
public string? Tel
{
get { return tel; }
set { tel = value; }
}
private DateTime dateOfBirth;
public DateTime DateOfBirth
{
get { return dateOfBirth; }
set { dateOfBirth = value; }
}
// constructor
public Student(int d, string? n, string? t, DateTime dob)
{
ID = d;
Name = n;
Tel = t;
DateOfBirth = dob;
}
// methods
public string StudentFullName()
{
return ID + " " + Name + " " + Tel + " " + DateOfBirth;
}
}
}
</code></pre>
<p>here is the csv file contents:</p>
<pre><code>ID,Name,Phone,Date of Birth
10,Alan Tan,98552211,13/5/2001
20,Bobby Lim,95678141,8/11/2001
</code></pre>
| [
{
"answer_id": 74333621,
"author": "vivek nuna",
"author_id": 6527049,
"author_profile": "https://Stackoverflow.com/users/6527049",
"pm_score": 1,
"selected": false,
"text": "//studentList2.Add(s6); //comment these lines\n//studentList2.Add(s7);\n\n\nstring[] csvLines = File.ReadAllLines(\"Students.csv\");\nstring[] heading = csvLines[0].Split(',');\n\n// Read and display lines from the file until the end of\n// the file is reached.\nfor (int i = 1; i < csvLines.Length; i++)\n{\n string[] data = csvLines[i].Split(',');\n //Console.WriteLine(\"{0,-5} {1,-17} {2,-10} {3,-20}\",\n // data[0], data[1], data[2], data[3]);\n //Student s6 = new Student(data[0], data[1], data[2], data[3]); //also comment these lines\n //Student s7 = new Student(data[0], data[1], data[2], data[3]);\n studentList2.Add(new Student(data[0], data[1], data[2], data[3]));\n}\n"
},
{
"answer_id": 74334034,
"author": "Auro",
"author_id": 7578948,
"author_profile": "https://Stackoverflow.com/users/7578948",
"pm_score": 0,
"selected": false,
"text": "List<Student> studentList2 = new List<Student>();\n string[] csvLines = File.ReadAllLines(\"Students.csv\");\n string[] heading = csvLines[0].Split(',');\n // Read and display lines from the file until the end of\n // the file is reached.\n for (int i = 1; i < csvLines.Length; i++)\n {\n string[] data = csvLines[i].Split(',');\n //Console.WriteLine(\"{0,-5} {1,-17} {2,-10} {3,-20}\",\n // data[0], data[1], data[2], data[3]);\n Student s6 = new Student(Convert.ToInt32(data[0]), data[1], data[2], Convert.ToDateTime(data[3]));\n Student s7 = new Student(Convert.ToInt32(data[0]), data[1], data[2], Convert.ToDateTime(data[3]));\n studentList2.Add(s6);\n studentList2.Add(s7);\n }\n DisplayOutput(studentList2);\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333485",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19566199/"
] |
74,333,499 | <p><code>git switch <branch></code> allows me to move to an existing branch.</p>
<p><code>git switch -c <branch></code> allows me to create a new branch.</p>
<p>Is there a command where dependent on whether the branch already exists, it'll either create a new branch or check out the existing one?</p>
| [
{
"answer_id": 74333896,
"author": "root",
"author_id": 10678955,
"author_profile": "https://Stackoverflow.com/users/10678955",
"pm_score": 1,
"selected": false,
"text": "git csw"
},
{
"answer_id": 74334152,
"author": "knittl",
"author_id": 112968,
"author_profile": "https://Stackoverflow.com/users/112968",
"pm_score": 2,
"selected": false,
"text": "if git show-ref --quiet \"refs/heads/$branchname\"; then\n git switch \"$branchname\";\nelse\n git switch -c \"$branchname\";\nfi\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333499",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/279911/"
] |
74,333,500 | <pre><code>function nvpdf_WrapString($my_pdf,$string,$width,$width_in_chars = "") {
// known problem: can only be called after the pdf document has been
// started, font size set, etc as it relies on the pdf being in the
// page scope to use pdf_stringwidth (see PDFLib manual p.83).
// returns an array: 1st level column
// 2nd level data string broken up into lines that fit the column
$string = str_replace('\n', "\n", $string);
$inlines = explode("\n",$string);
$outlines = array();
$font_size = PDF_get_option($my_pdf, "fontsize", "");
$font_name = pdf_get_parameter($my_pdf, "fontname", 0);
$font_id = PDF_load_font($my_pdf, $font_name, "host","");
</code></pre>
<p>I got a deprecation warning from php saying that I should use pdf_get_option() instead of pdf_get_parameter(). But how can I convert this pdf_get_parameter() to pdf_get_option()?</p>
<p>I need a method that will return me the font name of $mypdf.</p>
| [
{
"answer_id": 74343290,
"author": "Rainer",
"author_id": 2862406,
"author_profile": "https://Stackoverflow.com/users/2862406",
"pm_score": 1,
"selected": false,
"text": "deprecated parameter:\nascender, ascenderfaked, capheight, capheightfaked, descende, \ndescenderfaked, fontencoding, fontname,fontmaxcode, xheight, xheightfaked\n\ndeprecated since: \nPDFlib 7 \n\nreplacement method and option:\nPDF_info_font( ) with same-named keywords; for the numerical \nvalues fontsize=1 must be supplied;\nparameter fontencoding: use keyword encoding\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17308386/"
] |
74,333,504 | <p>I'm planning on trying to see if it's possible to make a website in Godot(Yes, I know I shouldn't I just want to try just to try). I thinking about and looking over the features I need and I have one problem.</p>
<p>I just need a way for a person to press a button and get redirected to my itch games. I don't care if it creates a new tab or changes the current tab. Thank you for any help.</p>
| [
{
"answer_id": 74333823,
"author": "Bugfish",
"author_id": 4423341,
"author_profile": "https://Stackoverflow.com/users/4423341",
"pm_score": 2,
"selected": false,
"text": "OS.shell_open(\"url\")"
},
{
"answer_id": 74333825,
"author": "Theraot",
"author_id": 402022,
"author_profile": "https://Stackoverflow.com/users/402022",
"pm_score": 0,
"selected": false,
"text": "OS.shell_open"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20144756/"
] |
74,333,505 | <p>Say the user enters <code>"-4x^0 + x^1 + 4x^3 - 4x^5 - 3x^7"</code> as an input. I want to extract values from the string and pass them into <code>coef[]</code> and <code>expo[]</code> so it looks like this:</p>
<pre><code>coef = [-4, 1, 0, 4, 0, -4, 0, -3]
expo = [ 0, 1, 2, 3, 4, 5, 6, 7]
</code></pre>
<p>Here's what I have so far but I don't know how to use tokens.</p>
<pre class="lang-c prettyprint-override"><code>int main()
{
char userInput[100];
char temp[100];
printf("Enter the polynomial: ");
scanf("%[^\n]%*c", userInput);
strcpy(temp, userInput);
printf("\n");
int coef[100];
int expo[100];
for (int i = 0; i < 100; i++) {
coef[i] = 0;
expo[i] = 0;
}
char *tok = strtok(temp, "x^");
int counter = 0;
while (tok) {
printf("*%s*\n", tok);
tok = strtok(NULL, "x^");
counter++;
}
return 0;
}
</code></pre>
<p>I have tried the following but it didn't work:</p>
<pre class="lang-c prettyprint-override"><code> int counter = 0;
while (tok) {
printf("*%s*\n", tok);
expo[counter] = atoi(tok);
tok = strtok(NULL, "x^");
counter++;
}
</code></pre>
| [
{
"answer_id": 74333891,
"author": "David C. Rankin",
"author_id": 3422102,
"author_profile": "https://Stackoverflow.com/users/3422102",
"pm_score": 2,
"selected": false,
"text": "1"
},
{
"answer_id": 74335625,
"author": "chqrlie",
"author_id": 4593267,
"author_profile": "https://Stackoverflow.com/users/4593267",
"pm_score": 2,
"selected": false,
"text": "strtok()"
},
{
"answer_id": 74339689,
"author": "Chris Dodd",
"author_id": 16406,
"author_profile": "https://Stackoverflow.com/users/16406",
"pm_score": 0,
"selected": false,
"text": "\nint main() {\n char userInput[100] = { 0 };\n printf(\"Enter the polynomial: \");\n fgets(userInput, sizeof(userInput), stdin);\n printf(\"\\n\");\n \n int coef[100] = { 0 };\n int expo[100] = { 0 };\n int i = 0;\n char *p = userInput;\n while (p && *p && i < 100) {\n int len;\n if (i == 0 && sscanf(p, \"%d x ^%d %n\", &coef[i], &expo[i], &len) == 2)) {\n } else if (sscanf(p, \" +%d x ^%d %n\", &coef[i], &expo[i], &len) == 2)) {\n } else if (sscanf(p, \" -%d x ^%d %n\", &coef[i], &expo[i], &len) == 2)) {\n coef[i] = -coef[i];\n } else if (i == 0 && sscanf(p, \" x ^%d %n\", &expo[i], &len) == 1) {\n coef[i] = 1;\n } else if (sscanf(p, \" + x ^%d %n\", &expo[i], &len) == 1) {\n coef[i] = 1;\n } else if (sscanf(p, \" - x ^%d %n\", &expo[i], &len) == 1) {\n coef[i] = -1;\n } else if (sscanf(p, \" +%d x %n\", &coeff[i], &len) == 1) {\n expo[i] = 1;\n } else if (sccanf(p, \" -%d x %n\", &coeff[i], &len) == 1) {\n coef[i] = -coef[i];\n expo[i] = 1;\n } else if (i == 0 && sccanf(p, \"%d x %n\", &coeff[i], &len) == 1) {\n expo[i] = 1;\n } else if (sscanf(p, \" +%d %n\", &coeff[i], &len) == 1) {\n expo[i] = 0;\n } else if (sccanf(p, \" -%d %n\", &coeff[i], &len) == 1) {\n coef[i] = -coef[i];\n expo[i] = 0;\n } else if (i == 0 && sccanf(p, \"%d %n\", &coeff[i], &len) == 1) {\n expo[i] = 0;\n } else {\n fprintf(stderr, \"this doesn't look like a polynomial: %s\\n\", p);\n break;\n }\n p += len;\n ++i;\n }\n\n printf(\"got polynomial: \");\n for (int j = 0; j < i; ++j)\n printf(\"%+dx^%d\", coef[j], expo[j]);\n printf(\"\\n\");\n}\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333505",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20430160/"
] |
74,333,507 | <p>Once I have changed the security rules it keeps giving me this error on whatever the rules are:<a href="https://i.stack.imgur.com/2HzSU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2HzSU.png" alt="enter image description here" /></a></p>
<p>My security rules now:
<a href="https://i.stack.imgur.com/KLbTR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KLbTR.png" alt="My security rules now:" /></a></p>
| [
{
"answer_id": 74333891,
"author": "David C. Rankin",
"author_id": 3422102,
"author_profile": "https://Stackoverflow.com/users/3422102",
"pm_score": 2,
"selected": false,
"text": "1"
},
{
"answer_id": 74335625,
"author": "chqrlie",
"author_id": 4593267,
"author_profile": "https://Stackoverflow.com/users/4593267",
"pm_score": 2,
"selected": false,
"text": "strtok()"
},
{
"answer_id": 74339689,
"author": "Chris Dodd",
"author_id": 16406,
"author_profile": "https://Stackoverflow.com/users/16406",
"pm_score": 0,
"selected": false,
"text": "\nint main() {\n char userInput[100] = { 0 };\n printf(\"Enter the polynomial: \");\n fgets(userInput, sizeof(userInput), stdin);\n printf(\"\\n\");\n \n int coef[100] = { 0 };\n int expo[100] = { 0 };\n int i = 0;\n char *p = userInput;\n while (p && *p && i < 100) {\n int len;\n if (i == 0 && sscanf(p, \"%d x ^%d %n\", &coef[i], &expo[i], &len) == 2)) {\n } else if (sscanf(p, \" +%d x ^%d %n\", &coef[i], &expo[i], &len) == 2)) {\n } else if (sscanf(p, \" -%d x ^%d %n\", &coef[i], &expo[i], &len) == 2)) {\n coef[i] = -coef[i];\n } else if (i == 0 && sscanf(p, \" x ^%d %n\", &expo[i], &len) == 1) {\n coef[i] = 1;\n } else if (sscanf(p, \" + x ^%d %n\", &expo[i], &len) == 1) {\n coef[i] = 1;\n } else if (sscanf(p, \" - x ^%d %n\", &expo[i], &len) == 1) {\n coef[i] = -1;\n } else if (sscanf(p, \" +%d x %n\", &coeff[i], &len) == 1) {\n expo[i] = 1;\n } else if (sccanf(p, \" -%d x %n\", &coeff[i], &len) == 1) {\n coef[i] = -coef[i];\n expo[i] = 1;\n } else if (i == 0 && sccanf(p, \"%d x %n\", &coeff[i], &len) == 1) {\n expo[i] = 1;\n } else if (sscanf(p, \" +%d %n\", &coeff[i], &len) == 1) {\n expo[i] = 0;\n } else if (sccanf(p, \" -%d %n\", &coeff[i], &len) == 1) {\n coef[i] = -coef[i];\n expo[i] = 0;\n } else if (i == 0 && sccanf(p, \"%d %n\", &coeff[i], &len) == 1) {\n expo[i] = 0;\n } else {\n fprintf(stderr, \"this doesn't look like a polynomial: %s\\n\", p);\n break;\n }\n p += len;\n ++i;\n }\n\n printf(\"got polynomial: \");\n for (int j = 0; j < i; ++j)\n printf(\"%+dx^%d\", coef[j], expo[j]);\n printf(\"\\n\");\n}\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333507",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16116968/"
] |
74,333,510 | <pre><code>class Fruit {
var name: String
var colour: String
init(name: String, colour: String) {
self.name = name
self.colour = colour
}
**var info: () -> String {
{
return "\(self.name) is \(self.colour) in colour"
}
}
}**
let fruit = Fruit(name: "apple", colour: "red")
print(fruit.info())
</code></pre>
<p>Hi,</p>
<p>Can someone explain the type of property of the variable name "info" in the above block of code.</p>
<p>If it is a computed property, can a computed property be written in swift without a get block?</p>
| [
{
"answer_id": 74333891,
"author": "David C. Rankin",
"author_id": 3422102,
"author_profile": "https://Stackoverflow.com/users/3422102",
"pm_score": 2,
"selected": false,
"text": "1"
},
{
"answer_id": 74335625,
"author": "chqrlie",
"author_id": 4593267,
"author_profile": "https://Stackoverflow.com/users/4593267",
"pm_score": 2,
"selected": false,
"text": "strtok()"
},
{
"answer_id": 74339689,
"author": "Chris Dodd",
"author_id": 16406,
"author_profile": "https://Stackoverflow.com/users/16406",
"pm_score": 0,
"selected": false,
"text": "\nint main() {\n char userInput[100] = { 0 };\n printf(\"Enter the polynomial: \");\n fgets(userInput, sizeof(userInput), stdin);\n printf(\"\\n\");\n \n int coef[100] = { 0 };\n int expo[100] = { 0 };\n int i = 0;\n char *p = userInput;\n while (p && *p && i < 100) {\n int len;\n if (i == 0 && sscanf(p, \"%d x ^%d %n\", &coef[i], &expo[i], &len) == 2)) {\n } else if (sscanf(p, \" +%d x ^%d %n\", &coef[i], &expo[i], &len) == 2)) {\n } else if (sscanf(p, \" -%d x ^%d %n\", &coef[i], &expo[i], &len) == 2)) {\n coef[i] = -coef[i];\n } else if (i == 0 && sscanf(p, \" x ^%d %n\", &expo[i], &len) == 1) {\n coef[i] = 1;\n } else if (sscanf(p, \" + x ^%d %n\", &expo[i], &len) == 1) {\n coef[i] = 1;\n } else if (sscanf(p, \" - x ^%d %n\", &expo[i], &len) == 1) {\n coef[i] = -1;\n } else if (sscanf(p, \" +%d x %n\", &coeff[i], &len) == 1) {\n expo[i] = 1;\n } else if (sccanf(p, \" -%d x %n\", &coeff[i], &len) == 1) {\n coef[i] = -coef[i];\n expo[i] = 1;\n } else if (i == 0 && sccanf(p, \"%d x %n\", &coeff[i], &len) == 1) {\n expo[i] = 1;\n } else if (sscanf(p, \" +%d %n\", &coeff[i], &len) == 1) {\n expo[i] = 0;\n } else if (sccanf(p, \" -%d %n\", &coeff[i], &len) == 1) {\n coef[i] = -coef[i];\n expo[i] = 0;\n } else if (i == 0 && sccanf(p, \"%d %n\", &coeff[i], &len) == 1) {\n expo[i] = 0;\n } else {\n fprintf(stderr, \"this doesn't look like a polynomial: %s\\n\", p);\n break;\n }\n p += len;\n ++i;\n }\n\n printf(\"got polynomial: \");\n for (int j = 0; j < i; ++j)\n printf(\"%+dx^%d\", coef[j], expo[j]);\n printf(\"\\n\");\n}\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333510",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20430169/"
] |
74,333,524 | <p>I'm using the datetime-local but my teacher say there is a better way for the date that can be selected is using JavaScript.I searched in google but only have writing out today date.Does it have in js?</p>
| [
{
"answer_id": 74333891,
"author": "David C. Rankin",
"author_id": 3422102,
"author_profile": "https://Stackoverflow.com/users/3422102",
"pm_score": 2,
"selected": false,
"text": "1"
},
{
"answer_id": 74335625,
"author": "chqrlie",
"author_id": 4593267,
"author_profile": "https://Stackoverflow.com/users/4593267",
"pm_score": 2,
"selected": false,
"text": "strtok()"
},
{
"answer_id": 74339689,
"author": "Chris Dodd",
"author_id": 16406,
"author_profile": "https://Stackoverflow.com/users/16406",
"pm_score": 0,
"selected": false,
"text": "\nint main() {\n char userInput[100] = { 0 };\n printf(\"Enter the polynomial: \");\n fgets(userInput, sizeof(userInput), stdin);\n printf(\"\\n\");\n \n int coef[100] = { 0 };\n int expo[100] = { 0 };\n int i = 0;\n char *p = userInput;\n while (p && *p && i < 100) {\n int len;\n if (i == 0 && sscanf(p, \"%d x ^%d %n\", &coef[i], &expo[i], &len) == 2)) {\n } else if (sscanf(p, \" +%d x ^%d %n\", &coef[i], &expo[i], &len) == 2)) {\n } else if (sscanf(p, \" -%d x ^%d %n\", &coef[i], &expo[i], &len) == 2)) {\n coef[i] = -coef[i];\n } else if (i == 0 && sscanf(p, \" x ^%d %n\", &expo[i], &len) == 1) {\n coef[i] = 1;\n } else if (sscanf(p, \" + x ^%d %n\", &expo[i], &len) == 1) {\n coef[i] = 1;\n } else if (sscanf(p, \" - x ^%d %n\", &expo[i], &len) == 1) {\n coef[i] = -1;\n } else if (sscanf(p, \" +%d x %n\", &coeff[i], &len) == 1) {\n expo[i] = 1;\n } else if (sccanf(p, \" -%d x %n\", &coeff[i], &len) == 1) {\n coef[i] = -coef[i];\n expo[i] = 1;\n } else if (i == 0 && sccanf(p, \"%d x %n\", &coeff[i], &len) == 1) {\n expo[i] = 1;\n } else if (sscanf(p, \" +%d %n\", &coeff[i], &len) == 1) {\n expo[i] = 0;\n } else if (sccanf(p, \" -%d %n\", &coeff[i], &len) == 1) {\n coef[i] = -coef[i];\n expo[i] = 0;\n } else if (i == 0 && sccanf(p, \"%d %n\", &coeff[i], &len) == 1) {\n expo[i] = 0;\n } else {\n fprintf(stderr, \"this doesn't look like a polynomial: %s\\n\", p);\n break;\n }\n p += len;\n ++i;\n }\n\n printf(\"got polynomial: \");\n for (int j = 0; j < i; ++j)\n printf(\"%+dx^%d\", coef[j], expo[j]);\n printf(\"\\n\");\n}\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20430191/"
] |
74,333,545 | <p>In devices below android 10 we can access any file like this::
File f = new File("storage/emulated/0/filename.txt");</p>
<p>But I want to do to same on android 10+ devices which are using something like scoped storage or mediastore class that I didn't understood in android studio I don't know exactly how to do it I want to access files any directories not only public directories like "Pictures" please help me</p>
<p>File f = new File("storage/emulated/0/file.jpg");</p>
| [
{
"answer_id": 74333891,
"author": "David C. Rankin",
"author_id": 3422102,
"author_profile": "https://Stackoverflow.com/users/3422102",
"pm_score": 2,
"selected": false,
"text": "1"
},
{
"answer_id": 74335625,
"author": "chqrlie",
"author_id": 4593267,
"author_profile": "https://Stackoverflow.com/users/4593267",
"pm_score": 2,
"selected": false,
"text": "strtok()"
},
{
"answer_id": 74339689,
"author": "Chris Dodd",
"author_id": 16406,
"author_profile": "https://Stackoverflow.com/users/16406",
"pm_score": 0,
"selected": false,
"text": "\nint main() {\n char userInput[100] = { 0 };\n printf(\"Enter the polynomial: \");\n fgets(userInput, sizeof(userInput), stdin);\n printf(\"\\n\");\n \n int coef[100] = { 0 };\n int expo[100] = { 0 };\n int i = 0;\n char *p = userInput;\n while (p && *p && i < 100) {\n int len;\n if (i == 0 && sscanf(p, \"%d x ^%d %n\", &coef[i], &expo[i], &len) == 2)) {\n } else if (sscanf(p, \" +%d x ^%d %n\", &coef[i], &expo[i], &len) == 2)) {\n } else if (sscanf(p, \" -%d x ^%d %n\", &coef[i], &expo[i], &len) == 2)) {\n coef[i] = -coef[i];\n } else if (i == 0 && sscanf(p, \" x ^%d %n\", &expo[i], &len) == 1) {\n coef[i] = 1;\n } else if (sscanf(p, \" + x ^%d %n\", &expo[i], &len) == 1) {\n coef[i] = 1;\n } else if (sscanf(p, \" - x ^%d %n\", &expo[i], &len) == 1) {\n coef[i] = -1;\n } else if (sscanf(p, \" +%d x %n\", &coeff[i], &len) == 1) {\n expo[i] = 1;\n } else if (sccanf(p, \" -%d x %n\", &coeff[i], &len) == 1) {\n coef[i] = -coef[i];\n expo[i] = 1;\n } else if (i == 0 && sccanf(p, \"%d x %n\", &coeff[i], &len) == 1) {\n expo[i] = 1;\n } else if (sscanf(p, \" +%d %n\", &coeff[i], &len) == 1) {\n expo[i] = 0;\n } else if (sccanf(p, \" -%d %n\", &coeff[i], &len) == 1) {\n coef[i] = -coef[i];\n expo[i] = 0;\n } else if (i == 0 && sccanf(p, \"%d %n\", &coeff[i], &len) == 1) {\n expo[i] = 0;\n } else {\n fprintf(stderr, \"this doesn't look like a polynomial: %s\\n\", p);\n break;\n }\n p += len;\n ++i;\n }\n\n printf(\"got polynomial: \");\n for (int j = 0; j < i; ++j)\n printf(\"%+dx^%d\", coef[j], expo[j]);\n printf(\"\\n\");\n}\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333545",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16811588/"
] |
74,333,561 | <p>I am using Redux Toolkit, Redux-Persist and RTK query in my project.</p>
<p>I have configured the store with Redux Toolkit and Redux Persist. Managed to persist data using Redux Persist. Currently I am able to get the persisted data into my component layer using useSelector hook.</p>
<p>I have other API definitions which is done by RTK query. I have a files with all the API definitions done by RTK query's createApi, baseQuery etc. functions.</p>
<p>My "PROBLEM" here is:</p>
<ul>
<li>I can't get access the persisted data before the store initialization in component layer I can access the data as that useSelector hook is making the render waiting until persisted data added to the store by persistGate</li>
<li>But in the same file I am calling those query functions hooks which are defined in the another file where I needed the persisted data to be rehydrated.</li>
</ul>
<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>// Main App.js
const App = () => {
return (
<Provider store={store}>
<PersistGate persistor={persistor}>
<Route path="/orderlist" element={<OrdersList />} />
</PersistGate>
</Provider>
)
}
// Store Configuration
const persistConfig = {
key: 'root',
storage: storage,
blacklist: [],
whitelist: ['auth']
}
const reducers = {
[authSlice.name] : authSlice.reducer,
}
const rootReducer = combineReducers(reducers)
const persistedReducer = persistReducer(persistConfig, rootReducer)
export const token = (state) => state.persistedReducer
export const store =
configureStore({
reducer: {
persistedReducer,
[api.reducerPath]: api.reducer,
order: orderSlice.reducer,
[userApi.reducerPath]: userApi.reducer
// [orderSlice.name] : orderSlice.reducer,
// [api.reducerPath]: api.reducer,
// order: orderSlice.reducer,
},
middleware: (getDefaultMiddleware) =>
getDefaultMiddleware({
serializableCheck: {
ignoredActions: [FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER],
}
}).concat([
api.middleware,
userApi.middleware
]),
})
// Api Definitions - where I needed the persisted data
import { createApi, fetchBaseQuery, retry } from '@reduxjs/toolkit/query/react'
import { rootState } from '../store'
// Root state is not working here, this file execute the code before store intiatization
// I need the rehydrated state here
// Please check my store configuration
// const storeSubscription = store.getState()
// console.log(rootState)
// Create Our baseQuery Instance
const baseQuery = fetchBaseQuery({
baseUrl: 'http://34.229.141.62/api/v1/',
})
// console.log(baseQuery)
const baseQueryWithRetry = retry(baseQuery, { maxRetries: 1 })
export const userApi = createApi({
reducerPath: 'USER_API_REDUCER_KEY',
baseQuery: baseQueryWithRetry,
// prepareHeaders: (headers, { getState }) => {
// const token = getState().order.isToken
// console.log(token)
// // If we have a token set in state, let's assume that we should be passing it.
// if (token) {
// headers.set(`Bearer ${token}`)
// }
// return headers
// },
tagTypes: ['Orders'],
endpoints: builder => ({}),
serializeQueryArgs: ({ endpointName, queryArgs }) => endpointName
})
// Endpoint injections in create API
import { createSelector, createEntityAdapter } from "@reduxjs/toolkit";
import { userApi } from "./userApi";
const ordersAdapter = createEntityAdapter({
// selectId: (order) => order.id,
sortComparer: (a,b) => b._id.localeCompare(a._id)
})
const initialState = ordersAdapter.getInitialState()
export const extendedApiSlice = userApi.injectEndpoints({
endpoints: builder => ({
getOrders: builder.query({
query: () => ({
url: 'orders/userOrders',
}),
transformResponse: (responseData, meta, arg) => {
let i = 1
const loadedOrders = responseData.orders.map(order => {
if(!order?.id) order.id = i++
// console.log(order)
return order
})
return ordersAdapter.setAll(initialState, loadedOrders)
},
providesTags: (result, error, arg) => [
// { type: 'Orders', id: 'LIST' },
'Orders'
]
}),
deleteOrders: builder.mutation({
// query: ({id}) => ({
query: (body) => ({
// url: `orders/cancel/${id}`,
url: `orders/cancel/`,
method: 'POST',
body: body,
refetchOnMountOrArgChange: true,
invalidatesTags: (result, error, arg) => [
'Orders'
]
})
})
}),
})
// console.log(ordersAdapter)
export const {
useGetOrdersQuery,
useDeleteOrdersMutation
} = extendedApiSlice
// console.log(extendedApiSlice)
export const selectOrdersResult = extendedApiSlice.endpoints.getOrders.select()
export const deleteOrdersResult = extendedApiSlice.endpoints.deleteOrders.initiate()
export const selectdeleteOrderResult = extendedApiSlice.endpoints.deleteOrders.select()
// export const useDeleteOrdersMutation = extendedApiSlice.endpoints.deleteOrders.useMutation()
// console.log(deleteOrdersResult)
// console.log(selectdeleteOrderResult)
export const selectOrdersData = createSelector(
selectOrdersResult,
ordersResult => ordersResult.data
)
// console.log(selectOrdersData)
export const {
selectAll: selectAllOrders,
selectById: selectOrderById,
selectIds: selectOrderIds
} = ordersAdapter.getSelectors(state => selectOrdersData(state) ?? initialState)
// Component where I am calling those query hooks from create API
import { token } from "../../Servicepage/store";
import { useDispatch, useSelector } from "react-redux";
import { useGetOrdersQuery, useDeleteOrdersMutation, selectAllOrders, selectOrderById, selectOrderIds } from "../../Servicepage/services/userSlice";
import Button from "./Button";
import { addToken, resOrder, selectCount } from "../../Servicepage/services/orderSlice"
import { useEffect } from "react";
const OrdersList = () => {
const dispatch = useDispatch()
const authState = useSelector(token)
const Token = authState.auth.accessToken
// console.log(Token)
// dispatch(addToken({ isToken: false }))
useEffect(() => {
dispatch(addToken({ isToken: Token}))
}, [])
const completeOrderState = useSelector(selectCount)
// console.log(completeOrderState)
const {
isLoading,
isSuccess,
refetch,
isError,
error
} = useGetOrdersQuery()
const orderIds = useSelector(selectOrderIds)
const orderIdz = useSelector((state) => selectOrderById(state, 1))
const orderAll = useSelector(selectAllOrders)
const [deletePost] = useDeleteOrdersMutation()
let content;
if (isLoading) {
content = <p>"Loading..."</p>
} else if (isSuccess) {
// console.log(orderIds)
// console.log(orderIdz)
console.log(orderAll)
// deletePost({ id: 'JBCS000001' })
content = orderAll.map((orders, indx) => {
return (
<div key={indx}>
<p><strong>Order List</strong></p>
<p>{orders.id}</p>
<p>Total Amount: {orders.totalAmount}</p>
<p>Email: {orders.email} </p>
<p>OrderId: {orders.orderId} </p>
<p>Status: {orders.status}</p>
<Button orderID={orders.orderId} />
</div>
)
})
}
return (
<div>
{content}
</div>
)
} </code></pre>
</div>
</div>
</p>
<p>So far I haven't been found any way to get the persisted data into my API definitions because my API definitions hooks are always calling before persisted data being imported into my store which is delayed in component by persistGate from App.</p>
<p>N:B: Please feel free to ask any question.</p>
| [
{
"answer_id": 74333891,
"author": "David C. Rankin",
"author_id": 3422102,
"author_profile": "https://Stackoverflow.com/users/3422102",
"pm_score": 2,
"selected": false,
"text": "1"
},
{
"answer_id": 74335625,
"author": "chqrlie",
"author_id": 4593267,
"author_profile": "https://Stackoverflow.com/users/4593267",
"pm_score": 2,
"selected": false,
"text": "strtok()"
},
{
"answer_id": 74339689,
"author": "Chris Dodd",
"author_id": 16406,
"author_profile": "https://Stackoverflow.com/users/16406",
"pm_score": 0,
"selected": false,
"text": "\nint main() {\n char userInput[100] = { 0 };\n printf(\"Enter the polynomial: \");\n fgets(userInput, sizeof(userInput), stdin);\n printf(\"\\n\");\n \n int coef[100] = { 0 };\n int expo[100] = { 0 };\n int i = 0;\n char *p = userInput;\n while (p && *p && i < 100) {\n int len;\n if (i == 0 && sscanf(p, \"%d x ^%d %n\", &coef[i], &expo[i], &len) == 2)) {\n } else if (sscanf(p, \" +%d x ^%d %n\", &coef[i], &expo[i], &len) == 2)) {\n } else if (sscanf(p, \" -%d x ^%d %n\", &coef[i], &expo[i], &len) == 2)) {\n coef[i] = -coef[i];\n } else if (i == 0 && sscanf(p, \" x ^%d %n\", &expo[i], &len) == 1) {\n coef[i] = 1;\n } else if (sscanf(p, \" + x ^%d %n\", &expo[i], &len) == 1) {\n coef[i] = 1;\n } else if (sscanf(p, \" - x ^%d %n\", &expo[i], &len) == 1) {\n coef[i] = -1;\n } else if (sscanf(p, \" +%d x %n\", &coeff[i], &len) == 1) {\n expo[i] = 1;\n } else if (sccanf(p, \" -%d x %n\", &coeff[i], &len) == 1) {\n coef[i] = -coef[i];\n expo[i] = 1;\n } else if (i == 0 && sccanf(p, \"%d x %n\", &coeff[i], &len) == 1) {\n expo[i] = 1;\n } else if (sscanf(p, \" +%d %n\", &coeff[i], &len) == 1) {\n expo[i] = 0;\n } else if (sccanf(p, \" -%d %n\", &coeff[i], &len) == 1) {\n coef[i] = -coef[i];\n expo[i] = 0;\n } else if (i == 0 && sccanf(p, \"%d %n\", &coeff[i], &len) == 1) {\n expo[i] = 0;\n } else {\n fprintf(stderr, \"this doesn't look like a polynomial: %s\\n\", p);\n break;\n }\n p += len;\n ++i;\n }\n\n printf(\"got polynomial: \");\n for (int j = 0; j < i; ++j)\n printf(\"%+dx^%d\", coef[j], expo[j]);\n printf(\"\\n\");\n}\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333561",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5700946/"
] |
74,333,563 | <p>I've made store page with Flutter, and Product card must have two click events.</p>
<ol>
<li>just click card</li>
<li>click <code>add to cart</code> button</li>
</ol>
<p>However, I used <a href="https://stackoverflow.com/a/59317162/17030983">Stacked InkWell</a> because Product card has image, and I wanted to apply ripple effect on it. And with Stacked InkWell, I can't trigger click event of inside button.</p>
<pre class="lang-dart prettyprint-override"><code>Stack(
children: [
Container(
color: Colors.grey,
child: Column(
children: [
ElevatedButton(
onPressed: () => print('not working TT'), // <- how can I trigger this?
child: const Text('click me!'),
),
],
),
),
Positioned.fill(
child: Material(
color: Colors.transparent,
child: InkWell(
onTap: () => print('nicely working'),
),
),
),
],
)
</code></pre>
<p><a href="https://dartpad.dev/ca48be3e4b867c800be6e364d1de95e8" rel="nofollow noreferrer">https://dartpad.dev/ca48be3e4b867c800be6e364d1de95e8</a></p>
<p>I just want to make this working with ripple effect on the image.</p>
| [
{
"answer_id": 74333613,
"author": "Ninad Sawant",
"author_id": 15294308,
"author_profile": "https://Stackoverflow.com/users/15294308",
"pm_score": 0,
"selected": false,
"text": "Stack(\n children: [\n Container(\n color: Colors.grey,\n child: Column(\n children: [\n //image\n SizedBox(\n width:100, \n height:60\n ),\n ],\n ),\n ),\n Positioned.fill(\n child: Material(\n color: Colors.transparent,\n child: InkWell(\n onTap: () => print('nicely working'),\n ),\n ),\n ),\n ElevatedButton(\n onPressed: () => print('not working TT'),\n child: const Text('click me!'),\n ),\n ],\n ),\n"
},
{
"answer_id": 74333735,
"author": "ahmed",
"author_id": 20033412,
"author_profile": "https://Stackoverflow.com/users/20033412",
"pm_score": 0,
"selected": false,
"text": " import 'package:flutter/material.dart';\n\nvoid main() => runApp(MyApp());\n\nclass MyApp extends StatelessWidget {\n @override\n Widget build(BuildContext context) {\n return MaterialApp(\n title: 'Flutter Demo',\n debugShowCheckedModeBanner: false,\n theme: ThemeData(\n primarySwatch: Colors.blue,\n ),\n home: \n Scaffold(\n body: Stack(\n children: [\n Container(\n height: double.maxFinite,\n width: 0100,\n \n color: Colors.grey,\n \n ),\n Positioned.fill(\n child: Material(\n color: Colors.transparent,\n child: InkWell(\n onTap: () => print('nicely working'),\n ),\n ),\n ),\n ElevatedButton(\n onPressed: () => print('not working TT'), // <- how can I trigger this?\n child: const Text('click me!'),\n ),\n \n \n ],\n ),\n ),\n \n );\n }\n}\n"
},
{
"answer_id": 74334287,
"author": "cra1nbow",
"author_id": 17030983,
"author_profile": "https://Stackoverflow.com/users/17030983",
"pm_score": 2,
"selected": true,
"text": "Ink.image"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333563",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17030983/"
] |
74,333,585 | <p>A few hours before, there's no issue when i run the React Native app on Android. Even it successfully built on Azure DevOps.</p>
<p>until when i tried to run the app again and this happens:</p>
<pre><code>* What went wrong:
Execution failed for task ':expo-splash-screen:compileDebugKotlin'.
> Compilation error. See log for more details
</code></pre>
<p>I trace the logs and it shows this message:</p>
<pre><code>> Task :expo-splash-screen:compileDebugKotlin FAILED
w: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:
/Users/s000-50105204/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.6.10/e80fe6ac3c3573a80305f5ec43f86b829e8ab53d/kotlin-stdlib-jdk8-1.6.10.jar (version 1.6)
/Users/s000-50105204/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.6.10/e1c380673654a089c4f0c9f83d0ddfdc1efdb498/kotlin-stdlib-jdk7-1.6.10.jar (version 1.6)
/Users/s000-50105204/.gradle/caches/transforms-2/files-2.1/ecefa6f1392695b7079790a9cdc8d4ee/jetified-kotlin-reflect-1.3.50.jar (version 1.3)
/Users/s000-50105204/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.6.10/b8af3fe6f1ca88526914929add63cf5e7c5049af/kotlin-stdlib-1.6.10.jar (version 1.6)
/Users/s000-50105204/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.6.10/c118700e3a33c8a0d9adc920e9dec0831171925/kotlin-stdlib-common-1.6.10.jar (version 1.6)
w: Some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath
</code></pre>
<p>After i browse for solutions, i found a solution by adding this line in build.gradle to use kotlin 1.6.10:</p>
<pre><code>dependencies {
classpath 'com.google.gms:google-services:4.3.4'
classpath("com.android.tools.build:gradle:3.5.4")
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10' <==== ADDED THIS LINE
}
</code></pre>
<p>But when i run the app again, it shows different error message like this:</p>
<pre><code>* What went wrong:
Execution failed for task ':unimodules-react-native-adapter:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
</code></pre>
<p>I trace the logs and found this:</p>
<pre><code>/Users/s000-50105204/Documents/react-native/Mobil88_MobileApps_Estore/node_modules/@unimodules/react-native-adapter/android/src/main/java/org/unimodules/adapters/react/services/CookieManagerModule.java:13: error: CookieManagerModule is not abstract and does not override abstract method invalidate() in NativeModule
public class CookieManagerModule extends ForwardingCookieHandler implements InternalModule, NativeModule {
^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
</code></pre>
<p>This is the buildscript in build.gradle:</p>
<pre><code> ext {
buildToolsVersion = "30.0.2"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31
}
</code></pre>
<p>This is dependencies on the packages.json for the project:</p>
<pre><code> "dependencies": {
"@ptomasroos/react-native-multi-slider": "^2.2.2",
"@react-native-async-storage/async-storage": "^1.15.8",
"@react-native-clipboard/clipboard": "^1.8.4",
"@react-native-community/geolocation": "^2.0.2",
"@react-native-firebase/app": "^14.7.0",
"@react-native-firebase/auth": "^14.7.0",
"@react-native-firebase/crashlytics": "^14.7.0",
"@react-native-firebase/messaging": "^14.7.0",
"@react-native-masked-view/masked-view": "^0.2.6",
"@redux-devtools/extension": "^3.2.2",
"@sentry/react-native": "^2.5.0",
"axios": "^0.21.2",
"expo": "^38.0.0",
"expo-analytics-amplitude": "~8.2.1",
"expo-apple-authentication": "~2.2.1",
"expo-asset": "~8.1.7",
"expo-crypto": "~8.2.1",
"expo-firebase-analytics": "~2.4.1",
"expo-firebase-core": "~1.1.1",
"expo-font": "~8.2.1",
"expo-google-sign-in": "~8.2.1",
"expo-secure-store": "~9.0.1",
"expo-updates": "~0.2.10",
"firebase": "7.9.0",
"install": "^0.13.0",
"jwt-decode": "^3.0.0",
"lodash.isequal": "^4.5.0",
"moment": "^2.22.2",
"npm": "^6.14.13",
"prop-types": "^15.6.1",
"qs": "^6.5.2",
"react": "~16.11.0",
"react-dom": "~16.11.0",
"react-native": "~0.62.2",
"react-native-animatable": "~1.3.0",
"react-native-background-timer": "^2.4.1",
"react-native-camera": "^4.2.1",
"react-native-check-version": "^1.0.16",
"react-native-checkbox": "~2.0.0",
"react-native-collapsible": "^1.6.0",
"react-native-config": "^1.4.2",
"react-native-copilot": "^2.5.1",
"react-native-countdown-component": "^2.7.1",
"react-native-datepicker": "~1.7.2",
"react-native-device-info": "^8.0.8",
"react-native-easy-toast": "~1.1.0",
"react-native-elements": "~0.19.1",
"react-native-email-link": "1.13.1",
"react-native-exit-app": "^1.1.0",
"react-native-fast-image": "^8.5.11",
"react-native-fbsdk-next": "^4.2.0",
"react-native-gesture-handler": "~1.6.0",
"react-native-image-picker": "^4.0.6",
"react-native-image-zoom-viewer": "^3.0.1",
"react-native-linear-gradient": "^2.5.6",
"react-native-maps": "0.27.1",
"react-native-modal-wrapper": "~3.1.1",
"react-native-network-logger": "^1.13.0",
"react-native-picker-select": "~5.1.0",
"react-native-progress": "^5.0.0",
"react-native-reanimated": "~1.9.0",
"react-native-screens": "~2.9.0",
"react-native-shake": "^5.1.1",
"react-native-skeleton-placeholder": "^5.0.0",
"react-native-smooth-pincode-input": "1.0.9",
"react-native-snap-carousel": "3.9.1",
"react-native-status-bar-height": "^2.6.0",
"react-native-svg": "12.1.0",
"react-native-tab-view": "~1.2.0",
"react-native-tip": "0.0.18",
"react-native-tracking-transparency": "^0.1.0",
"react-native-unimodules": "~0.10.1",
"react-native-vector-icons": "~6.6.0",
"react-native-webview": "11.0.0",
"react-navigation": "3.13.0",
"react-redux": "^5.0.7",
"redux": "^4.0.1",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.3.0",
"toggle-switch-react-native": "^3.2.0"
}
</code></pre>
<p>Is it the kotlin version? or the expo packages?</p>
<p>I cannot find any solutions for this issue, because it was fine before, no changes made and suddenly this happens. Been stuck for 2 days, it can't even run on emulator, and can't even build on Azure anymore</p>
| [
{
"answer_id": 74333613,
"author": "Ninad Sawant",
"author_id": 15294308,
"author_profile": "https://Stackoverflow.com/users/15294308",
"pm_score": 0,
"selected": false,
"text": "Stack(\n children: [\n Container(\n color: Colors.grey,\n child: Column(\n children: [\n //image\n SizedBox(\n width:100, \n height:60\n ),\n ],\n ),\n ),\n Positioned.fill(\n child: Material(\n color: Colors.transparent,\n child: InkWell(\n onTap: () => print('nicely working'),\n ),\n ),\n ),\n ElevatedButton(\n onPressed: () => print('not working TT'),\n child: const Text('click me!'),\n ),\n ],\n ),\n"
},
{
"answer_id": 74333735,
"author": "ahmed",
"author_id": 20033412,
"author_profile": "https://Stackoverflow.com/users/20033412",
"pm_score": 0,
"selected": false,
"text": " import 'package:flutter/material.dart';\n\nvoid main() => runApp(MyApp());\n\nclass MyApp extends StatelessWidget {\n @override\n Widget build(BuildContext context) {\n return MaterialApp(\n title: 'Flutter Demo',\n debugShowCheckedModeBanner: false,\n theme: ThemeData(\n primarySwatch: Colors.blue,\n ),\n home: \n Scaffold(\n body: Stack(\n children: [\n Container(\n height: double.maxFinite,\n width: 0100,\n \n color: Colors.grey,\n \n ),\n Positioned.fill(\n child: Material(\n color: Colors.transparent,\n child: InkWell(\n onTap: () => print('nicely working'),\n ),\n ),\n ),\n ElevatedButton(\n onPressed: () => print('not working TT'), // <- how can I trigger this?\n child: const Text('click me!'),\n ),\n \n \n ],\n ),\n ),\n \n );\n }\n}\n"
},
{
"answer_id": 74334287,
"author": "cra1nbow",
"author_id": 17030983,
"author_profile": "https://Stackoverflow.com/users/17030983",
"pm_score": 2,
"selected": true,
"text": "Ink.image"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333585",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12157247/"
] |
74,333,601 | <p>How to write a window function "Rank() over" for the following requirement:
GET THE LATEST MOD_DATE (20221104) and GROUP the output records BY columns A, B, C, and AMT1 from the INPUT TABLE - then sum up the AMT2 FOR EACH GROUPING). Please refer to the image below.</p>
<p><a href="https://i.stack.imgur.com/E2oyI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/E2oyI.png" alt="enter image description here" /></a></p>
<p>I tried the following but it does not work</p>
<pre><code> SELECT A,B,C, AMT1,AMT2 FROM
(SELECT A, B, C, MOD_DATE, AMT1, AMT2
RANK() OVER (PARTITION BY A, B, C ORDER BY LAST_MODIFIED_DATE DESC) AS rk
FROM INPUT_TABLE)
WHERE rk = 1;
</code></pre>
<p>Appreciate your inputs!</p>
| [
{
"answer_id": 74334420,
"author": "Lukasz Szozda",
"author_id": 5070879,
"author_profile": "https://Stackoverflow.com/users/5070879",
"pm_score": 1,
"selected": true,
"text": "SELECT A, B, C, MOD_DATE, AMT1, AMT2 \nFROM INPUT_TABLE\nQUALIFY RANK() OVER (PARTITION BY A, B, C ORDER BY LAST_MODIFIED_DATE DESC) = 1;\n"
},
{
"answer_id": 74339305,
"author": "Simeon Pilgrim",
"author_id": 43992,
"author_profile": "https://Stackoverflow.com/users/43992",
"pm_score": 1,
"selected": false,
"text": "with INPUT_TABLE(A, B,C, MOD_DATE, AMT1, AMT2) as (\n select * from values\n ('ABC','DEF','GHI',20221102, 2.00, 10.00),\n ('ABC','DEF','GHI',20221104, 2.00, 15.00),\n ('ABC','DEF','GHI',20221104, 2.00, 20.00),\n ('ABC','DEF','GHI',20221102, 3.00, 10.00),\n ('ABC','DEF','GHI',20221104, 3.00, 10.00),\n ('ABC','DEF','GHI',20221104, 3.00, 20.00),\n ('ABC','DEF','GHI',20221104, 4.00, 5.00),\n ('ABC','DEF','GHI',20221104, 4.00, 10.00),\n ('ABC','DEF','GHI',20221102, 5.00, 5.00),\n ('ABC','DEF','GHI',20221104, 5.00, 5.00)\n)\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333601",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5109125/"
] |
74,333,626 | <p>I have a dataframe that has negative values. I would like to replace the negative values to NaN.
The dataframe contains different column types (Object, float, int..) and has over 15 numeric columns so I am looking for a solution that would identify the numeric columns then change the negative values to NaN.</p>
<pre><code>name sodium potass .....
Natural Bran 130 280 .....
All-Bran -1 330 .....
Almond Delight 200 -5 .....
Tex 120 -2 .....
</code></pre>
<p>Thank you</p>
| [
{
"answer_id": 74333673,
"author": "hide1nbush",
"author_id": 19825642,
"author_profile": "https://Stackoverflow.com/users/19825642",
"pm_score": 2,
"selected": false,
"text": "pandas.mask"
},
{
"answer_id": 74333772,
"author": "Bhargav",
"author_id": 15358800,
"author_profile": "https://Stackoverflow.com/users/15358800",
"pm_score": 1,
"selected": false,
"text": "import numpy as np\n\ndf[df < 0] = np.nan\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333626",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11427018/"
] |
74,333,668 | <p>Calculate the n member of the sequence given by the formulas</p>
<pre><code>a[2 * n] = a[n] + 1
a[2 * n + 2] = a[2 * n + 1] - a[n]
a[0] = a[1] = 1
n > 0
</code></pre>
<p>I've tried a lot of variants, but I can't find correct one.</p>
<pre><code>n = int(input())
a = [0 for i in range(n + 3)]
a[0] = a[1] = 1
i = 1
while i * 2 + 2 < n + 3:
a[2 * i] = a[i] + 1;
a[2 * i + 1] = a[2 * i + 2] + a[i]
a[2 * i + 2] = a[2 * i + 1] - a[i]
i += 1
print(a[n])
</code></pre>
| [
{
"answer_id": 74333815,
"author": "TYeung",
"author_id": 8344820,
"author_profile": "https://Stackoverflow.com/users/8344820",
"pm_score": 1,
"selected": false,
"text": "a = {1, 1, 2, 4, 3, ... }"
},
{
"answer_id": 74335013,
"author": "Marina Golovanova",
"author_id": 20350533,
"author_profile": "https://Stackoverflow.com/users/20350533",
"pm_score": 0,
"selected": false,
"text": "n = int(input())\nk = n if n % 2 == 0 else n + 1\na = [None for i in range(k + 1)]\n\na[0] = a[1] = 1\n\ndef fill_list(a):\n while None in a:\n i = 1\n while i * 2 <= k:\n if a[i] != None:\n a[2 * i] = a[i] + 1\n i += 1\n \n i = 1\n while i * 2 + 2 <= k:\n if a[i * 2 + 2] != None and a[i] != None:\n a[i * 2 + 1] = a[i * 2 + 2] + a[i]\n \n i += 1\n\n \nfill_list(a)\nprint(a[n])\n"
},
{
"answer_id": 74335210,
"author": "Paul Hankin",
"author_id": 1400793,
"author_profile": "https://Stackoverflow.com/users/1400793",
"pm_score": 0,
"selected": false,
"text": "a[2n+2] = a[2n+1] - a[n]"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333668",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20350533/"
] |
74,333,669 | <p>I've got this code snippet below trying to apply a title theme to my appBar and I am not quite sure I am understanding the copyWith function for the theme. My understanding would be that all properties of my theme are copied over, except those that I change. I am not changing appBarTheme when I use the copyWith, so why is it not applying to the app?</p>
<p>I've uncommented the line that does't work, and commented out the one that does.</p>
<pre><code>class MyApp extends StatelessWidget {
final ThemeData theme = ThemeData(
primarySwatch: Colors.purple,
fontFamily: 'Quicksand',
// This doesn't work
appBarTheme: AppBarTheme(
titleTextStyle: TextStyle(fontFamily: 'OpenSans', fontSize: 40)),
);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Personal Expenses',
theme: theme.copyWith(
colorScheme: theme.colorScheme.copyWith(secondary: Colors.amber),
// This does work
// appBarTheme: AppBarTheme(
// titleTextStyle: TextStyle(fontFamily: 'OpenSans', fontSize: 40)),
),
home: MyHomePage(),
);
}
}
</code></pre>
| [
{
"answer_id": 74333876,
"author": "ahmed",
"author_id": 20033412,
"author_profile": "https://Stackoverflow.com/users/20033412",
"pm_score": 0,
"selected": false,
"text": " theme: theme.copyWith(\n appBarTheme: AppBarTheme(color: Colors.redAccent,titleTextStyle: TextStyle(fontFamily: \"Amiri\", fontSize: 40))\n"
},
{
"answer_id": 74333992,
"author": "Jiho Kim",
"author_id": 16562494,
"author_profile": "https://Stackoverflow.com/users/16562494",
"pm_score": 2,
"selected": true,
"text": "theme"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333669",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11102385/"
] |
74,333,683 | <pre><code> function prime_number()
{
var num, i, c, flag = true;
num = parseInt(document.getElementById("one").value);
for(i = 2; i <= num - 1; i++)
{
if(num % i === 0)
{
flag = false;
break;
}
if (flag === true)
var c = "It is a prime number";
else
var c = "It is not a prime number";
}
document.getElementById("two").value = c;
}
</code></pre>
<p><strong>THIS IS THE CODING FOR FORM</strong></p>
<pre><code> <form>
<input type="number" id="one" name="one" placeholder="Enter a positive number"><br>
<input type="text" id="two" name="two"><br>
<input type="button" id="submit" name="submit" value="CHECK" onclick="prime_number()"><br>
</form>
</code></pre>
<p>I've tried the <strong>ALERT</strong> method to show the text <strong>"THIS IS A PRIME NUMBER" or "THIS IS NOT A PRIME NUMBER"</strong> and that worked.</p>
| [
{
"answer_id": 74333725,
"author": "flyingfox",
"author_id": 3176419,
"author_profile": "https://Stackoverflow.com/users/3176419",
"pm_score": 0,
"selected": false,
"text": "c = xxx"
},
{
"answer_id": 74333749,
"author": "user31782",
"author_id": 3429430,
"author_profile": "https://Stackoverflow.com/users/3429430",
"pm_score": 1,
"selected": false,
"text": "c"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333683",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20430342/"
] |
74,333,707 | <pre><code>package com.chapter.BJ.UpperLower;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String str = sc.nextLine();
for (int i = 0; i < str.length(); i++) {
if (str.charAt(i) >= 65 && str.charAt(i) <= 90) {
str.charAt(i) += 32;
} else if (str.charAt(i) <= 122 && str.charAt(i) >= 97) {
str.charAt(i) -= 32;
}
System.out.print(str.charAt(i));
}
}
}
</code></pre>
<p>Hello everyone, I don't understand why I get an error on <code>str.charAt(i) += 32;</code> and <code>str.charAt(i) -= 32;</code>. Thank you for your help.</p>
| [
{
"answer_id": 74333725,
"author": "flyingfox",
"author_id": 3176419,
"author_profile": "https://Stackoverflow.com/users/3176419",
"pm_score": 0,
"selected": false,
"text": "c = xxx"
},
{
"answer_id": 74333749,
"author": "user31782",
"author_id": 3429430,
"author_profile": "https://Stackoverflow.com/users/3429430",
"pm_score": 1,
"selected": false,
"text": "c"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333707",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20387081/"
] |
74,333,762 | <p>If have the following list of strings in my Flutter application.</p>
<pre><code>numList = [for (var i = 0; i < 100; i++) i.toString().padLeft(2, "0")];
</code></pre>
<p>It is a list from 00 to 99.</p>
<p>Now I would like to create two new lists out of it.</p>
<ol>
<li><p>One that contains all strings containing a "0" (00,01,10,02,20...)</p>
</li>
<li><p>One that contains all strings starting with "1" (10,11,12,13...)</p>
</li>
</ol>
<p>How could I do that?</p>
| [
{
"answer_id": 74333725,
"author": "flyingfox",
"author_id": 3176419,
"author_profile": "https://Stackoverflow.com/users/3176419",
"pm_score": 0,
"selected": false,
"text": "c = xxx"
},
{
"answer_id": 74333749,
"author": "user31782",
"author_id": 3429430,
"author_profile": "https://Stackoverflow.com/users/3429430",
"pm_score": 1,
"selected": false,
"text": "c"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333762",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15819829/"
] |
74,333,767 | <p>IN this problem we have to print the sum of all the numbers until the user enters zero.</p>
<p>my attempt:</p>
<pre><code>import java.util.Scanner;
public class printsum_until_enter0 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int sum = 0;
//int count = 0;
int x = in.nextInt();
while (x >0) {
if (x > 0) {
sum = sum + x;
System.out.println(sum);
x--;
} else {
System.out.println("no data was entered");
}
x--;
}
}
}
</code></pre>
<p>it runs infinitly before writing X--...but now it takes only one input and after that it is executed...but it supposed to execute after entering 0 and sum of all the numbers before entering 0. But it is not happeing.Any solution guys...Code in java..</p>
| [
{
"answer_id": 74333859,
"author": "Jishnu Prathap",
"author_id": 3651739,
"author_profile": "https://Stackoverflow.com/users/3651739",
"pm_score": 0,
"selected": false,
"text": " package test1;\n import java.util.Scanner;\n public class printsum_until_enter0 {\n public static void main(String[] args) {\n Scanner in = new Scanner(System.in);\n int sum = 0;\n int x = in.nextInt();\n while (x >0) {\n if (x > 0) {\n sum = sum + x;\n } else {\n System.out.println(\"no data was entered\");\n }\n x = in.nextInt();\n }\n System.out.println(sum);\n }\n }\n"
},
{
"answer_id": 74333960,
"author": "Christoph Dahlen",
"author_id": 20370596,
"author_profile": "https://Stackoverflow.com/users/20370596",
"pm_score": 0,
"selected": false,
"text": "do {\n x = in.nextInt();\n if(x > 0) {\n sum += x;\n }\n} while(x > 0)\n"
},
{
"answer_id": 74334026,
"author": "Huhngut",
"author_id": 11355399,
"author_profile": "https://Stackoverflow.com/users/11355399",
"pm_score": 1,
"selected": false,
"text": "import java.util.Scanner;\n\nimport java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n\n Scanner in = new Scanner(System.in);\n int sum = 0;\n int x = 0;\n\n do {\n System.out.println(\"Please insert a number: \");\n x = in.nextInt();\n\n // If x is 0 it wont change the sum\n sum += x;\n System.out.println(sum);\n\n } while (x > 0);\n\n System.out.println(\"no data was entered\");\n\n }\n\n}\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333767",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20430414/"
] |
74,333,770 | <p>I am trying to write a code that replaces all rows of three or more continuous values for zeros. so the three threes on the first row should become zero. I wrote this code which in my mind should work but when I execute my code it seems to me that I am stuck in an infinite loop.</p>
<pre><code>import numpy as np
A = np.array([[1, 2, 3, 3, 3, 4],
[1, 3, 2, 4, 2, 4],
[1, 2, 4, 2, 4, 4],
[1, 2, 3, 5, 5, 5],
[1, 2, 1, 3, 4, 4]])
row_nmbr,column_nmbr = (A.shape)
row = 0
column = 0
while column < column_nmbr:
next_col = column + 1
next_col2 = next_col + 1
if A[row][column] == A[row][next_col] and A[row][next_col] == A[row][next_col2]:
A[row][column] = 0
column =+ 1
print(A)
</code></pre>
| [
{
"answer_id": 74334915,
"author": "user47",
"author_id": 4720957,
"author_profile": "https://Stackoverflow.com/users/4720957",
"pm_score": 3,
"selected": true,
"text": "from functools import partial\nfrom operator import itemgetter\n\n\nA = np.array([[3, 3, 5, 3, 3, 3, 5, 5, 5, 6, 6, 5, 5, 5], \n [1, 8, 8, 4, 7, 4, 7, 7, 7, 7, 1, 2, 3, 9],\n [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5],\n [1, 2, 3, 3, 3, 3, 3, 2, 1, 1, 1, 2, 2, 2], \n [1, 2, 1, 3, 4, 4, 9, 8, 8, 8, 8, 9, 9, 8]])\n\n\ndef func1d(row, replacement):\n # find and filter elements which occurs three or more times\n vals, count = np.unique(row, return_counts=True)\n vals = vals[count >= 3]\n\n # Iteration for each filtered element (val)\n for val in vals:\n # get indices of val from row\n indices = (row == val).nonzero()[0]\n\n # find contiguous indices\n for k, g in groupby(enumerate(indices), lambda t: t[1] - t[0]):\n l = list(map(itemgetter(1), g)) \n # if grouped indices are three or more, do replacement\n if len(l) >=3:\n row[l] = replacement\n\n return row\n\n\nwrapper = partial(func1d, replacement=0)\nnp.apply_along_axis(wrapper, 1, A)\n"
},
{
"answer_id": 74335976,
"author": "inquirer",
"author_id": 11985088,
"author_profile": "https://Stackoverflow.com/users/11985088",
"pm_score": 2,
"selected": false,
"text": "for i in range(row_nmbr):\n m, k = np.unique(A[i], return_inverse=True)\n val = m[np.bincount(k) > 2]\n if len(val) > 0:\n aaa = A[i]\n aaa[A[i] == val] = 0\n\n\nprint(A)\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333770",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19926949/"
] |
74,333,790 | <p>I have a CSV file containing the following:</p>
<pre class="lang-none prettyprint-override"><code>Name,Price,Date,SKU
</code></pre>
<p>I the date is formatted <code>yyy-mm-dd</code> and I want to take all items in the file from <code>2020-01</code> and put them in their own file in a different directory.</p>
<p>The results file will not exist at first but I need to run this on 3 csv files so it will exist for the last 2 runs. I want to maintain the old data still, rather just add all the data with the year 2020 and month 01 into a CSV file.</p>
<p>what I have now:</p>
<pre><code>awk -F, '$3 ~ /2020-01/ {print}' sourceFile.csv > data/2020/01/destonationFile.csv
</code></pre>
<p>I have tried to play around with grep and <code>awk</code>, but do not know how to properly check if the date is correct.
Any advice helps.</p>
<p>sample data as source - sourceData.csv</p>
<pre class="lang-none prettyprint-override"><code>Name,Price,Date,SKU
pixel 5, 20000, 2020-01-04, 124124
iphone 8, 35000,2019-12-11, 124125
note 20 , 50000, 2020-04-16, 124127
note 20 ultra, 60000, 2020-01-12, 124128
s 8, 15000, 2017, 124129
</code></pre>
<p>Sample data as output - destonationFile.csv</p>
<pre class="lang-none prettyprint-override"><code>pixel 5, 20000, 2020-01-04, 124124
note 20 ultra, 60000, 2020-01-12, 124126
</code></pre>
| [
{
"answer_id": 74334915,
"author": "user47",
"author_id": 4720957,
"author_profile": "https://Stackoverflow.com/users/4720957",
"pm_score": 3,
"selected": true,
"text": "from functools import partial\nfrom operator import itemgetter\n\n\nA = np.array([[3, 3, 5, 3, 3, 3, 5, 5, 5, 6, 6, 5, 5, 5], \n [1, 8, 8, 4, 7, 4, 7, 7, 7, 7, 1, 2, 3, 9],\n [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5],\n [1, 2, 3, 3, 3, 3, 3, 2, 1, 1, 1, 2, 2, 2], \n [1, 2, 1, 3, 4, 4, 9, 8, 8, 8, 8, 9, 9, 8]])\n\n\ndef func1d(row, replacement):\n # find and filter elements which occurs three or more times\n vals, count = np.unique(row, return_counts=True)\n vals = vals[count >= 3]\n\n # Iteration for each filtered element (val)\n for val in vals:\n # get indices of val from row\n indices = (row == val).nonzero()[0]\n\n # find contiguous indices\n for k, g in groupby(enumerate(indices), lambda t: t[1] - t[0]):\n l = list(map(itemgetter(1), g)) \n # if grouped indices are three or more, do replacement\n if len(l) >=3:\n row[l] = replacement\n\n return row\n\n\nwrapper = partial(func1d, replacement=0)\nnp.apply_along_axis(wrapper, 1, A)\n"
},
{
"answer_id": 74335976,
"author": "inquirer",
"author_id": 11985088,
"author_profile": "https://Stackoverflow.com/users/11985088",
"pm_score": 2,
"selected": false,
"text": "for i in range(row_nmbr):\n m, k = np.unique(A[i], return_inverse=True)\n val = m[np.bincount(k) > 2]\n if len(val) > 0:\n aaa = A[i]\n aaa[A[i] == val] = 0\n\n\nprint(A)\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333790",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12131758/"
] |
74,333,802 | <p>How to prevent browser back to display login page after logged in in inertia js?
if you login to inertia demo CRM with this url :</p>
<p><strong>Demo Inertia Js</strong> : <a href="https://demo.inertiajs.com/login" rel="nofollow noreferrer">https://demo.inertiajs.com/login</a></p>
<p>afetr loginning you can see login page by browser back again.
How can I solve it?
Thanks</p>
| [
{
"answer_id": 74335307,
"author": "ericmp",
"author_id": 14569750,
"author_profile": "https://Stackoverflow.com/users/14569750",
"pm_score": 1,
"selected": false,
"text": "/login"
},
{
"answer_id": 74555238,
"author": "dwweb0309",
"author_id": 18438516,
"author_profile": "https://Stackoverflow.com/users/18438516",
"pm_score": 0,
"selected": false,
"text": "Inertia.post('/login', {\n email: email, \n password: password \n}, {\n replace: true \n})\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333802",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7267170/"
] |
74,333,824 | <p>The button appears after the wait counter that appears automatically when the page is loaded</p>
<p>I want the counter to appear only after pressing the button and the seconds counter appear and then the button to be converted to appears inside the <a tag</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var downloadButton = document.getElementById("download");
var counter = 10;
var newElement = document.createElement("p");
newElement.innerHTML = "You can download the file in 10 seconds.";
var id;
downloadButton.parentNode.replaceChild(newElement, downloadButton);
id = setInterval(function() {
counter--;
if(counter < 0) {
newElement.parentNode.replaceChild(downloadButton, newElement);
clearInterval(id);
} else {
newElement.innerHTML = "You can download the file in " + counter.toString() + " seconds.";
}}, 1000);</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><button id="download"><a href="https://www.youtube.com/">Watch</a></button></code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74335307,
"author": "ericmp",
"author_id": 14569750,
"author_profile": "https://Stackoverflow.com/users/14569750",
"pm_score": 1,
"selected": false,
"text": "/login"
},
{
"answer_id": 74555238,
"author": "dwweb0309",
"author_id": 18438516,
"author_profile": "https://Stackoverflow.com/users/18438516",
"pm_score": 0,
"selected": false,
"text": "Inertia.post('/login', {\n email: email, \n password: password \n}, {\n replace: true \n})\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19877564/"
] |
74,333,836 | <p>Alright so don't ask why but I am trying to implement a reduce method on subclass of Map:</p>
<pre><code>const nah = Symbol('not-an-arg');
class MapArray<A, B> extends Map<A, B> {
reduce<T = [A, B]>(f: (prev: T, next: [A, B]) => any, initialVal?: T) {
let prev = arguments.length > 1 ? arguments[1] : nah;
for (const [k, v] of this) {
if (prev === nah) {
prev = [k, v];
continue;
}
prev = f(prev, [k, v]);
}
return prev;
}
}
</code></pre>
<p>it's not the prettiest thing, but it basically works. The problem is the typing. If I do:</p>
<pre><code>new MapArray<string,boolean>().reduce((a,b) => 'whatever');
</code></pre>
<p>versus:</p>
<pre><code>new MapArray<string,boolean>().reduce((a,b) => 'whatever', []);
</code></pre>
<p>I want it to able to capture the type of the 2nd argument <code>[]</code></p>
<p>using my <em>invalid</em> version of TS, I tried something like this:</p>
<pre><code> type X = (if initialVal ? typeof initialVal : [A, B])
reduce<R = any, T = X>(f: (prev: T, next: [A, B]) => R, initialVal?: T);
</code></pre>
<p>this is obviously completely wrong, but hopefully you get the idea, doubt it's possible though. Does anyone know if I can capture the type of <code>initialVal</code> if it's passed, and if not, default to <code>[A,B]</code>?</p>
<p>here is the problem:
<a href="https://www.typescriptlang.org/play?#code/MYewdgzgLgBGCGALGBeGBlAngWwEYgBsAKAcjBCgFp4xqAnAcxIEoBuAKHeAPgghgCy8AA4BBOnXiYAPKIA0MAEIA%20GAFMAHlDVgAJvyHDZClTADendjGsw6a3QFdga6QCVUMGpmVEAZgC4YImE7ADdAgG15JQBdBTBNKEjoxTiYAEs9TQB%20QLAHPDU6BQg1Al9cmChEdIhmVFVXZkDXDhtbeycXdzQvBQAVDy8fAKCQtXCYfvjE5JM0zN0cvILcIpKyisDq2vqURoVM9Kh0%20AIANTPA-uaYVqsbO0dnNyGwTAG37z9A4LDrmZaOaxQ5ZDSVfKFYowUrlSo7OoNO6g46nC5nSo3GAtcycdrtAhqWDjUJDRgFHRQCAAOkJYAY1RgqgAjDBsp5ydhKRAIsyYti4Eg2vjrITYItNB4AAwcB4i3wgOhBUCQWARADWClC-JAviqNURFjlIps6T1fwmqBQaAQiHqFhNjpgJI8Gq1MWFTvxKpO%20TUnqdAF88V7nWEPL4LaEFG6YNrQUsNABqJMKBFsEMi4PG9p2KAOOhgMMTWXtbPZ9gAekr%20rUMAVBAIIAA7pkGDBQNhhOlCRAFLgHOLYBBECAHARdGASP1LCqIIQ1LSQAwiMaEs3BCJxJIZJC1tDoHQ2z5mNTSlAiFKFCQFSAWGeiUQAEzX3DwOj3p5daTDIhEeD9nsqgOiac5qgAXgodD8r0AbtGBMCxtqHi4HBNhzguS4rmYAEwLggYZo6eYFkWJAkAGgYKAArFRzDsBmnBAA" rel="nofollow noreferrer">TS playground</a></p>
<p>It will compile but "a is not iterable" (a as in first argument to the reduce callback)...a is not iterable because a is 55.</p>
| [
{
"answer_id": 74333886,
"author": "Alexander Mills",
"author_id": 1223975,
"author_profile": "https://Stackoverflow.com/users/1223975",
"pm_score": 0,
"selected": false,
"text": "reduce<R = any>(f: (prev: [A, B], next: [A, B]) => R): R;\nreduce<R = any, T = any>(f: (prev: T, next: [A, B]) => R, initialVal?: T) {...}\n"
},
{
"answer_id": 74334673,
"author": "kikon",
"author_id": 16466946,
"author_profile": "https://Stackoverflow.com/users/16466946",
"pm_score": 1,
"selected": false,
"text": "undefined"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333836",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1223975/"
] |
74,333,839 | <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>const paragraph = document.querySelector(".paragraph")
const input = document.querySelector("input")
const updInnerHTML = () => {
paragraph.innerHTML = input.value
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code> <form>
<input type="text" placeholder="Type Something">
<button onclick="updInnerHTML()">Update InnerHTML</button>
</form>
<p class="paragraph"></p></code></pre>
</div>
</div>
</p>
<p>The above code seems to work for a split second, the value appends to the <code><p></code> tag and vanishes immediately, Yeah I know this could be made permanent if I remove <code><form></form></code> tags, but then I'll lose the ability to automatically clear the input fields! Is there a work around for this? Do I need to use a database or atleast LocalStorage? Is there a way to achieve it without using a database?</p>
| [
{
"answer_id": 74333886,
"author": "Alexander Mills",
"author_id": 1223975,
"author_profile": "https://Stackoverflow.com/users/1223975",
"pm_score": 0,
"selected": false,
"text": "reduce<R = any>(f: (prev: [A, B], next: [A, B]) => R): R;\nreduce<R = any, T = any>(f: (prev: T, next: [A, B]) => R, initialVal?: T) {...}\n"
},
{
"answer_id": 74334673,
"author": "kikon",
"author_id": 16466946,
"author_profile": "https://Stackoverflow.com/users/16466946",
"pm_score": 1,
"selected": false,
"text": "undefined"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333839",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18617343/"
] |
74,333,868 | <p>I have a problem with this code. 4.9 never comes out, only 4.5 or 5.5. Could it be possible to spin up the decimals instead of the integers to reach 4.9?</p>
<pre class="lang-js prettyprint-override"><code>let counts = setInterval(updated, 500);
let upto = 1.5;
function updated() {
var count = document.getElementById("counter");
count.innerHTML = ++upto;
if (Number(upto.toFixed(1)) >= 4.9) {
clearInterval(counts);
}
}
</code></pre>
| [
{
"answer_id": 74333962,
"author": "Amini",
"author_id": 15351296,
"author_profile": "https://Stackoverflow.com/users/15351296",
"pm_score": 1,
"selected": false,
"text": "let counts = setInterval(updated, 10);\nlet upto = 70.1;\nvar count = document.getElementById(\"counter\");\n\nfunction updated() {\n // ++upto would never hit 88.5, it will hit 88.1 89.1 -> so we do += 0.1\n // Updated: Show only one decimal using toFixed()\n const _t = upto += 0.1\n count.innerHTML = _t.toFixed(1);\n // Changing upto to number again because toFixed converts it to string\n if (Number(upto.toFixed(1)) === 88.5) {\n clearInterval(counts);\n }\n}"
},
{
"answer_id": 74334012,
"author": "Polina Shestakova",
"author_id": 10139955,
"author_profile": "https://Stackoverflow.com/users/10139955",
"pm_score": 1,
"selected": false,
"text": "let counts=setInterval(updated, 10);\nlet upto=70.1;\nfunction updated(){\n var count= document.getElementById(\"counter\");\n count.innerHTML=upto + 0.1;\n if(Number(upto.toFixed(1))===88.5)\n {\n clearInterval(counts);\n }\n}\n"
},
{
"answer_id": 74334310,
"author": "Roko C. Buljan",
"author_id": 383904,
"author_profile": "https://Stackoverflow.com/users/383904",
"pm_score": 0,
"selected": false,
"text": "from"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333868",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20319752/"
] |
74,333,903 | <p>`</p>
<pre><code>import './App.css';
import ArrayState from './components/ArrayState';
import FetchApi from './components/FetchAPI/FetchApi';
import Login from './components/Login';
import Useeffect2 from './components/Useeffect2';
import UseEffects from './components/UseEffects';
import React,{useEffect} from 'react'
function App() {
const getUsers = async() => {
console.log("function")
}
useEffect(() => {
console.log("use")
getUsers();
});
return (
// <ArrayState/>
// <Login/>
// <UseEffects/>
// <Useeffect2/>
<FetchApi/>
);
}
export default App;
</code></pre>
<p><a href="https://i.stack.imgur.com/CHcFW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CHcFW.png" alt="the result of code in image below" /></a></p>
<p>the function "getUsers" is called once in "UseState" but its runs 2 times. i want to run function once. i have define body of function into useEffect?</p>
| [
{
"answer_id": 74333957,
"author": "Nusrat Jahan",
"author_id": 20315115,
"author_profile": "https://Stackoverflow.com/users/20315115",
"pm_score": 0,
"selected": false,
"text": "useEffect(() => {\n // Side Effect\n}, []);\n"
},
{
"answer_id": 74333978,
"author": "Hammed Noibi",
"author_id": 9964193,
"author_profile": "https://Stackoverflow.com/users/9964193",
"pm_score": 1,
"selected": false,
"text": " useEffect(() => {\n const getUsers = async() => {\n console.log(\"function\")\n }\n console.log(\"use\")\n \n getUsers();\n }, []);\n\n"
},
{
"answer_id": 74333995,
"author": "Azzy",
"author_id": 2122822,
"author_profile": "https://Stackoverflow.com/users/2122822",
"pm_score": 0,
"selected": false,
"text": "useEffect(() => {\n\n\n}, []) // dependency array with props, variable that trigger the side effect\n"
},
{
"answer_id": 74334139,
"author": "tomleb",
"author_id": 15169145,
"author_profile": "https://Stackoverflow.com/users/15169145",
"pm_score": 0,
"selected": false,
"text": "React 18"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333903",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17408654/"
] |
74,333,934 | <p>Lets say I have 4 variables, a,b,c and d.</p>
<p>I'm trying to write a code(in the shortest formate) using only If Else (in nested formate) to arrange the variables in accensending order.</p>
<p>I'm sure their possibly are ways to do it smothly but using this method do you think if the code can be shortened</p>
<p>Do you guys have any simpler way of finding inequality in such a way</p>
<p>**```</p>
<pre><code>a=19
b=10
c=1
d=8
if a>b:
print()
if a>c:
print() #ALL OK
if a>d:
print()
if b>c:
print()
if c>d:
print("a>b>c>d")
else:
print("a>b>d>c")
else:
print()
if b>d:
print("a>c>b>d")
else:
print("a>c>d>b")
else:
print()
if b>c:
print("d>a>b>c")
else:
print("d>a>c>b")
else:
print()
if a>d:
print()
if d>b:
print("c>a>d>b")
else:
print("c>a>b>d")
else:
print()
if c>d:
print("c>d>a>b")
else:
print("d>c>a>b")
else:
print()
if b>c:
print()
if b>d:
print()
if a>c:
print()
if c>d:
print("b>a>c>d")
else:
print("b>a>d>c")
else:
print()
if a>d:
print("b>c>a>d")
else:
print("b>c>d>a")
else:
print()
if c>a:
print("d>b>c>a")
else:
print("d>b>a>c")
else:
print
if c>d:
print()
if a>d:
print("c>b>a>d")
else:
print("c>b>d>a")
else:
print("d>c>b>a")
```
`
```**
</code></pre>
| [
{
"answer_id": 74333957,
"author": "Nusrat Jahan",
"author_id": 20315115,
"author_profile": "https://Stackoverflow.com/users/20315115",
"pm_score": 0,
"selected": false,
"text": "useEffect(() => {\n // Side Effect\n}, []);\n"
},
{
"answer_id": 74333978,
"author": "Hammed Noibi",
"author_id": 9964193,
"author_profile": "https://Stackoverflow.com/users/9964193",
"pm_score": 1,
"selected": false,
"text": " useEffect(() => {\n const getUsers = async() => {\n console.log(\"function\")\n }\n console.log(\"use\")\n \n getUsers();\n }, []);\n\n"
},
{
"answer_id": 74333995,
"author": "Azzy",
"author_id": 2122822,
"author_profile": "https://Stackoverflow.com/users/2122822",
"pm_score": 0,
"selected": false,
"text": "useEffect(() => {\n\n\n}, []) // dependency array with props, variable that trigger the side effect\n"
},
{
"answer_id": 74334139,
"author": "tomleb",
"author_id": 15169145,
"author_profile": "https://Stackoverflow.com/users/15169145",
"pm_score": 0,
"selected": false,
"text": "React 18"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333934",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20426661/"
] |
74,333,969 | <p>I live in Ukraine, Kyiv. And due to the constant terrorist acts of russia, I very often have no electricity. However, there is a desire to learn React. But there is a dillema: How to create, view and deploy simple react app, because i know that</p>
<pre><code>npm init vite
</code></pre>
<pre><code>npm create-react-app
</code></pre>
<p>they all need internet connection to dowload data etc.</p>
<p>So how can i create local react app and when internet restores, publish it?</p>
<p>Probably codesandbox?</p>
| [
{
"answer_id": 74333996,
"author": "Someone",
"author_id": 15373641,
"author_profile": "https://Stackoverflow.com/users/15373641",
"pm_score": 2,
"selected": false,
"text": "npm start"
},
{
"answer_id": 74334042,
"author": "Thomas",
"author_id": 10148219,
"author_profile": "https://Stackoverflow.com/users/10148219",
"pm_score": 1,
"selected": false,
"text": "create-react-app"
},
{
"answer_id": 74544675,
"author": "Juan Picado",
"author_id": 308341,
"author_profile": "https://Stackoverflow.com/users/308341",
"pm_score": 0,
"selected": false,
"text": "npm create-react-app --registry http://localhost:4873"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333969",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18691446/"
] |
74,333,970 | <p>I have two lists of sets, let's say:
[{1, 2, 3}, {4, 5}, {6, 7}] and [{1, 2}, {3, 4}, {5, 6, 7}]</p>
<p>No set in the list has the same element and the sum of all sets in both lists is the same.
The function should check if the sets in both lists had the same elements. If there were some differences, put them in another set.</p>
<p>So above example should return:
[{1, 2}, {3}, {4}, {5}, {6, 7}]</p>
<p>I work on large sets so I would need this function to be as effective as possible.</p>
<p>Here is the example code and how I would like it to work:</p>
<pre><code>def mergeSets(x, y):
out = set()
for i in x:
out = out.union(i)
# this allows me to get the set of all elements but here where my mind stops working
# the problem sounds simple but thinking hours I can not think of good algorythm for this issue :(
# I found set.intersection() function but it works on single sets only, not lists of sets
return out
x = mergeSets([{1, 2, 3}, {4, 5}, {6, 7}], [{1, 2}, {3, 4}, {5, 6, 7}])
print(x)
# [{1, 2}, {3}, {4}, {5}, {6, 7}]
x = mergeSets([{1, 2}, {3, 4, 5, 6, 7}, {8}], [{1}, {2, 3, 4}, {5, 6, 7, 8}])
print(x)
# [{1}, {2}, {3, 4}, {5, 6, 7}, {8}]
</code></pre>
<p>EDIT: the data doesn't have to be sorted and may be even of different types than integer</p>
<p>EDIT2: the input lists don't have to be sorted so sets may appear in random order</p>
| [
{
"answer_id": 74334134,
"author": "David Smith",
"author_id": 13663981,
"author_profile": "https://Stackoverflow.com/users/13663981",
"pm_score": 2,
"selected": false,
"text": ".intersection()"
},
{
"answer_id": 74334284,
"author": "trincot",
"author_id": 5459839,
"author_profile": "https://Stackoverflow.com/users/5459839",
"pm_score": 4,
"selected": true,
"text": "from collections import defaultdict\n\ndef merge_sets(lista, listb):\n index_in_a = {\n val: idx\n for idx, elem in enumerate(lista) for val in elem\n }\n set_by_key = defaultdict(set)\n for idx, elem in enumerate(listb):\n for val in elem:\n set_by_key[(index_in_a[val], idx)].add(val)\n return list(set_by_key.values())\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74333970",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9630049/"
] |
74,334,000 | <p>Given:
an array</p>
<pre><code> [
{
"name": "home page",
"title": "Find Jobs in Technology",
"url": "https://www.url1.com/",
"elements": [
{
"category": "navigation",
"buttons": [
{
"title": "Tech Careers",
"type": "DropDown",
"options": [
{
"title": "Job Search",
"type": "Button",
"navigation": true
},
{
"title": "Career Events",
"type": "Button",
"navigation": false
}
]
},
{
"title": "Insights",
"type": "Link",
"navigation": true
}
]
}
]
},
{
"name": "tech careers",
"title": "careers",
"url": "https://www.url1.com/careers",
"elements": [
{
"category": "navigation",
"buttons": [
{
"title": "Login",
"type": "Link",
"navigation": true
}
]
}
]
}
]
</code></pre>
<p>I would like to filter this array using Javascript to get an array of objects with "navigation": true.</p>
<p>Expected filtered array:</p>
<pre><code>[
{
"title": "Job Search",
"type": "Button",
"navigation": true
},
{
"title": "Insights",
"type": "Link",
"navigation": true
},
{
"title": "Login",
"type": "Link",
"navigation": true
}
]
</code></pre>
<p>Thanks in advance.</p>
<p>I tried array.filter, but it works for one level of items.</p>
| [
{
"answer_id": 74334041,
"author": "trincot",
"author_id": 5459839,
"author_profile": "https://Stackoverflow.com/users/5459839",
"pm_score": 3,
"selected": true,
"text": "filterRecursive"
},
{
"answer_id": 74334087,
"author": "Dmytro Demyanenko",
"author_id": 20265473,
"author_profile": "https://Stackoverflow.com/users/20265473",
"pm_score": 0,
"selected": false,
"text": "function filter(array) {\n const filteredArray = [];\n\n array.forEach(page => {\n page.elements.forEach(el => {\n el.buttons.forEach(btn => {\n if (btn?.type === \"DropDown\") {\n btn.options.forEach(opt => {\n if (opt.navigation === true) {\n filteredArray.push(opt);\n }\n });\n } else if (btn.navigation === true) {\n filteredArray.push(btn);\n }\n })\n })\n });\n\n return filteredArray;\n}\n\nconst data = [{\"name\": \"home page\",\"title\": \"Find Jobs in Technology\",\"url\": \"https://www.url1.com/\",\"elements\": [{\"category\": \"navigation\",\"buttons\": [{\"title\": \"Tech Careers\",\"type\": \"DropDown\",\"options\": [{\"title\": \"Job Search\",\"type\": \"Button\",\"navigation\": true},{\"title\": \"Career Events\",\"type\": \"Button\",\"navigation\": false}]},{\"title\": \"Insights\",\"type\": \"Link\",\"navigation\": true}]}]},{\"name\": \"tech careers\",\"title\": \"careers\",\"url\": \"https://www.url1.com/careers\",\"elements\": [{\"category\": \"navigation\",\"buttons\": [{\"title\": \"Login\",\"type\": \"Link\",\"navigation\": true}]}]}];\n\nconsole.log(filter(data));"
},
{
"answer_id": 74334099,
"author": "symlink",
"author_id": 818326,
"author_profile": "https://Stackoverflow.com/users/818326",
"pm_score": 0,
"selected": false,
"text": "const arr=[{name:\"home page\",title:\"Find Jobs in Technology\",url:\"https://www.url1.com/\",elements:[{category:\"navigation\",buttons:[{title:\"Tech Careers\",type:\"DropDown\",options:[{title:\"Job Search\",type:\"Button\",navigation:true},{title:\"Career Events\",type:\"Button\",navigation:false}]},{title:\"Insights\",type:\"Link\",navigation:true}]}]},{name:\"tech careers\",title:\"careers\",url:\"https://www.url1.com/careers\",elements:[{category:\"navigation\",buttons:[{title:\"Login\",type:\"Link\",navigation:true}]}]}]\n\nconst res = []\n\nfunction findNavTrue(arr) {\n arr.forEach(obj => {\n for (let [key, val] of Object.entries(obj)) {\n if (Array.isArray(val)) {\n findNavTrue(val)\n } else if (key === \"navigation\" && val === true) {\n res.push(obj)\n }\n }\n })\n}\n\nfindNavTrue(arr)\nconsole.log(res)"
},
{
"answer_id": 74334169,
"author": "Nusrat Jahan",
"author_id": 20315115,
"author_profile": "https://Stackoverflow.com/users/20315115",
"pm_score": 0,
"selected": false,
"text": "let arr = [{name:\"home page\",title:\"Find Jobs in Technology\",url:\"https://www.url1.com/\",elements:[{category:\"navigation\",buttons:[{title:\"Tech Careers\",type:\"DropDown\",options:[{title:\"Job Search\",type:\"Button\",navigation:true},{title:\"Career Events\",type:\"Button\",navigation:false}]},{title:\"Insights\",type:\"Link\",navigation:true}]}]},{name:\"tech careers\",title:\"careers\",url:\"https://www.url1.com/careers\",elements:[{category:\"navigation\",buttons:[{title:\"Login\",type:\"Link\",navigation:true}]}]}]\nlet nav = [];\narr.map((elem1)=>{\n elem1.elements.map((elem2)=>{\n elem2.buttons.map((elem3)=>{ \n if(elem3.type == 'DropDown') {\n elem3.options.map((elem4)=>{\n if(elem4.navigation) nav.push(elem4)\n })\n }\n else if(elem3.navigation) nav.push(elem3)\n })\n })\n})\nconsole.log(nav);"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74334000",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20430432/"
] |
74,334,002 | <p>I have this working for loop,
I want to use lambda that prints same results below</p>
<pre><code>ids= [1,2,3,4,5,6,7]
val = [20,30,26,38,40,22,35]
list1=[]
for i,num in enumerate(val):
if num > 29:
list1.append(ids[i])
print("ids",list1)
#output ids [2, 4, 5, 7]
</code></pre>
<p>The code below throws and invalid syntax.
I just want to get the element value not the index.</p>
<pre><code>new_id=list(filter(lambda ids[i]:
val[i]>29, range(len(val))))
</code></pre>
| [
{
"answer_id": 74334015,
"author": "assume_irrational_is_rational",
"author_id": 11622508,
"author_profile": "https://Stackoverflow.com/users/11622508",
"pm_score": 0,
"selected": false,
"text": "val = [20,30,26,38,40,22,35]\nfun = lambda val: [v for v in val if v>29]\nres = fun(val)\n# [30, 38, 40, 35]\n"
},
{
"answer_id": 74334020,
"author": "fholl124",
"author_id": 14320213,
"author_profile": "https://Stackoverflow.com/users/14320213",
"pm_score": 0,
"selected": false,
"text": "filtered = [x for x in val if x > 29]\n"
},
{
"answer_id": 74334028,
"author": "ThePyGuy",
"author_id": 9136348,
"author_profile": "https://Stackoverflow.com/users/9136348",
"pm_score": 1,
"selected": false,
"text": "lambda"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74334002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8487751/"
] |
74,334,045 | <p>So basically, I m making a program where 25 tasks write the same random task to one file until it reaches a certain size, and I would like to dynamically display the file size of the selected file in 0.5 seconds interval, so I made a timer hooked with <code>Timer_Elapsed</code> which should be executed every 0.5 seconds and display on UI which I specify on mainWindow.xaml on the textblock x:Name="fileSize", so I placed the <code>createTimer</code> function in to <code>btnGo_Click</code> function in mainwindow.xaml.cs so the event would extract the right <code>fileInfo</code> of the <code>selectedFile</code>. Any advice for my wrong would be appreciated. I'm also sharing the <code>FileIO</code> class in case it is needed, so they are full solutions. Even aside from the questions I asked, any general advice to better my code would be appreciated because I need to get a grasp of the good code example.</p>
<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Windows;
using System.Threading;
namespace WriteFile
{
internal class FileIO
{
private object _lock = new object();
public volatile bool sizeReached = false;
private StreamWriter sw = null;
Mutex mut = null;
public FileIO()
{
if (!Mutex.TryOpenExisting("MyMutex", out mut))
{
mut = new Mutex(true, "MyMutex");
mut.ReleaseMutex();
}
}
internal void WriteFile(string FilePath)
{
while (!sizeReached)
{
mut.WaitOne();
try
{
using (sw = new StreamWriter(FilePath, true))
{
sw.WriteLine(Guid.NewGuid());
}
}
catch (Exception ex)
{
MessageBox.Show("Exception: " + ex.Message);
}
finally
{
if (sw != null)
{
sw.Close();
}
}
mut.ReleaseMutex();
}
}
internal void SizeMonitor(string FPath, int MaxSize, Task[] tasks)
{
FileInfo fi = null;
while (!sizeReached)
{
if (File.Exists(FPath))
{
fi = new FileInfo(FPath);
if (fi.Length >= MaxSize)
{
sizeReached = true;
}
}
if (sizeReached)
{
foreach (Task task in tasks)
{
task.Wait();
}
}
Thread.Sleep(1);
}
MessageBox.Show(fi.Length.ToString());
MessageBox.Show("Done");
}
}
}
</code></pre>
<p>mainWindow.xaml</p>
<pre class="lang-xml prettyprint-override"><code><Window x:Class="WriteFile.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WriteFile"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<TextBlock x:Name="fileSize"/>
<TextBox Name ="TargetSize" VerticalAlignment="Center" FontSize="20">
</TextBox>
<Label Content="Target Size" HorizontalAlignment="Left" Margin="92,150,0,0" VerticalAlignment="Top"/>
<Button Name ="btnGo" Content="Write to file" HorizontalAlignment="Left" Margin="92,267,0,0" VerticalAlignment="Top" Width="100" Click="btnGo_Click"/>
</Grid>
</Window>
</code></pre>
<p>mainWindow.xaml.cs</p>
<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.IO;
using Microsoft.Win32;
using System.ComponentModel;
using System.Timers;
using System.Threading;
using System.Runtime.CompilerServices;
namespace WriteFile
{
public partial class MainWindow : Window
{
System.Timers.Timer timer = new System.Timers.Timer();
Task[] tasks;
Task MonitorTask;
static FileIO fio = new FileIO();
static string fPath;
static FileInfo fileInfo;
public MainWindow()
{
InitializeComponent();
CreateTimer();
}
public void CreateTimer()
{
var timer = new System.Timers.Timer(500); // fire every 0.5 second
timer.Enabled = true;
timer.Elapsed += Timer_Elapsed;
}
private void Timer_Elapsed(object sender, ElapsedEventArgs e)
{
fileSize.Text = fileInfo.Length.ToString();
}
private void btnGo_Click(object sender, RoutedEventArgs e)
{
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.ShowDialog();
Stream myStream;
saveFileDialog.FilterIndex = 2;
saveFileDialog.RestoreDirectory = true;
if (File.Exists(saveFileDialog.FileName))
{
File.Delete(saveFileDialog.FileName);
}
if ((myStream = saveFileDialog.OpenFile()) != null)
{
StreamWriter sw = new StreamWriter(myStream);
sw.Write(" your text");
myStream.Close();
}
int NoOfTasks = 25;
int Target = Convert.ToInt32(TargetSize.Text);
fPath = saveFileDialog.FileName;
tasks = new Task[NoOfTasks];
fio.sizeReached = false;
fileInfo = new FileInfo(fPath);
for (int i = 0; i < NoOfTasks; i++)
{
tasks[i] = new Task(() => fio.WriteFile(fPath));
tasks[i].Start();
}
MonitorTask = new Task(() => fio.SizeMonitor(fPath, Target, tasks));
MonitorTask.Start();
}
}
}
</code></pre>
| [
{
"answer_id": 74334231,
"author": "EldHasp",
"author_id": 13349759,
"author_profile": "https://Stackoverflow.com/users/13349759",
"pm_score": -1,
"selected": false,
"text": " private void Timer_Elapsed(object sender, ElapsedEventArgs e)\n {\n // Asynchronously getting the right data\n string text = fileInfo.Length.ToString();\n\n // Using the Window's Dispatcher\n // to setting ready-made data to UI elements.\n Dispatcher.BeginInvoke(() => fileSize.Text = text);\n }\n"
},
{
"answer_id": 74338731,
"author": "BionicCode",
"author_id": 3141792,
"author_profile": "https://Stackoverflow.com/users/3141792",
"pm_score": 0,
"selected": false,
"text": "FileInfo.Length"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74334045",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18930577/"
] |
74,334,056 | <p>I have two array object, and i put that two array to make a chart in Vue JS 3</p>
<p>array 1 is for the title:</p>
<pre><code>[
"Jumlah SD",
"Jumlah SMP",
"Jumlah SD",
"Jumlah SMP"
]
</code></pre>
<p>and second array is the value:</p>
<pre><code>[
"22",
"243",
"44",
"22"
]
</code></pre>
<p>My question is, how to sum the second array? My expected array object is:
first array for title:</p>
<pre><code>[
"Jumlah SD",
"Jumlah SMP",
]
</code></pre>
<p>and second array for value will be:</p>
<pre><code>[
"66",
"265",
]
</code></pre>
<p>My current code is:</p>
<pre><code> onMounted(() => {
chart.totalField = props.datas.length === 0 ? 0 : JSON.parse(props.datas[0].fieldDatas).length
chart.totalData = props.datas.length
if (chart.total !== 0) {
for (let i = 0; i < chart.totalData; i++) {
for (let j = 0; j < chart.totalField; j++) {
chart.title.push(JSON.parse(props.datas[i].fieldDatas)[j].title)
chart.value.push(JSON.parse(props.datas[i].fieldDatas)[j].value)
}
}
}
console.log(chart.title);
console.log(chart.value);
})
</code></pre>
| [
{
"answer_id": 74334079,
"author": "Stephen Quan",
"author_id": 881441,
"author_profile": "https://Stackoverflow.com/users/881441",
"pm_score": 1,
"selected": true,
"text": " let obj = { };\n obj = { \"Jumlah SD\": 22 }; // i = 0\n obj = { \"Jumlah SD\": 22, \"Jumlah SMP\": 243}; // i = 1\n obj = { \"Jumlah SD\": 66, \"Jumlah SMP\": 243}; // i = 2\n obj = { \"Jumlah SD\": 66, \"Jumlah SMP\": 265}; // i = 3\n Object.keys(obj); // [ \"Jumlah SD\", \"Jumlah SMP\" ]\n Object.values(obj); // [ 66, 265 ]\n"
},
{
"answer_id": 74334082,
"author": "Mina",
"author_id": 11887902,
"author_profile": "https://Stackoverflow.com/users/11887902",
"pm_score": 2,
"selected": false,
"text": "reduce"
},
{
"answer_id": 74334086,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "const arr1 = [\n \"Jumlah SD\",\n \"Jumlah SMP\",\n \"Jumlah SD\",\n \"Jumlah SMP\"\n];\n\nconst arr2 = [\n \"22\",\n \"243\",\n \"44\",\n \"22\"\n];\n\ndict = {}\n\nfor (let i = 0; i < arr1.length; i++) {\n const key = arr1[i];\n if (key in dict) {\n dict[key] = String(Number(dict[key]) + Number(arr2[i]));\n } else {\n dict[key] = String(Number(arr2[i]));\n }\n}\n\nconst arr3 = Object.keys(dict);\nconst arr4 = Object.values(dict);\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74334056",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8402887/"
] |
74,334,091 | <p>I am learning the many ways to center an element in the middle of the screen. I just discovered the code below, and I am trying to understand the technical explanation behind how it works.</p>
<pre><code><body>
<div class="square"></div>
</body>
</code></pre>
<pre><code>.square{
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
margin: auto;
background-color: pink;
height: 50px;
width: 50px;
}
</code></pre>
<p>At first, I thought if both top and bottom are zero, the element will be we vertically centered on the screen. Also if both left and right are zero, the element will be horizontally centered on the screen. But all this will not work without <code>margin: auto</code>. Can you help me understand how <code>margin</code> interacts with <code>top, bottom, left and right</code>?</p>
| [
{
"answer_id": 74334079,
"author": "Stephen Quan",
"author_id": 881441,
"author_profile": "https://Stackoverflow.com/users/881441",
"pm_score": 1,
"selected": true,
"text": " let obj = { };\n obj = { \"Jumlah SD\": 22 }; // i = 0\n obj = { \"Jumlah SD\": 22, \"Jumlah SMP\": 243}; // i = 1\n obj = { \"Jumlah SD\": 66, \"Jumlah SMP\": 243}; // i = 2\n obj = { \"Jumlah SD\": 66, \"Jumlah SMP\": 265}; // i = 3\n Object.keys(obj); // [ \"Jumlah SD\", \"Jumlah SMP\" ]\n Object.values(obj); // [ 66, 265 ]\n"
},
{
"answer_id": 74334082,
"author": "Mina",
"author_id": 11887902,
"author_profile": "https://Stackoverflow.com/users/11887902",
"pm_score": 2,
"selected": false,
"text": "reduce"
},
{
"answer_id": 74334086,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "const arr1 = [\n \"Jumlah SD\",\n \"Jumlah SMP\",\n \"Jumlah SD\",\n \"Jumlah SMP\"\n];\n\nconst arr2 = [\n \"22\",\n \"243\",\n \"44\",\n \"22\"\n];\n\ndict = {}\n\nfor (let i = 0; i < arr1.length; i++) {\n const key = arr1[i];\n if (key in dict) {\n dict[key] = String(Number(dict[key]) + Number(arr2[i]));\n } else {\n dict[key] = String(Number(arr2[i]));\n }\n}\n\nconst arr3 = Object.keys(dict);\nconst arr4 = Object.values(dict);\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74334091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19642087/"
] |
74,334,116 | <p>So Im iterating over rows of pixels that'll look like this</p>
<pre><code>row = [0, 0, 0, 0, 255, 255, 0, 0, 255, 0, 0, 0, 0, 0,0]
</code></pre>
<p>and I'll have another array called whiteLine which looks like</p>
<pre><code>whiteLine = [255, 255, 255, 255, 255, 255]
</code></pre>
<p>And i want to check if there are 6 white pixels in a row. Or basically check if the whiteLine array explicitly exists in the row array</p>
<pre class="lang-py prettyprint-override"><code>Example
row = [0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 0, 0, 0, 0, 0,0]
True
row = [0, 0, 0, 0, 255, 255, 0, 255, 255, 255, 0, 0, 255, 0, 0, 0, 0, 0,0]
False
</code></pre>
| [
{
"answer_id": 74334158,
"author": "ShlomiF",
"author_id": 5024514,
"author_profile": "https://Stackoverflow.com/users/5024514",
"pm_score": 1,
"selected": false,
"text": "row"
},
{
"answer_id": 74334176,
"author": "ThePyGuy",
"author_id": 9136348,
"author_profile": "https://Stackoverflow.com/users/9136348",
"pm_score": 1,
"selected": true,
"text": "sliding_window_view"
},
{
"answer_id": 74334367,
"author": "KS20000",
"author_id": 19741635,
"author_profile": "https://Stackoverflow.com/users/19741635",
"pm_score": -1,
"selected": false,
"text": "def checker(num):\n counter = 0\n Pass = False\n for i in num:\n counter += 1\n if (sum(num[counter:counter+6]) >= 1530):\n Pass = True\n\n\n return Pass \n\n\nchecker(row1) #True\nchecker(row2) #False\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74334116",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14162728/"
] |
74,334,137 | <p>I want my code to read only the first letter of what the user inputs, but for some reason it reads more than that when there is a space in between words. If there is no space it'll work fine by storing only the first char, but if there are 2 words it'll store the first variable, go to the next line of code, then jump back quickly and override that variable with the first char of the second word and so on so forth with multiple words. It doesn't make any sense for it to do that because I thought that space was a char, so I don't understand why it restarts the char count.</p>
<p>Here is the code:</p>
<pre><code>import java.util.Scanner;
public class test1 {
static Scanner scn = new Scanner(System.in);
static char yn;
public static void main(String[] args) {
System.out.println("Would you like to change anything? (Y/N)");
yn = scn.next().charAt(0);
yn = Character.toUpperCase(yn);
answer();
}
static void answer(){
// Loop until their answer is one of the options
while (yn != 'Y' && yn != 'N') {
System.out.println("Please input Y for yes or N for no");
System.out.println("Would you like to change anything? (Y/N)");
yn = scn.next().charAt(0);
yn = Character.toUpperCase(yn);
}
}
</code></pre>
<p>I tried to create a string variable, then after the user inputs their answer, the string variable would only store the first word then store the first char in the char variable, but that didn't seem to work.</p>
<p>Here is the code that I tried:</p>
<pre><code>import java.util.Scanner;
public class test1 {
static Scanner scn = new Scanner(System.in);
static char yn;
static String yesno;
public static void main(String[] args) {
System.out.println("Would you like to change anything? (Y/N)");
yesno = scn.next();
yn = yesno.charAt(0);
yn = Character.toUpperCase(yn);
answer();
}
static void answer(){
// Loop until their answer is one of the options
while (yn != 'Y' && yn != 'N') {
System.out.println("Please input Y for yes or N for no");
System.out.println("Would you like to change anything? (Y/N)");
yesno = scn.next();
yn = yesno.charAt(0);
yn = Character.toUpperCase(yn);
}
}
}
</code></pre>
| [
{
"answer_id": 74334158,
"author": "ShlomiF",
"author_id": 5024514,
"author_profile": "https://Stackoverflow.com/users/5024514",
"pm_score": 1,
"selected": false,
"text": "row"
},
{
"answer_id": 74334176,
"author": "ThePyGuy",
"author_id": 9136348,
"author_profile": "https://Stackoverflow.com/users/9136348",
"pm_score": 1,
"selected": true,
"text": "sliding_window_view"
},
{
"answer_id": 74334367,
"author": "KS20000",
"author_id": 19741635,
"author_profile": "https://Stackoverflow.com/users/19741635",
"pm_score": -1,
"selected": false,
"text": "def checker(num):\n counter = 0\n Pass = False\n for i in num:\n counter += 1\n if (sum(num[counter:counter+6]) >= 1530):\n Pass = True\n\n\n return Pass \n\n\nchecker(row1) #True\nchecker(row2) #False\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74334137",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18444616/"
] |
74,334,162 | <p><strong>Note: Error may be different but if you are getting any error when taking android build without any changes in code for past two days</strong></p>
<p>My Error - Failed to install the app. Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081</p>
<pre><code>error Failed to install the app. Make sure you have the Android development environment set up:
Error: Command failed: ./gradlew app:installDebug
-PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* Where: Build file '/Users/....../node_modules/react-native-month-year-picker/android/build.gradle' line: 115
* What went wrong: A problem occurred configuring project ':react-native-month-year-picker'.
> Could not resolve all files for configuration ':react-native-month-year-picker:implementation'.
> Could not resolve com.facebook.react:react-native:+.
Required by:
project :react-native-month-year-picker
> Cannot choose between the following variants of com.facebook.react:react-native:0.71.0-rc.0:
- debugVariantDefaultRuntimePublication
- releaseVariantDefaultRuntimePublication
All of them match the consumer attributes:
- Variant 'debugVariantDefaultRuntimePublication' capability com.facebook.react:react-native:0.71.0-rc.0:
</code></pre>
| [
{
"answer_id": 74334163,
"author": "ZFloc Technologies",
"author_id": 10657559,
"author_profile": "https://Stackoverflow.com/users/10657559",
"pm_score": 7,
"selected": true,
"text": "0.71.0-rc0"
},
{
"answer_id": 74364307,
"author": "Emmanuel Ang",
"author_id": 20218802,
"author_profile": "https://Stackoverflow.com/users/20218802",
"pm_score": 2,
"selected": false,
"text": "npm install --save-exact"
},
{
"answer_id": 74364389,
"author": "HarshitMadhav",
"author_id": 6243553,
"author_profile": "https://Stackoverflow.com/users/6243553",
"pm_score": -1,
"selected": false,
"text": " exclusiveContent {\n // We get React Native's Android binaries exclusively through npm,\n // from a local Maven repo inside node_modules/react-native/.\n // (The use of exclusiveContent prevents looking elsewhere like Maven Central\n // and potentially getting a wrong version.)\n filter {\n includeGroup \"com.facebook.react\"\n }\n forRepository {\n maven {\n url \"$rootDir/../node_modules/react-native/android\"\n }\n }\n }\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74334162",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10657559/"
] |
74,334,211 | <p>This is my current root:</p>
<pre><code>main
→ index.html
→ page1.html
</code></pre>
<p>I would like to navigate the user on <code>page1.html</code> when a <code>button</code> is clicked. However, what I don't want here is the url to have <code>page1.html</code>. It should rather have <code>page1</code></p>
<p>For example, look at this link from discord: <a href="https://discord.com/app" rel="nofollow noreferrer">https://discord.com/app</a>
<br>
They don't have <code>/app.html</code> but rather <code>/app</code> which makes it easier for users to understand navigations. Similarly for <a href="https://stackoverflow.com/tags">https://stackoverflow.com/tags</a>.
<br>
I would like to achieve this using pure <code>HTML</code> and/or <code>JS</code>. I'm looking for the most efficient and fastest methods to achieve this.</p>
| [
{
"answer_id": 74334278,
"author": "Usitha Indeewara",
"author_id": 19099302,
"author_profile": "https://Stackoverflow.com/users/19099302",
"pm_score": 1,
"selected": false,
"text": "npm init -y\nnpm install --save express\n"
},
{
"answer_id": 74334294,
"author": "WhiteToggled",
"author_id": 20067906,
"author_profile": "https://Stackoverflow.com/users/20067906",
"pm_score": 3,
"selected": true,
"text": "RewriteCond %{REQUEST_FILENAME} !-d\nRewriteCond %{REQUEST_FILENAME} !-f\nRewriteRule ^([^\\.]+)$ $1.html [NC, L]\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74334211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15042008/"
] |
74,334,236 | <p>I'm trying to add a category section to my blog post form using django, the category field is created and I haven't got any error but the dropdown is not created.</p>
<p>models.py</p>
<pre><code>from django.db import models
from django.contrib.auth.models import User
from django.urls import reverse
class Category(models.Model):
name = models.CharField(max_length=200)
def __str__(self):
return self.name
def get_absolute_url(self):
return reverse('posts')
class Post(models.Model):
STATUS = [
(0, 'Drafted'),
(1, 'Published'),
]
title = models.CharField(max_length=200, unique=True)
slug = models.SlugField(max_length=200, unique=True)
author = models.ForeignKey(User, on_delete=models.CASCADE)
created_on = models.DateTimeField(auto_now_add=True)
published_on = models.DateTimeField(auto_now=True)
content = models.TextField()
status = models.IntegerField(choices=STATUS, default=0)
category = models.CharField(max_length=200, default='uncategorized')
class Meta:
ordering = ['-created_on']
def __str__(self):
return self.title
def get_absolute_url(self):
return reverse('my_blog:posts')
</code></pre>
<p>forms.py</p>
<pre><code>from django import forms
from .models import Post
class PostForm(forms.ModelForm):
class Meta:
model = Post
fields = ('title', 'author', 'category', 'content')
widgets = {
'title': forms.TextInput(attrs={'class': 'form-control'}),
'author': forms.Select(attrs={'class': 'form-control'}),
'category': forms.Select(attrs={'class': 'form-control'}),
'content': forms.Textarea(attrs={'class': 'form-control'}),
}
</code></pre>
<p>admin.py</p>
<pre><code>from django.contrib import admin
from .models import Post, Category, Comment
admin.site.register(Post)
admin.site.register(Category)
</code></pre>
<p>This method was based on a tutorial and I'm wondering if this is the right way to create category fields. Any help, please?</p>
| [
{
"answer_id": 74334278,
"author": "Usitha Indeewara",
"author_id": 19099302,
"author_profile": "https://Stackoverflow.com/users/19099302",
"pm_score": 1,
"selected": false,
"text": "npm init -y\nnpm install --save express\n"
},
{
"answer_id": 74334294,
"author": "WhiteToggled",
"author_id": 20067906,
"author_profile": "https://Stackoverflow.com/users/20067906",
"pm_score": 3,
"selected": true,
"text": "RewriteCond %{REQUEST_FILENAME} !-d\nRewriteCond %{REQUEST_FILENAME} !-f\nRewriteRule ^([^\\.]+)$ $1.html [NC, L]\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74334236",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20408779/"
] |
74,334,246 | <p>I am trying to create multiple GCP projects using terraform, In each project i am trying to create multiple SA's and custom roles.</p>
<p>As as initial step i am able to create multiple projects but i am unable to create resources in those projects.</p>
<p>Eg:</p>
<pre><code>resource "google_project" "project_creation" {
count = 5
name = "terraform-testing${count.index + 1}"
project_id = "terraform-testing${count.index + 1}"
}
output "gcp_projects" {
value = ["${google_project.project_creation[*].id}"]
}
resource "google_project_iam_custom_role" "role" {
project = google_project.project_creation[*].id
role_id = "myCustomRole"
title = "Bigquery Role"
description = "Bigquery Role"
permissions = ["roles/bigquery.admin"]
}
</code></pre>
<p><strong>Error:</strong>
│ google_project.project_creation is tuple with 2 elements
│ Inappropriate value for attribute "project": string required.</p>
| [
{
"answer_id": 74334333,
"author": "Chris Doyle",
"author_id": 1212401,
"author_profile": "https://Stackoverflow.com/users/1212401",
"pm_score": 2,
"selected": true,
"text": "resource \"google_project\" \"project_creation\" {\n count = 5\n name = \"terraform-testing${count.index + 1}\"\n project_id = \"terraform-testing${count.index + 1}\"\n}\n\noutput \"gcp_projects\" {\n value = [\"${google_project.project_creation[*].id}\"]\n}\n\nresource \"google_project_iam_custom_role\" \"role\" {\n count = length(google_project.project_creation)\n project = google_project.project_creation[count.index].id\n role_id = \"myCustomRole\"\n title = \"Bigquery Role\"\n description = \"Bigquery Role\"\n permissions = [\"roles/bigquery.admin\"]\n}\n"
},
{
"answer_id": 74353851,
"author": "Raphael Santos",
"author_id": 20444473,
"author_profile": "https://Stackoverflow.com/users/20444473",
"pm_score": 0,
"selected": false,
"text": "variable \"project\" {\n default = [\"project1\",\"project2\",\"project3\"]\n}\n \nresource \"google_project\" \"project_create\" {\n for_each = toset(var.project)\n name = each.value\n project_id = each.value\n}\n\nresource \"google_project_iam_custom_role\" \"iam_member\" {\n for_each = toset(var.project)\n project = each.value\n role_id = \"myCustomRole\"\n title = \"Bigquery Role\"\n description = \"Bigquery Role\"\n permissions = [\"roles/bigquery.admin\"]\n}\n \noutput \"gcp_projects\" {\n value = values(google_project.project_create).*.id\n}\n\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74334246",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10195404/"
] |
74,334,249 | <p>I have this array</p>
<pre><code>const data = [
{"id": "One", "number": 100},
{"id": "One", "number": 150},
{"id": "One", "number": 200},
{"id": "Two", "number": 50},
{"id": "Two", "number": 100},
{"id": "Three", "number": 10},
{"id": "Three", "number": 90}
];
</code></pre>
<p>and I want to get the sum for each id and create a new array like this:</p>
<pre><code>[
{"id": "One", "number": 450},
{"id": "Two", "number": 150},
{"id": "Three", "number": 100},
]
</code></pre>
| [
{
"answer_id": 74334300,
"author": "flyingfox",
"author_id": 3176419,
"author_profile": "https://Stackoverflow.com/users/3176419",
"pm_score": 1,
"selected": false,
"text": "reduce()"
},
{
"answer_id": 74334358,
"author": "Asraf",
"author_id": 20361860,
"author_profile": "https://Stackoverflow.com/users/20361860",
"pm_score": 3,
"selected": true,
"text": "reduce()"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74334249",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20430746/"
] |
74,334,274 | <p>In the data below I would like proc sql to select the minimum date for subject 123 as the missing date.</p>
<pre><code>data visit;
input subject $1-3 dtc $4-24 ;
cards;
123 2014-01-15T00:00
123
123 2014-01-17T00:00:00
124 2014-01-15T00:00:00
124 2014-01-15T00:00:00
124 2014-01-17T00:00:00
;
run;
proc sql;
create table want. as
select distinct subject, min(dtc) as mindt format = date9.
from have
where subject ne ''
group by subject;
quit;
</code></pre>
| [
{
"answer_id": 74334809,
"author": "Richard",
"author_id": 1249962,
"author_profile": "https://Stackoverflow.com/users/1249962",
"pm_score": 1,
"selected": false,
"text": "MIN()"
},
{
"answer_id": 74336915,
"author": "gregor",
"author_id": 20198546,
"author_profile": "https://Stackoverflow.com/users/20198546",
"pm_score": 0,
"selected": false,
"text": "proc sort data=have out=have_sorted; \n by subject dtc;\nquit;\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74334274",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14461082/"
] |
74,334,308 | <p>I know this concept isn't unique to react, but i couldn't find another reason to do this apart from shorter and more readable code.</p>
| [
{
"answer_id": 74334402,
"author": "kentomax",
"author_id": 8600591,
"author_profile": "https://Stackoverflow.com/users/8600591",
"pm_score": -1,
"selected": false,
"text": "function UserInfo({username}){\n return (\n <div className=\"UserInfo\">\n <div className=\"UserInfo-name\">\n {username}\n </div>\n </div>\n );\n }\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74334308",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7396271/"
] |
74,334,332 | <p>I have a script that opens a UI which is used to open another spreadsheet</p>
<p>When I click to open the link I would like the UI to close automatically if possible.</p>
<pre><code>function ServiceSetServiceSheets(){
var html = "<a href='https://docs.google.com/spreadsheets/d/xxxxxxxxxxxxxxxxxxxxxx'; target='_blank'>Open The Service Sheet</a>";
var anchor = HtmlService.createHtmlOutput(html).setSandboxMode(HtmlService.SandboxMode.IFRAME).setHeight(60).setWidth(150);
SpreadsheetApp.getUi().showModalDialog(anchor,"Click the link to")
}
</code></pre>
<p>Can anyone help please?</p>
| [
{
"answer_id": 74334402,
"author": "kentomax",
"author_id": 8600591,
"author_profile": "https://Stackoverflow.com/users/8600591",
"pm_score": -1,
"selected": false,
"text": "function UserInfo({username}){\n return (\n <div className=\"UserInfo\">\n <div className=\"UserInfo-name\">\n {username}\n </div>\n </div>\n );\n }\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74334332",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8429538/"
] |
74,334,338 | <p>My main issue is with printing the index in the following situations.</p>
<pre><code>catNames = []
while True:
print('Enter the name of cat ' + str(len(catNames)+1) + ' (or enter nothing to stop.):')
name = input()
if name == '':
break
catNames = catNames + [name]
print('The cat names are:')
for name in catNames:
print(str(catNames.index(name)+1) + '. ' + name)
</code></pre>
<p>In this first scenario, the results are</p>
<pre><code>Enter the name of cat 1 (or enter nothing to stop.):
george
Enter the name of cat 2 (or enter nothing to stop.):
sally
Enter the name of cat 3 (or enter nothing to stop.):
chloe
Enter the name of cat 4 (or enter nothing to stop.):
The cat names are:
1. george
2. sally
3. chloe
</code></pre>
<p>Which is exactly as expected.</p>
<p>However, when I try this for another scenario, it doesn't work. The next example is as below:</p>
<pre><code>supplies = ['pens', 'staplers', 'flamethrowers', 'binders']
for i in supplies:
print('Index ' + str(supplies.index(i)+1) + 'in supplies is: ' + supplies[i])
</code></pre>
<p>I instead get the error stating "TypeError: list indices must be integers or slices, not str".</p>
<p>I understand there's a better way to express the supplies example using <code>range(len(supplies)</code> but I'm just keen to understand why using the <code>for i in supplies</code> version doesn't work, although it worked for <code>catNames</code>. Thanks!</p>
| [
{
"answer_id": 74334386,
"author": "azro",
"author_id": 7212686,
"author_profile": "https://Stackoverflow.com/users/7212686",
"pm_score": 3,
"selected": true,
"text": "for name in catNames:\n print(str(catNames.index(name)+1) + '. ' + name)\n"
},
{
"answer_id": 74334413,
"author": "Dmitriy Neledva",
"author_id": 16786350,
"author_profile": "https://Stackoverflow.com/users/16786350",
"pm_score": 1,
"selected": false,
"text": "\"TypeError: list indices must be integers or slices, not str\"."
},
{
"answer_id": 74335099,
"author": "jspoh",
"author_id": 20255176,
"author_profile": "https://Stackoverflow.com/users/20255176",
"pm_score": 1,
"selected": false,
"text": "supplies = ['pens', 'staplers', 'flamethrowers', 'binders']\nfor i in supplies:\n print('Index ' + str(supplies.index(i)+1) + 'in supplies is: ' + supplies[i])\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74334338",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16117438/"
] |
74,334,349 | <p>In a for loop, let's assume it contains 100 iterations, and what I need is, i need to print the first element and skip the next two element, and then need to prit the fourth element.. for example,</p>
<pre><code>0 #should print
1 #should skip
2 #should skip
3 #should print
4 #should skip
5 #should skip
6 #should print
.
. like wise
</code></pre>
<p>I tried some existing skipping solutions out this platform, but didn't fit for my problem.
I know the continue statement allows you to skip over the current iteration, but I can't figure out how to <strong>skip the next two iterations</strong>. Ttried some itertool fuctions also.</p>
| [
{
"answer_id": 74334368,
"author": "azro",
"author_id": 7212686,
"author_profile": "https://Stackoverflow.com/users/7212686",
"pm_score": 1,
"selected": true,
"text": "range"
},
{
"answer_id": 74334377,
"author": "jspoh",
"author_id": 20255176,
"author_profile": "https://Stackoverflow.com/users/20255176",
"pm_score": -1,
"selected": false,
"text": "arr = [1,2,3,4,5,6,7,8,9,10]\nskip_count = 2 # how many to skip\ncounter = skip_count\n\nfor num in arr:\n if counter == skip_count:\n counter = 0\n print(num)\n else:\n counter += 1\n"
},
{
"answer_id": 74334391,
"author": "Jiho Choi",
"author_id": 7024693,
"author_profile": "https://Stackoverflow.com/users/7024693",
"pm_score": 0,
"selected": false,
"text": "enumerate"
},
{
"answer_id": 74334407,
"author": "TheLazyScripter",
"author_id": 4732620,
"author_profile": "https://Stackoverflow.com/users/4732620",
"pm_score": 0,
"selected": false,
"text": "range(start, stop, step)"
},
{
"answer_id": 74334451,
"author": "C-3PO",
"author_id": 4667669,
"author_profile": "https://Stackoverflow.com/users/4667669",
"pm_score": 0,
"selected": false,
"text": "enumerate"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74334349",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9549067/"
] |
74,334,351 | <p>I have this issue where I need to square line in Pascal's triangle and when it comes to big numbers it only outputs <code>0</code></p>
<pre><code>unsigned long sum_squared(const int line){
unsigned long long n = 2*line;
unsigned long long x1 = factorial(line);
unsigned long long k = x1*x1;
unsigned long long x = factorial(n)/(k);
return x;
}
unsigned long long factorial(unsigned long long n) {
if (n == 0){
return 1;
}
return n * factorial(n - 1);
}
</code></pre>
<p>I test it with:</p>
<pre><code>printf("%lu\n", sum_squared(14));
</code></pre>
| [
{
"answer_id": 74334378,
"author": "Clifford",
"author_id": 168986,
"author_profile": "https://Stackoverflow.com/users/168986",
"pm_score": 1,
"selected": false,
"text": "unsigned long long"
},
{
"answer_id": 74334387,
"author": "0___________",
"author_id": 6110094,
"author_profile": "https://Stackoverflow.com/users/6110094",
"pm_score": 0,
"selected": false,
"text": "28! = 304888344611713860501504000000"
},
{
"answer_id": 74337656,
"author": "Bob__",
"author_id": 4944425,
"author_profile": "https://Stackoverflow.com/users/4944425",
"pm_score": 1,
"selected": true,
"text": "⎛ 2n ⎞ (2n)!\n⎜ ⎟ = ―――――\n⎝ n ⎠ n!·n!\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74334351",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18930163/"
] |
74,334,362 | <p>So I was Solving a leetcode Problem and one dumb mistake made in debugg for more than an hour.
<a href="https://leetcode.com/problems/longest-palindrome-by-concatenating-two-letter-words/" rel="nofollow noreferrer">Leetcode Question</a></p>
<p>Answers(both working and not working)
Working code:
`</p>
<pre><code>class Solution {
public:
int longestPalindrome(vector<string>& words) {
unordered_map<string,int> map;
for(string s:words){
map[s]++;
}
bool isOdd = false;
int ans = 0;
for(auto i:map){
string rv = i.first;
reverse(rv.begin(),rv.end());
if(i.first[0]==i.first[1]){
if(i.second%2==0)
ans+=i.second;
else{
ans+= i.second-1;
isOdd = true;
}
}
else if(i.first[0]<i.first[1] && map.count(rv)){
ans += 2*min(i.second,map[rv]);
}
}
if(isOdd){
ans++;
}
return 2*ans;
}
};
</code></pre>
<p>Not working code:
`</p>
<pre><code>class Solution {
public:
int longestPalindrome(vector<string>& words) {
unordered_map<string,int> map;
for(string s:words){
map[s]++;
}
bool isOdd = false;
int ans = 0;
for(auto i:map){
string rv = i.first;
reverse(rv.begin(),rv.end());
if(i.first[0]==i.first[1]){
if(i.second%2==0)
ans+=i.second;
else{
ans+= i.second-1;
isOdd = true;
}
}
else if(i.first[0]<i.first[1] && map[rv]){
ans += 2*min(i.second,map[rv]);
}
}
if(isOdd){
ans++;
}
return 2*ans;
}
};
</code></pre>
<p>The only difference between both code is map[rv] ==> map.count(rv)</p>
<p>test case which is giving error:</p>
<pre><code>["oo","vv","uu","gg","pp","ff","ss","yy","vv","cc","rr","ig","jj","uu","ig","gb","zz","xx","ff","bb","ii","dd","ii",
"ee","mm","qq","ig","ww","ss","tt","vv","oo","ww","ss","bi","ff","gg","bi","jj","ee","gb",
"qq","bg","nn","vv","oo","bb","pp","ww","qq","mm","ee","tt","hh","ss","tt","ee","gi","ig","uu","ff","zz",
"ii","ff","ss","gi","yy","gb","mm","pp","uu","kk","jj","ee"]
</code></pre>
<p>Can anyone please help me?</p>
<p>I've tried googling this stuff but couldn't find it. then i've tried asking few people on discord. but no progress.
I just wanna know why above(not working part) code in not working.
What is the deal with map[key] and map.count(key)?
When should i use which one?</p>
| [
{
"answer_id": 74334405,
"author": "A M",
"author_id": 9666018,
"author_profile": "https://Stackoverflow.com/users/9666018",
"pm_score": 3,
"selected": true,
"text": "std::map.count()"
},
{
"answer_id": 74334406,
"author": "Jarod42",
"author_id": 2684539,
"author_profile": "https://Stackoverflow.com/users/2684539",
"pm_score": 2,
"selected": false,
"text": "map[rv]"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74334362",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17991749/"
] |
74,334,365 | <p>Using the iterator <code>*ngFor</code> converts a string union literal type <code>("apple" | "banana")</code> to a string type. When I use it as an index of an array expecting the correct string union literal type I get the error:</p>
<blockquote>
<p>Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'FruitCollection'.</p>
</blockquote>
<p><code>apple-banana-component.ts</code>:</p>
<pre><code>import { Component, OnInit } from '@angular/core';
const Fruits = ["apple", "banana"] as const;
type Fruit = typeof Fruits[number]; // "apple" | "banana"
type FruitCollection = { [fruit in Fruit]: number }; // {apple: number, banana: number}
@Component({
selector: 'app-apple-banana',
templateUrl: './apple-banana.component.html'
})
export class AppleBananaComponent implements OnInit {
fruitBasket: FruitCollection = {
apple: 10,
banana: 10
}
fruitEaten: FruitCollection = {
apple: 0,
banana: 0
}
constructor() { }
ngOnInit(): void { }
eatFruit(fruit: Fruit) {
this.fruitEaten[fruit]++;
this.fruitBasket[fruit]--;
}
}
</code></pre>
<p><code>apple-banana-component.html</code>:</p>
<pre><code><div>
You have eaten {{fruitEaten['apple']}} apples and {{fruitEaten['banana']}} bananas. <!-- works -->
<div *ngFor="let fruit of fruitBasket | keyvalue">
{{fruit.key}}:
{{fruit.value}} in basket,
{{fruitEaten[fruit.key]}} <!-- ERROR: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'FruitCollection'. -->
eaten.
<button (click)="eatFruit($any(fruit.key))">eat {{fruit.key}}</button>
</div>
</div>
</code></pre>
<p>For some reason I can't comprehend, <code>$any(fruit.key)</code> works inside <code>eatFruit()</code> but not inside <code>fruitBasket[]</code>.</p>
<pre><code>{{fruitEaten[fruit.key as Fruit]}} <!-- ERROR: Parser Error: Missing expected ] at column 22 [...] -->
{{fruitEaten[fruit.key as keyof typeof fruitEaten]}} <!-- ERROR: Parser Error: Missing expected ] at column 22 [...] -->
{{fruitEaten[$any(fruit.key)]}} <!-- ERROR: Element implicitly has an 'any' type because expression of type 'any' can't be used to index type 'FruitCollection'. -->
</code></pre>
| [
{
"answer_id": 74334472,
"author": "Tobias S.",
"author_id": 8613630,
"author_profile": "https://Stackoverflow.com/users/8613630",
"pm_score": 2,
"selected": true,
"text": "key"
},
{
"answer_id": 74334537,
"author": "socebic",
"author_id": 20430838,
"author_profile": "https://Stackoverflow.com/users/20430838",
"pm_score": 2,
"selected": false,
"text": "import { Component, OnInit } from '@angular/core';\n\nconst Fruits = [\"apple\", \"banana\"] as const;\ntype Fruit = typeof Fruits[number]; // \"apple\" | \"banana\"\ntype FruitCollection = { [fruit in Fruit]: number }; // {apple: number, banana: number}\n\n@Component({\n selector: 'app-apple-banana',\n templateUrl: './apple-banana.component.html'\n})\nexport class AppleBananaComponent implements OnInit {\n fruits = Fruits;\n fruitBasket: FruitCollection = {\n apple: 10,\n banana: 10\n }\n fruitEaten: FruitCollection = {\n apple: 0,\n banana: 0\n }\n constructor() { }\n ngOnInit(): void { }\n eatFruit(fruit: Fruit) {\n this.fruitEaten[fruit]++;\n this.fruitBasket[fruit]--;\n }\n}\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74334365",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20430838/"
] |
74,334,366 | <p>I'm running a kubernetes cluster (bare metal) with a mongodb (version 4, as my server cannot handle newer versions) replicaset (2 replicas), which is initially working, but from time to time (sometimes 24 hours, somtimes 10 days) one or more mongodb pods are failing.</p>
<pre><code>Warning BackOff 2m9s (x43454 over 6d13h) kubelet Back-off restarting failed container
</code></pre>
<p>The relevant part of the logs should be</p>
<pre><code>DBPathInUse: Unable to create/open the lock file: /bitnami/mongodb/data/db/mongod.lock (Read-only file system). Ensure the user executing mongod is the owner of the lock file and has the appropriate permissions. Also make sure that another mongod instance is not already running on the /bitnami/mongodb/data/db directory
</code></pre>
<p>But I do not change anything and initially it is working. Also the second pod is currently running (but which will fail the next days).</p>
<p>I'm using longhorn (before I tried nfs) for the storage and I installed mongodb using bitnami helm chart with these values:</p>
<pre><code>image:
registry: docker.io
repository: bitnami/mongodb
digest: "sha256:916202d7af766dd88c2fff63bf711162c9d708ac7a3ffccd2aa812e3f03ae209" # tag: 4.4.15
pullPolicy: IfNotPresent
architecture: replicaset
replicaCount: 2
updateStrategy:
type: RollingUpdate
containerPorts:
mongodb: 27017
auth:
enabled: true
rootUser: root
rootPassword: "password"
usernames: ["user"]
passwords: ["userpass"]
databases: ["db"]
service:
portName: mongodb
ports:
mongodb: 27017
persistence:
enabled: true
accessModes:
- ReadWriteOnce
size: 8Gi
volumePermissions:
enabled: true
livenessProbe:
enabled: false
readinessProbe:
enabled: false
</code></pre>
<p><strong>logs</strong></p>
<pre><code>mongodb 21:25:05.55 INFO ==> Advertised Hostname: mongodb-1.mongodb-headless.mongodb.svc.cluster.local
mongodb 21:25:05.55 INFO ==> Advertised Port: 27017
mongodb 21:25:05.56 INFO ==> Pod name doesn't match initial primary pod name, configuring node as a secondary
mongodb 21:25:05.59
mongodb 21:25:05.59 Welcome to the Bitnami mongodb container
mongodb 21:25:05.60 Subscribe to project updates by watching https://github.com/bitnami/containers
mongodb 21:25:05.60 Submit issues and feature requests at https://github.com/bitnami/containers/issues
mongodb 21:25:05.60
mongodb 21:25:05.60 INFO ==> ** Starting MongoDB setup **
mongodb 21:25:05.64 INFO ==> Validating settings in MONGODB_* env vars...
mongodb 21:25:05.78 INFO ==> Initializing MongoDB...
mongodb 21:25:05.82 INFO ==> Deploying MongoDB with persisted data...
mongodb 21:25:05.83 INFO ==> Writing keyfile for replica set authentication...
mongodb 21:25:05.88 INFO ==> ** MongoDB setup finished! **
mongodb 21:25:05.92 INFO ==> ** Starting MongoDB **
{"t":{"$date":"2022-10-29T21:25:05.961+00:00"},"s":"I", "c":"CONTROL", "id":20698, "ctx":"main","msg":"***** SERVER RESTARTED *****"}
{"t":{"$date":"2022-10-29T21:25:05.963+00:00"},"s":"I", "c":"CONTROL", "id":23285, "ctx":"main","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
{"t":{"$date":"2022-10-29T21:25:05.968+00:00"},"s":"W", "c":"ASIO", "id":22601, "ctx":"main","msg":"No TransportLayer configured during NetworkInterface startup"}
{"t":{"$date":"2022-10-29T21:25:05.968+00:00"},"s":"I", "c":"NETWORK", "id":4648601, "ctx":"main","msg":"Implicit TCP FastOpen unavailable. If TCP FastOpen is required, set tcpFastOpenServer, tcpFastOpenClient, and tcpFastOpenQueueSize."}
{"t":{"$date":"2022-10-29T21:25:05.969+00:00"},"s":"W", "c":"ASIO", "id":22601, "ctx":"main","msg":"No TransportLayer configured during NetworkInterface startup"}
{"t":{"$date":"2022-10-29T21:25:06.011+00:00"},"s":"I", "c":"STORAGE", "id":4615611, "ctx":"initandlisten","msg":"MongoDB starting","attr":{"pid":1,"port":27017,"dbPath":"/bitnami/mongodb/data/db","architecture":"64-bit","host":"mongodb-1"}}
{"t":{"$date":"2022-10-29T21:25:06.011+00:00"},"s":"I", "c":"CONTROL", "id":23403, "ctx":"initandlisten","msg":"Build Info","attr":{"buildInfo":{"version":"4.4.15","gitVersion":"bc17cf2c788c5dda2801a090ea79da5ff7d5fac9","openSSLVersion":"OpenSSL 1.1.1n 15 Mar 2022","modules":[],"allocator":"tcmalloc","environment":{"distmod":"debian10","distarch":"x86_64","target_arch":"x86_64"}}}}
{"t":{"$date":"2022-10-29T21:25:06.012+00:00"},"s":"I", "c":"CONTROL", "id":51765, "ctx":"initandlisten","msg":"Operating System","attr":{"os":{"name":"PRETTY_NAME=\"Debian GNU/Linux 10 (buster)\"","version":"Kernel 5.15.0-48-generic"}}}
{"t":{"$date":"2022-10-29T21:25:06.012+00:00"},"s":"I", "c":"CONTROL", "id":21951, "ctx":"initandlisten","msg":"Options set by command line","attr":{"options":{"config":"/opt/bitnami/mongodb/conf/mongodb.conf","net":{"bindIp":"*","ipv6":false,"port":27017,"unixDomainSocket":{"enabled":true,"pathPrefix":"/opt/bitnami/mongodb/tmp"}},"processManagement":{"fork":false,"pidFilePath":"/opt/bitnami/mongodb/tmp/mongodb.pid"},"replication":{"enableMajorityReadConcern":true,"replSetName":"rs0"},"security":{"authorization":"disabled","keyFile":"/opt/bitnami/mongodb/conf/keyfile"},"setParameter":{"enableLocalhostAuthBypass":"true"},"storage":{"dbPath":"/bitnami/mongodb/data/db","directoryPerDB":false,"journal":{"enabled":true}},"systemLog":{"destination":"file","logAppend":true,"logRotate":"reopen","path":"/opt/bitnami/mongodb/logs/mongodb.log","quiet":false,"verbosity":0}}}}
{"t":{"$date":"2022-10-29T21:25:06.013+00:00"},"s":"E", "c":"STORAGE", "id":20557, "ctx":"initandlisten","msg":"DBException in initAndListen, terminating","attr":{"error":"DBPathInUse: Unable to create/open the lock file: /bitnami/mongodb/data/db/mongod.lock (Read-only file system). Ensure the user executing mongod is the owner of the lock file and has the appropriate permissions. Also make sure that another mongod instance is not already running on the /bitnami/mongodb/data/db directory"}}
{"t":{"$date":"2022-10-29T21:25:06.013+00:00"},"s":"I", "c":"REPL", "id":4784900, "ctx":"initandlisten","msg":"Stepping down the ReplicationCoordinator for shutdown","attr":{"waitTimeMillis":10000}}
{"t":{"$date":"2022-10-29T21:25:06.014+00:00"},"s":"I", "c":"COMMAND", "id":4784901, "ctx":"initandlisten","msg":"Shutting down the MirrorMaestro"}
{"t":{"$date":"2022-10-29T21:25:06.014+00:00"},"s":"I", "c":"SHARDING", "id":4784902, "ctx":"initandlisten","msg":"Shutting down the WaitForMajorityService"}
{"t":{"$date":"2022-10-29T21:25:06.014+00:00"},"s":"I", "c":"NETWORK", "id":20562, "ctx":"initandlisten","msg":"Shutdown: going to close listening sockets"}
{"t":{"$date":"2022-10-29T21:25:06.014+00:00"},"s":"I", "c":"NETWORK", "id":4784905, "ctx":"initandlisten","msg":"Shutting down the global connection pool"}
{"t":{"$date":"2022-10-29T21:25:06.014+00:00"},"s":"I", "c":"STORAGE", "id":4784906, "ctx":"initandlisten","msg":"Shutting down the FlowControlTicketholder"}
{"t":{"$date":"2022-10-29T21:25:06.014+00:00"},"s":"I", "c":"-", "id":20520, "ctx":"initandlisten","msg":"Stopping further Flow Control ticket acquisitions."}
{"t":{"$date":"2022-10-29T21:25:06.014+00:00"},"s":"I", "c":"REPL", "id":4784907, "ctx":"initandlisten","msg":"Shutting down the replica set node executor"}
{"t":{"$date":"2022-10-29T21:25:06.014+00:00"},"s":"I", "c":"NETWORK", "id":4784918, "ctx":"initandlisten","msg":"Shutting down the ReplicaSetMonitor"}
{"t":{"$date":"2022-10-29T21:25:06.014+00:00"},"s":"I", "c":"SHARDING", "id":4784921, "ctx":"initandlisten","msg":"Shutting down the MigrationUtilExecutor"}
{"t":{"$date":"2022-10-29T21:25:06.014+00:00"},"s":"I", "c":"CONTROL", "id":4784925, "ctx":"initandlisten","msg":"Shutting down free monitoring"}
{"t":{"$date":"2022-10-29T21:25:06.014+00:00"},"s":"I", "c":"STORAGE", "id":4784927, "ctx":"initandlisten","msg":"Shutting down the HealthLog"}
{"t":{"$date":"2022-10-29T21:25:06.014+00:00"},"s":"I", "c":"STORAGE", "id":4784929, "ctx":"initandlisten","msg":"Acquiring the global lock for shutdown"}
{"t":{"$date":"2022-10-29T21:25:06.014+00:00"},"s":"I", "c":"-", "id":4784931, "ctx":"initandlisten","msg":"Dropping the scope cache for shutdown"}
{"t":{"$date":"2022-10-29T21:25:06.014+00:00"},"s":"I", "c":"FTDC", "id":4784926, "ctx":"initandlisten","msg":"Shutting down full-time data capture"}
{"t":{"$date":"2022-10-29T21:25:06.015+00:00"},"s":"I", "c":"CONTROL", "id":20565, "ctx":"initandlisten","msg":"Now exiting"}
{"t":{"$date":"2022-10-29T21:25:06.015+00:00"},"s":"I", "c":"CONTROL", "id":23138, "ctx":"initandlisten","msg":"Shutting down","attr":{"exitCode":100}}
</code></pre>
<p><strong>Update</strong></p>
<p>I checked the syslog and before the the logs <code>Nov 14 23:07:17 k8s-worker2 kubelet[752]: E1114 23:07:17.749057 752 pod_workers.go:951] "Error syncing pod, skipping" err="failed to \"StartContainer\" for \"mongodb\" with CrashLoopBackOff: \"back-off 10s restarting failed container=mongodb pod=mongodb-2_mongodb(314f2776-ced4-4ba3-b90b-f927dc079770)\"" pod="mongodb/mongodb-2" podUID=314f2776-ced4-4ba3-b90b-f927dc079770</code></p>
<p>I find these logs:</p>
<pre><code>Nov 14 23:06:59 k8s-worker2 kernel: [3413829.341806] sd 2:0:0:1: [sda] tag#42 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_OK cmd_age=11s
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.341866] sd 2:0:0:1: [sda] tag#42 Sense Key : Medium Error [current]
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.341891] sd 2:0:0:1: [sda] tag#42 Add. Sense: Unrecovered read error
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.341899] sd 2:0:0:1: [sda] tag#42 CDB: Write(10) 2a 00 00 85 1f b8 00 00 40 00
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.341912] blk_update_request: critical medium error, dev sda, sector 8724408 op 0x1:(WRITE) flags 0x800 phys_seg 8 prio class 0
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.352012] Aborting journal on device sda-8.
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.354980] EXT4-fs error (device sda) in ext4_reserve_inode_write:5726: Journal has aborted
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.355103] sd 2:0:0:1: [sda] tag#40 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_OK cmd_age=15s
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.357056] sd 2:0:0:1: [sda] tag#40 Sense Key : Medium Error [current]
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.357061] sd 2:0:0:1: [sda] tag#40 Add. Sense: Unrecovered read error
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.357066] sd 2:0:0:1: [sda] tag#40 CDB: Write(10) 2a 00 00 44 14 88 00 00 10 00
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.357068] blk_update_request: critical medium error, dev sda, sector 4461704 op 0x1:(WRITE) flags 0x800 phys_seg 2 prio class 0
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.357088] EXT4-fs error (device sda): ext4_dirty_inode:5922: inode #131080: comm mongod: mark_inode_dirty error
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.359566] EXT4-fs warning (device sda): ext4_end_bio:344: I/O error 7 writing to inode 131081 starting block 557715)
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.361432] EXT4-fs error (device sda) in ext4_dirty_inode:5923: Journal has aborted
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.362792] Buffer I/O error on device sda, logical block 557713
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.364010] Buffer I/O error on device sda, logical block 557714
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.365222] sd 2:0:0:1: [sda] tag#43 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_OK cmd_age=8s
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.365228] sd 2:0:0:1: [sda] tag#43 Sense Key : Medium Error [current]
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.365230] sd 2:0:0:1: [sda] tag#43 Add. Sense: Unrecovered read error
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.365233] sd 2:0:0:1: [sda] tag#43 CDB: Write(10) 2a 00 00 44 28 38 00 00 08 00
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.365234] blk_update_request: critical medium error, dev sda, sector 4466744 op 0x1:(WRITE) flags 0x0 phys_seg 1 prio class 0
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.367434] EXT4-fs warning (device sda): ext4_end_bio:344: I/O error 7 writing to inode 131083 starting block 558344)
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.367442] Buffer I/O error on device sda, logical block 558343
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.368593] sd 2:0:0:1: [sda] tag#41 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_OK cmd_age=15s
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.368597] sd 2:0:0:1: [sda] tag#41 Sense Key : Medium Error [current]
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.368599] sd 2:0:0:1: [sda] tag#41 Add. Sense: Unrecovered read error
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.368602] sd 2:0:0:1: [sda] tag#41 CDB: Write(10) 2a 00 00 44 90 70 00 00 10 00
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.368604] blk_update_request: critical medium error, dev sda, sector 4493424 op 0x1:(WRITE) flags 0x800 phys_seg 2 prio class 0
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.370907] EXT4-fs warning (device sda): ext4_end_bio:344: I/O error 7 writing to inode 131081 starting block 561680)
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.370946] sd 2:0:0:1: [sda] tag#39 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_OK cmd_age=15s
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.370949] sd 2:0:0:1: [sda] tag#39 Sense Key : Medium Error [current]
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.370952] sd 2:0:0:1: [sda] tag#39 Add. Sense: Unrecovered read error
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.370949] EXT4-fs error (device sda): ext4_journal_check_start:83: comm kworker/u4:0: Detected aborted journal
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.370954] sd 2:0:0:1: [sda] tag#39 CDB: Write(10) 2a 00 00 10 41 98 00 00 08 00
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.372081] blk_update_request: critical medium error, dev sda, sector 1065368 op 0x1:(WRITE) flags 0x800 phys_seg 1 prio class 0
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.374353] EXT4-fs warning (device sda): ext4_end_bio:344: I/O error 7 writing to inode 131080 starting block 133172)
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.374396] Buffer I/O error on device sda, logical block 133171
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.388492] EXT4-fs error (device sda) in __ext4_new_inode:1136: Journal has aborted
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.390763] EXT4-fs error (device sda) in ext4_create:2786: Journal has aborted
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.391732] sd 2:0:0:1: [sda] tag#46 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_OK cmd_age=0s
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.392941] sd 2:0:0:1: [sda] tag#46 Sense Key : Medium Error [current]
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.392944] sd 2:0:0:1: [sda] tag#46 Add. Sense: Unrecovered read error
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.392948] sd 2:0:0:1: [sda] tag#46 CDB: Write(10) 2a 08 00 00 00 00 00 00 08 00
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.392950] blk_update_request: critical medium error, dev sda, sector 0 op 0x1:(WRITE) flags 0x23800 phys_seg 1 prio class 0
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.395562] Buffer I/O error on dev sda, logical block 0, lost sync page write
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.396945] sd 2:0:0:1: [sda] tag#45 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_OK cmd_age=0s
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.396953] sd 2:0:0:1: [sda] tag#45 Sense Key : Medium Error [current]
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.396955] sd 2:0:0:1: [sda] tag#45 Add. Sense: Unrecovered read error
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.396958] sd 2:0:0:1: [sda] tag#45 CDB: Write(10) 2a 08 00 84 00 00 00 00 08 00
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.396959] blk_update_request: critical medium error, dev sda, sector 8650752 op 0x1:(WRITE) flags 0x20800 phys_seg 1 prio class 0
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.396930] EXT4-fs (sda): I/O error while writing superblock
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.399771] Buffer I/O error on dev sda, logical block 1081344, lost sync page write
Nov 14 23:06:59 k8s-worker2 kernel: [3413829.403897] JBD2: Error -5 detected when updating journal superblock for sda-8.
Nov 14 23:07:01 k8s-worker2 systemd[1]: run-docker-runtime\x2drunc-moby-d1c0f0dc3e024723707edfc12e023b98fb98f1be971177ecca5ac0cfdc91ab87-runc.w3zzIL.mount: Deactivated successfully.
Nov 14 23:07:05 k8s-worker2 kubelet[752]: E1114 23:07:05.415798 752 dns.go:157] "Nameserver limits exceeded" err="Nameserver limits were exceeded, some nameservers have been omitted, the applied nameserver line is: 46.38.252.230 46.38.225.230 2a03:4000:0:1::e1e6"
Nov 14 23:07:06 k8s-worker2 kubelet[752]: E1114 23:07:06.412219 752 dns.go:157] "Nameserver limits exceeded" err="Nameserver limits were exceeded, some nameservers have been omitted, the applied nameserver line is: 46.38.252.230 46.38.225.230 2a03:4000:0:1::e1e6"
Nov 14 23:07:06 k8s-worker2 systemd[1]: run-docker-runtime\x2drunc-moby-d1c0f0dc3e024723707edfc12e023b98fb98f1be971177ecca5ac0cfdc91ab87-runc.nK23K3.mount: Deactivated successfully.
Nov 14 23:07:11 k8s-worker2 systemd[1]: run-docker-runtime\x2drunc-moby-d1c0f0dc3e024723707edfc12e023b98fb98f1be971177ecca5ac0cfdc91ab87-runc.L5TkRU.mount: Deactivated successfully.
Nov 14 23:07:14 k8s-worker2 kernel: [3413844.411831] sd 2:0:0:1: [sda] tag#44 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_OK cmd_age=15s
Nov 14 23:07:14 k8s-worker2 kernel: [3413844.411888] sd 2:0:0:1: [sda] tag#44 Sense Key : Medium Error [current]
Nov 14 23:07:14 k8s-worker2 kernel: [3413844.411898] sd 2:0:0:1: [sda] tag#44 Add. Sense: Unrecovered read error
Nov 14 23:07:14 k8s-worker2 kernel: [3413844.411952] sd 2:0:0:1: [sda] tag#44 CDB: Write(10) 2a 00 00 44 28 40 00 00 50 00
Nov 14 23:07:14 k8s-worker2 kernel: [3413844.411965] blk_update_request: critical medium error, dev sda, sector 4466752 op 0x1:(WRITE) flags 0x0 phys_seg 10 prio class 0
Nov 14 23:07:14 k8s-worker2 kernel: [3413844.419273] EXT4-fs warning (device sda): ext4_end_bio:344: I/O error 7 writing to inode 131083 starting block 558354)
Nov 14 23:07:14 k8s-worker2 kernel: [3413844.430398] sd 2:0:0:1: [sda] tag#47 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_OK cmd_age=15s
Nov 14 23:07:14 k8s-worker2 kernel: [3413844.430407] sd 2:0:0:1: [sda] tag#47 Sense Key : Medium Error [current]
Nov 14 23:07:14 k8s-worker2 kernel: [3413844.430409] sd 2:0:0:1: [sda] tag#47 Add. Sense: Unrecovered read error
Nov 14 23:07:14 k8s-worker2 kernel: [3413844.430412] sd 2:0:0:1: [sda] tag#47 CDB: Write(10) 2a 08 00 00 00 00 00 00 08 00
Nov 14 23:07:14 k8s-worker2 kernel: [3413844.430415] blk_update_request: critical medium error, dev sda, sector 0 op 0x1:(WRITE) flags 0x23800 phys_seg 1 prio class 0
Nov 14 23:07:14 k8s-worker2 kernel: [3413844.433686] Buffer I/O error on dev sda, logical block 0, lost sync page write
Nov 14 23:07:14 k8s-worker2 kernel: [3413844.436088] EXT4-fs (sda): I/O error while writing superblock
Nov 14 23:07:14 k8s-worker2 kernel: [3413844.444291] sd 2:0:0:1: [sda] tag#32 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_OK cmd_age=14s
Nov 14 23:07:14 k8s-worker2 kernel: [3413844.444300] sd 2:0:0:1: [sda] tag#32 Sense Key : Medium Error [current]
Nov 14 23:07:14 k8s-worker2 kernel: [3413844.444304] sd 2:0:0:1: [sda] tag#32 Add. Sense: Unrecovered read error
Nov 14 23:07:14 k8s-worker2 kernel: [3413844.444308] sd 2:0:0:1: [sda] tag#32 CDB: Write(10) 2a 00 00 41 01 18 00 00 08 00
Nov 14 23:07:14 k8s-worker2 kernel: [3413844.444313] blk_update_request: critical medium error, dev sda, sector 4260120 op 0x1:(WRITE) flags 0x3000 phys_seg 1 prio class 0
Nov 14 23:07:14 k8s-worker2 kernel: [3413844.449491] Buffer I/O error on dev sda, logical block 532515, lost async page write
Nov 14 23:07:14 k8s-worker2 kernel: [3413844.453591] sd 2:0:0:1: [sda] tag#33 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_OK cmd_age=0s
Nov 14 23:07:14 k8s-worker2 kernel: [3413844.453600] sd 2:0:0:1: [sda] tag#33 Sense Key : Medium Error [current]
Nov 14 23:07:14 k8s-worker2 kernel: [3413844.453603] sd 2:0:0:1: [sda] tag#33 Add. Sense: Unrecovered read error
Nov 14 23:07:14 k8s-worker2 kernel: [3413844.453607] sd 2:0:0:1: [sda] tag#33 CDB: Write(10) 2a 08 00 00 00 00 00 00 08 00
Nov 14 23:07:14 k8s-worker2 kernel: [3413844.453610] blk_update_request: critical medium error, dev sda, sector 0 op 0x1:(WRITE) flags 0x23800 phys_seg 1 prio class 0
Nov 14 23:07:14 k8s-worker2 kernel: [3413844.459072] Buffer I/O error on dev sda, logical block 0, lost sync page write
Nov 14 23:07:14 k8s-worker2 kernel: [3413844.461189] EXT4-fs (sda): I/O error while writing superblock
Nov 14 23:07:14 k8s-worker2 kernel: [3413844.464347] EXT4-fs (sda): Remounting filesystem read-only
Nov 14 23:07:14 k8s-worker2 kernel: [3413844.466527] EXT4-fs (sda): failed to convert unwritten extents to written extents -- potential data loss! (inode 131081, error -30)
Nov 14 23:07:14 k8s-worker2 kernel: [3413844.470833] Buffer I/O error on device sda, logical block 561678
Nov 14 23:07:14 k8s-worker2 kernel: [3413844.473548] Buffer I/O error on device sda, logical block 561679
Nov 14 23:07:14 k8s-worker2 kernel: [3413844.477384] EXT4-fs (sda): failed to convert unwritten extents to written extents -- potential data loss! (inode 131083, error -30)
Nov 14 23:07:14 k8s-worker2 kernel: [3413844.482014] Buffer I/O error on device sda, logical block 558344
Nov 14 23:07:14 k8s-worker2 kernel: [3413844.484881] Buffer I/O error on device sda, logical block 558345
Nov 14 23:07:14 k8s-worker2 kernel: [3413844.487224] Buffer I/O error on device sda, logical block 558346
Nov 14 23:07:14 k8s-worker2 kernel: [3413844.488837] Buffer I/O error on device sda, logical block 558347
Nov 14 23:07:14 k8s-worker2 kernel: [3413844.490543] Buffer I/O error on device sda, logical block 558348
Nov 14 23:07:14 k8s-worker2 kernel: [3413844.492061] Buffer I/O error on device sda, logical block 558349
Nov 14 23:07:14 k8s-worker2 kernel: [3413844.493494] Buffer I/O error on device sda, logical block 558350
Nov 14 23:07:14 k8s-worker2 kernel: [3413844.494931] Buffer I/O error on device sda, logical block 558351
</code></pre>
<p>Not sure, if this is really related to the problem.</p>
| [
{
"answer_id": 74334472,
"author": "Tobias S.",
"author_id": 8613630,
"author_profile": "https://Stackoverflow.com/users/8613630",
"pm_score": 2,
"selected": true,
"text": "key"
},
{
"answer_id": 74334537,
"author": "socebic",
"author_id": 20430838,
"author_profile": "https://Stackoverflow.com/users/20430838",
"pm_score": 2,
"selected": false,
"text": "import { Component, OnInit } from '@angular/core';\n\nconst Fruits = [\"apple\", \"banana\"] as const;\ntype Fruit = typeof Fruits[number]; // \"apple\" | \"banana\"\ntype FruitCollection = { [fruit in Fruit]: number }; // {apple: number, banana: number}\n\n@Component({\n selector: 'app-apple-banana',\n templateUrl: './apple-banana.component.html'\n})\nexport class AppleBananaComponent implements OnInit {\n fruits = Fruits;\n fruitBasket: FruitCollection = {\n apple: 10,\n banana: 10\n }\n fruitEaten: FruitCollection = {\n apple: 0,\n banana: 0\n }\n constructor() { }\n ngOnInit(): void { }\n eatFruit(fruit: Fruit) {\n this.fruitEaten[fruit]++;\n this.fruitBasket[fruit]--;\n }\n}\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74334366",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3142695/"
] |
74,334,381 | <p>I have an infinite loop Python function for measuring how fast are SECP256K1 public Keys are generated.</p>
<p>The script:</p>
<pre><code>from time import time
a = 0
b = 7
n = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
gx = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
gy = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8
prime = 2**256 - 2**32 - 977
def addition(currentX, currentY, gx, gy, a, b, prime):
if gy == 0:
return (None, None)
elif currentX is None and currentY is None:
return (gx, gy)
elif currentX == gx and currentY != gy:
return (None, None)
elif currentX == gx and currentY == gy and currentY == 0:
return (None, None)
elif currentX == gx and currentY == gy:
s1 = (3 * pow(gx, 2, prime) + a) % prime
s2 = (gy * 2) % prime
s = (s1 * pow(s2, (prime - 2), prime)) % prime
currentX = (s ** 2 - 2 * gx) % prime
currentY = (s * (gx - currentX) - gy) % prime
elif currentX != gx:
s1 = (currentY - gy)
s2 = (currentX - gx)
s = (s1 * pow(s2, (prime - 2), prime)) % prime
currentX = ((s ** 2) - gx - currentX) % prime
currentY = ((s * (gx - currentX)) - gy) % prime
return (currentX, currentY)
def secp256k1BinaryExpansion(privateKey, gx, gy, a, b, prime):
#if pow(gy, 2, prime) != (pow(gx, 3, prime) + a * gx + b) % prime:
#return "The point is not on the curve"
coef = privateKey
currentX, currentY = gx, gy
resultX, resultY = None, None
while coef:
if coef & 1:
resultX, resultY = addition(resultX, resultY, currentX, currentY, a, b, prime)
currentX, currentY = addition(currentX, currentY, currentX, currentY, a, b, prime)
coef >>= 1
return (resultX, resultY)
def testLoop(gx, gy, a, b, prime):
count = 1 #Count is the number of all calculations
counter = 0 #Counter is for measuring the speed of the function
timeOne = time()
pubX, pubY = None, None
while True:
pubX, pubY = secp256k1BinaryExpansion(count, gx, gy, a, b, prime)
#print("Case ", count,":", pubX,pubY)
count += 1
counter += 1
timeTwo = time()
if (timeTwo - timeOne) >= 10:
print("The speed is: ", counter / (timeTwo - timeOne), "c/s")
timeOne = time()
counter = 0
testLoop(gx, gy, a, b, prime)
</code></pre>
<p>Whenever I am launching the script on Pycharm, it outputs aroud 100 c/s on Windows and 300 c/s on Ubuntu.</p>
<p>When it happens, on both os, only 1 core out ouf 4 gets loaded with this task for 100%, hence only 25% of CPU power is allocated to this.
The CPU: intel core i5-4440 cpu @ 3.10ghz</p>
<p>I'd like to allocate 2-3 cores to the task, so it gets loaded like: 50-75%.</p>
<p>The truth is I've read documentation and watched tutorials on Python Parallelism/Multithreading and it's confusing.</p>
<p>Not really sure how to allocate a single job across the cores.</p>
<p>May be you could help out?</p>
| [
{
"answer_id": 74336618,
"author": "Jérôme Richard",
"author_id": 12939557,
"author_profile": "https://Stackoverflow.com/users/12939557",
"pm_score": 1,
"selected": false,
"text": "import gmpy2\n\na = gmpy2.mpz(0)\nb = gmpy2.mpz(7)\nn = gmpy2.mpz(0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141)\ngx = gmpy2.mpz(0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798)\ngy = gmpy2.mpz(0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8)\nprime = gmpy2.mpz(2**256 - 2**32 - 977)\n"
},
{
"answer_id": 74337784,
"author": "Ahmed AEK",
"author_id": 15649230,
"author_profile": "https://Stackoverflow.com/users/15649230",
"pm_score": 0,
"selected": false,
"text": "iterools.repeat"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74334381",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19886263/"
] |
74,334,396 | <p>I want to hide the id="Watch" button.
until the class="button1" button is clicked
The countdown ends
Then the id="Watch" button appears.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>function DelayRedirect() {
var seconds = 10;
var dvCountDown = document.getElementById("dvCountDown");
var lblCount = document.getElementById("lblCount");
dvCountDown.style.display = "block";
lblCount.innerHTML = seconds;
setInterval(function () {
seconds--;
lblCount.innerHTML = seconds;
if (seconds == 0) {
dvCountDown.style.display = "none";
window.location = "#Watch";
}
}, 1000);
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code> <button class="button1" onclick="DelayRedirect()">continue</button>
<div id="dvCountDown" style = "display:none">
You will be redirected after <span id = "lblCount"></span>&nbsp;seconds.
</div>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<button id="Watch"><a class="button2" href="https://www.youtube.com/" target="_blank">Watch</i></a></button></code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74336618,
"author": "Jérôme Richard",
"author_id": 12939557,
"author_profile": "https://Stackoverflow.com/users/12939557",
"pm_score": 1,
"selected": false,
"text": "import gmpy2\n\na = gmpy2.mpz(0)\nb = gmpy2.mpz(7)\nn = gmpy2.mpz(0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141)\ngx = gmpy2.mpz(0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798)\ngy = gmpy2.mpz(0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8)\nprime = gmpy2.mpz(2**256 - 2**32 - 977)\n"
},
{
"answer_id": 74337784,
"author": "Ahmed AEK",
"author_id": 15649230,
"author_profile": "https://Stackoverflow.com/users/15649230",
"pm_score": 0,
"selected": false,
"text": "iterools.repeat"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74334396",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19877564/"
] |
74,334,494 | <p>Why my keyboard covers up my modal when I am focusing on my textinput ?</p>
<p><a href="https://i.stack.imgur.com/fBdQM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fBdQM.png" alt="enter image description here" /></a></p>
<p>Code:</p>
<pre><code> <BottomSheetModal
ref={ref}
index={1}
snapPoints={snapPoints}
handleIndicatorStyle={[s.handleStyle, s.handleColorWhite]}
backdropComponent={BottomSheetBackdrop}
>
<KeyboardAwareScrollView keyboardShouldPersistTaps='handled' contentContainerStyle={{flexGrow: 1}}>
<View style={s.centered}>
<Text style={s.title}>Rabatt-Code</Text>
<Text style={s.subtitle}>Füge ein Rabatt-Code für dein Produkt ein</Text>
<Text style={s.stepText}>{`Schritt ${step}/3`}</Text>
</View>
<Text style={[s.text, s.bold]}>Nur Buchstaben & Zahlen!</Text>
<View style={s.content}>
<View style={s.inputContainer}>
<Input
placeholder='Name (exp. Max50)'
value={coupon.name}
onChangeText={handleChangeName}
style={[InputStyles.full_icon]}
icon={<Ionicons name="md-newspaper-outline" size={24} style={s.icon} color="#333" />}
/>
</View>
<View style={s.containerInner}>
<Pressable onPress={handleChangeStage} style={[ButtonStyles.full]}>
<Text style={s.btnText}NEXT</Text>
</Pressable>
</View>
</View>
</KeyboardAwareScrollView>
</BottomSheetModal>
</code></pre>
<p>Anyone can explain me what I am doing wrong ? On Android its fine, this is only on iOS.</p>
| [
{
"answer_id": 74336618,
"author": "Jérôme Richard",
"author_id": 12939557,
"author_profile": "https://Stackoverflow.com/users/12939557",
"pm_score": 1,
"selected": false,
"text": "import gmpy2\n\na = gmpy2.mpz(0)\nb = gmpy2.mpz(7)\nn = gmpy2.mpz(0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141)\ngx = gmpy2.mpz(0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798)\ngy = gmpy2.mpz(0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8)\nprime = gmpy2.mpz(2**256 - 2**32 - 977)\n"
},
{
"answer_id": 74337784,
"author": "Ahmed AEK",
"author_id": 15649230,
"author_profile": "https://Stackoverflow.com/users/15649230",
"pm_score": 0,
"selected": false,
"text": "iterools.repeat"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74334494",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18281071/"
] |
74,334,508 | <p>I have a simple stored procedure with comma separated input params. I will send Database Names in Json or Comma separated values.
Like DB1,DB2,DB3 etc..;
When ever I send that parameter will be loading that table in each of the Database.
I'm looking for loop condition and splitting values.</p>
<pre><code>EXEC student_info (DBName = 'DB1,DB2,DB3,DB')
DELIMITER &&
ALTER PROCEDURE student_info (IN DBName varchar(100))
BEGIN
**Splitting comma separated**
**loop condition**
INSERT INTO @DBName.tbl_student(Name,Class)
SELECT Name,Class FROM DB.student_info ;
END &&
DELIMITER ;
</code></pre>
<p>What is the best way?</p>
| [
{
"answer_id": 74334561,
"author": "slaakso",
"author_id": 1052130,
"author_profile": "https://Stackoverflow.com/users/1052130",
"pm_score": 0,
"selected": false,
"text": "FIND_IN_SET"
},
{
"answer_id": 74337972,
"author": "Luuk",
"author_id": 724039,
"author_profile": "https://Stackoverflow.com/users/724039",
"pm_score": 1,
"selected": false,
"text": "drop procedure if exists student_info;\nDELIMITER && \nCREATE PROCEDURE student_info(IN dbname varchar(100)) \nBEGIN \n declare a CHAR(16);\n declare s VARCHAR(400);\n DECLARE cur1 CURSOR FOR\n with recursive cte as (\n select \n @dbname as s1,\n substring_index(substring_index(@dbname,',',1),',',-1) as s2, \n 1 as x\n union all\n select \n s1, \n substring_index(substring_index(s1,',',x+1),',',-1), \n x+1\n from cte \n where x< (select length(s1)-length(replace(s1,',',''))+1)\n )\n select s2 from cte;\n\n open cur1;\n \n read_loop: loop\n fetch cur1 into a;\n set @s = CONCAT('INSERT INTO ',a,'.tbl_student(Name,Class) SELECT Name,Class FROM DB.student_info ');\n PREPARE stmt1 FROM @s;\n execute stmt1 ;\n deallocate prepare stmt1;\n END loop;\n\n close cur1;\nEND && \nDELIMITER ; \n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74334508",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/943978/"
] |
74,334,528 | <p>example.yaml</p>
<pre class="lang-yaml prettyprint-override"><code>version: 0.20
</code></pre>
<p>main.py</p>
<pre><code>import yaml
with open("example.yaml", "r") as stream:
try:
print(yaml.safe_load(stream))
except yaml.YAMLError as exc:
print(exc)
</code></pre>
<p>Actual output:</p>
<pre><code>{'version': 0.2}
</code></pre>
<p>Desired output:</p>
<pre><code>{'version': '0.20'}
</code></pre>
<p>Looks like yaml is parsing the <code>version</code> field as a float, and hence removes the 0 at the end. Using Python, how do I prevent the version field from converting to a float value?</p>
<hr />
<p>The are two workarounds that modify the YAML to express the <code>version</code> field as a string:</p>
<p>example.yaml</p>
<pre class="lang-yaml prettyprint-override"><code>version: '0.20'
</code></pre>
<pre class="lang-yaml prettyprint-override"><code>version: 0.20.0
</code></pre>
<p>But I want to handle this inside Python.</p>
| [
{
"answer_id": 74334561,
"author": "slaakso",
"author_id": 1052130,
"author_profile": "https://Stackoverflow.com/users/1052130",
"pm_score": 0,
"selected": false,
"text": "FIND_IN_SET"
},
{
"answer_id": 74337972,
"author": "Luuk",
"author_id": 724039,
"author_profile": "https://Stackoverflow.com/users/724039",
"pm_score": 1,
"selected": false,
"text": "drop procedure if exists student_info;\nDELIMITER && \nCREATE PROCEDURE student_info(IN dbname varchar(100)) \nBEGIN \n declare a CHAR(16);\n declare s VARCHAR(400);\n DECLARE cur1 CURSOR FOR\n with recursive cte as (\n select \n @dbname as s1,\n substring_index(substring_index(@dbname,',',1),',',-1) as s2, \n 1 as x\n union all\n select \n s1, \n substring_index(substring_index(s1,',',x+1),',',-1), \n x+1\n from cte \n where x< (select length(s1)-length(replace(s1,',',''))+1)\n )\n select s2 from cte;\n\n open cur1;\n \n read_loop: loop\n fetch cur1 into a;\n set @s = CONCAT('INSERT INTO ',a,'.tbl_student(Name,Class) SELECT Name,Class FROM DB.student_info ');\n PREPARE stmt1 FROM @s;\n execute stmt1 ;\n deallocate prepare stmt1;\n END loop;\n\n close cur1;\nEND && \nDELIMITER ; \n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74334528",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20430998/"
] |
74,334,529 | <p>I made a Go fyne project, which works fine with <code>go run .</code>, and builds to Linux as expected with <code>go build .</code>.</p>
<p>However, when I try cross-compiling to windows using <code>env GOOS=windows GOARCH=arm64 go build .</code> it prints this error:</p>
<pre><code>go: downloading github.com/tevino/abool v1.2.0
package playground.com/colors
imports fyne.io/fyne/v2/app
imports fyne.io/fyne/v2/internal/driver/glfw
imports fyne.io/fyne/v2/internal/driver/common
imports fyne.io/fyne/v2/internal/painter/gl
imports github.com/go-gl/gl/v3.1/gles2: build constraints exclude all Go files in /home/mohamed/code/go/pkg/mod/github.com/go-gl/gl@v0.0.0-20211210172815-726fda9656d6/v3.1/gles2
</code></pre>
<p>I tried a clean install of Go, tried using <code>go clean -modcache</code>, tried creating a separate new module.</p>
<p>The code for error replication:</p>
<pre class="lang-golang prettyprint-override"><code>package main
import (
"fmt"
"image/color"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/widget"
)
func main() {
app := app.NewWithID("Color Mixer")
window := app.NewWindow("Color")
red := widget.NewSlider(0, 255)
green := widget.NewSlider(0, 255)
blue := widget.NewSlider(0, 255)
red_value := widget.NewLabel("0")
green_value := widget.NewLabel("0")
blue_value := widget.NewLabel("0")
red_label := widget.NewLabel("Red")
green_label := widget.NewLabel("Green")
blue_label := widget.NewLabel("Blue")
colorx := color.NRGBA{R: 0, G: 0, B: 0, A: 255}
rect := canvas.NewRectangle(colorx)
rect.SetMinSize(fyne.NewSize(300, 300))
red.OnChanged =
func(f float64) {
_, g, b, a := rect.FillColor.RGBA()
rect.FillColor = color.NRGBA{R: uint8(f),
G: uint8(g),
B: uint8(b),
A: uint8(a)}
rect.Refresh()
red_value.SetText(fmt.Sprintf("%.0f", f))
}
green.OnChanged =
func(f float64) {
r, _, b, a := rect.FillColor.RGBA()
rect.FillColor = color.NRGBA{R: uint8(r),
G: uint8(f),
B: uint8(b),
A: uint8(a)}
rect.Refresh()
green_value.SetText(fmt.Sprintf("%.0f", f))
}
blue.OnChanged =
func(f float64) {
r, g, _, a := rect.FillColor.RGBA()
rect.FillColor = color.NRGBA{R: uint8(r),
G: uint8(g),
B: uint8(f),
A: uint8(a)}
rect.Refresh()
blue_value.SetText(fmt.Sprintf("%.0f", f))
}
box := container.NewGridWithRows(
2,
container.NewGridWithRows(3, red_label, green_label, blue_label, red, green, blue, red_value, green_value, blue_value),
rect)
window.SetContent(box)
window.ShowAndRun()
}
</code></pre>
| [
{
"answer_id": 74334561,
"author": "slaakso",
"author_id": 1052130,
"author_profile": "https://Stackoverflow.com/users/1052130",
"pm_score": 0,
"selected": false,
"text": "FIND_IN_SET"
},
{
"answer_id": 74337972,
"author": "Luuk",
"author_id": 724039,
"author_profile": "https://Stackoverflow.com/users/724039",
"pm_score": 1,
"selected": false,
"text": "drop procedure if exists student_info;\nDELIMITER && \nCREATE PROCEDURE student_info(IN dbname varchar(100)) \nBEGIN \n declare a CHAR(16);\n declare s VARCHAR(400);\n DECLARE cur1 CURSOR FOR\n with recursive cte as (\n select \n @dbname as s1,\n substring_index(substring_index(@dbname,',',1),',',-1) as s2, \n 1 as x\n union all\n select \n s1, \n substring_index(substring_index(s1,',',x+1),',',-1), \n x+1\n from cte \n where x< (select length(s1)-length(replace(s1,',',''))+1)\n )\n select s2 from cte;\n\n open cur1;\n \n read_loop: loop\n fetch cur1 into a;\n set @s = CONCAT('INSERT INTO ',a,'.tbl_student(Name,Class) SELECT Name,Class FROM DB.student_info ');\n PREPARE stmt1 FROM @s;\n execute stmt1 ;\n deallocate prepare stmt1;\n END loop;\n\n close cur1;\nEND && \nDELIMITER ; \n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74334529",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16516114/"
] |
74,334,552 | <p>I want to do a time minus: 24Hours - 14Hours 20 minutes 10 seconds,write a function:</p>
<pre><code>def time_minus(start,end):
def convert_sec(time):
hours = int(time.split(":")[0])
mins = int(time.split(":")[1])
secs = int(time.split(":")[2])
return hours*60*60 + mins*60 + secs
start_time = convert_sec(start)
end_time = convert_sec(end)
st = end_time-start_time
hours = str(st//3600).rjust(2,'0')
mins = str((st%3600)//60).rjust(2,'0')
secs = str((st%3600)%60).rjust(2,'0')
result = hours + " hours " + mins + " minutes " + secs + " seconds"
print(result)
return hours + ":" + mins + ":" + secs
</code></pre>
<p>The output:</p>
<pre><code>x=time_minus("14:20:10","24:00:00")
09 hours 39 minutes 50 seconds
x
'09:39:50'
</code></pre>
<p>Is there a some python's lib to do the minus?How can call it?</p>
<pre><code>>>> from datetime import datetime
>>> s1 = '14:20:10'
>>> s2 = '24:00:00'
>>> FMT = '%H:%M:%S'
>>> tdelta = datetime.strptime(s2, FMT) - datetime.strptime(s1, FMT)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.9/_strptime.py", line 568, in _strptime_datetime
tt, fraction, gmtoff_fraction = _strptime(data_string, format)
File "/usr/lib/python3.9/_strptime.py", line 349, in _strptime
raise ValueError("time data %r does not match format %r" %
ValueError: time data '24:00:00' does not match format '%H:%M:%S'
</code></pre>
<p>I have to customize a function because of <code>time data '24:00:00' does not match format '%H:%M:%S'</code>!!!</p>
| [
{
"answer_id": 74334709,
"author": "C-3PO",
"author_id": 4667669,
"author_profile": "https://Stackoverflow.com/users/4667669",
"pm_score": 2,
"selected": false,
"text": "24:00:00"
},
{
"answer_id": 74334738,
"author": "newview",
"author_id": 20311786,
"author_profile": "https://Stackoverflow.com/users/20311786",
"pm_score": 0,
"selected": false,
"text": "from datetime import datetime\ns1 = '14:20:10'\ns2 = '00:00:00' \nFMT = '%H:%M:%S'\ntdelta = datetime.strptime(s2, FMT) - datetime.strptime(s1, FMT)\nstr(tdelta).split(\",\")[1].replace(\" \",\"0\")\n'09:39:50'\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74334552",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20311786/"
] |
74,334,591 | <p>.NET MAUI has the ability to use SVG images which is really nice, but I haven't been able to set the color of the SVG image. The official docs state I could use the TintColor in the project file but that's not a good solution as I want to be able to use different colors depending on certain conditions. So can we somehow specify the color of a SVG image?</p>
| [
{
"answer_id": 74341925,
"author": "Liqun Shen-MSFT",
"author_id": 20118901,
"author_profile": "https://Stackoverflow.com/users/20118901",
"pm_score": 0,
"selected": false,
"text": "<StackLayout>\n <skiact:SKCanvasView WidthRequest=\"500\" HeightRequest=\"500\" x:Name=\"mycanvasview\" PaintSurface=\"mycanvasview_PaintSurface\">\n </skiact:SKCanvasView>\n</StackLayout>\n"
},
{
"answer_id": 74362162,
"author": "Jasper",
"author_id": 2618738,
"author_profile": "https://Stackoverflow.com/users/2618738",
"pm_score": 2,
"selected": false,
"text": "<Image Source=\"shield.png\">\n <Image.Behaviors>\n <toolkit:IconTintColorBehavior TintColor=\"Red\" />\n </Image.Behaviors>\n</Image>\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74334591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2618738/"
] |
74,334,643 | <p>So I have a section, which is divided into 2 parts. I want the text to be vertically centered and aligned to th left. I managed to vertically center one of my texts, but when I try to add more text, it just moves somewhere else instead of being positioned right on top of the other.</p>
<p><strong>Current result:</strong></p>
<p><a href="https://i.stack.imgur.com/FR3Fw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FR3Fw.png" alt="My current design" /></a></p>
<p><strong>HTML:</strong></p>
<pre><code><section class="outer">
<div class="col2">
<h2>P E R F U M E</h2>
<h1>Gabrielle<br> Essence Eau<br> De Parfum</h1>
<p>A floral, solar and voluptuous<br> interpretation composed by<br> Olivier Polge,
Perfumer-Creator<br> for the House of CHANEL.
</p>
</div>
</section>
</code></pre>
<p><strong>CSS:</strong></p>
<pre><code>.col2 {
position: absolute;
display: table;
width: 350px;
height: 600px;
background-color: white;
right: 0;
text-align: left;
}
.col2 h1 {
display: table-cell;
vertical-align: middle;
text-align: left;
padding: 20px;
height: fit-content;
font-family: 'Fraunces';
}
</code></pre>
<p><strong>Expected result:</strong></p>
<p><a href="https://i.stack.imgur.com/Uj76v.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Uj76v.jpg" alt="Hoow I want it to look" /></a></p>
<p>I've tried using <code>display: table</code> for the container and <code>display: table--cell</code> for the text itself, which worked just fine with one div but not after adding some new text in another div in addition to te heading.
I also tried something with <code>line-height</code> but it did something else than expected.</p>
| [
{
"answer_id": 74334720,
"author": "Fabio Rotondo",
"author_id": 339620,
"author_profile": "https://Stackoverflow.com/users/339620",
"pm_score": 2,
"selected": false,
"text": "display: flex"
},
{
"answer_id": 74350024,
"author": "Lawrence",
"author_id": 20317896,
"author_profile": "https://Stackoverflow.com/users/20317896",
"pm_score": 0,
"selected": false,
"text": "<section class=\"outer\">\n<div class=\"col2\">\n<h2>P E R F U M E</h2>\n<h1>Gabrielle<br> Essence Eau<br> De Parfum</h1> \n<p>A floral, solar and voluptuous<br> interpretation composed by<br> Olivier Polge, Perfumer-Creator<br> for the House of CHANEL.\n</p>\n</div>\n</section>\n<style>\n.outer {\ndisplay: flex;\nflex-direction: row;\njustify-content: center;\n}\n.col2 {\ndisplay: flex;\njustify-content: center;\n}\n</style>\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74334643",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20407393/"
] |
74,334,705 | <p><a href="https://i.stack.imgur.com/HRflt.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HRflt.jpg" alt="Problem 4" /></a></p>
<p>I'm new to Loops and I'm trying to understand how will I be able to display those asterisks, such that each row will have its respective number of asterisks.</p>
<p>I've tried doing this, but I'm having a hard time with what to do next.</p>
<p>The problem is that the output only shows 3 asterisks for each row instead expected output on the first image. <a href="https://i.stack.imgur.com/9GQAC.jpg" rel="nofollow noreferrer">output problem</a></p>
<pre><code>void displayAst (int b) {
for (int i = 1; i <= b ; i++) {
printf ("*");
}
}
void displayMulti (int a) {
for (int i = 1; i <= 10 ; i++) {
printf ("\n%d x %d = ", a, i);
displayAst (a);
}
}
int main () {
int nNum;
printf ("Enter Number: ");
scanf ("%d", &nNum);
displayMulti (nNum);
return 0;
}
</code></pre>
| [
{
"answer_id": 74335028,
"author": "office.aizaz",
"author_id": 7257604,
"author_profile": "https://Stackoverflow.com/users/7257604",
"pm_score": 1,
"selected": true,
"text": "displayAst (a);\n"
},
{
"answer_id": 74335946,
"author": "Fuad Hasan",
"author_id": 10669505,
"author_profile": "https://Stackoverflow.com/users/10669505",
"pm_score": 1,
"selected": false,
"text": "displayMulti()"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74334705",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20084836/"
] |
74,334,710 | <p>I can't figure out the difference between the two states of the thread. Please explain this difference.</p>
| [
{
"answer_id": 74335028,
"author": "office.aizaz",
"author_id": 7257604,
"author_profile": "https://Stackoverflow.com/users/7257604",
"pm_score": 1,
"selected": true,
"text": "displayAst (a);\n"
},
{
"answer_id": 74335946,
"author": "Fuad Hasan",
"author_id": 10669505,
"author_profile": "https://Stackoverflow.com/users/10669505",
"pm_score": 1,
"selected": false,
"text": "displayMulti()"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74334710",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20431186/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.