qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
74,140,084 | <p>I am currently learning recursion in c language. I encountered this when trying out some stuff</p>
<pre><code>#include <stdio.h>
void draw(int x)
{
if (x > 0)
{
draw(x-1);
for (int i = 0; i < x; i++)
{
printf("*");
}
printf("\n");
}
}
int main (void)
{
draw(4);
}
</code></pre>
<p>I expected the code to print:</p>
<pre><code>****
***
**
*
</code></pre>
<p>Instead, it prints:</p>
<pre><code>*
**
***
****
</code></pre>
<p>Can anyone please explain why this is the case?
Thank you.</p>
| [
{
"answer_id": 74140157,
"author": "Vlad from Moscow",
"author_id": 2877241,
"author_profile": "https://Stackoverflow.com/users/2877241",
"pm_score": 1,
"selected": false,
"text": "x"
},
{
"answer_id": 74140221,
"author": "Aconcagua",
"author_id": 1312382,
"author_pro... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140084",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20291579/"
] |
74,140,121 | <p>I have a MySQL table called <code>names</code> with a column names <code>name</code>.</p>
<p>This column has the following values:</p>
<pre><code>Beacher
Ackley
Addison
Caldwell
Cameron
Alcott
Carling
Beardsley
Beldon
</code></pre>
<p>I want to get, alphabetically sorted, the value of every first letter.</p>
<p>Alphabetically sorted the list above is like this:</p>
<pre><code>Ackley
Addison
Alcott
Beacher
Beardsley
Beldon
Caldwell
Cameron
Carling
</code></pre>
<p>The first value starting with <code>A</code> is <code>Ackley</code>, the first value starting with <code>B</code> is <code>Beacher</code> …</p>
<p>So I want the following output:</p>
<pre><code>Ackley
Beacher
Caldwell
</code></pre>
<p>Is this even possible with a single SQL query? How?</p>
| [
{
"answer_id": 74140238,
"author": "James",
"author_id": 6826479,
"author_profile": "https://Stackoverflow.com/users/6826479",
"pm_score": 1,
"selected": false,
"text": "row_number"
},
{
"answer_id": 74142414,
"author": "trillion",
"author_id": 12513693,
"author_profi... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140121",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9548591/"
] |
74,140,135 | <p>How do we customize the Jackson <code>ObjectMapper</code> used by WebFlux OutboundGateway? The normal customization done via <code>Jackson2ObjectMapperBuilder</code> or <code>Jackson2ObjectMapperBuilderCustomizer</code> is NOT respected.</p>
<p>Without this customization, <code>LocalDate</code> is serialized as <code>SerializationFeature.WRITE_DATES_AS_TIMESTAMPS</code>. Sample output - [2022-10-20] and there is NO way to customize the format</p>
| [
{
"answer_id": 74143180,
"author": "cpigeon",
"author_id": 13003044,
"author_profile": "https://Stackoverflow.com/users/13003044",
"pm_score": 0,
"selected": false,
"text": "com.fasterxml.jackson.databind.module.SimpleModule"
},
{
"answer_id": 74157558,
"author": "Artem Bilan... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140135",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11878640/"
] |
74,140,141 | <p>This is not answering my own question, but I'll edit the solution later. This is a follow-up question from topic <a href="https://stackoverflow.com/questions/74136140/python-xml-parsing-without-root-v2/74136951#74136951">HERE</a>.</p>
<p>If I use the solution from this post, I get an error</p>
<pre><code>AttributeError: 'NoneType' object has no attribute 'text'
</code></pre>
<p>The values are in the XML file, so i really don't know what to do...</p>
<p>The code:</p>
<pre><code>import pandas as pd
from bs4 import BeautifulSoup
import xml.etree.ElementTree as ET
files = ["S1.xml"]
#files = glob.glob('./*.xml')
all_data = []
for file in files:
with open(file, "r") as f_in:
soup = BeautifulSoup(f_in.read(), "xml")
all_data.append({"file": file, "A": soup.A.text, "Qfl": soup.Qfl.text})
df = pd.DataFrame(all_data).set_index("file")
df.index.name = None
print(df)
</code></pre>
<p>A sample od S1.xml is here:</p>
<pre><code><?xml version="1.0" encoding="utf-8" standalone="no"?>
<reiXmlPrenos>
<QNH>24788</QNH>
<QNC>9698</QNC>
<RefKlima>42774.8</RefKlima>
<Qf>255340</Qf>
<Qp>597451</Qp>
<CO2>126660</CO2>
<A>2362.8</A>
<Ht>0.336</Ht>
<f0>0.59</f0>
<z>0.105891</z>
<TP>3300</TP>
<Qfaux>2126</Qfaux>
<Qfh>24065</Qfh>
<Qfc>5345</Qfc>
<Qfv>18177</Qfv>
<Qfst>0</Qfst>
<Qfw>195520</Qfw>
<Qfl>10107</Qfl>
<fOVE>6.4</fOVE>
</reiXmlPrenos>
</code></pre>
<p>The error I get</p>
<pre><code> File "<ipython-input-163-14360bc9577e>", line 1, in <module>
runfile('C:/......py', wdir='....n')
File ".....py", line 827, in runfile
execfile(filename, namespace)
File ".....py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File ".....py", line 25, in <module>
all_data.append({"file": file, "A": soup.A.text})
AttributeError: 'NoneType' object has no attribute 'text'
</code></pre>
| [
{
"answer_id": 74140771,
"author": "balderman",
"author_id": 415016,
"author_profile": "https://Stackoverflow.com/users/415016",
"pm_score": 0,
"selected": false,
"text": "import xml.etree.ElementTree as ET\n\nxml = '''<reiXmlPrenos>\n <QNH>24788</QNH>\n <QNC>9698</QNC>\n <RefKlima>42... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140141",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3579151/"
] |
74,140,173 | <p>I have a json that may look like the following:</p>
<pre><code>{
"description": "my description",
"company": "my company"
}
</code></pre>
<p>Or</p>
<pre><code>{
"description": "my description",
"company": {
"name": "my company"
}
}
</code></pre>
<p>How can I deserialize them to a model like below:</p>
<pre><code>public class ResponseModel
{
[JsonProperty("description")]
public string Description {get; set;}
[JsonProperty("company")] // and specify possible list of types as string or CompanyModel
public object Company {get; set;}
}
</code></pre>
| [
{
"answer_id": 74140771,
"author": "balderman",
"author_id": 415016,
"author_profile": "https://Stackoverflow.com/users/415016",
"pm_score": 0,
"selected": false,
"text": "import xml.etree.ElementTree as ET\n\nxml = '''<reiXmlPrenos>\n <QNH>24788</QNH>\n <QNC>9698</QNC>\n <RefKlima>42... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140173",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1601336/"
] |
74,140,201 | <p>I have a character vector of for instance:</p>
<pre><code>x = c("a","b","c")
</code></pre>
<p>and another string that goes like:</p>
<pre><code>y = "The alphabet starts with"
</code></pre>
<p>When I do</p>
<pre><code>paste(y,x)
</code></pre>
<p>I get</p>
<pre><code>[1] "The alphabet starts with a" "The alphabet starts with b"
[3] "The alphabet starts with c"
</code></pre>
<p>But what I want to get is this:</p>
<pre><code>[1] "The alphabet starts with a b c"
</code></pre>
<p>How do I manage to get this?</p>
| [
{
"answer_id": 74140206,
"author": "Maël",
"author_id": 13460602,
"author_profile": "https://Stackoverflow.com/users/13460602",
"pm_score": 3,
"selected": true,
"text": "paste"
},
{
"answer_id": 74142033,
"author": "Jilber Urbina",
"author_id": 1315767,
"author_profil... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140201",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6029286/"
] |
74,140,214 | <p>i has a query a table in db</p>
<pre><code>SELECT book_id,rating_date
from review r
ORDER BY book_id, rating_start
</code></pre>
<p>and result like</p>
<pre><code>id | book_id | rating_date
1 | 3 | 1
5 | 3 | 2
6 | 3 | 3
2 | 5 | 3
7 | 5 | 4
9 | 5 | 5
</code></pre>
<p>how i display average number of rating star of each book with formula like</p>
<pre><code>AR = (1*a+2*b+3*c+4*d+5*e) / (a+b+c+d+e)
o Where AR is the average rating
o a is the number of 1 star ratings
o b is the number of 2 star ratings
o c is the number of 3 star ratings
o d is the number of 4 star ratings
o e is the number of 5 star ratings
</code></pre>
| [
{
"answer_id": 74140293,
"author": "Vuudi",
"author_id": 8611104,
"author_profile": "https://Stackoverflow.com/users/8611104",
"pm_score": 0,
"selected": false,
"text": "AVG()"
},
{
"answer_id": 74140317,
"author": "Losbaltica",
"author_id": 5935388,
"author_profile":... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140214",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16849099/"
] |
74,140,218 | <p>My goal is to modify array which are declared in <code>C++ struct</code> and assigned with default value.</p>
<p>I have read <a href="https://pybind11.readthedocs.io/en/stable/advanced/cast/stl.html#making-opaque-types" rel="nofollow noreferrer">this</a>, <a href="https://pybind11.readthedocs.io/en/stable/advanced/cast/stl.html#binding-stl-containers" rel="nofollow noreferrer">this</a>, but unfortunately I cannot relate it with my problem.</p>
<h3>Sample Code</h3>
<ul>
<li>C++</li>
</ul>
<pre class="lang-cpp prettyprint-override"><code>class Math{
struct Data
{
std::array<float, 5> id_ = {0}; // all value set to ZERO
std::array<uint32_t, 5> length_ = {0}; // all value set to ZERO
std::array<bool, 5> status_ = {0}; // all value set to ZERO
float x_ = 7.5;
};
};
</code></pre>
<ul>
<li>Binded Code</li>
</ul>
<pre class="lang-cpp prettyprint-override"><code>#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <pybind11/complex.h>
namespace py = pybind11;
PYBIND11_MODULE(do_math, m)
{
py::class_<Math::Data> Data (m, "Data");
Data.def(py::init<>())
.def_readwrite("id_", &Math::Data::id_)
.def_readwrite("length_", &Math::Data::length_)
.def_readwrite("status_", &Math::Data::status_)
.def_readwrite("x_", &Math::Data::x_);
}
</code></pre>
<ul>
<li>Now, I would like to modify all <code>std::array</code> member value. I am only showing here <code>id_</code>.</li>
<li>In <code>python file</code> I can access the <code>id_</code> member variable and it prints <code>[0.0, 0.0, 0.0, 0.0, 0.0]</code> as well as the <code>x_</code> which output is <code>7.5</code></li>
</ul>
<pre class="lang-py prettyprint-override"><code>import do_math
struct_obj = do_math.Data()
print(struct_obj.id_)
print(struct_obj.x_)
</code></pre>
<ul>
<li>Now would like to modify the value of <code>id_</code> but here I am unable to do it.</li>
</ul>
<pre class="lang-py prettyprint-override"><code>struct_obj.id_[2] = 2.2 # cannot modify
struct_obj.x_ = 1.5 # it is modified
</code></pre>
<p>Still output of <code>struct_obj.id_</code> is <code>[0.0, 0.0, 0.0, 0.0, 0.0]</code> while <code>struct_obj.x_</code> is changed to <code>1.5</code>. How can I modify the <code>id_</code> array in python?</p>
<h3>Approach has taken so far</h3>
<p>By following <a href="https://stackoverflow.com/a/58723691/10634362">this answer</a> I have tried to implement but failed.</p>
<pre class="lang-cpp prettyprint-override"><code>#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <pybind11/complex.h>
#include "pybind11/numpy.h"
#include <pybind11/pytypes.h>
namespace py = pybind11;
PYBIND11_MODULE(do_math, m)
{
py::class_<Math::Data> Data (m, "Data", py::buffer_protocol());
Data.def(py::init<>())
.def_property("id_", [](Math::Data &p) -> py::array {
auto dtype = py::dtype(py::format_descriptor<float>::format());
auto base = py::array(dtype, {5}, {sizeof(float)});
return py::array(
dtype, {5}, {sizeof(float)}, p.id_, base);
}, [](Math::Data& p) {});
}
</code></pre>
<ul>
<li>Error Message : <code>error: no matching constructor for initialization of 'py::array' return py::array(</code></li>
</ul>
| [
{
"answer_id": 74140293,
"author": "Vuudi",
"author_id": 8611104,
"author_profile": "https://Stackoverflow.com/users/8611104",
"pm_score": 0,
"selected": false,
"text": "AVG()"
},
{
"answer_id": 74140317,
"author": "Losbaltica",
"author_id": 5935388,
"author_profile":... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140218",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10634362/"
] |
74,140,263 | <p>Could anyone explain to me what a CTE in SQL is, in a clear and concise manner?</p>
| [
{
"answer_id": 74140441,
"author": "DRapp",
"author_id": 74195,
"author_profile": "https://Stackoverflow.com/users/74195",
"pm_score": 2,
"selected": false,
"text": "with MyAliasJustManagers as\n( select \n E.EmployeeID,\n E.FirstName as ManagerFirstName,\n E.Last... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140263",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14291904/"
] |
74,140,266 | <p>Imagine 2 table with the same structure but that might have some rows not equal for the same primary key.</p>
<p>What really happen when using a where clause like this : " <code>where table1.* <> table2.*</code> " ?</p>
<p>I "used" it in PostgreSQL but I'm interested for other's languages behavior with this weird thing.</p>
| [
{
"answer_id": 74140540,
"author": "JGH",
"author_id": 7635569,
"author_profile": "https://Stackoverflow.com/users/7635569",
"pm_score": 2,
"selected": false,
"text": "(t1.id, t1.col1, t1.col2) <> (t2.id, t2.col2, t2.col2)\n"
},
{
"answer_id": 74140585,
"author": "Lennart - S... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140266",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20291778/"
] |
74,140,277 | <p>I am trying to create two separate buttons to pass value of true and false as options for quiz. I have the following</p>
<pre><code>public yes:boolean = false;
public no:boolean = false;
</code></pre>
<p>The buttons must have the same styles except when clicked. The button will change to orange. What I did was to set the yes and no to false, then use ! to alter the state when click. i.e true to apply the tailwind style. The orange background is only when the button selection is true and when the No button is true, the Yes button must be false.</p>
<pre><code> public yesButton():void {
this.score = '';
this.yes = !this.yes;
this.no ? this.no = false : this.no;
this.userChoice = true;
}
public noButton(): void {
this.score = '';
this.no = !this.no;
this.yes ? this.yes = false : this.yes;
this.userChoice = false;
}
</code></pre>
<p>It works fine but I want to know if I can do this with just a variable, for instance this.status instead of separate this.no and this.yes.</p>
<p>More also, I am using this.no and yes.no to determine the state of the buttons.</p>
<pre><code>[ngClass]="{
'bg-orange border-0 hover:text-white text-white': no,
'bg-white border text-gray-900 border-gray-100': !no}"
>
</code></pre>
<p>and for the yes;</p>
<pre><code>[ngClass]="{
'bg-orange border-0 hover:text-white text-white': yes,
'bg-white border text-gray-900 border-gray-100': !yes}"
>
</code></pre>
<p>I tried to use public status: boolean = false, instead of yes and no but the logic for ngClass failed if I click on one button, it is applicable to the other button.</p>
| [
{
"answer_id": 74140540,
"author": "JGH",
"author_id": 7635569,
"author_profile": "https://Stackoverflow.com/users/7635569",
"pm_score": 2,
"selected": false,
"text": "(t1.id, t1.col1, t1.col2) <> (t2.id, t2.col2, t2.col2)\n"
},
{
"answer_id": 74140585,
"author": "Lennart - S... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140277",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15062485/"
] |
74,140,283 | <p>I have a multi object request which look like follow in postman</p>
<pre><code>{ "affordability": {
"grossIncome": 100000,
"netIncome": 80000,
"capitalRequired": 25000,
"groceries": 200,
"utilities": 300,
"savings": 400,
"services": 500,
"transport": 600,
"support": 800,
"housing": 700,
"other": 900
},
"employment": {
"sector": "CentralGovernmentSocial",
"status": "Contract",
"startDate": "2010-08-01",
"endDate": "2030-08-01"
},
"declarations": {
"debtLiability": "None",
"pendingRetrenchment": "false",
"knownMedicalCondition": "false"
},
"bank": "ABSA"
}
</code></pre>
<p>I am doing some automation on our API's and this one got me. I have struggled for quite some time to get the request to look like the postman request. I have managed to get that right. Though I am not entirely sure if the method I went about to solve the problem is allowing for the POST request. Cause when I run the POST request I get the below error.
<strong>HTTPError: 400 Client Error: Bad Request for url:</strong> this is a url</p>
<p>This is what my code looks like in:</p>
<pre><code># &{baseURL}= this is a url
# ${offer}= /offer
# ${URL}= Catenate This is a url ${appID} /offer
# log to console ${URL}
# Create Session httpbin this is a url
&{affordability}= Create Dictionary grossIncome=60000 netIncome=30000 capitalRequired=25000 groceries=500 utilities=400 savings=300 services=200 transport=100 support=100 housing=500 other=100
${affordabilityobject}= Catenate {'affordability': ${affordability}
# log to console ${affordabilityobject}
&{employment}= Create Dictionary sector=CentralGovernmentSocial status=Contract startDate=2019-08-01 endDate=2023-08-01
${employmentobject}= Catenate 'employment': ${employment}
# log to console ${employmentobject}
&{declarations}= Create Dictionary debtLiability=None pendingRetrenchment=false knownMedicalCondition=false
${declarationsobject}= Catenate 'declarations': ${declarations}
# log to console ${declarationsobject}
# &{bank}= Create Dictionary bank=FirstNationalBank
${bank}= Catenate 'bank':'FirstNationalBank'}
log to console ${bank}
${fullrequest}= Catenate SEPARATOR=, ${affordabilityobject} ${employmentobject} ${declarationsobject} ${bank}
log to console ${fullrequest}
${resp}= Post this is a url/${appID}/offer json=${fullrequest}
</code></pre>
| [
{
"answer_id": 74146339,
"author": "Flibidisch",
"author_id": 12232123,
"author_profile": "https://Stackoverflow.com/users/12232123",
"pm_score": 1,
"selected": false,
"text": "&{baseURL}= this is a url\n${offer}= /offer\n${URL}= Catenate This is... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140283",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11108810/"
] |
74,140,307 | <p>I am trying to center components using a <a href="https://docs.oracle.com/javase/8/docs/api/java/awt/GridBagLayout.html" rel="nofollow noreferrer"><code>GridBagLayout</code></a> in the same manner that a <a href="https://docs.oracle.com/javase/8/docs/api/javax/swing/Box.html" rel="nofollow noreferrer"><code>Box</code></a> centers components when you use <a href="https://docs.oracle.com/javase/8/docs/api/javax/swing/Box.html#createVerticalGlue--" rel="nofollow noreferrer"><code>Box.createVerticalGlue()</code></a>. I initially <em>did</em> use a vertical Box:</p>
<pre><code>Box box = Box.createVerticalBox();
box.add(Box.createVerticalGlue());
box.add(add);
box.add(remove);
box.add(edit);
box.add(Box.createVerticalGlue());
JPanel internalPanel = new JPanel(new BorderLayout());
internalPanel.add(keywordsScrollPane, BorderLayout.CENTER);
internalPanel.add(box, BorderLayout.EAST);
</code></pre>
<p>But as you can see, it looks sloppy because my buttons are different sizes:</p>
<p><a href="https://i.stack.imgur.com/bxFWo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bxFWo.png" alt="Sloppy Buttons" /></a></p>
<p>I decided to switch to <code>GridBagLayout</code> so I can utilize <a href="https://docs.oracle.com/javase/8/docs/api/java/awt/GridBagConstraints.html#fill" rel="nofollow noreferrer"><code>GridBagConstraints.fill</code></a>. This approach fixes my button width issue, but I cannot figure out how to vertically center the buttons. I changed the grid size and placed the buttons in the middle three rows, but the buttons were still appearing at the top of the panel. I tried making use of <a href="https://docs.oracle.com/javase/8/docs/api/java/awt/GridBagConstraints.html#anchor" rel="nofollow noreferrer"><code>GridBagConstraints.anchor</code></a> and <a href="https://docs.oracle.com/javase/8/docs/api/java/awt/GridBagConstraints.html#weighty" rel="nofollow noreferrer"><code>GridBagConstraints.weighty</code></a> as well. The latter almost worked, but there are very large margins between the buttons:</p>
<p><a href="https://i.stack.imgur.com/y5j9C.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/y5j9C.png" alt="Large Margins" /></a></p>
<p>I am looking for the buttons to be grouped together as they were in my Box approach. How can I achieve this with a GridBadLayout?</p>
<p>I am using a class I created called <code>ConstraintsBuilder</code> which works exactly as you would expect. It's for creating GridBagContraints with nice one-liners. Here is all the (relevant) code for your viewing pleasure:</p>
<pre><code>public class KeywordsDialog extends JDialog implements ActionListener, ListSelectionListener {
private JList<String> keywords;
private JScrollPane keywordsScrollPane;
private JButton add;
private JButton remove;
private JButton edit;
private Set<String> keywordsList;
public KeywordsDialog(Window parent, Collection<String> keywordsList) {
super(parent);
this.keywordsList = keywordsList == null ? new HashSet<String>() : new HashSet<String>(keywordsList);
if (keywordsList != null && !keywordsList.isEmpty()) {
this.keywords = new JList<String>(toListModel(keywordsList));
} else {
this.keywords = new JList<String>(new DefaultListModel<String>());
}
this.keywordsScrollPane = new JScrollPane(keywords);
this.add = new JButton("Add");
this.remove = new JButton("Remove");
this.edit = new JButton("Edit");
this.edit.setEnabled(false);
this.add.setEnabled(false);
ConstraintsBuilder builder = LayoutUtils.gridBagConstraintsBuilder();
JPanel internalPanel = new JPanel(new GridBagLayout());
internalPanel.add(this.keywordsScrollPane, builder.gridX(0).gridY(0).gridHeight(3).margins(0, 0, 0, 5)
.fill(GridBagConstraints.BOTH).weightX(1D).weightY(1D).build());
internalPanel.add(this.add,
builder.reset().gridX(1).gridY(0).fill(GridBagConstraints.HORIZONTAL).weightX(1D).weightY(1D).build());
internalPanel.add(this.remove,
builder.reset().gridX(1).gridY(1).fill(GridBagConstraints.HORIZONTAL).weightX(1D).weightY(1D).build());
internalPanel.add(this.edit,
builder.reset().gridX(1).gridY(2).fill(GridBagConstraints.HORIZONTAL).weightX(1D).weightY(1D).build());
this.keywords.setBorder(BorderFactory.createTitledBorder("Keywords"));
internalPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
this.setLayout(new BorderLayout());
this.add(internalPanel, BorderLayout.CENTER);
Dimension screen = GuiHelper.getScreenSize(parent);
this.setSize((int) (screen.getWidth() / 4), (int) (screen.getHeight() / 3));
this.setLocationRelativeTo(parent);
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
}
// ...
}
</code></pre>
| [
{
"answer_id": 74140538,
"author": "Hovercraft Full Of Eels",
"author_id": 522444,
"author_profile": "https://Stackoverflow.com/users/522444",
"pm_score": 3,
"selected": true,
"text": "JPanel buttonPanel = new JPanel(new GridLayout(0, 1, 5, 5));"
},
{
"answer_id": 74140636,
"... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140307",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5645656/"
] |
74,140,323 | <p>I'm receiving an <code>id</code> (integer) and a <code>executor</code> (String) in my controller (Rest API). However, when looking at my database, I see that the string is being inserted into the database as an object. Example of database entry:</p>
<pre><code>{
"executor": "Pietje"
}
</code></pre>
<p><em>Controller:</em></p>
<pre><code>@PostMapping(path = "/accept/{id}")
public String acceptAssignment(@Valid @PathVariable Integer id, @RequestBody String executor) {
return assignmentService.acceptAssignment(id, executor);
}
</code></pre>
<p><em>Service implementation:</em></p>
<pre><code>@Override
public String acceptAssignment(Integer id, String executor) {
Assignment assignment = assignmentRespository.findById(id).orElse(null);
assignment.setExecutor(String.valueOf(executor));
AssignmentDTO assignmentDTO = assignmentConverter.convertEntityToDto(assignment);
assignmentRespository.save(assignment);
return assignmentDTO.getExecutor();
}
</code></pre>
<p>What am I doing wrong, and how can I fix it?</p>
<p>I could pass along the entire DTO instead of just the 'executor' value, but that doesn't seem efficient. As far as I know, the problem is not with the frontend but I could add the React code if necessary.</p>
| [
{
"answer_id": 74140695,
"author": "IamGroot",
"author_id": 8327330,
"author_profile": "https://Stackoverflow.com/users/8327330",
"pm_score": 0,
"selected": false,
"text": "ObjectMapper"
},
{
"answer_id": 74145448,
"author": "Alexander Ivanchenko",
"author_id": 17949945,
... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140323",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10148986/"
] |
74,140,337 | <p>Lets say I have:</p>
<p><em>(please ignore the fact that I am using <code>strncmp</code> in C++)</em></p>
<pre class="lang-cpp prettyprint-override"><code>if (!strncmp(some_str, "constant", strlen("constant"))) {}
</code></pre>
<p>The <code>strlen</code> can be evaluated at compile time but it can't be eliminated because the function is not <code>constexpr</code>.</p>
<p>One way around would be (accepted only by <code>g++</code>):</p>
<pre class="lang-cpp prettyprint-override"><code>constexpr size_t len = strlen("constant");
if (!strncmp(some_str, "constant", len)) {}
</code></pre>
<p>but this is harder to read and less practical.</p>
<p>Is there any way to specify <code>constexpr</code> for a part of a statement?</p>
| [
{
"answer_id": 74140695,
"author": "IamGroot",
"author_id": 8327330,
"author_profile": "https://Stackoverflow.com/users/8327330",
"pm_score": 0,
"selected": false,
"text": "ObjectMapper"
},
{
"answer_id": 74145448,
"author": "Alexander Ivanchenko",
"author_id": 17949945,
... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140337",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10126955/"
] |
74,140,406 | <p><br>How can I calculate the number of occurrences that are ONLY followed by a specific value that is after E*? e.g:'EXXXX' ?</p>
<p>file.txt:</p>
<pre><code>E2dd,Rv0761,Rv1408
2s32,Rv0761,Rv1862,Rv3086
6r87,Rv0761
Rv2fd90c,Rv1408
Esf62,Rv0761
Evsf62,Rv3086
</code></pre>
<p>i tried
input:</p>
<pre><code>awk -F, '{map[$2]++} END { for (key in map) { print key, map[key] } }' file.txt
</code></pre>
<p>and add:</p>
<pre><code>if [[ $line2 == `E*` ]];then
</code></pre>
<p>but not working, have syntax error</p>
<p>Expected Output:</p>
<pre><code>total no of occurrences:
Rv0761: 2
Rv3086:1
</code></pre>
<p>Now i can only count all number of occurrences of the second value</p>
| [
{
"answer_id": 74140695,
"author": "IamGroot",
"author_id": 8327330,
"author_profile": "https://Stackoverflow.com/users/8327330",
"pm_score": 0,
"selected": false,
"text": "ObjectMapper"
},
{
"answer_id": 74145448,
"author": "Alexander Ivanchenko",
"author_id": 17949945,
... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140406",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20121597/"
] |
74,140,414 | <p>I am working on a game made in Unity Engine.
For Movement, I have used vector2. But for vector2, you need to spam the buttons in order for the player to move. So i tried "while" function to loop the process. Here is the main code</p>
<pre><code> if (Input.GetKeyDown(KeyCode.W))
{
i = 5;
}
//test
if (Input.GetKeyUp(KeyCode.W))
{
i = 1;
}
while(i !=1)
{
rb.AddForce(Vector2.up * JumpForce);
}
</code></pre>
<p>However, when I run it the engine crashes. Why?
Just to let you know, there are no compiler errors.</p>
| [
{
"answer_id": 74142097,
"author": "Aseed Second",
"author_id": 20292485,
"author_profile": "https://Stackoverflow.com/users/20292485",
"pm_score": 0,
"selected": false,
"text": "if (Input.GetKey(KeyCode.W))\n{\n rb.AddForce(Vector2.up * JumpForce);\n}\n"
},
{
"answer_id": 741... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140414",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19315804/"
] |
74,140,422 | <p>How could I put an image inside my HTMl part of the code</p>
<p><code> <input id="sendButton" type="button" value=<img src="sendbutton.jpg"> /></code></p>
<p>I thought this would work but when I run the website it just shows as text "img src />"</p>
<p>Is there any way I could do this?</p>
<p>What this is about is a send button for a chat application, initially I had
<code><input id="sendButton" type="button" value="Send" /></code>
Which worked perfectly and showed the button as "Send", but I would love to use an image in there like twitter, instagram etc... does.</p>
| [
{
"answer_id": 74140465,
"author": "David",
"author_id": 328193,
"author_profile": "https://Stackoverflow.com/users/328193",
"pm_score": 1,
"selected": false,
"text": "<button id=\"sendButton\">\n <img src=\"sendbutton.jpg\">\n</button>\n"
},
{
"answer_id": 74140492,
"author... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140422",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15288924/"
] |
74,140,436 | <p>I'm currently using Mirror Networking to make a multiplayer game. I have a scene when players are all connected, they can choose their characters and set the ready. If all players are ready, I change current scene to arena scene using MyNetworkManager.ServerChangeScene(arenaSceneName). This method sets all player clients as not ready. But After the scene was loaded, my player client is no longer connected to my host and I don't know why.</p>
<p>Can you help me please ?</p>
<p>Thanks a lot for answers.</p>
| [
{
"answer_id": 74154415,
"author": "Lilian Sananikone",
"author_id": 16297802,
"author_profile": "https://Stackoverflow.com/users/16297802",
"pm_score": 0,
"selected": false,
"text": "public class ReadyPlayerChecker : NetworkBehaviour\n{\n public List<PlayerBehaviour> activePlayers;\n\n... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140436",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16297802/"
] |
74,140,462 | <p>I've been using EF core in my project for years without repositories layer and now I decided to implement repositories pattern for one of my projects which became very big. We have more than 30 entity models and a huge list of API endpoints.</p>
<p>The thing is, each endpoint returns to the client the necessary data from DB formatted by the frontend needs. Some times we want just a list of an entity, other times the same list with some related data and sometimes use some SQL aggregate functions to do some calculations.</p>
<p>We just use the DBContext directly in each endpoint to perform the queries as we need, but when implementing the repositories, we faced an effort obstacle which is coding several methods to get the different data formatted to our needs. Not only basic CRUD and some more operations.</p>
<p>My question is, this really how thing are done (creating as much methods as needed) or is there any best practices to this? Is there some way "rewrite" the DBContext so that I can use expressions and turn it generic avoiding creating so mach methods?</p>
<p>Thank you very much!</p>
| [
{
"answer_id": 74154415,
"author": "Lilian Sananikone",
"author_id": 16297802,
"author_profile": "https://Stackoverflow.com/users/16297802",
"pm_score": 0,
"selected": false,
"text": "public class ReadyPlayerChecker : NetworkBehaviour\n{\n public List<PlayerBehaviour> activePlayers;\n\n... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140462",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19745466/"
] |
74,140,474 | <p>Typically I'd use <code>> /var/log/snort/alert</code> however on FreeBSD this doesn't work. 'Invalid null command' error is thrown. Any way to do this other than deleting and making a new file?</p>
| [
{
"answer_id": 74154415,
"author": "Lilian Sananikone",
"author_id": 16297802,
"author_profile": "https://Stackoverflow.com/users/16297802",
"pm_score": 0,
"selected": false,
"text": "public class ReadyPlayerChecker : NetworkBehaviour\n{\n public List<PlayerBehaviour> activePlayers;\n\n... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140474",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8271065/"
] |
74,140,484 | <p>Given a library (let's call it LibraryA) that uses another library without typing - particularly js-yaml. To do so LibraryA has a devDependency <code>@types/js-yam</code> in its <code>package.json</code>. LibraryA itself compiles just fine.</p>
<p>Now I have a project where I installed LibraryA as a dependency (in devDependencies). In that project I imported types from the LibraryA and so that LibraryA gets compiled by tsc when I compile the whole project.
But tsc reports an error about code in LibraryA where I import js-yaml (<code>import yaml from 'js-yaml'</code>):</p>
<p>error TS7016: Could not find a declaration file for module 'js-yaml'.</p>
<p>I checked the node_modules for the project, and there's no @types/js-yaml there.
So, it explains why tsc can't see the typings. But I can't understand why it wasn't installed in the first place (when I installed LibraryA).</p>
<pre><code>project
package.json
devDependencies
LibraryA
LibraryA
package.json
dependencies
"js-yaml": "^4.1.0",
devDependencies
"@types/js-yaml": "^4.0.5",
js-yaml
</code></pre>
<p>So, probably the question is about npm and why it doesn't install "@types/js-yaml inside the project.</p>
| [
{
"answer_id": 74140608,
"author": "Archigan",
"author_id": 14333778,
"author_profile": "https://Stackoverflow.com/users/14333778",
"pm_score": 1,
"selected": false,
"text": "@types/package-name"
},
{
"answer_id": 74141037,
"author": "caTS",
"author_id": 18244921,
"au... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140484",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27703/"
] |
74,140,531 | <p>I'm trying to create new containers by clicking on a button, but I click on the button and it's not updating the screen in the application with the new container. What could I be doing wrong?</p>
<pre><code>int _i = 0;
return Column(
children: [
TextButton(
style: ButtonStyle(
foregroundColor: MaterialStateProperty.all<Color>(Colors.blue),
),
onPressed: () {
setState(() {
_i++;
print(_i);
print("Fidase");
});
},
child: Text('TextButton'),
),
SingleChildScrollView(
child: ListView.builder(
shrinkWrap: true,
itemCount: _i,
itemBuilder: (BuildContext ctxt, int index) {
return Container(
color: Colors.blueGrey,
height: heightScreen * .08,
width: widthScreen,
child: Text("Container numero $_i"));
}),
)
],
);
</code></pre>
| [
{
"answer_id": 74140608,
"author": "Archigan",
"author_id": 14333778,
"author_profile": "https://Stackoverflow.com/users/14333778",
"pm_score": 1,
"selected": false,
"text": "@types/package-name"
},
{
"answer_id": 74141037,
"author": "caTS",
"author_id": 18244921,
"au... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140531",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15784561/"
] |
74,140,537 | <p>I am writing a code where the text comes out like this:</p>
<pre><code>import time
def animation(phrase):
for i in phrase:
print(i,end="",flush=True) #Animates text to be printed out one by one
time.sleep(0.035)
print(phrase)
</code></pre>
<p>While the text is coming out one by one, the user can press enter in between the letters. After, that I have a code that asks for input and it assumes the <em>enter key</em> was the input the user put in.</p>
<p>I have tried using the keyboard module and other modules, I also want to avoid using the input function to detect whether it is an enter key or not.</p>
<p>I want to detect, at any point in my program when the enter key is pressed.</p>
<p><em>P.S I am using Grok, on online Python platform.</em></p>
| [
{
"answer_id": 74140608,
"author": "Archigan",
"author_id": 14333778,
"author_profile": "https://Stackoverflow.com/users/14333778",
"pm_score": 1,
"selected": false,
"text": "@types/package-name"
},
{
"answer_id": 74141037,
"author": "caTS",
"author_id": 18244921,
"au... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140537",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20135052/"
] |
74,140,566 | <p>I'm working in a side panel filter for my page, I have the parent checkbox (Select all) and the children checkboxes(specific filters).</p>
<p>Here is what I want, if I select a children I want the parent checkbox to be partially checked, see image below:</p>
<p><a href="https://i.stack.imgur.com/sOtjj.png" rel="nofollow noreferrer">link to example image</a></p>
<p>Currently this is my code, my parent checkbox ngModel is set to "dataSource.data.length == selectedAssetTypeFilters.length"</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><mat-panel-title>
<mat-checkbox [(ngModel)]="dataSource.data.length == selectedAssetTypeFilters.length" (click)="$event.stopPropagation()" (keydown)="$event.stopPropagation()" (change)="onSelectAll($event, 'assettype')" title="Select All">Data Asset Type</mat-checkbox> </mat-panel-title> </mat-expansion-panel-header>
<div class="filter-content">
<mat-tree [dataSource]="dataSource" [treeControl]="treeControl" class="example-tree">
<!-- This is the tree node template for leaf nodes -->
<mat-tree-node *matTreeNodeDef="let node" matTreeNodeToggle>
<li class="mat-tree-node">
<mat-checkbox [(ngModel)]="node.checked" (change)="onFilterUpdate(node, 'assettype');" title="{{node.label}}"></code></pre>
</div>
</div>
</p>
<p>How can I do this?</p>
| [
{
"answer_id": 74140676,
"author": "Charlie",
"author_id": 4185234,
"author_profile": "https://Stackoverflow.com/users/4185234",
"pm_score": 1,
"selected": false,
"text": "[indeterminate]"
},
{
"answer_id": 74141434,
"author": "Tanner",
"author_id": 7375929,
"author_p... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140566",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20291914/"
] |
74,140,584 | <p>This is my table<br>
<strong>Customer (custid, custName, custAddress, custPhone)</strong></p>
<p>My Question is<br>
<strong>List the pair of customers who share the same phone number.</strong></p>
<p>I just created the following table:</p>
<p><img src="https://i.stack.imgur.com/GPIoA.png" alt="Table" /></p>
| [
{
"answer_id": 74140676,
"author": "Charlie",
"author_id": 4185234,
"author_profile": "https://Stackoverflow.com/users/4185234",
"pm_score": 1,
"selected": false,
"text": "[indeterminate]"
},
{
"answer_id": 74141434,
"author": "Tanner",
"author_id": 7375929,
"author_p... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140584",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14013696/"
] |
74,140,597 | <p>I send below request & receive the below response.
but in response model only Index is the item identifier, there is no itemcode.</p>
<p>I want to update the discount details of each product in the database,
how can I do this.</p>
<p>P.S I am already having all necessary c# classes for database & other stuff, just help me with getting discount details for each item.
Please help me with whatever that needs write for this like joins, linq, loops..</p>
<p><strong>Request:</strong></p>
<pre><code> "Items": [
{
"itemcode": 5,
"price": 600,
"Index": 1
},
{
"itemcode": 34,
"price": 970,
"Index": 2
}
]
}
**Response:**
{
"Items": [
{
"discount": {
"id": 3,
"amoumt": 40
},
"Index": 1
},
{
"discount": {
"id": 3,
"amoumt": 25
},
"Index": 2
}
]
}
**Finally it should look like**
{
"items": [
{
"itemCode": 5,
"discount": {
"id": 3,
"amoumt": 40
}
},
{
"itemCode": 34,
"discount": {
"id": 3,
"amoumt": 25
}
}
]
}
</code></pre>
| [
{
"answer_id": 74140866,
"author": "Good Night Nerd Pride",
"author_id": 1025555,
"author_profile": "https://Stackoverflow.com/users/1025555",
"pm_score": 1,
"selected": false,
"text": "Join()"
},
{
"answer_id": 74141163,
"author": "Serge",
"author_id": 11392290,
"aut... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140597",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20291964/"
] |
74,140,605 | <p>I am building a script (linux bash) where I need to pass a certain number of arguments, it can be 7 or 8 arguments.</p>
<p>If I pass 7 arguments I will do it like this:</p>
<p>my_script.sh</p>
<pre><code>!/bin/bash
arg1=$1
arg2=$2
arg3=$3
arg4=$4
arg5=$5
arg6=$6
arg7=$7
#Do other stuff after this
</code></pre>
<p>and I run it like this: <code>./my_script.sh 1 2 3 4 5 6 7</code></p>
<p>I want to be able to add an optional 8th parameter into this script. So the idea is to run the script with this 8th parametes sometimes and the rest of the time only with 7 parameters.
How can I do this?</p>
| [
{
"answer_id": 74140769,
"author": "develc",
"author_id": 18505766,
"author_profile": "https://Stackoverflow.com/users/18505766",
"pm_score": 1,
"selected": false,
"text": "if [[ $8 != '' ]]\nthen\n # do something\nfi\n"
},
{
"answer_id": 74140922,
"author": "Jetchisel",
... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140605",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3740839/"
] |
74,140,606 | <p>I am looking for an efficient way to turn this pandas dataframe:</p>
<pre><code> A B C
0 0 1 0
1 0 1 1
2 1 1 1
3 1 1 0
4 0 0 1
</code></pre>
<p>into</p>
<pre><code> A B C
0 0 1 0
1 0 0 1
2 1 0 0
3 0 0 0
4 0 0 1
</code></pre>
<p>I only want "1" in a cell, if in the original dataframe the value jumps from "0" to "1". If it's the first row, I want a "1", if "1" is the start value. I have to use this operation often in my project and on a large dataframe, so it should be as efficient as possible. Thanks in advance!</p>
| [
{
"answer_id": 74140680,
"author": "mozway",
"author_id": 16343464,
"author_profile": "https://Stackoverflow.com/users/16343464",
"pm_score": 3,
"selected": true,
"text": "df.diff().clip(0).fillna(df)\n"
},
{
"answer_id": 74140710,
"author": "Viktor",
"author_id": 1285869... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19987055/"
] |
74,140,613 | <p>Is there a way to make VScode to autocomplete/make a snippet of className so when i choose is it it will complete to className={``} (instead of current situation when it just complete to "className" ) ?
Thanks</p>
| [
{
"answer_id": 74140680,
"author": "mozway",
"author_id": 16343464,
"author_profile": "https://Stackoverflow.com/users/16343464",
"pm_score": 3,
"selected": true,
"text": "df.diff().clip(0).fillna(df)\n"
},
{
"answer_id": 74140710,
"author": "Viktor",
"author_id": 1285869... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140613",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6610548/"
] |
74,140,635 | <pre><code>void f();
int main(int argc, char** argv)
{
if (f)
{
// other code
}
}
</code></pre>
<p>With VS2017, the linker complaint about unsolved external symbol, while it works with GCC. According to C99 spec, is it valid? Or it's implementation detail?</p>
| [
{
"answer_id": 74141006,
"author": "the busybee",
"author_id": 11294831,
"author_profile": "https://Stackoverflow.com/users/11294831",
"pm_score": 0,
"selected": false,
"text": "-O0"
}
] | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140635",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20291889/"
] |
74,140,642 | <p>i have a payload</p>
<pre><code>{
"category": "Mobile",
"price": {
"from": "10",
"to": "50"
},
"location": [
"Jakrta",
"Bandung",
"Surabaya"
],
"rating": [
"1",
"2",
"3"
]
}
</code></pre>
<p>i want to find all object which have rating 1 or 2 or 3 and also have any location
Basically i am creating a filter for an ecommerce store i which we will get multiple location and multiple ratings as well so we will return only those object which have matched property. i am attaching a screenshot of UI for better understanding.
<a href="https://i.stack.imgur.com/bxlwU.png" rel="nofollow noreferrer">i want to run this filter with multiple location and multiple checked checkbox</a></p>
| [
{
"answer_id": 74140770,
"author": "rrr63",
"author_id": 20059789,
"author_profile": "https://Stackoverflow.com/users/20059789",
"pm_score": 0,
"selected": false,
"text": "const arr = [{\n \"category\": \"Mobile1\",\n \"price\": {\n \"from\": \"10\",\n \"to\": \"50\"\... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140642",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15991822/"
] |
74,140,681 | <p>I have two text file. I have to compare two files line by line and write unmatched lines to another file.</p>
<p>suppose my file is like this:</p>
<p>file_1.txt</p>
<pre><code>000b423573 bdbaskbjejbajbkjfsjba
00036713dc sjgdjgdgdjadgygdeg263
00123fd351 heqgrg63u1quidg87gduq
0105517f52 vgfeeyguuiduiueyruuur
</code></pre>
<p>and another file,</p>
<p>file_2.txt</p>
<pre><code>000b423573 bdbaskbjejbajbkjfsjba
7736001772 absjueui3ryhfuhuffh3u
00123fd351 heqgrg63u1quidg87gduq
</code></pre>
<p>i have to write unmatched lines to another file:</p>
<p>output.txt</p>
<pre><code>00036713dc sjgdjgdgdjadgygdeg263
7736001772 absjueui3ryhfuhuffh3u
0105517f52 vgfeeyguuiduiueyruuur
</code></pre>
<p>this is my current attempt:</p>
<pre><code>new_1 = set()
new_2 = set()
with open('file_1.txt', 'r') as f:
for line in f:
new_1.add(line.strip())
with open('file_2.txt', 'r') as f:
for line in f:
new_2.add(line.strip())
with open('output.txt', 'w') as fout:
fout.write(new_1 - new_2)
</code></pre>
| [
{
"answer_id": 74140886,
"author": "arsho",
"author_id": 3129414,
"author_profile": "https://Stackoverflow.com/users/3129414",
"pm_score": 2,
"selected": false,
"text": "file_1_content = None\nfile_2_content = None\nwith open(\"file_1.txt\") as file_1:\n file_1_content = [line.strip()... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140681",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20273554/"
] |
74,140,687 | <p>How can I create an array of numbers that starts from 0 and ends with the number equal to the number length of n?</p>
<p>ex>
n=1
output:
123456789
n=2
output:
12345...99</p>
| [
{
"answer_id": 74141002,
"author": "Lain",
"author_id": 4728913,
"author_profile": "https://Stackoverflow.com/users/4728913",
"pm_score": 1,
"selected": false,
"text": "Math.pow"
},
{
"answer_id": 74141360,
"author": "VLAZ",
"author_id": 3689450,
"author_profile": "ht... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140687",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17244694/"
] |
74,140,697 | <p>I am struggling to make a simple solana anchor code example to work. All I am trying to do is to initialize a piece of data with only my wallet being allowed to do it.
Here is my Solana anchor code:</p>
<pre><code>impl<'info> Validate<'info> for InitData<'info> {
fn validate(&self) -> Result<()> {
assert_keys_eq!(self.manager, Pubkey::from_str("2jEfqL1wFEHFjtbKEDoRottSBsij3v1j19aZueqrnj7v").unwrap());
Ok(())
}
}
#[program]
mod coinflip_bet {
use super::*;
#[access_control(ctx.accounts.validate())]
pub fn init_data(ctx: Context<InitData>) -> Result<()> {
Ok(())
}
}
#[derive(Accounts)]
pub struct InitData<'info> {
#[account(
init,
payer = manager,
space = 8 + 1,
seeds = [b"data-account", manager.key().as_ref()],
bump
)]
pub data_account: Account<'info, DummyData>,
#[account(mut)]
pub manager: Signer<'info>,
pub system_program: Program<'info, System>,
}
#[account]
pub struct DummyData {
pub dummy: u8,
}
</code></pre>
<p>Here is my client code:</p>
<pre><code>require('dotenv').config();
const PROGRAM_ID = process.env.PROGRAM_ID ?? '';
async function run() {
const connection = new Connection('http://127.0.0.1:8899');
const wallet = NodeWallet.local();
const programId = new PublicKey(PROGRAM_ID);
const [dataAccount,] = await PublicKey.findProgramAddress(
[Buffer.from("data-account"), wallet.publicKey.toBuffer()],
SystemProgram.programId
);
const provider = new anchor.AnchorProvider(
connection,
wallet,
anchor.AnchorProvider.defaultOptions()
);
//doesn't compile without this type checker skip
//@ts-ignore
const program = new anchor.Program(IDL, programId, provider);
await program.methods.initData()
.accounts(
{
dataAccount: dataAccount,
manager: wallet.publicKey,
systemProgram: SystemProgram.programId,
}
)
.signers(
[wallet.payer]
)
.rpc();
}
run().then(
() => process.exit(),
err => {
console.error(err);
process.exit(-1);
},
);
</code></pre>
<p>I'm on localhost:8899, launching this with 'solana-test-validator', 'anchor build', 'anchor deploy', 'ts-node src/init-data-account.ts'
I get this error:</p>
<pre><code>SendTransactionError: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: Cross-program invocation with unauthorized signer or writable account
logs: [
'Program 6YQukxVDKejG79RNSddyeEy6YQRVNkXSi4f5HuEyVMd6 invoke [1]',
'Program log: Instruction: InitData',
"7g32AFUNrTqyyuj1zbve6ui1aUzqzEvzpBc2tdNmqBjo's signer privilege escalated",
'Program 6YQukxVDKejG79RNSddyeEy6YQRVNkXSi4f5HuEyVMd6 consumed 6670 of 200000 compute units',
'Program 6YQukxVDKejG79RNSddyeEy6YQRVNkXSi4f5HuEyVMd6 failed: Cross-program invocation with unauthorized signer or writable account'
],
</code></pre>
<p>Can you please help me get rid off this error?</p>
<p><strong>Update:</strong>
I updated my accounts struct:</p>
<pre><code>#[derive(Accounts)]
pub struct InitData<'info> {
#[account(
init,
payer = manager,
space = 8 + 1,
seeds = [b"data-account", handler.key().as_ref()],
bump
)]
pub data_account: Account<'info, Escrow>,
/// CHECK:
#[account(mut)]
pub handler: AccountInfo<'info>,
#[account(mut)]
pub manager: Signer<'info>,
pub system_program: Program<'info, System>,
}
</code></pre>
<p>And I still have this error:</p>
<pre><code>Cross-program invocation with unauthorized signer or writable account
</code></pre>
| [
{
"answer_id": 74141002,
"author": "Lain",
"author_id": 4728913,
"author_profile": "https://Stackoverflow.com/users/4728913",
"pm_score": 1,
"selected": false,
"text": "Math.pow"
},
{
"answer_id": 74141360,
"author": "VLAZ",
"author_id": 3689450,
"author_profile": "ht... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140697",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4685508/"
] |
74,140,714 | <p>I have a situation where we will have list of IP addresses (which are coming from the config map) then we need to validate these IP Addresses (i.e. check if they are accessible from this machine) then return the first accessible IP address so that application can access this ip address to process further actions.</p>
<p>I got the know that we can use <strong>InitContainers</strong> to do this stuff. But my question is how can we run a shell script in the initcontainer to identify the accessible IP Address and set it in the Environmental variable so that application process this further.</p>
| [
{
"answer_id": 74141035,
"author": "Harsh Manvar",
"author_id": 5525824,
"author_profile": "https://Stackoverflow.com/users/5525824",
"pm_score": 0,
"selected": false,
"text": "initContainers:\n - name: secret\n image: gcr.io/cloud-builders/kubectl:latest\n comma... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140714",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5662508/"
] |
74,140,723 | <p>I have found a similar issue online but the solutions havent helped my course. I am new to typescript and so I assume I could be missing something very simple. I have a simple app on Nextjs. It renders fine but I get this error when I try to build it locally:</p>
<pre><code>import { useState } from 'react'
import Sidebar from './sidebar';
import LayoutContent from './layout_content';
type Props = {
children: JSX.Element | JSX.Element[]
}
const Layout = ({ children }: Props) => {
const [open, setOpen] = useState(true);
const toggle = () => {
setOpen(!open)
}
return (
<>
<Sidebar onClick={toggle} sidebar={open} />
<LayoutContent children={children} sidebar={open}/>
</>
)
}
export default Layout;
</code></pre>
<p><strong>layout_content.tsx</strong></p>
<pre><code>const LayoutContent = ({ children , sidebar}: {children:any, sidebar:any}) => {
return(
<>
<div>
{children}
</div>
</>
)}
</code></pre>
| [
{
"answer_id": 74141035,
"author": "Harsh Manvar",
"author_id": 5525824,
"author_profile": "https://Stackoverflow.com/users/5525824",
"pm_score": 0,
"selected": false,
"text": "initContainers:\n - name: secret\n image: gcr.io/cloud-builders/kubectl:latest\n comma... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140723",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14287707/"
] |
74,140,733 | <p>This is what I have:</p>
<pre><code>ev_filt = filter(lambda x: x % 2 == 0, list1)
od_filt = filter(lambda x: x % 2 != 0, list1)
ev_list = list(ev_filt)
od_list = list(od_filt)
length = int(input("Enter the number of words yer gon pass"))
# initialize the list using for loop
for i in range(0, length):
item = int(input("Pass a number bro" + str(i+1) + " :"))
list1.append(item)
print(ev_list)
print(od_list)
</code></pre>
<p>I've tried to continue with this template, but it won't work.</p>
<p>Why?</p>
<p>How do I solve this?</p>
| [
{
"answer_id": 74140855,
"author": "Victor Bueno",
"author_id": 19757597,
"author_profile": "https://Stackoverflow.com/users/19757597",
"pm_score": 1,
"selected": false,
"text": "listTwo = [num for num in listOne if num % 2 == 0]\nlistThree = [num for num in listOne if num % 2 != 0]\n"
... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140733",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20231159/"
] |
74,140,781 | <p>I have the below code and as far as I'm concerned it only relies upon [page] yet, I am getting the error</p>
<pre><code>React Hook useEffect has a missing dependency
</code></pre>
<p>I've seen similar questions about commenting out a line in your eslint file but</p>
<ol>
<li>I don't have an eslint file</li>
<li>I would rather understand and resolve the issue</li>
</ol>
<pre><code>
const fetchStarWarsInfo = async () => {
const response = await getData(
`https://swapi.dev/api/people/?page=${dontReturnZero(page)}`
);
dispatch(setCurrentCharacters(response.results));
};
useEffect(() => {
fetchStarWarsInfo();
}, [page]);
</code></pre>
| [
{
"answer_id": 74140855,
"author": "Victor Bueno",
"author_id": 19757597,
"author_profile": "https://Stackoverflow.com/users/19757597",
"pm_score": 1,
"selected": false,
"text": "listTwo = [num for num in listOne if num % 2 == 0]\nlistThree = [num for num in listOne if num % 2 != 0]\n"
... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13020185/"
] |
74,140,852 | <p>Within the object that is saved as the first element of Question3_Object, replace the whole numbers (i.e., numbers without fractions) with infinity.</p>
<ol>
<li>What arithmetic function to use to identify a set of integers (whole numbers) from the object . And how do i replace it as the question asked.</li>
</ol>
<pre><code>structure(Question3_Object)
List of 3
: num [1:7] -3 0.333 3.667 7 10.333 ...
: num [1:21] -3 -2 -1 0 1 2 3 4 5 6 ...
:List of 3
..$ : num [1:6] 3 2.1 3.3 4 1.5 4.9
..$ : chr [1:6] "LOW" "MED" "LOW" "MED" ...
..$ : logi [1:9] FALSE TRUE TRUE TRUE FALSE TRUE ...```
</code></pre>
| [
{
"answer_id": 74140855,
"author": "Victor Bueno",
"author_id": 19757597,
"author_profile": "https://Stackoverflow.com/users/19757597",
"pm_score": 1,
"selected": false,
"text": "listTwo = [num for num in listOne if num % 2 == 0]\nlistThree = [num for num in listOne if num % 2 != 0]\n"
... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140852",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20292030/"
] |
74,140,861 | <p>So yeah, I got my first job and had the first task and we were instructed to create our own branch based of of the current working branch, now I have done my task and would like to merge my branch to our teams' current working branch. What is the step by step here? need help from you guys, I've searched for articles but I'd still like to know from you guys as I'm a bit hesitant to mess up.</p>
| [
{
"answer_id": 74140855,
"author": "Victor Bueno",
"author_id": 19757597,
"author_profile": "https://Stackoverflow.com/users/19757597",
"pm_score": 1,
"selected": false,
"text": "listTwo = [num for num in listOne if num % 2 == 0]\nlistThree = [num for num in listOne if num % 2 != 0]\n"
... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140861",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3352042/"
] |
74,140,872 | <p>I'm using a for to generate a excel file to graph the data from a df so I'm using value_counts but I would like to add under this df a second one with the same data but with percentages so my code is this one:</p>
<pre><code>li = []
for i in range(0, len(df.columns)):
value_counts = df.iloc[:, i].value_counts().to_frame().reset_index()
value_percentage = df.iloc[:, i].value_counts(normalize=True).to_frame().reset_index()#.drop(columns='index')
value_percentage = (value_percentage*100).astype(str)+'%'
li.append(value_counts)
li.append(value_percentage)
data = pd.concat(li, axis=1)
data.to_excel("resultdf.xlsx") #index cleaned
</code></pre>
<p>Basically I need it to look like this:</p>
<p><a href="https://i.stack.imgur.com/1ZDhm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1ZDhm.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74245241,
"author": "Moritz Wilksch",
"author_id": 7426792,
"author_profile": "https://Stackoverflow.com/users/7426792",
"pm_score": 2,
"selected": false,
"text": "pd.concat()"
},
{
"answer_id": 74262061,
"author": "Vitalizzare",
"author_id": 14909621,
... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140872",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16239103/"
] |
74,140,878 | <p>I have tried to scrap data using scrapy spider in python to the targeted URL: <a href="https://www.accenture.com/ro-en/services/data-analytics-index#block-what-we-think" rel="nofollow noreferrer">https://www.accenture.com/ro-en/services/data-analytics-index#block-what-we-think</a>
but it returns the Error: <strong>twisted.python.failure.Failure builtins.ValueError: not enough values to unpack (expected 2, got 1)</strong></p>
<p>But if i try to scrape data using the python requests library it works fine.</p>
| [
{
"answer_id": 74245241,
"author": "Moritz Wilksch",
"author_id": 7426792,
"author_profile": "https://Stackoverflow.com/users/7426792",
"pm_score": 2,
"selected": false,
"text": "pd.concat()"
},
{
"answer_id": 74262061,
"author": "Vitalizzare",
"author_id": 14909621,
... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16502801/"
] |
74,140,889 | <p>I am trying to upload an image in Laravel. Getting the following error:</p>
<pre><code>"message": "Could not move the file \"C:\\xampp\\tmp\\php84AA.tmp\" to \"F:\\bvend\\bvend-web\\public\\uploads/products\\bvend-product-1666274539.jpg\" (move_uploaded_file(): Unable to move &quot;C:\\xampp\\tmp\\php84AA.tmp&quot; to &quot;F:\\bvend\\bvend-web\\public\\uploads/products\\bvend-product-1666274539.jpg&quot;).",
"exception": "Symfony\\Component\\HttpFoundation\\File\\Exception\\FileException",
"file": "F:\\bvend\\bvend-web\\vendor\\symfony\\http-foundation\\File\\UploadedFile.php",
"line": 177,
"trace": [ .... ]
</code></pre>
<p>My code is given below:</p>
<pre><code>public function uploadImage($image, $image_path)
{
$path = config('global.' . $image_path . '_image_path');
file_exists($image) && unlink($image);
$image_name = 'bvend-' . $image_path . '-' . time() . '.' . $image->getClientOriginalExtension();
$image->move($path, $image_name); // $path: public_path('uploads/products')
return $image_name;
}
</code></pre>
<p>I understand its a simple issue but still no clue where it causing issue.</p>
| [
{
"answer_id": 74141427,
"author": "Abdullah Afridi",
"author_id": 8934627,
"author_profile": "https://Stackoverflow.com/users/8934627",
"pm_score": 0,
"selected": false,
"text": "public function uploadImage($image, $image_path)\n {\n // $path = config('global.' ... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140889",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3682099/"
] |
74,140,917 | <p>I was trying to create this <code>[80000, 104000, 135000...]</code> list in Python. Its the value, starting at 80,000 multiplied by 1.3 each time I want</p>
<p>What i've tried:</p>
<pre><code>a = [num*1.5 for num in ??? if num>=80000] #???--> i've tried range(10)
</code></pre>
<p>I should be able to do this but I can't find any solutions rn..
I must use list-comprehensions, if possible.</p>
<p>Some help would be nice, thank you!</p>
| [
{
"answer_id": 74141125,
"author": "Hyperplane",
"author_id": 9318372,
"author_profile": "https://Stackoverflow.com/users/9318372",
"pm_score": -1,
"selected": false,
"text": "import numpy as np\nprint(80000 * 1.3**np.arange(3))\n# [ 80000. 104000. 135200.]\n"
},
{
"answer_id": 7... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140917",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19786208/"
] |
74,140,938 | <p>I have some files that look like this:</p>
<pre><code>Node Present
1 243
2 445
10 65
4 456
43 8
...
</code></pre>
<p>I need to remove the values corresponding to specific nodes and I have a file specifying this nodes that looks like this:</p>
<pre><code>1
4
...
</code></pre>
<p>The idea is to delete the lines that start with the values specified in my second file. I know that "sed" can do something like this, but I do not know how to apply it for all the values specified in the second file. More over, I want to delete node 1, but not node 100, and I am seeing that node 100 will also get erased with my approach.</p>
<pre><code>sed '/^1/d'
</code></pre>
| [
{
"answer_id": 74140997,
"author": "anubhava",
"author_id": 548225,
"author_profile": "https://Stackoverflow.com/users/548225",
"pm_score": 3,
"selected": true,
"text": "sed"
},
{
"answer_id": 74141033,
"author": "William Pursell",
"author_id": 140750,
"author_profile... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140938",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17550734/"
] |
74,140,967 | <pre><code>int num,address ;
address = &num ;
num = 2029 ;
printf("\n%d",address) ;
</code></pre>
<p>It is printing the <em>address</em> of num but address of num is being printed.</p>
<p>Is it possible to print value of variable by <em>accessing its address</em> not by name like we do in the <code>scanf()</code> function?</p>
| [
{
"answer_id": 74141030,
"author": "Vlad from Moscow",
"author_id": 2877241,
"author_profile": "https://Stackoverflow.com/users/2877241",
"pm_score": 2,
"selected": false,
"text": "int num = 2029;\nint *address = #\nprintf( \"\\n%d\",*address) ;\n"
},
{
"answer_id": 74141442,... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140967",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19859895/"
] |
74,140,971 | <pre class="lang-yaml prettyprint-override"><code>- name: get ocp version
shell: "oc get clusterversion | awk '{print $2}'| tail -1"
register: ver
</code></pre>
<p>I have used above task to register the output in Ansible task, but <code>ver</code> will have minor version as well - <code>4.8.1</code>, I need only major version i.e., <code>4.8</code>.</p>
| [
{
"answer_id": 74141988,
"author": "P....",
"author_id": 6309601,
"author_profile": "https://Stackoverflow.com/users/6309601",
"pm_score": 2,
"selected": true,
"text": "- name: get ocp version\n shell: oc get clusterversion | awk 'END{split($2,a,\".\");print a[1] \".\" a[2]}'\n registe... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140971",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3572573/"
] |
74,140,972 | <p>I have a list=[1,2,3,4]
And I only want to receive tuple results for like all the positions in a matrix, so it would be</p>
<pre><code>(1,1),(1,2),(1,3),(1,4),(2,1),(2,2),(2,3),(2,4),(3,1),(3,2),(3,3),(3,4),(4,1),(4,2),(4,3),(4,4)
</code></pre>
<p>I've seen several codes that return all the combinations but i don't know how to restrict it only to the tuples or how to add the (1,1),(2,2),(3,3),(4,4)</p>
<p>Thank you in advance.</p>
| [
{
"answer_id": 74141146,
"author": "AziMez",
"author_id": 13809290,
"author_profile": "https://Stackoverflow.com/users/13809290",
"pm_score": 0,
"selected": false,
"text": "lst=[1,2,3,4]\n\nout=[(i,i) for i in lst]\n\nprint(out)\n"
},
{
"answer_id": 74141190,
"author": "skenv... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140972",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20277243/"
] |
74,140,973 | <p>Currently, I have an array in Javascript named locations, described below:</p>
<pre><code>let locations = [
{
"id": "1",
"city": "Kermit",
"state": "TX",
},
{
"id": "2",
"city": "Bloomington",
"state": "MN",
},
{
"id": "3",
"city": "Pauls Valley",
"state": "OK",
},
{
"id": "4",
"city": "Colville",
"state": "WA",
},
{
"id": "5",
"city": "Jacksboro",
"state": "TX",
},
{
"id": "6",
"city": "Shallowater",
"state": "TX"
}
]
</code></pre>
<p>using Javascript, I need to create another array from this array by filtering out the cities with the same states as a single array within the locations array.
required output:</p>
<pre><code>locations = [
TX:[{
"id": "1",
"city": "Kermit",
"state": "TX",
},
{
"id": "5",
"city": "Jacksboro",
"state": "TX",
},
{
"id": "6",
"city": "Shallowater",
"state": "TX"
}
],
MN:[
{
"id": "2",
"city": "Bloomington",
"state": "MN",
},
],
OK:[
{
"id": "3",
"city": "Pauls Valley",
"state": "OK",
},
],
WA:[
{
"id": "4",
"city": "Colville",
"state": "WA",
},
]
]
</code></pre>
<p>Also, I need this array sorted in alphabetical order. If some one could give me a good approach to solve this scenario, it would be a great help.</p>
| [
{
"answer_id": 74141146,
"author": "AziMez",
"author_id": 13809290,
"author_profile": "https://Stackoverflow.com/users/13809290",
"pm_score": 0,
"selected": false,
"text": "lst=[1,2,3,4]\n\nout=[(i,i) for i in lst]\n\nprint(out)\n"
},
{
"answer_id": 74141190,
"author": "skenv... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140973",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20292109/"
] |
74,140,974 | <p>I'm trying to have a program output data to a JSON file, but VS code or Python itself seems to have a problem with that. Specifically, I'm trying to output this(Tlist and Slist are lists of integers):</p>
<pre><code>output = {"Time": Tlist, "Space": Slist}
json_data = json.dumps(output, indent=4)
with open("sortsOutput.json", "a") as outfile:
outfile.write(json_data)
</code></pre>
<p>But nothing seems to be happening. SortsOutput.json was never made, and even with a pre-existing SortsOuput.json nothing happened. Heck, this doesn't even work:</p>
<pre><code>out = open("blah.txt", "w")
out.write("Egg")
out.close()
</code></pre>
<p>What might be going wrong for my software for this to happen? I'm using Python v2022.16.1, for the record, and every time the program runs for the first time the command "conda activate base" happens with some error text that doesn't seem to affect the rest of my program, so is it that? How do I fix that?</p>
| [
{
"answer_id": 74141146,
"author": "AziMez",
"author_id": 13809290,
"author_profile": "https://Stackoverflow.com/users/13809290",
"pm_score": 0,
"selected": false,
"text": "lst=[1,2,3,4]\n\nout=[(i,i) for i in lst]\n\nprint(out)\n"
},
{
"answer_id": 74141190,
"author": "skenv... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74140974",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20292162/"
] |
74,141,052 | <p>I'm trying to override the primary color in Bootstrap but it just doesn't work. Btw I'm using NextJS.</p>
<p>This is my "globals.scss" which I have imported in "_app.js".</p>
<pre><code>$primary: black;
@import 'bootstrap/scss/bootstrap';
</code></pre>
<p>And I have imported Bootstrap in index.js like this</p>
<pre><code>import 'bootstrap/dist/css/bootstrap.css'
</code></pre>
<p>I tried looking it up but everything I tried didn't work.
What I've tried:</p>
<ul>
<li>Importing functions, variables, and mixins from Bootstrap SCSS.</li>
<li>Rearranging the imports.</li>
<li>Importing bootstrap/scss/bootstrap.scss to "_app.js"</li>
</ul>
<p>But I've noticed that in the inspector it says my primary color is black but then right above it changes back to the original:</p>
<p>Below:</p>
<p><a href="https://i.stack.imgur.com/lx8tr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lx8tr.png" alt="my color" /></a></p>
<p>Above:</p>
<p><a href="https://i.stack.imgur.com/wx8OX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wx8OX.png" alt="original color" /></a></p>
| [
{
"answer_id": 74141122,
"author": "Cervus camelopardalis",
"author_id": 10347145,
"author_profile": "https://Stackoverflow.com/users/10347145",
"pm_score": 2,
"selected": false,
"text": "$primary"
},
{
"answer_id": 74148960,
"author": "hamid-davodi",
"author_id": 1377093... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141052",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13808098/"
] |
74,141,081 | <p>In Python, I can have the equivalent of C# static members:</p>
<pre class="lang-py prettyprint-override"><code>class MyClass:
i = 0 # This is like a C# static member
print(MyClass.i)
</code></pre>
<p>gives output</p>
<pre><code>0
</code></pre>
<p>But maybe my static member needs to be calculated somehow. I can do:</p>
<pre class="lang-py prettyprint-override"><code>class MyClass:
i = 0
i += 10
print(MyClass.i)
</code></pre>
<p>gives output</p>
<pre><code>10
</code></pre>
<p>In practice, I'm writing a config class which needs to read a json file from disk, validate it, and then populate some static members. The closest thing to what I want to do in Python would look like:</p>
<pre class="lang-py prettyprint-override"><code>class GlobalConfig:
with open('config.json', 'r') as f:
config_dict = json.read(f)
# Maybe do some validation here.
i = config_dict["i"]
a = config_dict["hello_world"]
</code></pre>
<p>Truth be told, I wouldn't really do this in Python, but I'm borrowing from C# in that everything needs to go in classes.</p>
<p>In practice in my C# code, I would have a <code>GlobalConfig</code> class in a <code>Config.cs</code> file and all my other files would have access to this.</p>
<p>But it seems I can't do anything other than declare/define members in the class body. How can I do the work of loading up and parsing my config file and have the result of that be accessible as static members to the rest of my program?</p>
<p>PS: I don't really want this to influence the answers I get in unless it has to, but FYI I am working with Unity.</p>
| [
{
"answer_id": 74141133,
"author": "Dmitry Bychenko",
"author_id": 2319407,
"author_profile": "https://Stackoverflow.com/users/2319407",
"pm_score": 3,
"selected": true,
"text": "static"
},
{
"answer_id": 74141192,
"author": "MakePeaceGreatAgain",
"author_id": 2528063,
... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141081",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4391249/"
] |
74,141,091 | <p>Json is generated in an ajax call from the view and then sent to the controller, unfortunately the code is not deserialising into an instance of a model and is giving me a null value
The json -</p>
<pre><code>{
"CheckSheetViewModel": {
"LstCheckSheetQuestion": {
"TblCheckSheetQuestion": [{
"CheckSheetQuestionId": "9",
"DateCreated": "04/11/2015 23:37:45",
"CreatedByUserId": "1",
"CheckSheetId": "2",
"QuestionType": "Traffic Lights",
"QuestionText": "Traffic lights and notes image upload test",
"AllowNotes": "",
"IncludeFollowUpDate": "",
"AllowSkip": "",
"AllowSupportingImages": "",
"QuestionTip": "",
"DisplayOrder": "0",
"CheckSheetGroupId": "",
"VehicleVisualsVideoId": "",
"VehicleVisualsVideoTitle": ""
}, {
"CheckSheetQuestionId": "10",
"DateCreated": "04/11/2015 23:38:21",
"CreatedByUserId": "1",
"CheckSheetId": "2",
"QuestionType": "Traffic Lights",
"QuestionText": "Traffic lights question",
"AllowNotes": "",
"IncludeFollowUpDate": "",
"AllowSkip": "",
"AllowSupportingImages": "",
"QuestionTip": "This is tip for this question",
"DisplayOrder": "1",
"CheckSheetGroupId": "",
"VehicleVisualsVideoId": "",
"VehicleVisualsVideoTitle": ""
}, {
"CheckSheetQuestionId": "406",
"DateCreated": "04/04/2016 09:55:30",
"CreatedByUserId": "1",
"CheckSheetId": "2",
"QuestionType": "Image Upload",
"QuestionText": "My test",
"AllowNotes": "",
"IncludeFollowUpDate": "",
"AllowSkip": "",
"AllowSupportingImages": "",
"QuestionTip": "",
"DisplayOrder": "3009",
"CheckSheetGroupId": "36",
"VehicleVisualsVideoId": "",
"VehicleVisualsVideoTitle": ""
}, {
"CheckSheetQuestionId": "407",
"DateCreated": "04/04/2016 10:18:34",
"CreatedByUserId": "1",
"CheckSheetId": "2",
"QuestionType": "Yes No",
"QuestionText": "This is question 3",
"AllowNotes": "",
"IncludeFollowUpDate": "",
"AllowSkip": "",
"AllowSupportingImages": "",
"QuestionTip": "",
"DisplayOrder": "2",
"CheckSheetGroupId": "",
"VehicleVisualsVideoId": "",
"VehicleVisualsVideoTitle": ""
}, {
"CheckSheetQuestionId": "440",
"DateCreated": "02/12/2016 17:57:04",
"CreatedByUserId": "2",
"CheckSheetId": "2",
"QuestionType": "Image Upload",
"QuestionText": "Another image question",
"AllowNotes": "",
"IncludeFollowUpDate": "",
"AllowSkip": "",
"AllowSupportingImages": "",
"QuestionTip": "",
"DisplayOrder": "1008",
"CheckSheetGroupId": "34",
"VehicleVisualsVideoId": "",
"VehicleVisualsVideoTitle": ""
}, {
"CheckSheetQuestionId": "5180",
"DateCreated": "23/08/2021 08:44:17",
"CreatedByUserId": "1",
"CheckSheetId": "2",
"QuestionType": "Traffic Lights",
"QuestionText": "test",
"AllowNotes": "",
"IncludeFollowUpDate": "",
"AllowSkip": "",
"AllowSupportingImages": "",
"QuestionTip": "",
"DisplayOrder": "3",
"CheckSheetGroupId": "",
"VehicleVisualsVideoId": "",
"VehicleVisualsVideoTitle": ""
}, {
"CheckSheetQuestionId": "5181",
"DateCreated": "23/08/2021 08:45:07",
"CreatedByUserId": "1",
"CheckSheetId": "2",
"QuestionType": "Yes No",
"QuestionText": "test 2",
"AllowNotes": "",
"IncludeFollowUpDate": "",
"AllowSkip": "",
"AllowSupportingImages": "",
"QuestionTip": "",
"DisplayOrder": "4",
"CheckSheetGroupId": "",
"VehicleVisualsVideoId": "",
"VehicleVisualsVideoTitle": ""
}, {
"CheckSheetQuestionId": "5182",
"DateCreated": "23/08/2021 08:46:04",
"CreatedByUserId": "1",
"CheckSheetId": "2",
"QuestionType": "Image Upload",
"QuestionText": "test question",
"AllowNotes": "",
"IncludeFollowUpDate": "",
"AllowSkip": "",
"AllowSupportingImages": "",
"QuestionTip": "",
"DisplayOrder": "5",
"CheckSheetGroupId": "",
"VehicleVisualsVideoId": "",
"VehicleVisualsVideoTitle": ""
}, {
"CheckSheetQuestionId": "5183",
"DateCreated": "23/08/2021 08:51:35",
"CreatedByUserId": "1",
"CheckSheetId": "2",
"QuestionType": "Traffic Lights",
"QuestionText": "question 10",
"AllowNotes": "",
"IncludeFollowUpDate": "",
"AllowSkip": "",
"AllowSupportingImages": "",
"QuestionTip": "",
"DisplayOrder": "6",
"CheckSheetGroupId": "",
"VehicleVisualsVideoId": "",
"VehicleVisualsVideoTitle": ""
}, {
"CheckSheetQuestionId": "5184",
"DateCreated": "23/08/2021 08:51:35",
"CreatedByUserId": "1",
"CheckSheetId": "2",
"QuestionType": "Serviceability",
"QuestionText": "question 11",
"AllowNotes": "",
"IncludeFollowUpDate": "",
"AllowSkip": "",
"AllowSupportingImages": "",
"QuestionTip": "",
"DisplayOrder": "7",
"CheckSheetGroupId": "",
"VehicleVisualsVideoId": "",
"VehicleVisualsVideoTitle": ""
}]
},
"LstCheckSheetQuestionGroup": {
"TblCheckSheetQuestionGroup": [{}, {
"CheckSheetGroupId": "34",
"DateCreated": "04/04/2016 09:55:05",
"Name": "Under The Bonnet",
"AnswerAsGroup": "true",
"DisplayOrder": "1"
}, {
"CheckSheetGroupId": "35",
"DateCreated": "04/04/2016 09:55:06",
"Name": "Tyre Report",
"AnswerAsGroup": "true",
"DisplayOrder": "3"
}, {
"CheckSheetGroupId": "36",
"DateCreated": "04/04/2016 10:18:04",
"Name": "Brake Report",
"AnswerAsGroup": "true",
"DisplayOrder": "4"
}, {
"CheckSheetGroupId": "37",
"DateCreated": "04/04/2016 10:18:04",
"Name": "Vehicle Raised",
"AnswerAsGroup": "true",
"DisplayOrder": "5"
}, {
"CheckSheetGroupId": "39",
"DateCreated": "04/04/2016 10:18:04",
"Name": "To Finish",
"AnswerAsGroup": "true",
"DisplayOrder": "7"
}, {
"CheckSheetGroupId": "42",
"DateCreated": "04/04/2016 10:18:34",
"Name": "Vehicle Lowered",
"AnswerAsGroup": "true",
"DisplayOrder": "6"
}]
},
"LstCheckSheet": {
"TblCheckSheet": [{
"CheckSheetId": "2",
"Description": "Amateur Service",
"DateCreated": "04/11/2015 23:37:45",
"CreatedByUserId": "1",
"Enabled": "true",
"StartMessage": "",
"EndMessage": "",
"AnswerInSequence": "False",
"AddToAllNewJobs": "True",
"MustBeSignedOff": "true"
}]
}
}
}
</code></pre>
<p>is being sent to this controller item -</p>
<pre><code> [HttpPost]
public ActionResult checkSheetUpdate([FromBody] CheckSheetViewModel data)
{
//do stuff
}
</code></pre>
<p>using this model -</p>
<pre><code> public partial class CheckSheetViewModel
{
[JsonProperty("LstCheckSheetQuestionGroup")]
[JsonPropertyName("LstCheckSheetQuestionGroup")]
public List<TblCheckSheetQuestionGroup> LstCheckSheetQuestionGroup { get; set; }
[JsonProperty("LstCheckSheetQuestion")]
[JsonPropertyName("LstCheckSheetQuestion")]
public List<TblCheckSheetQuestion> LstCheckSheetQuestion { get; set; }
[JsonProperty("LstCheckSheet")]
[JsonPropertyName("LstCheckSheet")]
public List<TblCheckSheet> LstCheckSheet { get; set; }
[JsonProperty("TblCheckSheet")]
[JsonPropertyName("TblCheckSheet")]
public TblCheckSheet TblCheckSheet { get; set; }
[JsonProperty("User")]
[JsonPropertyName("User")]
public TblUser User { get; set; }
[JsonProperty("Vidview")]
[JsonPropertyName("Vidview")]
public VideoViewModel Vidview { get; set; }
[JsonProperty("Animation")]
[JsonPropertyName("Animation")]
public Animation Animation { get; set; }
}
</code></pre>
<p>All the name and cases match and yet I still get a null on the input (data). Am I barking up the wrong tree or is there something obviously wrong? The model is made up of some lists of sub-models (not shown) for brevity.</p>
| [
{
"answer_id": 74141322,
"author": "Serge",
"author_id": 11392290,
"author_profile": "https://Stackoverflow.com/users/11392290",
"pm_score": 1,
"selected": false,
"text": " Root myModel = JsonConvert.DeserializeObject<Root>(json);\n\n public class Root\n {\n public CheckS... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2166283/"
] |
74,141,126 | <p>I'm looking for a tutorial on using a horizontal ListView that behaves like a Tabview, ie displaying the link on the same screen.
Some links to propose?
thanks</p>
<p><a href="https://i.stack.imgur.com/MwVsD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MwVsD.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74141322,
"author": "Serge",
"author_id": 11392290,
"author_profile": "https://Stackoverflow.com/users/11392290",
"pm_score": 1,
"selected": false,
"text": " Root myModel = JsonConvert.DeserializeObject<Root>(json);\n\n public class Root\n {\n public CheckS... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141126",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6438473/"
] |
74,141,154 | <p>I need to count the number of campaigns per day based on the start and end dates of the campaigns</p>
<p><strong>Input Table:</strong></p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Campaign name</th>
<th>Start date</th>
<th>End date</th>
</tr>
</thead>
<tbody>
<tr>
<td>Campaign A</td>
<td>2022-07-10</td>
<td>2022-09-25</td>
</tr>
<tr>
<td>Campaign B</td>
<td>2022-08-06</td>
<td>2022-10-07</td>
</tr>
<tr>
<td>Campaign C</td>
<td>2022-07-30</td>
<td>2022-09-10</td>
</tr>
<tr>
<td>Campaign D</td>
<td>2022-08-26</td>
<td>2022-10-24</td>
</tr>
<tr>
<td>Campaign E</td>
<td>2022-07-17</td>
<td>2022-09-29</td>
</tr>
<tr>
<td>Campaign F</td>
<td>2022-08-24</td>
<td>2022-09-12</td>
</tr>
<tr>
<td>Campaign G</td>
<td>2022-08-11</td>
<td>2022-10-24</td>
</tr>
<tr>
<td>Campaign H</td>
<td>2022-08-26</td>
<td>2022-11-22</td>
</tr>
<tr>
<td>Campaign I</td>
<td>2022-08-29</td>
<td>2022-09-25</td>
</tr>
<tr>
<td>Campaign J</td>
<td>2022-08-21</td>
<td>2022-11-15</td>
</tr>
<tr>
<td>Campaign K</td>
<td>2022-07-20</td>
<td>2022-09-18</td>
</tr>
<tr>
<td>Campaign L</td>
<td>2022-07-31</td>
<td>2022-11-20</td>
</tr>
<tr>
<td>Campaign M</td>
<td>2022-08-17</td>
<td>2022-10-10</td>
</tr>
<tr>
<td>Campaign N</td>
<td>2022-07-27</td>
<td>2022-09-07</td>
</tr>
<tr>
<td>Campaign O</td>
<td>2022-07-29</td>
<td>2022-09-26</td>
</tr>
<tr>
<td>Campaign P</td>
<td>2022-07-06</td>
<td>2022-09-15</td>
</tr>
<tr>
<td>Campaign Q</td>
<td>2022-07-16</td>
<td>2022-09-22</td>
</tr>
</tbody>
</table>
</div>
<p>Out needed <strong>(result):</strong></p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Date</th>
<th>Count unique campaigns</th>
</tr>
</thead>
<tbody>
<tr>
<td>2022-07-02</td>
<td>17</td>
</tr>
<tr>
<td>2022-07-03</td>
<td>47</td>
</tr>
<tr>
<td>2022-07-04</td>
<td>5</td>
</tr>
<tr>
<td>2022-07-05</td>
<td>5</td>
</tr>
<tr>
<td>2022-07-06</td>
<td>25</td>
</tr>
<tr>
<td>2022-07-07</td>
<td>27</td>
</tr>
<tr>
<td>2022-07-08</td>
<td>17</td>
</tr>
<tr>
<td>2022-07-09</td>
<td>58</td>
</tr>
<tr>
<td>2022-07-10</td>
<td>23</td>
</tr>
<tr>
<td>2022-07-11</td>
<td>53</td>
</tr>
<tr>
<td>2022-07-12</td>
<td>18</td>
</tr>
<tr>
<td>2022-07-13</td>
<td>29</td>
</tr>
<tr>
<td>2022-07-14</td>
<td>52</td>
</tr>
<tr>
<td>2022-07-15</td>
<td>7</td>
</tr>
<tr>
<td>2022-07-16</td>
<td>17</td>
</tr>
<tr>
<td>2022-07-17</td>
<td>37</td>
</tr>
<tr>
<td>2022-07-18</td>
<td>33</td>
</tr>
</tbody>
</table>
</div>
<p>How do I need to write the <strong>SQL</strong> command to get the above result? thanks all</p>
| [
{
"answer_id": 74141322,
"author": "Serge",
"author_id": 11392290,
"author_profile": "https://Stackoverflow.com/users/11392290",
"pm_score": 1,
"selected": false,
"text": " Root myModel = JsonConvert.DeserializeObject<Root>(json);\n\n public class Root\n {\n public CheckS... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141154",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20292114/"
] |
74,141,160 | <p>I would like to do an "incremental groupby". I have the following dataframe:</p>
<pre><code>v1 increment
0.1 0
0.5 0
0.42 1
0.4 1
0.3 2
0.7 2
</code></pre>
<p>I would like to compute the average of column v1, by incrementally grouping by the column "increment". For instance when I do the first groupby for 0, I would get the average of the first two rows. The for the second groupby, I would get the average of the first 4 rows ( both increment= 0 and 1), then for the third groupby I would get the average of increment = 0,1 and 2)</p>
<p>Any idea how I could do that efficiently?</p>
<p>Expected output:</p>
<pre><code>group average of v1
0 0.3
1 0.355
2 0.403
</code></pre>
| [
{
"answer_id": 74141323,
"author": "mozway",
"author_id": 16343464,
"author_profile": "https://Stackoverflow.com/users/16343464",
"pm_score": 2,
"selected": true,
"text": "g = df.groupby('increment')['v1'] # set up a grouper for efficiency\nout = (g.sum().cumsum() # cumulated sum... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141160",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9465029/"
] |
74,141,183 | <p>Given some rows coming from a SQL data source with an schema like...</p>
<pre><code>| A | B | C | D | E | F |
</code></pre>
<p>... I'd like to transform it into:</p>
<pre><code>{
A: {
invented: { B, C }
D,
E
F
}
}
</code></pre>
<p>AFAIK, <code>dataFrame.withColumn</code> won't let me implement such transformation (it doesn't support nesting a struct into a first-level struct)</p>
<p>Is my goal ever possible?</p>
| [
{
"answer_id": 74141490,
"author": "partlov",
"author_id": 759126,
"author_profile": "https://Stackoverflow.com/users/759126",
"pm_score": 1,
"selected": false,
"text": "df\n .withColumn(\"nested_struct\", struct(\n col(\"A\"),\n struct(\n col(\"B\"),\n struct(\n... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/411632/"
] |
74,141,198 | <p>In my current project, I have a CMS that is supplying all the data. One field of that CMS is for regular expressions, which allows me to enter my own specific expressions to check in the front end. My problem is that when I pull the regular expression it is coming through the escaped characters, and I can not seem to find a way to get around this.</p>
<p>The expression that I am using is <code>/^\d+$/</code>. As I mentioned this is stored inside my CMS and I am attempting to use it in the following code:</p>
<pre><code> const re = /^\d+$/;
const rea = new RegExp(this.question.QuestionExpression);
console.log(re);
console.log(rea);
console.log(this.answer)
console.log(re.test(this.answer));
console.log(rea.test(this.answer));
console.log(this.answer.toString().match(this.question.QuestionExpression))
</code></pre>
<p><code>this.question.QuestionExpression</code> is the Regular expression that is coming in from the CMS. The problem is not getting it, but how to interperet once I have it. <code>const re</code> is currently just being used as a test and has no real bearing on the final outcome.</p>
<p>The outcome from the above code is as follows:</p>
<pre><code>/^\d+$/
/\/^\d+$\//
13
true
false
null
</code></pre>
<p>As you can see in the second line, it is adding escape characters which are causing it to fail on the 5th line. I am sure that I am missing something simple, but any advice would be greatly appreciated.</p>
| [
{
"answer_id": 74141490,
"author": "partlov",
"author_id": 759126,
"author_profile": "https://Stackoverflow.com/users/759126",
"pm_score": 1,
"selected": false,
"text": "df\n .withColumn(\"nested_struct\", struct(\n col(\"A\"),\n struct(\n col(\"B\"),\n struct(\n... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3605206/"
] |
74,141,206 | <p>I extend my context because I need some file outside of Dockerfile directory.</p>
<p>This is my command :
docker build -f Dockerfile ../../
docker run (imageID)</p>
<p>file structure:</p>
<ul>
<li>model</li>
<li>servers
<ul>
<li>subscribeship (I run docker command in this directory)
<ul>
<li>Dockerfile</li>
<li>index.js</li>
<li>package.json</li>
<li>package-lock.json</li>
</ul>
</li>
</ul>
</li>
</ul>
<p>in my Dockerfile:</p>
<pre><code>FROM node:10
WORKDIR /app
COPY ./servers/subscribeship/package*.json .
RUN npm install
COPY ./servers/subscribeship .
COPY ./models ../../models
EXPOSE 3000
CMD ["node","index.js"]
</code></pre>
<p>log for build image:</p>
<pre><code>+] Building 7.5s (11/11) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 231B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 34B 0.0s
=> [internal] load metadata for docker.io/library/node:10 2.7s
=> [1/6] FROM docker.io/library/node:10@sha256:59531d2835edd5161c8f9512f9e095b1836f7a1fcb0ab73e005ec46047384911 0.0s
=> [internal] load build context 1.3s
=> => transferring context: 23.27MB 1.3s
=> CACHED [2/6] WORKDIR /app 0.0s
=> [3/6] COPY ./servers/subscribeship/package*.json . 0.1s
=> [4/6] RUN npm install 2.6s
=> [5/6] COPY ./servers/subscribeship . 0.4s
=> [6/6] COPY ./models ../../models 0.0s
=> exporting to image 0.3s
=> => exporting layers 0.3s
=> => writing image sha256:9a87c205096b94e442a9f40e7c050ac68383f2da7fd8b285b5ee840c20f922af
</code></pre>
<p>log for run container:</p>
<pre><code>internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module 'sequelize'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/models/index.js:5:19)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
</code></pre>
<p>It seems like npm install not working.
package.json & package-lock.json indeed have sequelize package</p>
<p><a href="https://i.stack.imgur.com/nQGxx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nQGxx.png" alt="enter image description here" /></a></p>
<p>I use same method for test if is my way wrong but it seems work..</p>
<p>I create another directory call bug, as same as servers level.
and then create bug1 directory inside bug folder like this:</p>
<p>command:</p>
<pre><code>docker build -f Dockerfile ../../
docker run (imageId)
</code></pre>
<ul>
<li>bug
<ul>
<li>bug1 (run command in here)
<ul>
<li>Dockerfile</li>
<li>package.json</li>
<li>pakcage-lock.json</li>
<li>.dockerignore</li>
</ul>
</li>
</ul>
</li>
</ul>
<p>dockerfile:</p>
<pre><code>FROM node:10
WORKDIR /app
COPY ./bug/bug1/package.json .
RUN npm install
COPY ./bug/bug1 .
EXPOSE 3000
CMD ["node","index.js"]
</code></pre>
<p><a href="https://i.stack.imgur.com/m8MZ6.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/m8MZ6.jpg" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74141490,
"author": "partlov",
"author_id": 759126,
"author_profile": "https://Stackoverflow.com/users/759126",
"pm_score": 1,
"selected": false,
"text": "df\n .withColumn(\"nested_struct\", struct(\n col(\"A\"),\n struct(\n col(\"B\"),\n struct(\n... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141206",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16930765/"
] |
74,141,235 | <p>I'm using Django for a Web app and I have the following data model:</p>
<pre><code>class classi(models.Model):
nome = models.TextField(null=True)
class Meta:
db_table = 'classi'
class users(models.Model):
name = models.TextField(null=True)
email = models.TextField(null=True)
password = models.TextField(null=True)
classe = models.ForeignKey(classi, db_column='classe', on_delete=models.CASCADE, null=True)
class Meta:
db_table = 'users'
class smartphone(models.Model):
marca = models.TextField(null=True)
modello = models.TextField(null=True)
possessore = models.ForeignKey(users, db_column='possessore', on_delete=models.CASCADE, null=True)
class Meta:
db_table = 'smartphone'
</code></pre>
<p>My goal is to show, on an HTML page, all classi, and for each classi all users and for each user all smartphone.</p>
<p>How can I implement my view.py and my html file?</p>
<p>The only solution that I found is to scan all table with a for loop and, through a condition, select the row using foreign key:</p>
<pre><code> {% for c in classi %}
<p>{{ c.nome }}</p>
{% for u in users %}
{% if u.classe == c %}
<p>{{ u.name }}, {{ u.email }}, {{ u.password }}</p>
{% for s in smartphone %}
{% if s.possessore == u %}<p>{{ s.marca }}, {{ s.modello }}</p> {% endif %}
{% endfor %}
{% endif %}
{% endfor %}
{% endfor %}
</code></pre>
<p>Is there a better solution?</p>
| [
{
"answer_id": 74141490,
"author": "partlov",
"author_id": 759126,
"author_profile": "https://Stackoverflow.com/users/759126",
"pm_score": 1,
"selected": false,
"text": "df\n .withColumn(\"nested_struct\", struct(\n col(\"A\"),\n struct(\n col(\"B\"),\n struct(\n... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141235",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15929222/"
] |
74,141,238 | <p>I have a view in Django that fetches some objects, adds new attribute to them and returns them as JSON response.</p>
<p>The code looks like this:</p>
<pre><code>def stats(request):
items = MyItem.objects.all().order_by('-id')
for item in items:
item.new_attribute = 10
items_json = serializers.serialize('json', items)
return HttpResponse(items_json, content_type='application/json')
</code></pre>
<p>The new_attribute is not visible in JSON response. How can I make it visible in JSON response? It can be accessed in templates normally with {{ item.new_attribute }}.</p>
<p><strong>EDIT:</strong> I'm using default Django serializer (from django.core import serializers)</p>
| [
{
"answer_id": 74141317,
"author": "Egor Wexler",
"author_id": 13698294,
"author_profile": "https://Stackoverflow.com/users/13698294",
"pm_score": 3,
"selected": true,
"text": "MyItem"
},
{
"answer_id": 74141331,
"author": "Code-Apprentice",
"author_id": 1440565,
"aut... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141238",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7500995/"
] |
74,141,242 | <p>I have numpy array like:</p>
<pre><code>x = np.array([
...
[[0, 0, 0, 0],
[0, 1, 1, 0],
[0, 1, 1, 0],
[0, 0, 0, 0]]
...
])
</code></pre>
<p>with shape <code>(4800, 4, 4)</code>.</p>
<p>So i need to replace every <code>0</code> with <code>[1, 1, 2]</code> and every <code>1</code> with <code>[5, 5, 9]</code></p>
<p>Result should be like this:</p>
<pre><code>[[[1, 1, 2], [1, 1, 2], [1, 1, 2], [1, 1, 2]],
[[1, 1, 2], [5, 5, 9], [5, 5, 9], [1, 1, 2]],
[[1, 1, 2], [5, 5, 9], [5, 5, 9], [1, 1, 2]],
[[1, 1, 2], [1, 1, 2], [1, 1, 2], [1, 1, 2]]]
</code></pre>
<p><strong>How do I do this?</strong></p>
| [
{
"answer_id": 74141409,
"author": "mozway",
"author_id": 16343464,
"author_profile": "https://Stackoverflow.com/users/16343464",
"pm_score": 3,
"selected": true,
"text": " # 0 1\nmapper = np.array([[1, 1, 2], [5, 5, 9]])\n\nout = mapper[a]\n"
},
{
"a... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141242",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13298898/"
] |
74,141,247 | <p>I want you to print the attachment of the incoming email. But it runs into an 438 error :( What could be wrong?</p>
<p>Code:</p>
<pre><code>Sub AttachmentPrint(Item As Outlook.MailItem)
On Error GoTo OError
Dim oFS As FileSystemObject
Dim sTempFolder As String
Set oFS = New FileSystemObject
sTempFolder = oFS.GetSpecialFolder(TemporaryFolder)
cTmpFld = sTempFolder & "\OETMP" & Format(Now, "yyyymmddhhmmss")
MkDir (cTmpFld)
Dim oAtt As Attachment
For Each oAtt In Item.Attachments
FileName = oAtt.FileName
FileType = LCase$(Right$(FileName, 4))
FullFile = cTmpFld & "\" & FileName
oAtt.SaveAsFile (FullFile)
Select Case FileType
Case ".doc", "docx", ".pdf", ".txt", ".jpg"
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace(0)
Set objFolderItem = objFolder.ParseName(FullFile)
objFolderItem.InvokeVebrEx ("Print")
End Select
Next oAtt
If Not oFS Is Nothing Then Set oFS = Nothing
If Not objFolder Is Nothing Then Set objFolder = Nothing
If Not objFolderItem Is Nothing Then Set objFolderItem = Nothing
If Not objShell Is Nothing Then Set objShell = Nothing
OError:
If Err <> 0 Then
MsgBox Err.Number & " - " & Err.Description
Err.Clear
End If
Exit Sub
End Sub
</code></pre>
| [
{
"answer_id": 74141409,
"author": "mozway",
"author_id": 16343464,
"author_profile": "https://Stackoverflow.com/users/16343464",
"pm_score": 3,
"selected": true,
"text": " # 0 1\nmapper = np.array([[1, 1, 2], [5, 5, 9]])\n\nout = mapper[a]\n"
},
{
"a... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141247",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20292314/"
] |
74,141,249 | <p>I was doing some anti metamethod hooks and I was curious on what metamethod is called in the code below between the parentheses</p>
<pre class="lang-lua prettyprint-override"><code>local test = "random string"
if (test == "random string") then --// What metamethod if any is being called here?
print("equals")
end
</code></pre>
<p>I've done some research and took a look at the __eq metamethod, but that is only called when comparing two tables which isn't what I'm tryna do.</p>
<p>If there isn't any metamethod being called then how would I protect the if condition?</p>
<p>-- Update --</p>
<p>What if I put every string inside of a table for example:</p>
<pre><code>local _Table1 = {"Test1", "Test2"}
local _Table2 = {"Test1", "Test2"}
for Index, Value in next, _Table1 do
if Value == _Table2[Index] then
print("Tables Match!")
elseif Value ~= _Table2[Index]
print("Tables Don't Match!")
end
end
</code></pre>
<p>I'm not doing any string converting here, but I'm showing what I could try and do for a simple anti tamper.</p>
| [
{
"answer_id": 74141409,
"author": "mozway",
"author_id": 16343464,
"author_profile": "https://Stackoverflow.com/users/16343464",
"pm_score": 3,
"selected": true,
"text": " # 0 1\nmapper = np.array([[1, 1, 2], [5, 5, 9]])\n\nout = mapper[a]\n"
},
{
"a... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141249",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16735847/"
] |
74,141,266 | <p>I set up a summary dataframe to only show the high/low of 3 measures across the country and then color coded the negative values. I'm stuck on also bolding the negative values in the same step. When I try:</p>
<pre><code>color = '#AF0061' & 'font-weight: bold'
</code></pre>
<p>It says unsupported operand type(s) for &: 'str' and 'str', but I don't get why. I thought I was only applying the function to the numeric columns.</p>
<pre><code>#define min/max index (State) and value for each metric
mx_Rs =df.loc[df.DeltaReadmitRate == df.DeltaReadmitRate.max(), 'State'].values[0]
mn_Rs =df.loc[df.DeltaReadmitRate == df.DeltaReadmitRate.min(), 'State'].values[0]
mx_R = df['DeltaReadmitRate'].max()/100
mn_R = df['DeltaReadmitRate'].min()/100
mx_Ts =df.loc[df.DeltaTAT == df.DeltaTAT.max(), 'State'].values[0]
mn_Ts =df.loc[df.DeltaTAT == df.DeltaTAT.min(), 'State'].values[0]
mx_T = df['DeltaTAT'].max()/100
mn_T = df['DeltaTAT'].min()/100
mx_Ls =df.loc[df.DeltaLOS == df.DeltaLOS.max(), 'State'].values[0]
mn_Ls =df.loc[df.DeltaLOS == df.DeltaLOS.min(), 'State'].values[0]
mx_L = df['DeltaLOS'].max()/100
mn_L = df['DeltaLOS'].min()/100
#convert to dataframe
data = {'State': [mx_Rs, mn_Rs],
'Readmission Rate': [mx_R, mn_R],
'State ': [mx_Ts, mn_Ts],
'Turnaround Time': [mx_T, mn_T],
'State ': [mx_Ls, mn_Ls],
'Length of Stay': [mx_L, mn_L],
}
df_Summary = pd.DataFrame(data)
#insert new column "Delta and plug in values"
df_Summary.insert(0, "Delta", ['Worst Increase', 'Biggest Improvement'], True)
#format
numeric_columns = ['Readmission Rate', 'Turnaround Time', 'Length of Stay']
col_format = {'Readmission Rate': '{:,.2%}', 'Turnaround Time':'{:,.2%}', 'Length of Stay':'{:,.2%}'}
def format_font(x):
if x < 0:
color = '#AF0061'
else:
color = 'black'
return f'color: {color}'
df_styled = df_Summary.style.\
format(col_format).\
applymap(format_font, subset=numeric_columns).\
hide(axis='index').\
set_table_styles(
[{'selector': 'th',
'props': [('background', '#78BE20'), ('color', 'white'), ('font-weight', 'bold'), ('text-align', 'right')]},
{'selector': 'th.row_heading',
'props': [('background', 'white'), ('color', 'black'),('font-weight', 'bold'), ('text-align', 'center')]},
]
)
</code></pre>
<p><a href="https://i.stack.imgur.com/bNypX.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bNypX.jpg" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74141359,
"author": "DonPre",
"author_id": 7022759,
"author_profile": "https://Stackoverflow.com/users/7022759",
"pm_score": 0,
"selected": false,
"text": "'#AF0061'"
},
{
"answer_id": 74141895,
"author": "nigh_anxiety",
"author_id": 17030540,
"author_p... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141266",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5301340/"
] |
74,141,269 | <p>I'm trying to display a scaffold msg when user inputted a value greater than some other value...</p>
<p>It is working fine until I clear the input...</p>
<p>After clearing the input it throws an exception...</p>
<p>Here it is...</p>
<pre><code>══╡ EXCEPTION CAUGHT BY WIDGETS ╞═══════════════════════════════════════════════════════════════════
The following FormatException was thrown while calling onChanged:
Invalid number (at character 1)
^
When the exception was thrown, this was the stack:
#0 int._handleFormatError (dart:core-patch/integers_patch.dart:129:7)
#1 int.parse (dart:core-patch/integers_patch.dart:55:14)
#2 _GeneralTabState.build.<anonymous closure>.<anonymous closure>
(package:shop_app_vendor/screens/add_products/general_tab.dart:247:25)
#3 new TextFormField.<anonymous closure>.onChangedHandler (package:flutter/src/material/text_form_field.dart:188:25)
#4 EditableTextState._formatAndSetValue (package:flutter/src/widgets/editable_text.dart:2630:27)
#5 EditableTextState.userUpdateTextEditingValue (package:flutter/src/widgets/editable_text.dart:2919:5)
#6 EditableTextState._replaceText (package:flutter/src/widgets/editable_text.dart:3144:5)
#7 CallbackAction.invoke (package:flutter/src/widgets/actions.dart:534:39)
#8 ActionDispatcher.invokeAction (package:flutter/src/widgets/actions.dart:573:21)
#9 Actions.invoke.<anonymous closure> (package:flutter/src/widgets/actions.dart:872:48)
#10 Actions._visitActionsAncestors (package:flutter/src/widgets/actions.dart:653:18)
#11 Actions.invoke (package:flutter/src/widgets/actions.dart:866:30)
#12 _DeleteTextAction.invoke (package:flutter/src/widgets/editable_text.dart:4042:20)
#13 _OverridableContextAction.invokeDefaultAction (package:flutter/src/widgets/actions.dart:1696:28)
#14 _OverridableActionMixin.invoke (package:flutter/src/widgets/actions.dart:1559:9)
#15 ActionDispatcher.invokeAction (package:flutter/src/widgets/actions.dart:571:21)
#16 ShortcutManager.handleKeypress (package:flutter/src/widgets/shortcuts.dart:755:38)
#17 _ShortcutsState._handleOnKey (package:flutter/src/widgets/shortcuts.dart:956:20)
#18 FocusManager._handleKeyMessage (package:flutter/src/widgets/focus_manager.dart:1687:32)
#19 KeyEventManager._dispatchKeyMessage (package:flutter/src/services/hardware_keyboard.dart:828:34)
#20 KeyEventManager.handleRawKeyMessage (package:flutter/src/services/hardware_keyboard.dart:875:15)
#21 BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:77:49)
#22 BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:76:47)
#23 _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:380:35)
#24 _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:377:46)
#25 _invoke2.<anonymous closure> (dart:ui/hooks.dart:190:15)
#29 _invoke2 (dart:ui/hooks.dart:189:10)
#30 _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:42:5)
#31 _Channel.push (dart:ui/channel_buffers.dart:132:31)
#32 ChannelBuffers.push (dart:ui/channel_buffers.dart:329:17)
#33 PlatformDispatcher._dispatchPlatformMessage (dart:ui/platform_dispatcher.dart:589:22)
#34 _dispatchPlatformMessage (dart:ui/hooks.dart:89:31)
(elided 3 frames from dart:async)
════════════════════════════════════════════════════════════════════════════════════════════════════
</code></pre>
<p>And here's my code...</p>
<p><strong>scf.dart</strong></p>
<pre><code>class SCF {
scaffoldMsg({context, msg}) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(msg),
backgroundColor: Colors.red,
action: SnackBarAction(
label: 'OK',
textColor: Colors.white,
onPressed: () {
ScaffoldMessenger.of(context).clearSnackBars();
},
),
));
}
}
</code></pre>
<p><strong>general_tab.dart</strong></p>
<pre><code>class GeneralTab extends StatefulWidget {
const GeneralTab({Key? key}) : super(key: key);
@override
State<GeneralTab> createState() => _GeneralTabState();
}
class _GeneralTabState extends State<GeneralTab> {
final SCF _scf = SCF();
@override
Widget build(BuildContext context) {
return Consumer<ProductProvider>(
builder: (context, provider, child) {
return ListView(
padding: const EdgeInsets.all(15.0),
children: [
// Regular Price
FormFieldInput(
label: 'Regular Price',
inputType: TextInputType.number,
onChanged: (value) {
provider.getFormData(regularPrice: int.parse(value));
},
),
// Sales Price
FormFieldInput(
label: 'Sales Price',
inputType: TextInputType.number,
onChanged: (value) {
if (int.parse(value) > provider.productData!['regularPrice']) {
_scf.scaffoldMsg(
context: context,
msg: 'Sales price should be less than regular price',
);
}
setState(() {
provider.getFormData(salesPrice: int.parse(value));
});
},
),
],
);
},
);
}
}
</code></pre>
<p><strong>product_provider.dart</strong></p>
<pre><code>class ProductProvider with ChangeNotifier {
Map<String, dynamic>? productData = {};
getFormData({
int? regularPrice,
int? salesPrice,
}) {
if (regularPrice != null) {
productData!['regularPrice'] = regularPrice;
}
if (salesPrice != null) {
productData!['salesPrice'] = salesPrice;
}
notifyListeners();
}
}
</code></pre>
<p><strong>form_field.dart</strong></p>
<pre><code>class FormFieldInput extends StatelessWidget {
final String? label;
final void Function(String)? onChanged;
final TextInputType? inputType;
const FormFieldInput({
Key? key,
this.label,
this.onChanged,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return TextFormField(
decoration: InputDecoration(
label: Text(label!),
),
onChanged: onChanged,
);
}
}
</code></pre>
<p>This is working fine and showing scaffold msg until I delete the content in the input...</p>
<p>So how can I fix this?</p>
| [
{
"answer_id": 74152607,
"author": "Kvu",
"author_id": 19701828,
"author_profile": "https://Stackoverflow.com/users/19701828",
"pm_score": 0,
"selected": false,
"text": "if(value.isNotEmpty)"
}
] | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141269",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19701828/"
] |
74,141,271 | <p>Hello I have a <strong>stimulus</strong> code into my <strong>symfony project</strong>.
This code is calling a <strong>rest API</strong> which taking around 3 seconds to provide the response. This rest api return JSON.</p>
<p>This is my code :</p>
<pre><code>import {Controller} from "@hotwired/stimulus";
import axios from "axios";
export default class extends Controller {
static values = {
url: String
}
connect() {
axios.get(this.urlValue)
.then((r) => {
if (r.data !== null) {
let html
const tmp = JSON.parse(r.data)
if (tmp === null) {
html = document.createElement("div")
html.classList.add("alert", "alert-danger", "alert-dismissible", "fade", "show")
html.innerHTML += "Asset Number Not Valid";
html.innerHTML += "<button type=\"button\" class=\"btn-close\" data-bs-dismiss=\"alert\" aria-label=\"Close\"></button>"
} else {
html = document.createElement("ul")
html.classList.add("list-group")
for(let key in tmp) {
html.innerHTML += "<li class=\"list-group-item\">" + key + " : " + tmp[key] + "</li>";
}
html.innerHTML += "</ul>";
}
this.element.replaceWith(html);
}
})
}
}
</code></pre>
<p>As you can see, it's building a list or display an error. This code is really simple and works well. I just don't like how html is build.</p>
<p>Do you have any other/cleaner way ?</p>
| [
{
"answer_id": 74151547,
"author": "Denis Omerovic",
"author_id": 7798841,
"author_profile": "https://Stackoverflow.com/users/7798841",
"pm_score": 0,
"selected": false,
"text": "errorMessage() {\n const div = document.createElement(\"div\");\n div.innerHTML = `\n <p>Some HTML here<... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141271",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11476399/"
] |
74,141,272 | <p>So, i tried to ping roles in Discord.js 14 in an embed, but it doesn't work. It only shows <code><@&1032648819340480586></code> this and not the actual role itself.</p>
<p>I hope I can get help here.</p>
| [
{
"answer_id": 74146430,
"author": "IDcLuc",
"author_id": 13547760,
"author_profile": "https://Stackoverflow.com/users/13547760",
"pm_score": -1,
"selected": true,
"text": "<@&1032648819340480586>"
}
] | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18269108/"
] |
74,141,362 | <p>Suppose I have this dataset (the actual dataset has 30+ columns and thousands of ids)</p>
<pre><code> df <- data.frame(id = 1:5,
admission = c("Severe", "Mild", "Mild", "Moderate", "Severe"),
d1 = c(NA, "Moderate", "Mild", "Moderate", "Severe"),
d2 = c(NA, "Moderate", NA, "Mild", "Moderate"),
d3 = c(NA, "Severe", NA, "Mild", NA),
d4 = c(NA, NA, NA, "Mild", NA),
outcome = c("Dead", "Dead", "Alive", "Alive", "Dead"))
</code></pre>
<p>I want to make a Sankey diagram that illustrates the daily severity of the patients over time. However, when the observation reaches NA (means that an outcome has been reached), I want the node to directly link to the outcome.</p>
<p>This is how the diagram should look like:
<a href="https://i.stack.imgur.com/rnoUq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rnoUq.png" alt="enter image description here" /></a></p>
<p><em>Image fetched from the question asked by @qdread <a href="https://stackoverflow.com/questions/58101983/create-sankey-diagram-with-ggforce-that-skips-nodes?noredirect=1#comment130877204_58101983">here</a></em></p>
<p>Is this possible with <code>ggsankey</code>?</p>
<p>This is my current code:</p>
<pre><code>df.sankey <- df %>%
make_long(admission, d1, d2, d3, d4, outcome)
ggplot(df.sankey, aes(x = x,
next_x = next_x,
node = node,
next_node = next_node,
fill = factor(node),
label = node)) +
geom_sankey(flow. Alpha = 0.5,
node. Color = NA,
show. Legend = TRUE) +
geom_sankey_text(size = 3, color = "black", fill = NA, hjust = 0, position = position_nudge(x = 0.1))
</code></pre>
<p><strong>EDIT</strong>
Based on the solution provided by @Allan Cameron, I managed to bypass the nodes with NA values. However, the diagram looks quite complex because the links to the <code>targets</code> are not sorted.</p>
<pre><code> do.call(rbind, apply(df, 1, function(x) {
x <- na.omit(x[-1])
data.frame(x = names(x), node = x,
next_x = dplyr::lead(names(x)),
next_node = dplyr::lead(x), row.names = NULL)
})) %>%
ggplot(df.sankey, aes(x = x,
next_x = next_x,
node = node,
next_node = next_node,
fill = factor(node),
label = node)) +
geom_sankey(flow.alpha = 0.5,
node.color = NA,
show.legend = TRUE) +
geom_sankey_text(size = 3, color = "black", fill = NA, hjust = 0, position = position_nudge(x = 0.1))
</code></pre>
<p>which results in this diagram:
<a href="https://i.stack.imgur.com/OYJt2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OYJt2.png" alt="enter image description here" /></a></p>
<p>Is it possible to sort the links to the Outcome <code>target</code> so that all links with <code>Severe</code> value gets aggregated?</p>
<p>Thanks in advance for the help.</p>
| [
{
"answer_id": 74141655,
"author": "zx8754",
"author_id": 680068,
"author_profile": "https://Stackoverflow.com/users/680068",
"pm_score": 1,
"selected": false,
"text": "library(ggplot2)\nlibrary(dplyr)\nlibrary(ggsankey)\n\n# fill NAs from last value\ndf[] <- t(apply(df, 1, zoo::na.locf,... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141362",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14571524/"
] |
74,141,367 | <p>I get an attribute error if I use the function:</p>
<pre><code>def faceDetection():
if results.detections:
for detection in results.detection:
print(id, detection)
</code></pre>
<blockquote>
<p>AttributeError: type object 'SolutionOutputs' has no attribute
'detections'</p>
</blockquote>
<p>is the error I get if I try running, specifically it calls it on the results.detections: line
it works fine in this <a href="https://www.youtube.com/watch?v=01sAkU_NvOY&t=23323s&ab_channel=freeCodeCamp.org" rel="nofollow noreferrer">youtube tutorial</a>
at 1:43:56
I don't really know how to read the github code but <a href="https://github.com/google/mediapipe/blob/master/mediapipe/python/solutions/face_detection.py" rel="nofollow noreferrer">here's</a> the link
I do have</p>
<pre><code>mpFD = mp.solutions.face_detection # FD = face_detection
fD = mpFD.FaceDetection()
</code></pre>
<p>defined before the function already.
Is this an issue with my code or is it something else?</p>
| [
{
"answer_id": 74141655,
"author": "zx8754",
"author_id": 680068,
"author_profile": "https://Stackoverflow.com/users/680068",
"pm_score": 1,
"selected": false,
"text": "library(ggplot2)\nlibrary(dplyr)\nlibrary(ggsankey)\n\n# fill NAs from last value\ndf[] <- t(apply(df, 1, zoo::na.locf,... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141367",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12279797/"
] |
74,141,374 | <p>I am a beginner in Unity and I am currently making a simple game. I recently solved my problem of scrolling two objects at the same time, but the vertical layout will put the other at the bottom. The answer came from the question I posted a while ago which is to use <code>LayoutElement</code> component. It does work in general, but when I start or play in the Unity it does not work at the start, I need to disable it and enable at runtime for it to work.</p>
<p>Just to add, I noticed that the <code>ObjectiveItem</code> object is 0 everytime I start or play the project. And the height will set to its children's height when I disable and enable the <code>LayoutElement</code> component.</p>
<p>I think the <code>Content Size Fitter</code> sets the height to 0. because when I mess with any height related settings in like when I uncheck the height value in <code>Child Force Expand</code> it will set the height to the height of its children same goes to the <code>Child Force Expand</code> of the <code>Lines</code> and <code>Items</code> objects. And like I mentioned in the start, when I disable and enable the <code>LayoutElement</code> in the <code>ObjectiveItem</code> object it will set the height of the children or even when setting the object itself inactive and active. The main problem is that the <code>height</code> is set to 0 at the start of the game.</p>
<p><a href="https://i.stack.imgur.com/Uwus2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Uwus2.png" alt="enter image description here" /></a></p>
<p>This is the object (<code>ObjectiveItem</code>) that is set to the Content of the <code>ScrollRect</code>. The object already has <code>Vertical Layout Group</code> and <code>Content Size Fitter</code> to get the height of its children.</p>
<p><a href="https://i.stack.imgur.com/QK9Yo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QK9Yo.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74148240,
"author": "Horothenic",
"author_id": 9855648,
"author_profile": "https://Stackoverflow.com/users/9855648",
"pm_score": 0,
"selected": false,
"text": "VerticalLayoutGroup"
},
{
"answer_id": 74150461,
"author": "derHugo",
"author_id": 7111561,
"... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141374",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11050464/"
] |
74,141,412 | <p>I've no experience with php, due to an old formtomail cgi script no longer working on a host server I decided to switch to a simple html to php mail for a contact page on a website. I took a template online and set up the html page but having difficulty editing the mail.php file so that all the data requests on my html form get emailed over to me. The template I use just had email and message. My html contact page has different requests i.e contact name not name, and asks for more information. so I need the php form to email all this information and need help on how to edit the php file to include whats requested on the html contact page.</p>
<p>I have a contact form HTML page with the following:</p>
<pre><code><form action="mail.php" method="POST">
<p class="bodytextgrey">
Contact Name:<br /><input type="text" name="contact name" size="50" /><br />
Firm Name:<br /><input type="test" name="firm name" /><br /><br />
E-mail: (Please enter the email address you would like the document is to be sent to)<br />
<input type="text" name="email" size="50" /><br />
Job Number:<br /><input type="test" name="job number" /><br /><br />
Document you require:<br /><form action=""><select name="Document you require">
<option value="Data Sheet">Data Sheet</option>
</select><br/ ><br />
Discount code:<br /><input type="text" name="Discount code" size="20" /><br /><br />
<input type="submit" value="Send"><input type="reset" value="Clear">
</form>
</code></pre>
<p>I then have a mail.php with this (MY EMAIL is my actual email):</p>
<pre><code><?php $name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$formcontent="From: $name \n Message: $message";
$recipient = "MY EMAIL";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!";
?>
</code></pre>
<p>Would also like it to bring up an existing thank you.html page rather than just a thankyou word on a white page so also need help adding in how I link this.</p>
<p>Any help would be appreciated</p>
| [
{
"answer_id": 74141459,
"author": "Warorua Alex",
"author_id": 16911437,
"author_profile": "https://Stackoverflow.com/users/16911437",
"pm_score": -1,
"selected": false,
"text": "header('location: thankyou.html');\n"
},
{
"answer_id": 74142132,
"author": "WOUNDEDStevenJones"... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141412",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20292426/"
] |
74,141,415 | <p>I am creating a new User with wp_insert_user() function in an AJAX call. After that I need to add the phone number as custom field, so I need to use the wordpress hook user_register and I don't know how to use it.</p>
<pre><code>add_action('wp_ajax_nopriv_register', 'register_user');
add_action('wp_ajax_register', 'register_user');
function registrar_cliente(){
if(isset($_POST['dataForPHP'])){
$phone = wp_filter_nohtml_kses($_POST['dataForPHP'][0]);
$name = wp_filter_nohtml_kses($_POST['dataForPHP'][1]);
$email = wp_filter_nohtml_kses($_POST['dataForPHP'][2]);
$userdata = [//adding data];
$user_id = wp_insert_user($userdata);
}
}
</code></pre>
<p>How can I use now <code>do_action( 'user_register', int $user_id, array $userdata )</code> in order to insert $phone to the user in a custom field?</p>
| [
{
"answer_id": 74141459,
"author": "Warorua Alex",
"author_id": 16911437,
"author_profile": "https://Stackoverflow.com/users/16911437",
"pm_score": -1,
"selected": false,
"text": "header('location: thankyou.html');\n"
},
{
"answer_id": 74142132,
"author": "WOUNDEDStevenJones"... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141415",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15291450/"
] |
74,141,417 | <p>I have a rather messy dataframe in which I need to assign first 3 rows as a multilevel column names.
This is my dataframe and I need index 3, 4 and 5 to be my multiindex column names.
<a href="https://i.stack.imgur.com/WaXsB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WaXsB.png" alt="enter image description here" /></a></p>
<p>For example, 'MINERAL TOTAL' should be the level 0 until next item; 'TRATAMIENTO (ts)' should be level 1 until 'LEY Cu(%)' comes up.</p>
<p>What I need actually is try to emulate what pandas.read_excel does when 'header' is specified with multiple rows.</p>
<p>Please help!</p>
<p>I am trying this, but no luck at all:</p>
<pre><code>pd.DataFrame(data=df.iloc[3:, :].to_numpy(), columns=tuple(df.iloc[:3, :].to_numpy(dtype='str')))
</code></pre>
| [
{
"answer_id": 74142029,
"author": "oliverjwroberts",
"author_id": 13937247,
"author_profile": "https://Stackoverflow.com/users/13937247",
"pm_score": 3,
"selected": true,
"text": "header"
},
{
"answer_id": 74143106,
"author": "suvayu",
"author_id": 289784,
"author_pr... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141417",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8798635/"
] |
74,141,428 | <p>Here is a subset of my table:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th style="text-align: left;">id</th>
<th style="text-align: center;">date</th>
<th style="text-align: right;">value</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">1</td>
<td style="text-align: center;">01/01/2022</td>
<td style="text-align: right;">5</td>
</tr>
<tr>
<td style="text-align: left;">1</td>
<td style="text-align: center;">02/02/2022</td>
<td style="text-align: right;">0</td>
</tr>
<tr>
<td style="text-align: left;">1</td>
<td style="text-align: center;">03/01/2022</td>
<td style="text-align: right;">0</td>
</tr>
<tr>
<td style="text-align: left;">1</td>
<td style="text-align: center;">04/02/2022</td>
<td style="text-align: right;">10</td>
</tr>
<tr>
<td style="text-align: left;">2</td>
<td style="text-align: center;">01/04/2022</td>
<td style="text-align: right;">5</td>
</tr>
<tr>
<td style="text-align: left;">2</td>
<td style="text-align: center;">02/04/2022</td>
<td style="text-align: right;">3</td>
</tr>
<tr>
<td style="text-align: left;">2</td>
<td style="text-align: center;">03/04/2022</td>
<td style="text-align: right;">0</td>
</tr>
<tr>
<td style="text-align: left;">2</td>
<td style="text-align: center;">04/04/2022</td>
<td style="text-align: right;">10</td>
</tr>
</tbody>
</table>
</div>
<p>Where there are 0s in the value field, i would like to replace them with the non-zero value that occurs after the sequence of 0s are over, partitioned by id.</p>
<p>I have tried to use LAG but im really struggling as it takes the value above the current value in the table.</p>
<p>Any help will be appreciated.</p>
<p>Transformed table to look like</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th style="text-align: left;">id</th>
<th style="text-align: center;">date</th>
<th style="text-align: right;">value</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">1</td>
<td style="text-align: center;">01/01/2022</td>
<td style="text-align: right;">5</td>
</tr>
<tr>
<td style="text-align: left;">1</td>
<td style="text-align: center;">02/02/2022</td>
<td style="text-align: right;">10</td>
</tr>
<tr>
<td style="text-align: left;">1</td>
<td style="text-align: center;">03/01/2022</td>
<td style="text-align: right;">10</td>
</tr>
<tr>
<td style="text-align: left;">1</td>
<td style="text-align: center;">04/02/2022</td>
<td style="text-align: right;">10</td>
</tr>
<tr>
<td style="text-align: left;">2</td>
<td style="text-align: center;">01/04/2022</td>
<td style="text-align: right;">5</td>
</tr>
<tr>
<td style="text-align: left;">2</td>
<td style="text-align: center;">02/04/2022</td>
<td style="text-align: right;">3</td>
</tr>
<tr>
<td style="text-align: left;">2</td>
<td style="text-align: center;">03/04/2022</td>
<td style="text-align: right;">10</td>
</tr>
<tr>
<td style="text-align: left;">2</td>
<td style="text-align: center;">04/04/2022</td>
<td style="text-align: right;">10</td>
</tr>
</tbody>
</table>
</div> | [
{
"answer_id": 74141507,
"author": "DannySlor",
"author_id": 19174570,
"author_profile": "https://Stackoverflow.com/users/19174570",
"pm_score": 1,
"selected": true,
"text": "max() over()"
},
{
"answer_id": 74141532,
"author": "Serkan Arslan",
"author_id": 8500110,
"a... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20230453/"
] |
74,141,440 | <p>In my dockerfile I have the line</p>
<p><code>RUN [Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\oracle\instantclient_19_10", "Machine")</code></p>
<p>I get this returned, even though when I run the above command in PowerShell everything "just works"</p>
<pre><code>At line:1 char:114
+ ... = 'SilentlyContinue'; [Environment]::SetEnvironmentVariable(Path, $e ...
+ ~
Missing ')' in method call.
At line:1 char:114
+ ... SilentlyContinue'; [Environment]::SetEnvironmentVariable(Path, $env:P ...
+ ~~~~
Unexpected token 'Path' in expression or statement.
At line:1 char:118
+ ... ilentlyContinue'; [Environment]::SetEnvironmentVariable(Path, $env:Pa ...
+ ~
Missing argument in parameter list.
At line:1 char:162
+ ... entVariable(Path, $env:Path + ;C:\oracle\instantclient_19_10, Machine ...
+ ~
Missing argument in parameter list.
At line:1 char:171
+ ... ntVariable(Path, $env:Path + ;C:\oracle\instantclient_19_10, Machine)
+ ~
Unexpected token ')' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordEx
ception
+ FullyQualifiedErrorId : MissingEndParenthesisInMethodCall
</code></pre>
| [
{
"answer_id": 74141507,
"author": "DannySlor",
"author_id": 19174570,
"author_profile": "https://Stackoverflow.com/users/19174570",
"pm_score": 1,
"selected": true,
"text": "max() over()"
},
{
"answer_id": 74141532,
"author": "Serkan Arslan",
"author_id": 8500110,
"a... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141440",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3684640/"
] |
74,141,469 | <p>I am trying to change the borders of marked ellipses created using ggforce::geom_mark_ellipse(). How can I remove the borders and just keep the filled ellipses? code for reproducibility is provided below.</p>
<p><a href="https://i.stack.imgur.com/cBQl3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cBQl3.png" alt="enter image description here" /></a></p>
<pre><code>library(palmerpenguins)
library(tidyverse)
library(ggplot2)
library(ggforce)
penguins <- penguins %>%
drop_na()
penguins %>% head() %>% print()
p <- penguins %>%
ggplot(aes(x = bill_length_mm,
y = flipper_length_mm))+
geom_mark_ellipse(aes(colour=species, fill = species),
expand = unit(0.5,"mm"),
show.legend = F)+
geom_point(aes(color = species))
print(p)
</code></pre>
| [
{
"answer_id": 74141507,
"author": "DannySlor",
"author_id": 19174570,
"author_profile": "https://Stackoverflow.com/users/19174570",
"pm_score": 1,
"selected": true,
"text": "max() over()"
},
{
"answer_id": 74141532,
"author": "Serkan Arslan",
"author_id": 8500110,
"a... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141469",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6524326/"
] |
74,141,471 | <p>I have set up a login page for my web app but the site header component I created earlier appears on the top. It has a menu in it that leads to other pages, so if it's on the login page a user doesn't need to login when they can just click the menu option that will lead them to the home page.
I would like the site header to be invisible on the login, register and reset pages.<br></p>
<p><strong>index.js</strong></p>
<pre><code> return (
<BrowserRouter>
<SiteHeader />
<Routes>
<Route path="/reviews/:id" element={ <MovieReviewPage /> } />
<Route path="/movies/home" element={<HomePage />} />
<Route path="/movies/favorites" element={<FavoriteMoviesPage />} />
<Route path="/movies/upcoming" element={<UpcomingMoviesPage />} />
<Route path="/movies/:id" element={<MoviePage />} />
<Route exact path="/" element={<LoginPage />} />
<Route exact path="/register" element={<RegisterPage />} />
<Route exact path="/reset" element={<ResetPage />} />
<Route path="*" element={ <Navigate to="/" /> } />
</Routes>
</BrowserRouter>
);
};
</code></pre>
| [
{
"answer_id": 74141652,
"author": "Avetik Nersisyan",
"author_id": 14938670,
"author_profile": "https://Stackoverflow.com/users/14938670",
"pm_score": 1,
"selected": false,
"text": "export const MyLayout = ({children}) => {\n\n return (\n <>\n <SiteHeader />\n {children}\n ... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20281834/"
] |
74,141,483 | <p>I have this simple cmdlet that correctly copies files and folders to a second directory:</p>
<pre><code>Copy-Item -Path 'G:\xyz\Test\A' -Recurse -Destination 'G:\xyz\Test\B\'
</code></pre>
<p>However I am unable to tweak it to only copy the <em>latest file</em> in each folder within its folder (i.e. also copying the folder structure). I have written the following, but this doesn't copy folder names and does not go down all the hierarchies of sub-folders.</p>
<pre><code>Get-ChildItem -Path 'G:\xyz\Test\A' -Directory | ForEach-Object {
Get-ChildItem -Path 'G:\xyz\Test\A' -File -Recurse |
Sort-Object LastWriteTime | Select-Object -Last 1 |
Copy-Item -Destination 'G:\xyz\Test\B\'
}
</code></pre>
<p>Could someone please identify my errors!</p>
| [
{
"answer_id": 74141652,
"author": "Avetik Nersisyan",
"author_id": 14938670,
"author_profile": "https://Stackoverflow.com/users/14938670",
"pm_score": 1,
"selected": false,
"text": "export const MyLayout = ({children}) => {\n\n return (\n <>\n <SiteHeader />\n {children}\n ... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141483",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4919674/"
] |
74,141,486 | <p>Say I have a string of s1 and s2. I wanted to be able to make a program which tells how many times s1 appears in s2. This is my attempt:</p>
<pre><code>char1 = int(input("number of character of s1: "))
s1 = str(input("insert string 1: "))
char2 = int(input("number of character of s2: "))
s2 = str(input("insert string 2: "))
n = 0
bool = True
start = 0
while bool:
a = s2.find(s1,start)
if a == -1:
bool = False
else:
n+=1
start = a+1
print("s1 appears", n, "times in s2.")
</code></pre>
<p>For instance I have s1 as "the" and s2 as "the bird the apple the chair" then the output should be:</p>
<blockquote>
<p>s1 appears 3 times in s2.</p>
</blockquote>
<p>The problem is, I can't use some functions such as: find, sum, count, max, min, len, try, break, etc.</p>
<p>I'm still a few days old learning python, which is no wonder why I'm still learning array and string--and I can't think of a way for the alternative of the find function that I code. I know I'm very close to get the desired output (since my code actually works), however the find() function is banned</p>
| [
{
"answer_id": 74141607,
"author": "Mortz",
"author_id": 4248842,
"author_profile": "https://Stackoverflow.com/users/4248842",
"pm_score": 1,
"selected": false,
"text": "times = sum(1 if word == s1 else 0 for word in s2.split())\nprint(f's1 appears {times} times in s2') \n"
},
{
... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141486",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20254119/"
] |
74,141,523 | <p>My dataframe:</p>
<p><a href="https://i.stack.imgur.com/Bk1qY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Bk1qY.png" alt="enter image description here" /></a></p>
<p>I have to check if the value in each column matches a certain rule. For example:</p>
<ul>
<li>If column 'a' has a number, column 'b' has xx or yy, column 'c' has 1 or 2, and column 'd' has 0 -> then the output should be 'output1'</li>
<li>It is not necessary that all columns should have rules. If a rule does not exist then it should simply ignore it. E.g., for 'output3', it does not matter what is there in column 'c'.</li>
<li>If it does not match any rules, it should say 'no matches found'.</li>
</ul>
<p>Since there are so many rules, I created a dictionary of regex rules as follows:</p>
<pre class="lang-py prettyprint-override"><code>rules_dict =
{'output1': {'a': '^[0-9]*$',
'b': 'xx | yy',
'c': '^[1-2]*$',
'd': '0'},
'output2': {'a': '^[a-z]+$',
'b': 'xx | yy',
'c': '1',
'd': '0'},
'output3': {'a': '^[a-zA-Z0-9_.-]*$',
'b': 'xx | yy',
'd': '0'},
'output4': {'a': '^[0-9]*$',
'b': 'xx | yy',
'c': '^[1-2]*$',
'd': '0'}
}
</code></pre>
<p>The expected output:</p>
<p><a href="https://i.stack.imgur.com/fqqpg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fqqpg.png" alt="enter image description here" /></a></p>
<p>I used the following PySpark script:</p>
<pre class="lang-py prettyprint-override"><code>for out in rules_dict.keys():
for column, rule in rules_dict[out].items():
output_df = df.withColumn('output', F.when(df[column].rlike(rule), out).otherwise('no matches found'))
output_df.show()
</code></pre>
<p>But the output is:</p>
<p><a href="https://i.stack.imgur.com/W0Ofh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/W0Ofh.png" alt="enter image description here" /></a></p>
<p>P.S: I am doing it for a large dataset, with a large number of rules. I have only created a sample for simplifying the question.</p>
| [
{
"answer_id": 74141607,
"author": "Mortz",
"author_id": 4248842,
"author_profile": "https://Stackoverflow.com/users/4248842",
"pm_score": 1,
"selected": false,
"text": "times = sum(1 if word == s1 else 0 for word in s2.split())\nprint(f's1 appears {times} times in s2') \n"
},
{
... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141523",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13762885/"
] |
74,141,542 | <p>I am trying to find the farthest point by coordinates. I have 2 data tables:</p>
<pre><code>data={'X':[1,1,1,3,4],'Y':[1,2,4,3,5]}
data=pd.DataFrame(data)
points={'ID':['1','2','3','4'],'X':[1,2,4,5],'Y':[3,3,4,1]}
points=pd.DataFrame(points)
</code></pre>
<p>I would like to determine which point from the "points" table is the farthest one from the coordinates included in the "data" table. The calculation I wish to use is the vector distance as follows.</p>
<p>d = √(x2 −x1)2 +(y2 −y1)2</p>
<p>Based on the example, this is my "data":
<a href="https://i.stack.imgur.com/NHkER.png" rel="nofollow noreferrer">photo in link</a>
And this is "points" table:
<a href="https://i.stack.imgur.com/utIrM.png" rel="nofollow noreferrer">photo in link</a></p>
<p>I would like to indicate that the <strong>ID 4</strong> in the "points" table is the farthest point (red one in the picture) from the coordinates in the "data" table.
What I've tried:</p>
<pre><code>points['DISTANCE']=data.apply(lambda x: (np.sqrt(((x['X']-points['X'])**2)+((x['Y']-points['Y'])**2))).max(), axis=1)
</code></pre>
<p>Unfortunately the code returns a wrong result, not what I expected. ID 4 should have the most value in DISTANCE column.</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>ID</th>
<th>X</th>
<th>Y</th>
<th>DISTANCE</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>1</td>
<td>3</td>
<td>4.242641</td>
</tr>
<tr>
<td>2</td>
<td>2</td>
<td>3</td>
<td>3.605551</td>
</tr>
<tr>
<td>3</td>
<td>4</td>
<td>4</td>
<td>3.000000</td>
</tr>
<tr>
<td>4</td>
<td>1</td>
<td>5</td>
<td>2.828427</td>
</tr>
</tbody>
</table>
</div>
<p>I am asking for help in solving this problem.</p>
| [
{
"answer_id": 74141607,
"author": "Mortz",
"author_id": 4248842,
"author_profile": "https://Stackoverflow.com/users/4248842",
"pm_score": 1,
"selected": false,
"text": "times = sum(1 if word == s1 else 0 for word in s2.split())\nprint(f's1 appears {times} times in s2') \n"
},
{
... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141542",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11377790/"
] |
74,141,543 | <p>for a school project i have to use position fixed and get the cookie statement right bottom on the screen. If I try to move the element doesnt even display.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>.cookie {
position: fixed;
top: 0%;
bottom: 0%;
left: 0%;
right: 0%;
width: 100px;
height: 50px;
opacity: 50%;
float: right;
background-color: #FA0;
}
.cookie-text {
color: #FFF;
text-align: center;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><section class="cookie">
<p class="cookie-text">Cookie statement </p>
</section></code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74141607,
"author": "Mortz",
"author_id": 4248842,
"author_profile": "https://Stackoverflow.com/users/4248842",
"pm_score": 1,
"selected": false,
"text": "times = sum(1 if word == s1 else 0 for word in s2.split())\nprint(f's1 appears {times} times in s2') \n"
},
{
... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141543",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20111693/"
] |
74,141,572 | <p>Let's say I have a function Foo that takes 3 arguments. Foo for example sums these 3 numbers.</p>
<pre><code>(defun Foo (a b c)
(+ a b c)
</code></pre>
<p>Then I have have a list of these 3 values.
Is there a way of dissolving this list, so each value gets bind to the parameter?</p>
<pre><code>(setf list (list 1 2 3))
> (1 2 3)
(Foo (dissolve list))
> 6
</code></pre>
<p>Only option I came up with was using macros, but then I got error such that ,@ cannot be right after backquote.</p>
<pre><code>(defmacro dissolve (list)
`,@list)
</code></pre>
<p>I know, one of the answers is to use &rest inside Foo function, but I don't want to. I am just wondering whether there is such a construct that fixes this from outside of the function.</p>
| [
{
"answer_id": 74142165,
"author": "sds",
"author_id": 850781,
"author_profile": "https://Stackoverflow.com/users/850781",
"pm_score": 4,
"selected": true,
"text": "apply"
},
{
"answer_id": 74151387,
"author": "MRmHolub",
"author_id": 15918726,
"author_profile": "http... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141572",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15918726/"
] |
74,141,587 | <p>I have a CI Runner that automatically builds a docker image from a Dockerfile. My docker image is based on another docker image. So the beginning of my Dockerfile looks like this:</p>
<pre><code>FROM linktoimage/imagename:latest
</code></pre>
<p>Does docker check during the build process if my local version of <code>imagename</code> is still the latest (similar to docker pull? Because i noticed that my ci runner shows sn older version of <code>imagename</code> if i run <code>docker images</code> on it</p>
| [
{
"answer_id": 74141798,
"author": "Paolo",
"author_id": 3390419,
"author_profile": "https://Stackoverflow.com/users/3390419",
"pm_score": 3,
"selected": true,
"text": "--no-cache"
}
] | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141587",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10145604/"
] |
74,141,602 | <p>I'm working on a booking tool and as part of the process, users have to select a desk on the map by clicking on it.</p>
<p>Each desk is in a <code><g></code> with its own <code><title></code>, <code><path></code> and <code><text></code> elements. It seems every <code><text></code> aligns to the SVG itself, not to their parent <code><g></code>. We have like ~200 desks, so positioning every desk number is a bit too much work, plus, the floor map can change from time to time. Did I miss anything?</p>
<p>My example is a simplified version:
<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><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 453.16 313.93">
<defs>
<style>
.cls-1 {
fill: none;
stroke: #231f20;
stroke-miterlimit: 10;
}
.cls-2 {
font-size: 30px;
text-anchor: middle;
}
</style>
</defs>
<g>
<path class="cls-1" d="M122.05,61.28H.5V.5H122.05V61.28Z"/>
<text class="cls-2" x="63" y="34">001</text>
</g>
<g>
<path class="cls-1" d="M122.05,145.33H.5v-60.78H122.05v60.78Z"/>
<text class="cls-2" x="63" y="116">002</text>
</g>
<g>
<path class="cls-1" d="M122.05,229.38H.5v-60.78H122.05v60.78Z"/>
<text class="cls-2" x="63" y="200">003</text>
</g>
</svg></code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74141798,
"author": "Paolo",
"author_id": 3390419,
"author_profile": "https://Stackoverflow.com/users/3390419",
"pm_score": 3,
"selected": true,
"text": "--no-cache"
}
] | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141602",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1226126/"
] |
74,141,603 | <p>I am trying to print out a set of students in a class in a numbered list.</p>
<p>Here's the code I have</p>
<pre><code>var spanish101: Set = ["Angela", "Declan", "Aldany", "Alex", "Sonny", "Alif", "Skyla"]
var german101: Set = ["Angela", "Alex", "Declan", "Kenny", "Cynara", "Adam"]
var advancedCalculus: Set = ["Cynara", "Gabby", "Angela", "Samantha", "Ana", "Aldany", "Galina", "Jasmine"]
var artHistory: Set = ["Samantha", "Vanessa", "Aldrian", "Cynara", "Kenny", "Declan", "Skyla"]
var englishLiterature: Set = ["Gabby", "Jasmine", "Alex", "Alif", "Aldrian", "Adam", "Angela"]
var computerScience: Set = ["Galina", "Kenny", "Sonny", "Alex", "Skyla"]
var allStudents: Set = spanish101.union(german101).union(advancedCalculus).union(artHistory).union(englishLiterature).union(computerScience)
for students in allStudents
{
print(students)
}
</code></pre>
<p>I've tried doing <code>print(students.count, students)</code>, but that just prints out random numbers.</p>
<p>Unsure of why and where those numbers come from. <br />
I've tried making a nested loop with for count in 1..<students.count , but that made the list print out 16 times.</p>
<p>I want the output to look like</p>
<pre><code>1 studentName
2 studentName
3 studentName
4 studentName
...
16 studentName
</code></pre>
| [
{
"answer_id": 74141725,
"author": "Larme",
"author_id": 1801544,
"author_profile": "https://Stackoverflow.com/users/1801544",
"pm_score": 2,
"selected": false,
"text": "for anEnumerated in allStudents.enumerated() {\n print(\"\\(anEnumerated.0) - \\(anEnumerated.1)\")\n}\n"
},
{
... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141603",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20265293/"
] |
74,141,611 | <pre><code>import{useState}from'react';
export default function App() {
const[state,setState]=useState('mariam');
const[count, setCount]= useState((num)=>{
if (num>=0) {
setCount(count-1)
} else {
setCount(0)
}
});
return (
<div>
<p>{state}</p>
<input onChange={(e)=> setState(e.target.value)} />
<p>{count}</p>
<button onClick={setCount} >click</button>
</div>
)
}
</code></pre>
| [
{
"answer_id": 74141892,
"author": "JustMe",
"author_id": 19453327,
"author_profile": "https://Stackoverflow.com/users/19453327",
"pm_score": 1,
"selected": false,
"text": "const [count, setCount] = useState(0)\n\nconst decrease = () => {\n setCount(count => {\n return count = ... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141611",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16952125/"
] |
74,141,618 | <p>We have a code base that is built every night. Last night, it failed to build (without me making changes that were related to NPM libraries).</p>
<p>I got the following error:</p>
<pre><code>ERROR TS2688: Cannot find type definition file for 'keyv'.
The file is in the program because: Entry point for implicit type library 'keyv'.
</code></pre>
<p>I found that the keyv library is not in my packages json, but some other packages that are listed in package.json are using it. In the package-lock.json I found @types/keyv is used in several places.</p>
<p>Searching for the types library and looking at the change in the package-lock.json lead to this line, and this is its link:</p>
<p><a href="https://www.npmjs.com/package/@types/keyv" rel="nofollow noreferrer">https://www.npmjs.com/package/@types/keyv</a>
"This is a stub types definition. keyv provides its own type definitions, so you do not need this installed."</p>
<p>The packages using 'keyv' tried to use the @types/keyv which is deprecated.</p>
| [
{
"answer_id": 74216575,
"author": "mitchwd",
"author_id": 20345071,
"author_profile": "https://Stackoverflow.com/users/20345071",
"pm_score": 3,
"selected": false,
"text": "npm install -D keyv"
}
] | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141618",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14497873/"
] |
74,141,628 | <p>Doing a React Native update from 0.69.5 to 0.70.3.</p>
<p>App is building on both platforms, but when it runs on Metro this error comes up.</p>
<p><code>error: Error: resolveDependencies: Found duplicate dependency key 'undefined' in /Users/LA/Repo/sb-app/index.js at resolveDependencies (/Users/LA/Repo/sb-app/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro/src/DeltaBundler/graphOperations.js:484:13)</code></p>
<pre><code>error: Error: resolveDependencies: Found duplicate dependency key 'undefined' in /Users/LA/Repo/sb-app/index.js
at resolveDependencies (/Users/LA/Repo/sb-app/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro/src/DeltaBundler/graphOperations.js:484:13)
at processModule (/Users/LA/Repo/sb-app/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro/src/DeltaBundler/graphOperations.js:232:31)
at async traverseDependenciesForSingleFile (/Users/LA/Repo/sb-app/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro/src/DeltaBundler/graphOperations.js:221:3)
at async Promise.all (index 0)
at async initialTraverseDependencies (/Users/LA/Repo/sb-app/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro/src/DeltaBundler/graphOperations.js:204:3)
at async DeltaCalculator._getChangedDependencies (/Users/LA/Repo/sb-app/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro/src/DeltaBundler/DeltaCalculator.js:208:25)
at async DeltaCalculator.getDelta (/Users/LA/Repo/sb-app/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro/src/DeltaBundler/DeltaCalculator.js:90:16)
at async DeltaBundler.buildGraph (/Users/LA/Repo/sb-app/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro/src/DeltaBundler.js:56:5)
at async IncrementalBundler.buildGraphForEntries (/Users/LA/Repo/sb-app/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro/src/IncrementalBundler.js:81:19)
at async IncrementalBundler.buildGraph (/Users/LA/Repo/sb-app/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro/src/IncrementalBundler.js:161:19)
</code></pre>
<p>Following the error file locations only takes me to the 'throw' statements, and, of course there are no duplicate deps on index.js or app.tsx, as i'm assuming the error is just being thrown upwards to that file. I think...</p>
<p>Anyway, this has stumped me and my team for two days straight now, hoping someone else might have run into this and knows how to debug it. The <code>undefined</code> key is 0% helpful.</p>
<p>I haven't seen this error posted on stack or github so posting it here.</p>
| [
{
"answer_id": 74216575,
"author": "mitchwd",
"author_id": 20345071,
"author_profile": "https://Stackoverflow.com/users/20345071",
"pm_score": 3,
"selected": false,
"text": "npm install -D keyv"
}
] | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141628",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13219809/"
] |
74,141,643 | <p>Knowing that the values inside the list num, num2 will change, the idea is to sort the output list, or the lists that form the output, based on the sorted num2.
This is the code:</p>
<pre><code>letter = ['A','B','C','D','E']
num = [7,6,1,1,1]
num2 = [24000,20900,5250,4500,5000]
output = []
for i in range(len(letter)):
output.append((letter[i], num[i], num2[i]))
</code></pre>
<p>Current Output:</p>
<pre><code>[('A', 7, 24000), ('B', 6, 20900), ('C', 1, 5250), ('D', 1, 4500), ('E', 1, 5000)]
</code></pre>
<p>Expected Output:</p>
<pre><code>[(’A’, 7, 24000), (’B’, 6, 20900), (’C’, 1, 5250), (’E’, 1, 5000), (’D’, 1, 4500)]
</code></pre>
| [
{
"answer_id": 74216575,
"author": "mitchwd",
"author_id": 20345071,
"author_profile": "https://Stackoverflow.com/users/20345071",
"pm_score": 3,
"selected": false,
"text": "npm install -D keyv"
}
] | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141643",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20160297/"
] |
74,141,656 | <p>Hello I have the following problem: I have an array of objects that I need to check if the name and method are being repeated, if so add the attributes of their values and transform into a single object with the values added</p>
<pre><code>let array = [
{name: visa, method: 1, value: 55},
{name: visa, method: 1, value: 78},
{name: master, method: 2, value: 143},
{name: visa, method: 1, value: 18}
];
</code></pre>
<p>objective:</p>
<pre><code>let array = [
{name: visa, method: 1, value: 151},
{name: master, method: 2, value: 143}
];
</code></pre>
<p>Try:</p>
<pre><code> let array2 = [];
for (let j = 0; j < array.length -1; j++) {
const element = array[j];
const element2 = array[j + 1];
if(element.name === element2.name && element.method === element2.method){
element.value += element2.value;
array2.push(element);
}
}
</code></pre>
| [
{
"answer_id": 74141847,
"author": "Karma Blackshaw",
"author_id": 8749149,
"author_profile": "https://Stackoverflow.com/users/8749149",
"pm_score": 1,
"selected": false,
"text": "const array = [\n { name: 'visa', method: 1, value: 55 },\n { name: 'visa', method: 1, value: 78 },\n { n... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141656",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11699582/"
] |
74,141,677 | <p>I'm trying to reach the <code>aws_partner_event_source</code> variable that sits within sink{} inside the resource.</p>
<pre><code>resource "auth0_log_stream" "aws_logstream" {
name = "AWS Eventbridge Auth0 Log Stream"
type = "eventbridge"
status = "active"
sink {
aws_account_id = "xxx"
aws_region = "eu-west-1"
aws_partner_event_source = "xxx"
}
}
resource "aws_cloudwatch_event_bus" "event_bridge_event_bus" {
event_source_name = auth0_log_stream.aws_logstream.sink[aws_partner_event_source]
}
</code></pre>
<p>This however, doesn't work. I get:
<code>A reference to a resource type must be followed by at least one attribute access, specifying the resource name.</code></p>
<p>I also tried:</p>
<pre><code>event_source_name = auth0_log_stream.aws_logstream.sink[2]
</code></pre>
<p>Which throws:</p>
<p><code>auth0_log_stream.aws_logstream.sink is list of object with 1 element │ │ The given key does not identify an element in this collection value.</code></p>
<p>These are the possible solutions I found when looking through Terraform Variable docs, but I can't seem to get it to work. Any help appreciated, thanks.</p>
| [
{
"answer_id": 74141752,
"author": "javier",
"author_id": 13175646,
"author_profile": "https://Stackoverflow.com/users/13175646",
"pm_score": 0,
"selected": false,
"text": "auth0_log_stream.aws_logstream.sink.aws_partner_event_source\n"
},
{
"answer_id": 74142078,
"author": "... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10830515/"
] |
74,141,691 | <p>trying to solve this problem:
This function will take an object representing a student's data, a key that needs changing, and its English translation.</p>
<p>and so far I managed to solve it with this code:</p>
<pre><code>function translateKey(student, keyToChange, translation) {
student[translation] = student[keyToChange];
delete student[keyToChange];
return student;
}
const student = {
firstName: "Napoleon",
surname: "Bonaparte",
ilsSontMorts: true,
};
console.log(translateKey(student, "ilsSontMorts", "isDead"));
</code></pre>
<p>but the second request is to return these changes into a NEW OBJECT, with the key successfully translated E.g:</p>
<pre><code>{
firstName: "Napoleon",
surname: "Bonaparte",
isDead: true,'
}
</code></pre>
<p>I tried different "solutions" like</p>
<pre><code>return new Object(student)
</code></pre>
<p>but it doesn't work.. how can I return my results as new object?</p>
<p>thank you for your support.</p>
| [
{
"answer_id": 74141752,
"author": "javier",
"author_id": 13175646,
"author_profile": "https://Stackoverflow.com/users/13175646",
"pm_score": 0,
"selected": false,
"text": "auth0_log_stream.aws_logstream.sink.aws_partner_event_source\n"
},
{
"answer_id": 74142078,
"author": "... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141691",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19459850/"
] |
74,141,712 | <p>I am working on a project off codecademy focusing on creating custom iterable classes and having trouble figuring out this section.</p>
<p>I have a list of dictionaries of students, example below:</p>
<pre><code>student_roster = [
{
"name": "Karina M",
"age": 8,
"height": 48,
"favorite_subject": "Math",
"favorite_animal": "Dog"
},
{
"name": "Yori K",
"age": 7,
"height": 50,
"favorite_subject": "Art",
"favorite_animal": "Cat"
},
{
"name": "Alex C",
"age": 7,
"height": 47,
"favorite_subject": "Science",
"favorite_animal": "Cow"
}]
</code></pre>
<p>What I need to do is iterate through the dictionaries in this list, and if a particular student's "favorite_subject" is either "Math" or "Science", I need to grab their name and add them to a separate list.</p>
<p>I have tried multiple options and but I seem to keep adding EVERYONE to my new list, as the dictionary, rather than just grabbing only the value of their name to add to a list.</p>
<p>The end goal is to have a list:</p>
<p>stem = [Karina M, Alex C, etc]</p>
<p>I have tried a number of attempts, but for example, my most recent attempt. This is within the custom class created:</p>
<pre><code>def get_students_with_subject(self):
stem = []
for i in range(len(student_roster)):
for key, value in student_roster[i].items():
if student_roster[i][key] == "Math" or "Science":
stem.append(student_roster[i])
</code></pre>
<p>When this runs, however, I am just adding every dictionary in my list to the new, stem list and it's not parsing out the specific values.</p>
<p>I have also appended the stem list with:</p>
<pre><code>stem.append(student_roster[i][key])
</code></pre>
<p>But that then adds all values from all dictionaries to the list and I can't figure out how to add JUST the names of JUST the dictionaries that included "favorite_subject" == "Math" or "Science"</p>
<p>I am still learning so any help would be very appreciated.</p>
| [
{
"answer_id": 74141752,
"author": "javier",
"author_id": 13175646,
"author_profile": "https://Stackoverflow.com/users/13175646",
"pm_score": 0,
"selected": false,
"text": "auth0_log_stream.aws_logstream.sink.aws_partner_event_source\n"
},
{
"answer_id": 74142078,
"author": "... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20074479/"
] |
74,141,719 | <p>I am trying to write a script in python which could allow me to move zip files to a new folder based on their names, but I am struggling with it as I cannot figure out how to make python read the zip files name and move it to relevant folders. Any help would be appreciated.</p>
<p>zip file names are
12345788_CATPICC1_2022_01_10_08_21_31.zip
90234578_CATPICC1_2022_01_10_08_21_31.zip
96352536_CATPICC2_2022_01_10_08_21_31.zip
78541296_CATPICC2_2022_01_10_08_21_31.zip</p>
<p>Folders where above zip files need to go:
Markky wool (CATPICC1)
Markky wool (CATPICC2)</p>
<p>when moving zip file python needs to read CATPICC1 from 12345788_CATPICC1_2022_01_10_08_21_31.zip and move it to Markky wool (CATPICC1) and if zip file name is 78541296_CATPICC2_2022_01_10_08_21_31.zip then move it to Markky wool (CATPICC2)</p>
<p>i have thousands of files like these and i want to move each of them to a folder with matching name e.g., 12345788_CATPICC1_2022_01_10_08_21_31.zip to Markky wool (CATPICC1)</p>
| [
{
"answer_id": 74141917,
"author": "TheDataScienceNinja",
"author_id": 10929995,
"author_profile": "https://Stackoverflow.com/users/10929995",
"pm_score": 1,
"selected": false,
"text": "from pathlib import Path\nimport os\nimport shutil\n\npath = Path.cwd() # insert your path\n\nfiles =... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141719",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20292356/"
] |
74,141,749 | <p>I have accidentally made '1' the default value for the models.DateField().
Now Django throws an error everytime I try to migrate, even if I delete the CharacterField / change the default value using (default=datetime.now()).</p>
<p>Is there a way to fix this?</p>
<pre><code>Applying mainApp.0006_test_date...Traceback (most recent call last):
File "/Users/di/Code/Schule/GymnasiumApp/manage.py", line 22, in <module>
main()
File "/Users/di/Code/Schule/GymnasiumApp/manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/Users/di/Code/Schule/GymnasiumApp/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
utility.execute()
File "/Users/di/Code/Schule/GymnasiumApp/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 440, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/di/Code/Schule/GymnasiumApp/venv/lib/python3.10/site-packages/django/core/management/base.py", line 402, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/di/Code/Schule/GymnasiumApp/venv/lib/python3.10/site-packages/django/core/management/base.py", line 448, in execute
output = self.handle(*args, **options)
File "/Users/di/Code/Schule/GymnasiumApp/venv/lib/python3.10/site-packages/django/core/management/base.py", line 96, in wrapped
res = handle_func(*args, **kwargs)
File "/Users/di/Code/Schule/GymnasiumApp/venv/lib/python3.10/site-packages/django/core/management/commands/migrate.py", line 349, in handle
post_migrate_state = executor.migrate(
File "/Users/di/Code/Schule/GymnasiumApp/venv/lib/python3.10/site-packages/django/db/migrations/executor.py", line 135, in migrate
state = self._migrate_all_forwards(
File "/Users/di/Code/Schule/GymnasiumApp/venv/lib/python3.10/site-packages/django/db/migrations/executor.py", line 167, in _migrate_all_forwards
state = self.apply_migration(
File "/Users/di/Code/Schule/GymnasiumApp/venv/lib/python3.10/site-packages/django/db/migrations/executor.py", line 252, in apply_migration
state = migration.apply(state, schema_editor)
File "/Users/di/Code/Schule/GymnasiumApp/venv/lib/python3.10/site-packages/django/db/migrations/migration.py", line 130, in apply
operation.database_forwards(
File "/Users/di/Code/Schule/GymnasiumApp/venv/lib/python3.10/site-packages/django/db/migrations/operations/fields.py", line 108, in database_forwards
schema_editor.add_field(
File "/Users/di/Code/Schule/GymnasiumApp/venv/lib/python3.10/site-packages/django/db/backends/sqlite3/schema.py", line 394, in add_field
self._remake_table(model, create_field=field)
File "/Users/di/Code/Schule/GymnasiumApp/venv/lib/python3.10/site-packages/django/db/backends/sqlite3/schema.py", line 237, in _remake_table
self.effective_default(create_field),
File "/Users/di/Code/Schule/GymnasiumApp/venv/lib/python3.10/site-packages/django/db/backends/base/schema.py", line 423, in effective_default
return field.get_db_prep_save(self._effective_default(field), self.connection)
File "/Users/di/Code/Schule/GymnasiumApp/venv/lib/python3.10/site-packages/django/db/models/fields/__init__.py", line 925, in get_db_prep_save
return self.get_db_prep_value(value, connection=connection, prepared=False)
File "/Users/di/Code/Schule/GymnasiumApp/venv/lib/python3.10/site-packages/django/db/models/fields/__init__.py", line 1438, in get_db_prep_value
value = self.get_prep_value(value)
File "/Users/di/Code/Schule/GymnasiumApp/venv/lib/python3.10/site-packages/django/db/models/fields/__init__.py", line 1433, in get_prep_value
return self.to_python(value)
File "/Users/di/Code/Schule/GymnasiumApp/venv/lib/python3.10/site-packages/django/db/models/fields/__init__.py", line 1389, in to_python
parsed = parse_date(value)
File "/Users/di/Code/Schule/GymnasiumApp/venv/lib/python3.10/site-packages/django/utils/dateparse.py", line 74, in parse_date
return datetime.date.fromisoformat(value)
TypeError: fromisoformat: argument must be str
</code></pre>
| [
{
"answer_id": 74141959,
"author": "Lucas Grugru",
"author_id": 16984466,
"author_profile": "https://Stackoverflow.com/users/16984466",
"pm_score": 2,
"selected": false,
"text": "makemigrations"
}
] | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141749",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18298825/"
] |
74,141,764 | <p>I have a simple antd select which has three options ( "Jack", "Lucy" and "Laura"). Lucy is default value. I have h2 that displays value of select when I change any value. When I click "Jack", it displays: "Field value is Jack" and same happens for other two values as well. I am using onChange event to catch the value and then store it in a state and then display it. Problem is I want to display "Field value is lucy" when page loads and I am not able to achieve this. When I change value to other than lucy and again come back to lucy then onChange event captures the value of lucy in state and it gets displayed, but I want to display its value from start, when page loads without changing value other than lucy. How can I extract default value of this antd select?</p>
<p>Here is code: <a href="https://stackblitz.com/edit/react-ey3kfq?file=src%2FApp.js,src%2Fstyle.css" rel="nofollow noreferrer">https://stackblitz.com/edit/react-ey3kfq?file=src%2FApp.js,src%2Fstyle.css</a></p>
<p>Help would be greatly appreciated.</p>
| [
{
"answer_id": 74141959,
"author": "Lucas Grugru",
"author_id": 16984466,
"author_profile": "https://Stackoverflow.com/users/16984466",
"pm_score": 2,
"selected": false,
"text": "makemigrations"
}
] | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141764",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19556024/"
] |
74,141,770 | <p>I want to open a presentation with a specific slide on. I know the slideId (4540) which is different from slide number(4). I tried the following urls but they always opens with slide 1.</p>
<pre><code>https://xyzsolutions.sharepoint.com/sites/2021/Shared Documents/General/xyzfolder/xyzppt.pptx?&web=1&wdSlideId=4540
https://xyzsolutions.sharepoint.com/sites/2021/Shared Documents/General/xyzfolder/xyzppt.pptx?&web=1&wdSlideNumber=4
</code></pre>
<p>what is the correct URL to be used?</p>
<p><a href="https://answers.microsoft.com/en-us/msoffice/forum/all/open-an-o365-powerpoint-file-in-presentation-mode/9b922332-4198-46c8-b1ac-62fa9f3a123d" rel="nofollow noreferrer">Reference</a></p>
| [
{
"answer_id": 74229575,
"author": "codeye",
"author_id": 4786776,
"author_profile": "https://Stackoverflow.com/users/4786776",
"pm_score": 3,
"selected": true,
"text": "https://xyzsolutions.sharepoint.com/sites/2021/Shared Documents/General/xyzfolder/xyzppt.pptx?&web=1&nav=eyJzSWQiOjI1O... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74141770",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4670408/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.