qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
74,430,090 | <p>I want to create a new column that multiplies the column values of pt_nm with predefined values, if the name is selected in the variable:</p>
<p>df["pt_nm"] looks like this</p>
<pre><code>0 0.0
1 1.0
2 1.0
3 2.0
4 1.0
dtype: float64
</code></pre>
<p>my variables that are available to select are these:</p>
<pre><code>types = ["E", "S", "EK"]
r_type = "E"
pt_s= 25
pt_e = 60
pt_ek = 45
</code></pre>
<p>I tried the following which doesn't work:</p>
<pre><code>def race (r_type, pt_nm):
if r_type == "E":
pt_nm* pt_e
elif r_type == "S":
pt_nm* pt_s
else:
pt_nm* pt_ek
df["pt_new"] = df["pt_nm"].apply(race, axis = 1)
</code></pre>
<p>I assume the problem is probably in the arguments? An explanation on how the function would work is appreciated! :)</p>
| [
{
"answer_id": 74432244,
"author": "Glen Stautland",
"author_id": 17611060,
"author_profile": "https://Stackoverflow.com/users/17611060",
"pm_score": 1,
"selected": false,
"text": "<ul> or <ol>"
},
{
"answer_id": 74446356,
"author": "Alejandro Suárez",
"author_id": 17751007,
"author_profile": "https://Stackoverflow.com/users/17751007",
"pm_score": 1,
"selected": false,
"text": "tabindex=\"0\""
},
{
"answer_id": 74617365,
"author": "Andy",
"author_id": 608042,
"author_profile": "https://Stackoverflow.com/users/608042",
"pm_score": 1,
"selected": false,
"text": "tabindex"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430090",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19225090/"
] |
74,430,103 | <p>this is my table now</p>
<pre><code> c1 c2 c3 c4 c5
r1 1 NA NA NA NA
r2 1 1 NA NA NA
r3 1 1 1 NA NA
r4 1 1 1 1 NA
r5 1 1 1 1 1
</code></pre>
<p>i want to shift the NA's at the bottom of each column and then shift the non NA numbers upward with out doing anything or arranging the non NA values in the matrix (suppose that the non NA values are unique), i just want them to shift up and make the NA's be at the bottom like this:</p>
<pre><code> c1 c2 c3 c4 c5
r1 1 1 1 1 1
r2 1 1 1 1 NA
r3 1 1 1 NA NA
r4 1 1 NA NA NA
r5 1 NA NA NA NA
</code></pre>
<p>is there any function that can do what i want to do with my matrix? i already found a similar <a href="https://stackoverflow.com/questions/34402553/move-na-to-the-start-of-each-column-in-a-matrix">question</a> like this but the question is the oppposite of mine so i cant really use the answers in that question. any help would be appreciated.</p>
<p>EDIT:</p>
<p>is there a way that this can be done by a loop? or like transferring the elements into another matrix then the new matrix has the correct position of the elements? many thanks</p>
| [
{
"answer_id": 74430323,
"author": "user2974951",
"author_id": 2974951,
"author_profile": "https://Stackoverflow.com/users/2974951",
"pm_score": 1,
"selected": false,
"text": "df=data.frame(outer(1:5,1:5))\ndf[upper.tri(df)]=NA\n\n X1 X2 X3 X4 X5\n1 1 NA NA NA NA\n2 2 4 NA NA NA\n3 3 6 9 NA NA\n4 4 8 12 16 NA\n5 5 10 15 20 25\n\nsapply(df,function(x){c(x[!is.na(x)],rep(NA,sum(is.na(x))))})\n\n X1 X2 X3 X4 X5\n[1,] 1 4 9 16 25\n[2,] 2 6 12 20 NA\n[3,] 3 8 15 NA NA\n[4,] 4 10 NA NA NA\n[5,] 5 NA NA NA NA\n"
},
{
"answer_id": 74430361,
"author": "pluke",
"author_id": 948397,
"author_profile": "https://Stackoverflow.com/users/948397",
"pm_score": 0,
"selected": false,
"text": "rev"
},
{
"answer_id": 74430898,
"author": "ThomasIsCoding",
"author_id": 12158757,
"author_profile": "https://Stackoverflow.com/users/12158757",
"pm_score": 2,
"selected": false,
"text": "NA"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430103",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17118303/"
] |
74,430,104 | <p>on c# i have created a button to automatically download the SpotifySetup.exe and its all fine but it downloads to a folder at "\bin\Debug\net6.0-windows" but i dont want that i want to set a location to where i want the file to download.</p>
<p>this is the code i have bellow</p>
<pre><code> private void FileDownloadComplete(object sender, AsyncCompletedEventArgs e)
{
MessageBox.Show("Download Completed");
}
private void DownloadSpotify_Click(object sender, EventArgs e)
{
wc.DownloadFileCompleted += new AsyncCompletedEventHandler(FileDownloadComplete);
Uri fileurl = new Uri("https://download.scdn.co/SpotifySetup.exe");
wc.DownloadFileAsync(fileurl, "SpotifySetup.exe");
}
</code></pre>
<p>i want to set where the file downloads to, i do not want the file to download to the default location.</p>
| [
{
"answer_id": 74430323,
"author": "user2974951",
"author_id": 2974951,
"author_profile": "https://Stackoverflow.com/users/2974951",
"pm_score": 1,
"selected": false,
"text": "df=data.frame(outer(1:5,1:5))\ndf[upper.tri(df)]=NA\n\n X1 X2 X3 X4 X5\n1 1 NA NA NA NA\n2 2 4 NA NA NA\n3 3 6 9 NA NA\n4 4 8 12 16 NA\n5 5 10 15 20 25\n\nsapply(df,function(x){c(x[!is.na(x)],rep(NA,sum(is.na(x))))})\n\n X1 X2 X3 X4 X5\n[1,] 1 4 9 16 25\n[2,] 2 6 12 20 NA\n[3,] 3 8 15 NA NA\n[4,] 4 10 NA NA NA\n[5,] 5 NA NA NA NA\n"
},
{
"answer_id": 74430361,
"author": "pluke",
"author_id": 948397,
"author_profile": "https://Stackoverflow.com/users/948397",
"pm_score": 0,
"selected": false,
"text": "rev"
},
{
"answer_id": 74430898,
"author": "ThomasIsCoding",
"author_id": 12158757,
"author_profile": "https://Stackoverflow.com/users/12158757",
"pm_score": 2,
"selected": false,
"text": "NA"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17055100/"
] |
74,430,118 | <p>I am using plt.hist() function to show histogram. When I tried it on a smaller dataset, everything works fine.
However, my original dataset contains nearly 30k samples, for which I need to show on that histogram 6 values per sample.
I am aware this is a lot, but what I need help with is how to make the compilation time in my case smaller. I am okay waiting 10 minutes, but yesterday I was waiting for the result over an hour and I gave up.</p>
<p>How can I optimize it and reduce the compilation time?
My first idea was adding bins to that function, so something like this:</p>
<pre><code>plt.hist(values, bins=50)
</code></pre>
<p>But I am not sure what exactly bins do. Will this result in printing the histogram too general for my data or will it just take 50 first values from my data? Besides, will it shorten the compilation time?
What can I do?</p>
| [
{
"answer_id": 74430323,
"author": "user2974951",
"author_id": 2974951,
"author_profile": "https://Stackoverflow.com/users/2974951",
"pm_score": 1,
"selected": false,
"text": "df=data.frame(outer(1:5,1:5))\ndf[upper.tri(df)]=NA\n\n X1 X2 X3 X4 X5\n1 1 NA NA NA NA\n2 2 4 NA NA NA\n3 3 6 9 NA NA\n4 4 8 12 16 NA\n5 5 10 15 20 25\n\nsapply(df,function(x){c(x[!is.na(x)],rep(NA,sum(is.na(x))))})\n\n X1 X2 X3 X4 X5\n[1,] 1 4 9 16 25\n[2,] 2 6 12 20 NA\n[3,] 3 8 15 NA NA\n[4,] 4 10 NA NA NA\n[5,] 5 NA NA NA NA\n"
},
{
"answer_id": 74430361,
"author": "pluke",
"author_id": 948397,
"author_profile": "https://Stackoverflow.com/users/948397",
"pm_score": 0,
"selected": false,
"text": "rev"
},
{
"answer_id": 74430898,
"author": "ThomasIsCoding",
"author_id": 12158757,
"author_profile": "https://Stackoverflow.com/users/12158757",
"pm_score": 2,
"selected": false,
"text": "NA"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430118",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20183885/"
] |
74,430,130 | <p>I am trying to convert a text file into HTML using awk command in shell script. Since the text file is auto-generated from server it contains server reponses, there are some empty values in the file as shown below</p>
<pre><code>A 00
B 00
C
D
E 00
</code></pre>
<p>I want to replace this empty value with string "NULL" or "No response". Please suggest how it can be done.
<a href="https://i.stack.imgur.com/plTuw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/plTuw.png" alt="Table gererated from script for the above data" /></a></p>
<p>I have tried this</p>
<pre><code>awk '{print "<tr>";for(i=1;i<=NF;i++){
if($i==" ")
{
print "<td>$i</td>";
}
.........{some lines of code}
}'
</code></pre>
<p>Current Output
<a href="https://i.stack.imgur.com/us51k.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/us51k.png" alt="enter image description here" /></a>
Expected Output
<a href="https://i.stack.imgur.com/FEwKi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FEwKi.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74430323,
"author": "user2974951",
"author_id": 2974951,
"author_profile": "https://Stackoverflow.com/users/2974951",
"pm_score": 1,
"selected": false,
"text": "df=data.frame(outer(1:5,1:5))\ndf[upper.tri(df)]=NA\n\n X1 X2 X3 X4 X5\n1 1 NA NA NA NA\n2 2 4 NA NA NA\n3 3 6 9 NA NA\n4 4 8 12 16 NA\n5 5 10 15 20 25\n\nsapply(df,function(x){c(x[!is.na(x)],rep(NA,sum(is.na(x))))})\n\n X1 X2 X3 X4 X5\n[1,] 1 4 9 16 25\n[2,] 2 6 12 20 NA\n[3,] 3 8 15 NA NA\n[4,] 4 10 NA NA NA\n[5,] 5 NA NA NA NA\n"
},
{
"answer_id": 74430361,
"author": "pluke",
"author_id": 948397,
"author_profile": "https://Stackoverflow.com/users/948397",
"pm_score": 0,
"selected": false,
"text": "rev"
},
{
"answer_id": 74430898,
"author": "ThomasIsCoding",
"author_id": 12158757,
"author_profile": "https://Stackoverflow.com/users/12158757",
"pm_score": 2,
"selected": false,
"text": "NA"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430130",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20040019/"
] |
74,430,171 | <p>I have such a pyspark DataFrames:</p>
<p>df1:</p>
<pre class="lang-py prettyprint-override"><code>+--------------------+----------+----------+----------+----------+----------+------+-----------------+--------+
| NAME | X_NAME | BEGIN | END | A| B| C| D| E|
+--------------------+----------+----------+----------+----------+----------+------+-----------------+--------+
|whatever1 | XYZ|2021-09-27|2021-10-03| 0.0| 1.0| 0.0| 0.0| 0.0|
|whatever2 | XYZ|2021-09-27|2021-10-03| 0.0| 1.0| 0.0| 0.0| 0.0|
|whatever3 | XYZ|2021-10-04|2021-10-10| 0.0| 1.0| 0.0| 0.0| 0.0|
|whatever4 | XYZ|2021-10-04|2021-10-10| 0.0| 1.0| 0.0| 0.0| 0.0|
|whatever6 | XYZ|2021-10-18|2021-10-24| 0.0| 0.0| 1.0| 0.0| 0.0|
|whatever9 | XYZ|2021-10-25|2021-10-31| 0.0| 1.0| 0.0| 0.0| 0.0|
...
...
...
</code></pre>
<p>df2:</p>
<pre class="lang-py prettyprint-override"><code>+-------------------+-----+----+-------+
| start_of_week|month|year|week_no|
+-------------------+-----+----+-------+
|2021-12-06 00:00:00| 12|2021|2021W49|
|2021-12-13 00:00:00| 12|2021|2021W50|
|2021-12-20 00:00:00| 12|2021|2021W51|
|2021-12-27 00:00:00| 12|2021|2021W52|
|2022-01-03 00:00:00| 1|2022| 2022W1|
|2022-01-10 00:00:00| 1|2022| 2022W2|
|2022-01-17 00:00:00| 1|2022| 2022W3|
|2022-01-24 00:00:00| 1|2022| 2022W4|
|2022-01-31 00:00:00| 2|2022| 2022W5|
|2022-02-07 00:00:00| 2|2022| 2022W6|
|2020-11-16 00:00:00| 11|2020|2020W47|
|2020-11-23 00:00:00| 11|2020|2020W48|
|2020-11-30 00:00:00| 12|2020|2020W49|
|2020-12-07 00:00:00| 12|2020|2020W50|
|2020-12-14 00:00:00| 12|2020|2020W51|
|2020-12-21 00:00:00| 12|2020|2020W52|
|2020-12-28 00:00:00| 12|2020|2020W53|
|2021-01-04 00:00:00| 1|2021| 2021W1|
|2021-01-11 00:00:00| 1|2021| 2021W2|
|2020-07-06 00:00:00| 7|2020|2020W28|
|2020-07-13 00:00:00| 7|2020|2020W29|
|2020-07-20 00:00:00| 7|2020|2020W30|
|2020-07-27 00:00:00| 7|2020|2020W31|
|2020-08-03 00:00:00| 8|2020|2020W32|
|2020-08-10 00:00:00| 8|2020|2020W33|
|2020-08-17 00:00:00| 8|2020|2020W34|
|2020-08-24 00:00:00| 8|2020|2020W35|
|2020-08-31 00:00:00| 9|2020|2020W36|
|2020-09-07 00:00:00| 9|2020|2020W37|
|2021-03-22 00:00:00| 3|2021|2021W12|
|2021-03-29 00:00:00| 4|2021|2021W13|
|2021-04-05 00:00:00| 4|2021|2021W14|
|2021-04-12 00:00:00| 4|2021|2021W15|
|2021-04-19 00:00:00| 4|2021|2021W16|
|2021-04-26 00:00:00| 4|2021|2021W17|
|2021-05-03 00:00:00| 5|2021|2021W18|
|2021-05-10 00:00:00| 5|2021|2021W19|
|2021-05-17 00:00:00| 5|2021|2021W20|
|2021-05-24 00:00:00| 5|2021|2021W21|
|2022-08-22 00:00:00| 8|2022|2022W34|
|2022-08-29 00:00:00| 9|2022|2022W35|
|2022-09-05 00:00:00| 9|2022|2022W36|
|2022-09-12 00:00:00| 9|2022|2022W37|
|2022-09-19 00:00:00| 9|2022|2022W38|
|2022-09-26 00:00:00| 9|2022|2022W39|
|2022-10-03 00:00:00| 10|2022|2022W40|
|2022-10-10 00:00:00| 10|2022|2022W41|
|2022-10-17 00:00:00| 10|2022|2022W42|
|2022-10-24 00:00:00| 10|2022|2022W43|
|2020-09-14 00:00:00| 9|2020|2020W38|
|2020-09-21 00:00:00| 9|2020|2020W39|
|2020-09-28 00:00:00| 10|2020|2020W40|
|2020-10-05 00:00:00| 10|2020|2020W41|
|2020-10-12 00:00:00| 10|2020|2020W42|
|2020-10-19 00:00:00| 10|2020|2020W43|
|2020-10-26 00:00:00| 10|2020|2020W44|
|2020-11-02 00:00:00| 11|2020|2020W45|
|2020-11-09 00:00:00| 11|2020|2020W46|
|2020-05-04 00:00:00| 5|2020|2020W19|
|2020-05-11 00:00:00| 5|2020|2020W20|
|2020-05-18 00:00:00| 5|2020|2020W21|
|2020-05-25 00:00:00| 5|2020|2020W22|
|2020-06-01 00:00:00| 6|2020|2020W23|
|2020-06-08 00:00:00| 6|2020|2020W24|
|2020-06-15 00:00:00| 6|2020|2020W25|
|2020-06-22 00:00:00| 6|2020|2020W26|
|2020-06-29 00:00:00| 7|2020|2020W27|
|2021-10-04 00:00:00| 10|2021|2021W40|
|2021-10-11 00:00:00| 10|2021|2021W41|
|2021-10-18 00:00:00| 10|2021|2021W42|
|2021-10-25 00:00:00| 10|2021|2021W43|
|2021-11-01 00:00:00| 11|2021|2021W44|
|2021-11-08 00:00:00| 11|2021|2021W45|
|2021-11-15 00:00:00| 11|2021|2021W46|
|2021-11-22 00:00:00| 11|2021|2021W47|
|2021-11-29 00:00:00| 12|2021|2021W48|
|2022-02-14 00:00:00| 2|2022| 2022W7|
|2022-02-21 00:00:00| 2|2022| 2022W8|
|2022-02-28 00:00:00| 3|2022| 2022W9|
|2022-03-07 00:00:00| 3|2022|2022W10|
|2022-03-14 00:00:00| 3|2022|2022W11|
|2022-03-21 00:00:00| 3|2022|2022W12|
|2022-03-28 00:00:00| 3|2022|2022W13|
|2022-04-04 00:00:00| 4|2022|2022W14|
|2022-04-11 00:00:00| 4|2022|2022W15|
|2022-04-18 00:00:00| 4|2022|2022W16|
|2022-04-25 00:00:00| 4|2022|2022W17|
|2022-05-02 00:00:00| 5|2022|2022W18|
|2022-05-09 00:00:00| 5|2022|2022W19|
|2022-05-16 00:00:00| 5|2022|2022W20|
|2022-05-23 00:00:00| 5|2022|2022W21|
|2022-05-30 00:00:00| 6|2022|2022W22|
|2022-06-06 00:00:00| 6|2022|2022W23|
|2022-06-13 00:00:00| 6|2022|2022W24|
|2022-06-20 00:00:00| 6|2022|2022W25|
|2022-06-27 00:00:00| 6|2022|2022W26|
|2022-07-04 00:00:00| 7|2022|2022W27|
|2022-07-11 00:00:00| 7|2022|2022W28|
|2022-07-18 00:00:00| 7|2022|2022W29|
|2022-07-25 00:00:00| 7|2022|2022W30|
|2022-08-01 00:00:00| 8|2022|2022W31|
|2022-08-08 00:00:00| 8|2022|2022W32|
|2022-08-15 00:00:00| 8|2022|2022W33|
|2021-01-18 00:00:00| 1|2021| 2021W3|
|2021-01-25 00:00:00| 1|2021| 2021W4|
|2021-02-01 00:00:00| 2|2021| 2021W5|
|2021-02-08 00:00:00| 2|2021| 2021W6|
|2021-02-15 00:00:00| 2|2021| 2021W7|
|2021-02-22 00:00:00| 2|2021| 2021W8|
|2021-03-01 00:00:00| 3|2021| 2021W9|
|2021-03-08 00:00:00| 3|2021|2021W10|
|2021-03-15 00:00:00| 3|2021|2021W11|
|2020-03-02 00:00:00| 3|2020|2020W10|
|2020-03-09 00:00:00| 3|2020|2020W11|
|2020-03-16 00:00:00| 3|2020|2020W12|
|2020-03-23 00:00:00| 3|2020|2020W13|
|2020-03-30 00:00:00| 4|2020|2020W14|
|2020-04-06 00:00:00| 4|2020|2020W15|
|2020-04-13 00:00:00| 4|2020|2020W16|
|2020-04-20 00:00:00| 4|2020|2020W17|
|2020-04-27 00:00:00| 4|2020|2020W18|
|2021-05-31 00:00:00| 6|2021|2021W22|
|2021-06-07 00:00:00| 6|2021|2021W23|
|2021-06-14 00:00:00| 6|2021|2021W24|
|2021-06-21 00:00:00| 6|2021|2021W25|
|2021-06-28 00:00:00| 7|2021|2021W26|
|2021-07-05 00:00:00| 7|2021|2021W27|
|2021-07-12 00:00:00| 7|2021|2021W28|
|2021-07-19 00:00:00| 7|2021|2021W29|
|2021-07-26 00:00:00| 7|2021|2021W30|
|2021-08-02 00:00:00| 8|2021|2021W31|
|2021-08-09 00:00:00| 8|2021|2021W32|
|2021-08-16 00:00:00| 8|2021|2021W33|
|2021-08-23 00:00:00| 8|2021|2021W34|
|2021-08-30 00:00:00| 9|2021|2021W35|
|2021-09-06 00:00:00| 9|2021|2021W36|
|2021-09-13 00:00:00| 9|2021|2021W37|
|2021-09-20 00:00:00| 9|2021|2021W38|
|2021-09-27 00:00:00| 9|2021|2021W39|
|2019-12-30 00:00:00| 1|2020| 2020W1|
|2020-01-06 00:00:00| 1|2020| 2020W2|
|2020-01-13 00:00:00| 1|2020| 2020W3|
|2020-01-20 00:00:00| 1|2020| 2020W4|
|2020-01-27 00:00:00| 1|2020| 2020W5|
|2020-02-03 00:00:00| 2|2020| 2020W6|
|2020-02-10 00:00:00| 2|2020| 2020W7|
|2020-02-17 00:00:00| 2|2020| 2020W8|
|2020-02-24 00:00:00| 2|2020| 2020W9|
+-------------------+-----+----+-------+
</code></pre>
<p>I would like to divide these <code>BEGIN</code> and <code>END</code> ranges to smaller units - week numbers from the second DataFrame. So final DataFrame would have only <code>week_no</code> column instead of <code>BEGIN</code> and <code>END</code>. If the range is wider than one week, record would be multiplied to have more than one week number.</p>
<p>For example.:</p>
<pre class="lang-py prettyprint-override"><code>+--------------------+----------+----------+----------+----------+----------+------+-----------------+--------+
| NAME | X_NAME | BEGIN | END | A| B| C| D| E|
+--------------------+----------+----------+----------+----------+----------+------+-----------------+--------+
|whatever345 | XYZ|2021-12-07|2021-12-14| 0.0| 1.0| 0.0| 0.0| 0.0|
</code></pre>
<p>Would be:</p>
<pre class="lang-py prettyprint-override"><code>+--------------------+----------+----------+----------+----------+------+-----------------+--------+
| NAME | X_NAME | week_no | A| B| C| D| E|
+--------------------+----------+----------+----------+----------+------+-----------------+--------+
|whatever345 | XYZ| 2021W49| 0.0| 1.0| 0.0| 0.0| 0.0|
|whatever345 | XYZ| 2021W50| 0.0| 1.0| 0.0| 0.0| 0.0|
</code></pre>
| [
{
"answer_id": 74430323,
"author": "user2974951",
"author_id": 2974951,
"author_profile": "https://Stackoverflow.com/users/2974951",
"pm_score": 1,
"selected": false,
"text": "df=data.frame(outer(1:5,1:5))\ndf[upper.tri(df)]=NA\n\n X1 X2 X3 X4 X5\n1 1 NA NA NA NA\n2 2 4 NA NA NA\n3 3 6 9 NA NA\n4 4 8 12 16 NA\n5 5 10 15 20 25\n\nsapply(df,function(x){c(x[!is.na(x)],rep(NA,sum(is.na(x))))})\n\n X1 X2 X3 X4 X5\n[1,] 1 4 9 16 25\n[2,] 2 6 12 20 NA\n[3,] 3 8 15 NA NA\n[4,] 4 10 NA NA NA\n[5,] 5 NA NA NA NA\n"
},
{
"answer_id": 74430361,
"author": "pluke",
"author_id": 948397,
"author_profile": "https://Stackoverflow.com/users/948397",
"pm_score": 0,
"selected": false,
"text": "rev"
},
{
"answer_id": 74430898,
"author": "ThomasIsCoding",
"author_id": 12158757,
"author_profile": "https://Stackoverflow.com/users/12158757",
"pm_score": 2,
"selected": false,
"text": "NA"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430171",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20034347/"
] |
74,430,181 | <p>I was writing one query in which there is one join and one group by but on executing the query i got this error which is quite common but for reference this was the error</p>
<pre><code>Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'ipay_app.sp.code' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
</code></pre>
<p>the query is</p>
<pre><code>select sp.code,count(sps.sp_key)
from service_providers sp
left join service_providers_sub sps
on sp.code = sps.sp_key
group by sps.sp_key;
</code></pre>
<p><a href="https://i.stack.imgur.com/RwDGD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RwDGD.png" alt="image one before adding group by" /></a></p>
<p>but when i am adding sp.code in group by clause i am getting expected result .</p>
<p><a href="https://i.stack.imgur.com/aRJwR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aRJwR.png" alt="image two after adding group by" /></a></p>
<p>just wanted to make sure why ?</p>
| [
{
"answer_id": 74430266,
"author": "Zarian71",
"author_id": 15506660,
"author_profile": "https://Stackoverflow.com/users/15506660",
"pm_score": -1,
"selected": false,
"text": "SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));\n"
},
{
"answer_id": 74433996,
"author": "slaakso",
"author_id": 1052130,
"author_profile": "https://Stackoverflow.com/users/1052130",
"pm_score": 2,
"selected": false,
"text": "sp.code"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430181",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19231732/"
] |
74,430,201 | <p>I have the following dataset.</p>
<pre><code>col1 col2 col3
a 1 yes
a 1 no
b 1 no
a 3 yes
c 1 yes
b 2 yes
</code></pre>
<p>I have used the crosstab to create a table between col1 and col2 and count the observation.</p>
<pre><code>pd.crosstab(df.col1, df.col2)
output:
col2 1 2 3
col1
a 2 0 1
b 1 1 0
c 1 0 0
</code></pre>
<p><strong>If i want the same table for groupby col3, how will i do that?</strong></p>
<pre><code>Desired output:
col3: Yes col3: No
col2 1 2 3 col2 1 2 3
col1 col1
a 1 0 1 a 1 0 0
b 0 1 0 b 1 0 0
c 1 0 0 c 0 0 0
</code></pre>
<p>Moreover, Is there any way to visualize the table more presentable?</p>
| [
{
"answer_id": 74430266,
"author": "Zarian71",
"author_id": 15506660,
"author_profile": "https://Stackoverflow.com/users/15506660",
"pm_score": -1,
"selected": false,
"text": "SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));\n"
},
{
"answer_id": 74433996,
"author": "slaakso",
"author_id": 1052130,
"author_profile": "https://Stackoverflow.com/users/1052130",
"pm_score": 2,
"selected": false,
"text": "sp.code"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430201",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13019735/"
] |
74,430,216 | <p>Simple code and straightforward. It works with postman but fails with Apps Script.</p>
<pre><code>function validateAddress () {
const url = 'https://addressvalidation.googleapis.com/v1:validateAddress?key=';
const apikey = '...';
let payload, options, temp;
payload = JSON.stringify({
"address": {
"addressLines": "1600 Amphitheatre Pkwy"
}
});
options = {
'muteHttpExceptions': true,
'method': 'POST',
'Content-Type': 'application/json',
'body': payload
}
temp = UrlFetchApp.fetch(url + apikey, options);
Logger.log(temp)
}
</code></pre>
<p>Error:</p>
<pre><code>{
"error": {
"code": 400,
"message": "Address is missing from request.",
"status": "INVALID_ARGUMENT"
}
}
</code></pre>
<p><strong>EDIT:</strong></p>
<p>Change <code>options</code> to</p>
<pre><code> options = {
'muteHttpExceptions': true,
'method': 'POST',
'Content-Type': 'application/json',
'payload': payload
}
</code></pre>
<p>Gives error:</p>
<pre><code>{
"error": {
"code": 400,
"message": "Invalid JSON payload received. Unknown name \"{\"address\":{\"addressLines\":\"1600 Amphitheatre Pkwy\"}}\": Cannot bind query parameter. Field '{\"address\":{\"addressLines\":\"1600 Amphitheatre Pkwy\"}}' could not be found in request message.",
"status": "INVALID_ARGUMENT",
"details": [
{
"@type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"description": "Invalid JSON payload received. Unknown name \"{\"address\":{\"addressLines\":\"1600 Amphitheatre Pkwy\"}}\": Cannot bind query parameter. Field '{\"address\":{\"addressLines\":\"1600 Amphitheatre Pkwy\"}}' could not be found in request message."
}
]
}
]
}
}
</code></pre>
<p>Documentation:
<a href="https://developers.google.com/maps/documentation/address-validation/requests-validate-address" rel="nofollow noreferrer">https://developers.google.com/maps/documentation/address-validation/requests-validate-address</a></p>
| [
{
"answer_id": 74430420,
"author": "ValLeNain",
"author_id": 3410584,
"author_profile": "https://Stackoverflow.com/users/3410584",
"pm_score": 2,
"selected": true,
"text": "addressLines"
},
{
"answer_id": 74432366,
"author": "sangnandar",
"author_id": 1907366,
"author_profile": "https://Stackoverflow.com/users/1907366",
"pm_score": 0,
"selected": false,
"text": "options"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430216",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1907366/"
] |
74,430,223 | <p>is there any methode while doing resampling() to ffill() or bfill() a object column?</p>
<p>Suppose we have:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Date</th>
<th>Sort</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>2022-10-23 15:40:41</td>
<td>A</td>
<td>1</td>
</tr>
<tr>
<td>2022-10-23 18:43:13</td>
<td>B</td>
<td>2</td>
</tr>
<tr>
<td>2022-10-24 15:40:41</td>
<td>C</td>
<td>3</td>
</tr>
<tr>
<td>2022-10-24 18:43:13</td>
<td>D</td>
<td>4</td>
</tr>
</tbody>
</table>
</div>
<p>i would like to have following results with:</p>
<pre><code>df.resample("15min").mean()
</code></pre>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Date</th>
<th>Sort</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>2022-10-23 15:45:00</td>
<td>A</td>
<td>1</td>
</tr>
<tr>
<td>2022-10-23 16:00:00</td>
<td>A</td>
<td>1</td>
</tr>
<tr>
<td>2022-10-23 16:15:00</td>
<td>A</td>
<td>1</td>
</tr>
<tr>
<td>2022-10-23 16:35:00</td>
<td>A</td>
<td>1</td>
</tr>
<tr>
<td>...</td>
<td>...</td>
<td>...</td>
</tr>
<tr>
<td>2022-10-23 18:00:00</td>
<td>D</td>
<td>1</td>
</tr>
<tr>
<td>2022-10-23 18:15:00</td>
<td>D</td>
<td>1</td>
</tr>
<tr>
<td>2022-10-23 18:30:00</td>
<td>D</td>
<td>1</td>
</tr>
<tr>
<td>2022-10-23 18:45:00</td>
<td>D</td>
<td>1</td>
</tr>
</tbody>
</table>
</div>
<p>but it always kick out the "sort column".
would be nice if anyone here can help!</p>
<p>best
M.</p>
| [
{
"answer_id": 74430420,
"author": "ValLeNain",
"author_id": 3410584,
"author_profile": "https://Stackoverflow.com/users/3410584",
"pm_score": 2,
"selected": true,
"text": "addressLines"
},
{
"answer_id": 74432366,
"author": "sangnandar",
"author_id": 1907366,
"author_profile": "https://Stackoverflow.com/users/1907366",
"pm_score": 0,
"selected": false,
"text": "options"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430223",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10107452/"
] |
74,430,225 | <p>I want to write horizontal bullet points in latex. How can I do that? as far as I got some solution on the internet is a vertical list with numbers.</p>
<p>How can I get bullet points instead of numbers?</p>
<p>My current code is something like this-</p>
<pre><code> \documentclass[twoside = false, % doppelseitiger Druck
DIV=17, % DIV Faktor für Satzspiegelberechnung, sie Doku zu KOMA Script
BCOR=15mm, % Bindekorrektur
chapterprefix=false,
headinclude=true,
footinclude=false,
pagesize, % write pagesize to DVI or PDF
fontsize=11pt, % use this font size
paper=a4, % use ISO A4
bibliography=totoc, % write bibliography-chapter to table of contents
index=totoc, % write index-chapter to table of contents
cleardoublepage=plain, % \cleardoublepage generates pages with pagestyle empty
headings=big, % A4/B5
listof=flat, % improved list of tables
numbers=noenddot
]{scrbook}
\begin{inparaenum}
\item A
\item B
\item C
\item D
\item E
\item F
\item G
\end{inparaenum}
\end{document}
</code></pre>
<p><img src="https://i.stack.imgur.com/KZCd4.png" alt="enter image description here" /></p>
| [
{
"answer_id": 74430878,
"author": "Ieva B.",
"author_id": 14047474,
"author_profile": "https://Stackoverflow.com/users/14047474",
"pm_score": -1,
"selected": false,
"text": "\\documentclass{article}\n\n\\usepackage[inline]{enumitem}\n\n\\begin{document}\n\nText before list.\n\\begin{enumerate*}\n \\item My first in list.\n \\item My second in list.\n\\end{enumerate*}\nText after list.\n\n\\end{document}\n"
},
{
"answer_id": 74431891,
"author": "sebo1234",
"author_id": 18275876,
"author_profile": "https://Stackoverflow.com/users/18275876",
"pm_score": 3,
"selected": true,
"text": "paralist"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430225",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19665666/"
] |
74,430,234 | <p>I'm working on my Python homework of: Write a program that requests a sentence, a word in the sentence, and another word and then displays the sentence with the first word replaced by the second.</p>
<p>The hint says to use the method "find" to help solve it but i can't think of a way to do so.</p>
<pre><code>sentence = input("Enter a sentence.")
word = input("Enter word to replace. ")
replacement = input("Enter replacement word. ")
A = sentence.find(word)
print(sentencereplacement)
</code></pre>
<p>I'm not sure how to use find and what to print in the end.</p>
| [
{
"answer_id": 74430878,
"author": "Ieva B.",
"author_id": 14047474,
"author_profile": "https://Stackoverflow.com/users/14047474",
"pm_score": -1,
"selected": false,
"text": "\\documentclass{article}\n\n\\usepackage[inline]{enumitem}\n\n\\begin{document}\n\nText before list.\n\\begin{enumerate*}\n \\item My first in list.\n \\item My second in list.\n\\end{enumerate*}\nText after list.\n\n\\end{document}\n"
},
{
"answer_id": 74431891,
"author": "sebo1234",
"author_id": 18275876,
"author_profile": "https://Stackoverflow.com/users/18275876",
"pm_score": 3,
"selected": true,
"text": "paralist"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20482987/"
] |
74,430,243 | <p>I have two data frames dat1 and dat2. I will like to compare the values of the similar columns in the two data frames and returned the highest value.</p>
<p>How can I compare value of two table and return highest value in r?</p>
<pre><code>library(reshape2)
dat1 <- data.frame(sn=c("v1","v2"), A=c(1,0), B=c(0,1), C=c(0,0), D=c(1,0))
dat2 <- data.frame(sn=c("v1","v2", "v3"), A=c(1,0,1), C=c(1,0,1), B=c(0,0,1))
</code></pre>
<pre><code>dat1:
sn A B C D
v1 1 0 0 1
v2 0 1 0 0
dat2:
sn A C B
v1 1 1 0
v2 0 0 0
v3 1 1 1
dt1 <- melt(dat1,"sn")
dt2 <- melt(dat2,"sn")
dt3 <- merge(dt1,dt2,by=c("sn","variable"))
dt3$value <- max(dt3$value.x, dt3$value.y)
#I got the following which is not correct.
dt3:
sn variable value.x value.y value
v1 A 1 1 1
v1 B 0 0 1
v1 C 0 1 1
v2 A 0 0 1
v2 B 1 0 1
v2 C 0 0 1
#I will like dt3 to return the following
dt3:
dt3
sn variable value.x value.y value
v1 A 1 1 1
v1 B 0 0 0
v1 C 0 1 1
v2 A 0 0 0
v2 B 1 0 1
v2 C 0 0 0
</code></pre>
| [
{
"answer_id": 74430878,
"author": "Ieva B.",
"author_id": 14047474,
"author_profile": "https://Stackoverflow.com/users/14047474",
"pm_score": -1,
"selected": false,
"text": "\\documentclass{article}\n\n\\usepackage[inline]{enumitem}\n\n\\begin{document}\n\nText before list.\n\\begin{enumerate*}\n \\item My first in list.\n \\item My second in list.\n\\end{enumerate*}\nText after list.\n\n\\end{document}\n"
},
{
"answer_id": 74431891,
"author": "sebo1234",
"author_id": 18275876,
"author_profile": "https://Stackoverflow.com/users/18275876",
"pm_score": 3,
"selected": true,
"text": "paralist"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430243",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9150522/"
] |
74,430,245 | <p><strong>Goal:</strong> Set multiple values in the DECLARE statement to use in the WHERE statement.</p>
<p><strong>Issue:</strong> Cannot successfully add multiple values in the SET statement.</p>
<p><strong>Example of what I’m trying to complete:</strong></p>
<pre><code>DECLARE @Beverage as varchar(1000)
SET @Beverage = (‘Water’, ‘Soda’, ‘Wine’, ‘Beer’)
SELECT Beverage
FROM ExampleServer
WHERE Beverage in (@Beverage)
</code></pre>
<p><strong>Example of what currently executes correctly:</strong></p>
<pre><code>DECLARE @Beverage as varchar(1000)
SET @Beverage = (‘Water’)
SELECT Beverage
FROM ExampleServer
WHERE Beverage in (@Beverage)
</code></pre>
| [
{
"answer_id": 74430878,
"author": "Ieva B.",
"author_id": 14047474,
"author_profile": "https://Stackoverflow.com/users/14047474",
"pm_score": -1,
"selected": false,
"text": "\\documentclass{article}\n\n\\usepackage[inline]{enumitem}\n\n\\begin{document}\n\nText before list.\n\\begin{enumerate*}\n \\item My first in list.\n \\item My second in list.\n\\end{enumerate*}\nText after list.\n\n\\end{document}\n"
},
{
"answer_id": 74431891,
"author": "sebo1234",
"author_id": 18275876,
"author_profile": "https://Stackoverflow.com/users/18275876",
"pm_score": 3,
"selected": true,
"text": "paralist"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430245",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20499469/"
] |
74,430,300 | <p>I am trying to replace a word in a string with the current timestamp and for this I am using sed. However, sed updates the string with a single time timestamp value for all the 1000 records. How can I update the records so that I get actual timestamp.</p>
<pre><code>cat toreplacefile.txt
TIMESTAMP_line1
TIMESTAMP_line2
TIMESTAMP_line3
TIMESTAMP_line4
TIMESTAMP_line5
sed 's/TIMESTAMP/$(date +"%Y-%m-%dT%H:%M:%S.%3N")/g' toreplacefile.txt
2022-11-14T10:11:43.654_line1
2022-11-14T10:11:43.654_line2
2022-11-14T10:11:43.654_line3
2022-11-14T10:11:43.654_line4
2022-11-14T10:11:43.654_line5
However, what I am expecting is a time change atleast in milliseconds.
2022-11-14T10:11:43.654_line1
2022-11-14T10:11:43.656_line2
2022-11-14T10:11:43.657_line3
2022-11-14T10:11:43.660_line4
2022-11-14T10:11:43.661_line5
</code></pre>
| [
{
"answer_id": 74430878,
"author": "Ieva B.",
"author_id": 14047474,
"author_profile": "https://Stackoverflow.com/users/14047474",
"pm_score": -1,
"selected": false,
"text": "\\documentclass{article}\n\n\\usepackage[inline]{enumitem}\n\n\\begin{document}\n\nText before list.\n\\begin{enumerate*}\n \\item My first in list.\n \\item My second in list.\n\\end{enumerate*}\nText after list.\n\n\\end{document}\n"
},
{
"answer_id": 74431891,
"author": "sebo1234",
"author_id": 18275876,
"author_profile": "https://Stackoverflow.com/users/18275876",
"pm_score": 3,
"selected": true,
"text": "paralist"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430300",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18194450/"
] |
74,430,301 | <p>I have just started working with singlar.net and i came across this code but i dont know how to find out "your connection string" in the appsettings.json.</p>
<p>Please can someone help me with this!?</p>
<pre><code>
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"SqlServer": "Your connection string"
}
}
</code></pre>
<p>set a connection string for the database</p>
| [
{
"answer_id": 74430878,
"author": "Ieva B.",
"author_id": 14047474,
"author_profile": "https://Stackoverflow.com/users/14047474",
"pm_score": -1,
"selected": false,
"text": "\\documentclass{article}\n\n\\usepackage[inline]{enumitem}\n\n\\begin{document}\n\nText before list.\n\\begin{enumerate*}\n \\item My first in list.\n \\item My second in list.\n\\end{enumerate*}\nText after list.\n\n\\end{document}\n"
},
{
"answer_id": 74431891,
"author": "sebo1234",
"author_id": 18275876,
"author_profile": "https://Stackoverflow.com/users/18275876",
"pm_score": 3,
"selected": true,
"text": "paralist"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430301",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20499618/"
] |
74,430,304 | <p>I have a collection of lists of integer values in python like the following:</p>
<pre><code>[0, 0, 1, 0, 1, 0, 0, 2, 1, 1, 1, 2, 1]
</code></pre>
<p>Now I would like to have a somewhat "smoothed" sequence where each value with the same preceding and following value (which both differ from the central value in question) is replaced with this preceeding-following value. So my list above becomes:</p>
<pre><code>[0, 0, 0, 0, 0, 0, 0, 2, 1, 1, 1, 1, 1]
</code></pre>
<p>(The order or procession is from left to right, just to reconcile possible conflicting groupings.)</p>
<p>How could I achieve list?</p>
<p>Bonus: same as above with possible parametrization how many preceeding-following values must occur to change the central value (2-2 or 3-3 instead of just 1-1).</p>
| [
{
"answer_id": 74430503,
"author": "islam abdelmoumen",
"author_id": 19661530,
"author_profile": "https://Stackoverflow.com/users/19661530",
"pm_score": 0,
"selected": false,
"text": "arr = [0, 0, 1, 0, 1, 0, 0, 2, 1, 1, 1, 2, 1]\n\nres = [arr[0]]\ni = 0\n\nfor i in range(1,len(arr)):\n\n if res[i-1] not in arr[i:i+2]:\n res.append(arr[i])\n\n else:\n res.append(res[i-1] )\nprint(res)\n"
},
{
"answer_id": 74430566,
"author": "Cobra",
"author_id": 17580381,
"author_profile": "https://Stackoverflow.com/users/17580381",
"pm_score": 2,
"selected": true,
"text": "_list = [0, 0, 1, 0, 1, 0, 0, 2, 1, 1, 1, 2, 1]\n\nfor i in range(1, len(_list)-1):\n if _list[i-1] == _list[i+1]:\n _list[i] = _list[i-1]\n\nprint(_list)\n"
},
{
"answer_id": 74430696,
"author": "Stuart",
"author_id": 567595,
"author_profile": "https://Stackoverflow.com/users/567595",
"pm_score": 0,
"selected": false,
"text": "def smooth(lst, values=1, padding=None):\n padded = [padding] * values + lst + [padding] * values\n for i, n in enumerate(lst):\n surrounding = set(padded[i:i+values] + padded[i+values+1:i+values*2+1])\n if len(surrounding) == 1:\n yield surrounding.pop()\n else:\n yield n\n\nprint(list(smooth([0, 0, 1, 0, 1, 0, 0, 2, 1, 1, 1, 2, 1]))) # [0, 0, 0, 1, 0, 0, 0, 2, 1, 1, 1, 1, 1]\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430304",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4495790/"
] |
74,430,312 | <p>I'm programming a discord bot which should start some comands including a timer and two surveys every tuesday and thursday at 11.30 am.</p>
<p>Unfortunately the documentary is outdated and older articles in stack overflow do not work anymore. How do I do that in Python or is this impossible? The single commands are already programmed and work without problems.</p>
| [
{
"answer_id": 74430503,
"author": "islam abdelmoumen",
"author_id": 19661530,
"author_profile": "https://Stackoverflow.com/users/19661530",
"pm_score": 0,
"selected": false,
"text": "arr = [0, 0, 1, 0, 1, 0, 0, 2, 1, 1, 1, 2, 1]\n\nres = [arr[0]]\ni = 0\n\nfor i in range(1,len(arr)):\n\n if res[i-1] not in arr[i:i+2]:\n res.append(arr[i])\n\n else:\n res.append(res[i-1] )\nprint(res)\n"
},
{
"answer_id": 74430566,
"author": "Cobra",
"author_id": 17580381,
"author_profile": "https://Stackoverflow.com/users/17580381",
"pm_score": 2,
"selected": true,
"text": "_list = [0, 0, 1, 0, 1, 0, 0, 2, 1, 1, 1, 2, 1]\n\nfor i in range(1, len(_list)-1):\n if _list[i-1] == _list[i+1]:\n _list[i] = _list[i-1]\n\nprint(_list)\n"
},
{
"answer_id": 74430696,
"author": "Stuart",
"author_id": 567595,
"author_profile": "https://Stackoverflow.com/users/567595",
"pm_score": 0,
"selected": false,
"text": "def smooth(lst, values=1, padding=None):\n padded = [padding] * values + lst + [padding] * values\n for i, n in enumerate(lst):\n surrounding = set(padded[i:i+values] + padded[i+values+1:i+values*2+1])\n if len(surrounding) == 1:\n yield surrounding.pop()\n else:\n yield n\n\nprint(list(smooth([0, 0, 1, 0, 1, 0, 0, 2, 1, 1, 1, 2, 1]))) # [0, 0, 0, 1, 0, 0, 0, 2, 1, 1, 1, 1, 1]\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430312",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20110561/"
] |
74,430,322 | <p>I wanted to ask you somthing that i cant understand why it works.
i need to make a code that you input some number and it gives you all the prime numbers until you get to that num.</p>
<p>now i have this code that does the trick.
like every number that is not prime it goes to the next n and checks it but i dont understand this
if like it gets 4 and then turns it to 5 the j wont go to 3? and then you start checking 5/3 but you miss the division by 2 and so on like i dont get it does it resets the j to 2 every time that i edd i+1?</p>
<p>also if i give it like 10 it prints 11 and i dont want it to pass the original number how do i do that.</p>
<p>int num;</p>
<pre><code>printf("please enter num ");
scanf_s("%d", &num);
int i, j;
for (i = 2; i < num; i++)
{
for (j = 2; j < i; j++)
{
printf("j=%d ", j);
if (i % j == 0)
i += 1;
}
printf("%d ", i);
}
</code></pre>
| [
{
"answer_id": 74431388,
"author": "Support Ukraine",
"author_id": 4386427,
"author_profile": "https://Stackoverflow.com/users/4386427",
"pm_score": 0,
"selected": false,
"text": "int num;\nprintf(\"please enter num \");\nscanf(\"%d\", &num);\nint i, j;\nfor (i = 2; i < num; i++)\n{\n for (j = 2; j < i; j++)\n { \n // commented out printf(\"j=%d \", j);\n\n if (i % j == 0)\n i += 1;\n }\n printf(\"%d \", i);\n}\n"
},
{
"answer_id": 74433438,
"author": "chux - Reinstate Monica",
"author_id": 2410359,
"author_profile": "https://Stackoverflow.com/users/2410359",
"pm_score": 2,
"selected": false,
"text": "num"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19684848/"
] |
74,430,391 | <p>I have the code for range search in a BST:</p>
<pre><code>#include<bits/stdc++.h>
using namespace std;
class node{
public:
int data;
node *left;
node *right;
};
void nodesInRange(node *root, int k1, int k2){
if ( NULL == root )
return;
if ( k1 < root->data )
nodesInRange(root->left, k1, k2);
if ( k1 <= root->data && k2 >= root->data )
cout<<root->data<<",";
if ( k2 > root->data )
nodesInRange(root->right, k1, k2);
}
node* insert(int data){
node *temp = new node();
temp->data = data;
temp->left = NULL;
temp->right = NULL;
return temp;
}
int main(){
node *root = new node();
int k1 = 12, k2 = 25;
root = insert(20);
root->left = insert(10);
root->right = insert(24);
root->left->left = insert(8);
root->left->right = insert(15);
root->right->right = insert(32);
cout<<”The values of node within the range are\t”;
nodesInRange(root, k1, k2);
return 0;
}
</code></pre>
<p>The code<code>cout<<root->data<<",";</code> result <code>15,20,24,</code>
But I want to print <code>15,20,24</code>, how do I do that?</p>
<p>I've tried using <code>string.erase()</code> or insert comma before each entry except the first, but they don't work in this case and they would just remove all commas in the result like <code>152024</code>.</p>
| [
{
"answer_id": 74430852,
"author": "bitmask",
"author_id": 430766,
"author_profile": "https://Stackoverflow.com/users/430766",
"pm_score": 0,
"selected": false,
"text": "','"
},
{
"answer_id": 74430907,
"author": "Ted Lyngmo",
"author_id": 7582247,
"author_profile": "https://Stackoverflow.com/users/7582247",
"pm_score": 1,
"selected": false,
"text": "nodesInRange"
},
{
"answer_id": 74431002,
"author": "Marek R",
"author_id": 1387438,
"author_profile": "https://Stackoverflow.com/users/1387438",
"pm_score": 1,
"selected": false,
"text": "void forEachInRange(node* root, int k1, int k2, std::function<void(int data)> f)\n{\n if ( NULL == root )\n return;\n if ( k1 < root->data )\n forEachInRange(root->left, k1, k2, f);\n if ( k1 <= root->data && k2 >= root->data )\n f(root->data);\n if ( k2 > root->data )\n forEachInRange(root->right, k1, k2, f);\n}\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13908614/"
] |
74,430,404 | <p>I have a DF</p>
<pre><code>df = spark.sql("""select number,name,owner,support,user,business_unit from table""")
</code></pre>
<p>I want to rename <code>owner.display_value</code> as <code>owner_display_value</code> and <code>support.display_value</code> as <code>support_display_value</code></p>
<p>owner column and support column is a struct, hence i'm obtaining only the display_value from the column.</p>
<pre><code>df2 = df.select("number","name","owner.display_value" as owner_display_value,"support.display_value" as support_display_value, "user_group","business_unit")
</code></pre>
<p>But I get error</p>
<blockquote>
<p>'DataFrame' object has no attribute 'rename'.</p>
</blockquote>
| [
{
"answer_id": 74430628,
"author": "Steven",
"author_id": 5013752,
"author_profile": "https://Stackoverflow.com/users/5013752",
"pm_score": 2,
"selected": true,
"text": "df2 = df.select(\n \"number\",\n \"name\",\n \"owner.display_value\" as owner_display_value,\n \"support.display_value\" as support_display_value, \n \"user_group\",\n \"business_unit\"\n)\n"
},
{
"answer_id": 74432126,
"author": "Azhar Khan",
"author_id": 2847330,
"author_profile": "https://Stackoverflow.com/users/2847330",
"pm_score": 0,
"selected": false,
"text": "F.col(\"column_name\").alias(\"new_name\")"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430404",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8259636/"
] |
74,430,446 | <br/>
I wrote a simple python script that creates a 7x7 list of dots '.', I want to change the diagonal to stars '*'. <br/>Here is my script
<pre><code>n=7
l=['.']*n
m=[l]*n
for i in range(n):
for j in range(n):
if i==j:
m[i][j]='*'
print(*m[i])
</code></pre>
<p>Here is the output I get</p>
<pre><code>* . . . . . .
* * . . . . .
* * * . . . .
* * * * . . .
* * * * * . .
* * * * * * .
* * * * * * *
</code></pre>
<p>I don't understand why I have such output, when I added an else statement it works fine.<br/>
Did I miss something ?</p>
| [
{
"answer_id": 74430556,
"author": "Jakub Kuszneruk",
"author_id": 1565454,
"author_profile": "https://Stackoverflow.com/users/1565454",
"pm_score": 1,
"selected": true,
"text": "m"
},
{
"answer_id": 74430585,
"author": "AdmiJW",
"author_id": 14033758,
"author_profile": "https://Stackoverflow.com/users/14033758",
"pm_score": 2,
"selected": false,
"text": "if"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430446",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3733333/"
] |
74,430,485 | <p>I have a string variable which dependes on "i" variable, i want to call this string, like his method:</p>
<pre><code>String nameSetClassifiedMethod= "setClassficationdesc" + i;
</code></pre>
<p>and i wanted something like this:</p>
<pre><code>this.nameSetClassifiedMethod( some parametersIn);
</code></pre>
<p>I know this is not possible, because i can't invoke a method with a string like im doing, but i don't know any solutions for this.</p>
<p>I have some code that's whic is not mine, which is doing something like:</p>
<pre><code>if (i == 0) {this.setClassficationdesc0(..)}
if (i == 1) {this.setClassficationdesc1(..)}
if (i == 2) {this.setClassficationdesc2(..)}
</code></pre>
<p>So i'm trying to invoke the method by string to reduce complexity</p>
| [
{
"answer_id": 74430556,
"author": "Jakub Kuszneruk",
"author_id": 1565454,
"author_profile": "https://Stackoverflow.com/users/1565454",
"pm_score": 1,
"selected": true,
"text": "m"
},
{
"answer_id": 74430585,
"author": "AdmiJW",
"author_id": 14033758,
"author_profile": "https://Stackoverflow.com/users/14033758",
"pm_score": 2,
"selected": false,
"text": "if"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430485",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5738388/"
] |
74,430,512 | <p>eg</p>
<pre><code>Arun,Mishra,108,23,34,45,56,Mumbai
</code></pre>
<p>o\p I want is</p>
<pre><code>Arun,Mishra,108.23,34,45,56,Mumbai
</code></pre>
<p>Tried to replace the comma with dot but all the demiliters are replaced with comma</p>
<p>tried <code>text.replace(',','.')</code> but replacing all the commas with dot</p>
| [
{
"answer_id": 74430598,
"author": "3dSpatialUser",
"author_id": 5775358,
"author_profile": "https://Stackoverflow.com/users/5775358",
"pm_score": 2,
"selected": false,
"text": "import re\n\nold_str = 'Arun,Mishra,108,23,34,45,56,Mumbai'\nnew_str = re.sub(r'(\\d+)(,)(\\d+)', r'\\1.\\3', old_str, 1)\n>>> 'Arun,Mishra,108.23,34,45,56,Mumbai'\n"
},
{
"answer_id": 74430631,
"author": "Nikhil Belure",
"author_id": 14086220,
"author_profile": "https://Stackoverflow.com/users/14086220",
"pm_score": -1,
"selected": false,
"text": "s= 'Arun,Mishra,108,23,34,45,56,Mumbai '\nls = s.split(',')\nls[2] = '.'.join([ls[2], ls[3]])\nls.pop(3)\ns = ','.join(ls)\n"
},
{
"answer_id": 74430861,
"author": "Devrim Mert Yöyen",
"author_id": 20466471,
"author_profile": "https://Stackoverflow.com/users/20466471",
"pm_score": -1,
"selected": false,
"text": "txt = \"2459,12 is the best number. lets change the dots . with commas , 458,45.\"\n\ncommaindex = 0\n\nwhile commaindex != -1:\n commaindex = txt.find(\",\",commaindex+1)\n if txt[commaindex-1].isnumeric() and txt[commaindex+1].isnumeric():\n txt = txt[0:commaindex] + \".\" + txt[commaindex+1:len(txt)+1]\n \nprint(txt)\n"
},
{
"answer_id": 74430908,
"author": "Cobra",
"author_id": 17580381,
"author_profile": "https://Stackoverflow.com/users/17580381",
"pm_score": 0,
"selected": false,
"text": "s = 'Arun,Mishra,108,23,34,45,56,Mumbai'\n\npos = 1\n\nwhile (pos := s.find(',', pos, len(s)-1)) > 0:\n if s[pos-1].isdigit() and s[pos+1].isdigit():\n s = s[:pos] + '.' + s[pos+1:]\n break\n pos += 1\n\nprint(s)\n"
},
{
"answer_id": 74430984,
"author": "JohnXF",
"author_id": 5284011,
"author_profile": "https://Stackoverflow.com/users/5284011",
"pm_score": 0,
"selected": false,
"text": "$ echo \"Arun,Mishra,108,23,34,45,56,Mumbai\" | sed -r \"s/([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*)/\\1,\\2,\\3.\\4,\\5,\\6,\\7,\\8/\"\nArun,Mishra,108.23,34,45,56,Mumbai\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20499762/"
] |
74,430,552 | <p>I have a table where the first column remains fixed. I want the table to be vertically scrollable. I think I'm close, the below nearly does what I want, the only issue is the table rows are not as wide as the columns and I'm not sure why?</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>.table th:first-child,
.table td:first-child {
position: sticky;
left: 0;
background-color: #ad6c80;
color: #373737;
}
table {
height: 300px;
}
tbody {
overflow-y: scroll;
height: 200px;
width: 100%;
position: absolute;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><!doctype html>
<html>
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="https://unpkg.com/bootstrap-table@1.21.1/dist/bootstrap-table.min.css">
</head>
<body>
<div class="container">
<table class="table table-bordered table-hover" data=toggle="table" data-search="true" data-show-columns="true">
<thead>
<tr>
<th scope='col' data-sortable="true">Column 1</th>
<th scope='col'>Column 2</th>
<th scope='col'>Column 3</th>
<th scope='col'>Column 4</th>
<th scope='col'>Column 5</th>
<th scope='col'>Column 6</th>
<th scope='col'>Column 7</th>
<th scope='col'>Column 8</th>
<th scope='col'>Column 9</th>
</tr>
</thead>
<tbody>
<tr>
<td>Conf</td>
<td>even 20 trail A</td>
<td>True</td>
<td>False</td>
<td>0</td>
<td>True</td>
<td>True</td>
<td>True</td>
<td>True</td>
</tr>
<tr>
<td>Conf</td>
<td>even 20 trail B</td>
<td>True</td>
<td>False</td>
<td>0</td>
<td>True</td>
<td>True</td>
<td>True</td>
<td>True</td>
</tr>
<tr>
<td>Conf</td>
<td>even 20 trail A</td>
<td>True</td>
<td>False</td>
<td>0</td>
<td>True</td>
<td>True</td>
<td>True</td>
<td>True</td>
</tr>
<tr>
<td>Conf</td>
<td>even 20 trail B</td>
<td>True</td>
<td>False</td>
<td>0</td>
<td>True</td>
<td>True</td>
<td>True</td>
<td>True</td>
</tr>
<tr>
<td>Conf</td>
<td>even 20 trail A</td>
<td>True</td>
<td>False</td>
<td>0</td>
<td>True</td>
<td>True</td>
<td>True</td>
<td>True</td>
</tr>
<tr>
<td>Conf</td>
<td>even 20 trail B</td>
<td>True</td>
<td>False</td>
<td>0</td>
<td>True</td>
<td>True</td>
<td>True</td>
<td>True</td>
</tr>
<tr>
<td>Conf</td>
<td>even 20 trail A</td>
<td>True</td>
<td>False</td>
<td>0</td>
<td>True</td>
<td>True</td>
<td>True</td>
<td>True</td>
</tr>
<tr>
<td>Conf</td>
<td>even 20 trail B</td>
<td>True</td>
<td>False</td>
<td>0</td>
<td>True</td>
<td>True</td>
<td>True</td>
<td>True</td>
</tr>
<tr>
<td>Conf</td>
<td>even 20 trail A</td>
<td>True</td>
<td>False</td>
<td>0</td>
<td>True</td>
<td>True</td>
<td>True</td>
<td>True</td>
</tr>
<tr>
<td>Conf</td>
<td>even 20 trail B</td>
<td>True</td>
<td>False</td>
<td>0</td>
<td>True</td>
<td>True</td>
<td>True</td>
<td>True</td>
</tr>
<tr>
<td>Conf</td>
<td>even 20 trail A</td>
<td>True</td>
<td>False</td>
<td>0</td>
<td>True</td>
<td>True</td>
<td>True</td>
<td>True</td>
</tr>
<tr>
<td>Conf</td>
<td>even 20 trail B</td>
<td>True</td>
<td>False</td>
<td>0</td>
<td>True</td>
<td>True</td>
<td>True</td>
<td>True</td>
</tr>
</tbody>
</table>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://unpkg.com/bootstrap-table@1.21.1/dist/bootstrap-table.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js">
</script>
<script>
$(document).ready(function() {
$('table').bootstrapTable();
});
</script>
</body>
</html></code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74430730,
"author": "R-b-n",
"author_id": 3153039,
"author_profile": "https://Stackoverflow.com/users/3153039",
"pm_score": -1,
"selected": false,
"text": "tbody{\n overflow-y: scroll;\n height: 200px;\n width: 100%;\n position: absolute;\n }\n"
},
{
"answer_id": 74469241,
"author": "Cristian",
"author_id": 11256424,
"author_profile": "https://Stackoverflow.com/users/11256424",
"pm_score": 2,
"selected": false,
"text": "position"
},
{
"answer_id": 74471694,
"author": "CryptoAlgorithm",
"author_id": 13409955,
"author_profile": "https://Stackoverflow.com/users/13409955",
"pm_score": 2,
"selected": false,
"text": "overflow: auto"
},
{
"answer_id": 74484173,
"author": "Alvin",
"author_id": 9239975,
"author_profile": "https://Stackoverflow.com/users/9239975",
"pm_score": 1,
"selected": false,
"text": "/* This is the container*/\n.fixed-table-body {\n position: relative;\n height: 200px !important; /* This is not required in a normal situation, now it is just to make it work the bootstrap style container */\n}\n\n/* We make table absolute to keep elements in place */\ntable {\n position: absolute;\n}\n\n\n/* Make column sticky to left */\ntable th:first-child,\ntable td:first-child {\n position: sticky;\n left: 0;\n background-color: #ad6c80;\n color: #373737;\n}\n\n/* We make the headers sticky */\nth {\n position: sticky;\n z-index: 1; /* To overlap sticky column */\n background: white; /* If not will be transparent */\n}\n\ntable th:first-child {\n z-index: 2; /* To make 1st th element overlap its siblings */\n}\n\n/* Optional fix for default behaviour */\nth {\n top: -1px; /* This fixes small html alignment issue when a table element is fixed to top */\n border-top: 0 !important;\n border-bottom: 0 !important;\n}\n\n/* This must be the container of the th elements. define borders */\n.th-inner {\n border-top:1px solid #dee2e6;\n border-bottom:1px solid #dee2e6;\n}"
},
{
"answer_id": 74490075,
"author": "petern0691",
"author_id": 16015991,
"author_profile": "https://Stackoverflow.com/users/16015991",
"pm_score": 2,
"selected": false,
"text": "#myTable thead tr th,\n#myTable tbody tr td:first-child {\n background-color: #ad6c80;\n color: #373737;\n}\n\n/* Remove this if sticky column headers are not required for vertical scrolling */\n#myTable thead {\n position: sticky;\n top: 0px;\n /* Ensure first column header is not scrolled over on vertical scroll */\n /* Only required if sticky row headers are also required */\n z-index: 1;\n}\n\n/* Remove this if sticky row headers are not required for horizontal scrolling */\n#myTable thead tr th:first-child {\n position: sticky;\n left: 0px;\n}\n\n/* Remove this if sticky row headers are not required for horizontal scrolling */\n#myTable tbody tr td:first-child {\n position: sticky;\n left: 0px;\n}\n\n/* For this example, force scrolling by overiding boostrap */\n.bootstrap-table .fixed-table-container .fixed-table-body {\n height: 500px !important;\n width: 700px !important;\n}"
},
{
"answer_id": 74510465,
"author": "Alivia Pramanik",
"author_id": 19915328,
"author_profile": "https://Stackoverflow.com/users/19915328",
"pm_score": 0,
"selected": false,
"text": "table {\n height: 300px;\n}\n\ntbody {\n overflow-y: scroll;\n height: 200px;\n width: 100%;\n position: absolute;}\n"
},
{
"answer_id": 74550697,
"author": "Jayanika Chandrapriya",
"author_id": 10383509,
"author_profile": "https://Stackoverflow.com/users/10383509",
"pm_score": 1,
"selected": false,
"text": "thead"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430552",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2730554/"
] |
74,430,562 | <p>How do I display the common number? but if other numbers are just as common, I want to be able to display multiple.</p>
<p>So I have an array with a max length of 24, I can generate random number between 1-100 and sort them.</p>
<p>Looks something like this..
2
8
9
10
13
19
20
38
43
47
51
55
55
59
66
67
73
84
87
87
93
95
98
100</p>
<p>So the most common numbers are 55 and 87, as 55 and 87 show up twice.</p>
<p>Here's my code..</p>
<pre><code>private void buttonMode_Click(object sender, EventArgs e)
{
int mode = 0;
int max = 0;
var counts = new Dictionary<int, int>();
foreach (int value in dataArray)
{
if (counts.ContainsKey(value))
{
counts[value]++;
}
else
{
counts.Add(value, 1);
}
}
foreach(KeyValuePair<int,int> count in counts)
{
if (count.Value > max)
{
mode = count.Key;
max = count.Value;
}
}
textBoxOut1.Text = $"Mode is: {mode}";
}
</code></pre>
<p>This only displays the lowest common value, which using the example above would be 55 only.
I've searched and by using .Max this can be done, but how?</p>
| [
{
"answer_id": 74430640,
"author": "Tim Schmelter",
"author_id": 284240,
"author_profile": "https://Stackoverflow.com/users/284240",
"pm_score": 1,
"selected": false,
"text": "GroupBy"
},
{
"answer_id": 74430943,
"author": "swatsonpicken",
"author_id": 1185279,
"author_profile": "https://Stackoverflow.com/users/1185279",
"pm_score": 0,
"selected": false,
"text": "foreach"
},
{
"answer_id": 74431417,
"author": "Caveman74",
"author_id": 2032864,
"author_profile": "https://Stackoverflow.com/users/2032864",
"pm_score": 0,
"selected": false,
"text": "var dict = dataArray.GroupBy(x => x)\n .ToDictionary(x => x.Key, x => x.Count());\nvar max = dict.Values.Max();\nvar modes = dict.Where(x => x.Value == max)\n .Select(x => x.Key);\n"
},
{
"answer_id": 74454176,
"author": "ProgrammingLlama",
"author_id": 3181933,
"author_profile": "https://Stackoverflow.com/users/3181933",
"pm_score": 2,
"selected": true,
"text": "Dictionary<int, int>"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430562",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20155033/"
] |
74,430,573 | <p>I am trying to connect to my Exasol SaaS database, I tried via these tools(TALEND, DBVISUALIZER, POWERBI) and via python but I cannot connect and I keep getting the same error.</p>
<p>I saw another post on Exasol community <a href="https://community.exasol.com/t5/discussion-forum/exaconnectionfailederror/m-p/8049#M1855" rel="nofollow noreferrer">https://community.exasol.com/t5/discussion-forum/exaconnectionfailederror/m-p/8049#M1855</a> of this type of error but it doesn't explain exactly what was done to fix the error. I tried via the ODBC Data Source administrator(64-bit) too but still the same error. Maybe its an connection issue with my pc self but I'm not sure or maybe I am just inserting wrong values I don't know.</p>
<p>Oh the values I inserted are the recommended ones from what Exasol docs states and I have removed anything about proxy or vpn.</p>
<p>I put my errors under. I tried via different devices and I get the same error I really don't know what I can do any more, so any help will be greatly appreciated.</p>
<p>Note: I am using the Exasol SaaS database and I am currently on the trial mode so I am not sure if this is limiting me.</p>
<pre>
**Errors: **
Error message odbc exasol: [EXASOL][EXASolution driver]connection attempt timed out.
Error message Talend : Connection failure. You must change the Database Settings.
java.lang.RuntimeException: com.exasol.jdbc.ConnectFailed: connect timed out ->
Caused by: com.exasol.jdbc.ConnectFailed: connect timed out
Error message pyexasol : socket.timeout: timed out
Error message dbvisualizer : java.net.SocketTimeoutException: Connect timed out com.exasol.jdbc.ConnectFailed: java.net.SocketTimeoutException: Connect timed out
Error message Power BI desktop : Details: "ODBC: ERROR [HYT00][EXASOL][EXASolution driver]Connection attempt timed out."
</pre>
<pre>
My applications versions:
DbVisualizer Free 14.0.1 (build: 3540)
Talend Open Studio Data integration(8.0.1.2021119_1610)
java version -> jdk-16.0.02
Power BI -> Version: 2.110.1085.0 64-bit (October 2022)
ODBC : exasolodbc x64 7.1.14
JDBC : exasoljdbc 7.1.14
Python: python 3.8.10 -> pyexasol : 0.25.1
</pre>
| [
{
"answer_id": 74430640,
"author": "Tim Schmelter",
"author_id": 284240,
"author_profile": "https://Stackoverflow.com/users/284240",
"pm_score": 1,
"selected": false,
"text": "GroupBy"
},
{
"answer_id": 74430943,
"author": "swatsonpicken",
"author_id": 1185279,
"author_profile": "https://Stackoverflow.com/users/1185279",
"pm_score": 0,
"selected": false,
"text": "foreach"
},
{
"answer_id": 74431417,
"author": "Caveman74",
"author_id": 2032864,
"author_profile": "https://Stackoverflow.com/users/2032864",
"pm_score": 0,
"selected": false,
"text": "var dict = dataArray.GroupBy(x => x)\n .ToDictionary(x => x.Key, x => x.Count());\nvar max = dict.Values.Max();\nvar modes = dict.Where(x => x.Value == max)\n .Select(x => x.Key);\n"
},
{
"answer_id": 74454176,
"author": "ProgrammingLlama",
"author_id": 3181933,
"author_profile": "https://Stackoverflow.com/users/3181933",
"pm_score": 2,
"selected": true,
"text": "Dictionary<int, int>"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430573",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15048010/"
] |
74,430,596 | <pre><code>A = np.array([[4, 3, 2],
[1, 2, 3],
[0, -1, 5]])
shift = np.array([1,2,1])
out = np.array([[3, 2, np.nan],
[3, np.nan, np.nan],
[-1, 5, np.nan]])
</code></pre>
<p>I want to left shift the 2D numpy array towards the left for each row independently as given by the shift vector and impute the right with Nan.</p>
<p>Please help me out with this</p>
<p>Thanks</p>
| [
{
"answer_id": 74430640,
"author": "Tim Schmelter",
"author_id": 284240,
"author_profile": "https://Stackoverflow.com/users/284240",
"pm_score": 1,
"selected": false,
"text": "GroupBy"
},
{
"answer_id": 74430943,
"author": "swatsonpicken",
"author_id": 1185279,
"author_profile": "https://Stackoverflow.com/users/1185279",
"pm_score": 0,
"selected": false,
"text": "foreach"
},
{
"answer_id": 74431417,
"author": "Caveman74",
"author_id": 2032864,
"author_profile": "https://Stackoverflow.com/users/2032864",
"pm_score": 0,
"selected": false,
"text": "var dict = dataArray.GroupBy(x => x)\n .ToDictionary(x => x.Key, x => x.Count());\nvar max = dict.Values.Max();\nvar modes = dict.Where(x => x.Value == max)\n .Select(x => x.Key);\n"
},
{
"answer_id": 74454176,
"author": "ProgrammingLlama",
"author_id": 3181933,
"author_profile": "https://Stackoverflow.com/users/3181933",
"pm_score": 2,
"selected": true,
"text": "Dictionary<int, int>"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430596",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6455600/"
] |
74,430,604 | <p>I have created a custom appbar that contains buttons.The Problem is I cannot click on these buttons. I have checked the buttons with an output but not happened.</p>
<p>main.dart</p>
<pre><code>class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
initialRoute: '/',
routes: <String, WidgetBuilder>{
'/': (BuildContext context) {
return const HomeScreen();
},
'/archive': (BuildContext context) {
return const ArchiveScreen();
}
},
);
}
}
</code></pre>
<p>HomeScreen.dart</p>
<pre><code>class HomeScreen extends StatelessWidget {
const HomeScreen({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Stack(
children: const [
Indexed(
index: 10,
child: Positioned(bottom: 0, left: 0, child: BottomNav()),
),
Indexed(
index: 1,
child: Positioned(
bottom: 0,
left: 0,
right: 0,
top: 0,
child: Text("hallo"),
),
),
],
),
),
);
}
}
</code></pre>
<p>BottomBar.dart</p>
<pre><code>class BottomNav extends StatefulWidget with PreferredSizeWidget {
const BottomNav({super.key});
@override
Size get preferredSize => const Size.fromHeight(70.0);
@override
State<BottomNav> createState() => _BottomNavState();
}
class _BottomNavState extends State<BottomNav> {
@override
Widget build(BuildContext context) {
final Size size = MediaQuery.of(context).size;
return Container(
width: size.width,
height: 60,
decoration: const BoxDecoration(
border: Border(
top: BorderSide(width: 1.0, color: Color(0xFF999999)),
),
color: Color(0xFFF0F1F4),
),
child: Stack(
children: [
Align(
alignment: const Alignment(0, -0.5),
child: SizedBox(
width: 0,
height: 0,
child: OverflowBox(
minWidth: 0.0,
maxWidth: 100.0,
minHeight: 0.0,
maxHeight: 100.0,
child: Container(
width: 64,
height: 64,
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(100)),
color: Color(0xFF00007F)),
child: IconButton(
icon: SvgPicture.asset('assets/icons/search-navbar.svg'),
tooltip: 'Increase volume by 10',
onPressed: () => {
Navigator.pushNamed(context, '/'),
debugPrint("home")
},
),
),
),
),
),
Align(
alignment: const Alignment(-0.8, 0),
child: IconButton(
icon: SvgPicture.asset('assets/icons/archive.svg'),
tooltip: 'Increase volume by 11',
onPressed: () => {
Navigator.pushNamed(context, '/archive'),
debugPrint("archive")
},
),
),
],
),
);
}
}
</code></pre>
<p><img src="https://i.stack.imgur.com/fl2j0.png" alt="Screenshot of app" /></p>
<p>My first thought was that the cause is the stack and there is an element above the button. So I removed all the elements so that there was only one button in the appbar, but it didn't help.</p>
| [
{
"answer_id": 74430835,
"author": "manhtuan21",
"author_id": 8921450,
"author_profile": "https://Stackoverflow.com/users/8921450",
"pm_score": 1,
"selected": false,
"text": "onPressed: () => {\n Navigator.pushNamed(context, '/'),\n debugPrint(\"home\")\n},\n"
},
{
"answer_id": 74430986,
"author": "Stellar Creed",
"author_id": 1723187,
"author_profile": "https://Stackoverflow.com/users/1723187",
"pm_score": 0,
"selected": false,
"text": "Stack(\n children: [\n const Indexed(\n index: 10,\n child: Positioned(bottom: 0, left: 0, child: BottomNav()),\n ),\n Indexed( /// <- this widget is above the BottomNav and it covers the entire area\n index: 1,\n child: Positioned(\n bottom: 0,\n left: 0,\n right: 0,\n top: 0,\n child: Container(\n color: Colors.red,\n child: Text(\"hallo\"),\n ),\n ),\n ),\n ],\n )\n"
},
{
"answer_id": 74431750,
"author": "Patrickj",
"author_id": 20372186,
"author_profile": "https://Stackoverflow.com/users/20372186",
"pm_score": 0,
"selected": false,
"text": " minWidth: 0.0,\n maxWidth: 100.0,\n minHeight: 0.0,\n maxHeight: 100.0,\n child: Container(\n width: 64,\n height: 64,\n decoration: const BoxDecoration(\n borderRadius: BorderRadius.all(Radius.circular(100)),\n color: Color(0xFF00007F)),\n child: IconButton(\n icon: SvgPicture.asset('assets/icons/search-navbar.svg'),\n tooltip: 'Increase volume by 10',\n onPressed: () {\n /* Navigator.pushNamed(context, '/'); */\n debugPrint(\"home\");\n }),\n ),\n ),\n ),\n ),\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20372186/"
] |
74,430,656 | <p>Let A be a matrix:</p>
<pre><code>A = array([[0. , 0. , 0. , ..., 0. , 0. ,
0. ],
[0. , 0.28867513, 0.28867513, ..., 0. , 0. ,
0. ],
[0. , 0. , 0. , ..., 0. , 0. ,
0. ],
[0. , 0. , 0. , ..., 0. , 0. ,
0. ],
[0. , 0.13363062, 0.13363062, ..., 0. , 0. ,
0. ]])
B = array([0.70710678, 0.66666667, 0.5 , 0.75 , 1. ])
</code></pre>
<p>I need to find the indexes of B in A.</p>
<p>Expected Output:</p>
<pre><code>Matrix containing position of elements.
</code></pre>
<p>I want to perform this using inbuilt numpy commands/ logic and not using list comprehension or for loops.</p>
<p>Update: Already tried using isin, unable to tackle multiple elements with same value in the same row.</p>
<p>Updated with a better example of the problem.</p>
| [
{
"answer_id": 74430723,
"author": "SiP",
"author_id": 14826251,
"author_profile": "https://Stackoverflow.com/users/14826251",
"pm_score": 1,
"selected": false,
"text": "numpy.all"
},
{
"answer_id": 74449177,
"author": "hpaulj",
"author_id": 901925,
"author_profile": "https://Stackoverflow.com/users/901925",
"pm_score": 0,
"selected": false,
"text": "In [436]: A = [[0, 1, 2, 3],\n ...: [4, 5, 6, 7],\n ...: [8, 9, 10, 11]]\n ...: \n ...: B = [2, 5, 11]\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430656",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11706289/"
] |
74,430,673 | <p>I have a variable named <code>duration.video</code> in the following format <code>hh:mm:ss</code> that I would like to recode into a categorical variable ('Less than 5 minutes', 'between 5 and 30 min', etc.)</p>
<p>Here is my line of code:</p>
<pre><code>video$Duration.video<-as.factor(car::recode(
video$Duration.video,
"00:00:01:00:04:59='Less than 5 minutes';00:05:00:00:30:00='Between 5 and 30 minutes';00:30:01:01:59:59='More than 30 minutes and less than 2h';02:00:00:08:00:00='2h and more'"
))
</code></pre>
<p>The code does not work because all the values of the variable are put in one category ('Between 5 and 30 minutes').</p>
<p>I think it's because my variable is in character format but I can't convert it to numeric. And also maybe the format with ":" can be a problem for the recoding in R.</p>
<p>I tried to convert to <code>data.table::ITime</code> but the result remains the same.</p>
| [
{
"answer_id": 74430830,
"author": "Eric",
"author_id": 7091646,
"author_profile": "https://Stackoverflow.com/users/7091646",
"pm_score": 2,
"selected": false,
"text": "library(lubridate)\nlibrary(dplyr)\n\ndf <- data.frame(\n duration_string = c(\"00:00:03\",\"00:00:06\",\"00:12:00\",\"00:31:00\",\"01:12:01\")\n )\n\ndf <- df %>%\n mutate(\n duration = as.duration(hms(duration_string)),\n cat_duration = case_when(\n duration < dseconds(5) ~ \"less than 5 secs\",\n duration >= dseconds(5) & duration < dminutes(30) ~ \"between 5 secs and 30 mins\",\n duration >= dminutes(30) & duration < dhours(1) ~ \"between 30 mins and 1 hour\",\n duration > dhours(1) ~ \"more than 1 hour\",\n ) ,\n cat_duration = factor(cat_duration,levels = c(\"less than 5 secs\",\n \"between 5 secs and 30 mins\",\n \"between 30 mins and 1 hour\",\n \"more than 1 hour\"\n ))\n ) \n"
},
{
"answer_id": 74433698,
"author": "G. Grothendieck",
"author_id": 516548,
"author_profile": "https://Stackoverflow.com/users/516548",
"pm_score": 0,
"selected": false,
"text": "factor"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20499688/"
] |
74,430,690 | <p>I've been struggling with loading <code>Map</code> from localstorage couple of days. A <code>Map</code> is created in action reducer and it's successfully serialized and saved into localstorage. The problem becomes with loading it on refresh (flag <code>rehydrate</code> is set to <code>true</code>). Seems like the <code>Map</code> is successfully deserialized, but it's not existing in the new state after <code>@ngrx/store/init</code> action (only after refresh), there is just <code>{}</code> (empty object) instead. I'm also wondering why it's <code>null</code> (which is correct) after first init (page load; with empty localstorage) and <code>{}</code> after other init (refresh).</p>
<p>I've tried also <code>replacer</code> and <code>reviver</code> functions</p>
<blockquote>
<ul>
<li>replacer: A replacer function as specified in the JSON.stringify documentation.</li>
<li>reviver: A reviver function as specified in the JSON.parse documentation.</li>
</ul>
</blockquote>
<p>But without success.</p>
<p>I created <a href="https://stackblitz.com/edit/angular-ivy-dbjopn?file=src/store/reducers/index.ts" rel="nofollow noreferrer">Stackblitz project</a>.</p>
<p>Any help is appreciated.</p>
| [
{
"answer_id": 74438828,
"author": "Jimmy",
"author_id": 4960765,
"author_profile": "https://Stackoverflow.com/users/4960765",
"pm_score": 0,
"selected": false,
"text": "rehydratedState"
},
{
"answer_id": 74452347,
"author": "Lonli-Lokli",
"author_id": 462669,
"author_profile": "https://Stackoverflow.com/users/462669",
"pm_score": 1,
"selected": false,
"text": "mergeReducer"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430690",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4741929/"
] |
74,430,704 | <p>I have a csv file that looks like the following:</p>
<pre><code>Halley Bailey - 1998
Hayley Orrantia (1994-) American actress, singer, and songwriter
Ken Watanabe (actor)
etc...
</code></pre>
<p>I’d like to remove the items in the parentheses, as well as the commas in some of the names that have commas, so that the dataframe looks like this:</p>
<pre><code>Halley Bailey
Hayley Orrantia
Ken Watanabe
</code></pre>
<p>I attempted using the following code, which succeeds in removing the dates after the name, but not the parentheses or things after commmas, how could I expand it so it can replace all these items?</p>
<pre><code>regex = '|'.join(map(re.escape, df['actors']))
</code></pre>
| [
{
"answer_id": 74438828,
"author": "Jimmy",
"author_id": 4960765,
"author_profile": "https://Stackoverflow.com/users/4960765",
"pm_score": 0,
"selected": false,
"text": "rehydratedState"
},
{
"answer_id": 74452347,
"author": "Lonli-Lokli",
"author_id": 462669,
"author_profile": "https://Stackoverflow.com/users/462669",
"pm_score": 1,
"selected": false,
"text": "mergeReducer"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430704",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20330965/"
] |
74,430,743 | <p>Good Morning</p>
<p>I'm having an issue converting a Base64 string back to a byte stream when using a compressed file. There appears to be a difference in the byte arrays between a pre converted string from python vs a byte conversion in Java.</p>
<p><strong>UPDATED:</strong></p>
<p>Apologies, I think my explanation left something to desire. I've attempted to simplify the issue into two scenarios.</p>
<p><strong>Scenario 1: Java Only (Successful scenario)</strong></p>
<p>A compressed file encoded as base64 is received into my Java application from a message queue...</p>
<p>H4sIAAAAAAAA/3WSzW7sIAyF9zyFd7PJS0xX7aaq1JG6ZsAJdAiOwBlu3v4eyGwrRVGCfzjfsW+B"C9O6V6U7U5WV6RGzJ5mp2YNkV7XUc8y3jZ40MP3KgwupjB8NkWdz6xmXikNBLxfISZ73GiWbD3I2"X5QWVspChVMvMG+IZq6VVs5T73SQLzE/aD2oIWK+kjTEyMeln7EtGsynZEY4JUr85ESSh4jUCz7l"Lh6K5xlaPIVYqUnx5p2PCQSHQQaut7UXydDD/1xU9l3+CdITB386qG7gPMnIdo9sPuj8WyUvtFfz"E4Rmhg4NVqFiZsKt913JDpdAqRPtYRpnh+xkYe3HRI0vT4bh3PUX2ZcwWphr7hajB54sCvsLzVZh"voBYcSdVlY3UJqi8IJYqQ2uWNiACCjAGsGmExITSF/t7f11hnE1dfHetWXVBpXExX7DecaUHbzpi"z8gNeDGBNqUzXfo4nMWGdIrGWc0bjJkFQiuXp81ap74C5odTOrmxPzV62HIOyknymGhVi+vMtY/S"O1jnsVpLkZbMrWFIqCiY3vB624pYF4DzcqcvAD7uvNgxyICyF+SffH9G/gMaqXG6/wIAAA==</p>
<p>It is passed through the following code...</p>
<pre><code>byte[] decodedPayload = inlineAttachment.getPayload().getBytes("UTF-8");
decodedPayload = Base64.getMimeDecoder().decode(inlineAttachment.getPayload());
if (inlineAttachment.isCompressed()) {
GZIPInputStream inputStream = new GZIPInputStream(new ByteArrayInputStream(decodedPayload));
payload = inputStream.readAllBytes();
}
</code></pre>
<p>There are no issues with this the file is decompressed.
It should be noted that the decodedPayload before the decompression looks like this as a string…</p>
<p>��������u��n� ��<�w��KLW�ԑ�f� t��n���l+EQ�8߱o�ӺW�;S����'��كdW��s̷��40�ʃ��
�gs���CA/�I��%�r6_�V�B�S/0o�f��V�S�t�/1?h=�!b��4��ǥ��-̧dF8%J��D����>�.��Z<�X�I�杏 �A�������\T�]� �:�n�<��v�l>��[%/�W��f�
V�bf�]��@��ag��da��D�/O����ٗ0Z�k���,
��Va��Xq'U���&�� �*Ck�6
0�i�Ą��{]a�M]|w�YuA�q1_��q�o:b��
x1�6�3]�8�ņt��Y���B+���Z���S:��?5z�r�I�hU��̵��;X�ZK��̭aH�(���zۊX��r�/�>��1Ȁ��|F��q����</p>
<p>and this as a byte string...</p>
<p>[31, -117, 8, 0, 0, 0, 0, 0, 0, -1, 117, -110, -51, 110, -20, 32, 12, -123, -9, 60, -123, 119, -77, -55, 75, 76, 87, -19, -90, -86, -44, -111, -70, 102, -64, 9, 116, 8, -114, -64,…</p>
<p><strong>Scenario 2: Python Base64 decode before Java decompression</strong></p>
<p>This time around we start off in the Python application, the Python application receives the base64 string and decodes it via the following...</p>
<pre><code>bpayload = payload.encode('utf-8')
splitLines = bpayload.splitlines()
splitlinesb = b''.join(splitLines)
value, defects = decode_b(splitlinesb)
</code></pre>
<p>In python the base64 byte array is as follows...</p>
<p>b"\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xffu\x92\xcdn\xec \x0c\x85\xf7<\x85w\xb3\xc9KLW\xed\xa6\xaa\xd4\x91\xbaf\xc0\tt\x08\x8e\xc0\x19n\xde\xfe\x1e\xc8l+EQ\x82\x7f8\xdf\xb1o\x81\x0b\xd3\xbaW\xa5;S\x95\x95\xe9\x11\xb3'\x99\xa9\xd9\x83dW\xb5\xd4s\xcc\xb7\x8d\x9e40\xfd\xca\x83\x0b\xa9\x8c\x1f\r\x91gs\xeb\x19\x97\x8aCA/\x17\xc8I\x9e\xf7\x1a%\x9b\x0fr6_\x94\x16V\xcaB\x85S/0o\x88f\xae\x95V\xceS\xeft\x90/1?h=\xa8!b\xbe\x924\xc4\xc8\xc7\xa5\x9f\xb1-\x1a\xcc\xa7dF8%J\xfc\xe4D\x92\x87\x88\xd4\x0b>\xe5.\x1e\x8a\xe7\x19Z<\x85X\xa9I\xf1\xe6\x9d\x8f\t\x04\x87A\x06\xae\xb7\xb5\x17\xc9\xd0\xc3\xff\T\xf6]\xfe\t\xd2\x13\x07\x7f:\xa8n\xe0<\xc9\xc8v\x8fl>\xe8\xfc[%/\xb4W\xf3\x13\x84f\x86\x0e\rV\xa1bf\xc2\xad\xf7]\xc9\x0e\x97@\xa9\x13\xeda\x1ag\x87\xecda\xed\xc7D\x8d/O\x86\xe1\xdc\xf5\x17\xd9\x970Z\x98k\xee\x16\xa3\x07\x9e,\n\xfb\x0b\xcdVa\xbe\x80Xq'U\x95\x8d\xd4&\xa8\xbc \x96*Ck\x966 \x02\n0\x06\xb0i\x84\xc4\x84\xd2\x17\xfb{\x7f]a\x9cM]|w\xadYuA\xa5q1_\xb0\xdeq\xa5\x07o:b\xcf\xc8\rx1\x816\xa53]\xfa8\x9c\xc5\x86t\x8a\xc6Y\xcd\x1b\x8c\x99\x05B+\x97\xa7\xcdZ\xa7\xbe\x02\xe6\x87S:\xb9\xb1?5z\xd8r\x0e\xcaI\xf2\x98hU\x8b\xeb\xcc\xb5\x8f\xd2;X\xe7\xb1ZK\x91\x96\xcc\xadaH\xa8(\x98\xde\xf0z\xdb\x8aX\x17\x80\xf3r\xa7/\x00>\xee\xbc\xd81\xc8\x80\xb2\x17\xe4\x9f|\x7fF\xfe\x03\x1a\xa9q\xba\xff\x02\x00\x00”</p>
<p>This is then placed into a message queue, the data looks like (covering all views of the data)...</p>
<p>\u001f\ufffd\b\u0000\u0000\u0000\u0000\u0000\u0000\ufffdu\ufffd\ufffdn\ufffd \f\ufffd\ufffd<\ufffdw\ufffd\ufffdKLW\ufffd\ufffd\ufffd\u0511\ufffdf\ufffd\tt\b\ufffd\ufffd\u0019n\ufffd\ufffd\u001e\ufffdl+EQ\ufffd\u007f8\u07f1o\ufffd\u000b\u04faW\ufffd;S\ufffd\ufffd\ufffd\u0011\ufffd'\ufffd\ufffd\u0643dW\ufffd\ufffds\u0337\ufffd\ufffd40\ufffd\u0283\u000b\ufffd\ufffd\u001f\r\ufffdgs\ufffd\u0019\ufffd\ufffdCA/\u0017\ufffdI\ufffd\ufffd\u001a%\ufffd\u000fr6_\ufffd\u0016V\ufffdB\ufffdS/0o\ufffdf\ufffd\ufffdV\ufffdS\ufffdt\ufffd/1?h=\ufffd!b\ufffd\ufffd4\ufffd\ufffd\u01e5\ufffd\ufffd-\u001a\u0327dF8%J\ufffd\ufffdD\ufffd\ufffd\ufffd\ufffd\u000b>\ufffd.\u001e\ufffd\ufffd\u0019Z<\ufffdX\ufffdI\ufffd\u674f\t\u0004\ufffdA\u0006\ufffd\ufffd\ufffd\u0017\ufffd\ufffd\ufffd\ufffd\T\ufffd]\ufffd\t\ufffd\u0013\u0007\u007f:\ufffdn\ufffd<\ufffd\ufffdv\ufffdl>\ufffd\ufffd[%/\ufffdW\ufffd\u0013\ufffdf\ufffd\u000e\rV\ufffdbf\u00ad\ufffd]\ufffd\u000e\ufffd@\ufffd\u0013\ufffda\u001ag\ufffd\ufffdda\ufffd\ufffdD\ufffd/O\ufffd\ufffd\ufffd\ufffd\u0017\u06570Z\ufffdk\ufffd\u0016\ufffd\u0007\ufffd,\n\ufffd\u000b\ufffdVa\ufffd\ufffdXq'U\ufffd\ufffd\ufffd&\ufffd\ufffd \ufffd*Ck\ufffd6 \u0002\n0\u0006\ufffdi\ufffd\u0104\ufffd\u0017\ufffd{\u007f]a\ufffdM]|w\ufffdYuA\ufffdq1_\ufffd\ufffdq\ufffd\u0007o:b\ufffd\ufffd\rx1\ufffd6\ufffd3]\ufffd8\ufffd\u0146t\ufffd\ufffdY\ufffd\u001b\ufffd\ufffd\u0005B+\ufffd\ufffd\ufffdZ\ufffd\ufffd\u0002\ufffdS:\ufffd\ufffd?5z\ufffdr\u000e\ufffdI\ufffdhU\ufffd\ufffd\u0335\ufffd\ufffd;X\ufffdZK\ufffd\ufffd\u032daH\ufffd(\ufffd\ufffd\ufffdz\u06caX\u0017\ufffd\ufffdr\ufffd/\u0000>\ufffd\ufffd1\u0200\ufffd\u0017\ufffd|\u007fF\ufffd\u0003\u001a\ufffdq\ufffd\ufffd\u0002\u0000\u0000</p>
<p>We now get to the <strong>Java side</strong>, the message is pulled off the queue and we attempt to decompress the given message only as the Base64 decode has already occurred...</p>
<pre><code>byte[] decodedPayload = inlineAttachment.getPayload().getBytes("UTF-8");
if (inlineAttachment.isCompressed()) {
GZIPInputStream inputStream = new GZIPInputStream(new ByteArrayInputStream(decodedPayload));
payload = inputStream.readAllBytes();
}
</code></pre>
<p>The decoded payload looks like this as a string...</p>
<p>��������u��n� ��<�w��KLW���ԑ�f� t��n���l+EQ�8߱o�ӺW�;S����'��كdW��s̷��40�ʃ��
�gs���CA/�I��%�r6_�V�B�S/0o�f��V�S�t�/1?h=�!b��4��ǥ��-̧dF8%J��D����>�.��Z<�X�I�杏 �A�������\T�]� �:�n�<��v�l>��[%/�W��f�
V�bf�]��@��ag��da��D�/O����ٗ0Z�k���,
��Va��Xq'U���&�� �*Ck�6
0�i�Ą��{]a�M]|w�YuA�q1_��q�o:b��
x1�6�3]�8�ņt��Y���B+���Z���S:��?5z�r�I�hU��̵��;X�ZK��̭aH�(���zۊX��r�/�>��1Ȁ��|F��q����</p>
<p>and this is the byte array...</p>
<p>[31, -17, -65, -67, 8, 0, 0, 0, 0, 0, 0, -17, -65, -67, 117, -17, -65, -67, -17, -65, -67, 110, -17, -65, -67, 32, 12, -17, -65, -67, -17, -65, -67, 60, -17, -65, -67, 119...</p>
<p>There is a difference at this point between the Java version which is KLW���ԑ�f� vs KLW�ԑ�f� in the first line.</p>
<p>It is this scenario which will not decompress, although the string versions of the file are almost identical, the byte arrays are significantly different.</p>
<p>Many Thanks in Advance</p>
| [
{
"answer_id": 74438828,
"author": "Jimmy",
"author_id": 4960765,
"author_profile": "https://Stackoverflow.com/users/4960765",
"pm_score": 0,
"selected": false,
"text": "rehydratedState"
},
{
"answer_id": 74452347,
"author": "Lonli-Lokli",
"author_id": 462669,
"author_profile": "https://Stackoverflow.com/users/462669",
"pm_score": 1,
"selected": false,
"text": "mergeReducer"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430743",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1756883/"
] |
74,430,782 | <p>I am trying to add mutable lists in other mutable lists<br />
but i dont know how to do it.</p>
<p>I tried mutablelist of mutablelist but not working.</p>
| [
{
"answer_id": 74438828,
"author": "Jimmy",
"author_id": 4960765,
"author_profile": "https://Stackoverflow.com/users/4960765",
"pm_score": 0,
"selected": false,
"text": "rehydratedState"
},
{
"answer_id": 74452347,
"author": "Lonli-Lokli",
"author_id": 462669,
"author_profile": "https://Stackoverflow.com/users/462669",
"pm_score": 1,
"selected": false,
"text": "mergeReducer"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430782",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15115764/"
] |
74,430,805 | <p>I've been going around the block in circles and just wanted an easy example of how I could use a typescript class in a javascript function.</p>
<p>My motivation is to use a typescript constant in a legacy js file (the js file can't be converted to ts yet, hence my dilemma).</p>
<p>I've read that <strong>.ts</strong> code should be somehow built in the process for us to be able to use it in <strong>.js</strong>, but everything has been a bit convoluted.</p>
<p>Example <strong>.ts</strong> class:</p>
<pre><code>export class ExampleConstantsClass { static readonly exampleConst = 1; }
</code></pre>
<p>Now I'd like to import this in a <strong>.js</strong> file and use it for example like this:</p>
<pre><code>function exampleFunction() { return ExampleConstantsClass.exampleConst }
</code></pre>
| [
{
"answer_id": 74431885,
"author": "Lord-JulianXLII",
"author_id": 19529102,
"author_profile": "https://Stackoverflow.com/users/19529102",
"pm_score": 1,
"selected": false,
"text": "yourJSFile.js\ntsFile.js (this is the file the compiler generates)\n\ntsFile.ts (this is your ts file you write in)\n"
},
{
"answer_id": 74432018,
"author": "Kokodoko",
"author_id": 1083572,
"author_profile": "https://Stackoverflow.com/users/1083572",
"pm_score": 0,
"selected": false,
"text": "tsconfig.json"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430805",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4602500/"
] |
74,430,829 | <p>I want to run the login thread group always first and wait for it to finish. And then in the same test plan run other thread group in parallel.</p>
<p>e.g.
Login-1 (always first )
Thread group-2 (after login in parallel)
Thread group-3 (after login in parallel)</p>
| [
{
"answer_id": 74431885,
"author": "Lord-JulianXLII",
"author_id": 19529102,
"author_profile": "https://Stackoverflow.com/users/19529102",
"pm_score": 1,
"selected": false,
"text": "yourJSFile.js\ntsFile.js (this is the file the compiler generates)\n\ntsFile.ts (this is your ts file you write in)\n"
},
{
"answer_id": 74432018,
"author": "Kokodoko",
"author_id": 1083572,
"author_profile": "https://Stackoverflow.com/users/1083572",
"pm_score": 0,
"selected": false,
"text": "tsconfig.json"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430829",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15199010/"
] |
74,430,837 | <p>I'm trying to establish if my planned way of working is correct.</p>
<p>I have two data sources; a MySql & MSSQL database. I need to combine these data sources and expose this data for Power BI to consume.</p>
<p>I've decided to use Azure Synapse Analytics for the ETL and would like to understand if there is anything in the process I can simplify or do better.</p>
<p>The process is as followed:</p>
<blockquote>
<p>MySql & MSSQL delta loaded into ASA as parquet format, stored in Azure Gen 2 Storage.
Once copy pipeline is complete a subsiquent data flow unions the data from the two sources and inserts into MSSQL storage in ASA.
BI Consumes from this workspace / data soruce.</p>
</blockquote>
<p>I'm not sure if I should be storing from the data sources to Azure Gene 2, or I should just perform the transform and insert from the source straight into the MSSQL storage. Any thoughts or suggestions would be greatly appreciated.</p>
| [
{
"answer_id": 74432711,
"author": "Mark Wojciechowicz",
"author_id": 2568521,
"author_profile": "https://Stackoverflow.com/users/2568521",
"pm_score": 2,
"selected": false,
"text": "Raw"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430837",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16697004/"
] |
74,430,846 | <p>When I try to run the simulator for my macOS app, which is using Firebase, it gives this error: "Thread 1: "The default FirebaseApp instance must be configured before the default Authinstance can be initialized. One way to ensure this is to call <code>FirebaseApp.configure()</code> in the App Delegate's <code>application(_:didFinishLaunchingWithOptions:)</code> (or the <code>@main</code> struct's initializer in SwiftUI)." I notice this happened after I created an environment object.</p>
<p>Here is my code:</p>
<pre><code>import SwiftUI
import FirebaseCore
@main
struct testagainApp: App {
@NSApplicationDelegateAdaptor(AppDelegate.self) var delegate
var body: some Scene {
WindowGroup {
let viewModel = AppViewModel()
ContentView()
.environmentObject(viewModel)
}
.windowStyle(HiddenTitleBarWindowStyle())
}
}
class AppDelegate: NSObject, NSApplicationDelegate {
func applicationDidFinishLaunching(_ notification: Notification) {
FirebaseApp.configure()
}
}
</code></pre>
<p>If I get rid of let viewModel = AppViewModel() and .environmentObject(viewModel), the simulator runs just fine. If I put the app delegate first, the simulator runs but nothing appears. I am new to Swift and am unsure how to fix this.</p>
| [
{
"answer_id": 74432711,
"author": "Mark Wojciechowicz",
"author_id": 2568521,
"author_profile": "https://Stackoverflow.com/users/2568521",
"pm_score": 2,
"selected": false,
"text": "Raw"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430846",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20487859/"
] |
74,430,850 | <p>When I study about <code>override</code> keyword, I found some strange thing like below code.</p>
<pre><code>#include <iostream>
template <class T>
class A
{
public:
virtual void some_function(const T a)
{
std::cout<<__PRETTY_FUNCTION__<<std::endl;
std::cout<<"Base"<<std::endl;
}
};
class Derived : public A<int*>
{
public:
virtual void some_function(const int* a)
{
std::cout<<__PRETTY_FUNCTION__<<std::endl;
std::cout<<"Derived"<<std::endl;
}
};
int main()
{
A<int*>* p = new Derived;
p->some_function(nullptr);
delete p;
}
</code></pre>
<p>When I first saw that code, I expected <strong>"Derived"</strong> to be called.
But above code print result like below.</p>
<pre><code>void A<T>::some_function(T) [with T = int*]
Base
</code></pre>
<p>But when I removed <code>const</code> keyword in the <code>some_function</code> that placed in <code>Derived</code> class,</p>
<pre><code>class Derived : public A<int*>
{
public:
virtual void some_function(int* a)
{
std::cout<<__PRETTY_FUNCTION__<<std::endl;
std::cout<<"Derived"<<std::endl;
}
};
</code></pre>
<p>It print <strong>"Derived"</strong>.
Can you tell me why this is happening?</p>
| [
{
"answer_id": 74430921,
"author": "mch",
"author_id": 3684343,
"author_profile": "https://Stackoverflow.com/users/3684343",
"pm_score": 4,
"selected": true,
"text": "T=int*"
},
{
"answer_id": 74438747,
"author": "shy45",
"author_id": 20313707,
"author_profile": "https://Stackoverflow.com/users/20313707",
"pm_score": 1,
"selected": false,
"text": "const T a\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19378787/"
] |
74,430,863 | <p>I'm having trouble solving this issue, this is my array of objects</p>
<pre><code>gamesAndChoosenNumbers: [
{
choosenNum: '15',
count: 10,
game: 'AB',
gameCode: 'double',
},
{
choosenNum: '15',
count: 5,
game: 'AB',
gameCode: 'double',
},
{
choosenNum: '16',
count: 20,
game: 'AB',
gameCode: 'double',
},
{
choosenNum: '16',
count: 20,
game: 'AB',
gameCode: 'double',
},
{
choosenNum: '16',
count: 10,
game: 'AB',
gameCode: 'double',
},
{
choosenNum: '150',
count: 10,
game: 'SUPER',
gameCode: 'super',
},
{
choosenNum: '150',
count: 10,
game: 'SUPER',
gameCode: 'super',
},
{
choosenNum: '155',
count: 20,
game: 'SUPER',
gameCode: 'super',
},
{
choosenNum: '155',
count: 20,
game: 'SUPER',
gameCode: 'super',
},
{
choosenNum: '200',
count: 10,
game: 'BOX',
gameCode: 'box',
},
{
choosenNum: '200',
count: 10,
game: 'BOX',
gameCode: 'box',
},
{
choosenNum: '155',
count: 20,
game: 'BOX',
gameCode: 'box',
},
];
</code></pre>
<p>so I want to reduce this array based on the <strong>choosenNum</strong> and <strong>game</strong> values and merge them and replace the count value with all of the other same objects **count'**s sum,</p>
<p>the result I'm exoecting to get is this </p>
<pre><code>gamesAndChoosenNumbers: [
{
choosenNum: '15',
count: 15,
game: 'AB',
gameCode: 'double',
},
{
choosenNum: '16',
count: 50,
game: 'AB',
gameCode: 'double',
},
{
choosenNum: '150',
count: 20,
game: 'SUPER',
gameCode: 'super',
},
{
choosenNum: '155',
count: 40,
game: 'SUPER',
gameCode: 'super',
},
{
choosenNum: '200',
count: 20,
game: 'BOX',
gameCode: 'box',
},
{
choosenNum: '155',
count: 20,
game: 'BOX',
gameCode: 'box',
},
];
</code></pre>
<p>I tried so much but could'nt solve this issue with this code</p>
<pre><code> const duplicateElementa = gamesAndChoosenNumbers.reduce((x, y, i) => {
console.log({ i, x, y });
if (x.map((it) => it.choosenNum).includes(y.choosenNum)) {
console.log({ i1: i, x1: x[i - 1], y1: y });
if (x[i - 1].game === y.game) {
return [...x, { ...y, count: x[i - 1]?.count + y.count }];
}
} else {
return [...x, y];
}
}, []);
const nondupes = gamesAndChoosenNumbers.filter(
(it) => !dupeNums.includes(it.choosenNum),
);
const dupesMerged = duplicateElementa.map((it, i, arr) => {
const gt = arr.sort((a, b) => b.count - a.count);
const st = gt.reduce((x, y, i, carr) => {
if (
x.map((it) => it.choosenNum).includes(y.choosenNum) &&
x.map((it) => it.game).includes(y.game)
) {
return x;
} else {
return [...x, y];
}
}, []);
return st;
})[0];
const final: [] = dupesMerged
.filter((it) => {
console.log(nondupes.map((u) => u.choosenNum).includes(it.choosenNum));
if (!nondupes.map((u) => u.choosenNum).includes(it.choosenNum)) {
return it;
}
})
.concat(nondupes);
</code></pre>
<p>here the final variable will have the answer but I got screwed when the 155 repeats in two code blocks!!!. I'm stuck...,,please help.</p>
| [
{
"answer_id": 74431123,
"author": "flyingfox",
"author_id": 3176419,
"author_profile": "https://Stackoverflow.com/users/3176419",
"pm_score": 1,
"selected": true,
"text": "reduce()"
},
{
"answer_id": 74431132,
"author": "Jay Vaghasiya",
"author_id": 10562084,
"author_profile": "https://Stackoverflow.com/users/10562084",
"pm_score": 0,
"selected": false,
"text": "gamesAndChoosenNumbers = [{\n choosenNum: '15',\n count: 10,\n game: 'AB',\n gameCode: 'double',\n },\n {\n choosenNum: '15',\n count: 5,\n game: 'AB',\n gameCode: 'double',\n },\n {\n choosenNum: '16',\n count: 20,\n game: 'AB',\n gameCode: 'double',\n },\n {\n choosenNum: '16',\n count: 20,\n game: 'AB',\n gameCode: 'double',\n },\n {\n choosenNum: '16',\n count: 10,\n game: 'AB',\n gameCode: 'double',\n },\n {\n choosenNum: '150',\n count: 10,\n game: 'SUPER',\n gameCode: 'super',\n },\n {\n choosenNum: '150',\n count: 10,\n game: 'SUPER',\n gameCode: 'super',\n },\n {\n choosenNum: '155',\n count: 20,\n game: 'SUPER',\n gameCode: 'super',\n },\n {\n choosenNum: '155',\n count: 20,\n game: 'SUPER',\n gameCode: 'super',\n },\n {\n choosenNum: '200',\n count: 10,\n game: 'BOX',\n gameCode: 'box',\n },\n {\n choosenNum: '200',\n count: 10,\n game: 'BOX',\n gameCode: 'box',\n },\n {\n choosenNum: '155',\n count: 20,\n game: 'BOX',\n gameCode: 'box',\n },\n];\nfinalArr = gamesAndChoosenNumbers.reduce((acc, item) => {\n const findObj = acc.findIndex(_item => item.choosenNum === _item.choosenNum && item.game === _item.game);\n console.log(findObj)\n if (findObj >= 0) {\n acc[findObj] = {\n ...item,\n count: item.count + findObj.count,\n }\n return acc\n }\n return [...acc, item];\n}, [])\nconsole.log(finalArr);"
},
{
"answer_id": 74431150,
"author": "Ping",
"author_id": 20288037,
"author_profile": "https://Stackoverflow.com/users/20288037",
"pm_score": 0,
"selected": false,
"text": "const gamesAndChoosenNumbers = [\n {choosenNum: '15', count: 10, game: 'AB', gameCode: 'double'},\n {choosenNum: '15', count: 5, game: 'AB', gameCode: 'double'},\n {choosenNum: '16', count: 20, game: 'AB', gameCode: 'double'},\n {choosenNum: '16', count: 20, game: 'AB', gameCode: 'double'},\n {choosenNum: '16', count: 10, game: 'AB', gameCode: 'double'},\n {choosenNum: '150', count: 10, game: 'SUPER', gameCode: 'super'},\n {choosenNum: '150', count: 10, game: 'SUPER', gameCode: 'super'},\n {choosenNum: '155', count: 20, game: 'SUPER', gameCode: 'super'},\n {choosenNum: '155', count: 20, game: 'SUPER', gameCode: 'super'},\n {choosenNum: '200', count: 10, game: 'BOX', gameCode: 'box'},\n {choosenNum: '200', count: 10, game: 'BOX', gameCode: 'box'},\n {choosenNum: '155', count: 20, game: 'BOX', gameCode: 'box'},\n];\n\nconst results = {}\ngamesAndChoosenNumbers.forEach(obj => {\n if(!results[obj.choosenNum + obj.game]) results[obj.choosenNum + obj.game] = obj;\n else results[obj.choosenNum + obj.game].count += obj.count;\n});\n\nconsole.log(Object.values(results));"
},
{
"answer_id": 74431247,
"author": "ths",
"author_id": 6388552,
"author_profile": "https://Stackoverflow.com/users/6388552",
"pm_score": -1,
"selected": false,
"text": "reduce"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430863",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16911043/"
] |
74,430,880 | <p>Is there a more elegant way of removing nulls from a Dart list than this:</p>
<pre><code>List<T> nullFilter<T>(List<T?> list) =>
list.where((T? e) => e != null)
// This should not be necessary
.map((e) => e!)
.toList();
</code></pre>
| [
{
"answer_id": 74431123,
"author": "flyingfox",
"author_id": 3176419,
"author_profile": "https://Stackoverflow.com/users/3176419",
"pm_score": 1,
"selected": true,
"text": "reduce()"
},
{
"answer_id": 74431132,
"author": "Jay Vaghasiya",
"author_id": 10562084,
"author_profile": "https://Stackoverflow.com/users/10562084",
"pm_score": 0,
"selected": false,
"text": "gamesAndChoosenNumbers = [{\n choosenNum: '15',\n count: 10,\n game: 'AB',\n gameCode: 'double',\n },\n {\n choosenNum: '15',\n count: 5,\n game: 'AB',\n gameCode: 'double',\n },\n {\n choosenNum: '16',\n count: 20,\n game: 'AB',\n gameCode: 'double',\n },\n {\n choosenNum: '16',\n count: 20,\n game: 'AB',\n gameCode: 'double',\n },\n {\n choosenNum: '16',\n count: 10,\n game: 'AB',\n gameCode: 'double',\n },\n {\n choosenNum: '150',\n count: 10,\n game: 'SUPER',\n gameCode: 'super',\n },\n {\n choosenNum: '150',\n count: 10,\n game: 'SUPER',\n gameCode: 'super',\n },\n {\n choosenNum: '155',\n count: 20,\n game: 'SUPER',\n gameCode: 'super',\n },\n {\n choosenNum: '155',\n count: 20,\n game: 'SUPER',\n gameCode: 'super',\n },\n {\n choosenNum: '200',\n count: 10,\n game: 'BOX',\n gameCode: 'box',\n },\n {\n choosenNum: '200',\n count: 10,\n game: 'BOX',\n gameCode: 'box',\n },\n {\n choosenNum: '155',\n count: 20,\n game: 'BOX',\n gameCode: 'box',\n },\n];\nfinalArr = gamesAndChoosenNumbers.reduce((acc, item) => {\n const findObj = acc.findIndex(_item => item.choosenNum === _item.choosenNum && item.game === _item.game);\n console.log(findObj)\n if (findObj >= 0) {\n acc[findObj] = {\n ...item,\n count: item.count + findObj.count,\n }\n return acc\n }\n return [...acc, item];\n}, [])\nconsole.log(finalArr);"
},
{
"answer_id": 74431150,
"author": "Ping",
"author_id": 20288037,
"author_profile": "https://Stackoverflow.com/users/20288037",
"pm_score": 0,
"selected": false,
"text": "const gamesAndChoosenNumbers = [\n {choosenNum: '15', count: 10, game: 'AB', gameCode: 'double'},\n {choosenNum: '15', count: 5, game: 'AB', gameCode: 'double'},\n {choosenNum: '16', count: 20, game: 'AB', gameCode: 'double'},\n {choosenNum: '16', count: 20, game: 'AB', gameCode: 'double'},\n {choosenNum: '16', count: 10, game: 'AB', gameCode: 'double'},\n {choosenNum: '150', count: 10, game: 'SUPER', gameCode: 'super'},\n {choosenNum: '150', count: 10, game: 'SUPER', gameCode: 'super'},\n {choosenNum: '155', count: 20, game: 'SUPER', gameCode: 'super'},\n {choosenNum: '155', count: 20, game: 'SUPER', gameCode: 'super'},\n {choosenNum: '200', count: 10, game: 'BOX', gameCode: 'box'},\n {choosenNum: '200', count: 10, game: 'BOX', gameCode: 'box'},\n {choosenNum: '155', count: 20, game: 'BOX', gameCode: 'box'},\n];\n\nconst results = {}\ngamesAndChoosenNumbers.forEach(obj => {\n if(!results[obj.choosenNum + obj.game]) results[obj.choosenNum + obj.game] = obj;\n else results[obj.choosenNum + obj.game].count += obj.count;\n});\n\nconsole.log(Object.values(results));"
},
{
"answer_id": 74431247,
"author": "ths",
"author_id": 6388552,
"author_profile": "https://Stackoverflow.com/users/6388552",
"pm_score": -1,
"selected": false,
"text": "reduce"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430880",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4357481/"
] |
74,430,909 | <p>I have this array of images in my component.ts:</p>
<pre><code>images = [
"https://content.xxx/50/front-page/background1.jpg",
"https://content.xxx/50/front-page/background2.jpg",
"https://content. xxx/50/front-page/background3.jpg"
];
</code></pre>
<p>And this div in my component.html:</p>
<pre><code> <div class="slider">
<div class="slider-container" *ngFor="let item of images">
<figure>
<img [src]="images" class="img-responsive"/>
</figure>
</div>
</div>
</code></pre>
<p>My problem is that I only see the first image in the slider.</p>
<p>Before I had this in the component.html and I saw the three images but when passing it to array I only see the first one.</p>
<pre><code><div class="slider">
<div class="slider-container">
<figure>
<img src="https://content.xxx/50/front-page/fondo1.jpg" class="img-responsive">
</figure>
<figure>
<img src="https://content.xxx/50/front-page/fondo2.jpg" class="img-responsive">
</figure>
<figure>
<img src="https://content.xxx/50/front-page/fondo3.jpg" class="img-responsive">
</figure>
</div>
</div>
</code></pre>
<p>Thank you</p>
<p>In the question I have put what I expected and what I have tried</p>
| [
{
"answer_id": 74431123,
"author": "flyingfox",
"author_id": 3176419,
"author_profile": "https://Stackoverflow.com/users/3176419",
"pm_score": 1,
"selected": true,
"text": "reduce()"
},
{
"answer_id": 74431132,
"author": "Jay Vaghasiya",
"author_id": 10562084,
"author_profile": "https://Stackoverflow.com/users/10562084",
"pm_score": 0,
"selected": false,
"text": "gamesAndChoosenNumbers = [{\n choosenNum: '15',\n count: 10,\n game: 'AB',\n gameCode: 'double',\n },\n {\n choosenNum: '15',\n count: 5,\n game: 'AB',\n gameCode: 'double',\n },\n {\n choosenNum: '16',\n count: 20,\n game: 'AB',\n gameCode: 'double',\n },\n {\n choosenNum: '16',\n count: 20,\n game: 'AB',\n gameCode: 'double',\n },\n {\n choosenNum: '16',\n count: 10,\n game: 'AB',\n gameCode: 'double',\n },\n {\n choosenNum: '150',\n count: 10,\n game: 'SUPER',\n gameCode: 'super',\n },\n {\n choosenNum: '150',\n count: 10,\n game: 'SUPER',\n gameCode: 'super',\n },\n {\n choosenNum: '155',\n count: 20,\n game: 'SUPER',\n gameCode: 'super',\n },\n {\n choosenNum: '155',\n count: 20,\n game: 'SUPER',\n gameCode: 'super',\n },\n {\n choosenNum: '200',\n count: 10,\n game: 'BOX',\n gameCode: 'box',\n },\n {\n choosenNum: '200',\n count: 10,\n game: 'BOX',\n gameCode: 'box',\n },\n {\n choosenNum: '155',\n count: 20,\n game: 'BOX',\n gameCode: 'box',\n },\n];\nfinalArr = gamesAndChoosenNumbers.reduce((acc, item) => {\n const findObj = acc.findIndex(_item => item.choosenNum === _item.choosenNum && item.game === _item.game);\n console.log(findObj)\n if (findObj >= 0) {\n acc[findObj] = {\n ...item,\n count: item.count + findObj.count,\n }\n return acc\n }\n return [...acc, item];\n}, [])\nconsole.log(finalArr);"
},
{
"answer_id": 74431150,
"author": "Ping",
"author_id": 20288037,
"author_profile": "https://Stackoverflow.com/users/20288037",
"pm_score": 0,
"selected": false,
"text": "const gamesAndChoosenNumbers = [\n {choosenNum: '15', count: 10, game: 'AB', gameCode: 'double'},\n {choosenNum: '15', count: 5, game: 'AB', gameCode: 'double'},\n {choosenNum: '16', count: 20, game: 'AB', gameCode: 'double'},\n {choosenNum: '16', count: 20, game: 'AB', gameCode: 'double'},\n {choosenNum: '16', count: 10, game: 'AB', gameCode: 'double'},\n {choosenNum: '150', count: 10, game: 'SUPER', gameCode: 'super'},\n {choosenNum: '150', count: 10, game: 'SUPER', gameCode: 'super'},\n {choosenNum: '155', count: 20, game: 'SUPER', gameCode: 'super'},\n {choosenNum: '155', count: 20, game: 'SUPER', gameCode: 'super'},\n {choosenNum: '200', count: 10, game: 'BOX', gameCode: 'box'},\n {choosenNum: '200', count: 10, game: 'BOX', gameCode: 'box'},\n {choosenNum: '155', count: 20, game: 'BOX', gameCode: 'box'},\n];\n\nconst results = {}\ngamesAndChoosenNumbers.forEach(obj => {\n if(!results[obj.choosenNum + obj.game]) results[obj.choosenNum + obj.game] = obj;\n else results[obj.choosenNum + obj.game].count += obj.count;\n});\n\nconsole.log(Object.values(results));"
},
{
"answer_id": 74431247,
"author": "ths",
"author_id": 6388552,
"author_profile": "https://Stackoverflow.com/users/6388552",
"pm_score": -1,
"selected": false,
"text": "reduce"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18979748/"
] |
74,430,928 | <p>I have a list of dicts like this:</p>
<pre><code>zip_values = [{'Spain': '43004'}, {'Spain': '43830'}, {'Spain': '46003'}, {'Spain': '50006'}, {'Portugal': ''}, {'Portugal': '1000-155'}, {'Portugal': '1000-226'}, {'Portugal': '1050-175'}, {'Portugal': '1050-190'}, {'Portugal': '1070-041'}, {'Portugal': '1150-101'}, {'Portugal': '1150-260'}, {'Portugal': '1200-114'}, {'Portugal': '1250-192'}, {'Portugal': '1300-243'}, {'Portugal': '1300-610'}, {'Portugal': '1350-100'}, {'Portugal': '1400-140'}, {'Portugal': '1400-212'}, {'Portugal': '1400-352'}, {'Portugal': '1495-057'}, {'Portugal': '1495-135'}, {'Portugal': '1500-073'}, {'Portugal': '1500-151'}, {'Portugal': '1500-506'}, {'Portugal': '1600-161'}, {'Portugal': '1600-864'}, {'Portugal': '1700-093'}, {'Portugal': '1700-163'}, {'Portugal': '1700-239'}, {'Portugal': '1750-249'}, {'Portugal': '1750-429'}, {'Portugal': '1800-297'}, {'Portugal': '1950-130'}, {'Portugal': '1990-179'}]
</code></pre>
<p>but much larger. I want to loop over it, I try like this</p>
<pre><code>for key, value in zip_values:
if key == "France" | key == "Germany" | key == "Spain":
current_zip = check_if_zipcodes_correct(value, 1000, 99999, 5)
</code></pre>
<p>check_if_zipcodes_correct is some function that I want to use for zipcodes, but it is not important, I get an error when run the script:
<strong>ValueError: not enough values to unpack (expected 2, got 1)</strong></p>
| [
{
"answer_id": 74431001,
"author": "Jay",
"author_id": 8677071,
"author_profile": "https://Stackoverflow.com/users/8677071",
"pm_score": 2,
"selected": false,
"text": "for key, value in zip_values"
},
{
"answer_id": 74431035,
"author": "Guy",
"author_id": 5168011,
"author_profile": "https://Stackoverflow.com/users/5168011",
"pm_score": 1,
"selected": false,
"text": "zip_values"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430928",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18805039/"
] |
74,431,025 | <p>I've got an ACS setup with SharePoint as the datasource. It's working well.</p>
<p>When I query the index and retrieve a document, I want to take that documents ID and query the sharepoint API to get additional information about that document. However, it seems that non of the identifiable information returned with the document (as documented <a href="https://learn.microsoft.com/en-us/azure/search/search-howto-index-sharepoint-online#indexing-document-metadata" rel="nofollow noreferrer">here</a>):</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Identifier</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>metadata_spo_site_library_item_id</td>
<td>Edm.String</td>
<td>The combination key of site ID, library ID, and item ID which uniquely identifies an item in a document library for a site.</td>
</tr>
<tr>
<td>metadata_spo_site_id</td>
<td>Edm.String</td>
<td>The ID of the SharePoint site.</td>
</tr>
<tr>
<td>metadata_spo_library_id</td>
<td>Edm.String</td>
<td>The ID of document library.</td>
</tr>
<tr>
<td>metadata_spo_item_id</td>
<td>Edm.String</td>
<td>The ID of the (document) item in the library.</td>
</tr>
<tr>
<td>etc...</td>
<td>...</td>
<td></td>
</tr>
</tbody>
</table>
</div>
<p>is recognised by the the sharepoint api e.g.</p>
<pre><code>_api/web/lists/GetByTitle('XXXXXXXX')/items?$select=Id&$filter=Id eq '{metadata_spo_site_library_item_id}'
</code></pre>
<p>does not work, nor does any variation I have tried.</p>
<p>What am I doing wrong?</p>
<p>EDIT:</p>
<p>I am decoding the document key and keeping on the index each item it contains separately:</p>
<p><a href="https://i.stack.imgur.com/6mBpk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6mBpk.png" alt="enter image description here" /></a></p>
<p>None of these provided ids identify the document in the sharepoint-api, unless I am using the wrong endpoint</p>
| [
{
"answer_id": 74442714,
"author": "Zella_msft",
"author_id": 18359481,
"author_profile": "https://Stackoverflow.com/users/18359481",
"pm_score": -1,
"selected": false,
"text": "GET https://{site_url}/_api/web/lists/GetByTitle('Test')/items({item_id})\n"
},
{
"answer_id": 74475415,
"author": "vijaya",
"author_id": 20336887,
"author_profile": "https://Stackoverflow.com/users/20336887",
"pm_score": 1,
"selected": false,
"text": "{\n\n\"@odata.context\": \"https://searchname.search.windows.net/$metadata#indexers/$entity\",\n\n\"@odata.etag\": \"\\\"*****\\\"\",\n\n\"name\": \"azureblob-indexer\",\n\n\"description\": \"\",\n\n\"dataSourceName\": \"ds01\",\n\n\"skillsetName\": null,\n\n\"targetIndexName\": \"azureblob-index\",\n\n\"disabled\": null,\n\n\"schedule\": null,\n\n\"parameters\": {\n\n\"batchSize\": null,\n\n\"maxFailedItems\": 0,\n\n\"maxFailedItemsPerBatch\": 0,\n\n\"base64EncodeKeys\": null,\n\n\"configuration\": {\n\n\"dataToExtract\": \"contentAndMetadata\",\n\n\"parsingMode\": \"default\"\n\n}\n\n},\n\n\"fieldMappings\": [\n\n{\n\n\"sourceFieldName\": \"metadata_storage_path\",\n\n\"targetFieldName\": \"metadata_storage_path\",\n\n\"mappingFunction\": {\n\n\"name\": \"base64Encode\"\n\n}\n\n},\n\n{\n\n\"sourceFieldName\": \"metadata_storage_path\",\n\n\"targetFieldName\": \"path\"\n\n}\n\n],\n\n\"outputFieldMappings\": [],\n\n\"cache\": null,\n\n\"encryptionKey\": null\n\n}\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431025",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9982309/"
] |
74,431,037 | <p>Implementing a simple fulltext search I encountered a problem with the combination of <strong>boolean mode</strong> and <strong>phrases</strong>. Also worth noting is that the column has a <strong>binary</strong> collation (utf8_bin) whilst the table does not have this.</p>
<p>Given the following setup:</p>
<pre><code>CREATE TABLE `test` (
`test_id` int(11) NOT NULL AUTO_INCREMENT,
`text_bin` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`test_id`),
FULLTEXT KEY `text_bin` (`text_bin`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `test` (`test_id`, `text_bin`) VALUES
(1, 'Lorem Ipsum Dolor Sit Amet.'),
(2, 'Consectetuer Adipiscing Elit.'),
(3, 'Amet Sit Dolor Ipsum Lorem.')
;
</code></pre>
<p>Then running this query:</p>
<pre><code>SELECT t.test_id, t.text_bin,
MATCH(t.text_bin) AGAINST ('Lorem Ipsum' IN BOOLEAN MODE) as m_Words,
MATCH(t.text_bin) AGAINST ('"Lorem Ipsum"' IN BOOLEAN MODE) as m_Phrase,
MATCH(t.text_bin) AGAINST ('Lorem' IN BOOLEAN MODE) as m_Lorem,
MATCH(t.text_bin) AGAINST ('Ipsum' IN BOOLEAN MODE) as m_Ipsum
FROM test t
;
</code></pre>
<p>This yields the following results:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>test_id</th>
<th>text_bin</th>
<th>m_Words</th>
<th>m_Phrase</th>
<th>m_Lorem</th>
<th>m_Ipsum</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Lorem Ipsum Dolor Sit Amet.</td>
<td>0.0620</td>
<td>0</td>
<td>0.0310</td>
<td>0.0310</td>
</tr>
<tr>
<td>2</td>
<td>Consectetuer Adipiscing Elit.</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>3</td>
<td>Amet Sit Dolor Ipsum Lorem.</td>
<td>0.0620</td>
<td>0</td>
<td>0.0310</td>
<td>0.0310</td>
</tr>
</tbody>
</table>
</div>
<p>(Note: I shortened the numbers to 4 decimal places for better readability.)</p>
<p>For the column <code>m_Phrase</code> I would expect a value greater then 0 on the first row. Is this a bug or can someone explain why the result is 0?</p>
<p>DB Fiddle: <a href="https://www.db-fiddle.com/f/8qxR3SiPVtESU3saebhgBG/0" rel="nofollow noreferrer">https://www.db-fiddle.com/f/8qxR3SiPVtESU3saebhgBG/0</a></p>
| [
{
"answer_id": 74442714,
"author": "Zella_msft",
"author_id": 18359481,
"author_profile": "https://Stackoverflow.com/users/18359481",
"pm_score": -1,
"selected": false,
"text": "GET https://{site_url}/_api/web/lists/GetByTitle('Test')/items({item_id})\n"
},
{
"answer_id": 74475415,
"author": "vijaya",
"author_id": 20336887,
"author_profile": "https://Stackoverflow.com/users/20336887",
"pm_score": 1,
"selected": false,
"text": "{\n\n\"@odata.context\": \"https://searchname.search.windows.net/$metadata#indexers/$entity\",\n\n\"@odata.etag\": \"\\\"*****\\\"\",\n\n\"name\": \"azureblob-indexer\",\n\n\"description\": \"\",\n\n\"dataSourceName\": \"ds01\",\n\n\"skillsetName\": null,\n\n\"targetIndexName\": \"azureblob-index\",\n\n\"disabled\": null,\n\n\"schedule\": null,\n\n\"parameters\": {\n\n\"batchSize\": null,\n\n\"maxFailedItems\": 0,\n\n\"maxFailedItemsPerBatch\": 0,\n\n\"base64EncodeKeys\": null,\n\n\"configuration\": {\n\n\"dataToExtract\": \"contentAndMetadata\",\n\n\"parsingMode\": \"default\"\n\n}\n\n},\n\n\"fieldMappings\": [\n\n{\n\n\"sourceFieldName\": \"metadata_storage_path\",\n\n\"targetFieldName\": \"metadata_storage_path\",\n\n\"mappingFunction\": {\n\n\"name\": \"base64Encode\"\n\n}\n\n},\n\n{\n\n\"sourceFieldName\": \"metadata_storage_path\",\n\n\"targetFieldName\": \"path\"\n\n}\n\n],\n\n\"outputFieldMappings\": [],\n\n\"cache\": null,\n\n\"encryptionKey\": null\n\n}\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431037",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1899323/"
] |
74,431,094 | <p>How can I open google sign in pop up with different clicnt_id s in one project? I want to have 2 different logins for mail and calendar. That's why I need 2 different client ids, but google make init only once, and the second doesn't work.</p>
<p>I have tried to call <code>gapi.auth2.init</code> twice, but second pop up doesn't open. Also I've tried with <code>gapi.auth2.authorize</code>.</p>
<p><img src="https://i.stack.imgur.com/HUqAt.png" alt="enter image description here" /></p>
| [
{
"answer_id": 74442714,
"author": "Zella_msft",
"author_id": 18359481,
"author_profile": "https://Stackoverflow.com/users/18359481",
"pm_score": -1,
"selected": false,
"text": "GET https://{site_url}/_api/web/lists/GetByTitle('Test')/items({item_id})\n"
},
{
"answer_id": 74475415,
"author": "vijaya",
"author_id": 20336887,
"author_profile": "https://Stackoverflow.com/users/20336887",
"pm_score": 1,
"selected": false,
"text": "{\n\n\"@odata.context\": \"https://searchname.search.windows.net/$metadata#indexers/$entity\",\n\n\"@odata.etag\": \"\\\"*****\\\"\",\n\n\"name\": \"azureblob-indexer\",\n\n\"description\": \"\",\n\n\"dataSourceName\": \"ds01\",\n\n\"skillsetName\": null,\n\n\"targetIndexName\": \"azureblob-index\",\n\n\"disabled\": null,\n\n\"schedule\": null,\n\n\"parameters\": {\n\n\"batchSize\": null,\n\n\"maxFailedItems\": 0,\n\n\"maxFailedItemsPerBatch\": 0,\n\n\"base64EncodeKeys\": null,\n\n\"configuration\": {\n\n\"dataToExtract\": \"contentAndMetadata\",\n\n\"parsingMode\": \"default\"\n\n}\n\n},\n\n\"fieldMappings\": [\n\n{\n\n\"sourceFieldName\": \"metadata_storage_path\",\n\n\"targetFieldName\": \"metadata_storage_path\",\n\n\"mappingFunction\": {\n\n\"name\": \"base64Encode\"\n\n}\n\n},\n\n{\n\n\"sourceFieldName\": \"metadata_storage_path\",\n\n\"targetFieldName\": \"path\"\n\n}\n\n],\n\n\"outputFieldMappings\": [],\n\n\"cache\": null,\n\n\"encryptionKey\": null\n\n}\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431094",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19316035/"
] |
74,431,099 | <p>I am given word and I have to check if the word is a palindrome. My program works well until I play around with the case of the word.</p>
<pre><code>def isPalindrome(word):
reversedWord = word[::-1]
palindrome = true
for n in range(len(word)):
if(word[n] != reversedWord[i])
palindrome = false
return palindrome
</code></pre>
<p>I tried the below code and it works well if I feed the function the word "mom", however it fails when I give it the same word but with a different case "Mom"</p>
<pre><code>def isPalindrome(word):
reversedWord = word[::-1]
palindrome = true
for n in range(len(word)):
if(word[n] != reversedWord[i])
palindrome = false
return palindrome
</code></pre>
| [
{
"answer_id": 74431181,
"author": "Timo",
"author_id": 12888866,
"author_profile": "https://Stackoverflow.com/users/12888866",
"pm_score": 0,
"selected": false,
"text": "def isPalindrome(word):\n word = word.lower()\n return True if word == word[::-1] else False\n"
},
{
"answer_id": 74431220,
"author": "Cobra",
"author_id": 17580381,
"author_profile": "https://Stackoverflow.com/users/17580381",
"pm_score": 1,
"selected": false,
"text": "def isPalindrome(word):\n word = word.lower()\n return word == word[::-1]\n"
},
{
"answer_id": 74431309,
"author": "Jyothis - Intel",
"author_id": 17095918,
"author_profile": "https://Stackoverflow.com/users/17095918",
"pm_score": 1,
"selected": false,
"text": "def isPalindrome(word):\n return True if (word.lower() == word[::-1].lower()) else False\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431099",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19871200/"
] |
74,431,108 | <p>This is my dataset:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Name</th>
<th>Test1</th>
<th>Test3</th>
<th>Test2</th>
<th>Quiz</th>
</tr>
</thead>
<tbody>
<tr>
<td>Boo</td>
<td>0.9</td>
<td>0</td>
<td>0</td>
<td>1.0</td>
</tr>
<tr>
<td>Buzz</td>
<td>0.8</td>
<td>0.7</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>Bree</td>
<td>0</td>
<td>0</td>
<td>1.0</td>
<td>0</td>
</tr>
</tbody>
</table>
</div>
<p>How I want my result dataset:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Name</th>
<th>Test1</th>
<th>Test3</th>
<th>Test2</th>
<th>Quiz</th>
</tr>
</thead>
<tbody>
<tr>
<td>Boo</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>1</td>
</tr>
<tr>
<td>Buzz</td>
<td>1</td>
<td>1</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>Bree</td>
<td>0</td>
<td>0</td>
<td>1</td>
<td>0</td>
</tr>
</tbody>
</table>
</div>
<p>I tried the df.astype to int64 - but this changed all values below 1 to 0. I also tried:</p>
<pre><code>df1 = df.apply(pd.to_numeric, errors='coerce')
</code></pre>
<p>but this caused my first column to become NaN values. I also tried:</p>
<pre><code>df.where(df <= 0.4, 1, inplace=True)
</code></pre>
<p>but I got an error saying this isn't possible between str and float. I had set_index() in the Name column, so ideally this error shouldn't come. I can't seem to figure this out, need major help :((</p>
| [
{
"answer_id": 74431137,
"author": "jezrael",
"author_id": 2901002,
"author_profile": "https://Stackoverflow.com/users/2901002",
"pm_score": 1,
"selected": false,
"text": "1"
},
{
"answer_id": 74431258,
"author": "Panda Kim",
"author_id": 20430449,
"author_profile": "https://Stackoverflow.com/users/20430449",
"pm_score": 3,
"selected": true,
"text": "df.set_index('Name').astype('float').gt(0.4).astype('int').reset_index()\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431108",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20406129/"
] |
74,431,117 | <p>I am hosting a site at localhost and am trying to load CSS from an external file. The CSS is not displaying and is not being accessed when I check my apache access_log. When I contain the CSS within the html it all works fine.</p>
<p>Also, when I access the CSS directory directly I can view the .css file in the browser.</p>
<p>Here is my html:</p>
<pre><code><html>
<head>
<style>
<link href="css/mobile.css" rel="stylesheet" type="text/css">
html {height: 100%;}
body {margin: 0px; padding: 0px; height: 100%; overflow: hidden;}
#site_box {position: absolute; margin:0px; min-height: 100%; min-width: 100%; padding:0px;}
#centre_column_box {display: block; margin-left: auto; margin-right: auto; max-width: 600px;}
#title_box {text-align: center; }
#title_box_title {font-weight: bold;}
#content_title_box {font-weight: bold;}
/* */
.wrapper {margin: 10px; padding: 5px;}
/*Test Wrapper
.wrapper {margin: 10px; padding: 5px; border-style: solid; border-color: black;}
/* */
/* For desktop */
@media (min-width: 1200px){
#top_row_box {display: none;}
#top_row_divider_box {display: none;}
#left_column_box {float: left; min-height: 100%; max-width: 200px;}
#profile_picture_box {width: 50px; height:50px;}
#menu_title {font-weight: bold;}
#left_column_divider_box {float: left; padding: 5px; height: 100vh; max-width: 5px;}
#left_column_divider {min-height: 99%; border-color: black; border-style: solid;}
}
</style>
</head>
<body>
<!-- html stuff here -->
</body>
</html>
</code></pre>
<p>and CSS:</p>
<pre><code>/* For mobile */
@media (max-width: 1200px){
#menu_list_box > ul > li {margin: 10px; display: inline-block; border-style: solid; border-color: black; padding: 10px;}
#top_row_divider_box {padding: 5px; width: 95%;}
#top_row_divider {min-height: 99%; border-color: black; border-style: solid;}
#left_column_box {display: none;}
#left_column_divider_box {display: none;}
}
</code></pre>
<p>The html file is in the document root and the css file is in the sub directory /css/.</p>
<p>Things I have tried so far:</p>
<ul>
<li>Clearing chrome cache</li>
<li>Placing CSS in the document root ( so at / instead of /css/ )</li>
<li>Trying Firefox</li>
<li>Loading CSS via an absolute path so /srv/apache2/htdocs/css/</li>
</ul>
<p>None of these presented the CSS or recorded an access in the apache access log.</p>
<p>What is going wrong ?</p>
<p>Help is appreciated !</p>
| [
{
"answer_id": 74431137,
"author": "jezrael",
"author_id": 2901002,
"author_profile": "https://Stackoverflow.com/users/2901002",
"pm_score": 1,
"selected": false,
"text": "1"
},
{
"answer_id": 74431258,
"author": "Panda Kim",
"author_id": 20430449,
"author_profile": "https://Stackoverflow.com/users/20430449",
"pm_score": 3,
"selected": true,
"text": "df.set_index('Name').astype('float').gt(0.4).astype('int').reset_index()\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431117",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13376754/"
] |
74,431,140 | <p>im trying to interact with a website. I want to apply some filters but i have an error, my code does not recognize the xpath.</p>
<pre><code>from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
options=Options()
options.add_argument('--windoes-size=1920,1080')
driver=webdriver.Chrome(options=options)
driver.get("https://dexscreener.com/polygon/uniswap")
folder=driver.find_element(By.XPATH,'//button[@class="chakra-button chakra-menu__menu-button custom-tpjv8u"]')
folder.click()
folder=driver.find_element(By.XPATH,'//button[@id="menu-list-36-menuitem-33"]')
folder.click()
</code></pre>
| [
{
"answer_id": 74431195,
"author": "docbrown-git",
"author_id": 19624812,
"author_profile": "https://Stackoverflow.com/users/19624812",
"pm_score": -1,
"selected": false,
"text": "folder=driver.find_element(By.CSS_SELECTOR, \"selector here\")\n"
},
{
"answer_id": 74431298,
"author": "pL3b",
"author_id": 17200418,
"author_profile": "https://Stackoverflow.com/users/17200418",
"pm_score": 1,
"selected": false,
"text": "//button[@value=\"m5\"] # Last 5 minutes button\n//button[@value=\"h1\"] # Last hour\n//button[@value=\"h6\"] # Last 6 hours\n//button[@value=\"h24\"] # Last 24 hours\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431140",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20500209/"
] |
74,431,180 | <p>Working on my project, the JS script file only loads around half the time which is very frustrating. The error I receive is</p>
<p><code>localhost/:252 GET http://localhost/js/script.js net::ERR_ABORTED 404 (Not Found)</code></p>
<p>I require the file at the bottom of the footer, which is in a blade component used on every page:</p>
<pre><code><x-footer />
</code></pre>
<pre><code></body>
<script src="{{ asset('js/script.js') }}"></script>
</html>`
</code></pre>
<p>I have tried moving the script file, renaming it, having it hard coded into each page instead of a blade component and still nothing works</p>
<p>Permissions of my public folder:</p>
<pre><code> total 32
0 drwxr-xr-x 11 brandon staff 352 4 Nov 14:35 .
0 drwxr-xr-x 30 brandon staff 960 4 Nov 14:33 ..
8 -rw-r--r-- 1 brandon staff 603 28 Oct 14:38 .htaccess
0 drwxr-xr-x 4 brandon staff 128 4 Nov 14:33 build
0 drwxr-xr-x 3 brandon staff 96 3 Nov 15:55 css
0 -rw-r--r-- 1 brandon staff 0 28 Oct 14:38 favicon.ico
8 -rw-r--r-- 1 brandon staff 21 11 Nov 15:57 hot
0 drwxr-xr-x 6 brandon staff 192 3 Nov 16:08 img
8 -rw-r--r-- 1 brandon staff 1710 28 Oct 14:38 index.php
0 drwxr-xr-x 3 brandon staff 96 11 Nov 15:53 js
8 -rw-r--r-- 1 brandon staff 24 28 Oct 14:38 robots.txt
</code></pre>
<p>and the JS file</p>
<pre><code> 0 drwxr-xr-x 3 brandon staff 96 11 Nov 15:53 .
0 drwxr-xr-x 11 brandon staff 352 4 Nov 14:35 ..
24 -rw-r--r-- 1 brandon staff 11937 14 Nov 11:54 script.js
</code></pre>
<p><strong>FIXED! It appeared to be a docker issue. I had to docker compose down and docker compose up the container, which fixed it.</strong></p>
| [
{
"answer_id": 74431349,
"author": "brance",
"author_id": 2746366,
"author_profile": "https://Stackoverflow.com/users/2746366",
"pm_score": -1,
"selected": false,
"text": "/public"
},
{
"answer_id": 74434438,
"author": "bfrith",
"author_id": 19571192,
"author_profile": "https://Stackoverflow.com/users/19571192",
"pm_score": 0,
"selected": false,
"text": "docker compose down"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19571192/"
] |
74,431,194 | <p>Here's the functionality I am expecting to achieve:</p>
<pre><code>darray<int> a;
a.push_back(1);
a.push_back(2);
a.push_back(3);
std::cout << a << std::endl; // displays: {1, 2, 3}
</code></pre>
<p>My implementation:</p>
<pre><code>template <typename T>
class darray
{
private:
long m_capacity;
long m_size;
T* m_data;
void resize();
public:
// constructors & destructors
darray();
// operations
void push_back(T);
std::ostream& print(std::ostream&) const;
template<typename U> friend std::ostream& operator<<(std::ostream& os, U const& ar);
};
template<typename T>
std::ostream& darray<T>::print(std::ostream& os) const
{
os << "{ ";
for (size_t i = 0; i < m_size; i++)
{
os << m_data[i] << ", ";
if ( i == m_size - 1 )
os << m_data[i];
}
os << " }\n";
return arr;
}
template<typename U>
std::ostream& operator<<(std::ostream& os, U const& obj)
{
return obj.print(os);
}
</code></pre>
<p>produces an error:</p>
<pre><code>error: ambiguous overload for ‘operator<<’ (operand types are ‘std::ostream’ {aka ‘std::basic_ostream<char>’} and ‘const char [66]’)
</code></pre>
<p>But, when I change the parameter of operator<< to accept a <code>darray<U></code> instead , it works fine:</p>
<pre><code>template<typename U>
std::ostream& operator<<(std::ostream& os, darray<U> const& obj)
{
return obj.print(os);
}
</code></pre>
<p>What am I missing here?</p>
<p>Update:</p>
<p>I also tried doing this, changing the parameter to <code>darray<U></code> type in the definition and the implementation, but it still produces the same error:</p>
<pre><code>template <typename T>
class darray
{
private:
long m_capacity;
long m_size;
T* m_data;
void resize();
public:
// constructors & destructors
darray();
// operations
void push_back(T);
std::ostream& print(std::ostream&) const;
template<typename U> friend std::ostream& operator<<(std::ostream& os, darray<U> const& ar);
};
template<typename T>
std::ostream& darray<T>::print(std::ostream& os) const
{
os << "{ ";
for (size_t i = 0; i < m_size; i++)
{
os << m_data[i] << ", ";
if ( i == m_size - 1 )
os << m_data[i];
}
os << " }\n";
return os;
}
template<typename U>
std::ostream& operator<<(std::ostream& os, darray<U> const& obj)
{
return obj.print(os);
}
</code></pre>
| [
{
"answer_id": 74431349,
"author": "brance",
"author_id": 2746366,
"author_profile": "https://Stackoverflow.com/users/2746366",
"pm_score": -1,
"selected": false,
"text": "/public"
},
{
"answer_id": 74434438,
"author": "bfrith",
"author_id": 19571192,
"author_profile": "https://Stackoverflow.com/users/19571192",
"pm_score": 0,
"selected": false,
"text": "docker compose down"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431194",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12137626/"
] |
74,431,211 | <p>hi My code as shown below, when i am trying to execute this code the result always gives me the else clause output, not able to understand where part of code is not working can you help me with it. Even if i type the correct answer still the out put is of else clause</p>
<pre><code>quizz = {
'Question1':{
'question':'what is the capital of India ',
'answer':'Delhi\n'
},
'Question2':{
'question':'what is the capital of germany ',
'answer':'Berlin\n'
}
}
score = 0
for key,value in quizz.items():
print(value['question'])
answer = input('Enter your answer ')
if answer.lower() == value['answer'].lower():
print('Thats correct answer')
score += 1
print('your score is '+ str(score))
else:
print('wrong')
print('your score is: ' + str(score) )
</code></pre>
<p>when the user input matches with the answer it should give me the proper output</p>
| [
{
"answer_id": 74431274,
"author": "abel1502",
"author_id": 13484707,
"author_profile": "https://Stackoverflow.com/users/13484707",
"pm_score": 2,
"selected": false,
"text": "input()"
},
{
"answer_id": 74431311,
"author": "askinmert",
"author_id": 12478084,
"author_profile": "https://Stackoverflow.com/users/12478084",
"pm_score": 0,
"selected": false,
"text": "quizz = {\n 'Question1':{\n 'question':'what is the capital of India ',\n 'answer':'Delhi\\n'\n },\n 'Question2':{\n 'question':'what is the capital of germany ',\n 'answer':'Berlin\\n'\n }\n"
},
{
"answer_id": 74431342,
"author": "sya",
"author_id": 18458525,
"author_profile": "https://Stackoverflow.com/users/18458525",
"pm_score": -1,
"selected": false,
"text": "quizz = {\n 'Question1':{\n 'question':'what is the capital of India ',\n 'answer':'Delhi'\n },\n 'Question2':{\n 'question':'whenter code hereat is the capital of germany ',\n 'answer':'Berlin'\n }\n}\nscore = 0\nfor key,value in quizz.items():\n print(value['question'])\n answer = input('Enter your answer ')\n\n if answer.lower() == value['answer'].lower():\n print('Thats correct answer')\n score += 1\n print('your score is '+ str(score))\n else:\n print('wrong')\n print('your score is: ' + str(score) )\n"
},
{
"answer_id": 74431362,
"author": "Thomas Hall",
"author_id": 18212295,
"author_profile": "https://Stackoverflow.com/users/18212295",
"pm_score": 0,
"selected": false,
"text": "quizz = {\n 'Question1':{\n 'question':'what is the capital of India? ',\n 'answer':'Delhi'\n },\n 'Question2':{\n 'question':'what is the capital of Germany? ',\n 'answer':'Berlin'\n }\n}\nscore = 0\nfor key,value in quizz.items():\n print(value['question'])\n answer = input('Enter your answer: ')\n\n if answer.lower() == value['answer'].lower():\n print('That is the correct answer')\n score += 1\n print('your score is '+ str(score))\n else:\n print('that is the incorrect answer...')\n print('your score is: ' + str(score) )\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16835606/"
] |
74,431,217 | <p>Hi Im making a big MVC project and now I'm trying to implement a logging functionallity through .xml file. I've triple checked the heading for typos and tried using differend encodings but nothing worked. I've added appenders for RollingFile and ConsoleAppender.I want to make a log containing name,date and level.I think thats all</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
<property name="LOG_FILE" value="logs/app.log"/>
<appender name="FILE-ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_FILE}</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>logs/archived/app.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<!-- each archived file, size max 5KB -->
<maxFileSize>5KB</maxFileSize>
<!-- total size of all archive files, if total size > 20KB,
it will delete old archived file -->
<totalSizeCap>20KB</totalSizeCap>
<!-- 60 days to keep -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%d %p %c{1.} [%t] %m%n</pattern>
</encoder>
</appender>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>
%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n
</Pattern>
</layout>
</appender>
<logger name="com.dailycodebuffer" level="error" additivity="false">
<appender-ref ref="EMAIL"/>
</logger>
<logger name="com.dailycodebuffer" level="trace" additivity="false">
<appender-ref ref="FILE-ROLLING"/>
</logger>
<root level="error">
<appender-ref ref="FILE-ROLLING"/>
</root>
<logger name="com.dailycodebuffer" level="debug" additivity="false">
<appender-ref ref="CONSOLE"/>
</logger>
<root level="error">
<appender-ref ref="CONSOLE"/>
</root>
</configuration>
</code></pre>
<p>the error im getting</p>
<pre><code> Logging system failed to initialize using configuration from 'null'
java.lang.IllegalStateException: Could not initialize Logback logging from classpath:logback.xml
at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:240)
at org.springframework.boot.logging.logback.LogbackLoggingSystem.reinitialize(LogbackLoggingSystem.java:307)
at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:73)
at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:60)
at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:186)
at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:332)
at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:298)
at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:246)
at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:223)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131)
at org.springframework.boot.context.event.EventPublishingRunListener.multicastInitialEvent(EventPublishingRunListener.java:136)
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:81)
at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:64)
at java.base/java.lang.Iterable.forEach(Iterable.java:75)
at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:118)
at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:112)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:63)
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:352)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1291)
at com.myfirm.CarDealer.CarDealerApplication.main(CarDealerApplication.java:10)
Caused by: ch.qos.logback.core.joran.spi.JoranException: Problem parsing XML document. See previously reported errors.
at ch.qos.logback.core.joran.event.SaxEventRecorder.recordEvents(SaxEventRecorder.java:71)
at ch.qos.logback.core.joran.GenericXMLConfigurator.populateSaxEventRecorder(GenericXMLConfigurator.java:178)
at ch.qos.logback.core.joran.GenericXMLConfigurator.doConfigure(GenericXMLConfigurator.java:159)
at ch.qos.logback.core.joran.GenericXMLConfigurator.doConfigure(GenericXMLConfigurator.java:122)
at ch.qos.logback.core.joran.GenericXMLConfigurator.doConfigure(GenericXMLConfigurator.java:65)
at org.springframework.boot.logging.logback.LogbackLoggingSystem.configureByResourceUrl(LogbackLoggingSystem.java:260)
at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:237)
... 24 more
Caused by: org.xml.sax.SAXParseException; systemId: file:/C:/gitlabProjects/project1/car_dealer/cardealer/target/classes/logback.xml; lineNumber: 1; columnNumber: 39; Content is not allowed in prolog.
at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1251)
at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:637)
at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:326)
at ch.qos.logback.core.joran.event.SaxEventRecorder.recordEvents(SaxEventRecorder.java:64)
... 30 more
</code></pre>
| [
{
"answer_id": 74431274,
"author": "abel1502",
"author_id": 13484707,
"author_profile": "https://Stackoverflow.com/users/13484707",
"pm_score": 2,
"selected": false,
"text": "input()"
},
{
"answer_id": 74431311,
"author": "askinmert",
"author_id": 12478084,
"author_profile": "https://Stackoverflow.com/users/12478084",
"pm_score": 0,
"selected": false,
"text": "quizz = {\n 'Question1':{\n 'question':'what is the capital of India ',\n 'answer':'Delhi\\n'\n },\n 'Question2':{\n 'question':'what is the capital of germany ',\n 'answer':'Berlin\\n'\n }\n"
},
{
"answer_id": 74431342,
"author": "sya",
"author_id": 18458525,
"author_profile": "https://Stackoverflow.com/users/18458525",
"pm_score": -1,
"selected": false,
"text": "quizz = {\n 'Question1':{\n 'question':'what is the capital of India ',\n 'answer':'Delhi'\n },\n 'Question2':{\n 'question':'whenter code hereat is the capital of germany ',\n 'answer':'Berlin'\n }\n}\nscore = 0\nfor key,value in quizz.items():\n print(value['question'])\n answer = input('Enter your answer ')\n\n if answer.lower() == value['answer'].lower():\n print('Thats correct answer')\n score += 1\n print('your score is '+ str(score))\n else:\n print('wrong')\n print('your score is: ' + str(score) )\n"
},
{
"answer_id": 74431362,
"author": "Thomas Hall",
"author_id": 18212295,
"author_profile": "https://Stackoverflow.com/users/18212295",
"pm_score": 0,
"selected": false,
"text": "quizz = {\n 'Question1':{\n 'question':'what is the capital of India? ',\n 'answer':'Delhi'\n },\n 'Question2':{\n 'question':'what is the capital of Germany? ',\n 'answer':'Berlin'\n }\n}\nscore = 0\nfor key,value in quizz.items():\n print(value['question'])\n answer = input('Enter your answer: ')\n\n if answer.lower() == value['answer'].lower():\n print('That is the correct answer')\n score += 1\n print('your score is '+ str(score))\n else:\n print('that is the incorrect answer...')\n print('your score is: ' + str(score) )\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14993069/"
] |
74,431,222 | <p>We developed an app which is running in android payment device(PAX). This device having low memory (1 GB).
In this app we are calling other app using ActivityResultLauncher and getting the result to store in our DB.</p>
<p>Out of 1000 cases 1 or 2 times our app is got killed while waiting for result and our app in background.</p>
<p>Here my doubts:
1)Is it possible to avoid that, my app got killed by Android
2)Is it possible to maintain the same state after app got killed, so when our app come to foreground we can capture the activity result..</p>
<p>We are using android:largeHeap="true"</p>
| [
{
"answer_id": 74431274,
"author": "abel1502",
"author_id": 13484707,
"author_profile": "https://Stackoverflow.com/users/13484707",
"pm_score": 2,
"selected": false,
"text": "input()"
},
{
"answer_id": 74431311,
"author": "askinmert",
"author_id": 12478084,
"author_profile": "https://Stackoverflow.com/users/12478084",
"pm_score": 0,
"selected": false,
"text": "quizz = {\n 'Question1':{\n 'question':'what is the capital of India ',\n 'answer':'Delhi\\n'\n },\n 'Question2':{\n 'question':'what is the capital of germany ',\n 'answer':'Berlin\\n'\n }\n"
},
{
"answer_id": 74431342,
"author": "sya",
"author_id": 18458525,
"author_profile": "https://Stackoverflow.com/users/18458525",
"pm_score": -1,
"selected": false,
"text": "quizz = {\n 'Question1':{\n 'question':'what is the capital of India ',\n 'answer':'Delhi'\n },\n 'Question2':{\n 'question':'whenter code hereat is the capital of germany ',\n 'answer':'Berlin'\n }\n}\nscore = 0\nfor key,value in quizz.items():\n print(value['question'])\n answer = input('Enter your answer ')\n\n if answer.lower() == value['answer'].lower():\n print('Thats correct answer')\n score += 1\n print('your score is '+ str(score))\n else:\n print('wrong')\n print('your score is: ' + str(score) )\n"
},
{
"answer_id": 74431362,
"author": "Thomas Hall",
"author_id": 18212295,
"author_profile": "https://Stackoverflow.com/users/18212295",
"pm_score": 0,
"selected": false,
"text": "quizz = {\n 'Question1':{\n 'question':'what is the capital of India? ',\n 'answer':'Delhi'\n },\n 'Question2':{\n 'question':'what is the capital of Germany? ',\n 'answer':'Berlin'\n }\n}\nscore = 0\nfor key,value in quizz.items():\n print(value['question'])\n answer = input('Enter your answer: ')\n\n if answer.lower() == value['answer'].lower():\n print('That is the correct answer')\n score += 1\n print('your score is '+ str(score))\n else:\n print('that is the incorrect answer...')\n print('your score is: ' + str(score) )\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431222",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20500118/"
] |
74,431,255 | <p>So far the questions I've seen were about deleting the whole message when a specific word is detected. What I need is to just edit the message and delete the specific letter, word, or emoji. How to do that?</p>
<p>So for example I have a message content saying "Awesome ❤️", and I want to delete ❤️ character only from the message, so it should be "Awesome".</p>
<pre><code>client.on("messageCreate", (message) => {
if(message.content.includes("❤️")) {
//delete the ❤️ emoji only
}
})
</code></pre>
| [
{
"answer_id": 74431274,
"author": "abel1502",
"author_id": 13484707,
"author_profile": "https://Stackoverflow.com/users/13484707",
"pm_score": 2,
"selected": false,
"text": "input()"
},
{
"answer_id": 74431311,
"author": "askinmert",
"author_id": 12478084,
"author_profile": "https://Stackoverflow.com/users/12478084",
"pm_score": 0,
"selected": false,
"text": "quizz = {\n 'Question1':{\n 'question':'what is the capital of India ',\n 'answer':'Delhi\\n'\n },\n 'Question2':{\n 'question':'what is the capital of germany ',\n 'answer':'Berlin\\n'\n }\n"
},
{
"answer_id": 74431342,
"author": "sya",
"author_id": 18458525,
"author_profile": "https://Stackoverflow.com/users/18458525",
"pm_score": -1,
"selected": false,
"text": "quizz = {\n 'Question1':{\n 'question':'what is the capital of India ',\n 'answer':'Delhi'\n },\n 'Question2':{\n 'question':'whenter code hereat is the capital of germany ',\n 'answer':'Berlin'\n }\n}\nscore = 0\nfor key,value in quizz.items():\n print(value['question'])\n answer = input('Enter your answer ')\n\n if answer.lower() == value['answer'].lower():\n print('Thats correct answer')\n score += 1\n print('your score is '+ str(score))\n else:\n print('wrong')\n print('your score is: ' + str(score) )\n"
},
{
"answer_id": 74431362,
"author": "Thomas Hall",
"author_id": 18212295,
"author_profile": "https://Stackoverflow.com/users/18212295",
"pm_score": 0,
"selected": false,
"text": "quizz = {\n 'Question1':{\n 'question':'what is the capital of India? ',\n 'answer':'Delhi'\n },\n 'Question2':{\n 'question':'what is the capital of Germany? ',\n 'answer':'Berlin'\n }\n}\nscore = 0\nfor key,value in quizz.items():\n print(value['question'])\n answer = input('Enter your answer: ')\n\n if answer.lower() == value['answer'].lower():\n print('That is the correct answer')\n score += 1\n print('your score is '+ str(score))\n else:\n print('that is the incorrect answer...')\n print('your score is: ' + str(score) )\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431255",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/874737/"
] |
74,431,264 | <pre><code>// ignore_for_file: prefer_const_literals_to_create_immutables, prefer_const_constructors
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
// ignore: import_of_legacy_library_into_null_safe
import 'package:gradient_bottom_navigation_bar/gradient_bottom_navigation_bar.dart';
import 'package:rent_project/Ui/Auth/Account_screen.dart';
import 'package:rent_project/Ui/Auth/cart_scree.dart';
import 'package:rent_project/Ui/Auth/home_Screen2.dart';
import 'package:rent_project/Ui/Auth/message_screen.dart';
class HomeScreen extends StatefulWidget {
const HomeScreen({super.key});
@override
State<HomeScreen> createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
int _selectedIndex = 0;
static const TextStyle optionStyle =
TextStyle(fontSize: 30, fontWeight: FontWeight.bold);
static const List<Widget> _widgetOptions = <Widget>[
Home_Screen(),
Msg_Screen(),
Cart_Screen(),
AccountScreen(),
];
void _onItemTapped(int index) {
setState(() {
_selectedIndex = index;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: _widgetOptions.elementAt(_selectedIndex),
),
bottomNavigationBar: GradientBottomNavigationBar(
backgroundColorStart: Colors.purple,
backgroundColorEnd: Colors.white,
items: <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.home),
title: Text('Home'),
backgroundColor: Colors.purple,
),
BottomNavigationBarItem(
icon: Icon(Icons.message),
label: 'Message',
backgroundColor: Colors.purple,
),
BottomNavigationBarItem(
icon: Icon(Icons.shop),
label: 'Cart',
backgroundColor: Colors.purple,
),
BottomNavigationBarItem(
icon: Icon(Icons.account_box),
label: 'Account',
backgroundColor: Colors.purple,
),
],
currentIndex: _selectedIndex,
onTap: _onItemTapped,
),
);
}
}
</code></pre>
<p>I have seen the example code for GradientBottonNavigationBar on flutter's website they have used the title for the items but when I am using the title instead of label its giving me error and also its not accepting the label.</p>
<p>help me to solve this issue,</p>
<p>what should I do here? label is also giving me error and title is also creating troubles.....</p>
<pre><code>Try correcting the name to the name of an existing getter, or defining a getter or field named 'title'.
child: item.title
</code></pre>
| [
{
"answer_id": 74433215,
"author": "Yeasin Sheikh",
"author_id": 10157127,
"author_profile": "https://Stackoverflow.com/users/10157127",
"pm_score": 0,
"selected": false,
"text": "label"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431264",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19753091/"
] |
74,431,267 | <p>I am working on my test project and i check all null value but it didnt worked from my side. Always showing empty list view. Is there any way to solve this issue it will be very helpful!
Here is my screenshot to remove blank list item:
<a href="https://i.stack.imgur.com/Vclsp.png" rel="nofollow noreferrer">enter image description here</a></p>
<p>API Endpoint: <a href="https://retoolapi.dev/GFHqAV/getemployees" rel="nofollow noreferrer">check api here</a></p>
<h1><strong>Model Class:</strong></h1>
<p>`</p>
<pre><code>import 'dart:convert';
List<EmployeeResponseModel> employeeResponseModelFromJson(String str) =>
List<EmployeeResponseModel>.from(
json.decode(str).map((x) => EmployeeResponseModel.fromJson(x)));
String employeeResponseModelToJson(List<EmployeeResponseModel> data) =>
json.encode(List<dynamic>.from(data.map((x) => x.toJson())));
class EmployeeResponseModel {
EmployeeResponseModel({
this.id,
this.name,
this.company,
this.designation,
this.companyLogo,
});
final int? id;
final String? name;
final String? company;
final String? designation;
final String? companyLogo;
factory EmployeeResponseModel.fromJson(Map<String, dynamic> json) =>
EmployeeResponseModel(
id: json["id"] == "null" ? '' : json["id"],
name: json["name"] == "null" ? '' : json["name"],
company: json["company"] == "null" ? '' : json["company"],
designation: json["designation"] == "null" ? '' : json["designation"],
companyLogo: json["company_logo"] == "null" ? '' : json["company_logo"],
);
Map<String, dynamic> toJson() => {
"id": id,
"name": name,
"company": company,
"designation": designation,
"company_logo": companyLogo,
};
}
</code></pre>
<p>`</p>
<h1><strong>Provider:</strong></h1>
<p>`</p>
<pre><code>class EmployeeProvider extends ChangeNotifier {
bool isAuthenticated = false;
Future<List<EmployeeResponseModel>?> getAllEmployee() async {
try {
http.Response response = await http.get(
Uri.parse(ApiBaseUrl().employeeBaseUrl),
headers: {
'Content-Type': 'application/json; charset=utf-8',
},
);
if (response.statusCode == 200) {
final parsed = json.decode(response.body);
notifyListeners();
return parsed
.map<EmployeeResponseModel>(
(json) => EmployeeResponseModel.fromJson(json))
.toList();
} else {
throw Exception(AppStrings.failedToLoadEmployeeList);
}
} on SocketException {
throw AppStrings.noInternet;
}
}
}
</code></pre>
<p>`</p>
<h1><strong>Render list to UI:</strong></h1>
<p>`</p>
<pre><code>class EmployeeList extends StatefulWidget {
const EmployeeList({super.key});
@override
State<EmployeeList> createState() => _EmployeeListState();
}
class _EmployeeListState extends State<EmployeeList> {
late Future<List<EmployeeResponseModel>?> _employeeModelList;
void initState() {
getAllEmployee();
super.initState();
}
Future<void> getAllEmployee() async {
setState(() {
_employeeModelList = Provider.of<EmployeeProvider>(context, listen: false)
.getAllEmployee();
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text(AppStrings.employeeList),
backgroundColor: Colors.blue,
),
body: RefreshIndicator(
onRefresh: getAllEmployee,
child: SingleChildScrollView(
physics: const ScrollPhysics(),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
FutureBuilder<List<EmployeeResponseModel>?>(
future: _employeeModelList,
builder: (context, snapshot) {
switch (snapshot.connectionState) {
case ConnectionState.none:
case ConnectionState.active:
case ConnectionState.waiting:
return ListView.builder(
itemCount: 10,
shrinkWrap: true,
itemBuilder: (context, index) {
return skeltonBuild();
});
case ConnectionState.done:
if (snapshot.hasData && snapshot.data!.isNotEmpty) {
return Flexible(
child: ListView.builder(
itemCount: snapshot.data!.length,
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (_, index) {
return EmployeeListWidget(
name: snapshot.data![index].name.toString(),
company:
snapshot.data![index].company.toString(),
designation: snapshot.data![index].designation
.toString(),
company_logo: snapshot.data![index].companyLogo
.toString(),
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
const EmployeeDetails()),
),
);
},
),
);
} else {
return Padding(
padding: EdgeInsets.only(
top: MediaQuery.of(context).size.height * 0.2),
child: NoInternetConnection(
message: snapshot.error.toString()),
);
}
}
},
),
],
),
),
),
);
}
</code></pre>
<p>`</p>
<h1><strong>Widget:</strong></h1>
<p>`</p>
<pre><code>class EmployeeListWidget extends StatelessWidget {
final String name;
final String company;
final String designation;
final String company_logo;
final VoidCallback? onTap;
const EmployeeListWidget(
{super.key,
required this.name,
required this.company,
required this.designation,
required this.company_logo,
required this.onTap});
@override
Widget build(BuildContext context) {
return InkWell(
onTap: onTap,
child: Padding(
padding: const EdgeInsets.fromLTRB(4.0, 0.0, 4.0, 0.0),
child: Card(
elevation: 2.0,
child: Padding(
padding: const EdgeInsets.all(4.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (name != "null")
Text(name.toString(),
style: const TextStyle(
fontSize: 16,
color: Colors.black87,
fontWeight: FontWeight.bold)),
const SizedBox(height: 4),
if (company != "null")
SmallGreyTextIcon(
text: company, icon: Icons.apartment_outlined),
const SizedBox(height: 4),
if (designation != "null")
SmallGreyTextIcon(
text: designation, icon: Icons.badge_outlined),
],
),
const SizedBox(
height: 4,
),
if (company_logo != "null")
CachedNetworkImage(
imageUrl: company_logo,
width: 50,
height: 50,
placeholder: (context, url) =>
const CircularProgressIndicator(),
errorWidget: (context, url, error) =>
const Icon(Icons.error),
),
],
),
),
),
),
);
}
}
</code></pre>
<p>`</p>
<p>Please help me to find this better way to handle this problem.</p>
<p>I have tried null check and validatin it still show blank list. I wan tot remove that blank list value from list view.</p>
| [
{
"answer_id": 74433215,
"author": "Yeasin Sheikh",
"author_id": 10157127,
"author_profile": "https://Stackoverflow.com/users/10157127",
"pm_score": 0,
"selected": false,
"text": "label"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20500210/"
] |
74,431,293 | <p>Working on a huge repo with lots of activity all day, I'm trying to figure a method to get the list of files from chained commits on a branch via API. Doing it via git operations is causing me huge pain.</p>
<p>When one creates a pull request in the web UI as in "Create a pull request" then click "Files", Azure has exact knowledge of the commits and files. I am looking for a way to emulate this, ideally without creating the pull request. If I can get the commit hashes, that too would work.</p>
| [
{
"answer_id": 74433215,
"author": "Yeasin Sheikh",
"author_id": 10157127,
"author_profile": "https://Stackoverflow.com/users/10157127",
"pm_score": 0,
"selected": false,
"text": "label"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431293",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1018542/"
] |
74,431,336 | <p>I'm not new at Java, but I'm in JUnit. I'm having a problem with a simple for loop. I'm ordering array elements with bubble sorting, but I don't know why the two last elements disappear during the loop. I know it will be a little tiny thing, but I can't find the mistake. Could you help me, please?</p>
<p>This is my class:</p>
<pre><code>package exercise5;
public class Ejercicio5 {
public static int[] sort(int[] arrayNums) {
// array that I have tried: {6,5,8,3,7,1}; [6]
System.out.println("size: " + arrayNums.length);
for (int j = 0; j < arrayNums.length; j++) {
System.out.println("j:" + j);
if (arrayNums[j] > arrayNums[j + 1]) {
System.out.println("entra");
int numGuardado = arrayNums[j + 1];
arrayNums[j + 1] = arrayNums[j];
arrayNums[j] = numGuardado;
}
print(arrayNums);
}
return arrayNums;
}
public static void print(int[] arrayParaImprimir) {
System.out.println("Array:");
for (int j = 0; j < arrayParaImprimir.length; j++) {
if (j != arrayParaImprimir.length - 1) {
System.out.print(arrayParaImprimir[j] + ", ");
} else {
System.out.print(arrayParaImprimir[j] + "\n");
}
}
}
}
</code></pre>
<p>My TestClass with JUnit5:</p>
<pre><code>package exercise5;
import org.junit.Assert;
import org.junit.jupiter.api.Test;
import junit.framework.TestCase;
public class Ejercicio5Test extends TestCase{
@Test
public void resultadoCorrecto(){
int[] correct = {1,3,5,6,7,8};
int[] array = {6,5,8,3,7,1};
int[] result = Ejercicio5.sort(array);
Assert.assertArrayEquals(result, correct);
}
@Test
public void resultadoIncorrecto(){
int[] correct = {1,3,5,6};
int[] array = {3,5,6,1};
int[] result = Ejercicio5.sort(array);
Assert.assertArrayEquals(result, correct);
}
}
</code></pre>
<p>When j is equal to 4, the ordering is doing: 5, 6, 3, 7, 1, 8
but when j passed to 5, two elements disappear.
In addition, in my Test class there are only two methods, but, when I run it, it recognises one more and give me an error:</p>
<p><a href="https://i.stack.imgur.com/w5GKV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/w5GKV.png" alt="enter image description here" /></a></p>
<p>This is the array that I have tried {1,3,5,6,7,8} and this is that I expected {5,6,3,7,1,8} with 6 of array's size, not element disappearing.</p>
<p><a href="https://i.stack.imgur.com/64OBg.png" rel="nofollow noreferrer">enter image description here</a></p>
<p>This is the output in console. NOT ArrayIndexOutOfBounds. Only disappear 2 elements, and the size changes, not throwing any exceptions:</p>
<pre class="lang-none prettyprint-override"><code>size: 6
j:0
entra
Array:
5, 6, 8, 3, 7, 1
j:1
Array:
5, 6, 8, 3, 7, 1
j:2
entra
Array:
5, 6, 3, 8, 7, 1
j:3
entra
Array:
5, 6, 3, 7, 8, 1
j:4
entra
Array:
5, 6, 3, 7, 1, 8
j:5
size: 4
j:0
Array:
3, 5, 6, 1
j:1
Array:
3, 5, 6, 1
j:2
entra
Array:
3, 5, 1, 6
j:3
</code></pre>
| [
{
"answer_id": 74433215,
"author": "Yeasin Sheikh",
"author_id": 10157127,
"author_profile": "https://Stackoverflow.com/users/10157127",
"pm_score": 0,
"selected": false,
"text": "label"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431336",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20500251/"
] |
74,431,404 | <p>I have a question regarding converting spatial data in R and bringing it from R into QGIS.</p>
<p>I have a GeoTiff of Antarctic sea ice concentration, downloaded from the link below:</p>
<p><a href="https://seaice.uni-bremen.de/databrowser/#day=13&month=10&year=2022&img=%7B%22image%22%3A%22image-1%22%2C%22product%22%3A%22AMSR%22%2C%22type%22%3A%22visual%22%2C%22region%22%3A%22Antarctic3125%22%7D" rel="nofollow noreferrer">https://seaice.uni-bremen.de/databrowser/#day=13&month=10&year=2022&img=%7B%22image%22%3A%22image-1%22%2C%22product%22%3A%22AMSR%22%2C%22type%22%3A%22visual%22%2C%22region%22%3A%22Antarctic3125%22%7D</a></p>
<p>I want to extract the contour of the sea ice edge (defined as 15%), and then have this contour in a file type that I can open in QGIS and reproject for use in making other maps. My current understanding is that to do this, I would need to convert the contour to a spatial points df, and then convert that to a spatial polygons df which I would then be able to open as a shapefile in QGIS. However, I think I'm going wrong here as I cannot make the conversion with the below code - any suggestions?</p>
<pre><code>**This is my current workflow:**
library(raster)
library(tidyverse)
library(sp)
library(sf)
#Load in sea ice geotiff
sic <- raster('Environmental_Data/SIC/AMSR2/asi-AMSR2-s3125-20220107-v5.4.tif')/1
plot(sic)
#Make all values over land NA
sic[sic>100] = NA
#Crop to make area smaller (I have a specific area of interest)
sic = crop(sic, extent(sic)*c(0.5,0.5,0,1))
plot(sic)
#Pull out the sea ice edge (15% contour) (this makes it a spatial lines df)
ie = rasterToContour(sic, levels=15)
#Convert to spatial points
ie.pt = as(ie, "SpatialPointsDataFrame") plot(ie.pt, add=T, pch=16, cex=0.4)
#Convert to spatial polygons
ie.pt_poly <-as(ie.pt, "SpatialPolygons")
#Then I get this error:
Error in as(ie.pt, "SpatialPolygons"):
no method or default for coercing “SpatialPointsDataFrame” to “SpatialPolygons”
</code></pre>
| [
{
"answer_id": 74435877,
"author": "Chris",
"author_id": 794450,
"author_profile": "https://Stackoverflow.com/users/794450",
"pm_score": 1,
"selected": false,
"text": "terra"
},
{
"answer_id": 74439071,
"author": "Robert Hijmans",
"author_id": 635245,
"author_profile": "https://Stackoverflow.com/users/635245",
"pm_score": 1,
"selected": true,
"text": "library(terra)\nr <- rast(\"asi-AMSR2-s3125-20221113-v5.4.tif\")\n\n# crop to the area of interest\ne <- ext(-1975000, 1975000, 2e+05, 4350000)\nre <- crop(r, e)\n\n# get contour and save to file\nv <- as.contour(re, levels=15)\nwriteVector(v, \"contour_lines.shp\")\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431404",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20179430/"
] |
74,431,425 | <p>I am totally new to PHP. I am trying to automatically create a WordPress user when a form is submitted with a custom plugin using the following code:</p>
<pre><code>add_action( 'gform_post_process', 'wp_create_user', 10, 3 );
function wp_create_user( $username, $random_password, $email ) {
$user_login = wp_slash( $entry[1]);
$user_email = wp_slash( $entry[2]);
$user_pass = wp_generate_password( $length = 12, $include_standard_special_chars = false );
$role = 'Cp Client';
$userdata = compact( 'user_login', 'user_email', 'user_pass' );
return wp_insert_user( $userdata );
}}
</code></pre>
<p>I have also tried with gform_after_submission and changing the function's name, but then my website breaks.</p>
<p>What Am I doing wrong? Is this even possible? Could someone offer me a code example, please?</p>
<p>Thanks in advance,</p>
<p>Paco</p>
| [
{
"answer_id": 74435877,
"author": "Chris",
"author_id": 794450,
"author_profile": "https://Stackoverflow.com/users/794450",
"pm_score": 1,
"selected": false,
"text": "terra"
},
{
"answer_id": 74439071,
"author": "Robert Hijmans",
"author_id": 635245,
"author_profile": "https://Stackoverflow.com/users/635245",
"pm_score": 1,
"selected": true,
"text": "library(terra)\nr <- rast(\"asi-AMSR2-s3125-20221113-v5.4.tif\")\n\n# crop to the area of interest\ne <- ext(-1975000, 1975000, 2e+05, 4350000)\nre <- crop(r, e)\n\n# get contour and save to file\nv <- as.contour(re, levels=15)\nwriteVector(v, \"contour_lines.shp\")\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431425",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19450544/"
] |
74,431,432 | <p>The user enters, for example, "Hello". How to make the "print" output the indexes of all the letters l</p>
<pre><code>if "l" in user_sms:
print()
</code></pre>
| [
{
"answer_id": 74435877,
"author": "Chris",
"author_id": 794450,
"author_profile": "https://Stackoverflow.com/users/794450",
"pm_score": 1,
"selected": false,
"text": "terra"
},
{
"answer_id": 74439071,
"author": "Robert Hijmans",
"author_id": 635245,
"author_profile": "https://Stackoverflow.com/users/635245",
"pm_score": 1,
"selected": true,
"text": "library(terra)\nr <- rast(\"asi-AMSR2-s3125-20221113-v5.4.tif\")\n\n# crop to the area of interest\ne <- ext(-1975000, 1975000, 2e+05, 4350000)\nre <- crop(r, e)\n\n# get contour and save to file\nv <- as.contour(re, levels=15)\nwriteVector(v, \"contour_lines.shp\")\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431432",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20377891/"
] |
74,431,472 | <p>I have a <code>Hashmap< String, String> p</code> and I'm trying to replace half of the values of the keys with '-'
For instance, lets say my current Hashmap has the following values</p>
<pre><code>"A", "100"
"B", "400"
"C", "600"
"D", "845"
</code></pre>
<p>I want to somehow manipulate only half (first two in this case) of the key of the values by changing their values from the provided integer to a '-'.
So it would look like this:</p>
<pre><code> "A", "-"
"B", "-"
"C", "600"
"D", "845"
</code></pre>
<p>I've attempted this, but to no avail.</p>
<pre><code>for (String i : p.keySet()/2) {
p.replace(i, '-')
}
</code></pre>
<p>Is there a way to do this? If yes, can you please explain how?</p>
| [
{
"answer_id": 74431716,
"author": "szeak",
"author_id": 1597791,
"author_profile": "https://Stackoverflow.com/users/1597791",
"pm_score": 1,
"selected": true,
"text": "int maxiterations = p.keySet().size() / 2;\nIterator<String> iterator = p.keySet().iterator();\nfor (int i=0; i < maxiterations; i++) {\n if (iterator.hasNext()) {\n String key = iterator.next();\n p.replace(key, \"-\");\n }\n}\n"
},
{
"answer_id": 74431732,
"author": "Vipul Pandey",
"author_id": 5881773,
"author_profile": "https://Stackoverflow.com/users/5881773",
"pm_score": 0,
"selected": false,
"text": " Map<Integer, Integer> map= new HashMap<>();\n for (int i = 0; i < 10; i++) {\n map.put(i,i);\n }\n int half=map.size()/2;\n int count=0;\n for (Map.Entry<Integer,Integer> cm: map.entrySet()) {\n if (!((count++) < half))) { // if my count is greater than half\n System.out.println(cm.getKey() + \" \" + cm.getValue());\n }\n }\n"
},
{
"answer_id": 74431819,
"author": "Aniruddh Parihar",
"author_id": 8031784,
"author_profile": "https://Stackoverflow.com/users/8031784",
"pm_score": -1,
"selected": false,
"text": "public static void putDashInMap(){\n Map<String, String > emap = new HashMap<>();\n int count =0;\n int halfCount = emap.entrySet().size()/2;\n for(Map.Entry str : emap.entrySet()){\n if(count<=halfCount){\n str.setValue(\"-\");\n }else{\n continue;// you can also use break here. its depend on you.\n }\n count++;\n }\n }\n"
},
{
"answer_id": 74432208,
"author": "xyz",
"author_id": 7715095,
"author_profile": "https://Stackoverflow.com/users/7715095",
"pm_score": 3,
"selected": false,
"text": " p.entrySet()\n .stream()\n .limit(p.size()/2)\n .forEach(e-> e.setValue(\"-\"));\n"
},
{
"answer_id": 74432553,
"author": "AAG",
"author_id": 8384918,
"author_profile": "https://Stackoverflow.com/users/8384918",
"pm_score": 0,
"selected": false,
"text": "String[] keys = capitalCities.keySet().toArray(new String[0]);\nfor(int i=0 ; i<keys.length/2 ; i++)\n capitalCities.put(keys[i],\"-\");\n"
},
{
"answer_id": 74436356,
"author": "Dinuka Silva",
"author_id": 20457576,
"author_profile": "https://Stackoverflow.com/users/20457576",
"pm_score": 0,
"selected": false,
"text": " public static void main(String[] args) {\n\n HashMap< String, String> p = new HashMap<>();\n p.put(\"A\", \"100\");\n p.put(\"B\", \"400\");\n p.put(\"C\", \"600\");\n p.put(\"D\", \"845\");\n\n int halfSize = (p.size() / 2)+1;\n\n for(String key : p.keySet()){\n halfSize = halfSize-1;\n if (halfSize == 0){\n break;\n }else{\n p.replace(key, \"-\");\n }\n }\n\n for (String key : p.keySet()){\n System.out.println(p.get(key));\n }\n\n\n}\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431472",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18984687/"
] |
74,431,477 | <p>Is there a way to construct a map with two ranges in C++? That is, instead of calling a default constructor and consequently inserting elements to a map:</p>
<pre><code>for (size_t i = 0; i < Vector_1.size() && i < Vector_2.size(); i++) {
mymap[Vector_1[i]] = Vector_2[i];
}
</code></pre>
<p>I'd like to build a map in place by calling some sort of a constructor which would take two ranges as arguments, something like this:</p>
<pre><code>std::map<t1, t2> mymap(Vector_1.begin(), Vector_1.end(), Vector_2.begin(), Vector_2.end());
</code></pre>
<p>Or:</p>
<pre><code>mymap.insert(Vector_1.begin(), Vector_1.end(), Vector_2.begin(), Vector_2.end());
</code></pre>
<p>I haven't found any, but maybe there is still a way to do it. Is there a shortcut to initialize a map from two ranges, or at least insert two ranges into a map?</p>
| [
{
"answer_id": 74433668,
"author": "rturrado",
"author_id": 260313,
"author_profile": "https://Stackoverflow.com/users/260313",
"pm_score": 3,
"selected": false,
"text": "#include <fmt/ranges.h>\n#include <map>\n#include <range/v3/all.hpp>\n#include <vector>\n\nint main() {\n std::vector<char> cs{'a', 'b', 'c'};\n std::vector<int> is{1, 2, 3};\n auto m{ ranges::views::zip(cs, is) | ranges::to<std::map<char, int>>() };\n fmt::print(\"{}\", m);\n}\n\n// Outputs: {'a': 1, 'b': 2, 'c': 3}\n"
},
{
"answer_id": 74435078,
"author": "MarkB",
"author_id": 17841694,
"author_profile": "https://Stackoverflow.com/users/17841694",
"pm_score": 1,
"selected": false,
"text": "#include <cassert>\n#include <vector>\n#include <list>\n#include <map>\n#include <ranges>\n#include <iostream>\n\ntemplate <std::ranges::range K, std::ranges::range V>\nstd::map<std::ranges::range_value_t<K>, std::ranges::range_value_t<V>> createMapFromRanges(K&& krng, V&& vrng)\n{\n std::map<std::ranges::range_value_t<K>, std::ranges::range_value_t<V>> map;\n assert(std::size(krng) == std::size(vrng));\n auto [k, kend] = std::tuple{krng.begin(), krng.end()};\n auto [v, vend] = std::tuple{vrng.begin(), vrng.end()};\n while (k != kend && v != vend)\n map.emplace(*k++,*v++);\n return map;\n}\n \nint main()\n{\n auto map = createMapFromRanges(std::vector<int>{1,2,3}, std::list<int>{4,5,6});\n for (auto& elem : map) {\n std::cout << elem.first << '/' << elem.second << '\\n';\n }\n return 0;\n}\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431477",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14755500/"
] |
74,431,501 | <p>How can I generate a random number using Uniform distributed random number range between (Length of the string and 2000000), integer only., by using all the time constant seed(2) in random generation to get the same results in each run?</p>
<pre><code>x = random.uniform(len(String),200)
</code></pre>
<p>How can I use seed next?</p>
| [
{
"answer_id": 74431570,
"author": "Thomas Hall",
"author_id": 18212295,
"author_profile": "https://Stackoverflow.com/users/18212295",
"pm_score": 0,
"selected": false,
"text": "import random\nrandom.seed(12)\nfor i in range (1, 10):\n a = random.randint(1,10)\n print(a)\n"
},
{
"answer_id": 74431669,
"author": "atru",
"author_id": 2763915,
"author_profile": "https://Stackoverflow.com/users/2763915",
"pm_score": 2,
"selected": true,
"text": "import random\n\n# Fixed seed for repetitive results\nconst_seed = 200\n\n# Bounds of numbers\nn_min = 0\nn_max = 2\n\n# Final number of values \nn_numbers = 5\n\n# Seed and retrieve the values\nrandom.seed(const_seed)\n\nnumbers = [random.uniform(n_min, n_max) for i in range(0, n_numbers)]\n\nprint(numbers)\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431501",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18766534/"
] |
74,431,547 | <p>Suppose we have three tables student table, course table, and teacher table something like this</p>
<p>'student' table</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>std_id</th>
<th>std_name</th>
<th>course_id</th>
<th>teacher_id</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Ramesh</td>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td>2</td>
<td>Ganesh</td>
<td>1</td>
<td>3</td>
</tr>
<tr>
<td>3</td>
<td>Aadesh</td>
<td>3</td>
<td>3</td>
</tr>
<tr>
<td>4</td>
<td>Nilesh</td>
<td>3</td>
<td>1</td>
</tr>
<tr>
<td>5</td>
<td>Sonam</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>6</td>
<td>Abhi</td>
<td>2</td>
<td>4</td>
</tr>
<tr>
<td>7</td>
<td>Anil</td>
<td>2</td>
<td>4</td>
</tr>
</tbody>
</table>
</div>
<p>'course' table</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>course_id</th>
<th>course_name</th>
<th>std_id</th>
<th>teacher_id</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>JAVA</td>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td>2</td>
<td>JAVASCRIPT</td>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>VB.NET</td>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td>4</td>
<td>C#.NET</td>
<td>5</td>
<td>2</td>
</tr>
<tr>
<td>5</td>
<td>PYTHON</td>
<td>5</td>
<td>4</td>
</tr>
<tr>
<td>6</td>
<td>SAP</td>
<td>6</td>
<td>4</td>
</tr>
<tr>
<td>7</td>
<td>C++</td>
<td>6</td>
<td>1</td>
</tr>
</tbody>
</table>
</div>
<p>'teacher' table</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>teacher_id</th>
<th>teacher_name</th>
<th>course_id</th>
<th>std_id</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Roy</td>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td>2</td>
<td>Amit</td>
<td>2</td>
<td>1</td>
</tr>
<tr>
<td>3</td>
<td>John</td>
<td>1</td>
<td>5</td>
</tr>
<tr>
<td>4</td>
<td>Yogesh</td>
<td>3</td>
<td>5</td>
</tr>
<tr>
<td>5</td>
<td>Rocky</td>
<td>3</td>
<td>1</td>
</tr>
</tbody>
</table>
</div>
<p>so here I have given the three tables so now I want to show students who have the courses and teachers.</p>
<p>so here you can see in the 'student' table we have std_id and course_id and in the 'course' table we have course_id and std_id</p>
<p>so as you can see here in the student table we have std_id and course_id and in the course table we have course_id and std_id</p>
<p>so here which column should be used to join the student table with the course table?</p>
<p>because both tables have std_id and course_id and if I want to show students who have courses so which column should be used here to join the student table and the course table?</p>
<p>and here I also want to show teachers so here in the teacher table, we have teacher_id and course_id, and std_id here which table column should be used to join with the teacher table because the student table also has the teacher_id and course table also has the teacher_id so here which table teacher_id should be used here to join with the teacher table?</p>
<p>please let me know guys how can I know which column should be used here to join?</p>
| [
{
"answer_id": 74435147,
"author": "Tim Jarosz",
"author_id": 2452207,
"author_profile": "https://Stackoverflow.com/users/2452207",
"pm_score": 0,
"selected": false,
"text": "JOIN"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431547",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17296444/"
] |
74,431,568 | <p>I am implementing a code that after debugging for a month I found out the problem that could be translated in the present simpler case:</p>
<pre><code>for i in range(1,5):
x=2
if i==1:
y=2*x
else:
y=2*ypred
ypred=y
print(i)
print(ypred)
print(y)
</code></pre>
<p>I want to store only the previous value to be reuse in the loop. However, after analysing the print results, I found out that ypred is not the previous value of y in each interaction but exactly the same.</p>
<pre><code>1
4
4
2
8
8
3
16
16
4
32
32
</code></pre>
<p>I know this problem may be simple, but I am learning how to code for mathematical purposes.
How do I store only the previous value to be reused in the following interaction?</p>
<p>Thanks in advance.</p>
| [
{
"answer_id": 74435147,
"author": "Tim Jarosz",
"author_id": 2452207,
"author_profile": "https://Stackoverflow.com/users/2452207",
"pm_score": 0,
"selected": false,
"text": "JOIN"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431568",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16030617/"
] |
74,431,579 | <p>I have the following file structure in my monorepo</p>
<pre><code>monorepo
┣ node_modules
┣ packages
┃ ┣ package-1
┃ ┃ ┗ jest.config.js
┃ ┣ package-2
┃ ┃ ┗ jest.config.js
┃ ┣ package-3
┃ ┃ ┗ jest.config.js
┣ package.json
┗ jest.base.config.js
</code></pre>
<p>In the monorepo root I have the file <code>jest.base.config.js</code> which contains</p>
<pre><code>module.exports = {
coverageThreshold: {
global: {
branches: 80,
functions: 80,
lines: 80,
statements: 80,
},
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
transformIgnorePatterns: [
'node_modules/(?!((jest-)?react-native|@react-native(-community)?|@fortawesome/react-native-fontawesome|d3-.*|internmap)/)',
],
};
</code></pre>
<p>Then in each packages <code>jest.config.js</code> I imported the <code>jest.base.config</code> and export it with any overrides, like so</p>
<pre><code>const baseConfig = require('../../jest.base.config');
module.exports = {
...baseConfig,
testPathIgnorePatterns: ['<rootDir>/cypress/'],
collectCoverageFrom: ['src/**/*.{ts,tsx,js,jsx}', '!src/**/*.style.{ts,js}'],
moduleNameMapper: {
'^.+\\.svg$': '<rootDir>/__mocks__/mockSVG.js',
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|pdf)$':
'<rootDir>/__mocks__/mockFile.js',
'\\.(css|less)$': 'identity-obj-proxy',
},
globals: {
__WEB__: true,
google: {},
},
setupFiles: ['./jest.setup.js'],
testURL: 'http://localhost:3000',
};
</code></pre>
<p>However, there is an issue with one of the packages <code>@uiw/react-textarea-code-editor</code> <a href="https://github.com/uiwjs/react-textarea-code-editor/issues/111#issue-1204328945" rel="nofollow noreferrer">(Issue Here)</a> that needs a mapper, so trying to map it to a common js file, by adding it as a property in the <code>moduleNameMapper</code> property in the <code>jest.config.js</code> file.</p>
<pre><code>moduleNameMapper: {
...
'@uiw/react-textarea-code-editor': '<rootDir>/node_modules/@uiw/react-textarea-code-editor/dist/editor.js',
},
</code></pre>
<p>This works on a regular repository I have, but the issue here is <code><rootDir>/node_modules</code> is targeting <code>./packages/package-1/node_modules</code> and not <code>./node_modules</code> on the root of the monorepo as that is where the <code>@uiw</code> directory resides.</p>
<p>Now, I know I can change the <code>rootDir</code> to be <code>rootDir: './../../',</code> but that throws off all other references to <code>rootDir</code></p>
<p>I tried</p>
<pre><code>moduleNameMapper: {
...
'@uiw/react-textarea-code-editor': '../../node_modules/@uiw/react-textarea-code-editor/dist/editor.js',
},
</code></pre>
<p>Which should target <code>./node_modules/@uiw/react-textarea-code-editor/dist/editor.js</code></p>
<p>But that gives me the following error</p>
<pre><code>Configuration error:
Could not locate module @uiw/react-textarea-code-editor mapped as:
../../node_modules/@uiw/react-textarea-code-editor/dist/editor.js.
Please check your configuration for these entries:
{
"moduleNameMapper": {
"/@uiw\/react-textarea-code-editor/": "../../node_modules/@uiw/react-textarea-code-editor/dist/editor.js"
},
"resolver": undefined
}
</code></pre>
<p>Is there a more elegant solution than changing the <code>rootDir</code> value?</p>
| [
{
"answer_id": 74554414,
"author": "morganney",
"author_id": 258174,
"author_profile": "https://Stackoverflow.com/users/258174",
"pm_score": 1,
"selected": false,
"text": "@uiw/react-textarea-code-editor"
},
{
"answer_id": 74554625,
"author": "Fornasetti",
"author_id": 20586426,
"author_profile": "https://Stackoverflow.com/users/20586426",
"pm_score": 3,
"selected": true,
"text": "path.resolve"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431579",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3113377/"
] |
74,431,604 | <p>I am trying to loop through all items in a column.</p>
<p>If it meets the condition in the column then check to see,
If another condition is met in a different column.</p>
<p>The data types in the two columns are different, one is an integer & the other a string that I am checking for.</p>
<p>I am not sure where I have gone wrong & all information I've found online so far is about creating new columns based on data from a column.</p>
<p>Here is a simplified version of the code I am using.</p>
<pre><code>import pandas as pd
servercount = 0
othercount = 0
df = pd.DataFrame({
'operatingsystem': ['Windows 7', 'Windows Server 2012', 'Windows Server 2012 R',
'macOSX', 'Linux Server'],
'login': [9, 12, 5, 11, 19],
})
for i in df['login']:
if i > 10:
if i in df['operatingsystem'].str.lower().str.contains("server"):
servercount += 1
else:
othercount += 1
print("Servers:", servercount, "\nOthers:", othercount)
</code></pre>
<p>Currently this returns 0 on the servercount & 3 on the othercount meaning that it is not detecting the word server in the operatingsystem column.</p>
| [
{
"answer_id": 74554414,
"author": "morganney",
"author_id": 258174,
"author_profile": "https://Stackoverflow.com/users/258174",
"pm_score": 1,
"selected": false,
"text": "@uiw/react-textarea-code-editor"
},
{
"answer_id": 74554625,
"author": "Fornasetti",
"author_id": 20586426,
"author_profile": "https://Stackoverflow.com/users/20586426",
"pm_score": 3,
"selected": true,
"text": "path.resolve"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15835102/"
] |
74,431,609 | <p>I have added an image on my grid, and assign script to it. But script executes only when I click on image, and when another user(with reader permission) clicks on image nothing happens. The same situation is with <code>onOpen()</code> trigger - nothing happens when user whith reader permission opens the grid. I understand that editor permission will fix it, but I don't need the user to be able to edit the table, I only need that user be able click buttons(image)/get alive triggers/menus that i create, but not edit anything manually. How can i do this(may be i should give some extended reader permission, or to turn on something in GAS project)?</p>
| [
{
"answer_id": 74432143,
"author": "Martín",
"author_id": 20363318,
"author_profile": "https://Stackoverflow.com/users/20363318",
"pm_score": 0,
"selected": false,
"text": "function function1_toOrigin() {\n LibraryName.function1()\n}\nfunction function2_toOrigin() {\n LibraryName.function2()\n}\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431609",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10767014/"
] |
74,431,630 | <p>I have a very large json file that is in the form of multiple objects, for small dataset, this works</p>
<pre><code>data=pd.read_json(file,lines=True)
</code></pre>
<p>but on the same but larger dataset it would crash on 8gb ram computer, so i tried to convert it to list first with below code</p>
<pre><code>data[]
with open(file) as file:
for i in file:
d = json.loads(i)
data.append(d)'
</code></pre>
<p>then convert the list into dataframe with</p>
<pre><code>df = pd.DataFrame(data)
</code></pre>
<p>this does convert it into a list fine even with the large dataset file, but it crashes when i try to convert it into a dataframe due to it using to much memory i presume</p>
<p>i have tried doing</p>
<pre><code>data[]
with open(file) as file:
for i in file:
d = json.loads(i)
df=pd.DataFrame([d])'
</code></pre>
<p>I thought it would append it one by one but i think it still create one large copy in memory at once insteads, so it still crashes</p>
<p>how would i convert the large json file into dataframe by chuncks so it limit the memory useage?</p>
| [
{
"answer_id": 74432143,
"author": "Martín",
"author_id": 20363318,
"author_profile": "https://Stackoverflow.com/users/20363318",
"pm_score": 0,
"selected": false,
"text": "function function1_toOrigin() {\n LibraryName.function1()\n}\nfunction function2_toOrigin() {\n LibraryName.function2()\n}\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431630",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20500243/"
] |
74,431,650 | <p>I am creating a hangman game and I am displaying the letters that have not yet been guessed so if no letters have been guessed it displays all the abc's. And what I am trying to figure out is how to get rid of the letter the user inputted from the letters remaining and return the string of the remaining letters.</p>
<pre><code>def get_available_letters(letters_guessed):
"""
Returns a string of letters that have not yet been guessed.
:param: letters_guessed: letters that have been guessed so far by the player
:type letters_guessed: str
:return: letters that have not been guessed
:rtype: str
"""
ALL_LETTERS = 'abcdefghijklmnopqrstuvwxyz'
letters_guessed = letters_guessed.lower()
for ch in ALL_LETTERS:
if ch in letters_guessed:
letters_left = ALL_LETTERS.replace(letters_guessed, '')
return letters_left
else:
return ALL_LETTERS
</code></pre>
| [
{
"answer_id": 74431866,
"author": "1mmunity",
"author_id": 16578794,
"author_profile": "https://Stackoverflow.com/users/16578794",
"pm_score": 2,
"selected": true,
"text": "letters_guessed"
},
{
"answer_id": 74431874,
"author": "Pietro Campolucci",
"author_id": 15260703,
"author_profile": "https://Stackoverflow.com/users/15260703",
"pm_score": 0,
"selected": false,
"text": "ch"
},
{
"answer_id": 74431967,
"author": "Brhaka",
"author_id": 11578778,
"author_profile": "https://Stackoverflow.com/users/11578778",
"pm_score": 0,
"selected": false,
"text": "abc"
},
{
"answer_id": 74431971,
"author": "pL3b",
"author_id": 17200418,
"author_profile": "https://Stackoverflow.com/users/17200418",
"pm_score": 0,
"selected": false,
"text": "from string import ascii_lowercase\n\nALL_LETTERS = list(ascii_lowercase)\nLETTERS_LEFT = ALL_LETTERS\n\ndef guess():\n letter = str(input(\"Enter letter: \")).lower()\n if letter in LETTERS_LEFT:\n LETTERS_LEFT.pop(LETTERS_LEFT.index(letter)) # Remove letter from list\n elif letter in ALL_LETTERS:\n print(\"This letter was already used!\")\n else:\n print(\"Wrong input! Use one of:\", \"\".join(ALL_LETTERS))\n return get_available_letters()\n\n\ndef get_available_letters():\n return LETTERS_LEFT\n\n\nwhile True:\n print(guess())\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431650",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20326002/"
] |
74,431,668 | <p>I'm following the <a href="https://hub.docker.com/_/mariadb/" rel="nofollow noreferrer">docs of mariadb</a>. It says that the db should be created if it find a .sql in /docker-entrypoint-initdb.d.
I'm working on a Ubuntu Server in a Oracle Virtual BOX VM.
My docker-compose.yml looks like this:</p>
<pre><code>version: "3.9"
services:
db:
image: mariadb:10
container_name: mariadb
ports:
- 3306:3306
environment:
- MYSQL_USER=user
- MYSQL_ROOT_PASSWORD=password
- MYSQL_PASSWORD=password
- MARIADB_DATABASE=database // tried with MYSQL_DATABASE and without this line
volumes:
- "db_data:/var/lib/mysql"
- ".database/initdb/dump.sql:/docker-entrypoint-initdb.d/initdb.sql"
# networks:
# - network
volumes:
db_data:
</code></pre>
<p>My initdb.sql looks like this (the one that should work in the end looks different but out of simplicity I reduced it to the max and could not even this simple one working):</p>
<pre><code>CREATE DATABASE NEWDB;
</code></pre>
<p>I honestly don't know where to look or what to do now because everywhere I looked for a possible solution I found that this is the bare minimum example that should work.</p>
<p>I tried to restarted docker, deleted all containers, images and volumes, modified the initdb.sql into:</p>
<pre><code>CREATE USER user WITH PASSWORD 'password';
CREATE DATABASE IF NOT EXISTS database;
GRANT ALL PRIVILEGES ON DATABASE database TO user;
</code></pre>
<p>but the database is not initialized when I docker compose up.
I looked up the container and the initdb.sql was there.</p>
<p>EDIT: It somehow worked, when I docker compose up with MARIADB_DATABASE=database but the script initdb.sql still doesn't work and it's the most important thing because it set's up the whole database.
(NOTE: On top of that I want to set up another PHP-container that runs a PHP-script in order to collect data that is being stored in the above MariaDB-container. The MariaDB is connected with a website that calls data from the container)</p>
| [
{
"answer_id": 74431884,
"author": "Salvino D'sa",
"author_id": 16046521,
"author_profile": "https://Stackoverflow.com/users/16046521",
"pm_score": 1,
"selected": false,
"text": "php"
},
{
"answer_id": 74485354,
"author": "pheromone42",
"author_id": 16464441,
"author_profile": "https://Stackoverflow.com/users/16464441",
"pm_score": 0,
"selected": false,
"text": "# For more information: https://laravel.com/docs/sail\nversion: '3'\nservices:\n laravel.test:\n build:\n context: ./vendor/laravel/sail/runtimes/8.1\n dockerfile: Dockerfile\n args:\n WWWGROUP: '${WWWGROUP}'\n image: sail-8.1/app\n extra_hosts:\n - 'host.docker.internal:host-gateway'\n ports:\n - '${APP_PORT:-80}:80'\n - '${VITE_PORT:-5173}:${VITE_PORT:-5173}'\n environment:\n WWWUSER: '${WWWUSER}'\n LARAVEL_SAIL: 1\n XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}'\n XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}'\n volumes:\n - '.:/var/www/html'\n networks:\n - sail\n depends_on:\n - mariadb\n mariadb:\n image: 'mariadb:10'\n container_name: 'mariadb-10'\n ports:\n - '${FORWARD_DB_PORT:-3306}:3306'\n environment:\n MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'\n MYSQL_ROOT_HOST: \"%\"\n MYSQL_DATABASE: '${DB_DATABASE}'\n MYSQL_USER: '${DB_USERNAME}'\n MYSQL_PASSWORD: '${DB_PASSWORD}'\n MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'\n volumes:\n - 'sail-mariadb:/var/lib/mysql'\n - './vendor/laravel/sail/database/mysql/create-testing-database.sh:/docker-entrypoint-initdb.d/10-create-testing-database.sh'\n networks:\n - sail\n healthcheck:\n test: [\"CMD\", \"mysqladmin\", \"ping\", \"-p${DB_PASSWORD}\"]\n retries: 3\n timeout: 5s\nnetworks:\n sail:\n driver: bridge\nvolumes:\n sail-mariadb:\n driver: local\n\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431668",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16464441/"
] |
74,431,681 | <p>I have an external API which returns numbers as strings in the following format</p>
<pre><code>5e+24
</code></pre>
<p>which is supposed to mean a number equal to <code>5 * 10^24</code> ==> 5 with 24 zeros.</p>
<p>Does Elixir have a capacity to convert such numbers into integers?</p>
<p>And what is this format even called?</p>
| [
{
"answer_id": 74432119,
"author": "zwippie",
"author_id": 409792,
"author_profile": "https://Stackoverflow.com/users/409792",
"pm_score": 3,
"selected": true,
"text": "Float.parse"
},
{
"answer_id": 74432898,
"author": "Adam Millerchip",
"author_id": 1225617,
"author_profile": "https://Stackoverflow.com/users/1225617",
"pm_score": 2,
"selected": false,
"text": "[a, b] = String.split(\"5e+24\", \"e+\")\nString.to_integer(a) * 10 ** String.to_integer(b)\n"
},
{
"answer_id": 74433115,
"author": "bortzmeyer",
"author_id": 15625,
"author_profile": "https://Stackoverflow.com/users/15625",
"pm_score": 1,
"selected": false,
"text": "defmodule BigInteger do\n \n def parse(s) do\n {i, e} = Integer.parse(s)\n e = String.downcase(e)\n if not String.starts_with?(e, \"e\") do\n {:error, \"No \\\"e\\\"\"}\n else\n e = String.slice(e, 1..-1)\n cond do\n String.starts_with?(e, \"+\") ->\n {exp, rest} = Integer.parse(String.slice(e, 1..-1))\n if rest != \"\" do\n IO.inspect(rest)\n {:error, \"Not integer after \\\"e+\\\"\"}\n else\n {:ok, i * Integer.pow(10, exp)}\n end\n True ->\n {exp, rest} = Integer.parse(String.slice(e, 0..-1))\n if rest != \"\" do\n {:error, \"Not integer after \\\"e\\\"\"}\n else\n {:ok, i * Integer.pow(10, exp)}\n end\n end\n end\n end\nend\n\nIO.inspect(BigInteger.parse(\"3e+24\"))\nIO.inspect(BigInteger.parse(\"4e24\"))\nIO.inspect(BigInteger.parse(\"5E24\"))\n"
},
{
"answer_id": 74439626,
"author": "JasonTrue",
"author_id": 13433,
"author_profile": "https://Stackoverflow.com/users/13433",
"pm_score": 1,
"selected": false,
"text": "Number.Delimit.number_to_delimited(\"5e+24\")\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431681",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20383282/"
] |
74,431,697 | <p>Problem statement:</p>
<p>There are multiple instances of charging and discharging for each vehicle, get the minimum charge, maximum charge, min discharge and max discharge for each vehicle for a particular day.</p>
<p>df1</p>
<pre><code>Date Time vehicle_no soc SOC Diff
0 2022-10-01 02:27:56 DL21GD0100 80.0 0
1 2022-10-01 02:28:26 DL21GD0100 80.0 Discharging
2 2022-10-01 02:28:56 DL21GD0100 80.0 Discharging
3 2022-10-01 02:29:26 DL21GD0100 80.0 Discharging
4 2022-10-01 02:29:56 DL21GD0100 69.0 Discharging
5 2022-10-01 02:29:56 DL21GD0100 70.0 Charging
6 2022-10-01 02:29:56 DL21GD0100 71.0 Charging
7 2022-10-01 02:29:56 DL21GD0100 72.0 Charging
8 2022-10-01 03:16:00 DL21GD0100 63.0 Discharging
9 2022-10-01 03:16:30 DL21GD0100 23.0 Discharging
10 2022-10-01 04:17:00 DL21GD0100 54.0 Charging
11 2022-10-01 09:17:30 WB25M9298 24.0 Charging
12 2022-10-01 09:18:00 WB25M9298 25.0 Charging
</code></pre>
| [
{
"answer_id": 74432119,
"author": "zwippie",
"author_id": 409792,
"author_profile": "https://Stackoverflow.com/users/409792",
"pm_score": 3,
"selected": true,
"text": "Float.parse"
},
{
"answer_id": 74432898,
"author": "Adam Millerchip",
"author_id": 1225617,
"author_profile": "https://Stackoverflow.com/users/1225617",
"pm_score": 2,
"selected": false,
"text": "[a, b] = String.split(\"5e+24\", \"e+\")\nString.to_integer(a) * 10 ** String.to_integer(b)\n"
},
{
"answer_id": 74433115,
"author": "bortzmeyer",
"author_id": 15625,
"author_profile": "https://Stackoverflow.com/users/15625",
"pm_score": 1,
"selected": false,
"text": "defmodule BigInteger do\n \n def parse(s) do\n {i, e} = Integer.parse(s)\n e = String.downcase(e)\n if not String.starts_with?(e, \"e\") do\n {:error, \"No \\\"e\\\"\"}\n else\n e = String.slice(e, 1..-1)\n cond do\n String.starts_with?(e, \"+\") ->\n {exp, rest} = Integer.parse(String.slice(e, 1..-1))\n if rest != \"\" do\n IO.inspect(rest)\n {:error, \"Not integer after \\\"e+\\\"\"}\n else\n {:ok, i * Integer.pow(10, exp)}\n end\n True ->\n {exp, rest} = Integer.parse(String.slice(e, 0..-1))\n if rest != \"\" do\n {:error, \"Not integer after \\\"e\\\"\"}\n else\n {:ok, i * Integer.pow(10, exp)}\n end\n end\n end\n end\nend\n\nIO.inspect(BigInteger.parse(\"3e+24\"))\nIO.inspect(BigInteger.parse(\"4e24\"))\nIO.inspect(BigInteger.parse(\"5E24\"))\n"
},
{
"answer_id": 74439626,
"author": "JasonTrue",
"author_id": 13433,
"author_profile": "https://Stackoverflow.com/users/13433",
"pm_score": 1,
"selected": false,
"text": "Number.Delimit.number_to_delimited(\"5e+24\")\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431697",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20500338/"
] |
74,431,767 | <p><a href="https://i.stack.imgur.com/j5kYF.png" rel="nofollow noreferrer">image</a>
This is my JSON repsonse, there is an attribute (key) in the response named as <strong>DATA</strong> which is list of lists and have 1000+ list in it.</p>
<p>I want to limit the size of data(attribute inside json) to 30 lists and 90 lists for two different controllers. I am not able to find out how to do it.</p>
| [
{
"answer_id": 74431969,
"author": "Marc Stroebel",
"author_id": 4445625,
"author_profile": "https://Stackoverflow.com/users/4445625",
"pm_score": 3,
"selected": true,
"text": "@Service"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431767",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14864573/"
] |
74,431,801 | <p>In Stata I need to create a new variable "changes in the board of directors" which indicates whether the same directors are observed in the same firm over time. Consider an example below:</p>
<pre><code>clear
input dirid firmid year
1 10 2006
2 10 2006
3 10 2006
1 10 2007
2 10 2007
3 10 2007
1 10 2008
2 10 2008
3 10 2008
4 10 2008
3 10 2009
4 10 2009
end
</code></pre>
<p>Directors ID 1, 2, and 3 are in firm 10 in 2006 and in 2007. So there was no change in the board of directors from t-1 to t. The variable "changes in the board of directors" should be 0. However, in 2008 a new director came to the board dirid = 4, so there was a change in the board and the variable should be 1. The same in 2009 because dirid 1 and 2 left the company. So any change, whether the entrance or exit of directors, should be reported with 1 in the new binary variable.</p>
| [
{
"answer_id": 74431969,
"author": "Marc Stroebel",
"author_id": 4445625,
"author_profile": "https://Stackoverflow.com/users/4445625",
"pm_score": 3,
"selected": true,
"text": "@Service"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16648201/"
] |
74,431,816 | <p><strong>Some context:<br/></strong>
I'm working on a Chrome Extension where the user can launch it via default "popup.html", or if the user so desires this Extension can be detached from the top right corner and be used on a popup window via <code>window.open</code> <br/></p>
<p>This question will also apply for situations where users create a Shortcut for the extension on Chrome via:<br/>
"..." > "More tools" > "Create Shortcut"</p>
<p><strong>Problem:<br/></strong>
So what I need is for those cases where users use the extension detached via <code>window.open</code> or through a shortcut, when navigating through different options, for the Height of the window to be resized smoothly.</p>
<p>I somewhat achieve this but the animation is clunky and also the final height is not always the same. Sometimes I need to click twice on the button to resize too because 1 click won't be enough. Another issue is there is also some twitching of the bottom text near the edge of the window when navigating.</p>
<p><strong>Here's what I got so far:<br/></strong>
(<code>strWdif</code> and <code>strHdif</code> are used to compensate for some issues with CSS setting proper sizes which I haven't figured out yet.)</p>
<pre><code>const popup = window;
function resizeWindow(popup) {
setTimeout(function () {
var strW = getComputedStyle(window.document.querySelector(".body_zero")).getPropertyValue("width");
var strW2 = strW.slice(0, -2);
var strWdif = 32;
var bodyTargetWidth = (parseFloat(strW2) + parseFloat(strWdif));
var strH = getComputedStyle(window.document.querySelector(".body_zero")).getPropertyValue("height");
var strH2 = strH.slice(0, -2);
var strHdif = 54;
var bodyTargetHeight = (parseFloat(parseInt(strH2)) + parseFloat(strHdif));
var height = window.innerHeight;
console.log("Window Height: ", height, "CSS Height: ", bodyTargetHeight);
var timer = setInterval(function () {
if (height < bodyTargetHeight) {
popup.resizeTo(bodyTargetWidth, height += 5);
if (height >= bodyTargetHeight) {
clearInterval(timer);
}
} else if (height > bodyTargetHeight) {
popup.resizeTo(bodyTargetWidth, height -= 5);
if (height <= bodyTargetHeight) {
clearInterval(timer);
}
} else {
clearInterval(timer);
}
}, 0);
}, 0400);
}
</code></pre>
<p><strong>Question:<br/></strong>
Is there a way to make this more responsive, and smooth and eliminate all the twitching and clunkiness?</p>
<p>I guess the issue might be that I am increasing/diminishing by 5 pixels at a time but that is the speed I need. Maybe there is another way to increase/decrease by 1px at a faster rate? Could this be the cause of the twitching and clunkiness?</p>
<p>Also, I should add that troubleshooting this is difficult because the browser keeps crashing so there is also a performance issue sometimes when trying different things.</p>
<p><strong>EDIT:<br/></strong>
Another option using <code>resizeBy</code>:</p>
<pre><code>function animateClose(time) {
setTimeout(function () {
var strW = getComputedStyle(window.document.querySelector(".body_zero")).getPropertyValue("width");
var strW2 = strW.slice(0, -2);
var strWdif = 32;
var bodyTargetWidth = (parseFloat(strW2) + parseFloat(strWdif));
var strH = getComputedStyle(window.document.querySelector(".body_zero")).getPropertyValue("height");
var strH2 = strH.slice(0, -2);
var strHdif = 54;
var bodyTargetHeight = (parseFloat(parseInt(strH2)) + parseFloat(strHdif));
var w = window.innerWidth; //Get window width
var h = window.innerHeight; //Get window height
var loops = time * 0.1; //Get nb of loops
var widthPercentageMinus = (w / loops) * -0;
var heightPercentageMinus = (h / loops) * -1;
var widthPercentagePlus = (w / loops) * +0;
var heightPercentagePlus = (h / loops) * +1;
console.log("Window Height: ", h, "CSS Height: ", bodyTargetHeight);
var loopInterval = setInterval(function () {
if (h > bodyTargetHeight) {
window.resizeBy(widthPercentageMinus, heightDecrheightPercentageMinuseasePercentageMinus);
} else if (h < bodyTargetHeight) {
window.resizeBy(widthPercentagePlus, heightPercentagePlus);
} else {
clearInterval(loopInterval);
}
}, 1);
}, 0400);
}
</code></pre>
<p>This one is a bit more smooth but I can't make it stop at the desired Height. It also is not differentiating between resizing up or down, also crashes the browser sometimes.</p>
| [
{
"answer_id": 74431969,
"author": "Marc Stroebel",
"author_id": 4445625,
"author_profile": "https://Stackoverflow.com/users/4445625",
"pm_score": 3,
"selected": true,
"text": "@Service"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431816",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16498578/"
] |
74,431,820 | <p>I'm using react with typescript and I have this:</p>
<pre><code>interface SomeProps {
stuff: {
optionalStuff?: object[];
}[];
}
</code></pre>
<p>The only problem with this approach is that if I try to insert any property besides <code>optionalStuff</code> inside the <code>stuff object[]</code>, it will fail because those properties are not listed.</p>
<p>How can I do something like:</p>
<pre><code>interface SomeProps {
stuff: {
ACCEPTS_ANY_GENERIC_STUFF_INSIDE: string | number | object | undefined
optionalStuff?: object[];
}[];
}
</code></pre>
| [
{
"answer_id": 74431897,
"author": "kind user",
"author_id": 6695924,
"author_profile": "https://Stackoverflow.com/users/6695924",
"pm_score": 3,
"selected": true,
"text": "SomeProps"
},
{
"answer_id": 74432081,
"author": "Laci556",
"author_id": 10581265,
"author_profile": "https://Stackoverflow.com/users/10581265",
"pm_score": 1,
"selected": false,
"text": "stuff"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431820",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6156165/"
] |
74,431,848 | <p>I've configured in <code>deployment.toml</code> the hostname of an Active-Active WSO2 API Manager cluster so each node is properly named: <code>node1.cloud.client.com</code>, <code>node2.cloud.client.com</code>.</p>
<p>Besides I've configured the https_endpoint for the API Gateway URL: <code>gateway.cloud.client.com</code>.</p>
<p>When I login to the developer portal console and access the Oauth2 tokens screen I see <code>localhost:9443</code> as the token endpoint URL. How can I customize it to a proper hostname? Should it point to a node <code>nodeX.cloud.client.com</code> or the gateway <code>gateway.cloud.client.com</code>?</p>
<p><a href="https://i.stack.imgur.com/tuVr4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tuVr4.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74431897,
"author": "kind user",
"author_id": 6695924,
"author_profile": "https://Stackoverflow.com/users/6695924",
"pm_score": 3,
"selected": true,
"text": "SomeProps"
},
{
"answer_id": 74432081,
"author": "Laci556",
"author_id": 10581265,
"author_profile": "https://Stackoverflow.com/users/10581265",
"pm_score": 1,
"selected": false,
"text": "stuff"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431848",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1729795/"
] |
74,431,853 | <p>In my code I have function which calls the api. I want to throttle it someehow that the user cannot just keep on clicking the button to call the api.</p>
<p>Here is my function which calls the service</p>
<pre><code> public toggleFavorite(message: Message): void {
const toggleMessageFavourite = new ToggleMessageFavouriteState(message.Id);
this.messageService.toggleMessageFavourite(toggleMessageFavourite).subscribe(() => {
message.Isfavourite = !message.Isfavourite;
});
}
</code></pre>
<p>In my service I have this code</p>
<pre><code>toggleMessageFavourite(model: ToggleMessageFavouriteState) {
const url = `/Api/message/toggleMessageFavourite/`;
return this.httpClient.post(url, model).pipe(
throttleTime(5000)
);
}
}
</code></pre>
<p>I am expecting this function to throttle for 5 seconds before calling the next request.</p>
| [
{
"answer_id": 74431897,
"author": "kind user",
"author_id": 6695924,
"author_profile": "https://Stackoverflow.com/users/6695924",
"pm_score": 3,
"selected": true,
"text": "SomeProps"
},
{
"answer_id": 74432081,
"author": "Laci556",
"author_id": 10581265,
"author_profile": "https://Stackoverflow.com/users/10581265",
"pm_score": 1,
"selected": false,
"text": "stuff"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431853",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2613439/"
] |
74,431,893 | <p>We have a daemon application that makes IMAP connection to access mailbox of user. Earlier we were using plain authentication method of using email ID and password to establish IMAP connection. Now as Microsoft has blocked this type authentication process and introduced oAuth2.0.</p>
<p>My question here I was able to establish IMAP connection with the user that falls inside my tenant. But I am unable to figure out that how it can be done if I need to access the mailbox of user that doesn't fall inside my tenant or need to access the mailbox of any personal outlook account.</p>
| [
{
"answer_id": 74431897,
"author": "kind user",
"author_id": 6695924,
"author_profile": "https://Stackoverflow.com/users/6695924",
"pm_score": 3,
"selected": true,
"text": "SomeProps"
},
{
"answer_id": 74432081,
"author": "Laci556",
"author_id": 10581265,
"author_profile": "https://Stackoverflow.com/users/10581265",
"pm_score": 1,
"selected": false,
"text": "stuff"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431893",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19297691/"
] |
74,431,901 | <p>I would like to join my dataframe with itself in a way that it has the same amount of rows for a particular column. It sounds a bit complicated but I believe it is not when you see it. So here is an example:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th style="text-align: left;">year</th>
<th style="text-align: left;">brand</th>
<th style="text-align: left;">series</th>
<th style="text-align: left;">model</th>
<th style="text-align: center;">version</th>
<th style="text-align: right;">value</th>
<th style="text-align: right;">value 2</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">2022</td>
<td style="text-align: left;">bmw</td>
<td style="text-align: left;">A</td>
<td style="text-align: left;">1X</td>
<td style="text-align: center;">plan</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1</td>
</tr>
<tr>
<td style="text-align: left;">2022</td>
<td style="text-align: left;">bmw</td>
<td style="text-align: left;">B</td>
<td style="text-align: left;">2X</td>
<td style="text-align: center;">plan</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">1</td>
</tr>
<tr>
<td style="text-align: left;">2022</td>
<td style="text-align: left;">bmw</td>
<td style="text-align: left;">A</td>
<td style="text-align: left;">1X</td>
<td style="text-align: center;">sold</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">1</td>
</tr>
<tr>
<td style="text-align: left;">2022</td>
<td style="text-align: left;">bmw</td>
<td style="text-align: left;">C</td>
<td style="text-align: left;">3X</td>
<td style="text-align: center;">sold</td>
<td style="text-align: right;">10</td>
<td style="text-align: right;">1</td>
</tr>
<tr>
<td style="text-align: left;">2021</td>
<td style="text-align: left;">bmw</td>
<td style="text-align: left;">A</td>
<td style="text-align: left;">1X</td>
<td style="text-align: center;">sold</td>
<td style="text-align: right;">50</td>
<td style="text-align: right;">20</td>
</tr>
<tr>
<td style="text-align: left;">2021</td>
<td style="text-align: left;">bmw</td>
<td style="text-align: left;">C</td>
<td style="text-align: left;">3X</td>
<td style="text-align: center;">sold</td>
<td style="text-align: right;">50</td>
<td style="text-align: right;">20</td>
</tr>
<tr>
<td style="text-align: left;">2022</td>
<td style="text-align: left;">bmw</td>
<td style="text-align: left;">A</td>
<td style="text-align: left;">1X</td>
<td style="text-align: center;">prediction</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">1</td>
</tr>
<tr>
<td style="text-align: left;">2022</td>
<td style="text-align: left;">audi</td>
<td style="text-align: left;">D</td>
<td style="text-align: left;">4X</td>
<td style="text-align: center;">prediction</td>
<td style="text-align: right;">7</td>
<td style="text-align: right;">1</td>
</tr>
</tbody>
</table>
</div>
<p>I would like to have the column <code>version</code> the same amount of <code>model</code> always, like this:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th style="text-align: left;">year</th>
<th style="text-align: left;">brand</th>
<th style="text-align: left;">series</th>
<th style="text-align: left;">model</th>
<th style="text-align: center;">version</th>
<th style="text-align: right;">value</th>
<th style="text-align: right;">value 2</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">2022</td>
<td style="text-align: left;">bmw</td>
<td style="text-align: left;">A</td>
<td style="text-align: left;">1X</td>
<td style="text-align: center;">plan</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1</td>
</tr>
<tr>
<td style="text-align: left;">2022</td>
<td style="text-align: left;">bmw</td>
<td style="text-align: left;">B</td>
<td style="text-align: left;">2X</td>
<td style="text-align: center;">plan</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">1</td>
</tr>
<tr>
<td style="text-align: left;">2022</td>
<td style="text-align: left;">bmw</td>
<td style="text-align: left;">C</td>
<td style="text-align: left;">3X</td>
<td style="text-align: center;">plan</td>
<td style="text-align: right;">Nan</td>
<td style="text-align: right;">Nan</td>
</tr>
<tr>
<td style="text-align: left;">2022</td>
<td style="text-align: left;">audi</td>
<td style="text-align: left;">D</td>
<td style="text-align: left;">4X</td>
<td style="text-align: center;">plan</td>
<td style="text-align: right;">Nan</td>
<td style="text-align: right;">Nan</td>
</tr>
<tr>
<td style="text-align: left;">2022</td>
<td style="text-align: left;">bmw</td>
<td style="text-align: left;">A</td>
<td style="text-align: left;">1X</td>
<td style="text-align: center;">sold</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">1</td>
</tr>
<tr>
<td style="text-align: left;">2022</td>
<td style="text-align: left;">bmw</td>
<td style="text-align: left;">C</td>
<td style="text-align: left;">3X</td>
<td style="text-align: center;">sold</td>
<td style="text-align: right;">10</td>
<td style="text-align: right;">1</td>
</tr>
<tr>
<td style="text-align: left;">2022</td>
<td style="text-align: left;">bmw</td>
<td style="text-align: left;">A</td>
<td style="text-align: left;">1X</td>
<td style="text-align: center;">sold</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">1</td>
</tr>
<tr>
<td style="text-align: left;">2021</td>
<td style="text-align: left;">bmw</td>
<td style="text-align: left;">C</td>
<td style="text-align: left;">3X</td>
<td style="text-align: center;">sold</td>
<td style="text-align: right;">50</td>
<td style="text-align: right;">20</td>
</tr>
<tr>
<td style="text-align: left;">2021</td>
<td style="text-align: left;">bmw</td>
<td style="text-align: left;">A</td>
<td style="text-align: left;">1X</td>
<td style="text-align: center;">sold</td>
<td style="text-align: right;">50</td>
<td style="text-align: right;">20</td>
</tr>
<tr>
<td style="text-align: left;">2022</td>
<td style="text-align: left;">audi</td>
<td style="text-align: left;">D</td>
<td style="text-align: left;">4X</td>
<td style="text-align: center;">sold</td>
<td style="text-align: right;">Nan</td>
<td style="text-align: right;">Nan</td>
</tr>
<tr>
<td style="text-align: left;">2022</td>
<td style="text-align: left;">bmw</td>
<td style="text-align: left;">A</td>
<td style="text-align: left;">1X</td>
<td style="text-align: center;">prediction</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">1</td>
</tr>
<tr>
<td style="text-align: left;">2022</td>
<td style="text-align: left;">audi</td>
<td style="text-align: left;">D</td>
<td style="text-align: left;">4X</td>
<td style="text-align: center;">prediction</td>
<td style="text-align: right;">7</td>
<td style="text-align: right;">1</td>
</tr>
<tr>
<td style="text-align: left;">2022</td>
<td style="text-align: left;">bmw</td>
<td style="text-align: left;">B</td>
<td style="text-align: left;">2X</td>
<td style="text-align: center;">prediction</td>
<td style="text-align: right;">Nan</td>
<td style="text-align: right;">Nan</td>
</tr>
<tr>
<td style="text-align: left;">2022</td>
<td style="text-align: left;">bmw</td>
<td style="text-align: left;">C</td>
<td style="text-align: left;">3X</td>
<td style="text-align: center;">prediction</td>
<td style="text-align: right;">Nan</td>
<td style="text-align: right;">Nan</td>
</tr>
</tbody>
</table>
</div>
<p>As you can see, columns <code>year</code> to <code>version</code> are unique (I have more grouped unique columns). The rest are values(i.e. numeric data).</p>
| [
{
"answer_id": 74432087,
"author": "mozway",
"author_id": 16343464,
"author_profile": "https://Stackoverflow.com/users/16343464",
"pm_score": 1,
"selected": false,
"text": "pivot"
},
{
"answer_id": 74432161,
"author": "sammywemmy",
"author_id": 7175713,
"author_profile": "https://Stackoverflow.com/users/7175713",
"pm_score": 2,
"selected": false,
"text": "# pip install pyjanitor\nimport pandas as pd\nimport janitor\n\ndf.complete('version', 'model') \n model version value\n0 1X plan 3.0\n1 2X plan 8.0\n2 3X plan NaN\n3 4X plan NaN\n4 1X sold 1.0\n5 2X sold NaN\n6 3X sold 10.0\n7 4X sold NaN\n8 1X prediction 2.0\n9 2X prediction NaN\n10 3X prediction NaN\n11 4X prediction 7.0\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431901",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9761749/"
] |
74,431,911 | <p>I am using <code>SimpleDateFormat</code> like this:</p>
<pre><code>SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd-HH:mm:ss.SSS");
Date result = sdf.parse("20221114-12:34:56.789");
</code></pre>
<p>Works fine for the above example (result: <code>Mon Nov 14 12:34:56 CET 2022</code>), but works strange for obvious erroneous input:</p>
<ul>
<li><code>123-20221114-12:34:56.789</code> -> <code>Sun Feb 15 12:34:56 CET 728</code></li>
<li><code>12320221114-12:34:56.789</code> -> <code>Mon Nov 21 12:34:56 CET 1289</code></li>
</ul>
<p>I would expect to throw <code>ParseException</code> in these cases.</p>
<p>Note that the timestamp is input and the format cannot be changed.</p>
<p>As a cross-check I tried this: <code>abc-20221114-12:34:56.789</code>, and at least in this case it threw <code>ParseException</code>.</p>
| [
{
"answer_id": 74437229,
"author": "Basil Bourque",
"author_id": 642706,
"author_profile": "https://Stackoverflow.com/users/642706",
"pm_score": 1,
"selected": false,
"text": "SimpleDateFormat"
},
{
"answer_id": 74486705,
"author": "Csaba Faragó",
"author_id": 19280082,
"author_profile": "https://Stackoverflow.com/users/19280082",
"pm_score": 1,
"selected": true,
"text": "SimpleDateFormat"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431911",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19280082/"
] |
74,431,920 | <p>``
Hello everyone, I am working on a deep learning project. The data I will use for the project consists of multiple excel files. Since I will be using the pd.read_csv command of the Pandas library, I used a VBA code that automatically converts all excel files to csv format.</p>
<p>Here is the VBA CODE: (xlsx to csv)</p>
<pre><code>Sub WorkbooksSaveAsCsvToFolder()
'UpdatebyExtendoffice20181031
Dim xObjWB As Workbook
Dim xObjWS As Worksheet
Dim xStrEFPath As String
Dim xStrEFFile As String
Dim xObjFD As FileDialog
Dim xObjSFD As FileDialog
Dim xStrSPath As String
Dim xStrCSVFName As String
Dim xS As String
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
Application.DisplayAlerts = False
On Error Resume Next
Set xObjFD = Application.FileDialog(msoFileDialogFolderPicker)
xObjFD.AllowMultiSelect = False
xObjFD.Title = "Kutools for Excel - Select a folder which contains Excel files"
If xObjFD.Show <> -1 Then Exit Sub
xStrEFPath = xObjFD.SelectedItems(1) & "\"
Set xObjSFD = Application.FileDialog(msoFileDialogFolderPicker)
xObjSFD.AllowMultiSelect = False
xObjSFD.Title = "Kutools for Excel - Select a folder to locate CSV files"
If xObjSFD.Show <> -1 Then Exit Sub
xStrSPath = xObjSFD.SelectedItems(1) & "\"
xStrEFFile = Dir(xStrEFPath & "*.xlsx*")
Do While xStrEFFile <> ""
xS = xStrEFPath & xStrEFFile
Set xObjWB = Application.Workbooks.Open(xS)
xStrCSVFName = xStrSPath & Left(xStrEFFile, InStr(1, xStrEFFile, ".") - 1) & ".csv"
xObjWB.SaveAs Filename:=xStrCSVFName, FileFormat:=xlCSV
xObjWB.Close savechanges:=False
xStrEFFile = Dir
Loop
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
</code></pre>
<p>With this code, thousands of .xlsx files become .csv. The problem here is that although the conversion happens correctly, when I use the pd.read_csv command, it only reads 1 column.</p>
<p>As it seems:</p>
<pre><code> 0
0 PlatformData,2,0.020000,43.000000,33.000000,32...
1 PlatformData,1,0.020000,42.730087,33.000000,25...
2 PlatformData,2,0.040000,43.000000,33.000000,32...
3 PlatformData,1,0.040000,42.730141,33.000006,25...
4 PlatformData,2,0.060000,43.000000,33.000000,32...
... ...
9520 PlatformData,1,119.520000,42.931132,33.056849,...
9521 PlatformData,1,119.540000,42.931184,33.056868,...
9522 PlatformData,1,119.560000,42.931184,33.056868,...
9523 PlatformData,1,119.580000,42.931237,33.056887,...
9524 PlatformData,1,119.600000,42.931237,33.056887,...
</code></pre>
<p>Because the column part is not correct, it combines the data and prevents me from training the model.</p>
<p>Afterwards, in order to understand what the problem was, I saw that the problem disappeared when I converted only 1 excel file to .csv format manually using the "Save as" command and read it using the pandas library.</p>
<p>Which looks like this:</p>
<pre><code>0 1 2 3 4 5 6 7 8 9 10 11
0 PlatformData 2 0.02 43.000000 33.000000 3200.0 0.000000 0.0 0.0 0.000000 0.000000 -0.0
1 PlatformData 1 0.02 42.730087 33.000000 3050.0 60.000029 0.0 0.0 74.999931 129.903854 -0.0
2 PlatformData 2 0.04 43.000000 33.000000 3200.0 0.000000 -0.0 0.0 0.000000 0.000000 -0.0
3 PlatformData 1 0.04 42.730114 33.000064 3050.0 60.000029 0.0 0.0 74.999931 129.903854 -0.0
4 PlatformData 2 0.06 43.000000 33.000000 3200.0 0.000000 -0.0 0.0 0.000000 0.000000 -0.0
... ... ... ... ... ... ... ... ... ... ... ... ...
57867 PlatformData 1 119.72 42.891333 33.019166 2550.0 5.000000 0.0 0.0 149.429214 13.073360 -0.0
57868 PlatformData 1 119.74 42.891333 33.019166 2550.0 5.000000 0.0 0.0 149.429214 13.073360 -0.0
57869 PlatformData 1 119.76 42.891387 33.019172 2550.0 5.000000 0.0 0.0 149.429214 13.073360 -0.0
57870 PlatformData 1 119.78 42.891387 33.019172 2550.0 5.000000 0.0 0.0 149.429214 13.073360 -0.0
57871 PlatformData 1 119.80 42.891441 33.019178 2550.0 5.000000 0.0 0.0 149.429214 13.073360 -0.0
</code></pre>
<p>As seen here, each comma is separated as a separate column.</p>
<p>I need to convert multiple files using VBA or some other convert technique because I have so many excel files. But as you can see, even though the format of the files is translated correctly, it is read incorrectly by pandas.</p>
<p>I've tried converting with a bunch of different VBA codes so far. Then I tried to read it with the read_excel command on python and then convert it with to_csv, but I encountered the same problem again. (Reading only 1 column)</p>
<p>What do I need to do to make it look like it was when I changed the format manually?
Is there an error in the VBA code or do I need to implement another method for this operation?</p>
<p>Thank you for your interest. Thanks in advance for any help</p>
| [
{
"answer_id": 74437229,
"author": "Basil Bourque",
"author_id": 642706,
"author_profile": "https://Stackoverflow.com/users/642706",
"pm_score": 1,
"selected": false,
"text": "SimpleDateFormat"
},
{
"answer_id": 74486705,
"author": "Csaba Faragó",
"author_id": 19280082,
"author_profile": "https://Stackoverflow.com/users/19280082",
"pm_score": 1,
"selected": true,
"text": "SimpleDateFormat"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431920",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16713556/"
] |
74,431,996 | <p>I have a dictionary in <code>python 3</code> with objects in the values, in the form of:</p>
<pre><code>a={'modem0': <interfaces.modems.hw_trx_qmi.QmiModem object at 0x7fdcfe9ced70>,
...
...
}
</code></pre>
<p>if I search for the key <code>modem0</code> it is not being found, why might this be?</p>
<pre><code>if 'modem0' in a:
print("found")
else:
print("not found")
</code></pre>
| [
{
"answer_id": 74437229,
"author": "Basil Bourque",
"author_id": 642706,
"author_profile": "https://Stackoverflow.com/users/642706",
"pm_score": 1,
"selected": false,
"text": "SimpleDateFormat"
},
{
"answer_id": 74486705,
"author": "Csaba Faragó",
"author_id": 19280082,
"author_profile": "https://Stackoverflow.com/users/19280082",
"pm_score": 1,
"selected": true,
"text": "SimpleDateFormat"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74431996",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1803007/"
] |
74,432,022 | <p>If I have a timeseries dataframe in r from 2011 to 2018. How can I do a for loop where I count the number of NA per year separately and if that specific year has more than x % I drop that year or do something.</p>
<p>please refer to the image to see how my Dataframe looks like.</p>
<p><a href="https://i.stack.imgur.com/2fwDk.png" rel="nofollow noreferrer">https://i.stack.imgur.com/2fwDk.png</a></p>
<pre><code>years_values <- 2011:2020
years = pretty(years_values,n=10)
count = 0
for (y in years){
for (j in df$Flow == y) {
if (is.na(df$Flow[j]){
count = count+1
}
}
if (count) > 1{
bfi = BFI(df$Flow == y)}
else {bfi = NA}
}
</code></pre>
<p>I am trying to use this code to loop for each year and then count the NA. and if the NA is greater than 1% I want to no compute for BFI and if it is less the compute for the BFI. I do have the BFI function working well. The problem I have is to formulate this loop.</p>
| [
{
"answer_id": 74437229,
"author": "Basil Bourque",
"author_id": 642706,
"author_profile": "https://Stackoverflow.com/users/642706",
"pm_score": 1,
"selected": false,
"text": "SimpleDateFormat"
},
{
"answer_id": 74486705,
"author": "Csaba Faragó",
"author_id": 19280082,
"author_profile": "https://Stackoverflow.com/users/19280082",
"pm_score": 1,
"selected": true,
"text": "SimpleDateFormat"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74432022",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19303567/"
] |
74,432,027 | <p>In the below code sample I would expect both <code>a</code> and <code>b</code> to be deleted at the end of each loop.</p>
<p>What happens is that <code>a</code> is deleted but not <code>b</code>. Why is that? And how can I make sure that b is also deleted at the end of each loop?</p>
<pre><code>class bag:
a = 5
b = []
def funcie(self):
self.a = self.a + 1
self.b.append(1)
for i in range(5):
inst = bag()
inst.funcie()
print(inst.a)
print(inst.b)
# del inst
</code></pre>
<p>output:</p>
<pre><code>6
[1]
6
[1, 1]
6
[1, 1, 1]
6
[1, 1, 1, 1]
6
[1, 1, 1, 1, 1]
</code></pre>
<p>EDIT: So <a href="https://stackoverflow.com/questions/1537202/difference-between-variables-inside-and-outside-of-init-class-and-instanc?rq=1">this post</a> explains why the <code>b</code> list keeps growing in each loop i.e. I should have declared the <code>b</code> list in the <code>__init(self)__</code> function.
However it doesn't explain why the <code>a</code> variable gets overwritten at the end of each loop whilst the <code>b</code> variable doesn't.</p>
| [
{
"answer_id": 74432323,
"author": "ShadowRanger",
"author_id": 364696,
"author_profile": "https://Stackoverflow.com/users/364696",
"pm_score": 1,
"selected": false,
"text": "bag.a"
},
{
"answer_id": 74432795,
"author": "dkruit",
"author_id": 13769079,
"author_profile": "https://Stackoverflow.com/users/13769079",
"pm_score": 0,
"selected": false,
"text": "list"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74432027",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5542916/"
] |
74,432,035 | <p>bit new to dax and I am struggling in creating a formula.</p>
<p>So I need to write a mathematical calculation which =+(E4+Mx6)/2*33 for the East Silo on the same date and time only.</p>
<p><a href="https://i.stack.imgur.com/uBRCm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uBRCm.png" alt="enter image description here" /></a></p>
<p>So the first one would be 07/11/2022 4:30 am calculation (4+4)/2*33</p>
<p>I tried doing the calculation but i couldn't figure out how to calculate based on the same date field</p>
| [
{
"answer_id": 74432271,
"author": "Peter",
"author_id": 7108589,
"author_profile": "https://Stackoverflow.com/users/7108589",
"pm_score": 2,
"selected": false,
"text": "#\"Pivoted Column\" = Table.Pivot(\n #\"Changed Type\", List.Distinct(#\"Changed Type\"[Parameter]), \"Parameter\", \"Value\", List.Sum),\n#\"Added Custom\" = Table.AddColumn(\n #\"Pivoted Column\", \"Custom\", each ([E4]+[Mx6]) / 2 * 33)\n"
},
{
"answer_id": 74432635,
"author": "Peter",
"author_id": 7108589,
"author_profile": "https://Stackoverflow.com/users/7108589",
"pm_score": 0,
"selected": false,
"text": "Math = \nVAR tbl = \n SUMMARIZE(\n 'Table',\n 'Table'[Datetime],\n 'Table'[Silo],\n \"E4\", CALCULATE(\n SUM('Table'[Value]),\n 'Table'[Parameter] = \"E4\"\n ), \n \"Mx6\", CALCULATE( \n SUM('Table'[Value]),\n 'Table'[Parameter] = \"Mx6\"\n )\n )\nRETURN\n SUMX(\n tbl,\n ([E4] + [Mx6]) / 2 * 33\n )\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74432035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20500810/"
] |
74,432,049 | <p>I have some integer-based survey data. N = 10,000, X = 6. I would like to encode each of the 10,000 observations as a string of 6 variables</p>
<p>Could someone please show me how to encode this in R, such that rows with duplicate strings take on the same assignment?</p>
<pre><code>set.seed(1)
dat <- data.frame(
matrix(
sample(1:3,5*12, replace=TRUE),12,5,
dimnames=list(1:12,c("X1","X2","X3","X4","X5"))
),
Sex=rep(c("Male", "Female")))
</code></pre>
| [
{
"answer_id": 74432200,
"author": "zx8754",
"author_id": 680068,
"author_profile": "https://Stackoverflow.com/users/680068",
"pm_score": 2,
"selected": false,
"text": "dat$id <- as.integer(factor(apply(dat, 1, paste, collapse = \"_\")))\n"
},
{
"answer_id": 74432225,
"author": "zephryl",
"author_id": 17303805,
"author_profile": "https://Stackoverflow.com/users/17303805",
"pm_score": 2,
"selected": false,
"text": "tidyr::unite()"
},
{
"answer_id": 74432431,
"author": "ThomasIsCoding",
"author_id": 12158757,
"author_profile": "https://Stackoverflow.com/users/12158757",
"pm_score": 2,
"selected": false,
"text": "paste"
},
{
"answer_id": 74435419,
"author": "akrun",
"author_id": 3732271,
"author_profile": "https://Stackoverflow.com/users/3732271",
"pm_score": 1,
"selected": false,
"text": "exec"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74432049",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15917305/"
] |
74,432,070 | <p>I am trying to check the internet connection of the mobile device. I am using below code to check the connectivity.</p>
<pre><code>import 'package:flutter/material.dart';
import 'package:internet_connection_checker/internet_connection_checker.dart';
class RedirectPage extends StatelessWidget {
final int? status;
@override
Widget build(BuildContext context) {
bool? isDeviceConnected;
() async {
print("a");
print(123);
isDeviceConnected = await checkConnection();
print(888);
};
if (isDeviceConnected != null && isDeviceConnected == false) {
return AppNetworkConnectivityHome();
} else{
return HomePage();
}
}
}
print(isDeviceConnected); //giving null for the first time and true or false on the second time.
Future<bool?> checkConnection() async {
bool a = false;
a = await InternetConnectionChecker().hasConnection;
print(a);
return a;
}
</code></pre>
<p>how to force wait for the await function to complete</p>
| [
{
"answer_id": 74432099,
"author": "eamirho3ein",
"author_id": 10306997,
"author_profile": "https://Stackoverflow.com/users/10306997",
"pm_score": 2,
"selected": true,
"text": "async"
},
{
"answer_id": 74432134,
"author": "Robert Sandberg",
"author_id": 13263384,
"author_profile": "https://Stackoverflow.com/users/13263384",
"pm_score": 2,
"selected": false,
"text": "Future<bool?> myMethod() async {\n return await InternetConnectionChecker().hasConnection;\n}\n\n...\nprint(await myMethod());\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74432070",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1889044/"
] |
74,432,097 | <p>We have an array of objects with the attributes "description" and "id".</p>
<pre><code>foo[0].id // "45g-332"
foo[0].id2 // "45G-000332"
foo[0].description // "tomatoes"
foo[1].id // "45f-842"
foo[1].id2 // "45F-000842"
foo[1].description // "cherries"
foo[2].id // "45g-332"
foo[2].id2 // "45G-000332"
foo[2].description // "peaches"
</code></pre>
<p>I need a variable or object in which all descriptions for the same id are combined to have a result like this:</p>
<pre><code>bar[0].id // "45g-332"
bar[0].id2 // "45G-000332"
bar[0].description // "tomatoes; peaches"
bar[1].id // "45f-842"
bar[1].id2 // "45F-000842"
bar[1].description // "cherries"
</code></pre>
<p>… or with associative labels</p>
<pre><code>bar["45g-332"].description // "tomatoes; peaches"
bar["45f-842"].description // "cherries"
bar["45g-332"].id2 // "45G-000332"
</code></pre>
<p>The only passably slim solution I came up with is (→ <a href="https://jsfiddle.net/jv5u9b1n/" rel="nofollow noreferrer">jsFiddle</a>):</p>
<pre><code>let foo = [];
foo[0] = [];
foo[1] = [];
foo[2] = [];
foo[0].id = "45g-332";
foo[0].id2 = "45G-000332";
foo[0].description = "tomatoes";
foo[1].id = "45f-842";
foo[1].id2 = "45F-000842";
foo[1].description = "cherries";
foo[2].id = "45g-332";
foo[2].id2 = "45G-000332";
foo[2].description = "peaches";
let bar = [];
for (let i in foo) { // Loop through source (foo)
if (bar[foo[i].id]) { // Check if sink (bar) with id already exists
bar[foo[i].id].description += "; " + foo[i].description; // Add description to existing bar element
} else {
bar[foo[i].id] = []; // Create new bar element
bar[foo[i].id].description = foo[i].description;
};
bar[foo[i].id].id2 = foo[i].id2; // Added by edit
};
for (let i in bar) {
console.log("id: " + i + " has: " + bar[i].description + " and id2: " + bar[i].id2);
};
// Result is
// "id: 45g-332 has: tomatoes; peaches and id2: 45G-000332"
// "id: 45f-842 has: cherries and id2: 45F-000842"
</code></pre>
<p>I'm pretty sure that there's a more plain way to do this. What's gold standard?</p>
| [
{
"answer_id": 74432708,
"author": "sojin",
"author_id": 8736569,
"author_profile": "https://Stackoverflow.com/users/8736569",
"pm_score": 1,
"selected": false,
"text": " const foo = [\n {id: \"45g-332\", description: \"tomatoes\"},\n {id: \"45f-842\", description: \"cherries\"},\n {id: \"45g-332\", description: \"peaches\"}\n ]\n const bar = {}\n foo.forEach(d => {\n bar[d.id] = bar[d.id] ? bar[d.id] + \"; \" + d. description : d.description\n });\n\n console.log(bar)"
},
{
"answer_id": 74432808,
"author": "kennarddh",
"author_id": 14813577,
"author_profile": "https://Stackoverflow.com/users/14813577",
"pm_score": 3,
"selected": true,
"text": "const foo = [{\n id: '45g-332',\n id2: '45G-000332',\n description: 'tomatoes'\n },\n {\n id: '45f-842',\n id2: '45F-000842',\n description: 'cherries'\n },\n {\n id: '45g-332',\n id2: '45G-000332',\n description: 'peaches'\n },\n {\n id: '45g-332',\n id2: '45G-000332',\n description: 'x'\n }\n]\n\nconst bar = foo.reduce((acc, {\n id,\n id2,\n description\n}) => {\n if (acc[id]) {\n acc[id].id2.push(id2)\n acc[id].description.push(description)\n } else {\n acc[id] = {\n id2: [id2],\n description: [description]\n }\n }\n\n return acc\n}, {})\n\nconsole.log(bar)"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74432097",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2768597/"
] |
74,432,102 | <p>I have a REST API on Enterprise Integrator that uses a db lookup mediator to search a microsoft sql server database and redirects based on the whether or not the data exists in the db. I need to make the redirect part of the code configurable/dynamic as it wouldn't make sense to constantly update the url and redeploy every time the url changes.</p>
<pre><code><api xmlns="http://ws.apache.org/ns/synapse" name="DBLookupAPI" context="/dblookup">
<resource methods="GET" uri-template="/{UserCode}">
<inSequence>
<log level="custom">
<property name="Value" expression="get-property('uri.var.UserCode')"/>
</log>
<dblookup>
<connection>
<pool>
<driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver>
<url>jdbc:sqlserver://10.1.1.111\test;databaseName=UserDB</url>
<user>admin</user>
<password>admin</password>
</pool>
</connection>
<statement>
<sql>select UserCode from UserDB.dbo.Users where UserCode =?;</sql>
<parameter expression="get-property('uri.var.UserCode ')" type="CHAR"/>
<result name="foundnr" column="UserCode "/>
</statement>
</dblookup>
<log level="custom">
<property name="Value" expression="get-property('foundnr')"/>
</log>
<filter source="boolean(get-property('foundnr'))" regex="true">
<then>
<log>
<property name="Message" value="Name Exists Lets redirect"/>
</log>
<property name="HTTP_SC" value="302"/>
<property name="Location" value="https://wso2.com/" scope="transport"/>
</then>
<else>
<log>
<property name="Message" value="Name Does Not Exist Lets redirect"/>
</log>
<property name="HTTP_SC" value="302"/>
<property name="Location" value="https://www.youtube.com/" scope="transport"/>
</else>
</filter>
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
</api>
</code></pre>
| [
{
"answer_id": 74432708,
"author": "sojin",
"author_id": 8736569,
"author_profile": "https://Stackoverflow.com/users/8736569",
"pm_score": 1,
"selected": false,
"text": " const foo = [\n {id: \"45g-332\", description: \"tomatoes\"},\n {id: \"45f-842\", description: \"cherries\"},\n {id: \"45g-332\", description: \"peaches\"}\n ]\n const bar = {}\n foo.forEach(d => {\n bar[d.id] = bar[d.id] ? bar[d.id] + \"; \" + d. description : d.description\n });\n\n console.log(bar)"
},
{
"answer_id": 74432808,
"author": "kennarddh",
"author_id": 14813577,
"author_profile": "https://Stackoverflow.com/users/14813577",
"pm_score": 3,
"selected": true,
"text": "const foo = [{\n id: '45g-332',\n id2: '45G-000332',\n description: 'tomatoes'\n },\n {\n id: '45f-842',\n id2: '45F-000842',\n description: 'cherries'\n },\n {\n id: '45g-332',\n id2: '45G-000332',\n description: 'peaches'\n },\n {\n id: '45g-332',\n id2: '45G-000332',\n description: 'x'\n }\n]\n\nconst bar = foo.reduce((acc, {\n id,\n id2,\n description\n}) => {\n if (acc[id]) {\n acc[id].id2.push(id2)\n acc[id].description.push(description)\n } else {\n acc[id] = {\n id2: [id2],\n description: [description]\n }\n }\n\n return acc\n}, {})\n\nconsole.log(bar)"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74432102",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20220789/"
] |
74,432,108 | <p>I am working a on projects using Django. Here is my <code>models.py</code> :</p>
<pre><code>class Owner(models.Model):
name = models.CharField(max_length=200)
class Cat(models.Model):
owner = models.ForeignKey(Owner, on_delete=models.CASCADE)
pseudo = models.CharField(max_length=200)
</code></pre>
<p>I did that :</p>
<p><code>first_owner = Owner.objects.get(id=1)</code></p>
<p>And I would like to do something like that</p>
<p><code>first_owner.Cat</code></p>
<p>to get all the cats from an owner</p>
<p>I know I can do something like that :</p>
<p><code>first_cat = Owner.objects.get(id=1)</code></p>
<p><code>owner = first_cat.owner</code></p>
<p>But I would like the reverse operation without using ManyToMany field because every cats has an only owner in my case.</p>
<p>My aim is to do that using only one query.</p>
| [
{
"answer_id": 74432708,
"author": "sojin",
"author_id": 8736569,
"author_profile": "https://Stackoverflow.com/users/8736569",
"pm_score": 1,
"selected": false,
"text": " const foo = [\n {id: \"45g-332\", description: \"tomatoes\"},\n {id: \"45f-842\", description: \"cherries\"},\n {id: \"45g-332\", description: \"peaches\"}\n ]\n const bar = {}\n foo.forEach(d => {\n bar[d.id] = bar[d.id] ? bar[d.id] + \"; \" + d. description : d.description\n });\n\n console.log(bar)"
},
{
"answer_id": 74432808,
"author": "kennarddh",
"author_id": 14813577,
"author_profile": "https://Stackoverflow.com/users/14813577",
"pm_score": 3,
"selected": true,
"text": "const foo = [{\n id: '45g-332',\n id2: '45G-000332',\n description: 'tomatoes'\n },\n {\n id: '45f-842',\n id2: '45F-000842',\n description: 'cherries'\n },\n {\n id: '45g-332',\n id2: '45G-000332',\n description: 'peaches'\n },\n {\n id: '45g-332',\n id2: '45G-000332',\n description: 'x'\n }\n]\n\nconst bar = foo.reduce((acc, {\n id,\n id2,\n description\n}) => {\n if (acc[id]) {\n acc[id].id2.push(id2)\n acc[id].description.push(description)\n } else {\n acc[id] = {\n id2: [id2],\n description: [description]\n }\n }\n\n return acc\n}, {})\n\nconsole.log(bar)"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74432108",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20387485/"
] |
74,432,111 | <p>I have a html form which contains a button. This button has a .click() event attached within a js file. This was working fine, until I used jquery .html() to substitute my main page content with the form content. The form shows on the page but clicking the button no longer triggers the event. I am wondering why this is? Code below...</p>
<p>html:</p>
<pre><code><body>
<div id="mainContent">
<!-- Visible page content will show here -->
</div>
<div id="otherScreens">
<form id="loginForm">
<label for="email">Email</label>
<input type="text" id="email" spellcheck="false">
<label for="password">Password</label>
<input type="password" id="password">
<button type="submit" id="signInBtn">Sign In</button>
<ul id="signInMessages"></ul>
</form>
</div>
</code></pre>
<p>css:</p>
<pre><code>#otherScreens {
display: none;
}
</code></pre>
<p>js:</p>
<pre><code>const mainContentArea = $(document).find('#mainContent');
let onPageContent = $(document).find('#loginForm').html();
$(document).ready(function () {
mainContentArea.html(onPageContent);
});
$('#signInBtn').click(function (event) {
event.preventDefault();
console.log("Hello world!");
}
</code></pre>
<p>I tested changing the .click() event to target #mainContent and it triggered upon clicking anywhere within the div on the webpage, as expected. So I'm not quite sure what's happening with the form button?</p>
<p>(does not seem to relate to suggested duplicate Q)</p>
| [
{
"answer_id": 74432209,
"author": "Kairav Thakar",
"author_id": 20447312,
"author_profile": "https://Stackoverflow.com/users/20447312",
"pm_score": 2,
"selected": true,
"text": "const mainContentArea = $(document).find('#mainContent');\nlet onPageContent = $(document).find('#loginForm').html();\n\n$(document).ready(function () {\n\n mainContentArea.html(onPageContent);\n \n $('#signInBtn').click(function (event) {\n event.preventDefault();\n console.log(\"Hello world!\");\n});\n});\n"
},
{
"answer_id": 74432294,
"author": "riffnl",
"author_id": 313663,
"author_profile": "https://Stackoverflow.com/users/313663",
"pm_score": 0,
"selected": false,
"text": "function replaceElement(htmlContent) {\n $('.mybutton').off('click'); // drop the event handler\n $('#mainContent').html(htmlContent); // replace content\n // add event handler\n $('.mybutton').click(function() { \n console.log('yup, working again');\n });\n}\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74432111",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8119860/"
] |
74,432,112 | <p>I got some data like this</p>
<pre><code>https://www.travel.taipei/d_upload_ttn/sceneadmin/pic/11000358.jpghttps://www.travel.taipei/d_upload_ttn/sceneadmin/image/a0/b0/c0/d756/e285/f317/2ece2309-3d1c-49da-8d3a-32e0227e7732.jpghttps://www.travel.taipei/d_upload_ttn/sceneadmin/image/a0/b0/c1/d379/e118/f25/554586cb-cf2d-40ef-9b6a-55fcf8d9e598.jpghttps://www.travel.taipei/d_upload_ttn/sceneadmin/image/a0/b0/c1/d856/e130/f366/21ed2d17-7610-4ad2-b517-5b1b0007612a.jpghttps://www.travel.taipei/d_upload_ttn/sceneadmin/pic/11000360.jpghttps://www.travel.taipei/d_upload_ttn/sceneadmin/image/a0/b0/c1/d356/e17/f185/b1a2de52-4110-4355-a9fb-bf1d0eb627c9.jpghttps://www.travel.taipei/d_upload_ttn/sceneadmin/image/a0/b0/c0/d593/e103/f285/1633c311-e148-4d03-bb43-292d816951d2.jpghttps://www.travel.taipei/d_upload_ttn/sceneadmin/pic/11000359.jpghttps://www.travel.taipei/streams/scenery_file_audio/c03.mp3
</code></pre>
<p>The thing I want to do is to put URL that contains <code>"jpg"</code> or <code>"png"</code> into a list by using Python.<br/>
like<code>["https.....jpg", "https......jpg", "https........png"]</code><br/>
But I have no ideas. Any suggestions?</p>
| [
{
"answer_id": 74432209,
"author": "Kairav Thakar",
"author_id": 20447312,
"author_profile": "https://Stackoverflow.com/users/20447312",
"pm_score": 2,
"selected": true,
"text": "const mainContentArea = $(document).find('#mainContent');\nlet onPageContent = $(document).find('#loginForm').html();\n\n$(document).ready(function () {\n\n mainContentArea.html(onPageContent);\n \n $('#signInBtn').click(function (event) {\n event.preventDefault();\n console.log(\"Hello world!\");\n});\n});\n"
},
{
"answer_id": 74432294,
"author": "riffnl",
"author_id": 313663,
"author_profile": "https://Stackoverflow.com/users/313663",
"pm_score": 0,
"selected": false,
"text": "function replaceElement(htmlContent) {\n $('.mybutton').off('click'); // drop the event handler\n $('#mainContent').html(htmlContent); // replace content\n // add event handler\n $('.mybutton').click(function() { \n console.log('yup, working again');\n });\n}\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74432112",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19870073/"
] |
74,432,137 | <p><a href="https://i.stack.imgur.com/Zst9c.png" rel="nofollow noreferrer">enter image description here</a></p>
<p>I'm solving the decryption problem in C language</p>
<p>There's a problem.</p>
<p>There's a process of counting the vowels in the string,</p>
<p>code not reading the number of vowels properly in that 'countingmeasure'</p>
<p>I was so curious that I debugged it,</p>
<p>count ++ doesn't work at'o'.</p>
<p>I'm really curious why this is happening</p>
<pre><code>#include <stdio.h>
int main(void)
{
char original[15] = { 't','f','l','e','k','v','i','d','v','r','j','l','i','v',NULL };
printf("암호화된 문자열 : %s\n", original);
printf("원본 가능 문자열 \n");
printf("\n");
for (int j = 0; j < 26; j++)//모음이 7개일때만 출력을 어떻게 시킬까?
{
char change[14] = { 0 };
int counter=0;
char a;
for (int i = 0; i < 14; i++)
{
a = original[i] + j;
if (a > 122)
{
original[i] -= 26 ;
}
if (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
{
counter++;
}
printf("%c", original[i] + j);
}
printf(" %d\n",counter);
}
}
</code></pre>
| [
{
"answer_id": 74432669,
"author": "Lundin",
"author_id": 584518,
"author_profile": "https://Stackoverflow.com/users/584518",
"pm_score": 1,
"selected": false,
"text": "a = original[i] + j;"
},
{
"answer_id": 74432780,
"author": "0___________",
"author_id": 6110094,
"author_profile": "https://Stackoverflow.com/users/6110094",
"pm_score": 0,
"selected": false,
"text": "char *mystrchr(const char *str, const char lt, int ignoreCase)\n{\n while(*str) \n {\n if(ignoreCase) \n if(tolower((unsigned char)*str) == tolower((unsigned char)lt)) return (char *)str;\n else \n if(*str == lt) return (char *)str;\n str++;\n }\n return NULL;\n}\n\nsize_t count(const char *haystack, const char *needle, int ignoreCase)\n{\n size_t count = 0;\n while(*haystack)\n {\n if(mystrchr(needle, *haystack, ignoreCase)) count++;\n haystack++;\n }\n return count;\n}\n\nint main(void)\n{\n char *str = \"tflekvidvrjliv\";\n\n printf(\"%zu\\n\", count(str, \"aeiou\", 1));\n}\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74432137",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20147423/"
] |
74,432,138 | <p>I would like to change both the background color (from transparent to #07b8b5) and the color of the arrow (from #07b8b5 to WHITE) when hover the ss-go-top the button.</p>
<p>I can only change the background color of the button but not the inside arrow's color..</p>
<p>I am a beginner, please if something is missing to understand the question let me know and I'll clarify. Thank you)) –</p>
<p>Here the HTML and CSS code:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>ss-go-top {
z-index: 2;
opacity: 0;
border: 2px;
border-style: solid;
border-radius: 50%;
border-color: #07b8b5;
visibility: hidden;
-webkit-transform: translate3d(0, 200%, 0);
transform: translate3d(0, 200%, 0);
-webkit-transition: all 0.5s cubic-bezier(0.215, 0.61, 0.355, 1);
transition: all 0.5s cubic-bezier(0.215, 0.61, 0.355, 1);
position: fixed;
bottom: 8.4rem;
right: 4rem;
}
.ss-go-top a {
text-decoration: none;
border: 2px;
display: block;
height: 6.4rem;
width: 6.4rem;
border-radius: 50%;
background-color: transparent;
-webkit-transition: all .3s;
transition: all .3s;
position: relative;
}
.ss-go-top a:hover,
.ss-go-top a:focus {
background-color: #07b8b5;
}
.ss-go-top svg {
height: 1.2rem;
width: 1.2rem;
position: absolute;
-webkit-transform: translate3d(-50%, -50%, 0);
transform: translate3d(-50%, -50%, 0);
left: 50%;
top: 50%;
}
.ss-go-top svg path {
fill: #07b8b5;
}
.ss-go-top.link-is-visible {
opacity: 1;
visibility: visible;
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="ss-go-top">
<a class="smoothscroll" title="Back to Top" href="#top">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M12 0l8 9h-6v15h-4v-15h-6z"/></svg>
</a>
</div></code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74432397,
"author": "Jaswinder Kaur",
"author_id": 15258737,
"author_profile": "https://Stackoverflow.com/users/15258737",
"pm_score": 2,
"selected": true,
"text": "ss-go-top {\n z-index: 2;\n opacity: 0;\n border: 2px;\n border-style: solid;\n border-radius: 50%;\n border-color: #07b8b5;\n visibility: hidden;\n -webkit-transform: translate3d(0, 200%, 0);\n transform: translate3d(0, 200%, 0);\n -webkit-transition: all 0.5s cubic-bezier(0.215, 0.61, 0.355, 1);\n transition: all 0.5s cubic-bezier(0.215, 0.61, 0.355, 1);\n position: fixed;\n bottom: 8.4rem;\n right: 4rem;\n}\n.ss-go-top a:hover svg, .ss-go-top a:hover svg path {\n fill: #fff;\n}\n.ss-go-top a {\n text-decoration: none;\n border: 2px;\n display: block;\n height: 6.4rem;\n width: 6.4rem;\n border-radius: 50%;\n background-color: transparent;\n -webkit-transition: all .3s;\n transition: all .3s;\n position: relative;\n}\n\n.ss-go-top a:hover,\n.ss-go-top a:focus {\n background-color: #07b8b5;\n}\n\n.ss-go-top svg {\n height: 1.2rem;\n width: 1.2rem;\n position: absolute;\n -webkit-transform: translate3d(-50%, -50%, 0);\n transform: translate3d(-50%, -50%, 0);\n left: 50%;\n top: 50%;\n}\n\n.ss-go-top svg path {\n fill: #07b8b5;\n}\n\n.ss-go-top.link-is-visible {\n opacity: 1;\n visibility: visible;\n -webkit-transform: translate3d(0, 0, 0);\n transform: translate3d(0, 0, 0);\n}\n "
},
{
"answer_id": 74432450,
"author": "matt lost",
"author_id": 20381102,
"author_profile": "https://Stackoverflow.com/users/20381102",
"pm_score": -1,
"selected": false,
"text": ".ss-go-top:hover .smoothscroll{background: #07b8b5;}\n.ss-go-top:hover .smoothscroll svg path {fill: #fff;}\n"
},
{
"answer_id": 74432570,
"author": "tfernandez",
"author_id": 20500972,
"author_profile": "https://Stackoverflow.com/users/20500972",
"pm_score": 1,
"selected": false,
"text": " .smoothscroll {\n background-color: transparent;\n display: grid;\n place-items: center;\n width: 100px;\n height: 100px;\n border-radius: 50%;\n }\n .smoothscroll svg {\n fill: #07b8b5;\n background-color: transparent;\n }\n\n .smoothscroll:hover {\n background-color: #07b8b5;\n }\n .smoothscroll:hover svg {\n fill: #ffffff;\n }"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74432138",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20381102/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.