qid
int64 4
22.2M
| question
stringlengths 18
48.3k
| answers
list | date
stringlengths 10
10
| metadata
list |
|---|---|---|---|---|
74,471,015
|
<p>This is the code I am trying with:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>const arr = ['a' , 'b' ,'c', 'd']
const func = async () => {
let i = 0
let interval = setInterval(() => {
let x = arr[i++ % arr.length]
console.log(x)
if (i === 4 ) {
clearInterval(interval)
}
}, 2000)
}
const another_func = () => {
console.log('logic')
}
const main = async () => {
await func()
another_func()
}
main()</code></pre>
</div>
</div>
</p>
<p>Output :-</p>
<pre><code>logic
a
b
c
d
</code></pre>
<p>When I run this problem "logic" gets printed before all the elements of array.</p>
<p>Why should I do print all the elements of array first and only then run the other function and print the logic?</p>
|
[
{
"answer_id": 74471225,
"author": "talent-jsdev",
"author_id": 15087608,
"author_profile": "https://Stackoverflow.com/users/15087608",
"pm_score": 2,
"selected": false,
"text": "const arr = ['a', 'b', 'c', 'd']\n\nconst func = () => new Promise((resolve, reject) => {\n\n let i = 0\n let interval = setInterval(() => {\n let com = arr[i++ % arr.length]\n console.log(com)\n if (i === 4) {\n clearInterval(interval);\n resolve('success');\n }\n }, 2000)\n})\n\nconst another_func = () => {\n console.log('logic')\n}\n\nconst main = async () => {\n await func()\n\n another_func()\n}\nmain()\n"
},
{
"answer_id": 74471995,
"author": "trincot",
"author_id": 5459839,
"author_profile": "https://Stackoverflow.com/users/5459839",
"pm_score": 0,
"selected": false,
"text": "async"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471015",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20527086/"
] |
74,471,023
|
<p>In the simplified code at the bottom of this post, I believe it is js that is used for formatting outputs of the table rendered using rhandsontable. I play around with row/column formatting with some success in the js section of the code. However, as illustrated below, how would I format row 2 of the table so that it is shown as an integer (rounded to digits = 0, so there are no decimals) with commas separating the thousands, for all columns as they are added?</p>
<p>I've played around with the usual <code>formatC()</code>, etc., with no luck. Looks like the answer might lie in js.</p>
<p><a href="https://i.stack.imgur.com/7MJis.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7MJis.png" alt="enter image description here" /></a></p>
<p>Code:</p>
<pre><code>library(rhandsontable)
library(shiny)
mydata <- data.frame('Series 1' = c(1,2000.39,3,4),check.names = FALSE)
rownames(mydata) <- c('A','B','C','D')
ui <- fluidPage(
rHandsontableOutput("mytable"),
textInput('NewCol', 'Enter new column name'),
actionButton("goButton", "Update Table")
)
server <- function(input, output) {
output$mytable = renderRHandsontable(df())
df <- eventReactive(input$goButton, {
if(input$NewCol!="" && !is.null(input$NewCol) && input$goButton>0){
newcol <- data.frame(NROW(mydata))
newcol[2,] <- c(1234.22)
names(newcol) <- input$NewCol
mydata <<- cbind(mydata, newcol)
}
rhandsontable(mydata,rowHeaderWidth = 100)%>%
hot_cols(
renderer = "function(instance, td, row, col, prop, value, cellProperties) {
Handsontable.renderers.NumericRenderer.apply(this, arguments);
// format as integers first 2 rows:
if(row == 0 || row == 1){td.innerHTML = `${value}`;}
// shade 2nd row:
if(row == 1){td.style.background='#eff0f1'}
// format as % the 2nd set of 2 rows:
if(row == 2 || row == 3){td.innerHTML = `${Number.parseFloat(value*100)}%`}
}") %>%
hot_row(c(2), readOnly = TRUE) # makes row 2 read-only
}, ignoreNULL = FALSE)
observe(if (!is.null(input$mytable)) mydata <<- hot_to_r(input$mytable))
}
shinyApp(ui,server)
</code></pre>
|
[
{
"answer_id": 74471225,
"author": "talent-jsdev",
"author_id": 15087608,
"author_profile": "https://Stackoverflow.com/users/15087608",
"pm_score": 2,
"selected": false,
"text": "const arr = ['a', 'b', 'c', 'd']\n\nconst func = () => new Promise((resolve, reject) => {\n\n let i = 0\n let interval = setInterval(() => {\n let com = arr[i++ % arr.length]\n console.log(com)\n if (i === 4) {\n clearInterval(interval);\n resolve('success');\n }\n }, 2000)\n})\n\nconst another_func = () => {\n console.log('logic')\n}\n\nconst main = async () => {\n await func()\n\n another_func()\n}\nmain()\n"
},
{
"answer_id": 74471995,
"author": "trincot",
"author_id": 5459839,
"author_profile": "https://Stackoverflow.com/users/5459839",
"pm_score": 0,
"selected": false,
"text": "async"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471023",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19657749/"
] |
74,471,030
|
<p>Currently, I have a DB table called mytable which looks like this</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>id</th>
<th>startTime</th>
<th>result</th>
</tr>
</thead>
<tbody>
<tr>
<td>100</td>
<td>2022-11-17 06:19:00</td>
<td>pass</td>
</tr>
<tr>
<td>101</td>
<td>2022-11-17 07:19:00</td>
<td>fail</td>
</tr>
<tr>
<td>102</td>
<td>2022-11-17 08:44:00</td>
<td>pass</td>
</tr>
<tr>
<td>103</td>
<td>2022-11-17 16:19:00</td>
<td>fail</td>
</tr>
<tr>
<td>104</td>
<td>2022-11-16 06:11:00</td>
<td>pass</td>
</tr>
<tr>
<td>105</td>
<td>2022-11-16 06:11:00</td>
<td>fail</td>
</tr>
<tr>
<td>106</td>
<td>2022-11-16 06:12:00</td>
<td>pass</td>
</tr>
<tr>
<td>107</td>
<td>2022-11-16 12:11:00</td>
<td>pass</td>
</tr>
</tbody>
</table>
</div>
<p>This needs to be transformed into</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>date</th>
<th>pass</th>
<th>fail</th>
</tr>
</thead>
<tbody>
<tr>
<td>2022-11-17</td>
<td>2</td>
<td>2</td>
</tr>
<tr>
<td>2022-11-16</td>
<td>3</td>
<td>1</td>
</tr>
</tbody>
</table>
</div>
<p>What query can I use for this?</p>
<p>I have tried</p>
<pre><code>SELECT result, DATE(startTime), COUNT(result)
FROM mytable
GROUP BY DATE(startTime), result;
</code></pre>
<p>but that doesnt work properly</p>
|
[
{
"answer_id": 74471149,
"author": "Barbaros Özhan",
"author_id": 5841306,
"author_profile": "https://Stackoverflow.com/users/5841306",
"pm_score": 2,
"selected": false,
"text": "DATE(startTime)"
},
{
"answer_id": 74471845,
"author": "Jonas Metzler",
"author_id": 18794826,
"author_profile": "https://Stackoverflow.com/users/18794826",
"pm_score": 0,
"selected": false,
"text": "SELECT DATE(startTime) AS `date`, \n result,\n COUNT(result) AS resultQty\n FROM mytable \n GROUP BY DATE(startTime), result\n ORDER BY DATE(startTime) DESC;\n"
},
{
"answer_id": 74481611,
"author": "BoHuang",
"author_id": 14492048,
"author_profile": "https://Stackoverflow.com/users/14492048",
"pm_score": 0,
"selected": false,
"text": "aggregating"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471030",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20526962/"
] |
74,471,046
|
<p>How I can implement a 2-dimensional array with different column sizes dynamically in C?</p>
<p>I tried many ways to implement a 2-dimensional array dynamically with different column sizes in c but I can't get it.</p>
<p>Please tell me one suggestion...</p>
|
[
{
"answer_id": 74471623,
"author": "Imran",
"author_id": 19443172,
"author_profile": "https://Stackoverflow.com/users/19443172",
"pm_score": -1,
"selected": false,
"text": "//Hemanth you can find the below code,\n#include <stdio.h>\n#include <stdlib.h> \nint main() {\n int row = 2, col = 3; //number of rows=2 and number of columns=3\n int *arr = (int *)malloc(row * col * sizeof(int)); \n int i, j;\n for (i = 0; i < row; i++)\n for (j = 0; j < col; j++)\n *(arr + i*col + j) = i + j; \n printf(\"The matrix elements are:\\n\");\n for (i = 0; i < row; i++) {\n for (j = 0; j < col; j++) {\n printf(\"%d \", *(arr + i*col + j)); \n }\n printf(\"\\n\");\n }\n free(arr); \n return 0;\n}\n//let me know if you are still finding any problems with it.\n"
},
{
"answer_id": 74476457,
"author": "Peter - Reinstate Monica",
"author_id": 3150802,
"author_profile": "https://Stackoverflow.com/users/3150802",
"pm_score": -1,
"selected": false,
"text": "struct jagged_col_arr_ST"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471046",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20527044/"
] |
74,471,049
|
<pre class="lang-java prettyprint-override"><code>public class test2 {
public static void main(String[] args) {
A a = new A();
int y = 5;
System.out.println(a.foo(y));
}
}
class A{
public A() {
}
public int foo(int x) {
return x+1;
}
public static int foo(int x) {
return x+2;
}
}
</code></pre>
<p>If a java class has two methods of the same name but one has static and the other doesn't which one does it execute? Why does it prioritize the one on top? Or is it because the first foo does not have static?</p>
|
[
{
"answer_id": 74471242,
"author": "Sagar Gandhi",
"author_id": 6722664,
"author_profile": "https://Stackoverflow.com/users/6722664",
"pm_score": 1,
"selected": false,
"text": "public int foo(int x){\n return x;\n }\n\n public static float foo(float y){\n return y;\n } \n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471049",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10627189/"
] |
74,471,072
|
<p>I am in the process of converting Python 2 code into Python 3. Currently I am facing difficulty in converting the following code to Python 3. Please help.</p>
<pre><code>print 'Data cache hit ratio: %4.2f%%' % ratio
</code></pre>
<p>Also, what %4.2f%% means?</p>
<p>Tried to rewrite the code with format().</p>
|
[
{
"answer_id": 74471242,
"author": "Sagar Gandhi",
"author_id": 6722664,
"author_profile": "https://Stackoverflow.com/users/6722664",
"pm_score": 1,
"selected": false,
"text": "public int foo(int x){\n return x;\n }\n\n public static float foo(float y){\n return y;\n } \n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471072",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7182741/"
] |
74,471,100
|
<p>I am trying understand Artificial Intelligence Neural Network and I am self-learner. Hope anyone would help me in understanding on how to solve this problem</p>
<p><strong>If this post should be posted here. Please comment instead of degrading the post. Appreciate for this as well.</strong></p>
<p>I have a question that I am totally confused about how to solve it. I encountered this online but was unable to understand how to solve it. I have added the question below. Hope you can provide some help.</p>
<p>The data set contains 4 observations for 4 input variables (Temp, Pres, Flow, and Process) and an output variable (Rejects). The first column "No" is simply an identifier. The table below reproduces the first 4 observations:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>No</th>
<th>Temp</th>
<th>Pres</th>
<th>Flow</th>
<th>Process</th>
<th>Rejects</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>53.39</td>
<td>10.52</td>
<td>4.82</td>
<td>0</td>
<td>1.88</td>
</tr>
<tr>
<td>2</td>
<td>46.23</td>
<td>15.13</td>
<td>5.31</td>
<td>0</td>
<td>2.13</td>
</tr>
<tr>
<td>3</td>
<td>42.85</td>
<td>18.79</td>
<td>3.59</td>
<td>0</td>
<td>2.66</td>
</tr>
<tr>
<td>4</td>
<td>53.09</td>
<td>18.33</td>
<td>3.67</td>
<td>0</td>
<td>2.03</td>
</tr>
</tbody>
</table>
</div>
<p>Train a back-propagation neural network on approximately 80% of the observations, randomly selected. Test the trained network using the remaining 20% observations.</p>
<p>Question:</p>
<ol>
<li>Based on this how to define a fixed neural network with output values and backpropagate an expected output pattern? Here, the output is only one which is the "Rejects" Column</li>
<li>What are the error values which is required to be calculated?</li>
<li>Does it required to define the hidden layer here? And how can we define the hidden layer?</li>
<li>What type of “tool” can be used to create a report for the above inputs and get the expected output? Can you help related to this? I am unsure about one thing as well</li>
<li>If not tool could you provide any program to understand this? Preferable tool though.</li>
<li>Create a figure that plots the actual and predicted values of the output "Rejects" for the training and test data sets.</li>
<li>Does this mean creating a chart something similar to the plot chart we create for the Support Vector Machine? Is that possible to create in the tool where we are using for the above question?</li>
<li>How to solve -> Sum of squared errors for the training and test data sets.</li>
</ol>
<p>I would really appreciate your help.</p>
|
[
{
"answer_id": 74471242,
"author": "Sagar Gandhi",
"author_id": 6722664,
"author_profile": "https://Stackoverflow.com/users/6722664",
"pm_score": 1,
"selected": false,
"text": "public int foo(int x){\n return x;\n }\n\n public static float foo(float y){\n return y;\n } \n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471100",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3481508/"
] |
74,471,134
|
<p>I understand I can code like single loop to build widget like;</p>
<pre><code>final icon =["lock.png","map.png","stake.png","cheer.png","sushi.png"];
// omit
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
for(int i = 0; i < icon.length; i++) ... {
selectIcon(id: 1, iconPass: icon[i]),
},
],
),
</code></pre>
<p>But when those widgets structured as nested like:</p>
<pre><code>final icon =["lock.png","map.png","stake.png","cheer.png","sushi.png","drink.png","toy.png","christmas.png","newyear.png","flag.png")];
//omit,
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
selectIcon(id: 1, iconPass: "lock.png"),
selectIcon(id: 1, iconPass: "map.png"),
selectIcon(id: 1, iconPass: "sushi.png"),
selectIcon(id: 1, iconPass: "stake.png"),
selectIcon(id: 1, iconPass: "cheer.png"),
],
),
Container(
margin: const EdgeInsets.only(top:10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
selectIcon(id: 1, iconPass: "drink.png"),
selectIcon(id: 1, iconPass: "toy.png"),
selectIcon(id: 1, iconPass: "christmas.png"),
selectIcon(id: 1, iconPass: "newyear.png"),
selectIcon(id: 1, iconPass: "flag.png"),
],
),
),
]
);
</code></pre>
<p>How can I build with nested widget with loop in flutter / Dart ? or is it unacceptable ?</p>
|
[
{
"answer_id": 74471205,
"author": "eamirho3ein",
"author_id": 10306997,
"author_profile": "https://Stackoverflow.com/users/10306997",
"pm_score": 2,
"selected": true,
"text": "class _CustomTitleWidgetState extends State<CustomTitleWidget> {\n final icon = [\n \"lock.png\",\n \"map.png\",\n \"stake.png\",\n \"cheer.png\",\n \"sushi.png\",\n \"drink.png\",\n \"toy.png\",\n \"christmas.png\",\n \"newyear.png\",\n \"flag.png\"\n ];\n\n Widget selectIcon({required int id, required String iconPass}) {\n return Container(\n child: Text(iconPass),\n );\n }\n\n @override\n Widget build(BuildContext context) {\n var iconChunks = icon.slices(5).toList();\n\n return Scaffold(\n appBar: AppBar(),\n backgroundColor: Colors.white,\n body: Column(\n children: iconChunks\n .map((e) => Padding(\n padding: const EdgeInsets.only(bottom: 10.0),\n child: Row(\n mainAxisAlignment: MainAxisAlignment.spaceBetween,\n children:\n e.map((e) => selectIcon(id: 1, iconPass: e)).toList(),\n ),\n ))\n .toList()),\n );\n }\n}\n"
},
{
"answer_id": 74471269,
"author": "Emily Cs",
"author_id": 20375779,
"author_profile": "https://Stackoverflow.com/users/20375779",
"pm_score": 1,
"selected": false,
"text": "List.generate"
},
{
"answer_id": 74472071,
"author": "Ivo",
"author_id": 1514861,
"author_profile": "https://Stackoverflow.com/users/1514861",
"pm_score": 0,
"selected": false,
"text": " Column(\n children: [\n for(int i = 0; i < icon.length / 5; i++)\n if (i == 0)\n Row(\n mainAxisAlignment: MainAxisAlignment.spaceBetween,\n children: [\n for (int j = 5 * i; j < min(icon.length, 5 * i + 5); j++) selectIcon(id: 1, iconPass: icon[j])\n ],\n )\n else\n Container(\n margin: const EdgeInsets.only(top:10),\n child: Row(\n mainAxisAlignment: MainAxisAlignment.spaceBetween,\n children: [\n for (int j = 5 * i; j < min(icon.length, 5 * i + 5); j++) selectIcon(id: 1, iconPass: icon[j])\n ],\n ),\n ),\n ]\n )\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471134",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6843543/"
] |
74,471,143
|
<p>I have two tables named <code>property</code> and <code>equipment_type</code>.</p>
<pre><code>CREATE TABLE IF NOT EXISTS equipment_type (
class_code class_code NOT NULL,
major_code character(2) NOT NULL,
minor_code character(2) NOT NULL,
estimated_useful_life integer NOT NULL, -- in years
PRIMARY KEY (class_code, major_code, minor_code)
);
</code></pre>
<pre><code>CREATE TABLE IF NOT EXISTS PROPERTY(
property_number character(16) PRIMARY KEY,
class_code class_code NOT NULL,
major_code character(2) NOT NULL,
minor_code character(2) NOT NULL,
date_acquired date NOT NULL,
warranty_period integer,
warranty_start_date date,
warranty_end_date date
GENERATED ALWAYS AS (
warranty_start_date + (interval '1 year' * warranty_period)
) STORED,
is_beyond_ul boolean
GENERATED ALWAYS AS (
-- condition
) STORED,
FOREIGN KEY (class_code, major_code, minor_code)
REFERENCES equipment_type (class_code, major_code, minor_code)
);
</code></pre>
<p>Sample data:</p>
<pre><code>INSERT INTO equipment_type (class_code, major_code, minor_code, estimated_useful_life)
VALUES
('CE', '01', '01', 10),
('CE', '02', '01', 10);
</code></pre>
<pre><code>INSERT INTO PPE (property_number, class_code, major_code, minor_code, date_acquired, warranty_period, warranty_start_date)
VALUES
('10-0518IT39020042', 'CE', '01', '01', '2014-12-01', 1, '2014-12-01'),
('10-0518IT39020034', 'CE', '02', '01', '2015-03-15', 3, '2015-03-18');
</code></pre>
<p>I want to generate the value for <code>is_beyond_UL</code> column, where it will be true if <code>CURRENT_DATE - date_acquired > equipment_type.estimated_useful_life</code>, and false otherwise. How do i do this?</p>
|
[
{
"answer_id": 74471267,
"author": "a_horse_with_no_name",
"author_id": 330315,
"author_profile": "https://Stackoverflow.com/users/330315",
"pm_score": 3,
"selected": true,
"text": "select ... other columns ....,\n CURRENT_DATE - p.date_acquired > et.estimated_useful_life as is_beyond_ul \nfrom property p\n join equipment_type et on ...;\n \n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9988159/"
] |
74,471,161
|
<p>I need to be able to move the turtle cursor to its current coordinates +10<em>y</em>.</p>
<p>For example, if the turtle is at <strong>(0.00,0.00)</strong> I would need it to read its own coordinates and add 10 to the <em>y</em> value making it <strong>(0.00,10.00)</strong>.</p>
<p>I already know how to find the Turtle's current position with turtle.pos() but how would I add an integer onto any given axis?</p>
|
[
{
"answer_id": 74471223,
"author": "Bluffyyy",
"author_id": 19754899,
"author_profile": "https://Stackoverflow.com/users/19754899",
"pm_score": 1,
"selected": false,
"text": "current_y = t.ycor()\nt.sety(current_y + 10)\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471161",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19754899/"
] |
74,471,168
|
<p>I'm trying to show how many time went since the creation on a post! after searching I found that I have to use momentJs.
The time is stored like this:</p>
<p><a href="https://i.stack.imgur.com/bMoXz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bMoXz.png" alt="enter image description here" /></a></p>
<p>And I used this code to show the time</p>
<pre><code>{moment.utc(post.createdAt).local().startOf('seconds').fromNow()}
</code></pre>
<p>and the output is like this:</p>
<p><a href="https://i.stack.imgur.com/DqE8u.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DqE8u.png" alt="enter image description here" /></a></p>
<p>now the question is how change the output to arabic language?</p>
|
[
{
"answer_id": 74471223,
"author": "Bluffyyy",
"author_id": 19754899,
"author_profile": "https://Stackoverflow.com/users/19754899",
"pm_score": 1,
"selected": false,
"text": "current_y = t.ycor()\nt.sety(current_y + 10)\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471168",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17342280/"
] |
74,471,211
|
<p>Hope everyone doing well. I am new in flutter I want to know how to give shape of an image like this, I have attached the sample... The image is coming from database</p>
<p><a href="https://i.stack.imgur.com/aiex9.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aiex9.jpg" alt="Shape Image Like this" /></a></p>
|
[
{
"answer_id": 74471256,
"author": "Yeasin Sheikh",
"author_id": 10157127,
"author_profile": "https://Stackoverflow.com/users/10157127",
"pm_score": 3,
"selected": true,
"text": "Stack(\n clipBehavior: Clip.hardEdge,\n children: [\n Positioned(\n top: -30, //negative value will shift to up side \n right: -30, // this will shift pixel to the right\n child: Container(\n width: 100, //,\n height: 100,\n child: Image.network(\n \" \",\n fit: BoxFit.cover,\n )),\n )\n ],\n),\n"
},
{
"answer_id": 74472021,
"author": "Duy Tran",
"author_id": 19851394,
"author_profile": "https://Stackoverflow.com/users/19851394",
"pm_score": 1,
"selected": false,
"text": "Container(\n decoration: const BoxDecoration(shape: BoxShape.circle),\n clipBehavior: Clip.hardEdge,\n width: MediaQuery.of(context).size.height * 0.08,\n height: MediaQuery.of(context).size.height * 0.08,\n child: Image.asset('assets/default_avatar.png')),\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17863927/"
] |
74,471,213
|
<p><a href="https://i.stack.imgur.com/IdOon.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IdOon.jpg" alt="enter image description here" /></a>
Text is all white here. I do nothing yesterday everything was okay. Can someone help?</p>
|
[
{
"answer_id": 74471256,
"author": "Yeasin Sheikh",
"author_id": 10157127,
"author_profile": "https://Stackoverflow.com/users/10157127",
"pm_score": 3,
"selected": true,
"text": "Stack(\n clipBehavior: Clip.hardEdge,\n children: [\n Positioned(\n top: -30, //negative value will shift to up side \n right: -30, // this will shift pixel to the right\n child: Container(\n width: 100, //,\n height: 100,\n child: Image.network(\n \" \",\n fit: BoxFit.cover,\n )),\n )\n ],\n),\n"
},
{
"answer_id": 74472021,
"author": "Duy Tran",
"author_id": 19851394,
"author_profile": "https://Stackoverflow.com/users/19851394",
"pm_score": 1,
"selected": false,
"text": "Container(\n decoration: const BoxDecoration(shape: BoxShape.circle),\n clipBehavior: Clip.hardEdge,\n width: MediaQuery.of(context).size.height * 0.08,\n height: MediaQuery.of(context).size.height * 0.08,\n child: Image.asset('assets/default_avatar.png')),\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471213",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19918265/"
] |
74,471,229
|
<p><a href="https://file:///C:/Users/abc/Downloads/lf30_editor_c25ykyq1.json" rel="nofollow noreferrer">enter link description here</a></p>
<p>Above link is json file of gif</p>
<p>How do I load this gif via json file.</p>
<p>I tried in Iamage.asset but it didn't work</p>
|
[
{
"answer_id": 74471600,
"author": "Mansoor Malik",
"author_id": 12790690,
"author_profile": "https://Stackoverflow.com/users/12790690",
"pm_score": 0,
"selected": false,
"text": "assets"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471229",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14299145/"
] |
74,471,238
|
<p>I have an accordion where it has a flex-row textbox and it has icons on its right.
I need to add the menu positioned as shown in the image below</p>
<p><a href="https://i.stack.imgur.com/qPp6Y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qPp6Y.png" alt="enter image description here" /></a></p>
<p>My code is here</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><html>
<head>
<style>
.accordion {
margin: 30px;
}
.accordion-button.collapsed {
border-bottom: #ccc 1px solid
}
.accordion-body {
border-left: #673ab744 1px solid;
border-bottom: #673ab744 1px solid;
border-right: #673ab744 1px solid
}
.accordion-button {
display: inline!important
}
.flx-row {
display: flex;
justify-content: space-between;
}
</style>
<script src="/scripts/snippet-javascript-console.min.js?v=1"></script>
</head>
<body>
<script src="/scripts/snippet-javascript-console.min.js?v=1"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-OERcA2EqjJCMA+/3y+gxIOqMEjwtxJY7qPCqsdltbNJuaOe923+mo//f6V8Qbsw3" crossorigin="anonymous"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@48,400,0,0">
<div class="accordion accordion-flush" id="accordionFlushExample">
<div class="accordion-item">
<h2 class="accordion-header" id="flush-headingOne">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#flush-collapseOne" aria-expanded="false" aria-controls="flush-collapseOne">
<div class="flx-row">
<div>
<input type="textbox" value="Accordion Item #1">
</div>
<div>
<div class="btn-group">
<button type="button" class="btn btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false"> More </button>
<ul class="dropdown-menu dropdown-menu-lg-end" style="">
<li><a class="dropdown-item" href="#">Export</a></li>
<li><a class="dropdown-item" href="#">Duplicate</a></li>
<li><a class="dropdown-item tdelete" href="#">Delete</a></li>
</ul>
</div>
<span class="wcopy material-symbols-outlined text-primary">content_copy</span>
<span class="wdelete material-symbols-outlined text-primary">delete</span>
</div>
</div>
<br><span>Desc goes here</span><br><span>Desc goes here</span>
</button>
</h2>
<div id="flush-collapseOne" class="accordion-collapse collapse" aria-labelledby="flush-headingOne" data-bs-parent="#accordionFlushExample">
<div class="accordion-body">Placeholder content for this accordion, which is intended to demonstrate the <code>.accordion-flush</code> class. This is the first item's accordion body.</div>
</div>
</div>
<div class="accordion-item">
<h2 class="accordion-header" id="flush-headingTwo">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#flush-collapseTwo" aria-expanded="false" aria-controls="flush-collapseTwo">
Accordion Item #2
</button>
</h2>
<div id="flush-collapseTwo" class="accordion-collapse collapse" aria-labelledby="flush-headingTwo" data-bs-parent="#accordionFlushExample">
<div class="accordion-body">Placeholder content for this accordion, which is intended to demonstrate the <code>.accordion-flush</code> class. This is the second item's accordion body. Let's imagine this being filled with some actual content.</div>
</div>
</div>
</div>
<div class="as-console-wrapper">
<div class="as-console"></div>
</div>
<script type="text/javascript">
$(".wdelete").off().on('click', function(event) {
if (confirm(`Are you sure to delete the workflow ${$(this).prev().parent().prev().val()}?`) == true) {
$(this).closest('.accordion-item').remove();
}
event.preventDefault();
event.stopPropagation();
});
</script>
<div class="as-console-wrapper">
<div class="as-console"></div>
</div>
<div class="as-console-wrapper">
<div class="as-console"></div>
</div>
</body>
</html></code></pre>
</div>
</div>
</p>
|
[
{
"answer_id": 74472134,
"author": "sapna singh",
"author_id": 18544206,
"author_profile": "https://Stackoverflow.com/users/18544206",
"pm_score": -1,
"selected": false,
"text": " <div class=\"btn-group\">\n\n <button type=\"button\" class=\"btn btn-sm dropdown-toggle\" data-bs- \n toggle=\"dropdown\" aria-expanded=\"false\"> More </button>\n\n <ul class=\"dropdown-menu dropdown-menu-lg-end\">\n <li><a class=\"dropdown-item\" href=\"#\">Export</a></li>\n <li><a class=\"dropdown-item\" href=\"#\">Duplicate</a></li>\n <li><a class=\"dropdown-item tdelete\" href=\"#\">Delete</a></li>\n </ul>\n\n <span class=\"wcopy material-symbols-outlined text- \n primary\">content_copy</span>\n <span class=\"wdelete material-symbols-outlined text- \n primary\">delete</span>\n\n </div>\n"
},
{
"answer_id": 74476014,
"author": "DreamTeK",
"author_id": 2120261,
"author_profile": "https://Stackoverflow.com/users/2120261",
"pm_score": 0,
"selected": false,
"text": "div"
},
{
"answer_id": 74479103,
"author": "reza hrkeng",
"author_id": 20517507,
"author_profile": "https://Stackoverflow.com/users/20517507",
"pm_score": 2,
"selected": true,
"text": "display:flex;\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471238",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5549354/"
] |
74,471,241
|
<p>Hi in my flutter app have FutureBuilder that return listview, my list listview create some button for update the hive table. when I click the first time on one of buttons everything is run smoothly, but when I click on same button again my hive key turn to null and program show my this error: "type 'Null' is not a subtype of type 'int' "
I write print all over my code but still I do not get it why the key turn null from the second time.
How can I Correct this? please help my.
my Futurebuilder body is:</p>
<pre><code> FutureBuilder<List>(
future: controller.showTaskList(),
builder: (context, snapshot) {
switch (snapshot.connectionState) {
case ConnectionState.waiting:
return SizedBox(
height: Get.height,
child: const Center(
child: CircularProgressIndicator(),
),
);
default:
if (snapshot.hasError) {
return Text('Error: ${snapshot.error}');
} else {
List data = snapshot.data ?? [];
return ListView.separated(
scrollDirection: Axis.vertical,
physics:
const BouncingScrollPhysics(),
shrinkWrap: true,
itemCount: data.length,
itemBuilder: (context, index) {
// controller.taskIconCheckList
// .clear();
for (int i = 0;
i < data.length;
i++) {
if (data[i].status == true) {
controller.taskIconCheckList
.add(true.obs);
} else {
controller.taskIconCheckList
.add(false.obs);
}
}
return ListTile(
leading: Obx(
() => PageTransitionSwitcher(
transitionBuilder: (
child,
primaryAnimation,
secondaryAnimation,
) {
return SharedAxisTransition(
animation:
primaryAnimation,
secondaryAnimation:
secondaryAnimation,
transitionType:
SharedAxisTransitionType
.horizontal,
fillColor:
Colors.transparent,
child: child,
);
},
duration: const Duration(
milliseconds: 800),
child: controller
.taskIconCheckList[
index]
.value
? SizedBox(
child: IconButton(
icon: const Icon(
Icons
.check_circle_rounded,
color: Colors
.lightGreenAccent,
),
onPressed: () {
controller
.functionTaskIconCheckList(
index,
);
print('طول دیتا');
print(data.length.toString());
print('مقدار ایندکس');
print(index.toString());
print('مقدار کلید');
print(data[index].key.toString());
print(data[index].taskText.toString());
controller
.updateStatusTask(
index,
data[index]
.key); // here when i first click // return key currectly, but after that show null and updatestatusetask not run and show error.
},
),
)
: IconButton(
onPressed: () {
controller
.functionTaskIconCheckList(
index,
);
print('طول دیتا');
print(data.length.toString());
print('مقدار ایندکس');
print(index.toString());
print('مقدار کلید');
print(data[index].key.toString());
print(data[index].taskText.toString());
controller
.updateStatusTask(
index,
data[index]
.key); // here when i first click // return key currectly, but after that show null and updatestatusetask not run and show error.
},
icon: const Icon(
Icons
.radio_button_unchecked_outlined,
color: Colors.red,
),
),
),
),
title: Text(data[index].taskText,
style: normalTextForCategory),
subtitle: Text(
data[index]
.date
.toString()
.substring(0, 10),
textDirection:
TextDirection.ltr,
textAlign: TextAlign.right,
style: normalTextForSubtitle,
),
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
IconButton(
onPressed: () {
myDefaultDialog(
'هشدار',
'آیا از حذف این گزینه اطمینان دارید؟',
'بله',
'خیر',
() {
Get.back();
mySnakeBar(
'',
'گزینه مورد نظر با موفقیت حذف شد.',
Icons
.warning_amber_rounded,
Colors.yellow);
},
);
},
icon: const Icon(
Icons.delete),
color: Colors.redAccent,
),
IconButton(
onPressed: () {
Get.offNamed(
Routs.editTaskScreen,
arguments: 'edit');
},
icon: const Icon(
Icons.edit_calendar,
color:
Colors.yellowAccent,
),
),
],
),
);
},
separatorBuilder:
(BuildContext context,
int index) {
return const Divider(
height: 2,
color: Colors.white70,
);
},
);
}
}
},
),
</code></pre>
<p>this is my functionTaskIconCheckList form controller:</p>
<pre><code> functionTaskIconCheckList(int index) {
taskIconCheckList[index].value = !taskIconCheckList[index].value;}
</code></pre>
<p>and this the updatestatusetask function</p>
<pre><code> updateStatusTask(int index,int taskKey) async {
print('در تابع آپدیت ایندکس هست: ${index.toString()}');
print('در تابع آپدیت کی هست: ${taskKey.toString()}');
var taskBox = await Hive.openBox('task');
var filterTask = taskBox.values.where((task) => task.key == taskKey).toList();
Task task = Task(
filterTask[0].taskText,
filterTask[0].date,
taskIconCheckList[index].value,
filterTask[0].deleteStatus,
null,
null,
filterTask[0].taskCatId,
filterTask[0].userId);
await taskBox.put(taskKey, task);}
</code></pre>
<p>and this is my showtasklist function:</p>
<pre><code> Future<List> showTaskList() async {
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
var taskBox = await Hive.openBox('task');
var filterTask = taskBox.values
.where((task) => task.userId == sharedPreferences.getInt('key'))
.toList();
return filterTask;}
</code></pre>
<p>this is my model:</p>
<pre><code> @HiveType(typeId: 2)
class Task extends HiveObject{
@HiveField(0)
String taskText;
@HiveField(1)
DateTime date;
@HiveField(2)
bool status;
@HiveField(3)
bool deleteStatus;
@HiveField(4)
int taskCatId;
@HiveField(5)
int userId;
@HiveField(6)
User? user;
@HiveField(7)
TaskCat? taskCat;
Task(this.taskText, this.date, this.status, this.deleteStatus, this.user,
this.taskCat, this.taskCatId, this.userId);
}
</code></pre>
|
[
{
"answer_id": 74472134,
"author": "sapna singh",
"author_id": 18544206,
"author_profile": "https://Stackoverflow.com/users/18544206",
"pm_score": -1,
"selected": false,
"text": " <div class=\"btn-group\">\n\n <button type=\"button\" class=\"btn btn-sm dropdown-toggle\" data-bs- \n toggle=\"dropdown\" aria-expanded=\"false\"> More </button>\n\n <ul class=\"dropdown-menu dropdown-menu-lg-end\">\n <li><a class=\"dropdown-item\" href=\"#\">Export</a></li>\n <li><a class=\"dropdown-item\" href=\"#\">Duplicate</a></li>\n <li><a class=\"dropdown-item tdelete\" href=\"#\">Delete</a></li>\n </ul>\n\n <span class=\"wcopy material-symbols-outlined text- \n primary\">content_copy</span>\n <span class=\"wdelete material-symbols-outlined text- \n primary\">delete</span>\n\n </div>\n"
},
{
"answer_id": 74476014,
"author": "DreamTeK",
"author_id": 2120261,
"author_profile": "https://Stackoverflow.com/users/2120261",
"pm_score": 0,
"selected": false,
"text": "div"
},
{
"answer_id": 74479103,
"author": "reza hrkeng",
"author_id": 20517507,
"author_profile": "https://Stackoverflow.com/users/20517507",
"pm_score": 2,
"selected": true,
"text": "display:flex;\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471241",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20492111/"
] |
74,471,273
|
<p>I'm trying to get the top 10 movie name recommendations that match the search term 'Africa', based on the IMDB API demo here <a href="https://developer.imdb.com/documentation/api-documentation/sample-queries/search/?ref_=side_nav" rel="nofollow noreferrer">https://developer.imdb.com/documentation/api-documentation/sample-queries/search/?ref_=side_nav</a>.</p>
<p>I need the query to return the movie id, title, image poster and filming location.</p>
<p>However, when I run the graph query below, I get the error 'ClientError: Cannot query field "Image" on type "MainSearchEntity".|Cannot query field "FilmingLocation" on type "MainSearchEntity"."</p>
<p>The query works fine when I remove the code <code>Image { url } FilmingLocation { text }</code> from the script.</p>
<p>What could be the problem with the query below?</p>
<p>How do I include the poster image and filming location in the query?</p>
<p>Thanks!</p>
<pre><code>
{
# Get the top 10 name recommendations that match the search term Africa.
mainSearch(
first: 10
options: {
searchTerm: "Africa"
isExactMatch: false
type: TITLE
includeAdult:false,
}
) {
edges {
node {
entity {
# For returned Names, get me the id, name text, image, year, country
... on Name {
id
nameText {
text
}
}
Image {
url
}
FilmingLocation {
text
}
}
}
}
}
}
</code></pre>
|
[
{
"answer_id": 74472134,
"author": "sapna singh",
"author_id": 18544206,
"author_profile": "https://Stackoverflow.com/users/18544206",
"pm_score": -1,
"selected": false,
"text": " <div class=\"btn-group\">\n\n <button type=\"button\" class=\"btn btn-sm dropdown-toggle\" data-bs- \n toggle=\"dropdown\" aria-expanded=\"false\"> More </button>\n\n <ul class=\"dropdown-menu dropdown-menu-lg-end\">\n <li><a class=\"dropdown-item\" href=\"#\">Export</a></li>\n <li><a class=\"dropdown-item\" href=\"#\">Duplicate</a></li>\n <li><a class=\"dropdown-item tdelete\" href=\"#\">Delete</a></li>\n </ul>\n\n <span class=\"wcopy material-symbols-outlined text- \n primary\">content_copy</span>\n <span class=\"wdelete material-symbols-outlined text- \n primary\">delete</span>\n\n </div>\n"
},
{
"answer_id": 74476014,
"author": "DreamTeK",
"author_id": 2120261,
"author_profile": "https://Stackoverflow.com/users/2120261",
"pm_score": 0,
"selected": false,
"text": "div"
},
{
"answer_id": 74479103,
"author": "reza hrkeng",
"author_id": 20517507,
"author_profile": "https://Stackoverflow.com/users/20517507",
"pm_score": 2,
"selected": true,
"text": "display:flex;\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471273",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3639372/"
] |
74,471,291
|
<p>I mean i am reading a txt file, For every line in txt file i
want a new label.</p>
<pre><code>
root = tk.Tk()
#here it opens the file
with open("/file.txt", "r") as openedFile:
allLines = openedFile.readlines()
for line in allLines:
textInLine = line
testText = Label(root, text=textInLine)
testText.pack()
root.geometry("400x300")
root.mainloop()
</code></pre>
<p>Here in the text file lengths of lines is not same, so it puts the label text horizontally centered, i want it sticking to the left most side.</p>
|
[
{
"answer_id": 74472134,
"author": "sapna singh",
"author_id": 18544206,
"author_profile": "https://Stackoverflow.com/users/18544206",
"pm_score": -1,
"selected": false,
"text": " <div class=\"btn-group\">\n\n <button type=\"button\" class=\"btn btn-sm dropdown-toggle\" data-bs- \n toggle=\"dropdown\" aria-expanded=\"false\"> More </button>\n\n <ul class=\"dropdown-menu dropdown-menu-lg-end\">\n <li><a class=\"dropdown-item\" href=\"#\">Export</a></li>\n <li><a class=\"dropdown-item\" href=\"#\">Duplicate</a></li>\n <li><a class=\"dropdown-item tdelete\" href=\"#\">Delete</a></li>\n </ul>\n\n <span class=\"wcopy material-symbols-outlined text- \n primary\">content_copy</span>\n <span class=\"wdelete material-symbols-outlined text- \n primary\">delete</span>\n\n </div>\n"
},
{
"answer_id": 74476014,
"author": "DreamTeK",
"author_id": 2120261,
"author_profile": "https://Stackoverflow.com/users/2120261",
"pm_score": 0,
"selected": false,
"text": "div"
},
{
"answer_id": 74479103,
"author": "reza hrkeng",
"author_id": 20517507,
"author_profile": "https://Stackoverflow.com/users/20517507",
"pm_score": 2,
"selected": true,
"text": "display:flex;\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471291",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18025253/"
] |
74,471,322
|
<pre><code>public static void CategoryX(string categories)
{
string[] codes = { "A", "B", "C", "D", "E" };
string[] names = { "FIRST LETTER", "SECOND LETTER", "THIRD LETTER", "FOURTH LETTER", "FIFTH LETTER" };
}
</code></pre>
<p>I need the output to look like this:</p>
<pre><code>A FIRST LETTER
B SECOND LETTER
C THIRD LETTER
D FOURTH LETTER
E FIFTH LETTER
</code></pre>
<p>I have tried using a for statement using GroupBy which hasn't worked and also tried comparing the two arrays using a bool statement AND made a third array which contains codes and names as elements.</p>
|
[
{
"answer_id": 74472134,
"author": "sapna singh",
"author_id": 18544206,
"author_profile": "https://Stackoverflow.com/users/18544206",
"pm_score": -1,
"selected": false,
"text": " <div class=\"btn-group\">\n\n <button type=\"button\" class=\"btn btn-sm dropdown-toggle\" data-bs- \n toggle=\"dropdown\" aria-expanded=\"false\"> More </button>\n\n <ul class=\"dropdown-menu dropdown-menu-lg-end\">\n <li><a class=\"dropdown-item\" href=\"#\">Export</a></li>\n <li><a class=\"dropdown-item\" href=\"#\">Duplicate</a></li>\n <li><a class=\"dropdown-item tdelete\" href=\"#\">Delete</a></li>\n </ul>\n\n <span class=\"wcopy material-symbols-outlined text- \n primary\">content_copy</span>\n <span class=\"wdelete material-symbols-outlined text- \n primary\">delete</span>\n\n </div>\n"
},
{
"answer_id": 74476014,
"author": "DreamTeK",
"author_id": 2120261,
"author_profile": "https://Stackoverflow.com/users/2120261",
"pm_score": 0,
"selected": false,
"text": "div"
},
{
"answer_id": 74479103,
"author": "reza hrkeng",
"author_id": 20517507,
"author_profile": "https://Stackoverflow.com/users/20517507",
"pm_score": 2,
"selected": true,
"text": "display:flex;\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20527253/"
] |
74,471,343
|
<p>I have custom error pages e.g. resources/views/errors/404.blade.php everything is working just fine but the localization is not working for error pages. If I change website language the error pages still show in default language I tried in many way but its not working, Can anyone please help me make this work thanks in advance.</p>
<p>I try to make it work via exception handler but don't know how to do that. I can apply language middleware is someone can tell me where is default routes for error pages.</p>
|
[
{
"answer_id": 74471398,
"author": "Ramil Huseynov",
"author_id": 6711823,
"author_profile": "https://Stackoverflow.com/users/6711823",
"pm_score": 1,
"selected": false,
"text": "\nuse Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException;\n\n"
},
{
"answer_id": 74471443,
"author": "Semih SAHIN",
"author_id": 10542740,
"author_profile": "https://Stackoverflow.com/users/10542740",
"pm_score": 1,
"selected": false,
"text": "App\\Exceptions\\Handler.php"
},
{
"answer_id": 74472011,
"author": "Altaf Hussain",
"author_id": 4435216,
"author_profile": "https://Stackoverflow.com/users/4435216",
"pm_score": 0,
"selected": false,
"text": "use Session;\n\npublic function render($request, Throwable $exception)\n{\n app()->setLocale(Session::get('locale'));\n return parent::render($request, $exception);\n}\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471343",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4435216/"
] |
74,471,359
|
<p>I've just started learning XML/XSL and I've hit a roadblock in one of my assignments. Tried Googling and searching over here but I can't seem to find a question that has a solution that is basic. so what I am trying is to display rows of bucket-type and room-types associated with it. can somebody please help</p>
<pre><code><list-inventory list-count="2">
<list list-type="Standard" list-order = "1" count-Types = "3">
<types type="BEN2D"></room>
<types type="BESH2D"></room>
<types type="HNK"></room>
</list>
<list list-type="Deluxe" list-order = "2" count-Types = "3">
<types type="SNK"></room>
<types type="TESTKD"></room>
<types type="TESTKD"></room>
</list>
<list-inventory>
</code></pre>
<p>I want table as below</p>
<pre><code>Standard | Deluxe
BEN2D |SNK
BESH2D |TESTKD
HNK |TESTKD
</code></pre>
<p>I tried below xsl code but i see all list-type in single column and only 1st is being printing for all list-type:</p>
<pre><code> <xsl:for-each select="/contents/list-inventory/list">
<tr>
<td class="alt-th" style="border:1px solid black">
<xsl:value-of select="@list-type"/>
</td>
</tr>
<tr>
<td style="border:1px solid black">
<xsl:for-each select="/contents/list-inventory/list/types">
<span><xsl:value-of select="@type"/></span>
<xsl:if test="position()!=last()">
<br/>
</xsl:if>
</xsl:for-each>
</td>
</tr>
</xsl:for-each>
</code></pre>
<p>Can someone help me with xsl:for-each inside a xsl:for-each</p>
|
[
{
"answer_id": 74471398,
"author": "Ramil Huseynov",
"author_id": 6711823,
"author_profile": "https://Stackoverflow.com/users/6711823",
"pm_score": 1,
"selected": false,
"text": "\nuse Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException;\n\n"
},
{
"answer_id": 74471443,
"author": "Semih SAHIN",
"author_id": 10542740,
"author_profile": "https://Stackoverflow.com/users/10542740",
"pm_score": 1,
"selected": false,
"text": "App\\Exceptions\\Handler.php"
},
{
"answer_id": 74472011,
"author": "Altaf Hussain",
"author_id": 4435216,
"author_profile": "https://Stackoverflow.com/users/4435216",
"pm_score": 0,
"selected": false,
"text": "use Session;\n\npublic function render($request, Throwable $exception)\n{\n app()->setLocale(Session::get('locale'));\n return parent::render($request, $exception);\n}\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471359",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20526920/"
] |
74,471,390
|
<p>Good day all</p>
<p>I have a strange query.
Let's say I have a table with a composite primary key (2 columns).</p>
<pre><code>CREATE TABLE `testtable` (
`ifk1` INT(10) NOT NULL,
`ifk2` INT(10) NOT NULL,
`data1` VARCHAR(10) DEFAULT NULL,
PRIMARY KEY (`ifk1`,`ifk2`),
UNIQUE KEY `keyName` (`data1`)
) ENGINE=INNODB DEFAULT CHARSET=utf8mb4
</code></pre>
<p>Let's add some basic data</p>
<pre><code>INSERT INTO testtable(ifk1 , ifk2 , data1)
VALUES (1 , 2 , 'a') , (5 , 2 , 'b') , (2 , 4 , 'c') , (5 , 8 , 'd') , (2 , 2 , 'e') , (2 , 5 , 'f');
</code></pre>
<p>Let's do a simple SELECT to see what order the data comes out in:</p>
<pre><code>ifk1 ifk2 data1
1 2 a
2 2 e
2 4 c
2 5 f
5 2 b
5 8 d
</code></pre>
<p>Now, what if I want to write some code to iterate through the table, grabbing X number of records at a time.
With a small set of data, this is simple:</p>
<pre><code>SELECT * FROM testtable LIMIT 0 , 2;
SELECT * FROM testtable LIMIT 2 , 2;
SELECT * FROM testtable LIMIT 4 , 2;
</code></pre>
<p>This is going to run into some problems as the table gets bigger, as it's not using a WHERE clause and so not using an INDEX.
How do I use a WHERE clause to replicate the above SELECTS?</p>
<pre><code>SELECT * FROM testtable WHERE ifk1 > 0 AND ifk2 > 0 LIMIT 2; -- this will work
</code></pre>
<p>The first one is easy, but what about the others?
Is there a way to do that?</p>
|
[
{
"answer_id": 74471961,
"author": "Ozan Sen",
"author_id": 19469088,
"author_profile": "https://Stackoverflow.com/users/19469088",
"pm_score": 0,
"selected": false,
"text": "mysql> SELECT * FROM testtable WHERE ifk1 > 0 AND ifk2 > 0 LIMIT 2,2;\n+------+------+-------+\n| ifk1 | ifk2 | data1 |\n+------+------+-------+\n| 2 | 4 | c |\n| 5 | 8 | d |\n+------+------+-------+\n2 rows in set (0.00 sec)\n\nmysql> EXPLAIN SELECT * FROM testtable WHERE ifk1 > 0 AND ifk2 > 0 LIMIT 2,2;\n+----+-------------+-----------+------------+-------+---------------+---------+---------+------+------+----------+--------------------------+\n| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |\n+----+-------------+-----------+------------+-------+---------------+---------+---------+------+------+----------+--------------------------+\n| 1 | SIMPLE | testtable | NULL | index | PRIMARY | keyName | 43 | NULL | 6 | 33.33 | Using where; Using index |\n+----+-------------+-----------+------------+-------+---------------+---------+---------+------+------+----------+--------------------------+\n1 row in set, 1 warning (0.00 sec)\n\n\nmysql> SELECT * FROM testtable WHERE ifk1 > 0 AND ifk2 > 0 LIMIT 4,2;\n+------+------+-------+\n| ifk1 | ifk2 | data1 |\n+------+------+-------+\n| 2 | 2 | e |\n| 2 | 5 | f |\n+------+------+-------+\n2 rows in set (0.00 sec)\n\nmysql> EXPLAIN SELECT * FROM testtable WHERE ifk1 > 0 AND ifk2 > 0 LIMIT 4,2;\n+----+-------------+-----------+------------+-------+---------------+---------+---------+------+------+----------+--------------------------+\n| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |\n+----+-------------+-----------+------------+-------+---------------+---------+---------+------+------+----------+--------------------------+\n| 1 | SIMPLE | testtable | NULL | index | PRIMARY | keyName | 43 | NULL | 6 | 33.33 | Using where; Using index |\n+----+-------------+-----------+------------+-------+---------------+---------+---------+------+------+----------+--------------------------+\n1 row in set, 1 warning (0.00 sec)\n"
},
{
"answer_id": 74472218,
"author": "Thorsten Kettner",
"author_id": 2270762,
"author_profile": "https://Stackoverflow.com/users/2270762",
"pm_score": 2,
"selected": true,
"text": "LIMIT"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471390",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6029416/"
] |
74,471,413
|
<h1>I have imported the component of Name <strong>StoryBook</strong> that is exported default name.</h1>
<h1>But is also works as <strong>StoryBookX</strong>.</h1>
<p>e.g</p>
<p>import StoryBook from 'storybook', // This is <strong>default name.</strong>
import StoryBookX from 'storybook, //This is <strong>not default name</strong> but it also work.</p>
<p>Can anybody explain that what the reason of it.</p>
<pre><code><View>
<StoryBook />
</View>
<View>
<StoryBookX />
</View>
</code></pre>
<p>Both are <strong>wokring</strong> while there is no default component of name <strong>StoryBookX</strong></p>
<h1>I <strong>tried</strong> it .Because i was expecting that this will not work.But it works.</h1>
|
[
{
"answer_id": 74471961,
"author": "Ozan Sen",
"author_id": 19469088,
"author_profile": "https://Stackoverflow.com/users/19469088",
"pm_score": 0,
"selected": false,
"text": "mysql> SELECT * FROM testtable WHERE ifk1 > 0 AND ifk2 > 0 LIMIT 2,2;\n+------+------+-------+\n| ifk1 | ifk2 | data1 |\n+------+------+-------+\n| 2 | 4 | c |\n| 5 | 8 | d |\n+------+------+-------+\n2 rows in set (0.00 sec)\n\nmysql> EXPLAIN SELECT * FROM testtable WHERE ifk1 > 0 AND ifk2 > 0 LIMIT 2,2;\n+----+-------------+-----------+------------+-------+---------------+---------+---------+------+------+----------+--------------------------+\n| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |\n+----+-------------+-----------+------------+-------+---------------+---------+---------+------+------+----------+--------------------------+\n| 1 | SIMPLE | testtable | NULL | index | PRIMARY | keyName | 43 | NULL | 6 | 33.33 | Using where; Using index |\n+----+-------------+-----------+------------+-------+---------------+---------+---------+------+------+----------+--------------------------+\n1 row in set, 1 warning (0.00 sec)\n\n\nmysql> SELECT * FROM testtable WHERE ifk1 > 0 AND ifk2 > 0 LIMIT 4,2;\n+------+------+-------+\n| ifk1 | ifk2 | data1 |\n+------+------+-------+\n| 2 | 2 | e |\n| 2 | 5 | f |\n+------+------+-------+\n2 rows in set (0.00 sec)\n\nmysql> EXPLAIN SELECT * FROM testtable WHERE ifk1 > 0 AND ifk2 > 0 LIMIT 4,2;\n+----+-------------+-----------+------------+-------+---------------+---------+---------+------+------+----------+--------------------------+\n| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |\n+----+-------------+-----------+------------+-------+---------------+---------+---------+------+------+----------+--------------------------+\n| 1 | SIMPLE | testtable | NULL | index | PRIMARY | keyName | 43 | NULL | 6 | 33.33 | Using where; Using index |\n+----+-------------+-----------+------------+-------+---------------+---------+---------+------+------+----------+--------------------------+\n1 row in set, 1 warning (0.00 sec)\n"
},
{
"answer_id": 74472218,
"author": "Thorsten Kettner",
"author_id": 2270762,
"author_profile": "https://Stackoverflow.com/users/2270762",
"pm_score": 2,
"selected": true,
"text": "LIMIT"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471413",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17911211/"
] |
74,471,417
|
<p>I am working with Reactjs and i am using nextjs,Right now i am trying to integrate/fetch slider data,Problem is i want to add class "active" to first slide only,So i am trying to use {post.id},But how can i use condition(add "active" class where id="1") ?So how can i do this using loop/mapfunction ? Here is my current code</p>
<pre><code> <div className={`carousel-item ${post.id === 1 ? 'active' : ''}`}>
<img src="img/blog-slider.png" className="d-block w-100" alt="..." />
<div className="carousel-caption d-md-block">
<h5>MBG starts Their Journey</h5>
<p>Along with collecting as much data and information as possible, completing their research, and making their plan, the MBG team has now begun to implement their plan in detail, and they are in the initial steps. With the completion of any step, the MBG team will inform you about the latest news and information</p>
</div>
</div>
</code></pre>
|
[
{
"answer_id": 74471465,
"author": "KcH",
"author_id": 11737596,
"author_profile": "https://Stackoverflow.com/users/11737596",
"pm_score": 0,
"selected": false,
"text": "index"
},
{
"answer_id": 74471470,
"author": "Ali Sattarzadeh",
"author_id": 11434567,
"author_profile": "https://Stackoverflow.com/users/11434567",
"pm_score": 3,
"selected": true,
"text": "<div className={`carousel-item ${post.id == 1 ? 'active' : ''}`}>\n"
},
{
"answer_id": 74471511,
"author": "Libby Lebyane",
"author_id": 8664756,
"author_profile": "https://Stackoverflow.com/users/8664756",
"pm_score": 0,
"selected": false,
"text": "{this.state.trending.map((post, index) => {\nvar dt = post.CreatedAt;\n return (\n <>\n <div className={post.id == ‘1’ ? ‘carousel-item’ : ‘’>\n </>\n )\n })}\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471417",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5308126/"
] |
74,471,434
|
<pre><code>#include <stdio.h>
#include <omp.h>
static double num = 1;
double func1(){
for (int i=0; i<100; i++){
num += 1;
for (int j=0; j<100; j++){
num -= 1;
for (int k=0; k<100; k++){
num += 1;
if (num == 1000){
return num;
}
}
}
}
}
int main(){
#pragma omp parallel num_threads(10)
{
double num2 = func1();
}
printf("%lf", num2);
return 0;
}
/*
Compiles with: gcc fileName.c -o fileName -openmp
Executes with: ./fileName
// Note: in the terminal
*/
</code></pre>
<p>The above code when compiled gets stuck in an endless loop or something it does not exit.
I tried "#pragma omp parallel for" but it throws out an error.
I wonder if it works if I collapse the loop into one.
Would really appreciate help. Thanks.`</p>
|
[
{
"answer_id": 74471465,
"author": "KcH",
"author_id": 11737596,
"author_profile": "https://Stackoverflow.com/users/11737596",
"pm_score": 0,
"selected": false,
"text": "index"
},
{
"answer_id": 74471470,
"author": "Ali Sattarzadeh",
"author_id": 11434567,
"author_profile": "https://Stackoverflow.com/users/11434567",
"pm_score": 3,
"selected": true,
"text": "<div className={`carousel-item ${post.id == 1 ? 'active' : ''}`}>\n"
},
{
"answer_id": 74471511,
"author": "Libby Lebyane",
"author_id": 8664756,
"author_profile": "https://Stackoverflow.com/users/8664756",
"pm_score": 0,
"selected": false,
"text": "{this.state.trending.map((post, index) => {\nvar dt = post.CreatedAt;\n return (\n <>\n <div className={post.id == ‘1’ ? ‘carousel-item’ : ‘’>\n </>\n )\n })}\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471434",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20527299/"
] |
74,471,452
|
<p>Strange behaviour of data.table.</p>
<pre><code>library(data.table)
d<-data.table(a=1,b=2)
n<-names(d)
d[,c:=3,]
print(n)
</code></pre>
<p>Output:</p>
<pre><code> [1] "a" "b" "c"
</code></pre>
<p>This seems rather strange to me. Somehow the vector n is modified when adding columns to d.
Why is that?</p>
|
[
{
"answer_id": 74471465,
"author": "KcH",
"author_id": 11737596,
"author_profile": "https://Stackoverflow.com/users/11737596",
"pm_score": 0,
"selected": false,
"text": "index"
},
{
"answer_id": 74471470,
"author": "Ali Sattarzadeh",
"author_id": 11434567,
"author_profile": "https://Stackoverflow.com/users/11434567",
"pm_score": 3,
"selected": true,
"text": "<div className={`carousel-item ${post.id == 1 ? 'active' : ''}`}>\n"
},
{
"answer_id": 74471511,
"author": "Libby Lebyane",
"author_id": 8664756,
"author_profile": "https://Stackoverflow.com/users/8664756",
"pm_score": 0,
"selected": false,
"text": "{this.state.trending.map((post, index) => {\nvar dt = post.CreatedAt;\n return (\n <>\n <div className={post.id == ‘1’ ? ‘carousel-item’ : ‘’>\n </>\n )\n })}\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471452",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1901305/"
] |
74,471,453
|
<p>Hi everyone i am using java swing now.
I have a problem like this:
I have a pretty long piece of text and put it in a label with the <code><html></code> tag.</p>
<p><code><html> My text </html></code></p>
<p>If the text is too long, it will break the line according to the width of the label.
How to calculate the number of line breaks? or height needed to display text after line breaks</p>
<p>This is my code</p>
<pre class="lang-java prettyprint-override"><code>public Test() {
initComponents();
setPreferredSize(new Dimension(200, 200));
add(new JLabel("<html> "
+ "It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like)."
+ "</html>"));
}
</code></pre>
<p><img src="https://i.stack.imgur.com/oLV59.png" alt="enter image description here" /></p>
<p>How to know the exact height needed to display the text? </p>
|
[
{
"answer_id": 74472500,
"author": "Gilbert Le Blanc",
"author_id": 300257,
"author_profile": "https://Stackoverflow.com/users/300257",
"pm_score": 1,
"selected": false,
"text": "JTextArea"
},
{
"answer_id": 74472511,
"author": "Positronator",
"author_id": 20527747,
"author_profile": "https://Stackoverflow.com/users/20527747",
"pm_score": 0,
"selected": false,
"text": "String text = \"Your text here\";\nJLabel label = new JLabel(\"<html> \"\n + text\n + \"</html>\");\n//You can get very useful Information via the Font Metrics class\nFontMetrics fm = label.getFontMetrics(label.getFont());\n\n//Here you need a reference to your window so you can get the width of it.\n//Via the stringWidth function you get the width of the text when written as one line\n//Subtracting 40 is to counter the effect, that the text is broken after each line\n//The (int) (...) + 1 is just to round up\nint lines = (int) (fm.stringWidth(text) / (window.getWidth() - 40f)) + 1;\n\n//last you can set the window height however you like but watch out\n//since the window top margin has to be minded\nwindow.setSize(200, lines * fm.getHeight() + 30);\n"
},
{
"answer_id": 74508258,
"author": "Abra",
"author_id": 2164365,
"author_profile": "https://Stackoverflow.com/users/2164365",
"pm_score": 0,
"selected": false,
"text": "javax.swing.JLabel"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471453",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16804601/"
] |
74,471,550
|
<p>I have an array of object like this</p>
<pre><code>let data =
[
{
text: 'label'
},
{
text: 'username'
},
{
text: 'category'
},
{
text: 'book'
},
{
text: 'john'
},
{
text: 'education'
},
{
text: 'car'
},
{
text: 'doe'
},
{
text: 'automotive'
},
{
text: 'shoes'
},
{
text: 'cena'
},
{
text: 'fashion'
},
]
</code></pre>
<p>and my expect array of objects</p>
<pre><code>let result =
[
{
label: 'book',
username: 'john',
category: 'education'
},
{
label: 'car',
username: 'doe',
category: 'automotive'
},
{
label: 'shoes',
username: 'cena',
category: 'fashion'
},
]
</code></pre>
|
[
{
"answer_id": 74471654,
"author": "sm3sher",
"author_id": 8845480,
"author_profile": "https://Stackoverflow.com/users/8845480",
"pm_score": 0,
"selected": false,
"text": "switch-case"
},
{
"answer_id": 74471672,
"author": "flyingfox",
"author_id": 3176419,
"author_profile": "https://Stackoverflow.com/users/3176419",
"pm_score": 0,
"selected": false,
"text": "Array.slice()"
},
{
"answer_id": 74471864,
"author": "pilchard",
"author_id": 13762301,
"author_profile": "https://Stackoverflow.com/users/13762301",
"pm_score": 2,
"selected": true,
"text": "for"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471550",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12330085/"
] |
74,471,552
|
<p>I have sql query which will calculate the cumulative sum and etc. Below is the query</p>
<pre><code>SELECT
GRP,
category,
price,
units,
CASE WHEN customers > 10 THEN customers ELSE 0 END AS customers_adj,
1.00000 *(
SUM(customers_adj) OVER(PARTITION BY grp, category ORDER BY
FIGURE DESC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
))/ SUM(customers_adj) OVER (PARTITION BY grp, category) AS cum_max_price_cust
FROM
table_1
</code></pre>
<p>The issue is with the last column. It's returning error as SQL Error [100051] [22012]: Division by zero. Can anyone help me with this?</p>
|
[
{
"answer_id": 74471654,
"author": "sm3sher",
"author_id": 8845480,
"author_profile": "https://Stackoverflow.com/users/8845480",
"pm_score": 0,
"selected": false,
"text": "switch-case"
},
{
"answer_id": 74471672,
"author": "flyingfox",
"author_id": 3176419,
"author_profile": "https://Stackoverflow.com/users/3176419",
"pm_score": 0,
"selected": false,
"text": "Array.slice()"
},
{
"answer_id": 74471864,
"author": "pilchard",
"author_id": 13762301,
"author_profile": "https://Stackoverflow.com/users/13762301",
"pm_score": 2,
"selected": true,
"text": "for"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471552",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18158837/"
] |
74,471,560
|
<p>I have two lists:</p>
<pre><code>let cities = ["Istanbul", "Ankara", "Izmir"];
let filterVals = [true, false, false];
</code></pre>
<p>I need to filter cities using filterVals array.</p>
<p>In the example, I'm expecting only "Istanbul" for example.</p>
|
[
{
"answer_id": 74471591,
"author": "connexo",
"author_id": 3744304,
"author_profile": "https://Stackoverflow.com/users/3744304",
"pm_score": 3,
"selected": true,
"text": "cities.filter((city, index) => filterVals[index])\n"
},
{
"answer_id": 74471611,
"author": "Farbod Shabani",
"author_id": 14712252,
"author_profile": "https://Stackoverflow.com/users/14712252",
"pm_score": 2,
"selected": false,
"text": "let cities = [\"Istanbul\", \"Ankara\", \"Izmir\"];\nlet filterVals = [true, false, false];\n\n\nconst newCities = cities.filter((city, index) => filterVals[index]);\n\nconsole.log(newCities);"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471560",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8589270/"
] |
74,471,576
|
<p>Let's say I have a custom view inside of a sheet, something like this</p>
<pre><code>VStack {
Text("Title")
Text("Some very long text ...")
}
.padding()
.presentationDetents([.height(250)])
</code></pre>
<p>How can I get the exact height of the VStack and pass it to the presentationDetents modifier so that the height of the sheet is exactly the height of the content inside?</p>
|
[
{
"answer_id": 74471639,
"author": "jnpdx",
"author_id": 560942,
"author_profile": "https://Stackoverflow.com/users/560942",
"pm_score": 1,
"selected": false,
"text": "GeometryReader"
},
{
"answer_id": 74494816,
"author": "Tomas Gavenavičius",
"author_id": 19425640,
"author_profile": "https://Stackoverflow.com/users/19425640",
"pm_score": 0,
"selected": false,
"text": "struct ContentView: View {\n@State private var showingSheet = false\n\nlet heights = stride(from: 0.1, through: 1.0, by: 0.1).map { PresentationDetent.fraction($0) }\n\nvar body: some View {\n Button(\"Show Sheet\") {\n showingSheet.toggle()\n }\n .sheet(isPresented: $showingSheet) {\n Text(\"Random text \")\n .presentationDetents(Set(heights))\n }\n}\n"
},
{
"answer_id": 74495460,
"author": "Rahul Bir",
"author_id": 8250930,
"author_profile": "https://Stackoverflow.com/users/8250930",
"pm_score": 0,
"selected": false,
"text": "struct ContentView: View {\n @State private var showSheet = false\n @State private var sheetHeight: CGFloat = .zero\n\n var body: some View {\n Button(\"Open sheet\") {\n showSheet = true\n }\n .sheet(isPresented: $showSheet) {\n VStack {\n Text(\"Title\")\n Text(\"Some very long text ...\")\n }\n .padding()\n .overlay {\n GeometryReader { geometry in\n Color.clear.preference(key: InnerHeightPreferenceKey.self, value: geometry.size.height)\n }\n }\n .onPreferenceChange(InnerHeightPreferenceKey.self) { newHeight in\n sheetHeight = newHeight\n }\n .presentationDetents([.height(sheetHeight)])\n }\n }\n}\n\nstruct InnerHeightPreferenceKey: PreferenceKey {\n static var defaultValue: CGFloat = .zero\n static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) {\n value = nextValue()\n }\n}\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471576",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8250930/"
] |
74,471,616
|
<p>I'm working on a project using Webforms in Visual Studio where I'm building a quiz. Right now, I have all the questions on a single page. However, I want to transition this to have one question on the screen at a time, with a next and back button to let me switch between questions.</p>
<p>However, I want to try to keep this within the same <code>.aspx</code> file. Please let me know how I can achieve this! Please look below to see what my code looks like now. Thank you!</p>
<pre><code><p>Question 1</p>
<p>Text here</p>
<p>
<asp:Button ID="btnq1a" runat="server" OnClick="correct_click" Text="True" CssClass="btn btn-sm btn-default" /> <br>
<asp:Button ID="btnq1b" runat="server" Text="False" CssClass="btn btn-sm btn-default" />
</p>
<p>Question 2</p>
<p>Text here</p>
<p>
<asp:Button ID="btnq2a" runat="server" Text="answer 1" CssClass="btn btn-sm btn-default" /> <br>
<asp:Button ID="btnq2b" runat="server" Text="answer 2" CssClass="btn btn-sm btn-default" /> <br>
<asp:Button ID="btnq2c" runat="server" Text="answer 3" CssClass="btn btn-sm btn-default" /> <br>
<asp:Button ID="btnq2d" runat="server" OnClick="correct_click" Text="All of the above" CssClass="btn btn-sm btn-default" />
</p>
<p>Question 3</p>
<p>Text here</p>
<p>
<asp:Button ID="btnq3a" runat="server" OnClick="correct_click" Text="True" CssClass="btn btn-sm btn-default" /><br>
<asp:Button ID="btnq3b" runat="server" Text="False" CssClass="btn btn-sm btn-default" />
</p>
</code></pre>
<p>I am not sure where to even start. I tried researching various frames or instances of a page but could not find anything of substance, so I am turning to Stack Overflow!</p>
|
[
{
"answer_id": 74471639,
"author": "jnpdx",
"author_id": 560942,
"author_profile": "https://Stackoverflow.com/users/560942",
"pm_score": 1,
"selected": false,
"text": "GeometryReader"
},
{
"answer_id": 74494816,
"author": "Tomas Gavenavičius",
"author_id": 19425640,
"author_profile": "https://Stackoverflow.com/users/19425640",
"pm_score": 0,
"selected": false,
"text": "struct ContentView: View {\n@State private var showingSheet = false\n\nlet heights = stride(from: 0.1, through: 1.0, by: 0.1).map { PresentationDetent.fraction($0) }\n\nvar body: some View {\n Button(\"Show Sheet\") {\n showingSheet.toggle()\n }\n .sheet(isPresented: $showingSheet) {\n Text(\"Random text \")\n .presentationDetents(Set(heights))\n }\n}\n"
},
{
"answer_id": 74495460,
"author": "Rahul Bir",
"author_id": 8250930,
"author_profile": "https://Stackoverflow.com/users/8250930",
"pm_score": 0,
"selected": false,
"text": "struct ContentView: View {\n @State private var showSheet = false\n @State private var sheetHeight: CGFloat = .zero\n\n var body: some View {\n Button(\"Open sheet\") {\n showSheet = true\n }\n .sheet(isPresented: $showSheet) {\n VStack {\n Text(\"Title\")\n Text(\"Some very long text ...\")\n }\n .padding()\n .overlay {\n GeometryReader { geometry in\n Color.clear.preference(key: InnerHeightPreferenceKey.self, value: geometry.size.height)\n }\n }\n .onPreferenceChange(InnerHeightPreferenceKey.self) { newHeight in\n sheetHeight = newHeight\n }\n .presentationDetents([.height(sheetHeight)])\n }\n }\n}\n\nstruct InnerHeightPreferenceKey: PreferenceKey {\n static var defaultValue: CGFloat = .zero\n static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) {\n value = nextValue()\n }\n}\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471616",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19199808/"
] |
74,471,621
|
<p>I am trying to develop a device that changes the RGB led strips according to the colour of my display. To this, I am planning on screenshotting the screen and normalising/taking the mean of the colours of individual pixels in the display. I am having trouble normalising the image and taking out the average colour of the image. Here's the code I am using.</p>
<pre><code>import numpy as np
import cv2
import mss
import time
def getAverageColor(frame):
(B, G, R) = 0, 0, 0
for i in frame:
for j in i:
B += j[0]
G += j[1]
R += j[2]
B /= len(frame) * len(frame[0])
G /= len(frame) * len(frame[0])
R /= len(frame) * len(frame[0])
return (B, G, R)
with mss.mss() as sct:
# Grab frames in an endless lopp until q key is pressed
time.sleep(2)
# Iterate the list of monitors, and grab one frame from each monitor (ignore index 0)
for monitor_number, mon in enumerate(sct.monitors[1:]):
monitor = {"top": mon["top"], "left": mon["left"], "width": mon["width"], "height": mon["height"], "mon": monitor_number} # Not used in the example
# Grab the data
img = np.array(sct.grab(mon)) # BGRA Image (the format BGRA, at leat in Wiqndows 10).
print(getAverageColor(img))
# Show down-scaled image for testing
# The window name is img0, img1... applying different monitors.
cv2.imshow(f'img{monitor_number}', cv2.resize(img, (img.shape[1]//4, img.shape[0]//4)))
key = cv2.waitKey(1)
if key == ord('q'):
break
cv2.destroyAllWindows()
</code></pre>
<p>The program works fine but I would like to ask if there is any way o take out the average colour in openCV itself as my method is not very well recommended as it can be very slow in processing. Not to add this but the code is not very accurate as well.</p>
|
[
{
"answer_id": 74472602,
"author": "Cryptc_Slaughtr",
"author_id": 3572008,
"author_profile": "https://Stackoverflow.com/users/3572008",
"pm_score": 1,
"selected": false,
"text": "import pandas as pd\nfrom scipy.cluster.vq import whiten\nfrom scipy.cluster.vq import kmeans\n# import matplotlib.pyplot as plt\n\n\ndef getAverageColor(frame):\n r = []\n g = []\n b = []\n print(\"Frames\")\n for row in frame:\n for temp_r, temp_g, temp_b, temp in row:\n r.append(temp_r)\n g.append(temp_g)\n b.append(temp_b)\n \n df = pd.DataFrame({'r' : r, 'g' : g, 'b' : b})\n \n df['scaled_r'] = whiten(df['r'])\n df['scaled_b'] = whiten(df['b'])\n df['scaled_g'] = whiten(df['g'])\n \n cluster_centers, _ = kmeans(df[['scaled_r', 'scaled_b', 'scaled_g']], 3)\n \n dominant_colors = []\n \n r_std, g_std, b_std = df[['r', 'g', 'b']].std()\n \n for cluster_center in cluster_centers:\n red_scaled, green_scaled, blue_scaled = cluster_center\n dominant_colors.append((red_scaled * r_std / 255, green_scaled * g_std / 255, blue_scaled * b_std / 255))\n \n print(\"Dominant\", dominant_colors)\n return(dominant_colors[0])\n # plt.imshow([dominant_colors])\n # plt.show()\n"
},
{
"answer_id": 74481518,
"author": "Mark Setchell",
"author_id": 2836621,
"author_profile": "https://Stackoverflow.com/users/2836621",
"pm_score": 2,
"selected": false,
"text": "for"
},
{
"answer_id": 74491164,
"author": "Tanay Upreti",
"author_id": 19715706,
"author_profile": "https://Stackoverflow.com/users/19715706",
"pm_score": 1,
"selected": true,
"text": " def getAverageColor(frame):\n r = []\n g = []\n b = []\n print(\"Frames\")\n for row in frame:\n for pixel in row:\n r.append(pixel[0])\n g.append(pixel[1])\n b.append(pixel[2])\n\n r_mean = np.mean(r)\n g_mean = np.mean(g)\n b_mean = np.mean(b)\n \n return(r_mean, g_mean, b_mean)\n\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471621",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19715706/"
] |
74,471,632
|
<p>I got this code below to test out but it doesn't work the way it's supposed to.</p>
<p>Note that I'm using MacM1 and use vscode as IDE.</p>
<pre><code>fin = open("file.txt", "rt")
#output file to write the result to
fout = open("out.txt", "wt")
#for each line in the input file
for line in fin:
#read replace the string and write to output file
fout.write(line.replace('old', 'new'))
#close input and output files
fin.close()
fout.close()
</code></pre>
<p>I've the <code>file.txt</code> ready with strings in it including <code>'old'</code>.
Once I run the program, the new file <code>out.txt</code> was created but it is empty.
Vscode doesn't show errors so I don't know where to fix it.
Thanks!</p>
|
[
{
"answer_id": 74471703,
"author": "hide1nbush",
"author_id": 19825642,
"author_profile": "https://Stackoverflow.com/users/19825642",
"pm_score": 1,
"selected": false,
"text": "open"
},
{
"answer_id": 74471810,
"author": "Cobra",
"author_id": 17580381,
"author_profile": "https://Stackoverflow.com/users/17580381",
"pm_score": 0,
"selected": false,
"text": "with open('file.txt') as fin, open('out.txt', 'w') as fout:\n fout.write(fin.read().replace('old', 'new'))\n"
},
{
"answer_id": 74472368,
"author": "Oghli",
"author_id": 5169186,
"author_profile": "https://Stackoverflow.com/users/5169186",
"pm_score": 0,
"selected": false,
"text": "fin = open(\"file.txt\", \"rt\")\ndata = fin.read(4) # read the first 4 characters\ndata = fin.read() # read till end of file\ndata = fin.readline() # read one line of the file at current cursor\ndata = fin.readlines() # read till end of file line by line and return it in list\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471632",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20527509/"
] |
74,471,635
|
<p>I want the content of <code>{todo.title}</code> to be clickable and after clicked it should route to different page and display some more information. I want this to happen using <code><link></code> tag, route, and not <code><a></code>. I have done this using react and wanted url-param to be utilized while routing to next page.</p>
<p><a href="https://i.stack.imgur.com/bxCVa.png" rel="nofollow noreferrer">enter image description here</a></p>
<pre><code>import 'bootstrap/dist/css/bootstrap.min.css';
import React, { useEffect, useState } from 'react';
import { Route } from 'react-router-dom'
import './App.css';
//import TodoList from './components/TodoList';
function App() {
const [todos, setTodos] = useState([]);
const fetchData = () => {
fetch(`https://jsonplaceholder.typicode.com/todos?userId=1`)
.then((response) => response.json())
.then((actualData) => {
// console.log(actualData)
setTodos(actualData)
console.log(todos);
})
};
const updateData = (e) => {
const id = e.target.id;
const checked = e.target.checked;
console.log(id, checked);
if (checked) {
fetch('https://jsonplaceholder.typicode.com/todos/id', {
method: 'PATCH',
body: JSON.stringify({
completed: true,
}),
headers: {
'Content-type': 'application/json; charset=UTF-8',
},
})
.then((response) => response.json())
.then((json) => console.log(json));
} else {
fetch('https://jsonplaceholder.typicode.com/todos/id', {
method: 'PATCH',
body: JSON.stringify({
completed: false,
}),
headers: {
'Content-type': 'application/json; charset=UTF-8',
},
})
.then((response) => response.json())
.then((json) => console.log(json));
}
}
useEffect(() => {
fetchData();
}, [])
/*checked={todo.completed}*/
return (
<div >
<div className="window d-flex flex-column justify-content-center align-items-center">
<div className="d-flex flex-column align-items-center bg-info rounded border border-danger ">
<div className="p-2 "><h1>todo list</h1></div>
<div className="p-2 border border-danger">
<ul className="List-group">
{todos.map((todo) =>
<li className="list-group-item d-flex justify-content-between align-items-center" key={todo.id}>
{/*
<link to=''>{todo.title}</link>
*/ }
<a href='./more.js?id' >{todo.title}</a>
<input type='checkbox' id={todo.id} onChange={updateData} />
</li>)
}
</ul >
</div>
</div>
</div>
</div>
/* <div>
{
<TodoList todos={todos} />
}
</div>*/
);
}
export default App;
</code></pre>
|
[
{
"answer_id": 74471703,
"author": "hide1nbush",
"author_id": 19825642,
"author_profile": "https://Stackoverflow.com/users/19825642",
"pm_score": 1,
"selected": false,
"text": "open"
},
{
"answer_id": 74471810,
"author": "Cobra",
"author_id": 17580381,
"author_profile": "https://Stackoverflow.com/users/17580381",
"pm_score": 0,
"selected": false,
"text": "with open('file.txt') as fin, open('out.txt', 'w') as fout:\n fout.write(fin.read().replace('old', 'new'))\n"
},
{
"answer_id": 74472368,
"author": "Oghli",
"author_id": 5169186,
"author_profile": "https://Stackoverflow.com/users/5169186",
"pm_score": 0,
"selected": false,
"text": "fin = open(\"file.txt\", \"rt\")\ndata = fin.read(4) # read the first 4 characters\ndata = fin.read() # read till end of file\ndata = fin.readline() # read one line of the file at current cursor\ndata = fin.readlines() # read till end of file line by line and return it in list\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471635",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14595121/"
] |
74,471,657
|
<p>I use the python library Nvdlib which aims to extract information from Nist. Among these informations, I'm interested in the CPE and especially the api output.
Here is my code :</p>
<pre><code>import nvdlib
r = nvdlib.searchCVE(cveId='CVE-2019-19781')[0]
conf = r.configurations #list in ouput
for x in conf:
txt = ', '.join(str(x) for x in x.nodes) #transforme list to string
print(x)
</code></pre>
<p>output :</p>
<pre><code>{'operator': 'AND', 'negate': False, 'nodes': [{'operator': 'OR', 'negate': False, 'cpeMatch': [{'vulnerable': True, 'criteria': 'cpe:2.3:o:citrix:application_delivery_controller_firmware:10.5:*:*:*:*:*:*:*', 'matchCriteriaId': 'D56F2AAF-4658-484C-9A3A-D8A52BA5B10C'}, {'vulnerable': True, 'criteria': 'cpe:2.3:o:citrix:application_delivery_controller_firmware:11.1:*:*:*:*:*:*:*', 'matchCriteriaId': '8CE9E655-0D97-4DCF-AC2F-79DCD12770E5'}, {'vulnerable': True, 'criteria': 'cpe:2.3:o:citrix:application_delivery_controller_firmware:12.0:*:*:*:*:*:*:*', 'matchCriteriaId': '49454F7D-77B5-46DF-B95C-312AF2E68EAD'}, {'vulnerable': True, 'criteria': 'cpe:2.3:o:citrix:application_delivery_controller_firmware:12.1:*:*:*:*:*:*:*', 'matchCriteriaId': '201246D4-1E22-4F28-9683-D6A9FD0F7A6B'}, {'vulnerable': True, 'criteria': 'cpe:2.3:o:citrix:application_delivery_controller_firmware:13.0:*:*:*:*:*:*:*', 'matchCriteriaId': 'A3A50966-5554-4919-B6CE-BD8F6FF991D8'}]}, {'operator': 'OR', 'negate': False, 'cpeMatch': [{'vulnerable': False, 'criteria': 'cpe:2.3:h:citrix:application_delivery_controller:-:*:*:*:*:*:*:*', 'matchCriteriaId': '80E69E10-6F40-4FE4-9D84-F6C25EAB79D8'}]}]}
{'operator': 'AND', 'negate': False, 'nodes': [{'operator': 'OR', 'negate': False, 'cpeMatch': [{'vulnerable': True, 'criteria': 'cpe:2.3:o:citrix:netscaler_gateway_firmware:10.5:*:*:*:*:*:*:*', 'matchCriteriaId': '7E0FA8E2-3E8F-481E-8C39-FB00A9739DFC'}, {'vulnerable': True, 'criteria': 'cpe:2.3:o:citrix:netscaler_gateway_firmware:11.1:*:*:*:*:*:*:*', 'matchCriteriaId': 'A5D73B9A-59AA-4A38-AEAF-7EAB0965CD7E'}, {'vulnerable': True, 'criteria': 'cpe:2.3:o:citrix:netscaler_gateway_firmware:12.0:*:*:*:*:*:*:*', 'matchCriteriaId': 'B9F3ED0E-7F3D-477B-B645-77DA5FC7F502'}, {'vulnerable': True, 'criteria': 'cpe:2.3:o:citrix:netscaler_gateway_firmware:12.1:*:*:*:*:*:*:*', 'matchCriteriaId': '58349F8E-3177-413A-9CBE-BB454DCD31E4'}]}, {'operator': 'OR', 'negate': False, 'cpeMatch': [{'vulnerable': False, 'criteria': 'cpe:2.3:h:citrix:netscaler_gateway:-:*:*:*:*:*:*:*', 'matchCriteriaId': 'DEBB9B6A-1CAD-4D82-9B1E-939921986053'}]}]}
{'operator': 'AND', 'negate': False, 'nodes': [{'operator': 'OR', 'negate': False, 'cpeMatch': [{'vulnerable': True, 'criteria': 'cpe:2.3:o:citrix:gateway_firmware:13.0:*:*:*:*:*:*:*', 'matchCriteriaId': 'A80EAFB1-82DA-49BE-815D-D248624B442C'}]}, {'operator': 'OR', 'negate': False, 'cpeMatch': [{'vulnerable': False, 'criteria': 'cpe:2.3:h:citrix:gateway:-:*:*:*:*:*:*:*', 'matchCriteriaId': '3EF98B43-71DB-4230-B7AC-76EC2B1F0533'}]}]}
</code></pre>
<p>My procedure : I get the information, I transfer the output from "list" to string (I don't know if it's the best way) with the code above.</p>
<p>Then I delete the useless elements with a variable "to_delet_char = ["''", '""', "{" ,"}", "vulnerable", ": True, 'criteria': ", ", : ", "'", "]", ",", "OR negate:", "operator:", "False", "cpeMatch:", "[", "]", ]</p>
<p>And my goal would be to remove all the information other than "cpe" present in the outputs to have a result in the form of "list" or "dictionary" in which I will find only this kind of elements:</p>
<p>"cpe:2.3:o:citrix:netscaler_gateway_firmware:12.0:<em>:</em>:<em>:</em>:<em>:</em>"</p>
<p>I manage without difficulty to delete everything, however the Match serial ID being different each time I can't target it.</p>
<p>Would there be a solution via another library or not to "recover only" the cpe or to delete everything except the "cpe" and then transform them into a list or dictionary for the purpose of a database entry</p>
|
[
{
"answer_id": 74471872,
"author": "Sin Han Jinn",
"author_id": 12128167,
"author_profile": "https://Stackoverflow.com/users/12128167",
"pm_score": -1,
"selected": false,
"text": "nIndex = x.find('cpe')\n\nprint ((x[nIndex:].split())[0][:-2])\n"
},
{
"answer_id": 74472633,
"author": "Vilguax",
"author_id": 20511383,
"author_profile": "https://Stackoverflow.com/users/20511383",
"pm_score": 1,
"selected": true,
"text": "import nvdlib\nimport re\n\nr = nvdlib.searchCVE(cveId='CVE-2019-19781')[0]\n\nconf = r.configurations #output = list\n\nfor x in conf:\ntxt = ', '.join(str(x) for x in x.nodes) #transforme list to string\n\n#loop string startwith cpe:2.3:\nfor match in re.finditer(r'cpe:2.3:', txt):\n print(txt[match.start():].split()[0][:-2])\n"
},
{
"answer_id": 74472636,
"author": "Сергей Кох",
"author_id": 18400908,
"author_profile": "https://Stackoverflow.com/users/18400908",
"pm_score": 0,
"selected": false,
"text": "import nvdlib\n\nr = nvdlib.searchCVE(cveId='CVE-2019-19781')[0]\n\nconf = r.configurations\ncpes = []\nfor elem in conf:\n for el in elem.nodes:\n for e in el.cpeMatch:\n cpes.append(e.criteria)\nprint(cpes)\n\n['cpe:2.3:o:citrix:application_delivery_controller_firmware:10.5:*:*:*:*:*:*:*', 'cpe:2.3:o:citrix:application_delivery_controller_firmware:11.1:*:*:*:*:*:*:*', 'cpe:2.3:o:citrix:application_delivery_controller_firmware:12.0:*:*:*:*:*:*:*', 'cpe:2.3:o:citrix:application_delivery_controller_firmware:12.1:*:*:*:*:*:*:*', 'cpe:2.3:o:citrix:application_delivery_controller_firmware:13.0:*:*:*:*:*:*:*', 'cpe:2.3:h:citrix:application_delivery_controller:-:*:*:*:*:*:*:*', 'cpe:2.3:o:citrix:netscaler_gateway_firmware:10.5:*:*:*:*:*:*:*', 'cpe:2.3:o:citrix:netscaler_gateway_firmware:11.1:*:*:*:*:*:*:*', 'cpe:2.3:o:citrix:netscaler_gateway_firmware:12.0:*:*:*:*:*:*:*', 'cpe:2.3:o:citrix:netscaler_gateway_firmware:12.1:*:*:*:*:*:*:*', 'cpe:2.3:h:citrix:netscaler_gateway:-:*:*:*:*:*:*:*', 'cpe:2.3:o:citrix:gateway_firmware:13.0:*:*:*:*:*:*:*', 'cpe:2.3:h:citrix:gateway:-:*:*:*:*:*:*:*']\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20511383/"
] |
74,471,659
|
<p>I have an API that gets <code>count</code>. whenever user clicks on <code>IconButton</code> I must send the <code>count</code> to my server, but it always sends previous value. like if <code>count</code> is 1 it sends 0.</p>
<pre><code> const { fetchCalculatedService, response } = useCalcService();
const [count, setCount] = React.useState(0);
<IconButton
color="success"
disabled={!selectInsurance}
onClick={() => {
setCount((prev) => prev + 1);
fetchCalculatedService(
Date,
Id,
filter,
Time,
count
);
}}
>
<ArrowUpward />
</IconButton>
</code></pre>
<p>I logged my <code>response</code> and my <code>count</code> as well. the <code>count</code> is the lastest count and everthing is ok but API response shows <code>0</code> in count.</p>
<p>I also looked at server logs. API receives <code>0</code></p>
<p>shouldn't it get latest value of <code>count</code> whenever I call it? because value updated before <code>fetchCalculatedService</code> invoke</p>
|
[
{
"answer_id": 74471749,
"author": "Ali Sattarzadeh",
"author_id": 11434567,
"author_profile": "https://Stackoverflow.com/users/11434567",
"pm_score": 0,
"selected": false,
"text": " onClick={() => {\n setCount((prev) => {\n fetchCalculatedService(\n Date,\n Id,\n filter,\n Time,\n prev + 1\n );\n return prev + 1\n });\n\n }}\n"
},
{
"answer_id": 74471759,
"author": "sm3sher",
"author_id": 8845480,
"author_profile": "https://Stackoverflow.com/users/8845480",
"pm_score": 2,
"selected": true,
"text": "prev"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471659",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19869211/"
] |
74,471,666
|
<p>I am having <code>xlsx</code> file under the path <code>src/excel/data.xlsx</code> .</p>
<p>So I am trying to get the data from this excel and form array.</p>
<p><strong>Code tried:</strong></p>
<pre><code>import * as XLSX from "xlsx";
export function App() {
fetch("./excel/data.xlsx")
.then((res) => res.arrayBuffer())
.then((ab) => {
const wb = XLSX.read(ab, { type: "array" });
console.log("html ", wb);
});
return <div>Hello World</div>;
}
</code></pre>
<p><strong>Error:</strong></p>
<blockquote>
<p>Invalid HTML: could not find < table ></p>
</blockquote>
<p>If I give <em>correct path <code>./excel/data.xlsx</code> or wrong path <code>notvalid.xlsx</code></em> in this line <code>fetch("./excel/data.xlsx")</code> , then I get the same error like above, so I think it may be error due to path setting but I am not sure.</p>
<p><strong>Requirement:</strong></p>
<p>I am in the need to read the data from <code>excel/data.xlsx</code> file and get the data as array.</p>
<p><strong>Working Example:</strong></p>
<p><a href="https://codesandbox.io/s/old-lake-d2ygth?fontsize=14&hidenavigation=1&theme=dark" rel="nofollow noreferrer"><img src="https://codesandbox.io/static/img/play-codesandbox.svg" alt="Edit old-lake-d2ygth" /></a></p>
<p>Please help me to achieve the expected result.</p>
|
[
{
"answer_id": 74471713,
"author": "Dream Bold",
"author_id": 12743692,
"author_profile": "https://Stackoverflow.com/users/12743692",
"pm_score": 1,
"selected": false,
"text": "React.js"
},
{
"answer_id": 74471817,
"author": "Zehle",
"author_id": 5851085,
"author_profile": "https://Stackoverflow.com/users/5851085",
"pm_score": 1,
"selected": false,
"text": "fetch"
},
{
"answer_id": 74472258,
"author": "Jjagwe Dennis",
"author_id": 8620149,
"author_profile": "https://Stackoverflow.com/users/8620149",
"pm_score": 2,
"selected": true,
"text": "create-react-app"
},
{
"answer_id": 74472364,
"author": "Dream Bold",
"author_id": 12743692,
"author_profile": "https://Stackoverflow.com/users/12743692",
"pm_score": 0,
"selected": false,
"text": "public"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471666",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15916627/"
] |
74,471,696
|
<p>The latest version of spring boot is 2.7.5 from the Maven Repo is released .</p>
<p><a href="https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter" rel="nofollow noreferrer">https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter</a></p>
<p>Is spring boot 2.7.5 version stable version ? Can we use the sprint 2.7.5 version in projects .On what basis we can consider that this version is released and we can go ahead and start using the projects .Could anyone suggest on this please .</p>
|
[
{
"answer_id": 74471713,
"author": "Dream Bold",
"author_id": 12743692,
"author_profile": "https://Stackoverflow.com/users/12743692",
"pm_score": 1,
"selected": false,
"text": "React.js"
},
{
"answer_id": 74471817,
"author": "Zehle",
"author_id": 5851085,
"author_profile": "https://Stackoverflow.com/users/5851085",
"pm_score": 1,
"selected": false,
"text": "fetch"
},
{
"answer_id": 74472258,
"author": "Jjagwe Dennis",
"author_id": 8620149,
"author_profile": "https://Stackoverflow.com/users/8620149",
"pm_score": 2,
"selected": true,
"text": "create-react-app"
},
{
"answer_id": 74472364,
"author": "Dream Bold",
"author_id": 12743692,
"author_profile": "https://Stackoverflow.com/users/12743692",
"pm_score": 0,
"selected": false,
"text": "public"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471696",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10005690/"
] |
74,471,768
|
<p>How to convert more than 3 level N nested dictionary to levelled dataframe?</p>
<pre><code>input_dict = {
'.Stock': {
'.No[0]': '3241512)',
'.No[1]': '1111111111',
'.No[2]': '444444444444',
'.Version': '46',
'.Revision': '78'
},
'.Time': '12.11.2022'
}
</code></pre>
<p>what I expect:</p>
<pre><code>import pandas as pd
expected_df = pd.DataFrame([{'level_0': '.Stock', 'level_1': '.No_0', "value": '3241512'},
{'level_0': '.Stock', 'level_1': '.No_1', "value": '1111111111',},
{'level_0': '.Stock', 'level_1': '.No_2', "value": '444444444444'},
{'level_0': '.Stock', 'level_1': '.Version', "value": '46'},
{'level_0': '.Stock', 'level_1': '.Revision', "value": '78'},
{'level_0': '.Time', "value": '12.11.2022'}])
</code></pre>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>index</th>
<th>level_0</th>
<th>level_1</th>
<th>value</th>
</tr>
</thead>
<tbody>
<tr>
<td>0</td>
<td>.Stock</td>
<td>.No_0</td>
<td>3241512</td>
</tr>
<tr>
<td>1</td>
<td>.Stock</td>
<td>.No_1</td>
<td>1111111111</td>
</tr>
<tr>
<td>2</td>
<td>.Stock</td>
<td>.No_2</td>
<td>444444444444</td>
</tr>
<tr>
<td>3</td>
<td>.Stock</td>
<td>.Version</td>
<td>46</td>
</tr>
<tr>
<td>4</td>
<td>.Stock</td>
<td>.Revision</td>
<td>78</td>
</tr>
<tr>
<td>5</td>
<td>.Time</td>
<td>NaN</td>
<td>12.11.2022</td>
</tr>
</tbody>
</table>
</div>
<p>Firsly I need to convert nested dictionary to list of levelled dictionaries, than lastly convert list of dictionaries to dataframe. How can I convert, pls help me!</p>
<p>I've already tried the code below but it doesn't show exactly the right result.</p>
<pre><code>pd.DataFrame(input_dict).unstack().to_frame().reset_index()
</code></pre>
|
[
{
"answer_id": 74471713,
"author": "Dream Bold",
"author_id": 12743692,
"author_profile": "https://Stackoverflow.com/users/12743692",
"pm_score": 1,
"selected": false,
"text": "React.js"
},
{
"answer_id": 74471817,
"author": "Zehle",
"author_id": 5851085,
"author_profile": "https://Stackoverflow.com/users/5851085",
"pm_score": 1,
"selected": false,
"text": "fetch"
},
{
"answer_id": 74472258,
"author": "Jjagwe Dennis",
"author_id": 8620149,
"author_profile": "https://Stackoverflow.com/users/8620149",
"pm_score": 2,
"selected": true,
"text": "create-react-app"
},
{
"answer_id": 74472364,
"author": "Dream Bold",
"author_id": 12743692,
"author_profile": "https://Stackoverflow.com/users/12743692",
"pm_score": 0,
"selected": false,
"text": "public"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471768",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11742456/"
] |
74,471,770
|
<p>In this <a href="https://stackoverflow.com/a/40067240/16237416">answer</a>, the user gave a very clear example on how classes and methods work together.</p>
<p>I will reprint the example here:</p>
<pre class="lang-lisp prettyprint-override"><code>
(defclass human () ())
(defclass dog () ())
(defmethod greet ((thing human))
(print "Hi human!"))
(defmethod greet ((thing dog))
(print "Wolf-wolf dog!"))
(defparameter Anna (make-instance 'human))
(defparameter Rex (make-instance 'dog))
(greet Anna) ;; => "Hi human"
(greet Rex) ;; => "Wolf-wolf dog!"
</code></pre>
<p>My question is, using the same example:</p>
<ol>
<li>What value would creating a generic functions add?</li>
<li>Why are generic functions useful? Are they like instances in other OO languages that provide structure?</li>
</ol>
<p>It seems that generic functions are created in the background implicitly (not 100% sure). I notice that when I play with this example, if I create a method that has a different param structure than the first instance of the method, I get a <code>generic function error</code>.</p>
|
[
{
"answer_id": 74471992,
"author": "Rainer Joswig",
"author_id": 69545,
"author_profile": "https://Stackoverflow.com/users/69545",
"pm_score": 2,
"selected": false,
"text": "FUNCTION"
},
{
"answer_id": 74472874,
"author": "coredump",
"author_id": 124319,
"author_profile": "https://Stackoverflow.com/users/124319",
"pm_score": 4,
"selected": true,
"text": "talk"
},
{
"answer_id": 74517749,
"author": "ignis volens",
"author_id": 17026934,
"author_profile": "https://Stackoverflow.com/users/17026934",
"pm_score": 2,
"selected": false,
"text": "defmethod"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471770",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16237416/"
] |
74,471,797
|
<p>If I have array of string like</p>
<pre><code>const arrayOfString=["Ajay Choudhary","Charlli Chouhan","Kerri Cilce","Dalis Menary"];
</code></pre>
<p>How to get name which has startswith C and surname startswith C
like my output will be</p>
<pre><code>Ajay Choudhary
Charlli Chouhan
Kerri Cilce
</code></pre>
<p>I have tried below but it does not give expected output</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>const arrayOfString = ["Ajay Choudhary", "Charlli Chouhan", "Kerri Cilce", "Dalis Menary"];
arrayOfString.forEach(element => {
//console.log(element);
if (element.startsWith("C")) {
//console.log(element);
}
if (element.charAt(element.charAt(-1)).startsWith("C")) {
console.log(element);
}
});</code></pre>
</div>
</div>
</p>
|
[
{
"answer_id": 74471846,
"author": "Justinas",
"author_id": 1346234,
"author_profile": "https://Stackoverflow.com/users/1346234",
"pm_score": 1,
"selected": false,
"text": "C"
},
{
"answer_id": 74472043,
"author": "mplungjan",
"author_id": 295783,
"author_profile": "https://Stackoverflow.com/users/295783",
"pm_score": 1,
"selected": true,
"text": "const arrayOfString = [\"Ajay Choudhary\", \"Charlli Chouhan\", \"Kerri Cilce\", \"Dalis Menary\"];\n\nconst cNames = arrayOfString.filter(name => name.includes(\"C\"))\nconsole.log(cNames)"
},
{
"answer_id": 74472173,
"author": "Ali Sattarzadeh",
"author_id": 11434567,
"author_profile": "https://Stackoverflow.com/users/11434567",
"pm_score": 0,
"selected": false,
"text": "arrayOfString.filter(name=>name.split(' ').filter(n => n.startsWith('C')).length > 0)\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19812559/"
] |
74,471,816
|
<p>I am really not sure why I am seeing this error. I know it's something simple and right in my face . My issue is how I am passing on the <code>subnet_id</code> in the subnet_mapping block. This is the code below:</p>
<p><code>main.tf</code></p>
<pre><code>resource "aws_lb" "lb" {
name = var.name
internal = var.internal
load_balancer_type = var.lb_type
enable_cross_zone_load_balancing = var.enable_cross_zone_load_balancing
subnet_mapping {
allocation_id = aws_eip.lb.id
subnet_id = var.subnet_id[1]
}
}
resource "aws_eip" "lb" {
vpc = true
}
</code></pre>
<p><code>variables.tf</code></p>
<pre><code>variable "name" {
type = string
}
variable "internal" {
type = bool
default = false
}
variable "lb_type" {
type = string
default = "network"
}
variable "enable_cross_zone_load_balancing" {
type = bool
default = true
}
variable "vpc" {
type = bool
default = true
}
variable "vpc_id" {
type = string
}
variable "subnet_id" {
type = list(string)
default = []
}
</code></pre>
<p><code>terragrunt.hcl</code></p>
<pre><code>include {
path = find_in_parent_folders()
}
dependency "test" {
config_path = "../../../folder/test"
mock_outputs = {
vpc_id = "vpc-12345"
public_subnet_ids = ["subnet-1", "subnet-2"]
}
}
# var to pass in to use the module specified in the terragrunt configuration above
inputs = {
vpc_id = dependency.test.outputs.vpc_id
subnet_id = dependency.test.outputs.public_subnet_ids[1]
xxx...
</code></pre>
<p>Terragrunt error</p>
<pre><code>Error: Variables not allowed
on <value for var.subnet_id> line 1:
(source code not available)
Variables may not be used here.
</code></pre>
<p>I would appreciate some feedback. It has been a pain for the past few hours.</p>
|
[
{
"answer_id": 74471846,
"author": "Justinas",
"author_id": 1346234,
"author_profile": "https://Stackoverflow.com/users/1346234",
"pm_score": 1,
"selected": false,
"text": "C"
},
{
"answer_id": 74472043,
"author": "mplungjan",
"author_id": 295783,
"author_profile": "https://Stackoverflow.com/users/295783",
"pm_score": 1,
"selected": true,
"text": "const arrayOfString = [\"Ajay Choudhary\", \"Charlli Chouhan\", \"Kerri Cilce\", \"Dalis Menary\"];\n\nconst cNames = arrayOfString.filter(name => name.includes(\"C\"))\nconsole.log(cNames)"
},
{
"answer_id": 74472173,
"author": "Ali Sattarzadeh",
"author_id": 11434567,
"author_profile": "https://Stackoverflow.com/users/11434567",
"pm_score": 0,
"selected": false,
"text": "arrayOfString.filter(name=>name.split(' ').filter(n => n.startsWith('C')).length > 0)\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471816",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12678186/"
] |
74,471,856
|
<p>I'm working on a Google Sheets spreadsheet that uses MAXIFS, MINIFS, etc. I have one table that contains primary keys and non-unique numerical values associated with each key. I also have a filtered list of primary keys that I want to search. The following examples are simplified versions of what I have:</p>
<p><strong>Table 1</strong></p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>People</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>Alice</td>
<td>413</td>
</tr>
<tr>
<td>Bob</td>
<td>612</td>
</tr>
<tr>
<td>Carol</td>
<td>612</td>
</tr>
<tr>
<td>Dylan</td>
<td>1111</td>
</tr>
<tr>
<td>Eve</td>
<td>413</td>
</tr>
<tr>
<td>Frank</td>
<td>612</td>
</tr>
</tbody>
</table>
</div>
<p><strong>Table 2</strong></p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>People to Lookup</th>
</tr>
</thead>
<tbody>
<tr>
<td>Alice</td>
</tr>
<tr>
<td>Carol</td>
</tr>
<tr>
<td>Eve</td>
</tr>
</tbody>
</table>
</div>
<p>My goal is to look through Table 1 for the primary keys specified in Table 2, get the corresponding values from Table 1 in Column B, and then perform an operation on those values. For example, I need to use MAX, so it would yield "612" as the result, since that is the largest value in the specified list. I also want to use MIN, AVG, and MODE, if possible.</p>
<p>What formulas do I need to use to achieve this result? Do I need to make proxy tables or have some other helper tool?</p>
<p>I've tried looking up ways to use MAXIFS, VLOOKUP, and MATCH, but I'm either using the wrong formulas or putting in the wrong ranges. I've tried =MAXIFS('Table 1'!$B$2:$B, 'Table 1'!$A$2:$A, 'Table 2'!$A$2:$A), but this results in an error. Maybe I could iterate VLOOKUP for all of the items in Table 2? Or maybe MATCH would be a better fit? Any help is greatly appreciated. Thanks!</p>
|
[
{
"answer_id": 74471846,
"author": "Justinas",
"author_id": 1346234,
"author_profile": "https://Stackoverflow.com/users/1346234",
"pm_score": 1,
"selected": false,
"text": "C"
},
{
"answer_id": 74472043,
"author": "mplungjan",
"author_id": 295783,
"author_profile": "https://Stackoverflow.com/users/295783",
"pm_score": 1,
"selected": true,
"text": "const arrayOfString = [\"Ajay Choudhary\", \"Charlli Chouhan\", \"Kerri Cilce\", \"Dalis Menary\"];\n\nconst cNames = arrayOfString.filter(name => name.includes(\"C\"))\nconsole.log(cNames)"
},
{
"answer_id": 74472173,
"author": "Ali Sattarzadeh",
"author_id": 11434567,
"author_profile": "https://Stackoverflow.com/users/11434567",
"pm_score": 0,
"selected": false,
"text": "arrayOfString.filter(name=>name.split(' ').filter(n => n.startsWith('C')).length > 0)\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471856",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20526820/"
] |
74,471,889
|
<pre><code>$ourfilesdata = Get-Content "P:\myfiles\details.txt"
foreach ($i in $ourfilesdata )
{
if ( $i -match '\Mobile\b') {continue)
{
Write-Output "$i"
}
}
</code></pre>
<p>**My input is like 50 lines **</p>
<pre><code>aaaaaaa
bbbbb
Request
Mobile
Sim
datacard
internet
ccccccc
dddddddd
fffffff
</code></pre>
<p><strong>Output</strong></p>
<pre><code>mobile
sim
datacard
internet
</code></pre>
<p><strong>Note</strong> :- These input lines are horizontal fashion in my file</p>
|
[
{
"answer_id": 74471846,
"author": "Justinas",
"author_id": 1346234,
"author_profile": "https://Stackoverflow.com/users/1346234",
"pm_score": 1,
"selected": false,
"text": "C"
},
{
"answer_id": 74472043,
"author": "mplungjan",
"author_id": 295783,
"author_profile": "https://Stackoverflow.com/users/295783",
"pm_score": 1,
"selected": true,
"text": "const arrayOfString = [\"Ajay Choudhary\", \"Charlli Chouhan\", \"Kerri Cilce\", \"Dalis Menary\"];\n\nconst cNames = arrayOfString.filter(name => name.includes(\"C\"))\nconsole.log(cNames)"
},
{
"answer_id": 74472173,
"author": "Ali Sattarzadeh",
"author_id": 11434567,
"author_profile": "https://Stackoverflow.com/users/11434567",
"pm_score": 0,
"selected": false,
"text": "arrayOfString.filter(name=>name.split(' ').filter(n => n.startsWith('C')).length > 0)\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471889",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9299447/"
] |
74,471,905
|
<p>My prettier can't auto wrap line and add bracket,</p>
<p>before I save:</p>
<pre><code>function MyApp({ Component, pageProps }) {
return (<Layout><Component {...pageProps} /></Layout>)
}
</code></pre>
<p>I want the code become like this when save:</p>
<pre><code>function MyApp({ Component, pageProps }) {
return (
<Layout>
<Component {...pageProps} />
</Layout>
)
}
</code></pre>
<p>I tried to reinstall prettier but it didn't work, I don't know if there is something changed.
I had install ESLint too. Not sure is it the problem</p>
|
[
{
"answer_id": 74471846,
"author": "Justinas",
"author_id": 1346234,
"author_profile": "https://Stackoverflow.com/users/1346234",
"pm_score": 1,
"selected": false,
"text": "C"
},
{
"answer_id": 74472043,
"author": "mplungjan",
"author_id": 295783,
"author_profile": "https://Stackoverflow.com/users/295783",
"pm_score": 1,
"selected": true,
"text": "const arrayOfString = [\"Ajay Choudhary\", \"Charlli Chouhan\", \"Kerri Cilce\", \"Dalis Menary\"];\n\nconst cNames = arrayOfString.filter(name => name.includes(\"C\"))\nconsole.log(cNames)"
},
{
"answer_id": 74472173,
"author": "Ali Sattarzadeh",
"author_id": 11434567,
"author_profile": "https://Stackoverflow.com/users/11434567",
"pm_score": 0,
"selected": false,
"text": "arrayOfString.filter(name=>name.split(' ').filter(n => n.startsWith('C')).length > 0)\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471905",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19876880/"
] |
74,471,921
|
<p>I want to simplify a process where a non-privileged person needs to encrypt data with a symmetric key (AES-GCM) and give me the result. Non-privileged simply means the person has no access to the encryption key.</p>
<p>With asymmetric cryptos like RSA and EC, giving anyone the public key is of course part of the whole idea, but with symmetric cryptos, the privileged party is the only one who can decrypt <em>or</em> encrypt, obviously.</p>
<p>To simplify my workflow I'm considering setting up a simple HTTP endpoint that encrypts a given string using my private symmetric key and returns the result. Something like</p>
<pre><code>GET somewhere.com/encrypt?keyId=foo&data=Hello%20world
</code></pre>
<p>which would return something like</p>
<pre><code>{
"keyId": "foo",
"encryptedData": "xxxxxx"
}
</code></pre>
<p>Behind the scenes, this could be an AWS Lambda function using a KMS key designated by <code>keyId</code> to encrypt <code>data</code> and return the encrypted result.</p>
<p>However, I want to be sure this is not a security problem in itself. For example, is there a known attack where someone can find out the key material for AES from encrypting billions of strings and then processing the source strings and their encrypted counterparts? In other words, would exposing an encryption endpoint be a problem?</p>
|
[
{
"answer_id": 74471846,
"author": "Justinas",
"author_id": 1346234,
"author_profile": "https://Stackoverflow.com/users/1346234",
"pm_score": 1,
"selected": false,
"text": "C"
},
{
"answer_id": 74472043,
"author": "mplungjan",
"author_id": 295783,
"author_profile": "https://Stackoverflow.com/users/295783",
"pm_score": 1,
"selected": true,
"text": "const arrayOfString = [\"Ajay Choudhary\", \"Charlli Chouhan\", \"Kerri Cilce\", \"Dalis Menary\"];\n\nconst cNames = arrayOfString.filter(name => name.includes(\"C\"))\nconsole.log(cNames)"
},
{
"answer_id": 74472173,
"author": "Ali Sattarzadeh",
"author_id": 11434567,
"author_profile": "https://Stackoverflow.com/users/11434567",
"pm_score": 0,
"selected": false,
"text": "arrayOfString.filter(name=>name.split(' ').filter(n => n.startsWith('C')).length > 0)\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471921",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1226020/"
] |
74,471,941
|
<p>Hey I am working on an application Where I have two Buttons "Call Now" and "Chat Now". Generally We only show one button "Chat Now". If User Provide check "show call button" option then we will show both buttons. Otherwise only Chat Now Button will show. But the problem is in design if user enable call button then it will look like this</p>
<p>like this.</p>
<p><a href="https://i.stack.imgur.com/sJ5Ei.jpg" rel="nofollow noreferrer">How it should look</a></p>
<p>but the problem is that when i show the both it looks good but when i show only the Chat Now button it look weird while it should be.
like this</p>
<p><a href="https://i.stack.imgur.com/x48XD.jpg" rel="nofollow noreferrer">How it is looking</a></p>
<p><strong>XML CODE</strong></p>
<pre><code><LinearLayout
android:id="@+id/callNowLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2"
android:layout_marginTop="300dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<Button
android:id="@+id/callNow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp"
android:layout_weight="1"
android:backgroundTint="#FF5722"
android:padding="10dp"
android:text="Call Now"
android:textAllCaps="false"
android:textColor="@color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="@+id/chatNow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="10dp"
android:layout_weight="1"
android:padding="10dp"
android:text="Chat Now"
android:backgroundTint="#FF5722"
android:textAllCaps="false"
android:textColor="@color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/callNow" />
</LinearLayout>
</code></pre>
|
[
{
"answer_id": 74472147,
"author": "Somnath",
"author_id": 15660680,
"author_profile": "https://Stackoverflow.com/users/15660680",
"pm_score": 1,
"selected": false,
"text": "<LinearLayout\n android:id=\"@+id/callNowLayout\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"wrap_content\"\n android:orientation=\"horizontal\"\n android:weightSum=\"2\"\n android:layout_marginTop=\"300dp\"\n app:layout_constraintEnd_toEndOf=\"parent\"\n app:layout_constraintStart_toStartOf=\"parent\"\n app:layout_constraintTop_toTopOf=\"parent\">\n\n <Button\n android:id=\"@+id/callNow\"\n android:layout_width=\"0dp\"\n android:layout_weight=\"1\"\n android:layout_height=\"wrap_content\"\n android:layout_marginLeft=\"10dp\"\n android:layout_marginRight=\"5dp\"\n android:layout_weight=\"1\"\n android:backgroundTint=\"#FF5722\"\n android:padding=\"10dp\"\n android:text=\"Call Now\"\n android:textAllCaps=\"false\"\n android:textColor=\"@color/white\"\n app:layout_constraintBottom_toBottomOf=\"parent\"\n app:layout_constraintStart_toStartOf=\"parent\" />\n\n\n <Button\n android:id=\"@+id/chatNow\"\n android:layout_width=\"0dp\"\n android:layout_weight=\"1\"\n android:layout_height=\"wrap_content\"\n android:layout_marginLeft=\"5dp\"\n android:layout_marginRight=\"10dp\"\n android:layout_weight=\"1\"\n android:padding=\"10dp\"\n android:text=\"Chat Now\"\n android:backgroundTint=\"#FF5722\"\n android:textAllCaps=\"false\"\n android:textColor=\"@color/white\"\n app:layout_constraintBottom_toBottomOf=\"parent\"\n app:layout_constraintEnd_toEndOf=\"parent\"\n app:layout_constraintStart_toEndOf=\"@+id/callNow\" />\n\n\n</LinearLayout>\n"
},
{
"answer_id": 74473711,
"author": "Sandesh KhutalSaheb",
"author_id": 18362930,
"author_profile": "https://Stackoverflow.com/users/18362930",
"pm_score": 3,
"selected": true,
"text": "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n android:id=\"@+id/callNowLayout\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"wrap_content\"\n android:layout_marginTop=\"300dp\"\n android:orientation=\"horizontal\"\n android:weightSum=\"2\">\n\n <Button\n android:id=\"@+id/callNow\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"wrap_content\"\n android:layout_margin=\"5dp\"\n android:layout_weight=\"1\"\n android:backgroundTint=\"#FF5722\"\n android:text=\"Call Now\"\n android:textAllCaps=\"false\"\n android:textColor=\"@color/white\" />\n\n\n <Button\n android:id=\"@+id/chatNow\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"wrap_content\"\n android:layout_margin=\"5dp\"\n android:layout_weight=\"1\"\n android:backgroundTint=\"#FF5722\"\n android:text=\"Chat Now\"\n android:textAllCaps=\"false\"\n android:textColor=\"@color/white\" />\n\n\n</LinearLayout>\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471941",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20397293/"
] |
74,471,946
|
<p>H1 I have written a little process to save data before <code>Application.Terminate</code> using <code>OnCloseQuery</code>. I was wondering whether this is sufficient in the event of a power failure or a computer crash.</p>
<pre><code>type
TForm1 = class(TForm)
abs: TABSDatabase;
ABSTable1: TABSTable;
....
ABSTable6: TABSTable;
....
var
Form1: TForm1;
isBusy : Boolean;
....
procedure TForm1.CloseTables;
var
x : Integer;
dummy : TABSTable;
begin
for x:=0 to ComponentCount-1 do
begin
if Components[x] is TABSDataSet then
begin
if Components[x] is TABSTable then
begin
dummy := (Components[x] as TABSTable);
if ((dummy.Active = True) and ((dummy.state = dsEdit) or (dummy.State = dsInsert))) then
begin
dummy.Post;
dummy.Active := False;
end
else
if dummy. Active = True then dummy.Close;
end;
end;
end;
end;
procedure TForm1.FormActivate(Sender: TObject);
begin
if abs.Connected = True then isBusy := True else isBusy := False;
end;
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
if isBusy = True then
begin
CanClose := False;
CloseTables;
abs.Connected := False;
isBusy := False;
Application.Terminate;
end
else CanClose := True;
end;
</code></pre>
<p>Thank you in advance.</p>
<p><strong>Edit</strong></p>
<p>I modified my code following David Heffernan's advice.</p>
<pre><code>procedure TForm1.CloseTables;
var
x : Integer;
dummy : TABSTable;
begin
for x:=0 to ComponentCount-1 do
begin
if Components[x] is TABSDataSet then
begin
if Components[x] is TABSTable then
begin
dummy := (Components[x] as TABSTable);
if ((dummy.Active) and ((dummy.state = dsEdit) or (dummy.State = dsInsert))) then
begin
dummy.Post;
dummy.Active := False;
end
else
if dummy.Active then dummy.Close;
end;
end;
end;
end;
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
if abs.Connected then
begin
CanClose := False;
CloseTables;
abs.Connected := False;
Application.Terminate;
end
else CanClose := True;
end;
</code></pre>
|
[
{
"answer_id": 74479437,
"author": "AmigoJack",
"author_id": 4299358,
"author_profile": "https://Stackoverflow.com/users/4299358",
"pm_score": 1,
"selected": false,
"text": "OnCloseQuery"
},
{
"answer_id": 74497603,
"author": "Philip J. Rayment",
"author_id": 2377758,
"author_profile": "https://Stackoverflow.com/users/2377758",
"pm_score": 0,
"selected": false,
"text": "COMMIT"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471946",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14878056/"
] |
74,471,962
|
<p>I am using pandas and np.where to fill a new column if multiple conditions are met.</p>
<p>For this I am using the following database (but then 100 times bigger).</p>
<p><a href="https://i.stack.imgur.com/6s6dv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6s6dv.png" alt="enter image description here" /></a></p>
<p>What I am doing now is:</p>
<pre><code>df['new_column'] = np.where((df['year'] == 2018) & (df['price'] > 30000) & (df['fuel description'] == Petrol), 12, 10)
df['new_column'] = np.where((df['year'] == 2019) & (df['price'] > 30000) & (df['fuel description'] == Petrol), 15, 10)
df['new_column'] = np.where((df['year'] == 2020) & (df['price'] > 30000) & (df['fuel description'] == Petrol), 18, 10)
df['new_column'] = np.where((df['year'] == 2021) & (df['price'] > 30000) & (df['fuel description'] == Petrol), 21, 10)
df['new_column'] = np.where((df['year'] == 2022) & (df['price'] > 30000) & (df['fuel description'] == Petrol), 24, 10)
</code></pre>
<p>As you can see I am only changing the condition for the column: "year".</p>
<p>I am looking for an efficient way to use the other two conditions (price and fuel description) because I am just copying them now.</p>
<p>Looking forward to your answers!</p>
|
[
{
"answer_id": 74472030,
"author": "ILS",
"author_id": 10017662,
"author_profile": "https://Stackoverflow.com/users/10017662",
"pm_score": 2,
"selected": false,
"text": "condition = (df['year'] >= 2018) & (df['year'] <= 2022) & (df['price'] > 30000) \\\n & (df['fuel description'] == Petrol)\ndf['new_column'] = np.where(condition, 12 + (df['year']-2018)*3, 10)\n"
},
{
"answer_id": 74472124,
"author": "Nazar Nintendo",
"author_id": 20524194,
"author_profile": "https://Stackoverflow.com/users/20524194",
"pm_score": 1,
"selected": false,
"text": "def get_year_condition(df, year):\n return df['year'] == year & df['price'] > 30000 & df['fuel description'] == 'Petrol'\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471962",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13680411/"
] |
74,471,970
|
<p>I am new to bash and just ran into</p>
<pre><code>local name=; name = $("something", "something")
</code></pre>
<p>Can someone please explain what =; means?</p>
<p>I have tried to google it, but cannot find any explanation.</p>
|
[
{
"answer_id": 74472013,
"author": "Some programmer dude",
"author_id": 440558,
"author_profile": "https://Stackoverflow.com/users/440558",
"pm_score": 1,
"selected": false,
"text": ";"
},
{
"answer_id": 74472054,
"author": "axiac",
"author_id": 4265352,
"author_profile": "https://Stackoverflow.com/users/4265352",
"pm_score": 0,
"selected": false,
"text": "=;"
},
{
"answer_id": 74472070,
"author": "user1934428",
"author_id": 1934428,
"author_profile": "https://Stackoverflow.com/users/1934428",
"pm_score": 2,
"selected": true,
"text": "local name=; ...\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74471970",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15611043/"
] |
74,472,004
|
<p>I've a mysql table with me</p>
<p><a href="https://i.stack.imgur.com/5Ak6E.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5Ak6E.png" alt="enter image description here" /></a></p>
<p>Now we want to do some calculations like this</p>
<ul>
<li>count date wise for all courses enrolled</li>
<li>count where course id = 2 for date > start_date AND date < end_date</li>
</ul>
<p><em>Expected output where we calculate all courses enrolled</em></p>
<p><a href="https://i.stack.imgur.com/5Ij3p.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5Ij3p.png" alt="Expected output where we calculate all courses enrolled" /></a></p>
<p><em>Expected output where we calculate all courses enrolled where course id = 2</em></p>
<p>*<a href="https://i.stack.imgur.com/Z5n8s.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Z5n8s.png" alt="enter image description here" /></a></p>
<p><em>expected output where course_id = 2 AND date range is between 2022-11-15 to 2022-11-13</em></p>
<p><a href="https://i.stack.imgur.com/4VNa8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4VNa8.png" alt="enter image description here" /></a></p>
<p><strong>The query which I've right now</strong></p>
<pre><code>SELECT COUNT(*), DATE(registered_on)
FROM courses_enrolled
WHERE course_id = 1
GROUP BY DATE(registered_on), course_id
ORDER BY registered_on desc;
</code></pre>
|
[
{
"answer_id": 74472013,
"author": "Some programmer dude",
"author_id": 440558,
"author_profile": "https://Stackoverflow.com/users/440558",
"pm_score": 1,
"selected": false,
"text": ";"
},
{
"answer_id": 74472054,
"author": "axiac",
"author_id": 4265352,
"author_profile": "https://Stackoverflow.com/users/4265352",
"pm_score": 0,
"selected": false,
"text": "=;"
},
{
"answer_id": 74472070,
"author": "user1934428",
"author_id": 1934428,
"author_profile": "https://Stackoverflow.com/users/1934428",
"pm_score": 2,
"selected": true,
"text": "local name=; ...\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472004",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2349594/"
] |
74,472,032
|
<p>I'm trying to download PDF with SVG content using jsPDF library, it is able to download the file, but there is no content inside it, it is empty PDF.</p>
<p>This is my code:</p>
<pre><code>const downloadPDF = (goJSDiagram) => {
const svg = goJSDiagram.makeSvg({scale: 1, background: "white"});
const svgStr = new XMLSerializer().serializeToString(svg);
const pdfDoc = new jsPDF();
pdfDoc.addSvgAsImage(svgStr, 0, 0, pdfDoc.internal.pageSize.width, pdfDoc.internal.pageSize.height)
pdfDoc.save(props.model[0].cName?.split(" (")[0] + ".pdf");
}
</code></pre>
<p>When I do <code>console.log(svgStr)</code>, I can see the SVG XML string. What changes should I make to render the content inside PDF?</p>
|
[
{
"answer_id": 74475305,
"author": "this.srivastava",
"author_id": 6909182,
"author_profile": "https://Stackoverflow.com/users/6909182",
"pm_score": 2,
"selected": true,
"text": " const waitForImage = imgElem => new Promise(resolve => imgElem.complete ? resolve() : imgElem.onload = imgElem.onerror = resolve);\n\n const downloadPDF = async (goJSDiagram) => {\n const svg = goJSDiagram.makeSvg({scale: 1, background: \"white\"});\n const svgStr = new XMLSerializer().serializeToString(svg);\n const img = document.createElement('img');\n img.src = 'data:image/svg+xml;base64,' + window.btoa(svgStr);\n\n waitForImage(img)\n .then(_ => {\n const canvas = document.createElement('canvas');\n canvas.width = 500;\n canvas.height = 500;\n canvas.getContext('2d').drawImage(img, 0, 0, 500, 500);\n const pdfDoc = new jsPDF('p', 'pt', 'a4');\n pdfDoc.addImage(canvas.toDataURL('image/png', 1.0), 0, 200, 500, 500);\n pdfDoc.save(props.model[0].cName?.split(\" (\")[0] + \".pdf\");\n });\n }\n"
},
{
"answer_id": 74477017,
"author": "oligofren",
"author_id": 200987,
"author_profile": "https://Stackoverflow.com/users/200987",
"pm_score": 2,
"selected": false,
"text": " jsPDFAPI.addSvgAsImage = function(\n // ... bla bla\n return loadCanvg()\n .then(\n function(canvg) {\n return canvg.fromString(ctx, svg, options);\n },\n function() {\n return Promise.reject(new Error(\"Could not load canvg.\"));\n }\n )\n .then(function(instance) {\n return instance.render(options);\n })\n .then(function() {\n doc.addImage(\n canvas.toDataURL(\"image/jpeg\", 1.0),\n x,\n y,\n w,\n h,\n compression,\n rotation\n );\n });\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472032",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6909182/"
] |
74,472,039
|
<p>I am pushing Div element in an array and then iterating each one by one, but when I came out of first each section the array length becomes 0 and i am unable to enter into for loop.</p>
<p>in for loop, i want to click a section in each div and perform an assertation and go back to the previous section.</p>
<pre class="lang-js prettyprint-override"><code>let Array =[]
cy.get('.tag-wrapper-item').each(($pills) => {
cy.log($pills)
// cy.log('Success')
Array.push($pills)
cy.log(Array.length)
})
cy.log(Array.length)
for (const element of Array) {
cy.wrap(element).click()
cy.wrap(element).find('.--tag.tag-link.--active.tag-selector-button-link').click()
var OneOffModel = element.text()
cy.get('.heading-markdown').contains(OneOffModel)
cy.go('back')
}
</code></pre>
|
[
{
"answer_id": 74472283,
"author": "Mikhail Bolotov",
"author_id": 13109074,
"author_profile": "https://Stackoverflow.com/users/13109074",
"pm_score": 1,
"selected": false,
"text": "then"
},
{
"answer_id": 74473337,
"author": "TesterDick",
"author_id": 18366749,
"author_profile": "https://Stackoverflow.com/users/18366749",
"pm_score": 3,
"selected": true,
"text": ".tag-wrapper-item"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472039",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12450434/"
] |
74,472,061
|
<p>why CssProviderLeaf lasts about 1600 milliseconds?</p>
<pre><code>julia> using Gtk
julia> name ="FieldName"
"FieldName"
julia> @time Gtk.CssProviderLeaf(data="#$name {background:#C0C0C0;border-width:2px}")
3.397363 seconds (118.32 k allocations: 5.960 MiB, 7.66% compilation time)
GtkCssProviderLeaf()
julia> @time Gtk.CssProviderLeaf(data="#name {background:#C0C0C0;border-width:2px}")
3.968938 seconds (6 allocations: 96 bytes)
GtkCssProviderLeaf()
</code></pre>
<p>This occurs in Windows 10 both with version 1.8.1 and with version 1.8.2.</p>
|
[
{
"answer_id": 74472283,
"author": "Mikhail Bolotov",
"author_id": 13109074,
"author_profile": "https://Stackoverflow.com/users/13109074",
"pm_score": 1,
"selected": false,
"text": "then"
},
{
"answer_id": 74473337,
"author": "TesterDick",
"author_id": 18366749,
"author_profile": "https://Stackoverflow.com/users/18366749",
"pm_score": 3,
"selected": true,
"text": ".tag-wrapper-item"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472061",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4605440/"
] |
74,472,091
|
<p>I'm using an arraylist to append inputs and send the arraylist elements to file. However, everytime I exit the program and run it again, the contents in the written in the file becomes empty.</p>
<pre><code>ArrayList<String> memory = new ArrayList<String>();
public void fileHandling() {
try {
FileWriter fWriter = new FileWriter("notes.data");
for (int x = 0; x <= memory.size() - 1; x++) {
fWriter.write(memory.get(x) + '\n');
}
fWriter.close();
} catch (IOException e) {
System.out.println(e);
}
}
public void createNote() {
Scanner insertNote = new Scanner(System.in);
LocalDate todayDate = LocalDate.now();
LocalTime nowTime = LocalTime.now();
String timeFormat = nowTime.format(DateTimeFormatter.ofLocalizedTime(FormatStyle.MEDIUM));
String dateTime = todayDate.toString() + " at " + timeFormat;
while (true) {
System.out.println();
System.out.println("Enter a note");
System.out.print("> ");
String note = insertNote.nextLine();
if (note == null) {
System.out.println("Invalid input! Try again");
break;
} else {
memory.add(note + " /" + dateTime);
fileHandling();
System.out.println("Note is saved!\n");
break;
}
}
</code></pre>
<p>I expect the program to save the contents of every input. Then if I exit and run the program again, the contents will go back to the array</p>
|
[
{
"answer_id": 74472283,
"author": "Mikhail Bolotov",
"author_id": 13109074,
"author_profile": "https://Stackoverflow.com/users/13109074",
"pm_score": 1,
"selected": false,
"text": "then"
},
{
"answer_id": 74473337,
"author": "TesterDick",
"author_id": 18366749,
"author_profile": "https://Stackoverflow.com/users/18366749",
"pm_score": 3,
"selected": true,
"text": ".tag-wrapper-item"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20429783/"
] |
74,472,188
|
<p>I have don't have a lot of experiance with SQLs. I have two tables with prices from to different comanpies. I want to select the MIN price from each company and put them in a table together.</p>
<pre><code>|Company |Start city| Stop city| Price |
| -------- | -------- | -------- | -------- |
| A | HONGKONG | OSLO | 250 |
| A | BANGKOK | OSLO | 400 |
| A | BANGKOK | OSLO | 300 |
| A | HONGKOMG | OSLO | 500 |
|Company |Start city| Stop city| Price |
| -------- | -------- | -------- | -------- |
| B | HONGKONG | OSLO | 500 |
| B | BANGKOK | OSLO | 100 |
| B | BANGKOK | OSLO | 600 |
| B | HONGKOMG | OSLO | 150 |
</code></pre>
<p>The outcome I need it if select BANGKOK - OSLO, I get the MIN value of price from each table:</p>
<pre><code>|Company |Start city| Stop city| Price |
| -------- | -------- | -------- | -------- |
| A | BANGKOK | OSLO | 300 |
| B | BANGKOK | OSLO | 100 |
</code></pre>
<p>Is this possible?</p>
|
[
{
"answer_id": 74472273,
"author": "trillion",
"author_id": 12513693,
"author_profile": "https://Stackoverflow.com/users/12513693",
"pm_score": 2,
"selected": false,
"text": "with main as (\n\nselect * from table1\nunion all\nselect * from table2\n),finding_min as (\nselect \ncompany,\nstart_city,\nstop_city,\nmin(price) as minimum_price\nfrom main\ngroup by 1,2,3\n)\nselect * from finding_min\nwhere start_city = 'BANGKOK' and stop_city = 'OSLO'\n\n"
},
{
"answer_id": 74472450,
"author": "S.Visser",
"author_id": 1298289,
"author_profile": "https://Stackoverflow.com/users/1298289",
"pm_score": 3,
"selected": true,
"text": "CREATE VIEW cheapest_offers (company, start_city, stop_city, price) AS (\nSELECT company,\n start_city,\n stop_city,\n MIN(price) as price\n FROM (SELECT * FROM t1 \n UNION SELECT * FROM t2) sub\n GROUP BY company, start_city, stop_city\n);\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472188",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20471057/"
] |
74,472,202
|
<p>In VS code how can I see the current value of a specify setting variable?</p>
<p>For example: I have the <em>Code Runner</em> extension installed. In the Feature contribution page I saw that it has a setting variable</p>
<p><code>code-runner.executorMap</code> (Set the executor of each language.)</p>
<p>How can see the <em>current</em> value of this setting? Is there a way to display this value? Or do I need to trawl through the different JSON setting files (Default/User/Workspace) to then determine its current value?</p>
|
[
{
"answer_id": 74472357,
"author": "QuidalTHF",
"author_id": 13982632,
"author_profile": "https://Stackoverflow.com/users/13982632",
"pm_score": 0,
"selected": false,
"text": "const myWorkbench = vscode.workspace.getConfiguration('myWorkbench')\nconst yourConfigValue = myWorkbench.get('yourConfigValue')\n"
},
{
"answer_id": 74490723,
"author": "Mike Lischke",
"author_id": 1137174,
"author_profile": "https://Stackoverflow.com/users/1137174",
"pm_score": 2,
"selected": true,
"text": "code-runner.executorMap"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472202",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/65889/"
] |
74,472,214
|
<pre><code>inputTuple = ({'mobile': '91245555555', 'email': 'xyz@gmail.com', 'name': 'xyz', 'app_registration': 1},)
print(type(inputTuple)) # <class 'tuple'>
my_dict = dict(inputTuple)
print(my_dict) #ValueError: dictionary update sequence element #0 has length 4; 2 is required
mobile = my_dict.get("mobile")
email = my_dict.get("email")
name = my_dict.get("name")
print(mobile)
print(email)
print(name)
</code></pre>
<p><strong>how to get now each data from this tuple, first how to convert this to dict, i need to convert to dict and have to get all the key pair values,and not by using index values</strong>
<strong>Thanks for the answers</strong></p>
|
[
{
"answer_id": 74472272,
"author": "LegendWK",
"author_id": 11350541,
"author_profile": "https://Stackoverflow.com/users/11350541",
"pm_score": 1,
"selected": false,
"text": "my_dict = inputTuple[0]\ndata = my_dict['mobile']\nprint(data) \n"
},
{
"answer_id": 74489677,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": -1,
"selected": true,
"text": "inputTuple = ({'mobile': '91245555555', 'email': 'xyz@gmail.com', 'name': 'xyz', 'app_registration': 1})\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472214",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
74,472,232
|
<p>I have a string that is being dynamically created. As a result, sometimes the end of the string might have one dash or sometimes it might have more. I don't know how many dashes will be at the end; however, no matter how many dashes are at the end, I need to drop them all. So a few examples:</p>
<p>This:
101-239204-9230---
Becomes:
101-239204-9230</p>
<p>This:
101-239204-9230-
Becomes:
101-239204-9230</p>
<p>So no matter how many dashes at the end, if there are dashes at the end, I need to drop them all. I just can't wrap my head around how to do this exactly.</p>
<p>I've tried using str_replace, which works if I know the exact number of dashes, so:</p>
<pre><code>$number = 101-239204-9230---
$fixedNumber = str_replace('---', '', $number);
echo $fixedNumber
</code></pre>
<p>Again, the problem here is that I don't know how many dashes will be at the end.</p>
|
[
{
"answer_id": 74472259,
"author": "Anggara",
"author_id": 12196486,
"author_profile": "https://Stackoverflow.com/users/12196486",
"pm_score": 4,
"selected": true,
"text": "-"
},
{
"answer_id": 74472269,
"author": "Foobar",
"author_id": 19625365,
"author_profile": "https://Stackoverflow.com/users/19625365",
"pm_score": 2,
"selected": false,
"text": "$number = '101-239204-9230---';\n$fixedNumber = rtrim($number,'-');\necho $fixedNumber;\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20527879/"
] |
74,472,274
|
<p><a href="https://i.stack.imgur.com/t4Ptk.jpg" rel="nofollow noreferrer">enter image description here</a></p>
<p>I want to program motion as described in the drawing above. The angle changes according to this equation:<code>theta = Amp*np.sin(2*np.pi*ftheta*p)</code> . I am looping through p(time) and that is the only variable in this equation, nothing else changes. How do i make it stop once it reaches the amplitude and make it start going in the reverse direction until it hits the -(amplitude)</p>
<pre><code>import numpy as np
import matplotlib.pyplot as plt
import math
r=20
h=1.7
num_of_steps=100
emp=3
phi = []
theta = []
time=np.arange(0,100,1)
fphi = 1
ftheta = 1
Amp = 90
for j in time:
kampas = np.degrees(2*np.pi*fphi*j)
kitaskampas = np.degrees(np.sin(2*np.pi*ftheta*j))
if kampas > 360:
temp = math.floor(kampas/360)
sukasi = round(kampas - 360*temp)
print(sukasi)
phi.append(sukasi)
if kitaskampas == Amp:
print(phi)
</code></pre>
|
[
{
"answer_id": 74472259,
"author": "Anggara",
"author_id": 12196486,
"author_profile": "https://Stackoverflow.com/users/12196486",
"pm_score": 4,
"selected": true,
"text": "-"
},
{
"answer_id": 74472269,
"author": "Foobar",
"author_id": 19625365,
"author_profile": "https://Stackoverflow.com/users/19625365",
"pm_score": 2,
"selected": false,
"text": "$number = '101-239204-9230---';\n$fixedNumber = rtrim($number,'-');\necho $fixedNumber;\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472274",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20447735/"
] |
74,472,275
|
<p>Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click</p>
<pre><code> pro = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + "D:\FINAL PROJECT VB INVENTORY MANAGEMENT\Inventory.accdb;"
connstring = pro
myconnection.ConnectionString = connstring
myconnection.Open()
command = "Update stock set ProductName='" & ProductNameTextBox.Text & "', Quantity='" & QuantityTextBox.Text & "' , Price='" & PriceTextBox.Text & " where ProductID=" & ProductIDTextBox.Text & ""
Dim cmd As OleDbCommand = New OleDbCommand(command, myconnection)
MessageBox.Show("Data Updated!")
Try
cmd.ExecuteNonQuery()
cmd.Dispose()
myconnection.Close()
ProductIDTextBox.Clear()
ProductNameTextBox.Clear()
QuantityTextBox.Clear()
PriceTextBox.Clear()
Catch ex As Exception
End Try
End Sub
</code></pre>
|
[
{
"answer_id": 74472259,
"author": "Anggara",
"author_id": 12196486,
"author_profile": "https://Stackoverflow.com/users/12196486",
"pm_score": 4,
"selected": true,
"text": "-"
},
{
"answer_id": 74472269,
"author": "Foobar",
"author_id": 19625365,
"author_profile": "https://Stackoverflow.com/users/19625365",
"pm_score": 2,
"selected": false,
"text": "$number = '101-239204-9230---';\n$fixedNumber = rtrim($number,'-');\necho $fixedNumber;\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472275",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20527966/"
] |
74,472,284
|
<p>I have a simple webpage with a simple menu.</p>
<p>Each page of the webpage (for example, index.php, page-01.php etc) pulls the menu in using the include function:</p>
<pre><code><?php
include 'menu.php';
?>
</code></pre>
<p>I want the menu item for the current page formatted, so I'm trying to get the menu to check the name of the current page. For example, when I'm on index.php, I want a function in menu.php to return "index".</p>
<p>I tried using this in menu.php:</p>
<pre><code>echo basename(__FILE__, '.php');
</code></pre>
<p>But it returns "menu" instead (which in retrospect, makes a lot of sense).</p>
<p>What can I use in my menu.php file to return the current page name?</p>
<p>Thanks!</p>
|
[
{
"answer_id": 74472259,
"author": "Anggara",
"author_id": 12196486,
"author_profile": "https://Stackoverflow.com/users/12196486",
"pm_score": 4,
"selected": true,
"text": "-"
},
{
"answer_id": 74472269,
"author": "Foobar",
"author_id": 19625365,
"author_profile": "https://Stackoverflow.com/users/19625365",
"pm_score": 2,
"selected": false,
"text": "$number = '101-239204-9230---';\n$fixedNumber = rtrim($number,'-');\necho $fixedNumber;\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472284",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8269695/"
] |
74,472,295
|
<p>We have a nodejs monorepo project with >179 packages where each package may have >30 files. It also contains proxy with routing and several forked processes (as usual). So, when we packed all of this stuff into Docker image and moved it into CloudRun (with min instance = 1, max instance >10, concurrency=1000), users randomly start see the error '429 Rate exceeded'. (As far as we understood from the documentation, it happens when 'max instances' limit is reached by CloudRun and it can not scale our application anymore. Indirect reason of that maybe too long cold start (which is also limited in CloudRun = 10s). We measured our cold start - it was ~20sec.</p>
<p>To identify the issue of cold start we used this package - <a href="https://www.npmjs.com/package/require-so-slow" rel="nofollow noreferrer">https://www.npmjs.com/package/require-so-slow</a><br />
It showed us that each our small module requires ~5ms for 'import' or 'require' modules. So, average calculation may show why do we have so long cold start: 170 packages * 30 files * 5ms > 25s</p>
<p>For monorepo we use pnmpm and each package builds with tsc.</p>
<p>So, the question is how to improve cold start in CloudRun?</p>
<p>Note: Locally, on dev environment on laptops, we do not have issue with cold start, only in CloudRun. So, looks like, this issue is a platform specific issue.</p>
<p><strong>UPDATED:</strong> the best approach at this moment, for our case, is bundling all project (or partially) into single js file (with help of webpack or esbuild, like <a href="https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-using-build-typescript.html" rel="nofollow noreferrer">here</a>) + Cloud Run <a href="https://www.infoq.com/news/2022/09/google-startup-cpu-boost/" rel="nofollow noreferrer">'cpu boost'</a> option</p>
|
[
{
"answer_id": 74475047,
"author": "Anton Komarov",
"author_id": 5966911,
"author_profile": "https://Stackoverflow.com/users/5966911",
"pm_score": 0,
"selected": false,
"text": "const path = require('path');\nconst nodeExternals = require('webpack-node-externals');\n\nmodule.exports = (env) => {\n return {\n target: 'node',\n externals: [nodeExternals()],\n node: {\n global: false,\n __filename: false,\n __dirname: false,\n },\n entry: './src/index.ts',\n optimization: {\n minimize: false\n },\n module: {\n rules: [\n {\n test: /\\.tsx?$/,\n loader: 'ts-loader',\n exclude: /node_modules/,\n options: {\n compilerOptions: {\n outDir: env[1].output\n }\n }\n },\n ],\n },\n resolve: {\n extensions: ['.tsx', '.ts', '.js'],\n },\n output: {\n filename: 'index.js',\n pathinfo: false,\n libraryTarget: 'commonjs2'\n },\n}};\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472295",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5966911/"
] |
74,472,299
|
<p>I have a database with buildings, with their names and heights. I want a query that gives me the names of the buildigs that differ less than 100 meters height from the average of all
building.</p>
<p>I have tried:</p>
<pre><code>SELECT Name FROM building
WHERE Height BETWEEN ABS((AVG(Height)) - 100) AND ABS(AVG(Height))
</code></pre>
<p>But it is not working, any ideas? :)</p>
|
[
{
"answer_id": 74472369,
"author": "CthenB",
"author_id": 1885199,
"author_profile": "https://Stackoverflow.com/users/1885199",
"pm_score": 1,
"selected": false,
"text": "avg"
},
{
"answer_id": 74472424,
"author": "jarlh",
"author_id": 3706016,
"author_profile": "https://Stackoverflow.com/users/3706016",
"pm_score": 3,
"selected": true,
"text": "SELECT Name FROM mountain \nWHERE (select AVG(Height) from mountain) BETWEEN Height - 100 and Height + 100\n"
},
{
"answer_id": 74472478,
"author": "ahmed",
"author_id": 12705912,
"author_profile": "https://Stackoverflow.com/users/12705912",
"pm_score": 1,
"selected": false,
"text": "SELECT name, height\nFROM\n(\n SELECT *,\n AVG(height) OVER () av\n FROM table_name\n) T\nWHERE ABS(height-av) <= 100\n"
},
{
"answer_id": 74472492,
"author": "Jonas Metzler",
"author_id": 18794826,
"author_profile": "https://Stackoverflow.com/users/18794826",
"pm_score": 0,
"selected": false,
"text": "ABS"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472299",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
74,472,319
|
<p>As the name suggests, I have a problem with the clock() function.</p>
<p>I want the time of each step in the loop to be printed.</p>
<p>For example, I have code:</p>
<pre><code>#include<time.h>
int main()
{
clock_t start,end;
for(int i=0;i<number_of_elements;i++)
{
start=clock();
for(int z=/*something*/;z>=0;z--)
{
//Some desired processing
}
for(int g=0;g</*something*/;g++)
{
//Some desired processing
}
end=clock();
double duration=(double)(end-start)/CLOCKS_PER_SEC;
printf("%d.step %f\n",i+1,duration);
}
}
</code></pre>
<p>And now I want to print the time of each step from 'i' in this loop.
But what I get are only zeros.</p>
<p>Example:</p>
<pre><code>1.step 0.000000
2.step 0.000000
3.step 0.000000
4.step 0.000000
etc.
</code></pre>
<p>Can anyone help me about this?</p>
<p>Thanks in advance!</p>
|
[
{
"answer_id": 74472369,
"author": "CthenB",
"author_id": 1885199,
"author_profile": "https://Stackoverflow.com/users/1885199",
"pm_score": 1,
"selected": false,
"text": "avg"
},
{
"answer_id": 74472424,
"author": "jarlh",
"author_id": 3706016,
"author_profile": "https://Stackoverflow.com/users/3706016",
"pm_score": 3,
"selected": true,
"text": "SELECT Name FROM mountain \nWHERE (select AVG(Height) from mountain) BETWEEN Height - 100 and Height + 100\n"
},
{
"answer_id": 74472478,
"author": "ahmed",
"author_id": 12705912,
"author_profile": "https://Stackoverflow.com/users/12705912",
"pm_score": 1,
"selected": false,
"text": "SELECT name, height\nFROM\n(\n SELECT *,\n AVG(height) OVER () av\n FROM table_name\n) T\nWHERE ABS(height-av) <= 100\n"
},
{
"answer_id": 74472492,
"author": "Jonas Metzler",
"author_id": 18794826,
"author_profile": "https://Stackoverflow.com/users/18794826",
"pm_score": 0,
"selected": false,
"text": "ABS"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472319",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20485697/"
] |
74,472,354
|
<p>I have a file "test.js" in my "/constants" folder with the following content:</p>
<pre><code>const test = "test!"
export default test
</code></pre>
<p>My page in the "/pages" folder should read the string from "test.js" and print it</p>
<pre><code>import { test } from "../constants/test"
export default function Home() {
console.log("imported string: " + test)
}
</code></pre>
<p>If I run it the browser I get the following output:</p>
<p>"imported string: undefined"</p>
<p>Why is it not reading the string from the file? The path is correct. VSCode autocomplete even finds the file while typing.</p>
|
[
{
"answer_id": 74472392,
"author": "ThomasSquall",
"author_id": 2569789,
"author_profile": "https://Stackoverflow.com/users/2569789",
"pm_score": 3,
"selected": true,
"text": "import { test } from \"../constants/test\"\n"
},
{
"answer_id": 74472413,
"author": "owenizedd",
"author_id": 7146064,
"author_profile": "https://Stackoverflow.com/users/7146064",
"pm_score": 1,
"selected": false,
"text": "import { test }"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472354",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1931996/"
] |
74,472,379
|
<pre><code>import * as React from "react";
// import "./style.css";
export default function App() {
let [width, setWidth] = React.useState(window.innerWidth);
let [height, setHeight] = React.useState(window.innerHeight);
React.useEffect(() => {
console.log("useEffect is called");
window.addEventListener("resize", () => {
setHeight(window.innerHeight);
setWidth(window.innerWidth);
});
}, []);
return (
<div>
{/* <button onClick={handler}> Submit </button> */}
<h1>
{" "}
{height},{width}{" "}
</h1>
</div>
);
}
</code></pre>
<p>The above code causes <strong>re-render</strong> of <strong>height</strong> and <strong>width</strong> values on the UI <code>(height =windows.innerHeight & width = windows.innerWidth)</code> despite using useEffect with an empty dependency array.</p>
<p>I've deployed <code>useState</code> inside <code>useEffect</code> to update <code>height</code> and <code>width</code>. My understanding was that <code>useEffect</code> gets executed only once(after the initial render) if used with an empty dependency array but on resizing the screen size, <code>height</code> and <code>width</code> gets updated as well thereby causing <strong>re-render</strong></p>
|
[
{
"answer_id": 74472443,
"author": "Ali Sattarzadeh",
"author_id": 11434567,
"author_profile": "https://Stackoverflow.com/users/11434567",
"pm_score": 0,
"selected": false,
"text": "addEventListener"
},
{
"answer_id": 74472475,
"author": "Kuncheria",
"author_id": 6062364,
"author_profile": "https://Stackoverflow.com/users/6062364",
"pm_score": 0,
"selected": false,
"text": "useEffect"
},
{
"answer_id": 74472899,
"author": "Kamran Davar",
"author_id": 12510464,
"author_profile": "https://Stackoverflow.com/users/12510464",
"pm_score": 1,
"selected": false,
"text": "window.addEventListener"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16909739/"
] |
74,472,419
|
<p>I am trying to UPDATE table value where meta key value _stock_status and id value list of ids, but i got an error (You can't specify target table 'wpp' for update in FROM clause). please advise here is my query</p>
<pre><code>UPDATE meta_post AS wpp
SET wpp.meta_value = 'instock'
WHERE wpp.meta_key = '_stock_status'
AND wpp.id IN (
SELECT DISTINCT id
FROM meta_post
WHERE meta_key = '_stock'
AND (meta_value BETWEEN 2 AND 4)
)
</code></pre>
<p>thank you</p>
<p>Need to update column value where meta_key = '_stock_status' and id = [1,2,3,4]</p>
|
[
{
"answer_id": 74472443,
"author": "Ali Sattarzadeh",
"author_id": 11434567,
"author_profile": "https://Stackoverflow.com/users/11434567",
"pm_score": 0,
"selected": false,
"text": "addEventListener"
},
{
"answer_id": 74472475,
"author": "Kuncheria",
"author_id": 6062364,
"author_profile": "https://Stackoverflow.com/users/6062364",
"pm_score": 0,
"selected": false,
"text": "useEffect"
},
{
"answer_id": 74472899,
"author": "Kamran Davar",
"author_id": 12510464,
"author_profile": "https://Stackoverflow.com/users/12510464",
"pm_score": 1,
"selected": false,
"text": "window.addEventListener"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472419",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14393908/"
] |
74,472,423
|
<pre><code>In [1]: x = set()
In [2]: pos = collections.namedtuple('Position', ['x','y'])
In [4]: x.add(pos(1,1))
In [5]: x
Out[5]: {Position(x=1, y=1)}
In [6]: pos(1,1) in x
Out[6]: True
In [8]: pos(1,2) in x
Out[8]: False
</code></pre>
<p>I was not expecting Line 6 <code>pos(1,1) in x</code> to work. Since it does seem that pos(1,1) creates an object with a different object id every time.</p>
<pre><code>In [9]: id(pos(1,1))
Out[9]: 140290954200696
In [10]: id(pos(1,1))
Out[10]: 140290954171016
</code></pre>
<p>How does the set <code>in</code> operator work on named tuples in this case? Does it check the contents of namedtuple?</p>
|
[
{
"answer_id": 74472472,
"author": "Abdul Niyas P M",
"author_id": 6699447,
"author_profile": "https://Stackoverflow.com/users/6699447",
"pm_score": 3,
"selected": false,
"text": "__eq__"
},
{
"answer_id": 74472486,
"author": "Nazar Nintendo",
"author_id": 20524194,
"author_profile": "https://Stackoverflow.com/users/20524194",
"pm_score": 0,
"selected": false,
"text": "in"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472423",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3646408/"
] |
74,472,453
|
<pre><code> ElevatedButton(
style: ElevatedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10))),
onPressed: () {
cubit.addItemToCart(
id: cubit.getCartModel!.data[index].id);
},
child: Text(LocaleKeys.addToCart.tr()),
)
</code></pre>
<p>I'm trying to add item to cart so this RangeError Appears to me if anyone know how to solve it, I'll Aprreciate his Effort</p>
|
[
{
"answer_id": 74472472,
"author": "Abdul Niyas P M",
"author_id": 6699447,
"author_profile": "https://Stackoverflow.com/users/6699447",
"pm_score": 3,
"selected": false,
"text": "__eq__"
},
{
"answer_id": 74472486,
"author": "Nazar Nintendo",
"author_id": 20524194,
"author_profile": "https://Stackoverflow.com/users/20524194",
"pm_score": 0,
"selected": false,
"text": "in"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472453",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19247628/"
] |
74,472,503
|
<p>Could anyone help me out here please, all I'm trying to do here is to show popup modal confirmation for delete action, but every time I clicked on **Yes **btn to confirm my delete action the last product on the list always get deleted instead. I need help from anyone please?</p>
<p>Here is my code for handling the delete popup</p>
<pre><code> ```
//OPEN DELETE MODALS
const [openDeleteModal, isOpenDeleteModal] = useState(false);
const closeDeleteModal = () => {
isOpenDeleteModal(false);
document.body.style.overflow = "unset";
};
const showDeleteModal = () => {
isOpenDeleteModal(true);
};
```
</code></pre>
<p>and here is the api</p>
<pre><code> ```
//DELETE PRODUCT
const deleteHandler = async (product) => {
try {
await axios.delete(`/api/products/${product._id}`, {
headers: { Authorization: `Bearer ${userInfo.token}` },
});
toast.success("product deleted successfully", {
position: "bottom-center",
});
dispatch({ type: "DELETE_SUCCESS" });
} catch (err) {
toast.error(getError(err), { position: "bottom-center" });
dispatch({ type: "DELETE_FAIL" });
}
};
```
</code></pre>
<p>down here is my modal for confirmation</p>
<pre><code> ```
{/* MODAL */}
{openDeleteModal && (
<div className="delete-modal">
<div className="delete-modal-box">
<div className="delete-modal-content">
<p className="delete-modal-content-p">
Are you sure to delete this product?
</p>
<div className="delete-modal-btn">
<button
onClick={closeDeleteModal}
className="delete-modal-btn-close"
>
Close
</button>
<button
onClick={() => {
deleteHandler(product);
closeDeleteModal();
}}
className="delete-modal-btn-yes"
>
{" "}
Yes
</button>
</div>
</div>
</div>
</div>
)}
```
All I'm trying to do is to be able to delete any product from the list not the last product every time.
</code></pre>
<p><strong>here is the entirety of my productList map looks like</strong></p>
<pre><code> {products?.map((product, index) => (
<tr className="product-item-list" key={index}>
<tr>
<td className="product-item-id">{product._id}</td>
<td className="product-item-name">
{product.name}
</td>
<td className="product-item-price">
£{product.price}
</td>
<td className="product-item-category">
{product.category?.map((cat, index) => (
<span key={index}>{cat}</span>
))}
</td>
<td className="product-item-size">
{product.size?.map((s, index) => (
<span key={index}>{s}&nbsp;</span>
))}
</td>
<td className="product-btn-view">
<button
className="product-btn"
onClick={() =>
navigate(`/admin/productedit/${product._id}`)
}
>
Edit
</button>
&nbsp;
<DeleteOutline
className="product-delete"
onClick={showDeleteModal}
/>
{/* MODAL */}
{openDeleteModal && (
<div className="delete-modal">
<div className="delete-modal-box">
<div className="delete-modal-content">
<p className="delete-modal-content-p">
Are you sure to delete this product?
</p>
<div className="delete-modal-btn">
<button
onClick={closeDeleteModal}
className="delete-modal-btn-close"
>
Close
</button>
<button
onClick={() => {
deleteHandler(product);
closeDeleteModal();
}}
className="delete-modal-btn-yes"
>
{" "}
Yes
</button>
</div>
</div>
</div>
</div>
)}
</td>
</tr>
<tr></tr>
</tr>
))}
</code></pre>
|
[
{
"answer_id": 74472472,
"author": "Abdul Niyas P M",
"author_id": 6699447,
"author_profile": "https://Stackoverflow.com/users/6699447",
"pm_score": 3,
"selected": false,
"text": "__eq__"
},
{
"answer_id": 74472486,
"author": "Nazar Nintendo",
"author_id": 20524194,
"author_profile": "https://Stackoverflow.com/users/20524194",
"pm_score": 0,
"selected": false,
"text": "in"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472503",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18330870/"
] |
74,472,536
|
<p>Suppose I have a file(local.tfvars) which consists of:</p>
<pre><code>Car {
}
Bus {
}
</code></pre>
<p>Now I want to replace car in this file with</p>
<pre><code>Car {
Audi,
Mercedes,
}
Bus {
}
</code></pre>
<p>through the script.</p>
<p>I am fetching the local file through</p>
<pre><code> $localfile = Get-Content -Path ("local.tfvars")
</code></pre>
<p>after that I am using:</p>
<pre><code> $localfile.replace("Car","Car{`n Audi,Mercedes)
</code></pre>
<p>Which should give me the output as:</p>
<pre><code>Car {
Audi,
Mercedes,
}
Bus {
}
</code></pre>
<p>But the output doesn't seem to come in this way, the output that I am getting is:</p>
<pre><code>Car {
Audi,
}
Bus {
}
Car {
Mercedes,
}
Bus {
}
</code></pre>
<p>See here these are getting printed twice which I don't want.</p>
|
[
{
"answer_id": 74472632,
"author": "KojTug",
"author_id": 15589792,
"author_profile": "https://Stackoverflow.com/users/15589792",
"pm_score": 0,
"selected": false,
"text": "$result = @'\n{\n\nCar {\n}\nBus {\n}\n\n}\n'@\n\n$result = $result.Replace(\"Car {\", \"Car {`r`nAudi,`r`nMercedes,`r\")\n\n$result\n"
},
{
"answer_id": 74475475,
"author": "Theo",
"author_id": 9898643,
"author_profile": "https://Stackoverflow.com/users/9898643",
"pm_score": 2,
"selected": true,
"text": "-replace"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20527922/"
] |
74,472,538
|
<p>I've an array which contains the objects including various key and values. I'm going to pick out the certain values from the Array and check if the specific value is included or not in the Array.</p>
<pre><code>function groupByName (contract) {
const { age } = contract;
const groups = [
{name: 'John', age: 30},
{name: 'Jack', age: 33},
{name: 'Tom', age: 40}
...
];
...
}
</code></pre>
<p>In order to compare the <code>age</code> in <code>groups</code> array, right now I have to use loop functions and then check one by one.
Like</p>
<pre><code>groups.forEach(g => {
if (g.age === age) {
...
} else {
...
}
});
</code></pre>
<p>But I don't like this approach and think there are simple and effective way.
Please help me!</p>
|
[
{
"answer_id": 74472656,
"author": "R4ncid",
"author_id": 14326899,
"author_profile": "https://Stackoverflow.com/users/14326899",
"pm_score": 3,
"selected": true,
"text": "filter"
},
{
"answer_id": 74472665,
"author": "corcre",
"author_id": 19954006,
"author_profile": "https://Stackoverflow.com/users/19954006",
"pm_score": 2,
"selected": false,
"text": "groups.some(p=>r.age===age)//if there is a object meet the criteria, return true, else return false\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472538",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16525519/"
] |
74,472,540
|
<p>How can I make a list of prices that I got from my API.</p>
<pre><code>{
product: {
items: {
price1: {}
price2: {}
price3: {}
}
}
}
var productPrices = response.data
</code></pre>
<p>I have tried this one to get the prices but I would like a help to convert it to a List so I can map it to my widget, what I get in the list of Items is _JsonMap.</p>
<pre><code> productPrices.forEach((key, value) {
print(key);
final Map listofItems = Map.from(value);
print(listofItems);
});
</code></pre>
|
[
{
"answer_id": 74472708,
"author": "Onur Kağan Aldemir",
"author_id": 7335273,
"author_profile": "https://Stackoverflow.com/users/7335273",
"pm_score": 1,
"selected": false,
"text": "(jsonDecode(data)['product']['items'] as Map).values.toList()\n"
},
{
"answer_id": 74472709,
"author": "Vu Thanh",
"author_id": 7592717,
"author_profile": "https://Stackoverflow.com/users/7592717",
"pm_score": 0,
"selected": false,
"text": "productPrices.items.forEach((key, value) {\n print(key);\n final Map listofItems = Map.from(value);\n print(listofItems);\n });\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472540",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3352042/"
] |
74,472,542
|
<p>Say I want to make a simple method which takes in a collection and cuts the number of its elements:</p>
<pre><code> public static <T extends Collection<?>> T limit(T collection, long limit){
return collection.stream().limit(limit).collect(Collectors.toCollection(???));
}
</code></pre>
<p>Is it possible to collect it back to a collection of the generic type?</p>
|
[
{
"answer_id": 74472708,
"author": "Onur Kağan Aldemir",
"author_id": 7335273,
"author_profile": "https://Stackoverflow.com/users/7335273",
"pm_score": 1,
"selected": false,
"text": "(jsonDecode(data)['product']['items'] as Map).values.toList()\n"
},
{
"answer_id": 74472709,
"author": "Vu Thanh",
"author_id": 7592717,
"author_profile": "https://Stackoverflow.com/users/7592717",
"pm_score": 0,
"selected": false,
"text": "productPrices.items.forEach((key, value) {\n print(key);\n final Map listofItems = Map.from(value);\n print(listofItems);\n });\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472542",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16959486/"
] |
74,472,549
|
<p>I have a pandas dataframe like so:</p>
<pre><code>df = pd.DataFrame({'column': [[np.nan, np.nan, np.nan], [1, np.nan, np.nan], [2, 3, np.nan], [3, 2, 1]]})
column
0 [nan, nan, nan]
1 [1, nan, nan]
2 [2, 3, nan]
3 [3, 2, 1]
</code></pre>
<p>Note that there is never the same value twice in a row.</p>
<p>I wish to transform this single column into multiple columns named with the corresponding values. So I want to order the values and put them in the right column. The ones under <code>column_1</code>, twos under <code>column_2</code> etc.</p>
<pre><code> column_1 column_2 column_3
0 NaN NaN NaN
1 1.0 NaN NaN
2 NaN 2.0 3.0
3 1.0 2.0 3.0
</code></pre>
<p>How to do this? I don't really know where to start to be honest.</p>
|
[
{
"answer_id": 74472708,
"author": "Onur Kağan Aldemir",
"author_id": 7335273,
"author_profile": "https://Stackoverflow.com/users/7335273",
"pm_score": 1,
"selected": false,
"text": "(jsonDecode(data)['product']['items'] as Map).values.toList()\n"
},
{
"answer_id": 74472709,
"author": "Vu Thanh",
"author_id": 7592717,
"author_profile": "https://Stackoverflow.com/users/7592717",
"pm_score": 0,
"selected": false,
"text": "productPrices.items.forEach((key, value) {\n print(key);\n final Map listofItems = Map.from(value);\n print(listofItems);\n });\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472549",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8814131/"
] |
74,472,557
|
<p>Here I am trying to get user Info from redux state to the homepage after signing in but the problem is that the component refreshes and lose all the redux data stored because of the <code>useEffect</code> hook, and I can't use the <code>checkUser()</code> method which retrieve user data without that hook because it cause an infinite rendering problem and ruin the app.
So can you help me get the data from redux state without refreshing the component.</p>
<pre><code>import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import { useEffect, useState } from 'react';
import { checkUser } from '../../actions/userActions';
import { connect } from 'react-redux';
import './main.css';
function Main(props){
const [loggedIn, setLoggedIn] = useState(false)
useEffect(() => {
props.checkUser();
setLoggedIn(props?.user?.isLoggedIn)
},[checkUser])
useEffect(() => {
console.log(loggedIn)
}, [loggedIn])
let menuOpened = false;
const menuToggle = (element) => {
element.preventDefault();
let menuButton = document.querySelector('.menu-btn');
let responsiveMenu = document.querySelector('.toggle-menu');
if(!menuOpened){
menuButton.classList.add('open');
responsiveMenu?.classList.add('opened');
}else if(menuOpened){
menuButton.classList.remove('open');
responsiveMenu?.classList.remove('opened');
}
menuOpened = !menuOpened ;
}
const search = (e) => {
e.preventDefault();
}
return (
<div>
<h1 id='Title'>Your favorite<br></br>Gifts shop</h1>
<nav id='navbar'>
<div className='menu-btn' onClick={menuToggle}>
<div className='menu-btn-burger'></div>
</div>
<ul className='toggle-menu'>
<li className="toggle-menu-items">
<Link className='toggle-menu-anchors' {...(loggedIn ? {to:'/user-profile'} : {to:'/user-form'})}>Profile</Link>
</li>
<li className="toggle-menu-items">
<Link className='toggle-menu-anchors' to='/cart'>Cart</Link>
</li>
<li className="toggle-menu-items">
<Link className='toggle-menu-anchors' to='/support'>Support</Link>
</li>
</ul>
<ul>
<li className='menu' id='menu1'><Link className='anchor-menu' {...(loggedIn ? {to:'/user-profile'} : {to:'/user-form'})}>Profile</Link></li>
<li className='menu' id='menu2'><Link className='anchor-menu' to='/cart'>Cart</Link></li>
<li className='menu' id='menu3'><Link className='anchor-menu' to='/support'>Support</Link></li>
</ul>
<form id='mainForm'>
<input id='mainInput'/>
<button id='search' onClick={search}>search</button>
</form>
</nav>
</div>
);
}
const mapUserStateToProps = (state) => {
return{
user : state?.myUser || [],
}
}
export default connect(mapUserStateToProps, {checkUser})(Main);
</code></pre>
|
[
{
"answer_id": 74472708,
"author": "Onur Kağan Aldemir",
"author_id": 7335273,
"author_profile": "https://Stackoverflow.com/users/7335273",
"pm_score": 1,
"selected": false,
"text": "(jsonDecode(data)['product']['items'] as Map).values.toList()\n"
},
{
"answer_id": 74472709,
"author": "Vu Thanh",
"author_id": 7592717,
"author_profile": "https://Stackoverflow.com/users/7592717",
"pm_score": 0,
"selected": false,
"text": "productPrices.items.forEach((key, value) {\n print(key);\n final Map listofItems = Map.from(value);\n print(listofItems);\n });\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17862094/"
] |
74,472,565
|
<p>I have a 4 different configurations to be used and these configuration values are stored in a property file. The properties for all the configurations are same, but the values are different for each.</p>
<p>Ex:
The property file configurations I am using:</p>
<pre><code>####Config1####
conf1.password=admin
conf1.username=admin
conf1.context=123
conf1.name=localhost
####config2####
conf2.username=app
conf2.password=app
conf2.context=com
conf2.name=localhost
####config3####
conf3.username=app
conf3.password=app
conf3.context=com
conf3.name=localhost
####config4####
conf4.username=app
conf4.password=app
conf4.context=com
conf4.name=localhost
</code></pre>
<p>I can get the properties from the property file. Is it possible to have a single variable to store these values based on configuration and access them in an optimised and readable way?</p>
<p>I tried using hash-map for every configuration separately and fetching it from that. But it is increasing my code redundancy as if I perform same steps for every configuration and if-elsed the configuration name to get the hashmap values.</p>
<p>Currently I am using the properties with hashmap like this:</p>
<pre><code>HashMap<String, String> conf1 = new HashMap<>();
HashMap<String, String> conf2 = new HashMap<>();
HashMap<String, String> conf3 = new HashMap<>();
HashMap<String, String> conf4 = new HashMap<>();
conf1.put("UserName", prop.getProperty(“conf1.username"));
conf1.put("Password",prop.getProperty("conf1.password"));
conf1.put(“name”,prop.getProperty("conf1.name"));
conf1.put("context”,”conf1,context”);
conf2.put("UserName", prop.getProperty(“conf2.username"));
conf2.put("Password",prop.getProperty("conf2.password"));
conf2.put(“name”,prop.getProperty("conf2.name"));
conf2.put("context”,”conf2,context”);
conf3...
conf4...
if (Conf.equalsIgnoreCase(“conf1”)) {
GenerateTestFile(
"Name:“ + conf1.get("Name") + “-UserName:” +
conf1.get("UserName") + “-Password:” + conf1.get("Password") +
"-Context:” + conf1.get(“Context”) ,FileName);
} else if (Conf.equalsIgnoreCase(“conf2”)) {
GenerateTestFile(
"Name:“ + conf2.get("Name") + “-UserName:” +
conf2.get("UserName") + “-Password:” + conf2.get("Password") +
"-Context:” + conf2.get(“Context”) ,FileName);
}
Else if(conf3){…}
Else if(conf4){…}
</code></pre>
|
[
{
"answer_id": 74474892,
"author": "Positronator",
"author_id": 20527747,
"author_profile": "https://Stackoverflow.com/users/20527747",
"pm_score": 1,
"selected": false,
"text": "HashMap<String, HashMap<String, String>> conf = new HashMap<>();\n\nfor(int i = 1; i <= 4; i++) {\n String currentConfName = \"conf\" + i;\n HashMap<String, String> currentConf = new HashMap<>();\n currentConf.put(\"UserName\", prop.getProperty(currentConfName + \".username\"));\n //And everythin else you want to add\n\n conf.put(currentConfName, currentConf);\n}\n"
},
{
"answer_id": 74475226,
"author": "Maurice Perry",
"author_id": 7036419,
"author_profile": "https://Stackoverflow.com/users/7036419",
"pm_score": 1,
"selected": true,
"text": "Map<String,Map<String,String>>"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472565",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15170229/"
] |
74,472,578
|
<p>I have a list that has the keys and values of a dictionary as elements. I want to change it into a dictionary. Any help would be appreciated. I am new to programming.</p>
<pre class="lang-py prettyprint-override"><code>List=[key1,key2,value2,value2,key3,value3,value3,key4,value4]
</code></pre>
<p>I want to change it into:</p>
<pre class="lang-py prettyprint-override"><code>dict={key1:[],key2:[value2,value2],key3:[value3,value3],key4:[value4]}
</code></pre>
<p>The approach would be:</p>
<p>Loop through the lists and recognize the keys and add the next elements to the key until we hit the next key.</p>
<p>For example key1 is empty because before encountering any values we hit the next key (key2). Of course, you can use other approaches if you prefer.</p>
|
[
{
"answer_id": 74472911,
"author": "Tranbi",
"author_id": 13525512,
"author_profile": "https://Stackoverflow.com/users/13525512",
"pm_score": 1,
"selected": true,
"text": "list_in = [\"key1\",\"key2\",\"value2\",\"value2\",\"key3\",\"value3\",\"value3\",\"key4\",\"value4\"]\ndict_out = {}\n\ncurr_key = None\nfor el in list_in:\n if \"key\" in el: # replace with your actual condition\n dict_out[el] = []\n curr_key = el\n else:\n dict_out[curr_key].append(el)\n\nprint(dict_out)\n"
},
{
"answer_id": 74472944,
"author": "Serge Ballesta",
"author_id": 3545273,
"author_profile": "https://Stackoverflow.com/users/3545273",
"pm_score": 1,
"selected": false,
"text": "'key'"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12863170/"
] |
74,472,595
|
<p>When I call fetch function - I get the correct token from backend application.
But everytime in this program , even when I get the incorrect token - the program moves to StudentLobby (and that need to happen only when i get the correct token).</p>
<p>what i'm missing?</p>
<p><a href="https://i.stack.imgur.com/8HMjR.png" rel="nofollow noreferrer">Login function</a></p>
<p><a href="https://i.stack.imgur.com/ga39U.png" rel="nofollow noreferrer">return html</a></p>
<pre><code> .
</code></pre>
|
[
{
"answer_id": 74472911,
"author": "Tranbi",
"author_id": 13525512,
"author_profile": "https://Stackoverflow.com/users/13525512",
"pm_score": 1,
"selected": true,
"text": "list_in = [\"key1\",\"key2\",\"value2\",\"value2\",\"key3\",\"value3\",\"value3\",\"key4\",\"value4\"]\ndict_out = {}\n\ncurr_key = None\nfor el in list_in:\n if \"key\" in el: # replace with your actual condition\n dict_out[el] = []\n curr_key = el\n else:\n dict_out[curr_key].append(el)\n\nprint(dict_out)\n"
},
{
"answer_id": 74472944,
"author": "Serge Ballesta",
"author_id": 3545273,
"author_profile": "https://Stackoverflow.com/users/3545273",
"pm_score": 1,
"selected": false,
"text": "'key'"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472595",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16454734/"
] |
74,472,596
|
<p>I want to subtract count of a metric from now and for example 5 min ago.
how can I do that?</p>
<p>This is not work:</p>
<pre><code>count(istio_requests_total{destination_workload=~"production-api") - count(istio_requests_total{destination_workload=~"production-api") [5m:5m]
</code></pre>
<p>Each returned metric values is like:</p>
<pre><code>istio_requests_total{connection_security_policy="none", destination_app="unknown", destination_canonical_revision="latest", destination_canonical_service="production-api", destination_cluster="Kubernetes", destination_port="81", destination_principal="unknown", destination_service="production-api.production.svc.cluster.local", destination_service_name="production-api", destination_service_namespace="production", destination_version="unknown", destination_workload="production-api", destination_workload_namespace="production", instance="10.233.64.228:15090", job="envoy-stats", path="/favicon.ico", reporter="destination", request_duration="0.013466636s", request_host="api.test.com", request_protocol="http", request_size="0", request_time="2022-11-15T21:41:36.699467Z", request_total_size="1233", response_code="404", response_flags="-", source_app="unknown", source_canonical_revision="latest", source_canonical_service="unknown", source_cluster="unknown", source_principal="unknown", source_version="unknown", source_workload="unknown", source_workload_namespace="unknown", url_path="/favicon.ico"} 1 @1668673800
</code></pre>
<p>because of labels like request_duration and request_time each, returned metric is different than each other.</p>
<p>when running query I got this error:</p>
<blockquote>
<p>Error executing query: invalid parameter "query": 1:197: parse error: binary expression must contain only scalar and instant vector types</p>
</blockquote>
<p>I also tested something like this?</p>
<pre><code>delta(count(istio_requests_total{destination_workload=~"production-api"))[5m])
</code></pre>
|
[
{
"answer_id": 74472911,
"author": "Tranbi",
"author_id": 13525512,
"author_profile": "https://Stackoverflow.com/users/13525512",
"pm_score": 1,
"selected": true,
"text": "list_in = [\"key1\",\"key2\",\"value2\",\"value2\",\"key3\",\"value3\",\"value3\",\"key4\",\"value4\"]\ndict_out = {}\n\ncurr_key = None\nfor el in list_in:\n if \"key\" in el: # replace with your actual condition\n dict_out[el] = []\n curr_key = el\n else:\n dict_out[curr_key].append(el)\n\nprint(dict_out)\n"
},
{
"answer_id": 74472944,
"author": "Serge Ballesta",
"author_id": 3545273,
"author_profile": "https://Stackoverflow.com/users/3545273",
"pm_score": 1,
"selected": false,
"text": "'key'"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472596",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10306090/"
] |
74,472,598
|
<p>I'm a beginner and I'm trying to make a console <strong>login, registration and forgot password</strong>. The code simply works and it looks like this..</p>
<p><a href="https://i.stack.imgur.com/CzUvq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CzUvq.png" alt="How the output looks like" /></a></p>
<p><strong>Problem:</strong><br/>
Every thing works fine and when I select <strong>3</strong> it goes inside forgot password just like it should</p>
<p><a href="https://i.stack.imgur.com/OsxyK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OsxyK.png" alt="How forgot password looks like" /></a></p>
<p>And when I select <strong>2</strong> it goes back.</p>
<p><a href="https://i.stack.imgur.com/CzUvq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CzUvq.png" alt="How the output looks like" /></a></p>
<p>And after doing the above steps, when I select <strong>4</strong> to exit, it goes back inside forgot password and runs the default of the switch statement inside the forgotPassword() function. ( That's why it says invalid number 2 at the top in the screenshot below. )</p>
<p><a href="https://i.stack.imgur.com/3MdlT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3MdlT.png" alt="Runs forgot password again" /></a></p>
<p>I really don't know why but it runs forgot password again, but when I press other keys it works fine.</p>
<p><strong>Source Code:</strong></p>
<pre><code>#include <iostream>
#include <fstream>
using namespace std;
// call functions
void login();
void registration();
void forgotPassword();
int main()
{
int choice;
cout << "-------------- WELCOME --------------\n";
cout << "::Select Action::\n\n";
cout << "1. Login\n";
cout << "2. Register\n";
cout << "3. Forgot Password\n";
cout << "4. Exit\n\n";
cout << "Enter your choice: ";
cin >> choice;
cout << endl;
//handle choice
switch (choice) {
case 1:
login();
break;
case 2:
registration();
break;
case 3:
system("cls");
forgotPassword();
break;
case 4:
system("cls");
cout << "Thank you for using this app." << endl;
break;
default:
system("cls");
cout << "-- Invalid number " << choice << " --" << endl;
main();
}
return 0;
}
//login function
void login() {
int count = 0;
string userId, password, id, pass;
system("cls");
cout << "::Enter the username and password::\n\n" << endl;
cout << "Username: ";
cin >> userId;
cout << "Password: ";
cin >> password;
ifstream input("users.txt");
while (input >> id >> pass) {
if (id == userId && pass == password) {
count = 1;
system("cls");
}
}
input.close();
if (count == 1) {
cout << "Login Successful!\n\n" << userId << endl;
main();
}
else {
cout << "\n-- Username or password is invalid. --" << endl;
}
}
//register function
void registration() {
string userId, password, id, pass;
system("cls");
cout << "::Enter the username and password::\n\n" << endl;
cout << "Username: ";
cin >> userId;
cout << "Password: ";
cin >> password;
ofstream newUser("users.txt", ios::app);
newUser << userId << ' ' << password << endl;
system("cls");
cout << "-- Registration Successful! --\n\n" << endl;
main();
}
//forgot password function
void forgotPassword() {
int option;
cout << "::Forgot Password::\n\n" << endl;
cout << "1. Search by username" << endl;
cout << "2. Go Back\n" << endl;
cout << "Select option: ";
cin >> option;
switch (option) {
case 1 : {
int count = 0;
string userId, password, id, pass;
cout << "Enter your username: ";
cin >> userId;
ifstream users("users.txt");
while (users >> id >> pass) {
if (id == userId) {
count = 1;
}
}
users.close();
if (count == 1) {
system("cls");
cout << "-- User Found --\n" << endl;
cout << "Username: " << userId << endl;
cout << "Password: " << pass << endl;
}
else {
system("cls");
cout << "Account doesn't exist!\n" << endl;
main();
}
break;
}
case 2: {
system("cls");
main();
}
default:
system("cls");
cout << "-- Invalid number " << option << " --" << endl;
forgotPassword();
}
}
</code></pre>
|
[
{
"answer_id": 74472876,
"author": "nick",
"author_id": 20213170,
"author_profile": "https://Stackoverflow.com/users/20213170",
"pm_score": 2,
"selected": false,
"text": " else {\n system(\"cls\");\n cout << \"Account doesn't exist!\\n\" << endl;\n main(); // Don't do this\n }\n"
},
{
"answer_id": 74473150,
"author": "Javari",
"author_id": 11448600,
"author_profile": "https://Stackoverflow.com/users/11448600",
"pm_score": 2,
"selected": true,
"text": "int main()\n{\n bool continue_program = true;\n while (continue_program)\n {\n\n int choice;\n\n cout << \"-------------- WELCOME --------------\\n\";\n cout << \"::Select Action::\\n\\n\";\n\n cout << \"1. Login\\n\";\n cout << \"2. Register\\n\";\n cout << \"3. Forgot Password\\n\";\n cout << \"4. Exit\\n\\n\";\n\n cout << \"Enter your choice: \";\n cin >> choice;\n\n cout << endl;\n\n // handle choice\n switch (choice)\n {\n case 1:\n login();\n break;\n\n case 2:\n registration();\n break;\n\n case 3:\n system(\"cls\");\n forgotPassword();\n break;\n\n case 4:\n system(\"cls\");\n cout << \"Thank you for using this app.\" << endl;\n continue_program = false;\n break;\n\n default:\n system(\"cls\");\n cout << \"-- Invalid number \" << choice << \" --\" << endl;\n }\n }\n return 0;\n}\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472598",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18143615/"
] |
74,472,601
|
<p>how is the procedure to transfer one plugin to site A to B with the plugin data included? I am able to transfer the FTP data for sure but I need the saved files of the plugin also. So I need to do some actions in the database.</p>
<p>Where do I find the plugins database, where to extract and import it? Did not find it in wpoptions.</p>
<p>Bests,</p>
<p>Download FTP data and extract it in new site.</p>
|
[
{
"answer_id": 74472876,
"author": "nick",
"author_id": 20213170,
"author_profile": "https://Stackoverflow.com/users/20213170",
"pm_score": 2,
"selected": false,
"text": " else {\n system(\"cls\");\n cout << \"Account doesn't exist!\\n\" << endl;\n main(); // Don't do this\n }\n"
},
{
"answer_id": 74473150,
"author": "Javari",
"author_id": 11448600,
"author_profile": "https://Stackoverflow.com/users/11448600",
"pm_score": 2,
"selected": true,
"text": "int main()\n{\n bool continue_program = true;\n while (continue_program)\n {\n\n int choice;\n\n cout << \"-------------- WELCOME --------------\\n\";\n cout << \"::Select Action::\\n\\n\";\n\n cout << \"1. Login\\n\";\n cout << \"2. Register\\n\";\n cout << \"3. Forgot Password\\n\";\n cout << \"4. Exit\\n\\n\";\n\n cout << \"Enter your choice: \";\n cin >> choice;\n\n cout << endl;\n\n // handle choice\n switch (choice)\n {\n case 1:\n login();\n break;\n\n case 2:\n registration();\n break;\n\n case 3:\n system(\"cls\");\n forgotPassword();\n break;\n\n case 4:\n system(\"cls\");\n cout << \"Thank you for using this app.\" << endl;\n continue_program = false;\n break;\n\n default:\n system(\"cls\");\n cout << \"-- Invalid number \" << choice << \" --\" << endl;\n }\n }\n return 0;\n}\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472601",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20528237/"
] |
74,472,620
|
<p>After creating an exe of a script (the script was working on its own) with py2exe I got the following error:</p>
<pre><code>Traceback (most recent call last):
File "script.py", line 3, in <module>
File "zipextimporter.pyc", line 167, in exec_module
File "src\import_clixml.pyc", line 1, in <module>
File "zipextimporter.pyc", line 150, in create_module
ImportError: MemoryLoadLibrary failed loading win32crypt.pyd: The specified module could not be found. (126)
</code></pre>
<p>Which was weird, because I compiled a different script using the exact same library and there it worked just fine. It didn't even work when bundle_files = 3 option was used and the file was clearly available in the location the exe was searching in. It also used to work fine with Python 3.10 and old way of creating exes (<code>distutils</code> and <code>python setup.py</code>)</p>
<p>MCVE:</p>
<p>Python 3.11</p>
<p>py2exe 0.13</p>
<h2>script.py</h2>
<pre><code>import win32crypt
</code></pre>
<h2>setup.py</h2>
<pre><code>import py2exe
py2exe.freeze(
windows=[
{
"script": "script.py",
}
],
)
</code></pre>
<p>Running the setup.py creates an exe, but trying to run it results in an immediate error with import win32crypt not found error.</p>
|
[
{
"answer_id": 74472876,
"author": "nick",
"author_id": 20213170,
"author_profile": "https://Stackoverflow.com/users/20213170",
"pm_score": 2,
"selected": false,
"text": " else {\n system(\"cls\");\n cout << \"Account doesn't exist!\\n\" << endl;\n main(); // Don't do this\n }\n"
},
{
"answer_id": 74473150,
"author": "Javari",
"author_id": 11448600,
"author_profile": "https://Stackoverflow.com/users/11448600",
"pm_score": 2,
"selected": true,
"text": "int main()\n{\n bool continue_program = true;\n while (continue_program)\n {\n\n int choice;\n\n cout << \"-------------- WELCOME --------------\\n\";\n cout << \"::Select Action::\\n\\n\";\n\n cout << \"1. Login\\n\";\n cout << \"2. Register\\n\";\n cout << \"3. Forgot Password\\n\";\n cout << \"4. Exit\\n\\n\";\n\n cout << \"Enter your choice: \";\n cin >> choice;\n\n cout << endl;\n\n // handle choice\n switch (choice)\n {\n case 1:\n login();\n break;\n\n case 2:\n registration();\n break;\n\n case 3:\n system(\"cls\");\n forgotPassword();\n break;\n\n case 4:\n system(\"cls\");\n cout << \"Thank you for using this app.\" << endl;\n continue_program = false;\n break;\n\n default:\n system(\"cls\");\n cout << \"-- Invalid number \" << choice << \" --\" << endl;\n }\n }\n return 0;\n}\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472620",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9296093/"
] |
74,472,642
|
<p>I'm executing a script with the PowerShell SDK, which makes use of all different streams (information, warning, verbose, ..). I can capture the output from them correctly, but not in the sequence they are generated. As an example, here is a console app (C#, .NET 7, installed the NuGet package <em>Microsoft.PowerShell.SDK</em>):</p>
<pre class="lang-cs prettyprint-override"><code>using System.Management.Automation.Runspaces;
var runSpace = RunspaceFactory.CreateRunspace(InitialSessionState.CreateDefault());
runSpace.Open();
var instance = System.Management.Automation.PowerShell.Create(runSpace);
instance.AddScript("""
$VerbosePreference = 'Continue'
Write-Verbose "Line 1"
Write-Output "Line 2"
Write-Verbose "Line 3"
Write-Information "Line 4"
Write-Information "Line 5"
Write-Verbose "Line 6"
"""
);
var output = instance.Invoke();
foreach (var o in output)
{
Console.WriteLine($"[N]: {o}");
}
foreach (var v in instance.Streams.Verbose)
{
Console.WriteLine($"[V]: {v}");
}
foreach (var i in instance.Streams.Information)
{
Console.WriteLine($"[I]: {i}");
}
</code></pre>
<p>As you can see I'm returning different results on different streams. When I output them like that of course, they are no longer in the correct order:</p>
<pre><code>[N]: Line 2
[V]: Line 1
[V]: Line 3
[V]: Line 6
[I]: Line 4
[I]: Line 5
</code></pre>
<p>I have been looking at the objects provided by <code>instance.Streams.Information</code>, <code>instance.Streams.Verbose</code>, etc. - but I could not find a property that would let me sort them. Interestingly <code>instance.Streams.Information</code> has a <code>TimeGenerated</code>, but it is missing from all the other stream objects!</p>
<p>So I'm stumped how I could accomplish this, would it be possible to get these sorted based on the time they were generated?</p>
|
[
{
"answer_id": 74474772,
"author": "Thomas Glaser",
"author_id": 1244910,
"author_profile": "https://Stackoverflow.com/users/1244910",
"pm_score": 0,
"selected": false,
"text": "instance.Commands.Commands[0].MergeMyResults(PipelineResultTypes.All,PipelineResultTypes.Output);\n"
},
{
"answer_id": 74474792,
"author": "Mathias R. Jessen",
"author_id": 712649,
"author_profile": "https://Stackoverflow.com/users/712649",
"pm_score": 2,
"selected": true,
"text": "DataAdded"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472642",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1244910/"
] |
74,472,700
|
<p>I have a <code>.csv</code> file that contains 2500 unique request id like "4485-182-65846".
I want to run a elasticsearch query command that contain this request Id.
my query be like:</p>
<pre class="lang-bash prettyprint-override"><code>curl -XGET 127.0.0.1:9200/_search?pretty -d '
{
"query": {
"match": {
"request_id": "$VARIABLE(contents of the file)"
}
}
}' > answer.csv
</code></pre>
<p>Now I want to put every unique id into a VARIBALE and run the query to answer them in a specific file</p>
<p>I would appreciate any help.</p>
<p>I tried this code but did not answer</p>
<pre class="lang-bash prettyprint-override"><code>request_id=(cat file.csv)
for i in request_id;
do
curl -XGET 127.0.0.1:9200/_search?pretty -d '
{
"query": {
"match": {
"request_id": "$i"
}
}
}' > answer.csv
</code></pre>
|
[
{
"answer_id": 74474772,
"author": "Thomas Glaser",
"author_id": 1244910,
"author_profile": "https://Stackoverflow.com/users/1244910",
"pm_score": 0,
"selected": false,
"text": "instance.Commands.Commands[0].MergeMyResults(PipelineResultTypes.All,PipelineResultTypes.Output);\n"
},
{
"answer_id": 74474792,
"author": "Mathias R. Jessen",
"author_id": 712649,
"author_profile": "https://Stackoverflow.com/users/712649",
"pm_score": 2,
"selected": true,
"text": "DataAdded"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472700",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19068624/"
] |
74,472,714
|
<p>I have a constant Enum class that looks something like this:</p>
<pre><code>class Animals(Enum):
Dog= 'dog'
Cat= 'cat'
Chicken = 'chicken'
Horse = 'horse'
</code></pre>
<p>I need to find a simple and efficient way to find the index of one of the members of the Enum. so I came up with the following oneliner:</p>
<pre><code>list(Animals).index(Animals.Chicken)
</code></pre>
<p>output:</p>
<pre><code>2
</code></pre>
<p>The problem is, parsing to a list and searching it again is not efficient enough, and I can't change the constant.
It feels like there should be a simple solution that I'm missing.</p>
|
[
{
"answer_id": 74474772,
"author": "Thomas Glaser",
"author_id": 1244910,
"author_profile": "https://Stackoverflow.com/users/1244910",
"pm_score": 0,
"selected": false,
"text": "instance.Commands.Commands[0].MergeMyResults(PipelineResultTypes.All,PipelineResultTypes.Output);\n"
},
{
"answer_id": 74474792,
"author": "Mathias R. Jessen",
"author_id": 712649,
"author_profile": "https://Stackoverflow.com/users/712649",
"pm_score": 2,
"selected": true,
"text": "DataAdded"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472714",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11239996/"
] |
74,472,720
|
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>function myfunc(){
document.getElementById("bob").innerText += "azerty";
}</code></pre>
<pre class="snippet-code-css lang-css prettyprint-override"><code>#bob{
color: green;
transition: all 1s;
}
#bob:modified{ /* ":modified" pseudo-class doesn't exists; I'm searching for the good one */
color: red;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><div>I would like the green text below to turn red when it changes and then green again.</div>
<div id="bob">azerty</div>
<button onclick="myfunc();">click to modify</button></code></pre>
</div>
</div>
</p>
<p>I want to create a transition when I modify the text of my node via javascript. Is there a selector for nodes whose content is modified?</p>
<p>I tried ":first-child" by deleting then recreating the node, and ":defined", but it did not work.</p>
<p>I would like the transition to apply when the text is changed.</p>
|
[
{
"answer_id": 74472943,
"author": "jeremy-denis",
"author_id": 3054722,
"author_profile": "https://Stackoverflow.com/users/3054722",
"pm_score": 1,
"selected": false,
"text": "bob.dataset.modified = true;\nbob.classList.add('modified');\n"
},
{
"answer_id": 74473250,
"author": "Jerome Demantke",
"author_id": 4015022,
"author_profile": "https://Stackoverflow.com/users/4015022",
"pm_score": 0,
"selected": false,
"text": "function myfunc(){\n let bob = document.getElementById(\"bob\")\n bob.innerText += \"azerty\"; \n bob.classList.add('modified');\n setTimeout(function() { bob.classList.remove('modified'); }, 1000);\n}"
},
{
"answer_id": 74481643,
"author": "Bergi",
"author_id": 1048572,
"author_profile": "https://Stackoverflow.com/users/1048572",
"pm_score": 2,
"selected": true,
"text": "const el = document.getElementById(\"bob\");\nconst [modifiedAnimation] = el.getAnimations();\nmodifiedAnimation.pause(); // don't run immediately\nfunction myfunc(){\n el.innerText += \"azerty\";\n modifiedAnimation.play();\n}"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472720",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4015022/"
] |
74,472,746
|
<p>the close isnt working, the dialogRef.close() is undefined??</p>
<p>Here is the code
template</p>
<pre><code> <button mat-raised-button (click)="openModal()">Open Project Specifics</button>
</code></pre>
<p>TS</p>
<pre><code> openModal(){
let dialogRef = this.dialog.open(ProjectSpecificContentComponent, {
data:{projectsSpecifics: this.projectSpecific},
panelClass: 'project-content-dialog'
})
dialogRef.afterClosed().subscribe(result => console.log(result))
}
</code></pre>
<p>here is the called Component</p>
<pre><code> <button mat-dialog-close>X</button>
<div class="container">
<div class="project-specific" *ngFor="let projectS of projectSpecificList">
<h5>{{projectS.name}}</h5>
<mat-form-field appearance="fill" class="mat-group">
<mat-label>Add project specific</mat-label>
<mat-select multiple>
<mat-option *ngFor="let item of getContent(projectS)">{{item.content}}</mat-
option>
</mat-select>
</mat-form-field>
</div>
</div>
<div mat-dialog-actions>
<button (click)="onClose()" mat-raised-button>Done!</button>
</div>
</code></pre>
<p>and TS</p>
<pre><code> constructor(@Inject(MAT_DIALOG_DATA) public data: any,
public dialogRef: MatDialogRef<ProjectSpecificContentComponent>,
) { }
onClose(){
this.dialogRef.close();
}
</code></pre>
<p>Also here you can see the module where i imported the component</p>
<pre><code> imports[MatDialogModule]
entryComponents: [ProjectSpecificContentComponent]
</code></pre>
|
[
{
"answer_id": 74472943,
"author": "jeremy-denis",
"author_id": 3054722,
"author_profile": "https://Stackoverflow.com/users/3054722",
"pm_score": 1,
"selected": false,
"text": "bob.dataset.modified = true;\nbob.classList.add('modified');\n"
},
{
"answer_id": 74473250,
"author": "Jerome Demantke",
"author_id": 4015022,
"author_profile": "https://Stackoverflow.com/users/4015022",
"pm_score": 0,
"selected": false,
"text": "function myfunc(){\n let bob = document.getElementById(\"bob\")\n bob.innerText += \"azerty\"; \n bob.classList.add('modified');\n setTimeout(function() { bob.classList.remove('modified'); }, 1000);\n}"
},
{
"answer_id": 74481643,
"author": "Bergi",
"author_id": 1048572,
"author_profile": "https://Stackoverflow.com/users/1048572",
"pm_score": 2,
"selected": true,
"text": "const el = document.getElementById(\"bob\");\nconst [modifiedAnimation] = el.getAnimations();\nmodifiedAnimation.pause(); // don't run immediately\nfunction myfunc(){\n el.innerText += \"azerty\";\n modifiedAnimation.play();\n}"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472746",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19198215/"
] |
74,472,761
|
<p>I have 3 table: <code>tasks</code>, <code>users</code>, <code>group</code>, and a pivot table <code>group_user</code>.</p>
<p>A task has <code>user_id</code>, <code>group_id</code></p>
<p>A group_user pivot table has <code>user_id</code>, <code>group_id</code></p>
<p>I want to query the tasks if the task belongs to a group of the user.</p>
<p>I don't want tasks from groups that the user doesn't belong to.</p>
<p>What I have so far:</p>
<pre><code>public function index()
{
$userId = Auth::user()->id;
return TaskResource::collection(
Task::
latest()
->whereHas('group', function($query) use($userId) {
$query->where('group_id', '=', $userId); // = is wrong
})
->get()
);
}
</code></pre>
<p>This gives me empty results, I tried to think about it but my head hurts</p>
|
[
{
"answer_id": 74473486,
"author": "Devon Ray",
"author_id": 10037470,
"author_profile": "https://Stackoverflow.com/users/10037470",
"pm_score": 0,
"selected": false,
"text": "\n$query->whereHas('user', function($q2) use ($userId) {\n $q2->where('user_id', $userId);\n});\n"
},
{
"answer_id": 74473960,
"author": "baleghsefat",
"author_id": 9345941,
"author_profile": "https://Stackoverflow.com/users/9345941",
"pm_score": 2,
"selected": true,
"text": "$userId = auth()->id(); \n\n$tasks = Task::latest()\n ->whereHas('group', function($query) use ($userId) {\n $query->whereHas('users', function($query) use ($userId) {\n $query->where('user_id', $userId);\n });\n })\n ->get();\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472761",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20178708/"
] |
74,472,768
|
<p>I would like to refactor my method. I also need to get which value was first? So which anyOf? Is it possible to get it from here?</p>
<p>Example:</p>
<pre><code>List<string> anyOf = new List<string>(){"at", "near", "by", "above"};
string source = "South Branch Raritan River near High Bridge at NJ"
public static int IndexOfAny(this string source, IEnumerable<string> anyOf, StringComparison stringComparisonType = StringComparison.CurrentCultureIgnoreCase)
{
var founds = anyOf
.Select(sub => source.IndexOf(sub, stringComparisonType))
.Where(i => i >= 0);
return founds.Any() ? founds.Min() : -1;
}
</code></pre>
<p>I would like to get back what is first in string. "near" or "at".</p>
|
[
{
"answer_id": 74472919,
"author": "Tim Schmelter",
"author_id": 284240,
"author_profile": "https://Stackoverflow.com/users/284240",
"pm_score": 3,
"selected": true,
"text": "public static (int index, string? firstMatch) IndexOfAny(this string source, IEnumerable<string> anyOf, StringComparison stringComparisonType = StringComparison.CurrentCultureIgnoreCase)\n{\n return anyOf\n .Select(s => (Index: source.IndexOf(s, stringComparisonType), String: s))\n .Where(x => x.Index >= 0)\n .DefaultIfEmpty((-1, null))\n .First();\n}\n"
},
{
"answer_id": 74475855,
"author": "Jodrell",
"author_id": 659190,
"author_profile": "https://Stackoverflow.com/users/659190",
"pm_score": 0,
"selected": false,
"text": "public static class Extensions\n{\n public static int IndexOfAny<T>(\n this IEnumerable<T> source,\n IEnumerable<IEnumerable<T>> targets,\n IEqualityComparer<T> comparer = null)\n {\n // Parameter Handling\n comparer = comparer ?? EqualityComparer<T>.Default;\n ArgumentNullException.ThrowIfNull(targets);\n \n var clean = targets\n .Where(t => t != null)\n .Select(t => t.ToArray())\n .Where(t => t.Length > 0)\n .ToArray();\n \n if (clean.Length == 0)\n {\n throw new ArgumentException(\n $\"'{nameof(targets)}' does not contain a valid search sequence\");\n }\n \n // Prep\n var lengths = clean.Select(t => t.Length).ToArray();\n var indices = clean.Select(_ => 0).ToArray();\n int i = 0;\n \n // Process\n foreach(var t in source)\n {\n i++;\n for(var j = 0; j < clean.Length; j++)\n {\n var index = indices[j];\n if (comparer.Equals(clean[j][index], t))\n {\n index += 1;\n if (index == lengths[j])\n {\n return i - lengths[j];\n }\n \n indices[j] = index;\n }\n else\n {\n if (index != 0)\n {\n indices[j] = 0;\n }\n }\n }\n }\n \n return -1;\n }\n \n public static int IndexOfAny(\n this string source,\n IEnumerable<string> targets,\n StringComparer comparer = null)\n {\n comparer = comparer ?? StringComparer.Ordinal;\n ArgumentNullException.ThrowIfNull(targets);\n return source.ToCharArray().IndexOfAny(\n targets.Select(t => t.ToCharArray()),\n new CharComparerAdapter(comparer));\n }\n}\n\npublic class CharComparerAdapter : IEqualityComparer<char>\n{\n private StringComparer Comparer { get; }\n \n public CharComparerAdapter(StringComparer comparer)\n {\n ArgumentNullException.ThrowIfNull(comparer);\n Comparer = comparer;\n }\n \n public bool Equals(char left, char right)\n {\n return Comparer.Equals(left.ToString(), right.ToString());\n }\n \n public int GetHashCode(char v)\n {\n return v;\n }\n}\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472768",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/267679/"
] |
74,472,777
|
<p>I need a help with code, when i compile code, evrething ok, when i choose remove, evrething ok, but when i write my val, i see that error "Exception thrown: Read access violation.
front was nullptr."</p>
<p>In main can be something problems, its because i send not all code, just part when i use my function bool remove_Queue(Item& i, Queue* front, Queue* back, int& x)</p>
<p>code :</p>
<pre><code>typedef int Item;
const int MAX_QUEUE = 10;
int cont = 0;
typedef int Item;
struct Queue {
Item value;
Queue* next;
};
Queue* front;
Queue* back;
Queue* tmp;
bool insert_Queue( Item& i, Queue* front, Queue* back,Item x)
{
tmp = new Queue;
tmp->next = NULL;
tmp->value = 1;
front = back = tmp;
return true;
}
bool remove_Queue(Item& i, Queue* front, Queue* back, int& x)
{
if (front == NULL) return false;
i = front->value;
x --;
Queue* tmp = front;
front = front->next;
delete tmp;
if (x == 0) back = NULL;
return true;
}
int main()
{
while (1)
{
printf("\t\tChoose\n\n");
printf("1.Stack\t\t2.Queue\t\t3.List\n\n");
printf("Choose: ");
scanf_s("%d", &choice1);
while (1)
{
printf("\nOperations performed by Queue");
printf("\n1.Insert\t\t2.Remove\n3.Print queue\t\t4.Pop from start\n5.Count\t\t6.Is empty?\n7.Delete Queue\t\t8.Exit");
printf("\n\nEnter the choice: ");
scanf_s("%d", &choice2);
switch (choice2)
{
case 1:
{
int i;
printf("input value:");
scanf_s("%d", &i);
insert_Queue(i, front, back, cont);
x += 1;
break;
}
case 2:
{
Item val;
printf("input value:");
scanf_s("%d", &val);
remove_Queue(val, front, back, x);
break;
}
case 3:
{
print_Queue(front);
break;
}
case 4:
{
break;
}
case 5:
{
count_Queue(x);
break;
}
case 6:
{
isЕmpty_Queue(front);
break;
}
case 7:
{
delete_Queue(front, back, x);
break;
}
case 8:
{
exit(0);
}
default: printf("\n\n\nInvalid choice!!\n\n\n");
}
}
}
return 0;
}
</code></pre>
<p>I expecting when i call function remove_Queue, my program will remoove value which in start of Queue</p>
|
[
{
"answer_id": 74472919,
"author": "Tim Schmelter",
"author_id": 284240,
"author_profile": "https://Stackoverflow.com/users/284240",
"pm_score": 3,
"selected": true,
"text": "public static (int index, string? firstMatch) IndexOfAny(this string source, IEnumerable<string> anyOf, StringComparison stringComparisonType = StringComparison.CurrentCultureIgnoreCase)\n{\n return anyOf\n .Select(s => (Index: source.IndexOf(s, stringComparisonType), String: s))\n .Where(x => x.Index >= 0)\n .DefaultIfEmpty((-1, null))\n .First();\n}\n"
},
{
"answer_id": 74475855,
"author": "Jodrell",
"author_id": 659190,
"author_profile": "https://Stackoverflow.com/users/659190",
"pm_score": 0,
"selected": false,
"text": "public static class Extensions\n{\n public static int IndexOfAny<T>(\n this IEnumerable<T> source,\n IEnumerable<IEnumerable<T>> targets,\n IEqualityComparer<T> comparer = null)\n {\n // Parameter Handling\n comparer = comparer ?? EqualityComparer<T>.Default;\n ArgumentNullException.ThrowIfNull(targets);\n \n var clean = targets\n .Where(t => t != null)\n .Select(t => t.ToArray())\n .Where(t => t.Length > 0)\n .ToArray();\n \n if (clean.Length == 0)\n {\n throw new ArgumentException(\n $\"'{nameof(targets)}' does not contain a valid search sequence\");\n }\n \n // Prep\n var lengths = clean.Select(t => t.Length).ToArray();\n var indices = clean.Select(_ => 0).ToArray();\n int i = 0;\n \n // Process\n foreach(var t in source)\n {\n i++;\n for(var j = 0; j < clean.Length; j++)\n {\n var index = indices[j];\n if (comparer.Equals(clean[j][index], t))\n {\n index += 1;\n if (index == lengths[j])\n {\n return i - lengths[j];\n }\n \n indices[j] = index;\n }\n else\n {\n if (index != 0)\n {\n indices[j] = 0;\n }\n }\n }\n }\n \n return -1;\n }\n \n public static int IndexOfAny(\n this string source,\n IEnumerable<string> targets,\n StringComparer comparer = null)\n {\n comparer = comparer ?? StringComparer.Ordinal;\n ArgumentNullException.ThrowIfNull(targets);\n return source.ToCharArray().IndexOfAny(\n targets.Select(t => t.ToCharArray()),\n new CharComparerAdapter(comparer));\n }\n}\n\npublic class CharComparerAdapter : IEqualityComparer<char>\n{\n private StringComparer Comparer { get; }\n \n public CharComparerAdapter(StringComparer comparer)\n {\n ArgumentNullException.ThrowIfNull(comparer);\n Comparer = comparer;\n }\n \n public bool Equals(char left, char right)\n {\n return Comparer.Equals(left.ToString(), right.ToString());\n }\n \n public int GetHashCode(char v)\n {\n return v;\n }\n}\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472777",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20528299/"
] |
74,472,796
|
<p>I have a requirement to build a regex pattern to validate a String in Java. Hence I build a pattern
<code>[A-Z][a-z]*\s?[A-Z]?[a-z]*$</code> for the conditions:</p>
<ul>
<li>Should start with caps</li>
<li>Every other Word should start with caps</li>
<li>No numbers included</li>
<li>no consecutive two spaces allowed</li>
</ul>
<p><code>Pattern.matches("[A-Z][a-z]*\s?[A-Z]?[a-z]*$","Joe V")</code> returns <code>false</code> for me in java.
But the same pattern returns true for the data "Joe V" in regexr.com.</p>
<p>What might be the cause?</p>
|
[
{
"answer_id": 74472858,
"author": "Wiktor Stribiżew",
"author_id": 3832970,
"author_profile": "https://Stackoverflow.com/users/3832970",
"pm_score": 0,
"selected": false,
"text": "Pattern.matches(\"[A-Z][a-z]*(?:\\\\s[A-Z][a-z]*)*\",\"Joe V\")\nPattern.matches(\"\\\\p{Lu}\\\\p{Ll}*(?:\\\\s\\\\p{Lu}\\\\p{Ll}*)*\",\"Joe V\")\n"
},
{
"answer_id": 74475021,
"author": "berse2212",
"author_id": 20184128,
"author_profile": "https://Stackoverflow.com/users/20184128",
"pm_score": 1,
"selected": false,
"text": "\\"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472796",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19839205/"
] |
74,472,807
|
<p>I would like to format a text differently within a "p" tag with a class. There is a line break by "br" and the following text should be formatted differently.
Is there a solution for this from css?<br />
Below is the code example.</p>
<p>To-Do:
Format ${getDate(loadStoredTasks())}" different to ${zaehlerRechner(loadStoredTasks())}</p>
<pre><code><div class="list-task-responsible">
<img src="img/energy-consumption_light.png"/>
<p class="list-task-notes">${zaehlerRechner(loadStoredTasks())} <br>
${getDate(loadStoredTasks())}</p>
</div>
</code></pre>
<p><a href="https://i.stack.imgur.com/e93zu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/e93zu.png" alt="enter image description here" /></a></p>
<p><strong>800,10 kWh</strong>: is correct</p>
<p><strong>17.11.2022 - 20.11.2022</strong>: should have other format (should look like: 17.11.2022 - 20.11.2022)</p>
|
[
{
"answer_id": 74472925,
"author": "corcre",
"author_id": 19954006,
"author_profile": "https://Stackoverflow.com/users/19954006",
"pm_score": 0,
"selected": false,
"text": ".list-task-notes{\n font-weight: normal;\n}\n.list-task-notes::first-line {\n font-weight: bold;\n}\n"
},
{
"answer_id": 74472926,
"author": "Dream Bold",
"author_id": 12743692,
"author_profile": "https://Stackoverflow.com/users/12743692",
"pm_score": 0,
"selected": false,
"text": "div p::first-line{ /*Some styling here*/ }"
},
{
"answer_id": 74472934,
"author": "Fabrizio Calderan",
"author_id": 1098851,
"author_profile": "https://Stackoverflow.com/users/1098851",
"pm_score": 3,
"selected": true,
"text": ".list-task-notes {\n font: 2rem/1 system-ui;\n}\n\n.list-task-notes small {\n font-size: 50%;\n}"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472807",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16460726/"
] |
74,472,823
|
<p>There are two PCs with Visual Studio 2017 installed. I'm running a simple program on both of them, one that lists the name of modules (exes/DLLs) inside its own process.
But I get wildly different results. On one PC, I only get 7 modules:</p>
<pre><code> Lab7_1.exe
ntdll.dll
KERNEL32.DLL
KERNELBASE.dll
MSVCP140D.dll
VCRUNTIME140D.dll
ucrtbased.dll
</code></pre>
<p>On the other, I get whopping 31 modules. The full list includes, for example, user32.dll, which my sample program isn't using (it's a console app, not a GUI app).</p>
<p>So the question is: <em>what exactly affects the list of DLLs imported by default?</em> Debug/Release and x86/x64 switches produces some difference, but nothing that drastic.
Differences between platform tools versions (and corresponding versions of MS VC++ Redist) I can understand, but why are different system DLLs being imported as well?
I'm unsure where else to look.</p>
<p>Context: it's a part of an assignment. On of those PCs is mine, the other is where the students work. The assignment goes like this "We have this set of modules by default, now we use <code>MessageBoxA()</code>, and we see that more modules are imported, user32.dll among them". Which doesn't quite work if user32.dll is always imported by default.
Since the behaviour is vastly different, and I can't reproduce it on my PC, it's hard to adapt the assignment so the students can see import mechanics at work.</p>
<p>Sample program code:</p>
<pre><code>#include <iostream>
#include <vector>
#include <string>
#include <Windows.h>
#include <Psapi.h>
using namespace std;
#pragma comment(lib, "psapi.lib") //needed for MS VS 2010
void EnumerateModules(vector<HMODULE>& modules)
{
HANDLE me = GetCurrentProcess();
DWORD needed_size = 0;
while (true)
{
DWORD actual_size = modules.size() * sizeof(HMODULE);
EnumProcessModules(
me, //which process
modules.data(), //where to put the module handlers
actual_size, //allocated buffer size
&needed_size //desired buffer size
);
if (needed_size != actual_size)
modules.resize(needed_size / sizeof(HMODULE));
else
break;
}
}
string ModuleName(HMODULE module)
{
HANDLE me = GetCurrentProcess();
string buffer(FILENAME_MAX, 0);
DWORD real_length = GetModuleBaseNameA(
me, //which process
module, //which module
&buffer[0], //where to put the name
buffer.size() //size of the name buffer
);
if (real_length > 0)
return buffer.substr(0, real_length);
buffer = "";
return buffer;
}
int main(int argc, char* argv[])
{
setlocale(0, "");
vector<HMODULE> modules;
EnumerateModules(modules);
cout << modules.size() << " modules:" << endl;
for (size_t i = 0; i < modules.size(); i++)
{
string name = ModuleName(modules[i]);
cout << name.c_str() << endl;
}
return 0;
}
</code></pre>
|
[
{
"answer_id": 74472925,
"author": "corcre",
"author_id": 19954006,
"author_profile": "https://Stackoverflow.com/users/19954006",
"pm_score": 0,
"selected": false,
"text": ".list-task-notes{\n font-weight: normal;\n}\n.list-task-notes::first-line {\n font-weight: bold;\n}\n"
},
{
"answer_id": 74472926,
"author": "Dream Bold",
"author_id": 12743692,
"author_profile": "https://Stackoverflow.com/users/12743692",
"pm_score": 0,
"selected": false,
"text": "div p::first-line{ /*Some styling here*/ }"
},
{
"answer_id": 74472934,
"author": "Fabrizio Calderan",
"author_id": 1098851,
"author_profile": "https://Stackoverflow.com/users/1098851",
"pm_score": 3,
"selected": true,
"text": ".list-task-notes {\n font: 2rem/1 system-ui;\n}\n\n.list-task-notes small {\n font-size: 50%;\n}"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472823",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2201663/"
] |
74,472,843
|
<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>.editor {
width: 100%;
min-height: 100%;
height: 100%;
background-color: black;
color: #fff;
}
canvas {
background-color: green;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="editor" contenteditable><canvas></canvas></div></code></pre>
</div>
</div>
</p>
<p>How could I add canvas to contenteditable div</p>
<p>I have this code</p>
<pre><code><style>
.editor {
width: 100%;
min-height: 100%;
height: 100%;
background-color: black;
color: #fff;
}
canvas {
background-color: green;
}
</style>
<div class="editor" contenteditable><canvas></canvas></div>
</code></pre>
<p>For some reason I'm not able to write anything into the contenteditable div and even the caret somehow disappear. What I'm doing wrong? A help would be appreciated.</p>
|
[
{
"answer_id": 74472925,
"author": "corcre",
"author_id": 19954006,
"author_profile": "https://Stackoverflow.com/users/19954006",
"pm_score": 0,
"selected": false,
"text": ".list-task-notes{\n font-weight: normal;\n}\n.list-task-notes::first-line {\n font-weight: bold;\n}\n"
},
{
"answer_id": 74472926,
"author": "Dream Bold",
"author_id": 12743692,
"author_profile": "https://Stackoverflow.com/users/12743692",
"pm_score": 0,
"selected": false,
"text": "div p::first-line{ /*Some styling here*/ }"
},
{
"answer_id": 74472934,
"author": "Fabrizio Calderan",
"author_id": 1098851,
"author_profile": "https://Stackoverflow.com/users/1098851",
"pm_score": 3,
"selected": true,
"text": ".list-task-notes {\n font: 2rem/1 system-ui;\n}\n\n.list-task-notes small {\n font-size: 50%;\n}"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472843",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20426234/"
] |
74,472,849
|
<p>Weird title, but the question is pretty complex. (Please don't hesitate to change the title if you know a better one)</p>
<p>I need to create a fresh new list with altered keys from other list, substrings from keys to check key name of other list and match these key substrings with another key from list.</p>
<p>I hope it gets clear when I try to clarify what I need.</p>
<p>First list named <code>ansible_facts["ansible_net_virtual-systems"][0].vsys_zonelist</code> outputs this:</p>
<pre class="lang-json prettyprint-override"><code>{
"ansible_facts": {
"ansible_net_virtual-systems": [
{
"vsys_zonelist": [
"L3_v0123_Zone1",
"L3_v0124_Zone2",
"L3_v0125_Zone3",
"L3_Trans_v0020_Zone4"
]
}
]
}
}
</code></pre>
<p>Second list <code>ansible_facts.ansible_net_routing_table</code>:</p>
<pre class="lang-json prettyprint-override"><code>{
"ansible_facts": {
"ansible_net_routing_table": [
{
"virtual_router": "Internal",
"destination": "10.12.123.0/24",
"nexthop": "0.0.0.0",
"metric": "10",
"flags": " Oi ",
"age": "3924798",
"interface": "ae1.123",
"route_table": "unicast"
},
{
"virtual_router": "Internal",
"destination": "10.12.124.0/24",
"nexthop": "0.0.0.0",
"metric": "10",
"flags": " Oi ",
"age": "3924798",
"interface": "ae1.124",
"route_table": "unicast"
},
{
"virtual_router": "Internal",
"destination": "10.12.125.0/24",
"nexthop": "0.0.0.0",
"metric": "10",
"flags": " Oi ",
"age": "3924798",
"interface": "ae1.125",
"route_table": "unicast"
},
{
"virtual_router": "Internal",
"destination": "10.12.20.0/24",
"nexthop": "0.0.0.0",
"metric": "10",
"flags": " Oi ",
"age": "3924798",
"interface": "ae1.20",
"route_table": "unicast"
}
]
}
}
</code></pre>
<p>Now I have the substring v0<strong>123</strong> from first list and <code>interface:</code> ae1.<strong>123</strong> from second list. That means that they belong together. I now need the <code>destination</code> from the second list for each matching lists and also alter the name I get from <code>ansible_facts["ansible_net_virtual-systems"][0].vsys_zonelist</code>.</p>
<p><strong>What I need: Create a list that should look like this:</strong></p>
<p>(<code>"interface": "ae1.123"</code> is not needed anymore. Just a helper to match everything)</p>
<pre class="lang-json prettyprint-override"><code>{
"result_list": [
{
"name": "n-x-123-Zone1",
"destination": "10.12.123.0/24"
},
{
"name": "n-x-124-Zone2",
"destination": "10.12.124.0/24"
},
{
"name": "n-x-125-Zone3",
"destination": "10.12.125.0/24"
},
{
"name": "n-x-20-Zone4",
"destination": "10.12.20.0/24"
}
]
}
</code></pre>
<p>I tried many different ways but somehow I cant manage to get it to work as everything I've done, doesn't help me to create my needed list.</p>
<p>Some input for what I've already tried:</p>
<pre class="lang-yaml prettyprint-override"><code>- name: DEBUG list with split and loop
ansible.builtin.debug:
# creates
# n-x-01-Name
# but no list(!), just messages, but could be useful to create a loop
msg: "n-x-{% if item.split('_')[1].startswith('Client') %}{{ item[3:100] }}{% else %}{{ item.split('_')[1] | regex_replace('v','') }}-{% endif %}{% if item.split('_')[2] is defined and item.split('_')[2].startswith('Trans') %}{{ item[3:50] }}{% elif item.split('_')[1].startswith('Clients')%}{% else %}{{ item[9:100] | default('') }}{% endif %}"
loop: '{{ ansible_facts["ansible_net_virtual-systems"][0].vsys_zonelist }}'
delegate_to: 127.0.0.1
- name: create extract_interface
ansible.builtin.set_fact:
# creates (also see next task)
# {
# {
# "interface": "ae1.123"
# },
# {
# "interface": "ae1.124"
# }
# }
extract_interface: "{{ ansible_facts.ansible_net_routing_table | map(attribute='interface') | map('community.general.dict_kv', 'interface') | list }}"
delegate_to: 127.0.0.1
- name: create map_destination_to_interface
ansible.builtin.set_fact:
# {
# "ae1.123": "10.12.123.0/24",
# "ae1.124": "10.12.124.0/24"
# }
map_destination_to_interface: "{{ ansible_facts.ansible_net_routing_table | zip(extract_interface) | map('combine') | items2dict(key_name='interface', value_name='destination') }}"
delegate_to: 127.0.0.1
</code></pre>
<p>Maybe someone can understand what's needed. Thanks to everyone in advance!</p>
|
[
{
"answer_id": 74472925,
"author": "corcre",
"author_id": 19954006,
"author_profile": "https://Stackoverflow.com/users/19954006",
"pm_score": 0,
"selected": false,
"text": ".list-task-notes{\n font-weight: normal;\n}\n.list-task-notes::first-line {\n font-weight: bold;\n}\n"
},
{
"answer_id": 74472926,
"author": "Dream Bold",
"author_id": 12743692,
"author_profile": "https://Stackoverflow.com/users/12743692",
"pm_score": 0,
"selected": false,
"text": "div p::first-line{ /*Some styling here*/ }"
},
{
"answer_id": 74472934,
"author": "Fabrizio Calderan",
"author_id": 1098851,
"author_profile": "https://Stackoverflow.com/users/1098851",
"pm_score": 3,
"selected": true,
"text": ".list-task-notes {\n font: 2rem/1 system-ui;\n}\n\n.list-task-notes small {\n font-size: 50%;\n}"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472849",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19664607/"
] |
74,472,855
|
<p>I am new to C and recently encountered this problem.</p>
<p>I have two pieces of code:</p>
<pre><code>
#include <stdio.h>
#include <string.h>
int main()
{
char x = 'a';
// char *y=&x;
printf("%ld\n", strlen(&x)); // output: 1
return 0;
}
</code></pre>
<pre><code>#include <stdio.h>
#include <string.h>
int main()
{
char x = 'a';
char *y=&x;
printf("%ld\n", strlen(&x)); //output: 7
return 0;
}
</code></pre>
<p>What exactly happened when I added the variable y that it changed the result?</p>
|
[
{
"answer_id": 74472897,
"author": "Codo",
"author_id": 413337,
"author_profile": "https://Stackoverflow.com/users/413337",
"pm_score": 0,
"selected": false,
"text": "strlen()"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472855",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20528109/"
] |
74,472,882
|
<p>When I run the command <code>kubectl get pods | grep "apisix"</code>, I get the following data</p>
<pre><code>apisix-dev-78549978b7-pvh2v 1/1 Running 6 (4m19s ago) 8m14s
apisix-dev-dashboard-646df79bf-mwkpc 1/1 Running 6 (4m35s ago) 8m12s
apisix-dev-etcd-0 1/1 Running 0 8m12s
apisix-dev-etcd-1 1/1 Running 0 8m11s
apisix-dev-etcd-2 0/1 CrashLoopBackOff 4 (24s ago) 8m11s
apisix-dev-ingress-controller-58f7887759-28cm9 1/1 Running 0 8m11s
apisix-dev-ingress-controller-6cc65c7cb5-k6dx2 0/1 Init:0/1 0 8m9s
</code></pre>
<p>Is there any way to delete all the pods containing the word <code>apisix</code> instead of mentioning every pod name in kubectl delete command?</p>
|
[
{
"answer_id": 74473042,
"author": "Prafull Ladha",
"author_id": 6843187,
"author_profile": "https://Stackoverflow.com/users/6843187",
"pm_score": 1,
"selected": false,
"text": "kubectl delete pod $(kubectl get pod | grep apisix | awk '{print $1}')\n"
},
{
"answer_id": 74473187,
"author": "Michail Alexakis",
"author_id": 1943126,
"author_profile": "https://Stackoverflow.com/users/1943126",
"pm_score": 0,
"selected": false,
"text": "selector"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74472882",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12635985/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.